From f37fffc44fb1ddc8177bd24dfb44d830221e2479 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 9 Dec 2019 10:52:45 -0800 Subject: [PATCH 001/337] feat!: remove deprecated timestampInSnapshots setting (#808) --- dev/src/index.ts | 64 +----------------------------------------- dev/src/serializer.ts | 10 +------ dev/src/types.ts | 21 -------------- dev/test/index.ts | 23 +++------------ dev/test/timestamp.ts | 21 -------------- dev/test/typescript.ts | 2 -- types/firestore.d.ts | 21 -------------- 7 files changed, 6 insertions(+), 156 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index 7c7d66e60..df3510023 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -258,7 +258,7 @@ export class Firestore { * The configuration options for the GAPIC client. * @private */ - _settings: Settings = {}; + private _settings: Settings = {}; /** * Whether the initialization settings can still be changed by invoking @@ -317,20 +317,6 @@ export class Firestore { * can specify a `keyFilename` instead. * @param {string=} settings.host The host to connect to. * @param {boolean=} settings.ssl Whether to use SSL when connecting. - * @param {boolean=} settings.timestampsInSnapshots Specifies whether to use - * `Timestamp` objects for timestamp fields in `DocumentSnapshot`s. This is - * enabled by default and should not be disabled. - *
Previously, Firestore returned timestamp fields as `Date` but `Date` - * only supports millisecond precision, which leads to truncation and causes - * unexpected behavior when using a timestamp from a snapshot as a part of a - * subsequent query. - *
So now Firestore returns `Timestamp` values instead of `Date`, - * avoiding this kind of problem. - *
To opt into the old behavior of returning `Date` objects, you can - * temporarily set `timestampsInSnapshots` to false. - *
WARNING: This setting will be removed in a future release. You should - * update your code to expect `Timestamp` objects and stop using the - * `timestampsInSnapshots` setting. */ constructor(settings?: Settings) { const libraryHeader = { @@ -420,12 +406,6 @@ export class Firestore { settings(settings: Settings): void { validateObject('settings', settings); validateString('settings.projectId', settings.projectId, {optional: true}); - validateBoolean( - 'settings.timestampsInSnapshots', - // tslint:disable-next-line deprecation - settings.timestampsInSnapshots, - {optional: true} - ); if (this._settingsFrozen) { throw new Error( @@ -441,13 +421,6 @@ export class Firestore { } private validateAndApplySettings(settings: Settings): void { - validateBoolean( - 'settings.timestampsInSnapshots', - // tslint:disable-next-line deprecation - settings.timestampsInSnapshots, - {optional: true} - ); - if (settings.projectId !== undefined) { validateString('settings.projectId', settings.projectId); this._projectId = settings.projectId; @@ -1043,41 +1016,6 @@ export class Firestore { * @return A Promise that resolves when the client is initialized. */ async initializeIfNeeded(requestTag: string): Promise { - if (!this._settingsFrozen) { - // Nobody should set timestampsInSnapshots anymore, but the error depends - // on whether they set it to true or false... - // tslint:disable-next-line deprecation - if (this._settings.timestampsInSnapshots === true) { - console.error(` - The timestampsInSnapshots setting now defaults to true and you no - longer need to explicitly set it. In a future release, the setting - will be removed entirely and so it is recommended that you remove it - from your firestore.settings() call now.`); - // tslint:disable-next-line deprecation - } else if (this._settings.timestampsInSnapshots === false) { - console.error(` - The timestampsInSnapshots setting will soon be removed. YOU MUST UPDATE - YOUR CODE. - - To hide this warning, stop using the timestampsInSnapshots setting in your - firestore.settings({ ... }) call. - - Once you remove the setting, Timestamps stored in Cloud Firestore will be - read back as Firebase Timestamp objects instead of as system Date objects. - So you will also need to update code expecting a Date to instead expect a - Timestamp. For example: - - // Old: - const date = snapshot.get('created_at'); - // New: - const timestamp = snapshot.get('created_at'); - const date = timestamp.toDate(); - - Please audit all existing usages of Date when you enable the new - behavior.`); - } - } - this._settingsFrozen = true; if (this._projectId === undefined) { diff --git a/dev/src/serializer.ts b/dev/src/serializer.ts index dcfe0ea7c..8828a9f1e 100644 --- a/dev/src/serializer.ts +++ b/dev/src/serializer.ts @@ -52,7 +52,6 @@ export interface Serializable { * @private */ export class Serializer { - private timestampsInSnapshots: boolean; private createReference: (path: string) => DocumentReference; constructor(firestore: Firestore) { @@ -60,13 +59,6 @@ export class Serializer { // its `.doc()` method. This avoid a circular reference, which breaks // JSON.stringify(). this.createReference = path => firestore.doc(path); - // tslint:disable-next-line deprecation - if (firestore._settings.timestampsInSnapshots === undefined) { - this.timestampsInSnapshots = true; - } else { - // tslint:disable-next-line deprecation - this.timestampsInSnapshots = firestore._settings.timestampsInSnapshots; - } } /** @@ -218,7 +210,7 @@ export class Serializer { } case 'timestampValue': { const timestamp = Timestamp.fromProto(proto.timestampValue!); - return this.timestampsInSnapshots ? timestamp : timestamp.toDate(); + return timestamp; } case 'referenceValue': { const resourcePath = QualifiedResourcePath.fromSlashSeparatedString( diff --git a/dev/src/types.ts b/dev/src/types.ts index 0853a0683..1b216bfcb 100644 --- a/dev/src/types.ts +++ b/dev/src/types.ts @@ -69,27 +69,6 @@ export interface Settings { */ credentials?: {client_email?: string; private_key?: string}; - /** - * Specifies whether to use `Timestamp` objects for timestamp fields in - * `DocumentSnapshot`s. This is enabled by default and should not be disabled. - * - * Previously, Firestore returned timestamp fields as `Date` but `Date` only - * supports millisecond precision, which leads to truncation and causes - * unexpected behavior when using a timestamp from a snapshot as a part of a - * subsequent query. - * - * So now Firestore returns `Timestamp` values instead of `Date`, avoiding - * this kind of problem. - * - * To opt into the old behavior of returning `Date` objects, you can - * temporarily set `timestampsInSnapshots` to false. - * - * @deprecated This setting will be removed in a future release. You should - * update your code to expect `Timestamp` objects and stop using the - * `timestampsInSnapshots` setting. - */ - timestampsInSnapshots?: boolean; - /** Whether to use SSL when connecting. */ ssl?: boolean; diff --git a/dev/test/index.ts b/dev/test/index.ts index 597e1b991..30218d045 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -301,8 +301,10 @@ describe('instantiation', () => { const firestore = new Firestore.Firestore(DEFAULT_SETTINGS); firestore.settings({foo: 'bar'}); - expect(firestore._settings.projectId).to.equal(PROJECT_ID); - expect(firestore._settings.foo).to.equal('bar'); + /* tslint:disable:no-any */ + expect((firestore as any)._settings.projectId).to.equal(PROJECT_ID); + expect((firestore as any)._settings.foo).to.equal('bar'); + /* tslint:enable:no-any */ }); it('can only call settings() once', () => { @@ -340,23 +342,6 @@ describe('instantiation', () => { ); }); - it('validates timestampsInSnapshots is boolean', () => { - expect(() => { - const settings = {...DEFAULT_SETTINGS, timestampsInSnapshots: 1337}; - new Firestore.Firestore(settings as InvalidApiUsage); - }).to.throw( - 'Value for argument "settings.timestampsInSnapshots" is not a valid boolean.' - ); - - expect(() => { - new Firestore.Firestore(DEFAULT_SETTINGS).settings({ - timestampsInSnapshots: 1337 as InvalidApiUsage, - }); - }).to.throw( - 'Value for argument "settings.timestampsInSnapshots" is not a valid boolean.' - ); - }); - it('validates ssl is a boolean', () => { const invalidValues = ['true', 1337]; diff --git a/dev/test/timestamp.ts b/dev/test/timestamp.ts index ce24c398c..0f638f6c9 100644 --- a/dev/test/timestamp.ts +++ b/dev/test/timestamp.ts @@ -67,27 +67,6 @@ describe('timestamps', () => { }); }); - it('converted to dates when disabled', () => { - const oldErrorLog = console.error; - // Prevent error message that prompts to enable `timestampsInSnapshots` - // behavior. - console.error = () => {}; - - return createInstance( - {timestampsInSnapshots: false}, - DOCUMENT_WITH_TIMESTAMP - ).then(firestore => { - return firestore - .doc('collectionId/documentId') - .get() - .then(res => { - expect(res.data()!['moonLanding']).to.be.instanceOf(Date); - expect(res.get('moonLanding')).to.be.instanceOf(Date); - console.error = oldErrorLog; - }); - }); - }); - it('retain seconds and nanoseconds', () => { return createInstance({}, DOCUMENT_WITH_TIMESTAMP).then(firestore => { return firestore diff --git a/dev/test/typescript.ts b/dev/test/typescript.ts index 1697e3d51..7cdd3452b 100644 --- a/dev/test/typescript.ts +++ b/dev/test/typescript.ts @@ -39,7 +39,6 @@ xdescribe('firestore.d.ts', () => { const firestore: Firestore = new Firestore({ keyFilename: 'foo', projectId: 'foo', - timestampsInSnapshots: true, host: 'localhost', ssl: false, otherOption: 'foo', @@ -59,7 +58,6 @@ xdescribe('firestore.d.ts', () => { firestore.settings({ keyFilename: 'foo', projectId: 'foo', - timestampsInSnapshots: true, otherOption: 'foo', }); const collRef: CollectionReference = firestore.collection('coll'); diff --git a/types/firestore.d.ts b/types/firestore.d.ts index be1e8ef0e..2cc5796b3 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -77,27 +77,6 @@ declare namespace FirebaseFirestore { */ credentials?: {client_email?:string, private_key?:string}; - /** - * Specifies whether to use `Timestamp` objects for timestamp fields in - * `DocumentSnapshot`s. This is enabled by default and should not be disabled. - * - * Previously, Firestore returned timestamp fields as `Date` but `Date` only - * supports millisecond precision, which leads to truncation and causes - * unexpected behavior when using a timestamp from a snapshot as a part of a - * subsequent query. - * - * So now Firestore returns `Timestamp` values instead of `Date`, avoiding - * this kind of problem. - * - * To opt into the old behavior of returning `Date` objects, you can - * temporarily set `timestampsInSnapshots` to false. - * - * @deprecated This setting will be removed in a future release. You should - * update your code to expect `Timestamp` objects and stop using the - * `timestampsInSnapshots` setting. - */ - timestampsInSnapshots?: boolean; - /** Whether to use SSL when connecting. */ ssl?: boolean; From a9cab552a3b650fc1ec0061c388b4606ce23ebfa Mon Sep 17 00:00:00 2001 From: Lalji Kanjareeya <46327204+laljikanjareeya@users.noreply.github.com> Date: Sat, 14 Dec 2019 07:23:38 +0530 Subject: [PATCH 002/337] sample: sample for distributed counters (#814) --- samples/solution-counters.js | 68 ++++++++++++++++++++++++++ samples/test/solution-counters.test.js | 28 +++++++++++ 2 files changed, 96 insertions(+) create mode 100644 samples/solution-counters.js create mode 100644 samples/test/solution-counters.test.js diff --git a/samples/solution-counters.js b/samples/solution-counters.js new file mode 100644 index 000000000..3307ccaf5 --- /dev/null +++ b/samples/solution-counters.js @@ -0,0 +1,68 @@ +// Copyright 2019 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. + +'use strict'; +const { Firestore, FieldValue } = require('@google-cloud/firestore'); + +async function main() { + // [START increment_counter] + function incrementCounter(docRef, numShards) { + const shardId = Math.floor(Math.random() * numShards); + const shardRef = docRef.collection('shards').doc(shardId.toString()); + return shardRef.set({ count: FieldValue.increment(1) }, { merge: true }); + } + // [END increment_counter] + + // [START get_count] + async function getCount(docRef) { + const querySnapshot = await docRef.collection('shards').get(); + const documents = querySnapshot.docs; + + let count = 0; + for (const doc of documents) { + count += doc.get('count'); + } + return count; + } + // [END get_count] + + // [START delete_Docs] + async function deleteDocs(docRef) { + const shardsCollectionRef = docRef.collection('shards'); + const shardDocs = await shardsCollectionRef.select('id').get(); + let promises = []; + shardDocs.forEach(async (doc) => { + promises.push(shardsCollectionRef.doc(doc.id).delete()); + }); + return Promise.all(promises); + } + // [END delete_Docs] + + // Create a new client + const firestore = new Firestore(); + const docRef = firestore.doc('distributed_counter_samples/distributed_counter'); + const numberOfShards = 10; + // Increase the document count + return incrementCounter(docRef, numberOfShards).then(async () => { + console.log('counter increased'); + // Get document count + let count = await getCount(docRef); + console.log(`new count is : ${count}`); + // Delete the document + await deleteDocs(docRef); + console.log('Deleted the document'); + }); +} + +main(); diff --git a/samples/test/solution-counters.test.js b/samples/test/solution-counters.test.js new file mode 100644 index 000000000..2561b0e98 --- /dev/null +++ b/samples/test/solution-counters.test.js @@ -0,0 +1,28 @@ +// Copyright 2019 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. + +'use strict'; + +const { execSync } = require('child_process'); +const { assert } = require('chai'); +const exec = cmd => execSync(cmd, { encoding: 'utf8' }); + +describe('distributed counter', () => { + it('should increase, get counter and delete the docs', () => { + const output = exec('node solution-counters.js'); + assert.include(output, 'counter increased'); + assert.include(output, 'new count is : 1'); + assert.include(output, 'Deleted the document'); + }); +}); From 5000b2d4b5c528b66c5a71db343c0e4163d5d8f7 Mon Sep 17 00:00:00 2001 From: Alexander Fenster Date: Sun, 15 Dec 2019 04:18:47 -0800 Subject: [PATCH 003/337] feat!: convert Gapic client to TypeScript (#805) --- README.md | 1 + dev/conformance/runner.ts | 6 +- dev/protos/firestore_admin_v1_proto_api.d.ts | 3118 +++++++ dev/protos/firestore_admin_v1_proto_api.js | 5401 ++++++++++++ ...o_api.d.ts => firestore_v1_proto_api.d.ts} | 182 +- ...proto_api.js => firestore_v1_proto_api.js} | 359 +- dev/protos/firestore_v1beta1_proto_api.d.ts | 4264 ++++++++++ dev/protos/firestore_v1beta1_proto_api.js | 7431 +++++++++++++++++ dev/protos/google/api/client.proto | 100 + dev/protos/google/api/field_behavior.proto | 79 + dev/protos/google/api/resource.proto | 264 + .../google/firestore/admin/v1/field.proto | 6 + .../firestore/admin/v1/firestore_admin.proto | 119 +- .../google/firestore/admin/v1/index.proto | 6 + .../google/firestore/admin/v1/operation.proto | 22 +- .../google/firestore/v1/firestore.proto | 77 +- dev/protos/google/firestore/v1/query.proto | 28 +- .../google/firestore/v1beta1/firestore.proto | 77 +- .../google/firestore/v1beta1/query.proto | 10 +- dev/protos/google/protobuf/field_mask.proto | 2 +- dev/protos/google/type/latlng.proto | 1 - dev/protos/insert-license.sh | 38 + dev/protos/protos.json | 4336 +++++----- dev/protos/update.sh | 50 +- dev/src/convert.ts | 2 +- dev/src/document.ts | 2 +- dev/src/field-value.ts | 2 +- dev/src/geo-point.ts | 2 +- dev/src/index.ts | 2 +- dev/src/order.ts | 2 +- dev/src/path.ts | 2 +- dev/src/reference.ts | 2 +- dev/src/serializer.ts | 2 +- dev/src/timestamp.ts | 2 +- dev/src/transaction.ts | 2 +- dev/src/types.ts | 2 +- .../google/firestore/admin/v1/doc_field.js | 100 - .../firestore/admin/v1/doc_firestore_admin.js | 253 - .../google/firestore/admin/v1/doc_index.js | 206 - .../v1/doc/google/firestore/v1/doc_common.js | 108 - .../doc/google/firestore/v1/doc_document.js | 180 - .../doc/google/firestore/v1/doc_firestore.js | 859 -- .../v1/doc/google/firestore/v1/doc_query.js | 399 - .../v1/doc/google/firestore/v1/doc_write.js | 338 - .../doc/google/longrunning/doc_operations.js | 63 - dev/src/v1/doc/google/protobuf/doc_any.js | 137 - dev/src/v1/doc/google/protobuf/doc_empty.js | 34 - .../v1/doc/google/protobuf/doc_field_mask.js | 228 - .../v1/doc/google/protobuf/doc_timestamp.js | 117 - .../v1/doc/google/protobuf/doc_wrappers.js | 32 - dev/src/v1/doc/google/rpc/doc_status.js | 95 - dev/src/v1/firestore_admin_client.js | 1249 --- dev/src/v1/firestore_admin_client.ts | 1505 ++++ dev/src/v1/firestore_admin_client_config.json | 36 +- dev/src/v1/firestore_admin_proto_list.json | 6 +- dev/src/v1/firestore_client.js | 1544 ---- dev/src/v1/firestore_client.ts | 1312 +++ dev/src/v1/firestore_client_config.json | 51 +- dev/src/v1/firestore_proto_list.json | 4 + dev/src/v1/{index.js => index.ts} | 11 +- .../google/firestore/v1beta1/doc_common.js | 108 - .../google/firestore/v1beta1/doc_document.js | 180 - .../google/firestore/v1beta1/doc_firestore.js | 859 -- .../doc/google/firestore/v1beta1/doc_query.js | 399 - .../doc/google/firestore/v1beta1/doc_write.js | 338 - .../v1beta1/doc/google/protobuf/doc_any.js | 137 - .../v1beta1/doc/google/protobuf/doc_empty.js | 34 - .../doc/google/protobuf/doc_timestamp.js | 117 - .../doc/google/protobuf/doc_wrappers.js | 32 - dev/src/v1beta1/doc/google/rpc/doc_status.js | 95 - dev/src/v1beta1/firestore_client.js | 1544 ---- dev/src/v1beta1/firestore_client.ts | 1316 +++ dev/src/v1beta1/firestore_client_config.json | 25 +- dev/src/v1beta1/firestore_proto_list.json | 4 + dev/src/v1beta1/{index.js => index.ts} | 15 +- dev/src/watch.ts | 2 +- dev/src/write-batch.ts | 2 +- dev/synth.metadata | 28 +- dev/system-test/.eslintrc.yml | 4 + dev/system-test/firestore.ts | 1 + dev/test/document.ts | 2 +- .../{gapic-v1.js => gapic-firestore-v1.ts} | 974 +-- ...-v1beta1.js => gapic-firestore-v1beta1.ts} | 970 +-- dev/test/gapic-firestore_admin-v1.ts | 606 ++ dev/test/index.ts | 2 +- dev/test/order.ts | 2 +- dev/test/query.ts | 2 +- dev/test/timestamp.ts | 2 +- dev/test/transaction.ts | 2 +- dev/test/util/helpers.ts | 2 +- dev/test/watch.ts | 4 +- package.json | 26 +- samples/README.md | 18 + synth.metadata | 41 +- synth.py | 88 +- tsconfig.json | 12 +- 96 files changed, 29452 insertions(+), 13409 deletions(-) create mode 100644 dev/protos/firestore_admin_v1_proto_api.d.ts create mode 100644 dev/protos/firestore_admin_v1_proto_api.js rename dev/protos/{firestore_proto_api.d.ts => firestore_v1_proto_api.d.ts} (97%) rename dev/protos/{firestore_proto_api.js => firestore_v1_proto_api.js} (96%) create mode 100644 dev/protos/firestore_v1beta1_proto_api.d.ts create mode 100644 dev/protos/firestore_v1beta1_proto_api.js create mode 100644 dev/protos/google/api/client.proto create mode 100644 dev/protos/google/api/field_behavior.proto create mode 100644 dev/protos/google/api/resource.proto create mode 100755 dev/protos/insert-license.sh delete mode 100644 dev/src/v1/doc/google/firestore/admin/v1/doc_field.js delete mode 100644 dev/src/v1/doc/google/firestore/admin/v1/doc_firestore_admin.js delete mode 100644 dev/src/v1/doc/google/firestore/admin/v1/doc_index.js delete mode 100644 dev/src/v1/doc/google/firestore/v1/doc_common.js delete mode 100644 dev/src/v1/doc/google/firestore/v1/doc_document.js delete mode 100644 dev/src/v1/doc/google/firestore/v1/doc_firestore.js delete mode 100644 dev/src/v1/doc/google/firestore/v1/doc_query.js delete mode 100644 dev/src/v1/doc/google/firestore/v1/doc_write.js delete mode 100644 dev/src/v1/doc/google/longrunning/doc_operations.js delete mode 100644 dev/src/v1/doc/google/protobuf/doc_any.js delete mode 100644 dev/src/v1/doc/google/protobuf/doc_empty.js delete mode 100644 dev/src/v1/doc/google/protobuf/doc_field_mask.js delete mode 100644 dev/src/v1/doc/google/protobuf/doc_timestamp.js delete mode 100644 dev/src/v1/doc/google/protobuf/doc_wrappers.js delete mode 100644 dev/src/v1/doc/google/rpc/doc_status.js delete mode 100644 dev/src/v1/firestore_admin_client.js create mode 100644 dev/src/v1/firestore_admin_client.ts delete mode 100644 dev/src/v1/firestore_client.js create mode 100644 dev/src/v1/firestore_client.ts rename dev/src/v1/{index.js => index.ts} (63%) delete mode 100644 dev/src/v1beta1/doc/google/firestore/v1beta1/doc_common.js delete mode 100644 dev/src/v1beta1/doc/google/firestore/v1beta1/doc_document.js delete mode 100644 dev/src/v1beta1/doc/google/firestore/v1beta1/doc_firestore.js delete mode 100644 dev/src/v1beta1/doc/google/firestore/v1beta1/doc_query.js delete mode 100644 dev/src/v1beta1/doc/google/firestore/v1beta1/doc_write.js delete mode 100644 dev/src/v1beta1/doc/google/protobuf/doc_any.js delete mode 100644 dev/src/v1beta1/doc/google/protobuf/doc_empty.js delete mode 100644 dev/src/v1beta1/doc/google/protobuf/doc_timestamp.js delete mode 100644 dev/src/v1beta1/doc/google/protobuf/doc_wrappers.js delete mode 100644 dev/src/v1beta1/doc/google/rpc/doc_status.js delete mode 100644 dev/src/v1beta1/firestore_client.js create mode 100644 dev/src/v1beta1/firestore_client.ts rename dev/src/v1beta1/{index.js => index.ts} (56%) create mode 100644 dev/system-test/.eslintrc.yml rename dev/test/{gapic-v1.js => gapic-firestore-v1.ts} (56%) rename dev/test/{gapic-v1beta1.js => gapic-firestore-v1beta1.ts} (57%) create mode 100644 dev/test/gapic-firestore_admin-v1.ts diff --git a/README.md b/README.md index 552ecdf38..d1cd97732 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ has instructions for running the samples. | Sample | Source Code | Try it | | --------------------------- | --------------------------------- | ------ | | 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) | +| 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) | diff --git a/dev/conformance/runner.ts b/dev/conformance/runner.ts index 3bd342f03..41811ee47 100644 --- a/dev/conformance/runner.ts +++ b/dev/conformance/runner.ts @@ -19,10 +19,11 @@ import {CallOptions} from 'google-gax'; import * as path from 'path'; import * as protobufjs from 'protobufjs'; import * as through2 from 'through2'; -import * as proto from '../protos/firestore_proto_api'; +import * as proto from '../protos/firestore_v1_proto_api'; import { DocumentChange, + DocumentData, DocumentSnapshot, FieldPath, FieldValue, @@ -35,7 +36,6 @@ import { import {fieldsFromJson} from '../src/convert'; import {DocumentChangeType} from '../src/document-change'; import {QualifiedResourcePath} from '../src/path'; -import {DocumentData} from '../src/types'; import {isObject} from '../src/util'; import { ApiOverride, @@ -47,8 +47,6 @@ import api = proto.google.firestore.v1; // TODO(mrschmidt): Create Protobuf .d.ts file for the conformance proto type ConformanceProto = any; // tslint:disable-line:no-any -const REQUEST_TIME = 'REQUEST_TIME'; - /** List of test cases that are ignored. */ const ignoredRe: RegExp[] = []; diff --git a/dev/protos/firestore_admin_v1_proto_api.d.ts b/dev/protos/firestore_admin_v1_proto_api.d.ts new file mode 100644 index 000000000..d66a9fbdc --- /dev/null +++ b/dev/protos/firestore_admin_v1_proto_api.d.ts @@ -0,0 +1,3118 @@ +/*! + * Copyright 2019 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 $protobuf from "protobufjs"; +/** Namespace google. */ +export namespace google { + + /** Namespace firestore. */ + namespace firestore { + + /** Namespace admin. */ + namespace admin { + + /** Namespace v1. */ + namespace v1 { + + /** Properties of a Field. */ + interface IField { + + /** Field name */ + name?: (string|null); + + /** Field indexConfig */ + indexConfig?: (google.firestore.admin.v1.Field.IIndexConfig|null); + } + + /** Represents a Field. */ + class Field implements IField { + + /** + * Constructs a new Field. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IField); + + /** Field name. */ + public name: string; + + /** Field indexConfig. */ + public indexConfig?: (google.firestore.admin.v1.Field.IIndexConfig|null); + } + + namespace Field { + + /** Properties of an IndexConfig. */ + interface IIndexConfig { + + /** IndexConfig indexes */ + indexes?: (google.firestore.admin.v1.IIndex[]|null); + + /** IndexConfig usesAncestorConfig */ + usesAncestorConfig?: (boolean|null); + + /** IndexConfig ancestorField */ + ancestorField?: (string|null); + + /** IndexConfig reverting */ + reverting?: (boolean|null); + } + + /** Represents an IndexConfig. */ + class IndexConfig implements IIndexConfig { + + /** + * Constructs a new IndexConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.Field.IIndexConfig); + + /** IndexConfig indexes. */ + public indexes: google.firestore.admin.v1.IIndex[]; + + /** IndexConfig usesAncestorConfig. */ + public usesAncestorConfig: boolean; + + /** IndexConfig ancestorField. */ + public ancestorField: string; + + /** IndexConfig reverting. */ + public reverting: boolean; + } + } + + /** Represents a FirestoreAdmin */ + class FirestoreAdmin extends $protobuf.rpc.Service { + + /** + * Constructs a new FirestoreAdmin service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Calls CreateIndex. + * @param request CreateIndexRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public createIndex(request: google.firestore.admin.v1.ICreateIndexRequest, callback: google.firestore.admin.v1.FirestoreAdmin.CreateIndexCallback): void; + + /** + * Calls CreateIndex. + * @param request CreateIndexRequest message or plain object + * @returns Promise + */ + public createIndex(request: google.firestore.admin.v1.ICreateIndexRequest): Promise; + + /** + * Calls ListIndexes. + * @param request ListIndexesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListIndexesResponse + */ + public listIndexes(request: google.firestore.admin.v1.IListIndexesRequest, callback: google.firestore.admin.v1.FirestoreAdmin.ListIndexesCallback): void; + + /** + * Calls ListIndexes. + * @param request ListIndexesRequest message or plain object + * @returns Promise + */ + public listIndexes(request: google.firestore.admin.v1.IListIndexesRequest): Promise; + + /** + * Calls GetIndex. + * @param request GetIndexRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Index + */ + public getIndex(request: google.firestore.admin.v1.IGetIndexRequest, callback: google.firestore.admin.v1.FirestoreAdmin.GetIndexCallback): void; + + /** + * Calls GetIndex. + * @param request GetIndexRequest message or plain object + * @returns Promise + */ + public getIndex(request: google.firestore.admin.v1.IGetIndexRequest): Promise; + + /** + * Calls DeleteIndex. + * @param request DeleteIndexRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteIndex(request: google.firestore.admin.v1.IDeleteIndexRequest, callback: google.firestore.admin.v1.FirestoreAdmin.DeleteIndexCallback): void; + + /** + * Calls DeleteIndex. + * @param request DeleteIndexRequest message or plain object + * @returns Promise + */ + public deleteIndex(request: google.firestore.admin.v1.IDeleteIndexRequest): Promise; + + /** + * Calls GetField. + * @param request GetFieldRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Field + */ + public getField(request: google.firestore.admin.v1.IGetFieldRequest, callback: google.firestore.admin.v1.FirestoreAdmin.GetFieldCallback): void; + + /** + * Calls GetField. + * @param request GetFieldRequest message or plain object + * @returns Promise + */ + public getField(request: google.firestore.admin.v1.IGetFieldRequest): Promise; + + /** + * Calls UpdateField. + * @param request UpdateFieldRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public updateField(request: google.firestore.admin.v1.IUpdateFieldRequest, callback: google.firestore.admin.v1.FirestoreAdmin.UpdateFieldCallback): void; + + /** + * Calls UpdateField. + * @param request UpdateFieldRequest message or plain object + * @returns Promise + */ + public updateField(request: google.firestore.admin.v1.IUpdateFieldRequest): Promise; + + /** + * Calls ListFields. + * @param request ListFieldsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListFieldsResponse + */ + public listFields(request: google.firestore.admin.v1.IListFieldsRequest, callback: google.firestore.admin.v1.FirestoreAdmin.ListFieldsCallback): void; + + /** + * Calls ListFields. + * @param request ListFieldsRequest message or plain object + * @returns Promise + */ + public listFields(request: google.firestore.admin.v1.IListFieldsRequest): Promise; + + /** + * Calls ExportDocuments. + * @param request ExportDocumentsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public exportDocuments(request: google.firestore.admin.v1.IExportDocumentsRequest, callback: google.firestore.admin.v1.FirestoreAdmin.ExportDocumentsCallback): void; + + /** + * Calls ExportDocuments. + * @param request ExportDocumentsRequest message or plain object + * @returns Promise + */ + public exportDocuments(request: google.firestore.admin.v1.IExportDocumentsRequest): Promise; + + /** + * Calls ImportDocuments. + * @param request ImportDocumentsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public importDocuments(request: google.firestore.admin.v1.IImportDocumentsRequest, callback: google.firestore.admin.v1.FirestoreAdmin.ImportDocumentsCallback): void; + + /** + * Calls ImportDocuments. + * @param request ImportDocumentsRequest message or plain object + * @returns Promise + */ + public importDocuments(request: google.firestore.admin.v1.IImportDocumentsRequest): Promise; + } + + namespace FirestoreAdmin { + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#createIndex}. + * @param error Error, if any + * @param [response] Operation + */ + type CreateIndexCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#listIndexes}. + * @param error Error, if any + * @param [response] ListIndexesResponse + */ + type ListIndexesCallback = (error: (Error|null), response?: google.firestore.admin.v1.ListIndexesResponse) => void; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#getIndex}. + * @param error Error, if any + * @param [response] Index + */ + type GetIndexCallback = (error: (Error|null), response?: google.firestore.admin.v1.Index) => void; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#deleteIndex}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteIndexCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#getField}. + * @param error Error, if any + * @param [response] Field + */ + type GetFieldCallback = (error: (Error|null), response?: google.firestore.admin.v1.Field) => void; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#updateField}. + * @param error Error, if any + * @param [response] Operation + */ + type UpdateFieldCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#listFields}. + * @param error Error, if any + * @param [response] ListFieldsResponse + */ + type ListFieldsCallback = (error: (Error|null), response?: google.firestore.admin.v1.ListFieldsResponse) => void; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#exportDocuments}. + * @param error Error, if any + * @param [response] Operation + */ + type ExportDocumentsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#importDocuments}. + * @param error Error, if any + * @param [response] Operation + */ + type ImportDocumentsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of a CreateIndexRequest. */ + interface ICreateIndexRequest { + + /** CreateIndexRequest parent */ + parent?: (string|null); + + /** CreateIndexRequest index */ + index?: (google.firestore.admin.v1.IIndex|null); + } + + /** Represents a CreateIndexRequest. */ + class CreateIndexRequest implements ICreateIndexRequest { + + /** + * Constructs a new CreateIndexRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.ICreateIndexRequest); + + /** CreateIndexRequest parent. */ + public parent: string; + + /** CreateIndexRequest index. */ + public index?: (google.firestore.admin.v1.IIndex|null); + } + + /** Properties of a ListIndexesRequest. */ + interface IListIndexesRequest { + + /** ListIndexesRequest parent */ + parent?: (string|null); + + /** ListIndexesRequest filter */ + filter?: (string|null); + + /** ListIndexesRequest pageSize */ + pageSize?: (number|null); + + /** ListIndexesRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListIndexesRequest. */ + class ListIndexesRequest implements IListIndexesRequest { + + /** + * Constructs a new ListIndexesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IListIndexesRequest); + + /** ListIndexesRequest parent. */ + public parent: string; + + /** ListIndexesRequest filter. */ + public filter: string; + + /** ListIndexesRequest pageSize. */ + public pageSize: number; + + /** ListIndexesRequest pageToken. */ + public pageToken: string; + } + + /** Properties of a ListIndexesResponse. */ + interface IListIndexesResponse { + + /** ListIndexesResponse indexes */ + indexes?: (google.firestore.admin.v1.IIndex[]|null); + + /** ListIndexesResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListIndexesResponse. */ + class ListIndexesResponse implements IListIndexesResponse { + + /** + * Constructs a new ListIndexesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IListIndexesResponse); + + /** ListIndexesResponse indexes. */ + public indexes: google.firestore.admin.v1.IIndex[]; + + /** ListIndexesResponse nextPageToken. */ + public nextPageToken: string; + } + + /** Properties of a GetIndexRequest. */ + interface IGetIndexRequest { + + /** GetIndexRequest name */ + name?: (string|null); + } + + /** Represents a GetIndexRequest. */ + class GetIndexRequest implements IGetIndexRequest { + + /** + * Constructs a new GetIndexRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IGetIndexRequest); + + /** GetIndexRequest name. */ + public name: string; + } + + /** Properties of a DeleteIndexRequest. */ + interface IDeleteIndexRequest { + + /** DeleteIndexRequest name */ + name?: (string|null); + } + + /** Represents a DeleteIndexRequest. */ + class DeleteIndexRequest implements IDeleteIndexRequest { + + /** + * Constructs a new DeleteIndexRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IDeleteIndexRequest); + + /** DeleteIndexRequest name. */ + public name: string; + } + + /** Properties of an UpdateFieldRequest. */ + interface IUpdateFieldRequest { + + /** UpdateFieldRequest field */ + field?: (google.firestore.admin.v1.IField|null); + + /** UpdateFieldRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateFieldRequest. */ + class UpdateFieldRequest implements IUpdateFieldRequest { + + /** + * Constructs a new UpdateFieldRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IUpdateFieldRequest); + + /** UpdateFieldRequest field. */ + public field?: (google.firestore.admin.v1.IField|null); + + /** UpdateFieldRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Properties of a GetFieldRequest. */ + interface IGetFieldRequest { + + /** GetFieldRequest name */ + name?: (string|null); + } + + /** Represents a GetFieldRequest. */ + class GetFieldRequest implements IGetFieldRequest { + + /** + * Constructs a new GetFieldRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IGetFieldRequest); + + /** GetFieldRequest name. */ + public name: string; + } + + /** Properties of a ListFieldsRequest. */ + interface IListFieldsRequest { + + /** ListFieldsRequest parent */ + parent?: (string|null); + + /** ListFieldsRequest filter */ + filter?: (string|null); + + /** ListFieldsRequest pageSize */ + pageSize?: (number|null); + + /** ListFieldsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListFieldsRequest. */ + class ListFieldsRequest implements IListFieldsRequest { + + /** + * Constructs a new ListFieldsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IListFieldsRequest); + + /** ListFieldsRequest parent. */ + public parent: string; + + /** ListFieldsRequest filter. */ + public filter: string; + + /** ListFieldsRequest pageSize. */ + public pageSize: number; + + /** ListFieldsRequest pageToken. */ + public pageToken: string; + } + + /** Properties of a ListFieldsResponse. */ + interface IListFieldsResponse { + + /** ListFieldsResponse fields */ + fields?: (google.firestore.admin.v1.IField[]|null); + + /** ListFieldsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListFieldsResponse. */ + class ListFieldsResponse implements IListFieldsResponse { + + /** + * Constructs a new ListFieldsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IListFieldsResponse); + + /** ListFieldsResponse fields. */ + public fields: google.firestore.admin.v1.IField[]; + + /** ListFieldsResponse nextPageToken. */ + public nextPageToken: string; + } + + /** Properties of an ExportDocumentsRequest. */ + interface IExportDocumentsRequest { + + /** ExportDocumentsRequest name */ + name?: (string|null); + + /** ExportDocumentsRequest collectionIds */ + collectionIds?: (string[]|null); + + /** ExportDocumentsRequest outputUriPrefix */ + outputUriPrefix?: (string|null); + } + + /** Represents an ExportDocumentsRequest. */ + class ExportDocumentsRequest implements IExportDocumentsRequest { + + /** + * Constructs a new ExportDocumentsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IExportDocumentsRequest); + + /** ExportDocumentsRequest name. */ + public name: string; + + /** ExportDocumentsRequest collectionIds. */ + public collectionIds: string[]; + + /** ExportDocumentsRequest outputUriPrefix. */ + public outputUriPrefix: string; + } + + /** Properties of an ImportDocumentsRequest. */ + interface IImportDocumentsRequest { + + /** ImportDocumentsRequest name */ + name?: (string|null); + + /** ImportDocumentsRequest collectionIds */ + collectionIds?: (string[]|null); + + /** ImportDocumentsRequest inputUriPrefix */ + inputUriPrefix?: (string|null); + } + + /** Represents an ImportDocumentsRequest. */ + class ImportDocumentsRequest implements IImportDocumentsRequest { + + /** + * Constructs a new ImportDocumentsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IImportDocumentsRequest); + + /** ImportDocumentsRequest name. */ + public name: string; + + /** ImportDocumentsRequest collectionIds. */ + public collectionIds: string[]; + + /** ImportDocumentsRequest inputUriPrefix. */ + public inputUriPrefix: string; + } + + /** Properties of an Index. */ + interface IIndex { + + /** Index name */ + name?: (string|null); + + /** Index queryScope */ + queryScope?: (google.firestore.admin.v1.Index.QueryScope|null); + + /** Index fields */ + fields?: (google.firestore.admin.v1.Index.IIndexField[]|null); + + /** Index state */ + state?: (google.firestore.admin.v1.Index.State|null); + } + + /** Represents an Index. */ + class Index implements IIndex { + + /** + * Constructs a new Index. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IIndex); + + /** Index name. */ + public name: string; + + /** Index queryScope. */ + public queryScope: google.firestore.admin.v1.Index.QueryScope; + + /** Index fields. */ + public fields: google.firestore.admin.v1.Index.IIndexField[]; + + /** Index state. */ + public state: google.firestore.admin.v1.Index.State; + } + + namespace Index { + + /** Properties of an IndexField. */ + interface IIndexField { + + /** IndexField fieldPath */ + fieldPath?: (string|null); + + /** IndexField order */ + order?: (google.firestore.admin.v1.Index.IndexField.Order|null); + + /** IndexField arrayConfig */ + arrayConfig?: (google.firestore.admin.v1.Index.IndexField.ArrayConfig|null); + } + + /** Represents an IndexField. */ + class IndexField implements IIndexField { + + /** + * Constructs a new IndexField. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.Index.IIndexField); + + /** IndexField fieldPath. */ + public fieldPath: string; + + /** IndexField order. */ + public order: google.firestore.admin.v1.Index.IndexField.Order; + + /** IndexField arrayConfig. */ + public arrayConfig: google.firestore.admin.v1.Index.IndexField.ArrayConfig; + + /** IndexField valueMode. */ + public valueMode?: ("order"|"arrayConfig"); + } + + namespace IndexField { + + /** Order enum. */ + type Order = + "ORDER_UNSPECIFIED"| "ASCENDING"| "DESCENDING"; + + /** ArrayConfig enum. */ + type ArrayConfig = + "ARRAY_CONFIG_UNSPECIFIED"| "CONTAINS"; + } + + /** QueryScope enum. */ + type QueryScope = + "QUERY_SCOPE_UNSPECIFIED"| "COLLECTION"| "COLLECTION_GROUP"; + + /** State enum. */ + type State = + "STATE_UNSPECIFIED"| "CREATING"| "READY"| "NEEDS_REPAIR"; + } + + /** Properties of a LocationMetadata. */ + interface ILocationMetadata { + } + + /** Represents a LocationMetadata. */ + class LocationMetadata implements ILocationMetadata { + + /** + * Constructs a new LocationMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.ILocationMetadata); + } + + /** Properties of an IndexOperationMetadata. */ + interface IIndexOperationMetadata { + + /** IndexOperationMetadata startTime */ + startTime?: (google.protobuf.ITimestamp|null); + + /** IndexOperationMetadata endTime */ + endTime?: (google.protobuf.ITimestamp|null); + + /** IndexOperationMetadata index */ + index?: (string|null); + + /** IndexOperationMetadata state */ + state?: (google.firestore.admin.v1.OperationState|null); + + /** IndexOperationMetadata progressDocuments */ + progressDocuments?: (google.firestore.admin.v1.IProgress|null); + + /** IndexOperationMetadata progressBytes */ + progressBytes?: (google.firestore.admin.v1.IProgress|null); + } + + /** Represents an IndexOperationMetadata. */ + class IndexOperationMetadata implements IIndexOperationMetadata { + + /** + * Constructs a new IndexOperationMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IIndexOperationMetadata); + + /** IndexOperationMetadata startTime. */ + public startTime?: (google.protobuf.ITimestamp|null); + + /** IndexOperationMetadata endTime. */ + public endTime?: (google.protobuf.ITimestamp|null); + + /** IndexOperationMetadata index. */ + public index: string; + + /** IndexOperationMetadata state. */ + public state: google.firestore.admin.v1.OperationState; + + /** IndexOperationMetadata progressDocuments. */ + public progressDocuments?: (google.firestore.admin.v1.IProgress|null); + + /** IndexOperationMetadata progressBytes. */ + public progressBytes?: (google.firestore.admin.v1.IProgress|null); + } + + /** Properties of a FieldOperationMetadata. */ + interface IFieldOperationMetadata { + + /** FieldOperationMetadata startTime */ + startTime?: (google.protobuf.ITimestamp|null); + + /** FieldOperationMetadata endTime */ + endTime?: (google.protobuf.ITimestamp|null); + + /** FieldOperationMetadata field */ + field?: (string|null); + + /** FieldOperationMetadata indexConfigDeltas */ + indexConfigDeltas?: (google.firestore.admin.v1.FieldOperationMetadata.IIndexConfigDelta[]|null); + + /** FieldOperationMetadata state */ + state?: (google.firestore.admin.v1.OperationState|null); + + /** FieldOperationMetadata progressDocuments */ + progressDocuments?: (google.firestore.admin.v1.IProgress|null); + + /** FieldOperationMetadata progressBytes */ + progressBytes?: (google.firestore.admin.v1.IProgress|null); + } + + /** Represents a FieldOperationMetadata. */ + class FieldOperationMetadata implements IFieldOperationMetadata { + + /** + * Constructs a new FieldOperationMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IFieldOperationMetadata); + + /** FieldOperationMetadata startTime. */ + public startTime?: (google.protobuf.ITimestamp|null); + + /** FieldOperationMetadata endTime. */ + public endTime?: (google.protobuf.ITimestamp|null); + + /** FieldOperationMetadata field. */ + public field: string; + + /** FieldOperationMetadata indexConfigDeltas. */ + public indexConfigDeltas: google.firestore.admin.v1.FieldOperationMetadata.IIndexConfigDelta[]; + + /** FieldOperationMetadata state. */ + public state: google.firestore.admin.v1.OperationState; + + /** FieldOperationMetadata progressDocuments. */ + public progressDocuments?: (google.firestore.admin.v1.IProgress|null); + + /** FieldOperationMetadata progressBytes. */ + public progressBytes?: (google.firestore.admin.v1.IProgress|null); + } + + namespace FieldOperationMetadata { + + /** Properties of an IndexConfigDelta. */ + interface IIndexConfigDelta { + + /** IndexConfigDelta changeType */ + changeType?: (google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType|null); + + /** IndexConfigDelta index */ + index?: (google.firestore.admin.v1.IIndex|null); + } + + /** Represents an IndexConfigDelta. */ + class IndexConfigDelta implements IIndexConfigDelta { + + /** + * Constructs a new IndexConfigDelta. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.FieldOperationMetadata.IIndexConfigDelta); + + /** IndexConfigDelta changeType. */ + public changeType: google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType; + + /** IndexConfigDelta index. */ + public index?: (google.firestore.admin.v1.IIndex|null); + } + + namespace IndexConfigDelta { + + /** ChangeType enum. */ + type ChangeType = + "CHANGE_TYPE_UNSPECIFIED"| "ADD"| "REMOVE"; + } + } + + /** Properties of an ExportDocumentsMetadata. */ + interface IExportDocumentsMetadata { + + /** ExportDocumentsMetadata startTime */ + startTime?: (google.protobuf.ITimestamp|null); + + /** ExportDocumentsMetadata endTime */ + endTime?: (google.protobuf.ITimestamp|null); + + /** ExportDocumentsMetadata operationState */ + operationState?: (google.firestore.admin.v1.OperationState|null); + + /** ExportDocumentsMetadata progressDocuments */ + progressDocuments?: (google.firestore.admin.v1.IProgress|null); + + /** ExportDocumentsMetadata progressBytes */ + progressBytes?: (google.firestore.admin.v1.IProgress|null); + + /** ExportDocumentsMetadata collectionIds */ + collectionIds?: (string[]|null); + + /** ExportDocumentsMetadata outputUriPrefix */ + outputUriPrefix?: (string|null); + } + + /** Represents an ExportDocumentsMetadata. */ + class ExportDocumentsMetadata implements IExportDocumentsMetadata { + + /** + * Constructs a new ExportDocumentsMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IExportDocumentsMetadata); + + /** ExportDocumentsMetadata startTime. */ + public startTime?: (google.protobuf.ITimestamp|null); + + /** ExportDocumentsMetadata endTime. */ + public endTime?: (google.protobuf.ITimestamp|null); + + /** ExportDocumentsMetadata operationState. */ + public operationState: google.firestore.admin.v1.OperationState; + + /** ExportDocumentsMetadata progressDocuments. */ + public progressDocuments?: (google.firestore.admin.v1.IProgress|null); + + /** ExportDocumentsMetadata progressBytes. */ + public progressBytes?: (google.firestore.admin.v1.IProgress|null); + + /** ExportDocumentsMetadata collectionIds. */ + public collectionIds: string[]; + + /** ExportDocumentsMetadata outputUriPrefix. */ + public outputUriPrefix: string; + } + + /** Properties of an ImportDocumentsMetadata. */ + interface IImportDocumentsMetadata { + + /** ImportDocumentsMetadata startTime */ + startTime?: (google.protobuf.ITimestamp|null); + + /** ImportDocumentsMetadata endTime */ + endTime?: (google.protobuf.ITimestamp|null); + + /** ImportDocumentsMetadata operationState */ + operationState?: (google.firestore.admin.v1.OperationState|null); + + /** ImportDocumentsMetadata progressDocuments */ + progressDocuments?: (google.firestore.admin.v1.IProgress|null); + + /** ImportDocumentsMetadata progressBytes */ + progressBytes?: (google.firestore.admin.v1.IProgress|null); + + /** ImportDocumentsMetadata collectionIds */ + collectionIds?: (string[]|null); + + /** ImportDocumentsMetadata inputUriPrefix */ + inputUriPrefix?: (string|null); + } + + /** Represents an ImportDocumentsMetadata. */ + class ImportDocumentsMetadata implements IImportDocumentsMetadata { + + /** + * Constructs a new ImportDocumentsMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IImportDocumentsMetadata); + + /** ImportDocumentsMetadata startTime. */ + public startTime?: (google.protobuf.ITimestamp|null); + + /** ImportDocumentsMetadata endTime. */ + public endTime?: (google.protobuf.ITimestamp|null); + + /** ImportDocumentsMetadata operationState. */ + public operationState: google.firestore.admin.v1.OperationState; + + /** ImportDocumentsMetadata progressDocuments. */ + public progressDocuments?: (google.firestore.admin.v1.IProgress|null); + + /** ImportDocumentsMetadata progressBytes. */ + public progressBytes?: (google.firestore.admin.v1.IProgress|null); + + /** ImportDocumentsMetadata collectionIds. */ + public collectionIds: string[]; + + /** ImportDocumentsMetadata inputUriPrefix. */ + public inputUriPrefix: string; + } + + /** Properties of an ExportDocumentsResponse. */ + interface IExportDocumentsResponse { + + /** ExportDocumentsResponse outputUriPrefix */ + outputUriPrefix?: (string|null); + } + + /** Represents an ExportDocumentsResponse. */ + class ExportDocumentsResponse implements IExportDocumentsResponse { + + /** + * Constructs a new ExportDocumentsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IExportDocumentsResponse); + + /** ExportDocumentsResponse outputUriPrefix. */ + public outputUriPrefix: string; + } + + /** Properties of a Progress. */ + interface IProgress { + + /** Progress estimatedWork */ + estimatedWork?: (number|null); + + /** Progress completedWork */ + completedWork?: (number|null); + } + + /** Represents a Progress. */ + class Progress implements IProgress { + + /** + * Constructs a new Progress. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IProgress); + + /** Progress estimatedWork. */ + public estimatedWork: number; + + /** Progress completedWork. */ + public completedWork: number; + } + + /** OperationState enum. */ + type OperationState = + "OPERATION_STATE_UNSPECIFIED"| "INITIALIZING"| "PROCESSING"| "CANCELLING"| "FINALIZING"| "SUCCESSFUL"| "FAILED"| "CANCELLED"; + } + } + } + + /** Namespace api. */ + namespace api { + + /** Properties of a Http. */ + interface IHttp { + + /** Http rules */ + rules?: (google.api.IHttpRule[]|null); + } + + /** Represents a Http. */ + class Http implements IHttp { + + /** + * Constructs a new Http. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IHttp); + + /** Http rules. */ + public rules: google.api.IHttpRule[]; + } + + /** Properties of a HttpRule. */ + interface IHttpRule { + + /** HttpRule get */ + get?: (string|null); + + /** HttpRule put */ + put?: (string|null); + + /** HttpRule post */ + post?: (string|null); + + /** HttpRule delete */ + "delete"?: (string|null); + + /** HttpRule patch */ + patch?: (string|null); + + /** HttpRule custom */ + custom?: (google.api.ICustomHttpPattern|null); + + /** HttpRule selector */ + selector?: (string|null); + + /** HttpRule body */ + body?: (string|null); + + /** HttpRule additionalBindings */ + additionalBindings?: (google.api.IHttpRule[]|null); + } + + /** Represents a HttpRule. */ + class HttpRule implements IHttpRule { + + /** + * Constructs a new HttpRule. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IHttpRule); + + /** HttpRule get. */ + public get: string; + + /** HttpRule put. */ + public put: string; + + /** HttpRule post. */ + public post: string; + + /** HttpRule delete. */ + public delete: string; + + /** HttpRule patch. */ + public patch: string; + + /** HttpRule custom. */ + public custom?: (google.api.ICustomHttpPattern|null); + + /** HttpRule selector. */ + public selector: string; + + /** HttpRule body. */ + public body: string; + + /** HttpRule additionalBindings. */ + public additionalBindings: google.api.IHttpRule[]; + + /** HttpRule pattern. */ + public pattern?: ("get"|"put"|"post"|"delete"|"patch"|"custom"); + } + + /** Properties of a CustomHttpPattern. */ + interface ICustomHttpPattern { + + /** CustomHttpPattern kind */ + kind?: (string|null); + + /** CustomHttpPattern path */ + path?: (string|null); + } + + /** Represents a CustomHttpPattern. */ + class CustomHttpPattern implements ICustomHttpPattern { + + /** + * Constructs a new CustomHttpPattern. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ICustomHttpPattern); + + /** CustomHttpPattern kind. */ + public kind: string; + + /** CustomHttpPattern path. */ + public path: string; + } + + /** FieldBehavior enum. */ + type FieldBehavior = + "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"; + + /** Properties of a ResourceDescriptor. */ + interface IResourceDescriptor { + + /** ResourceDescriptor type */ + type?: (string|null); + + /** ResourceDescriptor pattern */ + pattern?: (string[]|null); + + /** ResourceDescriptor nameField */ + nameField?: (string|null); + + /** ResourceDescriptor history */ + history?: (google.api.ResourceDescriptor.History|null); + + /** ResourceDescriptor plural */ + plural?: (string|null); + + /** ResourceDescriptor singular */ + singular?: (string|null); + } + + /** Represents a ResourceDescriptor. */ + class ResourceDescriptor implements IResourceDescriptor { + + /** + * Constructs a new ResourceDescriptor. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IResourceDescriptor); + + /** ResourceDescriptor type. */ + public type: string; + + /** ResourceDescriptor pattern. */ + public pattern: string[]; + + /** ResourceDescriptor nameField. */ + public nameField: string; + + /** ResourceDescriptor history. */ + public history: google.api.ResourceDescriptor.History; + + /** ResourceDescriptor plural. */ + public plural: string; + + /** ResourceDescriptor singular. */ + public singular: string; + } + + namespace ResourceDescriptor { + + /** History enum. */ + type History = + "HISTORY_UNSPECIFIED"| "ORIGINALLY_SINGLE_PATTERN"| "FUTURE_MULTI_PATTERN"; + } + + /** Properties of a ResourceReference. */ + interface IResourceReference { + + /** ResourceReference type */ + type?: (string|null); + + /** ResourceReference childType */ + childType?: (string|null); + } + + /** Represents a ResourceReference. */ + class ResourceReference implements IResourceReference { + + /** + * Constructs a new ResourceReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IResourceReference); + + /** ResourceReference type. */ + public type: string; + + /** ResourceReference childType. */ + public childType: string; + } + } + + /** Namespace protobuf. */ + namespace protobuf { + + /** Properties of a FileDescriptorSet. */ + interface IFileDescriptorSet { + + /** FileDescriptorSet file */ + file?: (google.protobuf.IFileDescriptorProto[]|null); + } + + /** Represents a FileDescriptorSet. */ + class FileDescriptorSet implements IFileDescriptorSet { + + /** + * Constructs a new FileDescriptorSet. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileDescriptorSet); + + /** FileDescriptorSet file. */ + public file: google.protobuf.IFileDescriptorProto[]; + } + + /** Properties of a FileDescriptorProto. */ + interface IFileDescriptorProto { + + /** FileDescriptorProto name */ + name?: (string|null); + + /** FileDescriptorProto package */ + "package"?: (string|null); + + /** FileDescriptorProto dependency */ + dependency?: (string[]|null); + + /** FileDescriptorProto publicDependency */ + publicDependency?: (number[]|null); + + /** FileDescriptorProto weakDependency */ + weakDependency?: (number[]|null); + + /** FileDescriptorProto messageType */ + messageType?: (google.protobuf.IDescriptorProto[]|null); + + /** FileDescriptorProto enumType */ + enumType?: (google.protobuf.IEnumDescriptorProto[]|null); + + /** FileDescriptorProto service */ + service?: (google.protobuf.IServiceDescriptorProto[]|null); + + /** FileDescriptorProto extension */ + extension?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** FileDescriptorProto options */ + options?: (google.protobuf.IFileOptions|null); + + /** FileDescriptorProto sourceCodeInfo */ + sourceCodeInfo?: (google.protobuf.ISourceCodeInfo|null); + + /** FileDescriptorProto syntax */ + syntax?: (string|null); + } + + /** Represents a FileDescriptorProto. */ + class FileDescriptorProto implements IFileDescriptorProto { + + /** + * Constructs a new FileDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileDescriptorProto); + + /** FileDescriptorProto name. */ + public name: string; + + /** FileDescriptorProto package. */ + public package: string; + + /** FileDescriptorProto dependency. */ + public dependency: string[]; + + /** FileDescriptorProto publicDependency. */ + public publicDependency: number[]; + + /** FileDescriptorProto weakDependency. */ + public weakDependency: number[]; + + /** FileDescriptorProto messageType. */ + public messageType: google.protobuf.IDescriptorProto[]; + + /** FileDescriptorProto enumType. */ + public enumType: google.protobuf.IEnumDescriptorProto[]; + + /** FileDescriptorProto service. */ + public service: google.protobuf.IServiceDescriptorProto[]; + + /** FileDescriptorProto extension. */ + public extension: google.protobuf.IFieldDescriptorProto[]; + + /** FileDescriptorProto options. */ + public options?: (google.protobuf.IFileOptions|null); + + /** FileDescriptorProto sourceCodeInfo. */ + public sourceCodeInfo?: (google.protobuf.ISourceCodeInfo|null); + + /** FileDescriptorProto syntax. */ + public syntax: string; + } + + /** Properties of a DescriptorProto. */ + interface IDescriptorProto { + + /** DescriptorProto name */ + name?: (string|null); + + /** DescriptorProto field */ + field?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** DescriptorProto extension */ + extension?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** DescriptorProto nestedType */ + nestedType?: (google.protobuf.IDescriptorProto[]|null); + + /** DescriptorProto enumType */ + enumType?: (google.protobuf.IEnumDescriptorProto[]|null); + + /** DescriptorProto extensionRange */ + extensionRange?: (google.protobuf.DescriptorProto.IExtensionRange[]|null); + + /** DescriptorProto oneofDecl */ + oneofDecl?: (google.protobuf.IOneofDescriptorProto[]|null); + + /** DescriptorProto options */ + options?: (google.protobuf.IMessageOptions|null); + + /** DescriptorProto reservedRange */ + reservedRange?: (google.protobuf.DescriptorProto.IReservedRange[]|null); + + /** DescriptorProto reservedName */ + reservedName?: (string[]|null); + } + + /** Represents a DescriptorProto. */ + class DescriptorProto implements IDescriptorProto { + + /** + * Constructs a new DescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDescriptorProto); + + /** DescriptorProto name. */ + public name: string; + + /** DescriptorProto field. */ + public field: google.protobuf.IFieldDescriptorProto[]; + + /** DescriptorProto extension. */ + public extension: google.protobuf.IFieldDescriptorProto[]; + + /** DescriptorProto nestedType. */ + public nestedType: google.protobuf.IDescriptorProto[]; + + /** DescriptorProto enumType. */ + public enumType: google.protobuf.IEnumDescriptorProto[]; + + /** DescriptorProto extensionRange. */ + public extensionRange: google.protobuf.DescriptorProto.IExtensionRange[]; + + /** DescriptorProto oneofDecl. */ + public oneofDecl: google.protobuf.IOneofDescriptorProto[]; + + /** DescriptorProto options. */ + public options?: (google.protobuf.IMessageOptions|null); + + /** DescriptorProto reservedRange. */ + public reservedRange: google.protobuf.DescriptorProto.IReservedRange[]; + + /** DescriptorProto reservedName. */ + public reservedName: string[]; + } + + namespace DescriptorProto { + + /** Properties of an ExtensionRange. */ + interface IExtensionRange { + + /** ExtensionRange start */ + start?: (number|null); + + /** ExtensionRange end */ + end?: (number|null); + } + + /** Represents an ExtensionRange. */ + class ExtensionRange implements IExtensionRange { + + /** + * Constructs a new ExtensionRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.DescriptorProto.IExtensionRange); + + /** ExtensionRange start. */ + public start: number; + + /** ExtensionRange end. */ + public end: number; + } + + /** Properties of a ReservedRange. */ + interface IReservedRange { + + /** ReservedRange start */ + start?: (number|null); + + /** ReservedRange end */ + end?: (number|null); + } + + /** Represents a ReservedRange. */ + class ReservedRange implements IReservedRange { + + /** + * Constructs a new ReservedRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.DescriptorProto.IReservedRange); + + /** ReservedRange start. */ + public start: number; + + /** ReservedRange end. */ + public end: number; + } + } + + /** Properties of a FieldDescriptorProto. */ + interface IFieldDescriptorProto { + + /** FieldDescriptorProto name */ + name?: (string|null); + + /** FieldDescriptorProto number */ + number?: (number|null); + + /** FieldDescriptorProto label */ + label?: (google.protobuf.FieldDescriptorProto.Label|null); + + /** FieldDescriptorProto type */ + type?: (google.protobuf.FieldDescriptorProto.Type|null); + + /** FieldDescriptorProto typeName */ + typeName?: (string|null); + + /** FieldDescriptorProto extendee */ + extendee?: (string|null); + + /** FieldDescriptorProto defaultValue */ + defaultValue?: (string|null); + + /** FieldDescriptorProto oneofIndex */ + oneofIndex?: (number|null); + + /** FieldDescriptorProto jsonName */ + jsonName?: (string|null); + + /** FieldDescriptorProto options */ + options?: (google.protobuf.IFieldOptions|null); + } + + /** Represents a FieldDescriptorProto. */ + class FieldDescriptorProto implements IFieldDescriptorProto { + + /** + * Constructs a new FieldDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldDescriptorProto); + + /** FieldDescriptorProto name. */ + public name: string; + + /** FieldDescriptorProto number. */ + public number: number; + + /** FieldDescriptorProto label. */ + public label: google.protobuf.FieldDescriptorProto.Label; + + /** FieldDescriptorProto type. */ + public type: google.protobuf.FieldDescriptorProto.Type; + + /** FieldDescriptorProto typeName. */ + public typeName: string; + + /** FieldDescriptorProto extendee. */ + public extendee: string; + + /** FieldDescriptorProto defaultValue. */ + public defaultValue: string; + + /** FieldDescriptorProto oneofIndex. */ + public oneofIndex: number; + + /** FieldDescriptorProto jsonName. */ + public jsonName: string; + + /** FieldDescriptorProto options. */ + public options?: (google.protobuf.IFieldOptions|null); + } + + namespace FieldDescriptorProto { + + /** Type enum. */ + type Type = + "TYPE_DOUBLE"| "TYPE_FLOAT"| "TYPE_INT64"| "TYPE_UINT64"| "TYPE_INT32"| "TYPE_FIXED64"| "TYPE_FIXED32"| "TYPE_BOOL"| "TYPE_STRING"| "TYPE_GROUP"| "TYPE_MESSAGE"| "TYPE_BYTES"| "TYPE_UINT32"| "TYPE_ENUM"| "TYPE_SFIXED32"| "TYPE_SFIXED64"| "TYPE_SINT32"| "TYPE_SINT64"; + + /** Label enum. */ + type Label = + "LABEL_OPTIONAL"| "LABEL_REQUIRED"| "LABEL_REPEATED"; + } + + /** Properties of an OneofDescriptorProto. */ + interface IOneofDescriptorProto { + + /** OneofDescriptorProto name */ + name?: (string|null); + + /** OneofDescriptorProto options */ + options?: (google.protobuf.IOneofOptions|null); + } + + /** Represents an OneofDescriptorProto. */ + class OneofDescriptorProto implements IOneofDescriptorProto { + + /** + * Constructs a new OneofDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IOneofDescriptorProto); + + /** OneofDescriptorProto name. */ + public name: string; + + /** OneofDescriptorProto options. */ + public options?: (google.protobuf.IOneofOptions|null); + } + + /** Properties of an EnumDescriptorProto. */ + interface IEnumDescriptorProto { + + /** EnumDescriptorProto name */ + name?: (string|null); + + /** EnumDescriptorProto value */ + value?: (google.protobuf.IEnumValueDescriptorProto[]|null); + + /** EnumDescriptorProto options */ + options?: (google.protobuf.IEnumOptions|null); + } + + /** Represents an EnumDescriptorProto. */ + class EnumDescriptorProto implements IEnumDescriptorProto { + + /** + * Constructs a new EnumDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumDescriptorProto); + + /** EnumDescriptorProto name. */ + public name: string; + + /** EnumDescriptorProto value. */ + public value: google.protobuf.IEnumValueDescriptorProto[]; + + /** EnumDescriptorProto options. */ + public options?: (google.protobuf.IEnumOptions|null); + } + + /** Properties of an EnumValueDescriptorProto. */ + interface IEnumValueDescriptorProto { + + /** EnumValueDescriptorProto name */ + name?: (string|null); + + /** EnumValueDescriptorProto number */ + number?: (number|null); + + /** EnumValueDescriptorProto options */ + options?: (google.protobuf.IEnumValueOptions|null); + } + + /** Represents an EnumValueDescriptorProto. */ + class EnumValueDescriptorProto implements IEnumValueDescriptorProto { + + /** + * Constructs a new EnumValueDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumValueDescriptorProto); + + /** EnumValueDescriptorProto name. */ + public name: string; + + /** EnumValueDescriptorProto number. */ + public number: number; + + /** EnumValueDescriptorProto options. */ + public options?: (google.protobuf.IEnumValueOptions|null); + } + + /** Properties of a ServiceDescriptorProto. */ + interface IServiceDescriptorProto { + + /** ServiceDescriptorProto name */ + name?: (string|null); + + /** ServiceDescriptorProto method */ + method?: (google.protobuf.IMethodDescriptorProto[]|null); + + /** ServiceDescriptorProto options */ + options?: (google.protobuf.IServiceOptions|null); + } + + /** Represents a ServiceDescriptorProto. */ + class ServiceDescriptorProto implements IServiceDescriptorProto { + + /** + * Constructs a new ServiceDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IServiceDescriptorProto); + + /** ServiceDescriptorProto name. */ + public name: string; + + /** ServiceDescriptorProto method. */ + public method: google.protobuf.IMethodDescriptorProto[]; + + /** ServiceDescriptorProto options. */ + public options?: (google.protobuf.IServiceOptions|null); + } + + /** Properties of a MethodDescriptorProto. */ + interface IMethodDescriptorProto { + + /** MethodDescriptorProto name */ + name?: (string|null); + + /** MethodDescriptorProto inputType */ + inputType?: (string|null); + + /** MethodDescriptorProto outputType */ + outputType?: (string|null); + + /** MethodDescriptorProto options */ + options?: (google.protobuf.IMethodOptions|null); + + /** MethodDescriptorProto clientStreaming */ + clientStreaming?: (boolean|null); + + /** MethodDescriptorProto serverStreaming */ + serverStreaming?: (boolean|null); + } + + /** Represents a MethodDescriptorProto. */ + class MethodDescriptorProto implements IMethodDescriptorProto { + + /** + * Constructs a new MethodDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMethodDescriptorProto); + + /** MethodDescriptorProto name. */ + public name: string; + + /** MethodDescriptorProto inputType. */ + public inputType: string; + + /** MethodDescriptorProto outputType. */ + public outputType: string; + + /** MethodDescriptorProto options. */ + public options?: (google.protobuf.IMethodOptions|null); + + /** MethodDescriptorProto clientStreaming. */ + public clientStreaming: boolean; + + /** MethodDescriptorProto serverStreaming. */ + public serverStreaming: boolean; + } + + /** Properties of a FileOptions. */ + interface IFileOptions { + + /** FileOptions javaPackage */ + javaPackage?: (string|null); + + /** FileOptions javaOuterClassname */ + javaOuterClassname?: (string|null); + + /** FileOptions javaMultipleFiles */ + javaMultipleFiles?: (boolean|null); + + /** FileOptions javaGenerateEqualsAndHash */ + javaGenerateEqualsAndHash?: (boolean|null); + + /** FileOptions javaStringCheckUtf8 */ + javaStringCheckUtf8?: (boolean|null); + + /** FileOptions optimizeFor */ + optimizeFor?: (google.protobuf.FileOptions.OptimizeMode|null); + + /** FileOptions goPackage */ + goPackage?: (string|null); + + /** FileOptions ccGenericServices */ + ccGenericServices?: (boolean|null); + + /** FileOptions javaGenericServices */ + javaGenericServices?: (boolean|null); + + /** FileOptions pyGenericServices */ + pyGenericServices?: (boolean|null); + + /** FileOptions deprecated */ + deprecated?: (boolean|null); + + /** FileOptions ccEnableArenas */ + ccEnableArenas?: (boolean|null); + + /** FileOptions objcClassPrefix */ + objcClassPrefix?: (string|null); + + /** FileOptions csharpNamespace */ + csharpNamespace?: (string|null); + + /** FileOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** FileOptions .google.api.resourceDefinition */ + ".google.api.resourceDefinition"?: (google.api.IResourceDescriptor[]|null); + } + + /** Represents a FileOptions. */ + class FileOptions implements IFileOptions { + + /** + * Constructs a new FileOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileOptions); + + /** FileOptions javaPackage. */ + public javaPackage: string; + + /** FileOptions javaOuterClassname. */ + public javaOuterClassname: string; + + /** FileOptions javaMultipleFiles. */ + public javaMultipleFiles: boolean; + + /** FileOptions javaGenerateEqualsAndHash. */ + public javaGenerateEqualsAndHash: boolean; + + /** FileOptions javaStringCheckUtf8. */ + public javaStringCheckUtf8: boolean; + + /** FileOptions optimizeFor. */ + public optimizeFor: google.protobuf.FileOptions.OptimizeMode; + + /** FileOptions goPackage. */ + public goPackage: string; + + /** FileOptions ccGenericServices. */ + public ccGenericServices: boolean; + + /** FileOptions javaGenericServices. */ + public javaGenericServices: boolean; + + /** FileOptions pyGenericServices. */ + public pyGenericServices: boolean; + + /** FileOptions deprecated. */ + public deprecated: boolean; + + /** FileOptions ccEnableArenas. */ + public ccEnableArenas: boolean; + + /** FileOptions objcClassPrefix. */ + public objcClassPrefix: string; + + /** FileOptions csharpNamespace. */ + public csharpNamespace: string; + + /** FileOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + } + + namespace FileOptions { + + /** OptimizeMode enum. */ + type OptimizeMode = + "SPEED"| "CODE_SIZE"| "LITE_RUNTIME"; + } + + /** Properties of a MessageOptions. */ + interface IMessageOptions { + + /** MessageOptions messageSetWireFormat */ + messageSetWireFormat?: (boolean|null); + + /** MessageOptions noStandardDescriptorAccessor */ + noStandardDescriptorAccessor?: (boolean|null); + + /** MessageOptions deprecated */ + deprecated?: (boolean|null); + + /** MessageOptions mapEntry */ + mapEntry?: (boolean|null); + + /** MessageOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** MessageOptions .google.api.resource */ + ".google.api.resource"?: (google.api.IResourceDescriptor|null); + } + + /** Represents a MessageOptions. */ + class MessageOptions implements IMessageOptions { + + /** + * Constructs a new MessageOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMessageOptions); + + /** MessageOptions messageSetWireFormat. */ + public messageSetWireFormat: boolean; + + /** MessageOptions noStandardDescriptorAccessor. */ + public noStandardDescriptorAccessor: boolean; + + /** MessageOptions deprecated. */ + public deprecated: boolean; + + /** MessageOptions mapEntry. */ + public mapEntry: boolean; + + /** MessageOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + } + + /** Properties of a FieldOptions. */ + interface IFieldOptions { + + /** FieldOptions ctype */ + ctype?: (google.protobuf.FieldOptions.CType|null); + + /** FieldOptions packed */ + packed?: (boolean|null); + + /** FieldOptions jstype */ + jstype?: (google.protobuf.FieldOptions.JSType|null); + + /** FieldOptions lazy */ + lazy?: (boolean|null); + + /** FieldOptions deprecated */ + deprecated?: (boolean|null); + + /** FieldOptions weak */ + weak?: (boolean|null); + + /** FieldOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** FieldOptions .google.api.fieldBehavior */ + ".google.api.fieldBehavior"?: (google.api.FieldBehavior[]|null); + + /** FieldOptions .google.api.resourceReference */ + ".google.api.resourceReference"?: (google.api.IResourceReference|null); + } + + /** Represents a FieldOptions. */ + class FieldOptions implements IFieldOptions { + + /** + * Constructs a new FieldOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldOptions); + + /** FieldOptions ctype. */ + public ctype: google.protobuf.FieldOptions.CType; + + /** FieldOptions packed. */ + public packed: boolean; + + /** FieldOptions jstype. */ + public jstype: google.protobuf.FieldOptions.JSType; + + /** FieldOptions lazy. */ + public lazy: boolean; + + /** FieldOptions deprecated. */ + public deprecated: boolean; + + /** FieldOptions weak. */ + public weak: boolean; + + /** FieldOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + } + + namespace FieldOptions { + + /** CType enum. */ + type CType = + "STRING"| "CORD"| "STRING_PIECE"; + + /** JSType enum. */ + type JSType = + "JS_NORMAL"| "JS_STRING"| "JS_NUMBER"; + } + + /** Properties of an OneofOptions. */ + interface IOneofOptions { + + /** OneofOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an OneofOptions. */ + class OneofOptions implements IOneofOptions { + + /** + * Constructs a new OneofOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IOneofOptions); + + /** OneofOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + } + + /** Properties of an EnumOptions. */ + interface IEnumOptions { + + /** EnumOptions allowAlias */ + allowAlias?: (boolean|null); + + /** EnumOptions deprecated */ + deprecated?: (boolean|null); + + /** EnumOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an EnumOptions. */ + class EnumOptions implements IEnumOptions { + + /** + * Constructs a new EnumOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumOptions); + + /** EnumOptions allowAlias. */ + public allowAlias: boolean; + + /** EnumOptions deprecated. */ + public deprecated: boolean; + + /** EnumOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + } + + /** Properties of an EnumValueOptions. */ + interface IEnumValueOptions { + + /** EnumValueOptions deprecated */ + deprecated?: (boolean|null); + + /** EnumValueOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an EnumValueOptions. */ + class EnumValueOptions implements IEnumValueOptions { + + /** + * Constructs a new EnumValueOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumValueOptions); + + /** EnumValueOptions deprecated. */ + public deprecated: boolean; + + /** EnumValueOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + } + + /** Properties of a ServiceOptions. */ + interface IServiceOptions { + + /** ServiceOptions deprecated */ + deprecated?: (boolean|null); + + /** ServiceOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** ServiceOptions .google.api.defaultHost */ + ".google.api.defaultHost"?: (string|null); + + /** ServiceOptions .google.api.oauthScopes */ + ".google.api.oauthScopes"?: (string|null); + } + + /** Represents a ServiceOptions. */ + class ServiceOptions implements IServiceOptions { + + /** + * Constructs a new ServiceOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IServiceOptions); + + /** ServiceOptions deprecated. */ + public deprecated: boolean; + + /** ServiceOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + } + + /** Properties of a MethodOptions. */ + interface IMethodOptions { + + /** MethodOptions deprecated */ + deprecated?: (boolean|null); + + /** MethodOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** MethodOptions .google.api.http */ + ".google.api.http"?: (google.api.IHttpRule|null); + + /** MethodOptions .google.api.methodSignature */ + ".google.api.methodSignature"?: (string[]|null); + + /** MethodOptions .google.longrunning.operationInfo */ + ".google.longrunning.operationInfo"?: (google.longrunning.IOperationInfo|null); + } + + /** Represents a MethodOptions. */ + class MethodOptions implements IMethodOptions { + + /** + * Constructs a new MethodOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMethodOptions); + + /** MethodOptions deprecated. */ + public deprecated: boolean; + + /** MethodOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + } + + /** Properties of an UninterpretedOption. */ + interface IUninterpretedOption { + + /** UninterpretedOption name */ + name?: (google.protobuf.UninterpretedOption.INamePart[]|null); + + /** UninterpretedOption identifierValue */ + identifierValue?: (string|null); + + /** UninterpretedOption positiveIntValue */ + positiveIntValue?: (number|null); + + /** UninterpretedOption negativeIntValue */ + negativeIntValue?: (number|null); + + /** UninterpretedOption doubleValue */ + doubleValue?: (number|null); + + /** UninterpretedOption stringValue */ + stringValue?: (Uint8Array|null); + + /** UninterpretedOption aggregateValue */ + aggregateValue?: (string|null); + } + + /** Represents an UninterpretedOption. */ + class UninterpretedOption implements IUninterpretedOption { + + /** + * Constructs a new UninterpretedOption. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUninterpretedOption); + + /** UninterpretedOption name. */ + public name: google.protobuf.UninterpretedOption.INamePart[]; + + /** UninterpretedOption identifierValue. */ + public identifierValue: string; + + /** UninterpretedOption positiveIntValue. */ + public positiveIntValue: number; + + /** UninterpretedOption negativeIntValue. */ + public negativeIntValue: number; + + /** UninterpretedOption doubleValue. */ + public doubleValue: number; + + /** UninterpretedOption stringValue. */ + public stringValue: Uint8Array; + + /** UninterpretedOption aggregateValue. */ + public aggregateValue: string; + } + + namespace UninterpretedOption { + + /** Properties of a NamePart. */ + interface INamePart { + + /** NamePart namePart */ + namePart: string; + + /** NamePart isExtension */ + isExtension: boolean; + } + + /** Represents a NamePart. */ + class NamePart implements INamePart { + + /** + * Constructs a new NamePart. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.UninterpretedOption.INamePart); + + /** NamePart namePart. */ + public namePart: string; + + /** NamePart isExtension. */ + public isExtension: boolean; + } + } + + /** Properties of a SourceCodeInfo. */ + interface ISourceCodeInfo { + + /** SourceCodeInfo location */ + location?: (google.protobuf.SourceCodeInfo.ILocation[]|null); + } + + /** Represents a SourceCodeInfo. */ + class SourceCodeInfo implements ISourceCodeInfo { + + /** + * Constructs a new SourceCodeInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.ISourceCodeInfo); + + /** SourceCodeInfo location. */ + public location: google.protobuf.SourceCodeInfo.ILocation[]; + } + + namespace SourceCodeInfo { + + /** Properties of a Location. */ + interface ILocation { + + /** Location path */ + path?: (number[]|null); + + /** Location span */ + span?: (number[]|null); + + /** Location leadingComments */ + leadingComments?: (string|null); + + /** Location trailingComments */ + trailingComments?: (string|null); + + /** Location leadingDetachedComments */ + leadingDetachedComments?: (string[]|null); + } + + /** Represents a Location. */ + class Location implements ILocation { + + /** + * Constructs a new Location. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.SourceCodeInfo.ILocation); + + /** Location path. */ + public path: number[]; + + /** Location span. */ + public span: number[]; + + /** Location leadingComments. */ + public leadingComments: string; + + /** Location trailingComments. */ + public trailingComments: string; + + /** Location leadingDetachedComments. */ + public leadingDetachedComments: string[]; + } + } + + /** Properties of a GeneratedCodeInfo. */ + interface IGeneratedCodeInfo { + + /** GeneratedCodeInfo annotation */ + annotation?: (google.protobuf.GeneratedCodeInfo.IAnnotation[]|null); + } + + /** Represents a GeneratedCodeInfo. */ + class GeneratedCodeInfo implements IGeneratedCodeInfo { + + /** + * Constructs a new GeneratedCodeInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IGeneratedCodeInfo); + + /** GeneratedCodeInfo annotation. */ + public annotation: google.protobuf.GeneratedCodeInfo.IAnnotation[]; + } + + namespace GeneratedCodeInfo { + + /** Properties of an Annotation. */ + interface IAnnotation { + + /** Annotation path */ + path?: (number[]|null); + + /** Annotation sourceFile */ + sourceFile?: (string|null); + + /** Annotation begin */ + begin?: (number|null); + + /** Annotation end */ + end?: (number|null); + } + + /** Represents an Annotation. */ + class Annotation implements IAnnotation { + + /** + * Constructs a new Annotation. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.GeneratedCodeInfo.IAnnotation); + + /** Annotation path. */ + public path: number[]; + + /** Annotation sourceFile. */ + public sourceFile: string; + + /** Annotation begin. */ + public begin: number; + + /** Annotation end. */ + public end: number; + } + } + + /** Properties of an Empty. */ + interface IEmpty { + } + + /** Represents an Empty. */ + class Empty implements IEmpty { + + /** + * Constructs a new Empty. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEmpty); + } + + /** Properties of a FieldMask. */ + interface IFieldMask { + + /** FieldMask paths */ + paths?: (string[]|null); + } + + /** Represents a FieldMask. */ + class FieldMask implements IFieldMask { + + /** + * Constructs a new FieldMask. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldMask); + + /** FieldMask paths. */ + public paths: string[]; + } + + /** Properties of a Timestamp. */ + interface ITimestamp { + + /** Timestamp seconds */ + seconds?: (number|null); + + /** Timestamp nanos */ + nanos?: (number|null); + } + + /** Represents a Timestamp. */ + class Timestamp implements ITimestamp { + + /** + * Constructs a new Timestamp. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.ITimestamp); + + /** Timestamp seconds. */ + public seconds: number; + + /** Timestamp nanos. */ + public nanos: number; + } + + /** Properties of an Any. */ + interface IAny { + + /** Any type_url */ + type_url?: (string|null); + + /** Any value */ + value?: (Uint8Array|null); + } + + /** Represents an Any. */ + class Any implements IAny { + + /** + * Constructs a new Any. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IAny); + + /** Any type_url. */ + public type_url: string; + + /** Any value. */ + public value: Uint8Array; + } + + /** Properties of a Struct. */ + interface IStruct { + + /** Struct fields */ + fields?: ({ [k: string]: google.protobuf.IValue }|null); + } + + /** Represents a Struct. */ + class Struct implements IStruct { + + /** + * Constructs a new Struct. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IStruct); + + /** Struct fields. */ + public fields: { [k: string]: google.protobuf.IValue }; + } + + /** Properties of a Value. */ + interface IValue { + + /** Value nullValue */ + nullValue?: (google.protobuf.NullValue|null); + + /** Value numberValue */ + numberValue?: (number|null); + + /** Value stringValue */ + stringValue?: (string|null); + + /** Value boolValue */ + boolValue?: (boolean|null); + + /** Value structValue */ + structValue?: (google.protobuf.IStruct|null); + + /** Value listValue */ + listValue?: (google.protobuf.IListValue|null); + } + + /** Represents a Value. */ + class Value implements IValue { + + /** + * Constructs a new Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IValue); + + /** Value nullValue. */ + public nullValue: google.protobuf.NullValue; + + /** Value numberValue. */ + public numberValue: number; + + /** Value stringValue. */ + public stringValue: string; + + /** Value boolValue. */ + public boolValue: boolean; + + /** Value structValue. */ + public structValue?: (google.protobuf.IStruct|null); + + /** Value listValue. */ + public listValue?: (google.protobuf.IListValue|null); + + /** Value kind. */ + public kind?: ("nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"); + } + + /** NullValue enum. */ + type NullValue = + "NULL_VALUE"; + + /** Properties of a ListValue. */ + interface IListValue { + + /** ListValue values */ + values?: (google.protobuf.IValue[]|null); + } + + /** Represents a ListValue. */ + class ListValue implements IListValue { + + /** + * Constructs a new ListValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IListValue); + + /** ListValue values. */ + public values: google.protobuf.IValue[]; + } + + /** Properties of a DoubleValue. */ + interface IDoubleValue { + + /** DoubleValue value */ + value?: (number|null); + } + + /** Represents a DoubleValue. */ + class DoubleValue implements IDoubleValue { + + /** + * Constructs a new DoubleValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDoubleValue); + + /** DoubleValue value. */ + public value: number; + } + + /** Properties of a FloatValue. */ + interface IFloatValue { + + /** FloatValue value */ + value?: (number|null); + } + + /** Represents a FloatValue. */ + class FloatValue implements IFloatValue { + + /** + * Constructs a new FloatValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFloatValue); + + /** FloatValue value. */ + public value: number; + } + + /** Properties of an Int64Value. */ + interface IInt64Value { + + /** Int64Value value */ + value?: (number|null); + } + + /** Represents an Int64Value. */ + class Int64Value implements IInt64Value { + + /** + * Constructs a new Int64Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IInt64Value); + + /** Int64Value value. */ + public value: number; + } + + /** Properties of a UInt64Value. */ + interface IUInt64Value { + + /** UInt64Value value */ + value?: (number|null); + } + + /** Represents a UInt64Value. */ + class UInt64Value implements IUInt64Value { + + /** + * Constructs a new UInt64Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUInt64Value); + + /** UInt64Value value. */ + public value: number; + } + + /** Properties of an Int32Value. */ + interface IInt32Value { + + /** Int32Value value */ + value?: (number|null); + } + + /** Represents an Int32Value. */ + class Int32Value implements IInt32Value { + + /** + * Constructs a new Int32Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IInt32Value); + + /** Int32Value value. */ + public value: number; + } + + /** Properties of a UInt32Value. */ + interface IUInt32Value { + + /** UInt32Value value */ + value?: (number|null); + } + + /** Represents a UInt32Value. */ + class UInt32Value implements IUInt32Value { + + /** + * Constructs a new UInt32Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUInt32Value); + + /** UInt32Value value. */ + public value: number; + } + + /** Properties of a BoolValue. */ + interface IBoolValue { + + /** BoolValue value */ + value?: (boolean|null); + } + + /** Represents a BoolValue. */ + class BoolValue implements IBoolValue { + + /** + * Constructs a new BoolValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IBoolValue); + + /** BoolValue value. */ + public value: boolean; + } + + /** Properties of a StringValue. */ + interface IStringValue { + + /** StringValue value */ + value?: (string|null); + } + + /** Represents a StringValue. */ + class StringValue implements IStringValue { + + /** + * Constructs a new StringValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IStringValue); + + /** StringValue value. */ + public value: string; + } + + /** Properties of a BytesValue. */ + interface IBytesValue { + + /** BytesValue value */ + value?: (Uint8Array|null); + } + + /** Represents a BytesValue. */ + class BytesValue implements IBytesValue { + + /** + * Constructs a new BytesValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IBytesValue); + + /** BytesValue value. */ + public value: Uint8Array; + } + + /** Properties of a Duration. */ + interface IDuration { + + /** Duration seconds */ + seconds?: (number|null); + + /** Duration nanos */ + nanos?: (number|null); + } + + /** Represents a Duration. */ + class Duration implements IDuration { + + /** + * Constructs a new Duration. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDuration); + + /** Duration seconds. */ + public seconds: number; + + /** Duration nanos. */ + public nanos: number; + } + } + + /** Namespace type. */ + namespace type { + + /** Properties of a LatLng. */ + interface ILatLng { + + /** LatLng latitude */ + latitude?: (number|null); + + /** LatLng longitude */ + longitude?: (number|null); + } + + /** Represents a LatLng. */ + class LatLng implements ILatLng { + + /** + * Constructs a new LatLng. + * @param [properties] Properties to set + */ + constructor(properties?: google.type.ILatLng); + + /** LatLng latitude. */ + public latitude: number; + + /** LatLng longitude. */ + public longitude: number; + } + } + + /** Namespace rpc. */ + namespace rpc { + + /** Properties of a Status. */ + interface IStatus { + + /** Status code */ + code?: (number|null); + + /** Status message */ + message?: (string|null); + + /** Status details */ + details?: (google.protobuf.IAny[]|null); + } + + /** Represents a Status. */ + class Status implements IStatus { + + /** + * Constructs a new Status. + * @param [properties] Properties to set + */ + constructor(properties?: google.rpc.IStatus); + + /** Status code. */ + public code: number; + + /** Status message. */ + public message: string; + + /** Status details. */ + public details: google.protobuf.IAny[]; + } + } + + /** Namespace longrunning. */ + namespace longrunning { + + /** Represents an Operations */ + class Operations extends $protobuf.rpc.Service { + + /** + * Constructs a new Operations service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Calls ListOperations. + * @param request ListOperationsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListOperationsResponse + */ + public listOperations(request: google.longrunning.IListOperationsRequest, callback: google.longrunning.Operations.ListOperationsCallback): void; + + /** + * Calls ListOperations. + * @param request ListOperationsRequest message or plain object + * @returns Promise + */ + public listOperations(request: google.longrunning.IListOperationsRequest): Promise; + + /** + * Calls GetOperation. + * @param request GetOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public getOperation(request: google.longrunning.IGetOperationRequest, callback: google.longrunning.Operations.GetOperationCallback): void; + + /** + * Calls GetOperation. + * @param request GetOperationRequest message or plain object + * @returns Promise + */ + public getOperation(request: google.longrunning.IGetOperationRequest): Promise; + + /** + * Calls DeleteOperation. + * @param request DeleteOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteOperation(request: google.longrunning.IDeleteOperationRequest, callback: google.longrunning.Operations.DeleteOperationCallback): void; + + /** + * Calls DeleteOperation. + * @param request DeleteOperationRequest message or plain object + * @returns Promise + */ + public deleteOperation(request: google.longrunning.IDeleteOperationRequest): Promise; + + /** + * Calls CancelOperation. + * @param request CancelOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public cancelOperation(request: google.longrunning.ICancelOperationRequest, callback: google.longrunning.Operations.CancelOperationCallback): void; + + /** + * Calls CancelOperation. + * @param request CancelOperationRequest message or plain object + * @returns Promise + */ + public cancelOperation(request: google.longrunning.ICancelOperationRequest): Promise; + + /** + * Calls WaitOperation. + * @param request WaitOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public waitOperation(request: google.longrunning.IWaitOperationRequest, callback: google.longrunning.Operations.WaitOperationCallback): void; + + /** + * Calls WaitOperation. + * @param request WaitOperationRequest message or plain object + * @returns Promise + */ + public waitOperation(request: google.longrunning.IWaitOperationRequest): Promise; + } + + namespace Operations { + + /** + * Callback as used by {@link google.longrunning.Operations#listOperations}. + * @param error Error, if any + * @param [response] ListOperationsResponse + */ + type ListOperationsCallback = (error: (Error|null), response?: google.longrunning.ListOperationsResponse) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#getOperation}. + * @param error Error, if any + * @param [response] Operation + */ + type GetOperationCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#deleteOperation}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteOperationCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#cancelOperation}. + * @param error Error, if any + * @param [response] Empty + */ + type CancelOperationCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#waitOperation}. + * @param error Error, if any + * @param [response] Operation + */ + type WaitOperationCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of an Operation. */ + interface IOperation { + + /** Operation name */ + name?: (string|null); + + /** Operation metadata */ + metadata?: (google.protobuf.IAny|null); + + /** Operation done */ + done?: (boolean|null); + + /** Operation error */ + error?: (google.rpc.IStatus|null); + + /** Operation response */ + response?: (google.protobuf.IAny|null); + } + + /** Represents an Operation. */ + class Operation implements IOperation { + + /** + * Constructs a new Operation. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IOperation); + + /** Operation name. */ + public name: string; + + /** Operation metadata. */ + public metadata?: (google.protobuf.IAny|null); + + /** Operation done. */ + public done: boolean; + + /** Operation error. */ + public error?: (google.rpc.IStatus|null); + + /** Operation response. */ + public response?: (google.protobuf.IAny|null); + + /** Operation result. */ + public result?: ("error"|"response"); + } + + /** Properties of a GetOperationRequest. */ + interface IGetOperationRequest { + + /** GetOperationRequest name */ + name?: (string|null); + } + + /** Represents a GetOperationRequest. */ + class GetOperationRequest implements IGetOperationRequest { + + /** + * Constructs a new GetOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IGetOperationRequest); + + /** GetOperationRequest name. */ + public name: string; + } + + /** Properties of a ListOperationsRequest. */ + interface IListOperationsRequest { + + /** ListOperationsRequest name */ + name?: (string|null); + + /** ListOperationsRequest filter */ + filter?: (string|null); + + /** ListOperationsRequest pageSize */ + pageSize?: (number|null); + + /** ListOperationsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListOperationsRequest. */ + class ListOperationsRequest implements IListOperationsRequest { + + /** + * Constructs a new ListOperationsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IListOperationsRequest); + + /** ListOperationsRequest name. */ + public name: string; + + /** ListOperationsRequest filter. */ + public filter: string; + + /** ListOperationsRequest pageSize. */ + public pageSize: number; + + /** ListOperationsRequest pageToken. */ + public pageToken: string; + } + + /** Properties of a ListOperationsResponse. */ + interface IListOperationsResponse { + + /** ListOperationsResponse operations */ + operations?: (google.longrunning.IOperation[]|null); + + /** ListOperationsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListOperationsResponse. */ + class ListOperationsResponse implements IListOperationsResponse { + + /** + * Constructs a new ListOperationsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IListOperationsResponse); + + /** ListOperationsResponse operations. */ + public operations: google.longrunning.IOperation[]; + + /** ListOperationsResponse nextPageToken. */ + public nextPageToken: string; + } + + /** Properties of a CancelOperationRequest. */ + interface ICancelOperationRequest { + + /** CancelOperationRequest name */ + name?: (string|null); + } + + /** Represents a CancelOperationRequest. */ + class CancelOperationRequest implements ICancelOperationRequest { + + /** + * Constructs a new CancelOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.ICancelOperationRequest); + + /** CancelOperationRequest name. */ + public name: string; + } + + /** Properties of a DeleteOperationRequest. */ + interface IDeleteOperationRequest { + + /** DeleteOperationRequest name */ + name?: (string|null); + } + + /** Represents a DeleteOperationRequest. */ + class DeleteOperationRequest implements IDeleteOperationRequest { + + /** + * Constructs a new DeleteOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IDeleteOperationRequest); + + /** DeleteOperationRequest name. */ + public name: string; + } + + /** Properties of a WaitOperationRequest. */ + interface IWaitOperationRequest { + + /** WaitOperationRequest name */ + name?: (string|null); + + /** WaitOperationRequest timeout */ + timeout?: (google.protobuf.IDuration|null); + } + + /** Represents a WaitOperationRequest. */ + class WaitOperationRequest implements IWaitOperationRequest { + + /** + * Constructs a new WaitOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IWaitOperationRequest); + + /** WaitOperationRequest name. */ + public name: string; + + /** WaitOperationRequest timeout. */ + public timeout?: (google.protobuf.IDuration|null); + } + + /** Properties of an OperationInfo. */ + interface IOperationInfo { + + /** OperationInfo responseType */ + responseType?: (string|null); + + /** OperationInfo metadataType */ + metadataType?: (string|null); + } + + /** Represents an OperationInfo. */ + class OperationInfo implements IOperationInfo { + + /** + * Constructs a new OperationInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IOperationInfo); + + /** OperationInfo responseType. */ + public responseType: string; + + /** OperationInfo metadataType. */ + public metadataType: string; + } + } +} diff --git a/dev/protos/firestore_admin_v1_proto_api.js b/dev/protos/firestore_admin_v1_proto_api.js new file mode 100644 index 000000000..18baf526c --- /dev/null +++ b/dev/protos/firestore_admin_v1_proto_api.js @@ -0,0 +1,5401 @@ +/*! + * Copyright 2019 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. + */ + +// Common aliases +var $util = $protobuf.util; + +// Exported root namespace +var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); + +$root.google = (function() { + + /** + * Namespace google. + * @exports google + * @namespace + */ + var google = {}; + + google.firestore = (function() { + + /** + * Namespace firestore. + * @memberof google + * @namespace + */ + var firestore = {}; + + firestore.admin = (function() { + + /** + * Namespace admin. + * @memberof google.firestore + * @namespace + */ + var admin = {}; + + admin.v1 = (function() { + + /** + * Namespace v1. + * @memberof google.firestore.admin + * @namespace + */ + var v1 = {}; + + v1.Field = (function() { + + /** + * Properties of a Field. + * @memberof google.firestore.admin.v1 + * @interface IField + * @property {string|null} [name] Field name + * @property {google.firestore.admin.v1.Field.IIndexConfig|null} [indexConfig] Field indexConfig + */ + + /** + * Constructs a new Field. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a Field. + * @implements IField + * @constructor + * @param {google.firestore.admin.v1.IField=} [properties] Properties to set + */ + function Field(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Field name. + * @member {string} name + * @memberof google.firestore.admin.v1.Field + * @instance + */ + Field.prototype.name = ""; + + /** + * Field indexConfig. + * @member {google.firestore.admin.v1.Field.IIndexConfig|null|undefined} indexConfig + * @memberof google.firestore.admin.v1.Field + * @instance + */ + Field.prototype.indexConfig = null; + + Field.IndexConfig = (function() { + + /** + * Properties of an IndexConfig. + * @memberof google.firestore.admin.v1.Field + * @interface IIndexConfig + * @property {Array.|null} [indexes] IndexConfig indexes + * @property {boolean|null} [usesAncestorConfig] IndexConfig usesAncestorConfig + * @property {string|null} [ancestorField] IndexConfig ancestorField + * @property {boolean|null} [reverting] IndexConfig reverting + */ + + /** + * Constructs a new IndexConfig. + * @memberof google.firestore.admin.v1.Field + * @classdesc Represents an IndexConfig. + * @implements IIndexConfig + * @constructor + * @param {google.firestore.admin.v1.Field.IIndexConfig=} [properties] Properties to set + */ + function IndexConfig(properties) { + this.indexes = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * IndexConfig indexes. + * @member {Array.} indexes + * @memberof google.firestore.admin.v1.Field.IndexConfig + * @instance + */ + IndexConfig.prototype.indexes = $util.emptyArray; + + /** + * IndexConfig usesAncestorConfig. + * @member {boolean} usesAncestorConfig + * @memberof google.firestore.admin.v1.Field.IndexConfig + * @instance + */ + IndexConfig.prototype.usesAncestorConfig = false; + + /** + * IndexConfig ancestorField. + * @member {string} ancestorField + * @memberof google.firestore.admin.v1.Field.IndexConfig + * @instance + */ + IndexConfig.prototype.ancestorField = ""; + + /** + * IndexConfig reverting. + * @member {boolean} reverting + * @memberof google.firestore.admin.v1.Field.IndexConfig + * @instance + */ + IndexConfig.prototype.reverting = false; + + return IndexConfig; + })(); + + return Field; + })(); + + v1.FirestoreAdmin = (function() { + + /** + * Constructs a new FirestoreAdmin service. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a FirestoreAdmin + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function FirestoreAdmin(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (FirestoreAdmin.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = FirestoreAdmin; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#createIndex}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef CreateIndexCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls CreateIndex. + * @function createIndex + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.ICreateIndexRequest} request CreateIndexRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.CreateIndexCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.createIndex = function createIndex(request, callback) { + return this.rpcCall(createIndex, $root.google.firestore.admin.v1.CreateIndexRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "CreateIndex" }); + + /** + * Calls CreateIndex. + * @function createIndex + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.ICreateIndexRequest} request CreateIndexRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#listIndexes}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef ListIndexesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.admin.v1.ListIndexesResponse} [response] ListIndexesResponse + */ + + /** + * Calls ListIndexes. + * @function listIndexes + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IListIndexesRequest} request ListIndexesRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.ListIndexesCallback} callback Node-style callback called with the error, if any, and ListIndexesResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.listIndexes = function listIndexes(request, callback) { + return this.rpcCall(listIndexes, $root.google.firestore.admin.v1.ListIndexesRequest, $root.google.firestore.admin.v1.ListIndexesResponse, request, callback); + }, "name", { value: "ListIndexes" }); + + /** + * Calls ListIndexes. + * @function listIndexes + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IListIndexesRequest} request ListIndexesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#getIndex}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef GetIndexCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.admin.v1.Index} [response] Index + */ + + /** + * Calls GetIndex. + * @function getIndex + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IGetIndexRequest} request GetIndexRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.GetIndexCallback} callback Node-style callback called with the error, if any, and Index + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.getIndex = function getIndex(request, callback) { + return this.rpcCall(getIndex, $root.google.firestore.admin.v1.GetIndexRequest, $root.google.firestore.admin.v1.Index, request, callback); + }, "name", { value: "GetIndex" }); + + /** + * Calls GetIndex. + * @function getIndex + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IGetIndexRequest} request GetIndexRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#deleteIndex}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef DeleteIndexCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteIndex. + * @function deleteIndex + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IDeleteIndexRequest} request DeleteIndexRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.DeleteIndexCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.deleteIndex = function deleteIndex(request, callback) { + return this.rpcCall(deleteIndex, $root.google.firestore.admin.v1.DeleteIndexRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteIndex" }); + + /** + * Calls DeleteIndex. + * @function deleteIndex + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IDeleteIndexRequest} request DeleteIndexRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#getField}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef GetFieldCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.admin.v1.Field} [response] Field + */ + + /** + * Calls GetField. + * @function getField + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IGetFieldRequest} request GetFieldRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.GetFieldCallback} callback Node-style callback called with the error, if any, and Field + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.getField = function getField(request, callback) { + return this.rpcCall(getField, $root.google.firestore.admin.v1.GetFieldRequest, $root.google.firestore.admin.v1.Field, request, callback); + }, "name", { value: "GetField" }); + + /** + * Calls GetField. + * @function getField + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IGetFieldRequest} request GetFieldRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#updateField}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef UpdateFieldCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls UpdateField. + * @function updateField + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IUpdateFieldRequest} request UpdateFieldRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.UpdateFieldCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.updateField = function updateField(request, callback) { + return this.rpcCall(updateField, $root.google.firestore.admin.v1.UpdateFieldRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "UpdateField" }); + + /** + * Calls UpdateField. + * @function updateField + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IUpdateFieldRequest} request UpdateFieldRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#listFields}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef ListFieldsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.admin.v1.ListFieldsResponse} [response] ListFieldsResponse + */ + + /** + * Calls ListFields. + * @function listFields + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IListFieldsRequest} request ListFieldsRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.ListFieldsCallback} callback Node-style callback called with the error, if any, and ListFieldsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.listFields = function listFields(request, callback) { + return this.rpcCall(listFields, $root.google.firestore.admin.v1.ListFieldsRequest, $root.google.firestore.admin.v1.ListFieldsResponse, request, callback); + }, "name", { value: "ListFields" }); + + /** + * Calls ListFields. + * @function listFields + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IListFieldsRequest} request ListFieldsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#exportDocuments}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef ExportDocumentsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ExportDocuments. + * @function exportDocuments + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IExportDocumentsRequest} request ExportDocumentsRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.ExportDocumentsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.exportDocuments = function exportDocuments(request, callback) { + return this.rpcCall(exportDocuments, $root.google.firestore.admin.v1.ExportDocumentsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ExportDocuments" }); + + /** + * Calls ExportDocuments. + * @function exportDocuments + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IExportDocumentsRequest} request ExportDocumentsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#importDocuments}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef ImportDocumentsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ImportDocuments. + * @function importDocuments + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IImportDocumentsRequest} request ImportDocumentsRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.ImportDocumentsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.importDocuments = function importDocuments(request, callback) { + return this.rpcCall(importDocuments, $root.google.firestore.admin.v1.ImportDocumentsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ImportDocuments" }); + + /** + * Calls ImportDocuments. + * @function importDocuments + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IImportDocumentsRequest} request ImportDocumentsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return FirestoreAdmin; + })(); + + v1.CreateIndexRequest = (function() { + + /** + * Properties of a CreateIndexRequest. + * @memberof google.firestore.admin.v1 + * @interface ICreateIndexRequest + * @property {string|null} [parent] CreateIndexRequest parent + * @property {google.firestore.admin.v1.IIndex|null} [index] CreateIndexRequest index + */ + + /** + * Constructs a new CreateIndexRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a CreateIndexRequest. + * @implements ICreateIndexRequest + * @constructor + * @param {google.firestore.admin.v1.ICreateIndexRequest=} [properties] Properties to set + */ + function CreateIndexRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CreateIndexRequest parent. + * @member {string} parent + * @memberof google.firestore.admin.v1.CreateIndexRequest + * @instance + */ + CreateIndexRequest.prototype.parent = ""; + + /** + * CreateIndexRequest index. + * @member {google.firestore.admin.v1.IIndex|null|undefined} index + * @memberof google.firestore.admin.v1.CreateIndexRequest + * @instance + */ + CreateIndexRequest.prototype.index = null; + + return CreateIndexRequest; + })(); + + v1.ListIndexesRequest = (function() { + + /** + * Properties of a ListIndexesRequest. + * @memberof google.firestore.admin.v1 + * @interface IListIndexesRequest + * @property {string|null} [parent] ListIndexesRequest parent + * @property {string|null} [filter] ListIndexesRequest filter + * @property {number|null} [pageSize] ListIndexesRequest pageSize + * @property {string|null} [pageToken] ListIndexesRequest pageToken + */ + + /** + * Constructs a new ListIndexesRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a ListIndexesRequest. + * @implements IListIndexesRequest + * @constructor + * @param {google.firestore.admin.v1.IListIndexesRequest=} [properties] Properties to set + */ + function ListIndexesRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListIndexesRequest parent. + * @member {string} parent + * @memberof google.firestore.admin.v1.ListIndexesRequest + * @instance + */ + ListIndexesRequest.prototype.parent = ""; + + /** + * ListIndexesRequest filter. + * @member {string} filter + * @memberof google.firestore.admin.v1.ListIndexesRequest + * @instance + */ + ListIndexesRequest.prototype.filter = ""; + + /** + * ListIndexesRequest pageSize. + * @member {number} pageSize + * @memberof google.firestore.admin.v1.ListIndexesRequest + * @instance + */ + ListIndexesRequest.prototype.pageSize = 0; + + /** + * ListIndexesRequest pageToken. + * @member {string} pageToken + * @memberof google.firestore.admin.v1.ListIndexesRequest + * @instance + */ + ListIndexesRequest.prototype.pageToken = ""; + + return ListIndexesRequest; + })(); + + v1.ListIndexesResponse = (function() { + + /** + * Properties of a ListIndexesResponse. + * @memberof google.firestore.admin.v1 + * @interface IListIndexesResponse + * @property {Array.|null} [indexes] ListIndexesResponse indexes + * @property {string|null} [nextPageToken] ListIndexesResponse nextPageToken + */ + + /** + * Constructs a new ListIndexesResponse. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a ListIndexesResponse. + * @implements IListIndexesResponse + * @constructor + * @param {google.firestore.admin.v1.IListIndexesResponse=} [properties] Properties to set + */ + function ListIndexesResponse(properties) { + this.indexes = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListIndexesResponse indexes. + * @member {Array.} indexes + * @memberof google.firestore.admin.v1.ListIndexesResponse + * @instance + */ + ListIndexesResponse.prototype.indexes = $util.emptyArray; + + /** + * ListIndexesResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.firestore.admin.v1.ListIndexesResponse + * @instance + */ + ListIndexesResponse.prototype.nextPageToken = ""; + + return ListIndexesResponse; + })(); + + v1.GetIndexRequest = (function() { + + /** + * Properties of a GetIndexRequest. + * @memberof google.firestore.admin.v1 + * @interface IGetIndexRequest + * @property {string|null} [name] GetIndexRequest name + */ + + /** + * Constructs a new GetIndexRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a GetIndexRequest. + * @implements IGetIndexRequest + * @constructor + * @param {google.firestore.admin.v1.IGetIndexRequest=} [properties] Properties to set + */ + function GetIndexRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetIndexRequest name. + * @member {string} name + * @memberof google.firestore.admin.v1.GetIndexRequest + * @instance + */ + GetIndexRequest.prototype.name = ""; + + return GetIndexRequest; + })(); + + v1.DeleteIndexRequest = (function() { + + /** + * Properties of a DeleteIndexRequest. + * @memberof google.firestore.admin.v1 + * @interface IDeleteIndexRequest + * @property {string|null} [name] DeleteIndexRequest name + */ + + /** + * Constructs a new DeleteIndexRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a DeleteIndexRequest. + * @implements IDeleteIndexRequest + * @constructor + * @param {google.firestore.admin.v1.IDeleteIndexRequest=} [properties] Properties to set + */ + function DeleteIndexRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteIndexRequest name. + * @member {string} name + * @memberof google.firestore.admin.v1.DeleteIndexRequest + * @instance + */ + DeleteIndexRequest.prototype.name = ""; + + return DeleteIndexRequest; + })(); + + v1.UpdateFieldRequest = (function() { + + /** + * Properties of an UpdateFieldRequest. + * @memberof google.firestore.admin.v1 + * @interface IUpdateFieldRequest + * @property {google.firestore.admin.v1.IField|null} [field] UpdateFieldRequest field + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateFieldRequest updateMask + */ + + /** + * Constructs a new UpdateFieldRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents an UpdateFieldRequest. + * @implements IUpdateFieldRequest + * @constructor + * @param {google.firestore.admin.v1.IUpdateFieldRequest=} [properties] Properties to set + */ + function UpdateFieldRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UpdateFieldRequest field. + * @member {google.firestore.admin.v1.IField|null|undefined} field + * @memberof google.firestore.admin.v1.UpdateFieldRequest + * @instance + */ + UpdateFieldRequest.prototype.field = null; + + /** + * UpdateFieldRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.firestore.admin.v1.UpdateFieldRequest + * @instance + */ + UpdateFieldRequest.prototype.updateMask = null; + + return UpdateFieldRequest; + })(); + + v1.GetFieldRequest = (function() { + + /** + * Properties of a GetFieldRequest. + * @memberof google.firestore.admin.v1 + * @interface IGetFieldRequest + * @property {string|null} [name] GetFieldRequest name + */ + + /** + * Constructs a new GetFieldRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a GetFieldRequest. + * @implements IGetFieldRequest + * @constructor + * @param {google.firestore.admin.v1.IGetFieldRequest=} [properties] Properties to set + */ + function GetFieldRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetFieldRequest name. + * @member {string} name + * @memberof google.firestore.admin.v1.GetFieldRequest + * @instance + */ + GetFieldRequest.prototype.name = ""; + + return GetFieldRequest; + })(); + + v1.ListFieldsRequest = (function() { + + /** + * Properties of a ListFieldsRequest. + * @memberof google.firestore.admin.v1 + * @interface IListFieldsRequest + * @property {string|null} [parent] ListFieldsRequest parent + * @property {string|null} [filter] ListFieldsRequest filter + * @property {number|null} [pageSize] ListFieldsRequest pageSize + * @property {string|null} [pageToken] ListFieldsRequest pageToken + */ + + /** + * Constructs a new ListFieldsRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a ListFieldsRequest. + * @implements IListFieldsRequest + * @constructor + * @param {google.firestore.admin.v1.IListFieldsRequest=} [properties] Properties to set + */ + function ListFieldsRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListFieldsRequest parent. + * @member {string} parent + * @memberof google.firestore.admin.v1.ListFieldsRequest + * @instance + */ + ListFieldsRequest.prototype.parent = ""; + + /** + * ListFieldsRequest filter. + * @member {string} filter + * @memberof google.firestore.admin.v1.ListFieldsRequest + * @instance + */ + ListFieldsRequest.prototype.filter = ""; + + /** + * ListFieldsRequest pageSize. + * @member {number} pageSize + * @memberof google.firestore.admin.v1.ListFieldsRequest + * @instance + */ + ListFieldsRequest.prototype.pageSize = 0; + + /** + * ListFieldsRequest pageToken. + * @member {string} pageToken + * @memberof google.firestore.admin.v1.ListFieldsRequest + * @instance + */ + ListFieldsRequest.prototype.pageToken = ""; + + return ListFieldsRequest; + })(); + + v1.ListFieldsResponse = (function() { + + /** + * Properties of a ListFieldsResponse. + * @memberof google.firestore.admin.v1 + * @interface IListFieldsResponse + * @property {Array.|null} [fields] ListFieldsResponse fields + * @property {string|null} [nextPageToken] ListFieldsResponse nextPageToken + */ + + /** + * Constructs a new ListFieldsResponse. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a ListFieldsResponse. + * @implements IListFieldsResponse + * @constructor + * @param {google.firestore.admin.v1.IListFieldsResponse=} [properties] Properties to set + */ + function ListFieldsResponse(properties) { + this.fields = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListFieldsResponse fields. + * @member {Array.} fields + * @memberof google.firestore.admin.v1.ListFieldsResponse + * @instance + */ + ListFieldsResponse.prototype.fields = $util.emptyArray; + + /** + * ListFieldsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.firestore.admin.v1.ListFieldsResponse + * @instance + */ + ListFieldsResponse.prototype.nextPageToken = ""; + + return ListFieldsResponse; + })(); + + v1.ExportDocumentsRequest = (function() { + + /** + * Properties of an ExportDocumentsRequest. + * @memberof google.firestore.admin.v1 + * @interface IExportDocumentsRequest + * @property {string|null} [name] ExportDocumentsRequest name + * @property {Array.|null} [collectionIds] ExportDocumentsRequest collectionIds + * @property {string|null} [outputUriPrefix] ExportDocumentsRequest outputUriPrefix + */ + + /** + * Constructs a new ExportDocumentsRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents an ExportDocumentsRequest. + * @implements IExportDocumentsRequest + * @constructor + * @param {google.firestore.admin.v1.IExportDocumentsRequest=} [properties] Properties to set + */ + function ExportDocumentsRequest(properties) { + this.collectionIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExportDocumentsRequest name. + * @member {string} name + * @memberof google.firestore.admin.v1.ExportDocumentsRequest + * @instance + */ + ExportDocumentsRequest.prototype.name = ""; + + /** + * ExportDocumentsRequest collectionIds. + * @member {Array.} collectionIds + * @memberof google.firestore.admin.v1.ExportDocumentsRequest + * @instance + */ + ExportDocumentsRequest.prototype.collectionIds = $util.emptyArray; + + /** + * ExportDocumentsRequest outputUriPrefix. + * @member {string} outputUriPrefix + * @memberof google.firestore.admin.v1.ExportDocumentsRequest + * @instance + */ + ExportDocumentsRequest.prototype.outputUriPrefix = ""; + + return ExportDocumentsRequest; + })(); + + v1.ImportDocumentsRequest = (function() { + + /** + * Properties of an ImportDocumentsRequest. + * @memberof google.firestore.admin.v1 + * @interface IImportDocumentsRequest + * @property {string|null} [name] ImportDocumentsRequest name + * @property {Array.|null} [collectionIds] ImportDocumentsRequest collectionIds + * @property {string|null} [inputUriPrefix] ImportDocumentsRequest inputUriPrefix + */ + + /** + * Constructs a new ImportDocumentsRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents an ImportDocumentsRequest. + * @implements IImportDocumentsRequest + * @constructor + * @param {google.firestore.admin.v1.IImportDocumentsRequest=} [properties] Properties to set + */ + function ImportDocumentsRequest(properties) { + this.collectionIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ImportDocumentsRequest name. + * @member {string} name + * @memberof google.firestore.admin.v1.ImportDocumentsRequest + * @instance + */ + ImportDocumentsRequest.prototype.name = ""; + + /** + * ImportDocumentsRequest collectionIds. + * @member {Array.} collectionIds + * @memberof google.firestore.admin.v1.ImportDocumentsRequest + * @instance + */ + ImportDocumentsRequest.prototype.collectionIds = $util.emptyArray; + + /** + * ImportDocumentsRequest inputUriPrefix. + * @member {string} inputUriPrefix + * @memberof google.firestore.admin.v1.ImportDocumentsRequest + * @instance + */ + ImportDocumentsRequest.prototype.inputUriPrefix = ""; + + return ImportDocumentsRequest; + })(); + + v1.Index = (function() { + + /** + * Properties of an Index. + * @memberof google.firestore.admin.v1 + * @interface IIndex + * @property {string|null} [name] Index name + * @property {google.firestore.admin.v1.Index.QueryScope|null} [queryScope] Index queryScope + * @property {Array.|null} [fields] Index fields + * @property {google.firestore.admin.v1.Index.State|null} [state] Index state + */ + + /** + * Constructs a new Index. + * @memberof google.firestore.admin.v1 + * @classdesc Represents an Index. + * @implements IIndex + * @constructor + * @param {google.firestore.admin.v1.IIndex=} [properties] Properties to set + */ + function Index(properties) { + this.fields = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Index name. + * @member {string} name + * @memberof google.firestore.admin.v1.Index + * @instance + */ + Index.prototype.name = ""; + + /** + * Index queryScope. + * @member {google.firestore.admin.v1.Index.QueryScope} queryScope + * @memberof google.firestore.admin.v1.Index + * @instance + */ + Index.prototype.queryScope = 0; + + /** + * Index fields. + * @member {Array.} fields + * @memberof google.firestore.admin.v1.Index + * @instance + */ + Index.prototype.fields = $util.emptyArray; + + /** + * Index state. + * @member {google.firestore.admin.v1.Index.State} state + * @memberof google.firestore.admin.v1.Index + * @instance + */ + Index.prototype.state = 0; + + Index.IndexField = (function() { + + /** + * Properties of an IndexField. + * @memberof google.firestore.admin.v1.Index + * @interface IIndexField + * @property {string|null} [fieldPath] IndexField fieldPath + * @property {google.firestore.admin.v1.Index.IndexField.Order|null} [order] IndexField order + * @property {google.firestore.admin.v1.Index.IndexField.ArrayConfig|null} [arrayConfig] IndexField arrayConfig + */ + + /** + * Constructs a new IndexField. + * @memberof google.firestore.admin.v1.Index + * @classdesc Represents an IndexField. + * @implements IIndexField + * @constructor + * @param {google.firestore.admin.v1.Index.IIndexField=} [properties] Properties to set + */ + function IndexField(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * IndexField fieldPath. + * @member {string} fieldPath + * @memberof google.firestore.admin.v1.Index.IndexField + * @instance + */ + IndexField.prototype.fieldPath = ""; + + /** + * IndexField order. + * @member {google.firestore.admin.v1.Index.IndexField.Order} order + * @memberof google.firestore.admin.v1.Index.IndexField + * @instance + */ + IndexField.prototype.order = 0; + + /** + * IndexField arrayConfig. + * @member {google.firestore.admin.v1.Index.IndexField.ArrayConfig} arrayConfig + * @memberof google.firestore.admin.v1.Index.IndexField + * @instance + */ + IndexField.prototype.arrayConfig = 0; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * IndexField valueMode. + * @member {"order"|"arrayConfig"|undefined} valueMode + * @memberof google.firestore.admin.v1.Index.IndexField + * @instance + */ + Object.defineProperty(IndexField.prototype, "valueMode", { + get: $util.oneOfGetter($oneOfFields = ["order", "arrayConfig"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Order enum. + * @name google.firestore.admin.v1.Index.IndexField.Order + * @enum {number} + * @property {string} ORDER_UNSPECIFIED=ORDER_UNSPECIFIED ORDER_UNSPECIFIED value + * @property {string} ASCENDING=ASCENDING ASCENDING value + * @property {string} DESCENDING=DESCENDING DESCENDING value + */ + IndexField.Order = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ORDER_UNSPECIFIED"] = "ORDER_UNSPECIFIED"; + values[valuesById[1] = "ASCENDING"] = "ASCENDING"; + values[valuesById[2] = "DESCENDING"] = "DESCENDING"; + return values; + })(); + + /** + * ArrayConfig enum. + * @name google.firestore.admin.v1.Index.IndexField.ArrayConfig + * @enum {number} + * @property {string} ARRAY_CONFIG_UNSPECIFIED=ARRAY_CONFIG_UNSPECIFIED ARRAY_CONFIG_UNSPECIFIED value + * @property {string} CONTAINS=CONTAINS CONTAINS value + */ + IndexField.ArrayConfig = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ARRAY_CONFIG_UNSPECIFIED"] = "ARRAY_CONFIG_UNSPECIFIED"; + values[valuesById[1] = "CONTAINS"] = "CONTAINS"; + return values; + })(); + + return IndexField; + })(); + + /** + * QueryScope enum. + * @name google.firestore.admin.v1.Index.QueryScope + * @enum {number} + * @property {string} QUERY_SCOPE_UNSPECIFIED=QUERY_SCOPE_UNSPECIFIED QUERY_SCOPE_UNSPECIFIED value + * @property {string} COLLECTION=COLLECTION COLLECTION value + * @property {string} COLLECTION_GROUP=COLLECTION_GROUP COLLECTION_GROUP value + */ + Index.QueryScope = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "QUERY_SCOPE_UNSPECIFIED"] = "QUERY_SCOPE_UNSPECIFIED"; + values[valuesById[1] = "COLLECTION"] = "COLLECTION"; + values[valuesById[2] = "COLLECTION_GROUP"] = "COLLECTION_GROUP"; + return values; + })(); + + /** + * State enum. + * @name google.firestore.admin.v1.Index.State + * @enum {number} + * @property {string} STATE_UNSPECIFIED=STATE_UNSPECIFIED STATE_UNSPECIFIED value + * @property {string} CREATING=CREATING CREATING value + * @property {string} READY=READY READY value + * @property {string} NEEDS_REPAIR=NEEDS_REPAIR NEEDS_REPAIR value + */ + Index.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED"; + values[valuesById[1] = "CREATING"] = "CREATING"; + values[valuesById[2] = "READY"] = "READY"; + values[valuesById[3] = "NEEDS_REPAIR"] = "NEEDS_REPAIR"; + return values; + })(); + + return Index; + })(); + + v1.LocationMetadata = (function() { + + /** + * Properties of a LocationMetadata. + * @memberof google.firestore.admin.v1 + * @interface ILocationMetadata + */ + + /** + * Constructs a new LocationMetadata. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a LocationMetadata. + * @implements ILocationMetadata + * @constructor + * @param {google.firestore.admin.v1.ILocationMetadata=} [properties] Properties to set + */ + function LocationMetadata(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + return LocationMetadata; + })(); + + v1.IndexOperationMetadata = (function() { + + /** + * Properties of an IndexOperationMetadata. + * @memberof google.firestore.admin.v1 + * @interface IIndexOperationMetadata + * @property {google.protobuf.ITimestamp|null} [startTime] IndexOperationMetadata startTime + * @property {google.protobuf.ITimestamp|null} [endTime] IndexOperationMetadata endTime + * @property {string|null} [index] IndexOperationMetadata index + * @property {google.firestore.admin.v1.OperationState|null} [state] IndexOperationMetadata state + * @property {google.firestore.admin.v1.IProgress|null} [progressDocuments] IndexOperationMetadata progressDocuments + * @property {google.firestore.admin.v1.IProgress|null} [progressBytes] IndexOperationMetadata progressBytes + */ + + /** + * Constructs a new IndexOperationMetadata. + * @memberof google.firestore.admin.v1 + * @classdesc Represents an IndexOperationMetadata. + * @implements IIndexOperationMetadata + * @constructor + * @param {google.firestore.admin.v1.IIndexOperationMetadata=} [properties] Properties to set + */ + function IndexOperationMetadata(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * IndexOperationMetadata startTime. + * @member {google.protobuf.ITimestamp|null|undefined} startTime + * @memberof google.firestore.admin.v1.IndexOperationMetadata + * @instance + */ + IndexOperationMetadata.prototype.startTime = null; + + /** + * IndexOperationMetadata endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.firestore.admin.v1.IndexOperationMetadata + * @instance + */ + IndexOperationMetadata.prototype.endTime = null; + + /** + * IndexOperationMetadata index. + * @member {string} index + * @memberof google.firestore.admin.v1.IndexOperationMetadata + * @instance + */ + IndexOperationMetadata.prototype.index = ""; + + /** + * IndexOperationMetadata state. + * @member {google.firestore.admin.v1.OperationState} state + * @memberof google.firestore.admin.v1.IndexOperationMetadata + * @instance + */ + IndexOperationMetadata.prototype.state = 0; + + /** + * IndexOperationMetadata progressDocuments. + * @member {google.firestore.admin.v1.IProgress|null|undefined} progressDocuments + * @memberof google.firestore.admin.v1.IndexOperationMetadata + * @instance + */ + IndexOperationMetadata.prototype.progressDocuments = null; + + /** + * IndexOperationMetadata progressBytes. + * @member {google.firestore.admin.v1.IProgress|null|undefined} progressBytes + * @memberof google.firestore.admin.v1.IndexOperationMetadata + * @instance + */ + IndexOperationMetadata.prototype.progressBytes = null; + + return IndexOperationMetadata; + })(); + + v1.FieldOperationMetadata = (function() { + + /** + * Properties of a FieldOperationMetadata. + * @memberof google.firestore.admin.v1 + * @interface IFieldOperationMetadata + * @property {google.protobuf.ITimestamp|null} [startTime] FieldOperationMetadata startTime + * @property {google.protobuf.ITimestamp|null} [endTime] FieldOperationMetadata endTime + * @property {string|null} [field] FieldOperationMetadata field + * @property {Array.|null} [indexConfigDeltas] FieldOperationMetadata indexConfigDeltas + * @property {google.firestore.admin.v1.OperationState|null} [state] FieldOperationMetadata state + * @property {google.firestore.admin.v1.IProgress|null} [progressDocuments] FieldOperationMetadata progressDocuments + * @property {google.firestore.admin.v1.IProgress|null} [progressBytes] FieldOperationMetadata progressBytes + */ + + /** + * Constructs a new FieldOperationMetadata. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a FieldOperationMetadata. + * @implements IFieldOperationMetadata + * @constructor + * @param {google.firestore.admin.v1.IFieldOperationMetadata=} [properties] Properties to set + */ + function FieldOperationMetadata(properties) { + this.indexConfigDeltas = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldOperationMetadata startTime. + * @member {google.protobuf.ITimestamp|null|undefined} startTime + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @instance + */ + FieldOperationMetadata.prototype.startTime = null; + + /** + * FieldOperationMetadata endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @instance + */ + FieldOperationMetadata.prototype.endTime = null; + + /** + * FieldOperationMetadata field. + * @member {string} field + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @instance + */ + FieldOperationMetadata.prototype.field = ""; + + /** + * FieldOperationMetadata indexConfigDeltas. + * @member {Array.} indexConfigDeltas + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @instance + */ + FieldOperationMetadata.prototype.indexConfigDeltas = $util.emptyArray; + + /** + * FieldOperationMetadata state. + * @member {google.firestore.admin.v1.OperationState} state + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @instance + */ + FieldOperationMetadata.prototype.state = 0; + + /** + * FieldOperationMetadata progressDocuments. + * @member {google.firestore.admin.v1.IProgress|null|undefined} progressDocuments + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @instance + */ + FieldOperationMetadata.prototype.progressDocuments = null; + + /** + * FieldOperationMetadata progressBytes. + * @member {google.firestore.admin.v1.IProgress|null|undefined} progressBytes + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @instance + */ + FieldOperationMetadata.prototype.progressBytes = null; + + FieldOperationMetadata.IndexConfigDelta = (function() { + + /** + * Properties of an IndexConfigDelta. + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @interface IIndexConfigDelta + * @property {google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType|null} [changeType] IndexConfigDelta changeType + * @property {google.firestore.admin.v1.IIndex|null} [index] IndexConfigDelta index + */ + + /** + * Constructs a new IndexConfigDelta. + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @classdesc Represents an IndexConfigDelta. + * @implements IIndexConfigDelta + * @constructor + * @param {google.firestore.admin.v1.FieldOperationMetadata.IIndexConfigDelta=} [properties] Properties to set + */ + function IndexConfigDelta(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * IndexConfigDelta changeType. + * @member {google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType} changeType + * @memberof google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + * @instance + */ + IndexConfigDelta.prototype.changeType = 0; + + /** + * IndexConfigDelta index. + * @member {google.firestore.admin.v1.IIndex|null|undefined} index + * @memberof google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + * @instance + */ + IndexConfigDelta.prototype.index = null; + + /** + * ChangeType enum. + * @name google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType + * @enum {number} + * @property {string} CHANGE_TYPE_UNSPECIFIED=CHANGE_TYPE_UNSPECIFIED CHANGE_TYPE_UNSPECIFIED value + * @property {string} ADD=ADD ADD value + * @property {string} REMOVE=REMOVE REMOVE value + */ + IndexConfigDelta.ChangeType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "CHANGE_TYPE_UNSPECIFIED"] = "CHANGE_TYPE_UNSPECIFIED"; + values[valuesById[1] = "ADD"] = "ADD"; + values[valuesById[2] = "REMOVE"] = "REMOVE"; + return values; + })(); + + return IndexConfigDelta; + })(); + + return FieldOperationMetadata; + })(); + + v1.ExportDocumentsMetadata = (function() { + + /** + * Properties of an ExportDocumentsMetadata. + * @memberof google.firestore.admin.v1 + * @interface IExportDocumentsMetadata + * @property {google.protobuf.ITimestamp|null} [startTime] ExportDocumentsMetadata startTime + * @property {google.protobuf.ITimestamp|null} [endTime] ExportDocumentsMetadata endTime + * @property {google.firestore.admin.v1.OperationState|null} [operationState] ExportDocumentsMetadata operationState + * @property {google.firestore.admin.v1.IProgress|null} [progressDocuments] ExportDocumentsMetadata progressDocuments + * @property {google.firestore.admin.v1.IProgress|null} [progressBytes] ExportDocumentsMetadata progressBytes + * @property {Array.|null} [collectionIds] ExportDocumentsMetadata collectionIds + * @property {string|null} [outputUriPrefix] ExportDocumentsMetadata outputUriPrefix + */ + + /** + * Constructs a new ExportDocumentsMetadata. + * @memberof google.firestore.admin.v1 + * @classdesc Represents an ExportDocumentsMetadata. + * @implements IExportDocumentsMetadata + * @constructor + * @param {google.firestore.admin.v1.IExportDocumentsMetadata=} [properties] Properties to set + */ + function ExportDocumentsMetadata(properties) { + this.collectionIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExportDocumentsMetadata startTime. + * @member {google.protobuf.ITimestamp|null|undefined} startTime + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @instance + */ + ExportDocumentsMetadata.prototype.startTime = null; + + /** + * ExportDocumentsMetadata endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @instance + */ + ExportDocumentsMetadata.prototype.endTime = null; + + /** + * ExportDocumentsMetadata operationState. + * @member {google.firestore.admin.v1.OperationState} operationState + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @instance + */ + ExportDocumentsMetadata.prototype.operationState = 0; + + /** + * ExportDocumentsMetadata progressDocuments. + * @member {google.firestore.admin.v1.IProgress|null|undefined} progressDocuments + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @instance + */ + ExportDocumentsMetadata.prototype.progressDocuments = null; + + /** + * ExportDocumentsMetadata progressBytes. + * @member {google.firestore.admin.v1.IProgress|null|undefined} progressBytes + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @instance + */ + ExportDocumentsMetadata.prototype.progressBytes = null; + + /** + * ExportDocumentsMetadata collectionIds. + * @member {Array.} collectionIds + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @instance + */ + ExportDocumentsMetadata.prototype.collectionIds = $util.emptyArray; + + /** + * ExportDocumentsMetadata outputUriPrefix. + * @member {string} outputUriPrefix + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @instance + */ + ExportDocumentsMetadata.prototype.outputUriPrefix = ""; + + return ExportDocumentsMetadata; + })(); + + v1.ImportDocumentsMetadata = (function() { + + /** + * Properties of an ImportDocumentsMetadata. + * @memberof google.firestore.admin.v1 + * @interface IImportDocumentsMetadata + * @property {google.protobuf.ITimestamp|null} [startTime] ImportDocumentsMetadata startTime + * @property {google.protobuf.ITimestamp|null} [endTime] ImportDocumentsMetadata endTime + * @property {google.firestore.admin.v1.OperationState|null} [operationState] ImportDocumentsMetadata operationState + * @property {google.firestore.admin.v1.IProgress|null} [progressDocuments] ImportDocumentsMetadata progressDocuments + * @property {google.firestore.admin.v1.IProgress|null} [progressBytes] ImportDocumentsMetadata progressBytes + * @property {Array.|null} [collectionIds] ImportDocumentsMetadata collectionIds + * @property {string|null} [inputUriPrefix] ImportDocumentsMetadata inputUriPrefix + */ + + /** + * Constructs a new ImportDocumentsMetadata. + * @memberof google.firestore.admin.v1 + * @classdesc Represents an ImportDocumentsMetadata. + * @implements IImportDocumentsMetadata + * @constructor + * @param {google.firestore.admin.v1.IImportDocumentsMetadata=} [properties] Properties to set + */ + function ImportDocumentsMetadata(properties) { + this.collectionIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ImportDocumentsMetadata startTime. + * @member {google.protobuf.ITimestamp|null|undefined} startTime + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @instance + */ + ImportDocumentsMetadata.prototype.startTime = null; + + /** + * ImportDocumentsMetadata endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @instance + */ + ImportDocumentsMetadata.prototype.endTime = null; + + /** + * ImportDocumentsMetadata operationState. + * @member {google.firestore.admin.v1.OperationState} operationState + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @instance + */ + ImportDocumentsMetadata.prototype.operationState = 0; + + /** + * ImportDocumentsMetadata progressDocuments. + * @member {google.firestore.admin.v1.IProgress|null|undefined} progressDocuments + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @instance + */ + ImportDocumentsMetadata.prototype.progressDocuments = null; + + /** + * ImportDocumentsMetadata progressBytes. + * @member {google.firestore.admin.v1.IProgress|null|undefined} progressBytes + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @instance + */ + ImportDocumentsMetadata.prototype.progressBytes = null; + + /** + * ImportDocumentsMetadata collectionIds. + * @member {Array.} collectionIds + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @instance + */ + ImportDocumentsMetadata.prototype.collectionIds = $util.emptyArray; + + /** + * ImportDocumentsMetadata inputUriPrefix. + * @member {string} inputUriPrefix + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @instance + */ + ImportDocumentsMetadata.prototype.inputUriPrefix = ""; + + return ImportDocumentsMetadata; + })(); + + v1.ExportDocumentsResponse = (function() { + + /** + * Properties of an ExportDocumentsResponse. + * @memberof google.firestore.admin.v1 + * @interface IExportDocumentsResponse + * @property {string|null} [outputUriPrefix] ExportDocumentsResponse outputUriPrefix + */ + + /** + * Constructs a new ExportDocumentsResponse. + * @memberof google.firestore.admin.v1 + * @classdesc Represents an ExportDocumentsResponse. + * @implements IExportDocumentsResponse + * @constructor + * @param {google.firestore.admin.v1.IExportDocumentsResponse=} [properties] Properties to set + */ + function ExportDocumentsResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExportDocumentsResponse outputUriPrefix. + * @member {string} outputUriPrefix + * @memberof google.firestore.admin.v1.ExportDocumentsResponse + * @instance + */ + ExportDocumentsResponse.prototype.outputUriPrefix = ""; + + return ExportDocumentsResponse; + })(); + + v1.Progress = (function() { + + /** + * Properties of a Progress. + * @memberof google.firestore.admin.v1 + * @interface IProgress + * @property {number|null} [estimatedWork] Progress estimatedWork + * @property {number|null} [completedWork] Progress completedWork + */ + + /** + * Constructs a new Progress. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a Progress. + * @implements IProgress + * @constructor + * @param {google.firestore.admin.v1.IProgress=} [properties] Properties to set + */ + function Progress(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Progress estimatedWork. + * @member {number} estimatedWork + * @memberof google.firestore.admin.v1.Progress + * @instance + */ + Progress.prototype.estimatedWork = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Progress completedWork. + * @member {number} completedWork + * @memberof google.firestore.admin.v1.Progress + * @instance + */ + Progress.prototype.completedWork = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + return Progress; + })(); + + /** + * OperationState enum. + * @name google.firestore.admin.v1.OperationState + * @enum {number} + * @property {string} OPERATION_STATE_UNSPECIFIED=OPERATION_STATE_UNSPECIFIED OPERATION_STATE_UNSPECIFIED value + * @property {string} INITIALIZING=INITIALIZING INITIALIZING value + * @property {string} PROCESSING=PROCESSING PROCESSING value + * @property {string} CANCELLING=CANCELLING CANCELLING value + * @property {string} FINALIZING=FINALIZING FINALIZING value + * @property {string} SUCCESSFUL=SUCCESSFUL SUCCESSFUL value + * @property {string} FAILED=FAILED FAILED value + * @property {string} CANCELLED=CANCELLED CANCELLED value + */ + v1.OperationState = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATION_STATE_UNSPECIFIED"] = "OPERATION_STATE_UNSPECIFIED"; + values[valuesById[1] = "INITIALIZING"] = "INITIALIZING"; + values[valuesById[2] = "PROCESSING"] = "PROCESSING"; + values[valuesById[3] = "CANCELLING"] = "CANCELLING"; + values[valuesById[4] = "FINALIZING"] = "FINALIZING"; + values[valuesById[5] = "SUCCESSFUL"] = "SUCCESSFUL"; + values[valuesById[6] = "FAILED"] = "FAILED"; + values[valuesById[7] = "CANCELLED"] = "CANCELLED"; + return values; + })(); + + return v1; + })(); + + return admin; + })(); + + return firestore; + })(); + + google.api = (function() { + + /** + * Namespace api. + * @memberof google + * @namespace + */ + var api = {}; + + api.Http = (function() { + + /** + * Properties of a Http. + * @memberof google.api + * @interface IHttp + * @property {Array.|null} [rules] Http rules + */ + + /** + * Constructs a new Http. + * @memberof google.api + * @classdesc Represents a Http. + * @implements IHttp + * @constructor + * @param {google.api.IHttp=} [properties] Properties to set + */ + function Http(properties) { + this.rules = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Http rules. + * @member {Array.} rules + * @memberof google.api.Http + * @instance + */ + Http.prototype.rules = $util.emptyArray; + + return Http; + })(); + + api.HttpRule = (function() { + + /** + * Properties of a HttpRule. + * @memberof google.api + * @interface IHttpRule + * @property {string|null} [get] HttpRule get + * @property {string|null} [put] HttpRule put + * @property {string|null} [post] HttpRule post + * @property {string|null} ["delete"] HttpRule delete + * @property {string|null} [patch] HttpRule patch + * @property {google.api.ICustomHttpPattern|null} [custom] HttpRule custom + * @property {string|null} [selector] HttpRule selector + * @property {string|null} [body] HttpRule body + * @property {Array.|null} [additionalBindings] HttpRule additionalBindings + */ + + /** + * Constructs a new HttpRule. + * @memberof google.api + * @classdesc Represents a HttpRule. + * @implements IHttpRule + * @constructor + * @param {google.api.IHttpRule=} [properties] Properties to set + */ + function HttpRule(properties) { + this.additionalBindings = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * HttpRule get. + * @member {string} get + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.get = ""; + + /** + * HttpRule put. + * @member {string} put + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.put = ""; + + /** + * HttpRule post. + * @member {string} post + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.post = ""; + + /** + * HttpRule delete. + * @member {string} delete + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype["delete"] = ""; + + /** + * HttpRule patch. + * @member {string} patch + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.patch = ""; + + /** + * HttpRule custom. + * @member {google.api.ICustomHttpPattern|null|undefined} custom + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.custom = null; + + /** + * HttpRule selector. + * @member {string} selector + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.selector = ""; + + /** + * HttpRule body. + * @member {string} body + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.body = ""; + + /** + * HttpRule additionalBindings. + * @member {Array.} additionalBindings + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.additionalBindings = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * HttpRule pattern. + * @member {"get"|"put"|"post"|"delete"|"patch"|"custom"|undefined} pattern + * @memberof google.api.HttpRule + * @instance + */ + Object.defineProperty(HttpRule.prototype, "pattern", { + get: $util.oneOfGetter($oneOfFields = ["get", "put", "post", "delete", "patch", "custom"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return HttpRule; + })(); + + api.CustomHttpPattern = (function() { + + /** + * Properties of a CustomHttpPattern. + * @memberof google.api + * @interface ICustomHttpPattern + * @property {string|null} [kind] CustomHttpPattern kind + * @property {string|null} [path] CustomHttpPattern path + */ + + /** + * Constructs a new CustomHttpPattern. + * @memberof google.api + * @classdesc Represents a CustomHttpPattern. + * @implements ICustomHttpPattern + * @constructor + * @param {google.api.ICustomHttpPattern=} [properties] Properties to set + */ + function CustomHttpPattern(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CustomHttpPattern kind. + * @member {string} kind + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.kind = ""; + + /** + * CustomHttpPattern path. + * @member {string} path + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.path = ""; + + return CustomHttpPattern; + })(); + + /** + * FieldBehavior enum. + * @name google.api.FieldBehavior + * @enum {number} + * @property {string} FIELD_BEHAVIOR_UNSPECIFIED=FIELD_BEHAVIOR_UNSPECIFIED FIELD_BEHAVIOR_UNSPECIFIED value + * @property {string} OPTIONAL=OPTIONAL OPTIONAL value + * @property {string} REQUIRED=REQUIRED REQUIRED value + * @property {string} OUTPUT_ONLY=OUTPUT_ONLY OUTPUT_ONLY value + * @property {string} INPUT_ONLY=INPUT_ONLY INPUT_ONLY value + * @property {string} IMMUTABLE=IMMUTABLE IMMUTABLE value + */ + api.FieldBehavior = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "FIELD_BEHAVIOR_UNSPECIFIED"] = "FIELD_BEHAVIOR_UNSPECIFIED"; + values[valuesById[1] = "OPTIONAL"] = "OPTIONAL"; + values[valuesById[2] = "REQUIRED"] = "REQUIRED"; + values[valuesById[3] = "OUTPUT_ONLY"] = "OUTPUT_ONLY"; + values[valuesById[4] = "INPUT_ONLY"] = "INPUT_ONLY"; + values[valuesById[5] = "IMMUTABLE"] = "IMMUTABLE"; + return values; + })(); + + api.ResourceDescriptor = (function() { + + /** + * Properties of a ResourceDescriptor. + * @memberof google.api + * @interface IResourceDescriptor + * @property {string|null} [type] ResourceDescriptor type + * @property {Array.|null} [pattern] ResourceDescriptor pattern + * @property {string|null} [nameField] ResourceDescriptor nameField + * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history + * @property {string|null} [plural] ResourceDescriptor plural + * @property {string|null} [singular] ResourceDescriptor singular + */ + + /** + * Constructs a new ResourceDescriptor. + * @memberof google.api + * @classdesc Represents a ResourceDescriptor. + * @implements IResourceDescriptor + * @constructor + * @param {google.api.IResourceDescriptor=} [properties] Properties to set + */ + function ResourceDescriptor(properties) { + this.pattern = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResourceDescriptor type. + * @member {string} type + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.type = ""; + + /** + * ResourceDescriptor pattern. + * @member {Array.} pattern + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.pattern = $util.emptyArray; + + /** + * ResourceDescriptor nameField. + * @member {string} nameField + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.nameField = ""; + + /** + * ResourceDescriptor history. + * @member {google.api.ResourceDescriptor.History} history + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.history = 0; + + /** + * ResourceDescriptor plural. + * @member {string} plural + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.plural = ""; + + /** + * ResourceDescriptor singular. + * @member {string} singular + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.singular = ""; + + /** + * History enum. + * @name google.api.ResourceDescriptor.History + * @enum {number} + * @property {string} HISTORY_UNSPECIFIED=HISTORY_UNSPECIFIED HISTORY_UNSPECIFIED value + * @property {string} ORIGINALLY_SINGLE_PATTERN=ORIGINALLY_SINGLE_PATTERN ORIGINALLY_SINGLE_PATTERN value + * @property {string} FUTURE_MULTI_PATTERN=FUTURE_MULTI_PATTERN FUTURE_MULTI_PATTERN value + */ + ResourceDescriptor.History = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "HISTORY_UNSPECIFIED"] = "HISTORY_UNSPECIFIED"; + values[valuesById[1] = "ORIGINALLY_SINGLE_PATTERN"] = "ORIGINALLY_SINGLE_PATTERN"; + values[valuesById[2] = "FUTURE_MULTI_PATTERN"] = "FUTURE_MULTI_PATTERN"; + return values; + })(); + + return ResourceDescriptor; + })(); + + api.ResourceReference = (function() { + + /** + * Properties of a ResourceReference. + * @memberof google.api + * @interface IResourceReference + * @property {string|null} [type] ResourceReference type + * @property {string|null} [childType] ResourceReference childType + */ + + /** + * Constructs a new ResourceReference. + * @memberof google.api + * @classdesc Represents a ResourceReference. + * @implements IResourceReference + * @constructor + * @param {google.api.IResourceReference=} [properties] Properties to set + */ + function ResourceReference(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResourceReference type. + * @member {string} type + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.type = ""; + + /** + * ResourceReference childType. + * @member {string} childType + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.childType = ""; + + return ResourceReference; + })(); + + return api; + })(); + + google.protobuf = (function() { + + /** + * Namespace protobuf. + * @memberof google + * @namespace + */ + var protobuf = {}; + + protobuf.FileDescriptorSet = (function() { + + /** + * Properties of a FileDescriptorSet. + * @memberof google.protobuf + * @interface IFileDescriptorSet + * @property {Array.|null} [file] FileDescriptorSet file + */ + + /** + * Constructs a new FileDescriptorSet. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorSet. + * @implements IFileDescriptorSet + * @constructor + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + */ + function FileDescriptorSet(properties) { + this.file = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FileDescriptorSet file. + * @member {Array.} file + * @memberof google.protobuf.FileDescriptorSet + * @instance + */ + FileDescriptorSet.prototype.file = $util.emptyArray; + + return FileDescriptorSet; + })(); + + protobuf.FileDescriptorProto = (function() { + + /** + * Properties of a FileDescriptorProto. + * @memberof google.protobuf + * @interface IFileDescriptorProto + * @property {string|null} [name] FileDescriptorProto name + * @property {string|null} ["package"] FileDescriptorProto package + * @property {Array.|null} [dependency] FileDescriptorProto dependency + * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency + * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [messageType] FileDescriptorProto messageType + * @property {Array.|null} [enumType] FileDescriptorProto enumType + * @property {Array.|null} [service] FileDescriptorProto service + * @property {Array.|null} [extension] FileDescriptorProto extension + * @property {google.protobuf.IFileOptions|null} [options] FileDescriptorProto options + * @property {google.protobuf.ISourceCodeInfo|null} [sourceCodeInfo] FileDescriptorProto sourceCodeInfo + * @property {string|null} [syntax] FileDescriptorProto syntax + */ + + /** + * Constructs a new FileDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorProto. + * @implements IFileDescriptorProto + * @constructor + * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set + */ + function FileDescriptorProto(properties) { + this.dependency = []; + this.publicDependency = []; + this.weakDependency = []; + this.messageType = []; + this.enumType = []; + this.service = []; + this.extension = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FileDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.name = ""; + + /** + * FileDescriptorProto package. + * @member {string} package + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype["package"] = ""; + + /** + * FileDescriptorProto dependency. + * @member {Array.} dependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.dependency = $util.emptyArray; + + /** + * FileDescriptorProto publicDependency. + * @member {Array.} publicDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.publicDependency = $util.emptyArray; + + /** + * FileDescriptorProto weakDependency. + * @member {Array.} weakDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + + /** + * FileDescriptorProto messageType. + * @member {Array.} messageType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.messageType = $util.emptyArray; + + /** + * FileDescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.enumType = $util.emptyArray; + + /** + * FileDescriptorProto service. + * @member {Array.} service + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.service = $util.emptyArray; + + /** + * FileDescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.extension = $util.emptyArray; + + /** + * FileDescriptorProto options. + * @member {google.protobuf.IFileOptions|null|undefined} options + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.options = null; + + /** + * FileDescriptorProto sourceCodeInfo. + * @member {google.protobuf.ISourceCodeInfo|null|undefined} sourceCodeInfo + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.sourceCodeInfo = null; + + /** + * FileDescriptorProto syntax. + * @member {string} syntax + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.syntax = ""; + + return FileDescriptorProto; + })(); + + protobuf.DescriptorProto = (function() { + + /** + * Properties of a DescriptorProto. + * @memberof google.protobuf + * @interface IDescriptorProto + * @property {string|null} [name] DescriptorProto name + * @property {Array.|null} [field] DescriptorProto field + * @property {Array.|null} [extension] DescriptorProto extension + * @property {Array.|null} [nestedType] DescriptorProto nestedType + * @property {Array.|null} [enumType] DescriptorProto enumType + * @property {Array.|null} [extensionRange] DescriptorProto extensionRange + * @property {Array.|null} [oneofDecl] DescriptorProto oneofDecl + * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options + * @property {Array.|null} [reservedRange] DescriptorProto reservedRange + * @property {Array.|null} [reservedName] DescriptorProto reservedName + */ + + /** + * Constructs a new DescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a DescriptorProto. + * @implements IDescriptorProto + * @constructor + * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set + */ + function DescriptorProto(properties) { + this.field = []; + this.extension = []; + this.nestedType = []; + this.enumType = []; + this.extensionRange = []; + this.oneofDecl = []; + this.reservedRange = []; + this.reservedName = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DescriptorProto name. + * @member {string} name + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.name = ""; + + /** + * DescriptorProto field. + * @member {Array.} field + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.field = $util.emptyArray; + + /** + * DescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extension = $util.emptyArray; + + /** + * DescriptorProto nestedType. + * @member {Array.} nestedType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.nestedType = $util.emptyArray; + + /** + * DescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.enumType = $util.emptyArray; + + /** + * DescriptorProto extensionRange. + * @member {Array.} extensionRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extensionRange = $util.emptyArray; + + /** + * DescriptorProto oneofDecl. + * @member {Array.} oneofDecl + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.oneofDecl = $util.emptyArray; + + /** + * DescriptorProto options. + * @member {google.protobuf.IMessageOptions|null|undefined} options + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.options = null; + + /** + * DescriptorProto reservedRange. + * @member {Array.} reservedRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedRange = $util.emptyArray; + + /** + * DescriptorProto reservedName. + * @member {Array.} reservedName + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedName = $util.emptyArray; + + DescriptorProto.ExtensionRange = (function() { + + /** + * Properties of an ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @interface IExtensionRange + * @property {number|null} [start] ExtensionRange start + * @property {number|null} [end] ExtensionRange end + */ + + /** + * Constructs a new ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents an ExtensionRange. + * @implements IExtensionRange + * @constructor + * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set + */ + function ExtensionRange(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExtensionRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.start = 0; + + /** + * ExtensionRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.end = 0; + + return ExtensionRange; + })(); + + DescriptorProto.ReservedRange = (function() { + + /** + * Properties of a ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @interface IReservedRange + * @property {number|null} [start] ReservedRange start + * @property {number|null} [end] ReservedRange end + */ + + /** + * Constructs a new ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents a ReservedRange. + * @implements IReservedRange + * @constructor + * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set + */ + function ReservedRange(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReservedRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.start = 0; + + /** + * ReservedRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.end = 0; + + return ReservedRange; + })(); + + return DescriptorProto; + })(); + + protobuf.FieldDescriptorProto = (function() { + + /** + * Properties of a FieldDescriptorProto. + * @memberof google.protobuf + * @interface IFieldDescriptorProto + * @property {string|null} [name] FieldDescriptorProto name + * @property {number|null} [number] FieldDescriptorProto number + * @property {google.protobuf.FieldDescriptorProto.Label|null} [label] FieldDescriptorProto label + * @property {google.protobuf.FieldDescriptorProto.Type|null} [type] FieldDescriptorProto type + * @property {string|null} [typeName] FieldDescriptorProto typeName + * @property {string|null} [extendee] FieldDescriptorProto extendee + * @property {string|null} [defaultValue] FieldDescriptorProto defaultValue + * @property {number|null} [oneofIndex] FieldDescriptorProto oneofIndex + * @property {string|null} [jsonName] FieldDescriptorProto jsonName + * @property {google.protobuf.IFieldOptions|null} [options] FieldDescriptorProto options + */ + + /** + * Constructs a new FieldDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FieldDescriptorProto. + * @implements IFieldDescriptorProto + * @constructor + * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set + */ + function FieldDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.name = ""; + + /** + * FieldDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.number = 0; + + /** + * FieldDescriptorProto label. + * @member {google.protobuf.FieldDescriptorProto.Label} label + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.label = 1; + + /** + * FieldDescriptorProto type. + * @member {google.protobuf.FieldDescriptorProto.Type} type + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.type = 1; + + /** + * FieldDescriptorProto typeName. + * @member {string} typeName + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.typeName = ""; + + /** + * FieldDescriptorProto extendee. + * @member {string} extendee + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.extendee = ""; + + /** + * FieldDescriptorProto defaultValue. + * @member {string} defaultValue + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.defaultValue = ""; + + /** + * FieldDescriptorProto oneofIndex. + * @member {number} oneofIndex + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.oneofIndex = 0; + + /** + * FieldDescriptorProto jsonName. + * @member {string} jsonName + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.jsonName = ""; + + /** + * FieldDescriptorProto options. + * @member {google.protobuf.IFieldOptions|null|undefined} options + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.options = null; + + /** + * Type enum. + * @name google.protobuf.FieldDescriptorProto.Type + * @enum {number} + * @property {string} TYPE_DOUBLE=TYPE_DOUBLE TYPE_DOUBLE value + * @property {string} TYPE_FLOAT=TYPE_FLOAT TYPE_FLOAT value + * @property {string} TYPE_INT64=TYPE_INT64 TYPE_INT64 value + * @property {string} TYPE_UINT64=TYPE_UINT64 TYPE_UINT64 value + * @property {string} TYPE_INT32=TYPE_INT32 TYPE_INT32 value + * @property {string} TYPE_FIXED64=TYPE_FIXED64 TYPE_FIXED64 value + * @property {string} TYPE_FIXED32=TYPE_FIXED32 TYPE_FIXED32 value + * @property {string} TYPE_BOOL=TYPE_BOOL TYPE_BOOL value + * @property {string} TYPE_STRING=TYPE_STRING TYPE_STRING value + * @property {string} TYPE_GROUP=TYPE_GROUP TYPE_GROUP value + * @property {string} TYPE_MESSAGE=TYPE_MESSAGE TYPE_MESSAGE value + * @property {string} TYPE_BYTES=TYPE_BYTES TYPE_BYTES value + * @property {string} TYPE_UINT32=TYPE_UINT32 TYPE_UINT32 value + * @property {string} TYPE_ENUM=TYPE_ENUM TYPE_ENUM value + * @property {string} TYPE_SFIXED32=TYPE_SFIXED32 TYPE_SFIXED32 value + * @property {string} TYPE_SFIXED64=TYPE_SFIXED64 TYPE_SFIXED64 value + * @property {string} TYPE_SINT32=TYPE_SINT32 TYPE_SINT32 value + * @property {string} TYPE_SINT64=TYPE_SINT64 TYPE_SINT64 value + */ + FieldDescriptorProto.Type = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "TYPE_DOUBLE"] = "TYPE_DOUBLE"; + values[valuesById[2] = "TYPE_FLOAT"] = "TYPE_FLOAT"; + values[valuesById[3] = "TYPE_INT64"] = "TYPE_INT64"; + values[valuesById[4] = "TYPE_UINT64"] = "TYPE_UINT64"; + values[valuesById[5] = "TYPE_INT32"] = "TYPE_INT32"; + values[valuesById[6] = "TYPE_FIXED64"] = "TYPE_FIXED64"; + values[valuesById[7] = "TYPE_FIXED32"] = "TYPE_FIXED32"; + values[valuesById[8] = "TYPE_BOOL"] = "TYPE_BOOL"; + values[valuesById[9] = "TYPE_STRING"] = "TYPE_STRING"; + values[valuesById[10] = "TYPE_GROUP"] = "TYPE_GROUP"; + values[valuesById[11] = "TYPE_MESSAGE"] = "TYPE_MESSAGE"; + values[valuesById[12] = "TYPE_BYTES"] = "TYPE_BYTES"; + values[valuesById[13] = "TYPE_UINT32"] = "TYPE_UINT32"; + values[valuesById[14] = "TYPE_ENUM"] = "TYPE_ENUM"; + values[valuesById[15] = "TYPE_SFIXED32"] = "TYPE_SFIXED32"; + values[valuesById[16] = "TYPE_SFIXED64"] = "TYPE_SFIXED64"; + values[valuesById[17] = "TYPE_SINT32"] = "TYPE_SINT32"; + values[valuesById[18] = "TYPE_SINT64"] = "TYPE_SINT64"; + return values; + })(); + + /** + * Label enum. + * @name google.protobuf.FieldDescriptorProto.Label + * @enum {number} + * @property {string} LABEL_OPTIONAL=LABEL_OPTIONAL LABEL_OPTIONAL value + * @property {string} LABEL_REQUIRED=LABEL_REQUIRED LABEL_REQUIRED value + * @property {string} LABEL_REPEATED=LABEL_REPEATED LABEL_REPEATED value + */ + FieldDescriptorProto.Label = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "LABEL_OPTIONAL"] = "LABEL_OPTIONAL"; + values[valuesById[2] = "LABEL_REQUIRED"] = "LABEL_REQUIRED"; + values[valuesById[3] = "LABEL_REPEATED"] = "LABEL_REPEATED"; + return values; + })(); + + return FieldDescriptorProto; + })(); + + protobuf.OneofDescriptorProto = (function() { + + /** + * Properties of an OneofDescriptorProto. + * @memberof google.protobuf + * @interface IOneofDescriptorProto + * @property {string|null} [name] OneofDescriptorProto name + * @property {google.protobuf.IOneofOptions|null} [options] OneofDescriptorProto options + */ + + /** + * Constructs a new OneofDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an OneofDescriptorProto. + * @implements IOneofDescriptorProto + * @constructor + * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set + */ + function OneofDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OneofDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.OneofDescriptorProto + * @instance + */ + OneofDescriptorProto.prototype.name = ""; + + /** + * OneofDescriptorProto options. + * @member {google.protobuf.IOneofOptions|null|undefined} options + * @memberof google.protobuf.OneofDescriptorProto + * @instance + */ + OneofDescriptorProto.prototype.options = null; + + return OneofDescriptorProto; + })(); + + protobuf.EnumDescriptorProto = (function() { + + /** + * Properties of an EnumDescriptorProto. + * @memberof google.protobuf + * @interface IEnumDescriptorProto + * @property {string|null} [name] EnumDescriptorProto name + * @property {Array.|null} [value] EnumDescriptorProto value + * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options + */ + + /** + * Constructs a new EnumDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumDescriptorProto. + * @implements IEnumDescriptorProto + * @constructor + * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set + */ + function EnumDescriptorProto(properties) { + this.value = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.name = ""; + + /** + * EnumDescriptorProto value. + * @member {Array.} value + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.value = $util.emptyArray; + + /** + * EnumDescriptorProto options. + * @member {google.protobuf.IEnumOptions|null|undefined} options + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.options = null; + + return EnumDescriptorProto; + })(); + + protobuf.EnumValueDescriptorProto = (function() { + + /** + * Properties of an EnumValueDescriptorProto. + * @memberof google.protobuf + * @interface IEnumValueDescriptorProto + * @property {string|null} [name] EnumValueDescriptorProto name + * @property {number|null} [number] EnumValueDescriptorProto number + * @property {google.protobuf.IEnumValueOptions|null} [options] EnumValueDescriptorProto options + */ + + /** + * Constructs a new EnumValueDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumValueDescriptorProto. + * @implements IEnumValueDescriptorProto + * @constructor + * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set + */ + function EnumValueDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumValueDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.name = ""; + + /** + * EnumValueDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.number = 0; + + /** + * EnumValueDescriptorProto options. + * @member {google.protobuf.IEnumValueOptions|null|undefined} options + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.options = null; + + return EnumValueDescriptorProto; + })(); + + protobuf.ServiceDescriptorProto = (function() { + + /** + * Properties of a ServiceDescriptorProto. + * @memberof google.protobuf + * @interface IServiceDescriptorProto + * @property {string|null} [name] ServiceDescriptorProto name + * @property {Array.|null} [method] ServiceDescriptorProto method + * @property {google.protobuf.IServiceOptions|null} [options] ServiceDescriptorProto options + */ + + /** + * Constructs a new ServiceDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a ServiceDescriptorProto. + * @implements IServiceDescriptorProto + * @constructor + * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set + */ + function ServiceDescriptorProto(properties) { + this.method = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ServiceDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.name = ""; + + /** + * ServiceDescriptorProto method. + * @member {Array.} method + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.method = $util.emptyArray; + + /** + * ServiceDescriptorProto options. + * @member {google.protobuf.IServiceOptions|null|undefined} options + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.options = null; + + return ServiceDescriptorProto; + })(); + + protobuf.MethodDescriptorProto = (function() { + + /** + * Properties of a MethodDescriptorProto. + * @memberof google.protobuf + * @interface IMethodDescriptorProto + * @property {string|null} [name] MethodDescriptorProto name + * @property {string|null} [inputType] MethodDescriptorProto inputType + * @property {string|null} [outputType] MethodDescriptorProto outputType + * @property {google.protobuf.IMethodOptions|null} [options] MethodDescriptorProto options + * @property {boolean|null} [clientStreaming] MethodDescriptorProto clientStreaming + * @property {boolean|null} [serverStreaming] MethodDescriptorProto serverStreaming + */ + + /** + * Constructs a new MethodDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a MethodDescriptorProto. + * @implements IMethodDescriptorProto + * @constructor + * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set + */ + function MethodDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MethodDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.name = ""; + + /** + * MethodDescriptorProto inputType. + * @member {string} inputType + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.inputType = ""; + + /** + * MethodDescriptorProto outputType. + * @member {string} outputType + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.outputType = ""; + + /** + * MethodDescriptorProto options. + * @member {google.protobuf.IMethodOptions|null|undefined} options + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.options = null; + + /** + * MethodDescriptorProto clientStreaming. + * @member {boolean} clientStreaming + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.clientStreaming = false; + + /** + * MethodDescriptorProto serverStreaming. + * @member {boolean} serverStreaming + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.serverStreaming = false; + + return MethodDescriptorProto; + })(); + + protobuf.FileOptions = (function() { + + /** + * Properties of a FileOptions. + * @memberof google.protobuf + * @interface IFileOptions + * @property {string|null} [javaPackage] FileOptions javaPackage + * @property {string|null} [javaOuterClassname] FileOptions javaOuterClassname + * @property {boolean|null} [javaMultipleFiles] FileOptions javaMultipleFiles + * @property {boolean|null} [javaGenerateEqualsAndHash] FileOptions javaGenerateEqualsAndHash + * @property {boolean|null} [javaStringCheckUtf8] FileOptions javaStringCheckUtf8 + * @property {google.protobuf.FileOptions.OptimizeMode|null} [optimizeFor] FileOptions optimizeFor + * @property {string|null} [goPackage] FileOptions goPackage + * @property {boolean|null} [ccGenericServices] FileOptions ccGenericServices + * @property {boolean|null} [javaGenericServices] FileOptions javaGenericServices + * @property {boolean|null} [pyGenericServices] FileOptions pyGenericServices + * @property {boolean|null} [deprecated] FileOptions deprecated + * @property {boolean|null} [ccEnableArenas] FileOptions ccEnableArenas + * @property {string|null} [objcClassPrefix] FileOptions objcClassPrefix + * @property {string|null} [csharpNamespace] FileOptions csharpNamespace + * @property {Array.|null} [uninterpretedOption] FileOptions uninterpretedOption + * @property {Array.|null} [".google.api.resourceDefinition"] FileOptions .google.api.resourceDefinition + */ + + /** + * Constructs a new FileOptions. + * @memberof google.protobuf + * @classdesc Represents a FileOptions. + * @implements IFileOptions + * @constructor + * @param {google.protobuf.IFileOptions=} [properties] Properties to set + */ + function FileOptions(properties) { + this.uninterpretedOption = []; + this[".google.api.resourceDefinition"] = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FileOptions javaPackage. + * @member {string} javaPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaPackage = ""; + + /** + * FileOptions javaOuterClassname. + * @member {string} javaOuterClassname + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaOuterClassname = ""; + + /** + * FileOptions javaMultipleFiles. + * @member {boolean} javaMultipleFiles + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaMultipleFiles = false; + + /** + * FileOptions javaGenerateEqualsAndHash. + * @member {boolean} javaGenerateEqualsAndHash + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaGenerateEqualsAndHash = false; + + /** + * FileOptions javaStringCheckUtf8. + * @member {boolean} javaStringCheckUtf8 + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaStringCheckUtf8 = false; + + /** + * FileOptions optimizeFor. + * @member {google.protobuf.FileOptions.OptimizeMode} optimizeFor + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.optimizeFor = 1; + + /** + * FileOptions goPackage. + * @member {string} goPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.goPackage = ""; + + /** + * FileOptions ccGenericServices. + * @member {boolean} ccGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.ccGenericServices = false; + + /** + * FileOptions javaGenericServices. + * @member {boolean} javaGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaGenericServices = false; + + /** + * FileOptions pyGenericServices. + * @member {boolean} pyGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.pyGenericServices = false; + + /** + * FileOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.deprecated = false; + + /** + * FileOptions ccEnableArenas. + * @member {boolean} ccEnableArenas + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.ccEnableArenas = false; + + /** + * FileOptions objcClassPrefix. + * @member {string} objcClassPrefix + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.objcClassPrefix = ""; + + /** + * FileOptions csharpNamespace. + * @member {string} csharpNamespace + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.csharpNamespace = ""; + + /** + * FileOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * FileOptions .google.api.resourceDefinition. + * @member {Array.} .google.api.resourceDefinition + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype[".google.api.resourceDefinition"] = $util.emptyArray; + + /** + * OptimizeMode enum. + * @name google.protobuf.FileOptions.OptimizeMode + * @enum {number} + * @property {string} SPEED=SPEED SPEED value + * @property {string} CODE_SIZE=CODE_SIZE CODE_SIZE value + * @property {string} LITE_RUNTIME=LITE_RUNTIME LITE_RUNTIME value + */ + FileOptions.OptimizeMode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "SPEED"] = "SPEED"; + values[valuesById[2] = "CODE_SIZE"] = "CODE_SIZE"; + values[valuesById[3] = "LITE_RUNTIME"] = "LITE_RUNTIME"; + return values; + })(); + + return FileOptions; + })(); + + protobuf.MessageOptions = (function() { + + /** + * Properties of a MessageOptions. + * @memberof google.protobuf + * @interface IMessageOptions + * @property {boolean|null} [messageSetWireFormat] MessageOptions messageSetWireFormat + * @property {boolean|null} [noStandardDescriptorAccessor] MessageOptions noStandardDescriptorAccessor + * @property {boolean|null} [deprecated] MessageOptions deprecated + * @property {boolean|null} [mapEntry] MessageOptions mapEntry + * @property {Array.|null} [uninterpretedOption] MessageOptions uninterpretedOption + * @property {google.api.IResourceDescriptor|null} [".google.api.resource"] MessageOptions .google.api.resource + */ + + /** + * Constructs a new MessageOptions. + * @memberof google.protobuf + * @classdesc Represents a MessageOptions. + * @implements IMessageOptions + * @constructor + * @param {google.protobuf.IMessageOptions=} [properties] Properties to set + */ + function MessageOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MessageOptions messageSetWireFormat. + * @member {boolean} messageSetWireFormat + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.messageSetWireFormat = false; + + /** + * MessageOptions noStandardDescriptorAccessor. + * @member {boolean} noStandardDescriptorAccessor + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.noStandardDescriptorAccessor = false; + + /** + * MessageOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.deprecated = false; + + /** + * MessageOptions mapEntry. + * @member {boolean} mapEntry + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.mapEntry = false; + + /** + * MessageOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * MessageOptions .google.api.resource. + * @member {google.api.IResourceDescriptor|null|undefined} .google.api.resource + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype[".google.api.resource"] = null; + + return MessageOptions; + })(); + + protobuf.FieldOptions = (function() { + + /** + * Properties of a FieldOptions. + * @memberof google.protobuf + * @interface IFieldOptions + * @property {google.protobuf.FieldOptions.CType|null} [ctype] FieldOptions ctype + * @property {boolean|null} [packed] FieldOptions packed + * @property {google.protobuf.FieldOptions.JSType|null} [jstype] FieldOptions jstype + * @property {boolean|null} [lazy] FieldOptions lazy + * @property {boolean|null} [deprecated] FieldOptions deprecated + * @property {boolean|null} [weak] FieldOptions weak + * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption + * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior + * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference + */ + + /** + * Constructs a new FieldOptions. + * @memberof google.protobuf + * @classdesc Represents a FieldOptions. + * @implements IFieldOptions + * @constructor + * @param {google.protobuf.IFieldOptions=} [properties] Properties to set + */ + function FieldOptions(properties) { + this.uninterpretedOption = []; + this[".google.api.fieldBehavior"] = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldOptions ctype. + * @member {google.protobuf.FieldOptions.CType} ctype + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.ctype = 0; + + /** + * FieldOptions packed. + * @member {boolean} packed + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.packed = false; + + /** + * FieldOptions jstype. + * @member {google.protobuf.FieldOptions.JSType} jstype + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.jstype = 0; + + /** + * FieldOptions lazy. + * @member {boolean} lazy + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.lazy = false; + + /** + * FieldOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.deprecated = false; + + /** + * FieldOptions weak. + * @member {boolean} weak + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.weak = false; + + /** + * FieldOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * FieldOptions .google.api.fieldBehavior. + * @member {Array.} .google.api.fieldBehavior + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype[".google.api.fieldBehavior"] = $util.emptyArray; + + /** + * FieldOptions .google.api.resourceReference. + * @member {google.api.IResourceReference|null|undefined} .google.api.resourceReference + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype[".google.api.resourceReference"] = null; + + /** + * CType enum. + * @name google.protobuf.FieldOptions.CType + * @enum {number} + * @property {string} STRING=STRING STRING value + * @property {string} CORD=CORD CORD value + * @property {string} STRING_PIECE=STRING_PIECE STRING_PIECE value + */ + FieldOptions.CType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STRING"] = "STRING"; + values[valuesById[1] = "CORD"] = "CORD"; + values[valuesById[2] = "STRING_PIECE"] = "STRING_PIECE"; + return values; + })(); + + /** + * JSType enum. + * @name google.protobuf.FieldOptions.JSType + * @enum {number} + * @property {string} JS_NORMAL=JS_NORMAL JS_NORMAL value + * @property {string} JS_STRING=JS_STRING JS_STRING value + * @property {string} JS_NUMBER=JS_NUMBER JS_NUMBER value + */ + FieldOptions.JSType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "JS_NORMAL"] = "JS_NORMAL"; + values[valuesById[1] = "JS_STRING"] = "JS_STRING"; + values[valuesById[2] = "JS_NUMBER"] = "JS_NUMBER"; + return values; + })(); + + return FieldOptions; + })(); + + protobuf.OneofOptions = (function() { + + /** + * Properties of an OneofOptions. + * @memberof google.protobuf + * @interface IOneofOptions + * @property {Array.|null} [uninterpretedOption] OneofOptions uninterpretedOption + */ + + /** + * Constructs a new OneofOptions. + * @memberof google.protobuf + * @classdesc Represents an OneofOptions. + * @implements IOneofOptions + * @constructor + * @param {google.protobuf.IOneofOptions=} [properties] Properties to set + */ + function OneofOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OneofOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.OneofOptions + * @instance + */ + OneofOptions.prototype.uninterpretedOption = $util.emptyArray; + + return OneofOptions; + })(); + + protobuf.EnumOptions = (function() { + + /** + * Properties of an EnumOptions. + * @memberof google.protobuf + * @interface IEnumOptions + * @property {boolean|null} [allowAlias] EnumOptions allowAlias + * @property {boolean|null} [deprecated] EnumOptions deprecated + * @property {Array.|null} [uninterpretedOption] EnumOptions uninterpretedOption + */ + + /** + * Constructs a new EnumOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumOptions. + * @implements IEnumOptions + * @constructor + * @param {google.protobuf.IEnumOptions=} [properties] Properties to set + */ + function EnumOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumOptions allowAlias. + * @member {boolean} allowAlias + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.allowAlias = false; + + /** + * EnumOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.deprecated = false; + + /** + * EnumOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.uninterpretedOption = $util.emptyArray; + + return EnumOptions; + })(); + + protobuf.EnumValueOptions = (function() { + + /** + * Properties of an EnumValueOptions. + * @memberof google.protobuf + * @interface IEnumValueOptions + * @property {boolean|null} [deprecated] EnumValueOptions deprecated + * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption + */ + + /** + * Constructs a new EnumValueOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumValueOptions. + * @implements IEnumValueOptions + * @constructor + * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set + */ + function EnumValueOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumValueOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.deprecated = false; + + /** + * EnumValueOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.uninterpretedOption = $util.emptyArray; + + return EnumValueOptions; + })(); + + protobuf.ServiceOptions = (function() { + + /** + * Properties of a ServiceOptions. + * @memberof google.protobuf + * @interface IServiceOptions + * @property {boolean|null} [deprecated] ServiceOptions deprecated + * @property {Array.|null} [uninterpretedOption] ServiceOptions uninterpretedOption + * @property {string|null} [".google.api.defaultHost"] ServiceOptions .google.api.defaultHost + * @property {string|null} [".google.api.oauthScopes"] ServiceOptions .google.api.oauthScopes + */ + + /** + * Constructs a new ServiceOptions. + * @memberof google.protobuf + * @classdesc Represents a ServiceOptions. + * @implements IServiceOptions + * @constructor + * @param {google.protobuf.IServiceOptions=} [properties] Properties to set + */ + function ServiceOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ServiceOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.deprecated = false; + + /** + * ServiceOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * ServiceOptions .google.api.defaultHost. + * @member {string} .google.api.defaultHost + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype[".google.api.defaultHost"] = ""; + + /** + * ServiceOptions .google.api.oauthScopes. + * @member {string} .google.api.oauthScopes + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype[".google.api.oauthScopes"] = ""; + + return ServiceOptions; + })(); + + protobuf.MethodOptions = (function() { + + /** + * Properties of a MethodOptions. + * @memberof google.protobuf + * @interface IMethodOptions + * @property {boolean|null} [deprecated] MethodOptions deprecated + * @property {Array.|null} [uninterpretedOption] MethodOptions uninterpretedOption + * @property {google.api.IHttpRule|null} [".google.api.http"] MethodOptions .google.api.http + * @property {Array.|null} [".google.api.methodSignature"] MethodOptions .google.api.methodSignature + * @property {google.longrunning.IOperationInfo|null} [".google.longrunning.operationInfo"] MethodOptions .google.longrunning.operationInfo + */ + + /** + * Constructs a new MethodOptions. + * @memberof google.protobuf + * @classdesc Represents a MethodOptions. + * @implements IMethodOptions + * @constructor + * @param {google.protobuf.IMethodOptions=} [properties] Properties to set + */ + function MethodOptions(properties) { + this.uninterpretedOption = []; + this[".google.api.methodSignature"] = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MethodOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.deprecated = false; + + /** + * MethodOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * MethodOptions .google.api.http. + * @member {google.api.IHttpRule|null|undefined} .google.api.http + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.api.http"] = null; + + /** + * MethodOptions .google.api.methodSignature. + * @member {Array.} .google.api.methodSignature + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.api.methodSignature"] = $util.emptyArray; + + /** + * MethodOptions .google.longrunning.operationInfo. + * @member {google.longrunning.IOperationInfo|null|undefined} .google.longrunning.operationInfo + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.longrunning.operationInfo"] = null; + + return MethodOptions; + })(); + + protobuf.UninterpretedOption = (function() { + + /** + * Properties of an UninterpretedOption. + * @memberof google.protobuf + * @interface IUninterpretedOption + * @property {Array.|null} [name] UninterpretedOption name + * @property {string|null} [identifierValue] UninterpretedOption identifierValue + * @property {number|null} [positiveIntValue] UninterpretedOption positiveIntValue + * @property {number|null} [negativeIntValue] UninterpretedOption negativeIntValue + * @property {number|null} [doubleValue] UninterpretedOption doubleValue + * @property {Uint8Array|null} [stringValue] UninterpretedOption stringValue + * @property {string|null} [aggregateValue] UninterpretedOption aggregateValue + */ + + /** + * Constructs a new UninterpretedOption. + * @memberof google.protobuf + * @classdesc Represents an UninterpretedOption. + * @implements IUninterpretedOption + * @constructor + * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set + */ + function UninterpretedOption(properties) { + this.name = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UninterpretedOption name. + * @member {Array.} name + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.name = $util.emptyArray; + + /** + * UninterpretedOption identifierValue. + * @member {string} identifierValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.identifierValue = ""; + + /** + * UninterpretedOption positiveIntValue. + * @member {number} positiveIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.positiveIntValue = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * UninterpretedOption negativeIntValue. + * @member {number} negativeIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.negativeIntValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * UninterpretedOption doubleValue. + * @member {number} doubleValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.doubleValue = 0; + + /** + * UninterpretedOption stringValue. + * @member {Uint8Array} stringValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.stringValue = $util.newBuffer([]); + + /** + * UninterpretedOption aggregateValue. + * @member {string} aggregateValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.aggregateValue = ""; + + UninterpretedOption.NamePart = (function() { + + /** + * Properties of a NamePart. + * @memberof google.protobuf.UninterpretedOption + * @interface INamePart + * @property {string} namePart NamePart namePart + * @property {boolean} isExtension NamePart isExtension + */ + + /** + * Constructs a new NamePart. + * @memberof google.protobuf.UninterpretedOption + * @classdesc Represents a NamePart. + * @implements INamePart + * @constructor + * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set + */ + function NamePart(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * NamePart namePart. + * @member {string} namePart + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.namePart = ""; + + /** + * NamePart isExtension. + * @member {boolean} isExtension + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.isExtension = false; + + return NamePart; + })(); + + return UninterpretedOption; + })(); + + protobuf.SourceCodeInfo = (function() { + + /** + * Properties of a SourceCodeInfo. + * @memberof google.protobuf + * @interface ISourceCodeInfo + * @property {Array.|null} [location] SourceCodeInfo location + */ + + /** + * Constructs a new SourceCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a SourceCodeInfo. + * @implements ISourceCodeInfo + * @constructor + * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set + */ + function SourceCodeInfo(properties) { + this.location = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SourceCodeInfo location. + * @member {Array.} location + * @memberof google.protobuf.SourceCodeInfo + * @instance + */ + SourceCodeInfo.prototype.location = $util.emptyArray; + + SourceCodeInfo.Location = (function() { + + /** + * Properties of a Location. + * @memberof google.protobuf.SourceCodeInfo + * @interface ILocation + * @property {Array.|null} [path] Location path + * @property {Array.|null} [span] Location span + * @property {string|null} [leadingComments] Location leadingComments + * @property {string|null} [trailingComments] Location trailingComments + * @property {Array.|null} [leadingDetachedComments] Location leadingDetachedComments + */ + + /** + * Constructs a new Location. + * @memberof google.protobuf.SourceCodeInfo + * @classdesc Represents a Location. + * @implements ILocation + * @constructor + * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set + */ + function Location(properties) { + this.path = []; + this.span = []; + this.leadingDetachedComments = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Location path. + * @member {Array.} path + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.path = $util.emptyArray; + + /** + * Location span. + * @member {Array.} span + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.span = $util.emptyArray; + + /** + * Location leadingComments. + * @member {string} leadingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingComments = ""; + + /** + * Location trailingComments. + * @member {string} trailingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.trailingComments = ""; + + /** + * Location leadingDetachedComments. + * @member {Array.} leadingDetachedComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingDetachedComments = $util.emptyArray; + + return Location; + })(); + + return SourceCodeInfo; + })(); + + protobuf.GeneratedCodeInfo = (function() { + + /** + * Properties of a GeneratedCodeInfo. + * @memberof google.protobuf + * @interface IGeneratedCodeInfo + * @property {Array.|null} [annotation] GeneratedCodeInfo annotation + */ + + /** + * Constructs a new GeneratedCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a GeneratedCodeInfo. + * @implements IGeneratedCodeInfo + * @constructor + * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set + */ + function GeneratedCodeInfo(properties) { + this.annotation = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GeneratedCodeInfo annotation. + * @member {Array.} annotation + * @memberof google.protobuf.GeneratedCodeInfo + * @instance + */ + GeneratedCodeInfo.prototype.annotation = $util.emptyArray; + + GeneratedCodeInfo.Annotation = (function() { + + /** + * Properties of an Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @interface IAnnotation + * @property {Array.|null} [path] Annotation path + * @property {string|null} [sourceFile] Annotation sourceFile + * @property {number|null} [begin] Annotation begin + * @property {number|null} [end] Annotation end + */ + + /** + * Constructs a new Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @classdesc Represents an Annotation. + * @implements IAnnotation + * @constructor + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set + */ + function Annotation(properties) { + this.path = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Annotation path. + * @member {Array.} path + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.path = $util.emptyArray; + + /** + * Annotation sourceFile. + * @member {string} sourceFile + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.sourceFile = ""; + + /** + * Annotation begin. + * @member {number} begin + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.begin = 0; + + /** + * Annotation end. + * @member {number} end + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.end = 0; + + return Annotation; + })(); + + return GeneratedCodeInfo; + })(); + + protobuf.Empty = (function() { + + /** + * Properties of an Empty. + * @memberof google.protobuf + * @interface IEmpty + */ + + /** + * Constructs a new Empty. + * @memberof google.protobuf + * @classdesc Represents an Empty. + * @implements IEmpty + * @constructor + * @param {google.protobuf.IEmpty=} [properties] Properties to set + */ + function Empty(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + return Empty; + })(); + + protobuf.FieldMask = (function() { + + /** + * Properties of a FieldMask. + * @memberof google.protobuf + * @interface IFieldMask + * @property {Array.|null} [paths] FieldMask paths + */ + + /** + * Constructs a new FieldMask. + * @memberof google.protobuf + * @classdesc Represents a FieldMask. + * @implements IFieldMask + * @constructor + * @param {google.protobuf.IFieldMask=} [properties] Properties to set + */ + function FieldMask(properties) { + this.paths = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldMask paths. + * @member {Array.} paths + * @memberof google.protobuf.FieldMask + * @instance + */ + FieldMask.prototype.paths = $util.emptyArray; + + return FieldMask; + })(); + + protobuf.Timestamp = (function() { + + /** + * Properties of a Timestamp. + * @memberof google.protobuf + * @interface ITimestamp + * @property {number|null} [seconds] Timestamp seconds + * @property {number|null} [nanos] Timestamp nanos + */ + + /** + * Constructs a new Timestamp. + * @memberof google.protobuf + * @classdesc Represents a Timestamp. + * @implements ITimestamp + * @constructor + * @param {google.protobuf.ITimestamp=} [properties] Properties to set + */ + function Timestamp(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Timestamp seconds. + * @member {number} seconds + * @memberof google.protobuf.Timestamp + * @instance + */ + Timestamp.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Timestamp nanos. + * @member {number} nanos + * @memberof google.protobuf.Timestamp + * @instance + */ + Timestamp.prototype.nanos = 0; + + return Timestamp; + })(); + + protobuf.Any = (function() { + + /** + * Properties of an Any. + * @memberof google.protobuf + * @interface IAny + * @property {string|null} [type_url] Any type_url + * @property {Uint8Array|null} [value] Any value + */ + + /** + * Constructs a new Any. + * @memberof google.protobuf + * @classdesc Represents an Any. + * @implements IAny + * @constructor + * @param {google.protobuf.IAny=} [properties] Properties to set + */ + function Any(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Any type_url. + * @member {string} type_url + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.type_url = ""; + + /** + * Any value. + * @member {Uint8Array} value + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.value = $util.newBuffer([]); + + return Any; + })(); + + protobuf.Struct = (function() { + + /** + * Properties of a Struct. + * @memberof google.protobuf + * @interface IStruct + * @property {Object.|null} [fields] Struct fields + */ + + /** + * Constructs a new Struct. + * @memberof google.protobuf + * @classdesc Represents a Struct. + * @implements IStruct + * @constructor + * @param {google.protobuf.IStruct=} [properties] Properties to set + */ + function Struct(properties) { + this.fields = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Struct fields. + * @member {Object.} fields + * @memberof google.protobuf.Struct + * @instance + */ + Struct.prototype.fields = $util.emptyObject; + + return Struct; + })(); + + protobuf.Value = (function() { + + /** + * Properties of a Value. + * @memberof google.protobuf + * @interface IValue + * @property {google.protobuf.NullValue|null} [nullValue] Value nullValue + * @property {number|null} [numberValue] Value numberValue + * @property {string|null} [stringValue] Value stringValue + * @property {boolean|null} [boolValue] Value boolValue + * @property {google.protobuf.IStruct|null} [structValue] Value structValue + * @property {google.protobuf.IListValue|null} [listValue] Value listValue + */ + + /** + * Constructs a new Value. + * @memberof google.protobuf + * @classdesc Represents a Value. + * @implements IValue + * @constructor + * @param {google.protobuf.IValue=} [properties] Properties to set + */ + function Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Value nullValue. + * @member {google.protobuf.NullValue} nullValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.nullValue = 0; + + /** + * Value numberValue. + * @member {number} numberValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.numberValue = 0; + + /** + * Value stringValue. + * @member {string} stringValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.stringValue = ""; + + /** + * Value boolValue. + * @member {boolean} boolValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.boolValue = false; + + /** + * Value structValue. + * @member {google.protobuf.IStruct|null|undefined} structValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.structValue = null; + + /** + * Value listValue. + * @member {google.protobuf.IListValue|null|undefined} listValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.listValue = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Value kind. + * @member {"nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"|undefined} kind + * @memberof google.protobuf.Value + * @instance + */ + Object.defineProperty(Value.prototype, "kind", { + get: $util.oneOfGetter($oneOfFields = ["nullValue", "numberValue", "stringValue", "boolValue", "structValue", "listValue"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return Value; + })(); + + /** + * NullValue enum. + * @name google.protobuf.NullValue + * @enum {number} + * @property {string} NULL_VALUE=NULL_VALUE NULL_VALUE value + */ + protobuf.NullValue = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "NULL_VALUE"] = "NULL_VALUE"; + return values; + })(); + + protobuf.ListValue = (function() { + + /** + * Properties of a ListValue. + * @memberof google.protobuf + * @interface IListValue + * @property {Array.|null} [values] ListValue values + */ + + /** + * Constructs a new ListValue. + * @memberof google.protobuf + * @classdesc Represents a ListValue. + * @implements IListValue + * @constructor + * @param {google.protobuf.IListValue=} [properties] Properties to set + */ + function ListValue(properties) { + this.values = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListValue values. + * @member {Array.} values + * @memberof google.protobuf.ListValue + * @instance + */ + ListValue.prototype.values = $util.emptyArray; + + return ListValue; + })(); + + protobuf.DoubleValue = (function() { + + /** + * Properties of a DoubleValue. + * @memberof google.protobuf + * @interface IDoubleValue + * @property {number|null} [value] DoubleValue value + */ + + /** + * Constructs a new DoubleValue. + * @memberof google.protobuf + * @classdesc Represents a DoubleValue. + * @implements IDoubleValue + * @constructor + * @param {google.protobuf.IDoubleValue=} [properties] Properties to set + */ + function DoubleValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DoubleValue value. + * @member {number} value + * @memberof google.protobuf.DoubleValue + * @instance + */ + DoubleValue.prototype.value = 0; + + return DoubleValue; + })(); + + protobuf.FloatValue = (function() { + + /** + * Properties of a FloatValue. + * @memberof google.protobuf + * @interface IFloatValue + * @property {number|null} [value] FloatValue value + */ + + /** + * Constructs a new FloatValue. + * @memberof google.protobuf + * @classdesc Represents a FloatValue. + * @implements IFloatValue + * @constructor + * @param {google.protobuf.IFloatValue=} [properties] Properties to set + */ + function FloatValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FloatValue value. + * @member {number} value + * @memberof google.protobuf.FloatValue + * @instance + */ + FloatValue.prototype.value = 0; + + return FloatValue; + })(); + + protobuf.Int64Value = (function() { + + /** + * Properties of an Int64Value. + * @memberof google.protobuf + * @interface IInt64Value + * @property {number|null} [value] Int64Value value + */ + + /** + * Constructs a new Int64Value. + * @memberof google.protobuf + * @classdesc Represents an Int64Value. + * @implements IInt64Value + * @constructor + * @param {google.protobuf.IInt64Value=} [properties] Properties to set + */ + function Int64Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Int64Value value. + * @member {number} value + * @memberof google.protobuf.Int64Value + * @instance + */ + Int64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + return Int64Value; + })(); + + protobuf.UInt64Value = (function() { + + /** + * Properties of a UInt64Value. + * @memberof google.protobuf + * @interface IUInt64Value + * @property {number|null} [value] UInt64Value value + */ + + /** + * Constructs a new UInt64Value. + * @memberof google.protobuf + * @classdesc Represents a UInt64Value. + * @implements IUInt64Value + * @constructor + * @param {google.protobuf.IUInt64Value=} [properties] Properties to set + */ + function UInt64Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UInt64Value value. + * @member {number} value + * @memberof google.protobuf.UInt64Value + * @instance + */ + UInt64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + return UInt64Value; + })(); + + protobuf.Int32Value = (function() { + + /** + * Properties of an Int32Value. + * @memberof google.protobuf + * @interface IInt32Value + * @property {number|null} [value] Int32Value value + */ + + /** + * Constructs a new Int32Value. + * @memberof google.protobuf + * @classdesc Represents an Int32Value. + * @implements IInt32Value + * @constructor + * @param {google.protobuf.IInt32Value=} [properties] Properties to set + */ + function Int32Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Int32Value value. + * @member {number} value + * @memberof google.protobuf.Int32Value + * @instance + */ + Int32Value.prototype.value = 0; + + return Int32Value; + })(); + + protobuf.UInt32Value = (function() { + + /** + * Properties of a UInt32Value. + * @memberof google.protobuf + * @interface IUInt32Value + * @property {number|null} [value] UInt32Value value + */ + + /** + * Constructs a new UInt32Value. + * @memberof google.protobuf + * @classdesc Represents a UInt32Value. + * @implements IUInt32Value + * @constructor + * @param {google.protobuf.IUInt32Value=} [properties] Properties to set + */ + function UInt32Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UInt32Value value. + * @member {number} value + * @memberof google.protobuf.UInt32Value + * @instance + */ + UInt32Value.prototype.value = 0; + + return UInt32Value; + })(); + + protobuf.BoolValue = (function() { + + /** + * Properties of a BoolValue. + * @memberof google.protobuf + * @interface IBoolValue + * @property {boolean|null} [value] BoolValue value + */ + + /** + * Constructs a new BoolValue. + * @memberof google.protobuf + * @classdesc Represents a BoolValue. + * @implements IBoolValue + * @constructor + * @param {google.protobuf.IBoolValue=} [properties] Properties to set + */ + function BoolValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BoolValue value. + * @member {boolean} value + * @memberof google.protobuf.BoolValue + * @instance + */ + BoolValue.prototype.value = false; + + return BoolValue; + })(); + + protobuf.StringValue = (function() { + + /** + * Properties of a StringValue. + * @memberof google.protobuf + * @interface IStringValue + * @property {string|null} [value] StringValue value + */ + + /** + * Constructs a new StringValue. + * @memberof google.protobuf + * @classdesc Represents a StringValue. + * @implements IStringValue + * @constructor + * @param {google.protobuf.IStringValue=} [properties] Properties to set + */ + function StringValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StringValue value. + * @member {string} value + * @memberof google.protobuf.StringValue + * @instance + */ + StringValue.prototype.value = ""; + + return StringValue; + })(); + + protobuf.BytesValue = (function() { + + /** + * Properties of a BytesValue. + * @memberof google.protobuf + * @interface IBytesValue + * @property {Uint8Array|null} [value] BytesValue value + */ + + /** + * Constructs a new BytesValue. + * @memberof google.protobuf + * @classdesc Represents a BytesValue. + * @implements IBytesValue + * @constructor + * @param {google.protobuf.IBytesValue=} [properties] Properties to set + */ + function BytesValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BytesValue value. + * @member {Uint8Array} value + * @memberof google.protobuf.BytesValue + * @instance + */ + BytesValue.prototype.value = $util.newBuffer([]); + + return BytesValue; + })(); + + protobuf.Duration = (function() { + + /** + * Properties of a Duration. + * @memberof google.protobuf + * @interface IDuration + * @property {number|null} [seconds] Duration seconds + * @property {number|null} [nanos] Duration nanos + */ + + /** + * Constructs a new Duration. + * @memberof google.protobuf + * @classdesc Represents a Duration. + * @implements IDuration + * @constructor + * @param {google.protobuf.IDuration=} [properties] Properties to set + */ + function Duration(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Duration seconds. + * @member {number} seconds + * @memberof google.protobuf.Duration + * @instance + */ + Duration.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Duration nanos. + * @member {number} nanos + * @memberof google.protobuf.Duration + * @instance + */ + Duration.prototype.nanos = 0; + + return Duration; + })(); + + return protobuf; + })(); + + google.type = (function() { + + /** + * Namespace type. + * @memberof google + * @namespace + */ + var type = {}; + + type.LatLng = (function() { + + /** + * Properties of a LatLng. + * @memberof google.type + * @interface ILatLng + * @property {number|null} [latitude] LatLng latitude + * @property {number|null} [longitude] LatLng longitude + */ + + /** + * Constructs a new LatLng. + * @memberof google.type + * @classdesc Represents a LatLng. + * @implements ILatLng + * @constructor + * @param {google.type.ILatLng=} [properties] Properties to set + */ + function LatLng(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LatLng latitude. + * @member {number} latitude + * @memberof google.type.LatLng + * @instance + */ + LatLng.prototype.latitude = 0; + + /** + * LatLng longitude. + * @member {number} longitude + * @memberof google.type.LatLng + * @instance + */ + LatLng.prototype.longitude = 0; + + return LatLng; + })(); + + return type; + })(); + + google.rpc = (function() { + + /** + * Namespace rpc. + * @memberof google + * @namespace + */ + var rpc = {}; + + rpc.Status = (function() { + + /** + * Properties of a Status. + * @memberof google.rpc + * @interface IStatus + * @property {number|null} [code] Status code + * @property {string|null} [message] Status message + * @property {Array.|null} [details] Status details + */ + + /** + * Constructs a new Status. + * @memberof google.rpc + * @classdesc Represents a Status. + * @implements IStatus + * @constructor + * @param {google.rpc.IStatus=} [properties] Properties to set + */ + function Status(properties) { + this.details = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Status code. + * @member {number} code + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.code = 0; + + /** + * Status message. + * @member {string} message + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.message = ""; + + /** + * Status details. + * @member {Array.} details + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.details = $util.emptyArray; + + return Status; + })(); + + return rpc; + })(); + + google.longrunning = (function() { + + /** + * Namespace longrunning. + * @memberof google + * @namespace + */ + var longrunning = {}; + + longrunning.Operations = (function() { + + /** + * Constructs a new Operations service. + * @memberof google.longrunning + * @classdesc Represents an Operations + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function Operations(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (Operations.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Operations; + + /** + * Callback as used by {@link google.longrunning.Operations#listOperations}. + * @memberof google.longrunning.Operations + * @typedef ListOperationsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.ListOperationsResponse} [response] ListOperationsResponse + */ + + /** + * Calls ListOperations. + * @function listOperations + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object + * @param {google.longrunning.Operations.ListOperationsCallback} callback Node-style callback called with the error, if any, and ListOperationsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.listOperations = function listOperations(request, callback) { + return this.rpcCall(listOperations, $root.google.longrunning.ListOperationsRequest, $root.google.longrunning.ListOperationsResponse, request, callback); + }, "name", { value: "ListOperations" }); + + /** + * Calls ListOperations. + * @function listOperations + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#getOperation}. + * @memberof google.longrunning.Operations + * @typedef GetOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls GetOperation. + * @function getOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object + * @param {google.longrunning.Operations.GetOperationCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.getOperation = function getOperation(request, callback) { + return this.rpcCall(getOperation, $root.google.longrunning.GetOperationRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "GetOperation" }); + + /** + * Calls GetOperation. + * @function getOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#deleteOperation}. + * @memberof google.longrunning.Operations + * @typedef DeleteOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteOperation. + * @function deleteOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object + * @param {google.longrunning.Operations.DeleteOperationCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.deleteOperation = function deleteOperation(request, callback) { + return this.rpcCall(deleteOperation, $root.google.longrunning.DeleteOperationRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteOperation" }); + + /** + * Calls DeleteOperation. + * @function deleteOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#cancelOperation}. + * @memberof google.longrunning.Operations + * @typedef CancelOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls CancelOperation. + * @function cancelOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object + * @param {google.longrunning.Operations.CancelOperationCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.cancelOperation = function cancelOperation(request, callback) { + return this.rpcCall(cancelOperation, $root.google.longrunning.CancelOperationRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "CancelOperation" }); + + /** + * Calls CancelOperation. + * @function cancelOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#waitOperation}. + * @memberof google.longrunning.Operations + * @typedef WaitOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls WaitOperation. + * @function waitOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object + * @param {google.longrunning.Operations.WaitOperationCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.waitOperation = function waitOperation(request, callback) { + return this.rpcCall(waitOperation, $root.google.longrunning.WaitOperationRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "WaitOperation" }); + + /** + * Calls WaitOperation. + * @function waitOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return Operations; + })(); + + longrunning.Operation = (function() { + + /** + * Properties of an Operation. + * @memberof google.longrunning + * @interface IOperation + * @property {string|null} [name] Operation name + * @property {google.protobuf.IAny|null} [metadata] Operation metadata + * @property {boolean|null} [done] Operation done + * @property {google.rpc.IStatus|null} [error] Operation error + * @property {google.protobuf.IAny|null} [response] Operation response + */ + + /** + * Constructs a new Operation. + * @memberof google.longrunning + * @classdesc Represents an Operation. + * @implements IOperation + * @constructor + * @param {google.longrunning.IOperation=} [properties] Properties to set + */ + function Operation(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Operation name. + * @member {string} name + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.name = ""; + + /** + * Operation metadata. + * @member {google.protobuf.IAny|null|undefined} metadata + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.metadata = null; + + /** + * Operation done. + * @member {boolean} done + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.done = false; + + /** + * Operation error. + * @member {google.rpc.IStatus|null|undefined} error + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.error = null; + + /** + * Operation response. + * @member {google.protobuf.IAny|null|undefined} response + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.response = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Operation result. + * @member {"error"|"response"|undefined} result + * @memberof google.longrunning.Operation + * @instance + */ + Object.defineProperty(Operation.prototype, "result", { + get: $util.oneOfGetter($oneOfFields = ["error", "response"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return Operation; + })(); + + longrunning.GetOperationRequest = (function() { + + /** + * Properties of a GetOperationRequest. + * @memberof google.longrunning + * @interface IGetOperationRequest + * @property {string|null} [name] GetOperationRequest name + */ + + /** + * Constructs a new GetOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a GetOperationRequest. + * @implements IGetOperationRequest + * @constructor + * @param {google.longrunning.IGetOperationRequest=} [properties] Properties to set + */ + function GetOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetOperationRequest name. + * @member {string} name + * @memberof google.longrunning.GetOperationRequest + * @instance + */ + GetOperationRequest.prototype.name = ""; + + return GetOperationRequest; + })(); + + longrunning.ListOperationsRequest = (function() { + + /** + * Properties of a ListOperationsRequest. + * @memberof google.longrunning + * @interface IListOperationsRequest + * @property {string|null} [name] ListOperationsRequest name + * @property {string|null} [filter] ListOperationsRequest filter + * @property {number|null} [pageSize] ListOperationsRequest pageSize + * @property {string|null} [pageToken] ListOperationsRequest pageToken + */ + + /** + * Constructs a new ListOperationsRequest. + * @memberof google.longrunning + * @classdesc Represents a ListOperationsRequest. + * @implements IListOperationsRequest + * @constructor + * @param {google.longrunning.IListOperationsRequest=} [properties] Properties to set + */ + function ListOperationsRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListOperationsRequest name. + * @member {string} name + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.name = ""; + + /** + * ListOperationsRequest filter. + * @member {string} filter + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.filter = ""; + + /** + * ListOperationsRequest pageSize. + * @member {number} pageSize + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.pageSize = 0; + + /** + * ListOperationsRequest pageToken. + * @member {string} pageToken + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.pageToken = ""; + + return ListOperationsRequest; + })(); + + longrunning.ListOperationsResponse = (function() { + + /** + * Properties of a ListOperationsResponse. + * @memberof google.longrunning + * @interface IListOperationsResponse + * @property {Array.|null} [operations] ListOperationsResponse operations + * @property {string|null} [nextPageToken] ListOperationsResponse nextPageToken + */ + + /** + * Constructs a new ListOperationsResponse. + * @memberof google.longrunning + * @classdesc Represents a ListOperationsResponse. + * @implements IListOperationsResponse + * @constructor + * @param {google.longrunning.IListOperationsResponse=} [properties] Properties to set + */ + function ListOperationsResponse(properties) { + this.operations = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListOperationsResponse operations. + * @member {Array.} operations + * @memberof google.longrunning.ListOperationsResponse + * @instance + */ + ListOperationsResponse.prototype.operations = $util.emptyArray; + + /** + * ListOperationsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.longrunning.ListOperationsResponse + * @instance + */ + ListOperationsResponse.prototype.nextPageToken = ""; + + return ListOperationsResponse; + })(); + + longrunning.CancelOperationRequest = (function() { + + /** + * Properties of a CancelOperationRequest. + * @memberof google.longrunning + * @interface ICancelOperationRequest + * @property {string|null} [name] CancelOperationRequest name + */ + + /** + * Constructs a new CancelOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a CancelOperationRequest. + * @implements ICancelOperationRequest + * @constructor + * @param {google.longrunning.ICancelOperationRequest=} [properties] Properties to set + */ + function CancelOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CancelOperationRequest name. + * @member {string} name + * @memberof google.longrunning.CancelOperationRequest + * @instance + */ + CancelOperationRequest.prototype.name = ""; + + return CancelOperationRequest; + })(); + + longrunning.DeleteOperationRequest = (function() { + + /** + * Properties of a DeleteOperationRequest. + * @memberof google.longrunning + * @interface IDeleteOperationRequest + * @property {string|null} [name] DeleteOperationRequest name + */ + + /** + * Constructs a new DeleteOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a DeleteOperationRequest. + * @implements IDeleteOperationRequest + * @constructor + * @param {google.longrunning.IDeleteOperationRequest=} [properties] Properties to set + */ + function DeleteOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteOperationRequest name. + * @member {string} name + * @memberof google.longrunning.DeleteOperationRequest + * @instance + */ + DeleteOperationRequest.prototype.name = ""; + + return DeleteOperationRequest; + })(); + + longrunning.WaitOperationRequest = (function() { + + /** + * Properties of a WaitOperationRequest. + * @memberof google.longrunning + * @interface IWaitOperationRequest + * @property {string|null} [name] WaitOperationRequest name + * @property {google.protobuf.IDuration|null} [timeout] WaitOperationRequest timeout + */ + + /** + * Constructs a new WaitOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a WaitOperationRequest. + * @implements IWaitOperationRequest + * @constructor + * @param {google.longrunning.IWaitOperationRequest=} [properties] Properties to set + */ + function WaitOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WaitOperationRequest name. + * @member {string} name + * @memberof google.longrunning.WaitOperationRequest + * @instance + */ + WaitOperationRequest.prototype.name = ""; + + /** + * WaitOperationRequest timeout. + * @member {google.protobuf.IDuration|null|undefined} timeout + * @memberof google.longrunning.WaitOperationRequest + * @instance + */ + WaitOperationRequest.prototype.timeout = null; + + return WaitOperationRequest; + })(); + + longrunning.OperationInfo = (function() { + + /** + * Properties of an OperationInfo. + * @memberof google.longrunning + * @interface IOperationInfo + * @property {string|null} [responseType] OperationInfo responseType + * @property {string|null} [metadataType] OperationInfo metadataType + */ + + /** + * Constructs a new OperationInfo. + * @memberof google.longrunning + * @classdesc Represents an OperationInfo. + * @implements IOperationInfo + * @constructor + * @param {google.longrunning.IOperationInfo=} [properties] Properties to set + */ + function OperationInfo(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OperationInfo responseType. + * @member {string} responseType + * @memberof google.longrunning.OperationInfo + * @instance + */ + OperationInfo.prototype.responseType = ""; + + /** + * OperationInfo metadataType. + * @member {string} metadataType + * @memberof google.longrunning.OperationInfo + * @instance + */ + OperationInfo.prototype.metadataType = ""; + + return OperationInfo; + })(); + + return longrunning; + })(); + + return google; +})(); diff --git a/dev/protos/firestore_proto_api.d.ts b/dev/protos/firestore_v1_proto_api.d.ts similarity index 97% rename from dev/protos/firestore_proto_api.d.ts rename to dev/protos/firestore_v1_proto_api.d.ts index bb60077f3..9edef25cd 100644 --- a/dev/protos/firestore_proto_api.d.ts +++ b/dev/protos/firestore_v1_proto_api.d.ts @@ -1,16 +1,18 @@ -// Copyright 2019 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 -// -// https://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. +/*! + * Copyright 2019 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 $protobuf from "protobufjs"; /** Namespace google. */ @@ -584,6 +586,9 @@ export namespace google { /** FileOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** FileOptions .google.api.resourceDefinition */ + ".google.api.resourceDefinition"?: (google.api.IResourceDescriptor[]|null); } /** Represents a FileOptions. */ @@ -665,6 +670,9 @@ export namespace google { /** MessageOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** MessageOptions .google.api.resource */ + ".google.api.resource"?: (google.api.IResourceDescriptor|null); } /** Represents a MessageOptions. */ @@ -715,6 +723,12 @@ export namespace google { /** FieldOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** FieldOptions .google.api.fieldBehavior */ + ".google.api.fieldBehavior"?: (google.api.FieldBehavior[]|null); + + /** FieldOptions .google.api.resourceReference */ + ".google.api.resourceReference"?: (google.api.IResourceReference|null); } /** Represents a FieldOptions. */ @@ -845,6 +859,12 @@ export namespace google { /** ServiceOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** ServiceOptions .google.api.defaultHost */ + ".google.api.defaultHost"?: (string|null); + + /** ServiceOptions .google.api.oauthScopes */ + ".google.api.oauthScopes"?: (string|null); } /** Represents a ServiceOptions. */ @@ -875,6 +895,9 @@ export namespace google { /** MethodOptions .google.api.http */ ".google.api.http"?: (google.api.IHttpRule|null); + /** MethodOptions .google.api.methodSignature */ + ".google.api.methodSignature"?: (string[]|null); + /** MethodOptions .google.longrunning.operationInfo */ ".google.longrunning.operationInfo"?: (google.longrunning.IOperationInfo|null); } @@ -3229,26 +3252,6 @@ export namespace google { "OPERATOR_UNSPECIFIED"| "IS_NAN"| "IS_NULL"; } - /** Properties of a Projection. */ - interface IProjection { - - /** Projection fields */ - fields?: (google.firestore.v1.StructuredQuery.IFieldReference[]|null); - } - - /** Represents a Projection. */ - class Projection implements IProjection { - - /** - * Constructs a new Projection. - * @param [properties] Properties to set - */ - constructor(properties?: google.firestore.v1.StructuredQuery.IProjection); - - /** Projection fields. */ - public fields: google.firestore.v1.StructuredQuery.IFieldReference[]; - } - /** Properties of an Order. */ interface IOrder { @@ -3275,6 +3278,10 @@ export namespace google { public direction: google.firestore.v1.StructuredQuery.Direction; } + /** Direction enum. */ + type Direction = + "DIRECTION_UNSPECIFIED"| "ASCENDING"| "DESCENDING"; + /** Properties of a FieldReference. */ interface IFieldReference { @@ -3295,9 +3302,25 @@ export namespace google { public fieldPath: string; } - /** Direction enum. */ - type Direction = - "DIRECTION_UNSPECIFIED"| "ASCENDING"| "DESCENDING"; + /** Properties of a Projection. */ + interface IProjection { + + /** Projection fields */ + fields?: (google.firestore.v1.StructuredQuery.IFieldReference[]|null); + } + + /** Represents a Projection. */ + class Projection implements IProjection { + + /** + * Constructs a new Projection. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.StructuredQuery.IProjection); + + /** Projection fields. */ + public fields: google.firestore.v1.StructuredQuery.IFieldReference[]; + } } /** Properties of a Cursor. */ @@ -3737,6 +3760,93 @@ export namespace google { /** CustomHttpPattern path. */ public path: string; } + + /** FieldBehavior enum. */ + type FieldBehavior = + "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"; + + /** Properties of a ResourceDescriptor. */ + interface IResourceDescriptor { + + /** ResourceDescriptor type */ + type?: (string|null); + + /** ResourceDescriptor pattern */ + pattern?: (string[]|null); + + /** ResourceDescriptor nameField */ + nameField?: (string|null); + + /** ResourceDescriptor history */ + history?: (google.api.ResourceDescriptor.History|null); + + /** ResourceDescriptor plural */ + plural?: (string|null); + + /** ResourceDescriptor singular */ + singular?: (string|null); + } + + /** Represents a ResourceDescriptor. */ + class ResourceDescriptor implements IResourceDescriptor { + + /** + * Constructs a new ResourceDescriptor. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IResourceDescriptor); + + /** ResourceDescriptor type. */ + public type: string; + + /** ResourceDescriptor pattern. */ + public pattern: string[]; + + /** ResourceDescriptor nameField. */ + public nameField: string; + + /** ResourceDescriptor history. */ + public history: google.api.ResourceDescriptor.History; + + /** ResourceDescriptor plural. */ + public plural: string; + + /** ResourceDescriptor singular. */ + public singular: string; + } + + namespace ResourceDescriptor { + + /** History enum. */ + type History = + "HISTORY_UNSPECIFIED"| "ORIGINALLY_SINGLE_PATTERN"| "FUTURE_MULTI_PATTERN"; + } + + /** Properties of a ResourceReference. */ + interface IResourceReference { + + /** ResourceReference type */ + type?: (string|null); + + /** ResourceReference childType */ + childType?: (string|null); + } + + /** Represents a ResourceReference. */ + class ResourceReference implements IResourceReference { + + /** + * Constructs a new ResourceReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IResourceReference); + + /** ResourceReference type. */ + public type: string; + + /** ResourceReference childType. */ + public childType: string; + } } /** Namespace type. */ diff --git a/dev/protos/firestore_proto_api.js b/dev/protos/firestore_v1_proto_api.js similarity index 96% rename from dev/protos/firestore_proto_api.js rename to dev/protos/firestore_v1_proto_api.js index d929bfcb1..2bc89ea07 100644 --- a/dev/protos/firestore_proto_api.js +++ b/dev/protos/firestore_v1_proto_api.js @@ -1,16 +1,18 @@ -// Copyright 2019 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 -// -// https://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. +/*! + * Copyright 2019 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. + */ // Common aliases var $util = $protobuf.util; @@ -953,6 +955,7 @@ $root.google = (function() { * @property {string|null} [objcClassPrefix] FileOptions objcClassPrefix * @property {string|null} [csharpNamespace] FileOptions csharpNamespace * @property {Array.|null} [uninterpretedOption] FileOptions uninterpretedOption + * @property {Array.|null} [".google.api.resourceDefinition"] FileOptions .google.api.resourceDefinition */ /** @@ -965,6 +968,7 @@ $root.google = (function() { */ function FileOptions(properties) { this.uninterpretedOption = []; + this[".google.api.resourceDefinition"] = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -1091,6 +1095,14 @@ $root.google = (function() { */ FileOptions.prototype.uninterpretedOption = $util.emptyArray; + /** + * FileOptions .google.api.resourceDefinition. + * @member {Array.} .google.api.resourceDefinition + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype[".google.api.resourceDefinition"] = $util.emptyArray; + /** * OptimizeMode enum. * @name google.protobuf.FileOptions.OptimizeMode @@ -1121,6 +1133,7 @@ $root.google = (function() { * @property {boolean|null} [deprecated] MessageOptions deprecated * @property {boolean|null} [mapEntry] MessageOptions mapEntry * @property {Array.|null} [uninterpretedOption] MessageOptions uninterpretedOption + * @property {google.api.IResourceDescriptor|null} [".google.api.resource"] MessageOptions .google.api.resource */ /** @@ -1179,6 +1192,14 @@ $root.google = (function() { */ MessageOptions.prototype.uninterpretedOption = $util.emptyArray; + /** + * MessageOptions .google.api.resource. + * @member {google.api.IResourceDescriptor|null|undefined} .google.api.resource + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype[".google.api.resource"] = null; + return MessageOptions; })(); @@ -1195,6 +1216,8 @@ $root.google = (function() { * @property {boolean|null} [deprecated] FieldOptions deprecated * @property {boolean|null} [weak] FieldOptions weak * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption + * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior + * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference */ /** @@ -1207,6 +1230,7 @@ $root.google = (function() { */ function FieldOptions(properties) { this.uninterpretedOption = []; + this[".google.api.fieldBehavior"] = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -1269,6 +1293,22 @@ $root.google = (function() { */ FieldOptions.prototype.uninterpretedOption = $util.emptyArray; + /** + * FieldOptions .google.api.fieldBehavior. + * @member {Array.} .google.api.fieldBehavior + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype[".google.api.fieldBehavior"] = $util.emptyArray; + + /** + * FieldOptions .google.api.resourceReference. + * @member {google.api.IResourceReference|null|undefined} .google.api.resourceReference + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype[".google.api.resourceReference"] = null; + /** * CType enum. * @name google.protobuf.FieldOptions.CType @@ -1447,6 +1487,8 @@ $root.google = (function() { * @interface IServiceOptions * @property {boolean|null} [deprecated] ServiceOptions deprecated * @property {Array.|null} [uninterpretedOption] ServiceOptions uninterpretedOption + * @property {string|null} [".google.api.defaultHost"] ServiceOptions .google.api.defaultHost + * @property {string|null} [".google.api.oauthScopes"] ServiceOptions .google.api.oauthScopes */ /** @@ -1481,6 +1523,22 @@ $root.google = (function() { */ ServiceOptions.prototype.uninterpretedOption = $util.emptyArray; + /** + * ServiceOptions .google.api.defaultHost. + * @member {string} .google.api.defaultHost + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype[".google.api.defaultHost"] = ""; + + /** + * ServiceOptions .google.api.oauthScopes. + * @member {string} .google.api.oauthScopes + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype[".google.api.oauthScopes"] = ""; + return ServiceOptions; })(); @@ -1493,6 +1551,7 @@ $root.google = (function() { * @property {boolean|null} [deprecated] MethodOptions deprecated * @property {Array.|null} [uninterpretedOption] MethodOptions uninterpretedOption * @property {google.api.IHttpRule|null} [".google.api.http"] MethodOptions .google.api.http + * @property {Array.|null} [".google.api.methodSignature"] MethodOptions .google.api.methodSignature * @property {google.longrunning.IOperationInfo|null} [".google.longrunning.operationInfo"] MethodOptions .google.longrunning.operationInfo */ @@ -1506,6 +1565,7 @@ $root.google = (function() { */ function MethodOptions(properties) { this.uninterpretedOption = []; + this[".google.api.methodSignature"] = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -1536,6 +1596,14 @@ $root.google = (function() { */ MethodOptions.prototype[".google.api.http"] = null; + /** + * MethodOptions .google.api.methodSignature. + * @member {Array.} .google.api.methodSignature + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.api.methodSignature"] = $util.emptyArray; + /** * MethodOptions .google.longrunning.operationInfo. * @member {google.longrunning.IOperationInfo|null|undefined} .google.longrunning.operationInfo @@ -5593,42 +5661,6 @@ $root.google = (function() { return UnaryFilter; })(); - StructuredQuery.Projection = (function() { - - /** - * Properties of a Projection. - * @memberof google.firestore.v1.StructuredQuery - * @interface IProjection - * @property {Array.|null} [fields] Projection fields - */ - - /** - * Constructs a new Projection. - * @memberof google.firestore.v1.StructuredQuery - * @classdesc Represents a Projection. - * @implements IProjection - * @constructor - * @param {google.firestore.v1.StructuredQuery.IProjection=} [properties] Properties to set - */ - function Projection(properties) { - this.fields = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Projection fields. - * @member {Array.} fields - * @memberof google.firestore.v1.StructuredQuery.Projection - * @instance - */ - Projection.prototype.fields = $util.emptyArray; - - return Projection; - })(); - StructuredQuery.Order = (function() { /** @@ -5673,6 +5705,22 @@ $root.google = (function() { return Order; })(); + /** + * Direction enum. + * @name google.firestore.v1.StructuredQuery.Direction + * @enum {number} + * @property {string} DIRECTION_UNSPECIFIED=DIRECTION_UNSPECIFIED DIRECTION_UNSPECIFIED value + * @property {string} ASCENDING=ASCENDING ASCENDING value + * @property {string} DESCENDING=DESCENDING DESCENDING value + */ + StructuredQuery.Direction = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DIRECTION_UNSPECIFIED"] = "DIRECTION_UNSPECIFIED"; + values[valuesById[1] = "ASCENDING"] = "ASCENDING"; + values[valuesById[2] = "DESCENDING"] = "DESCENDING"; + return values; + })(); + StructuredQuery.FieldReference = (function() { /** @@ -5708,20 +5756,40 @@ $root.google = (function() { return FieldReference; })(); - /** - * Direction enum. - * @name google.firestore.v1.StructuredQuery.Direction - * @enum {number} - * @property {string} DIRECTION_UNSPECIFIED=DIRECTION_UNSPECIFIED DIRECTION_UNSPECIFIED value - * @property {string} ASCENDING=ASCENDING ASCENDING value - * @property {string} DESCENDING=DESCENDING DESCENDING value - */ - StructuredQuery.Direction = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "DIRECTION_UNSPECIFIED"] = "DIRECTION_UNSPECIFIED"; - values[valuesById[1] = "ASCENDING"] = "ASCENDING"; - values[valuesById[2] = "DESCENDING"] = "DESCENDING"; - return values; + StructuredQuery.Projection = (function() { + + /** + * Properties of a Projection. + * @memberof google.firestore.v1.StructuredQuery + * @interface IProjection + * @property {Array.|null} [fields] Projection fields + */ + + /** + * Constructs a new Projection. + * @memberof google.firestore.v1.StructuredQuery + * @classdesc Represents a Projection. + * @implements IProjection + * @constructor + * @param {google.firestore.v1.StructuredQuery.IProjection=} [properties] Properties to set + */ + function Projection(properties) { + this.fields = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Projection fields. + * @member {Array.} fields + * @memberof google.firestore.v1.StructuredQuery.Projection + * @instance + */ + Projection.prototype.fields = $util.emptyArray; + + return Projection; })(); return StructuredQuery; @@ -6488,6 +6556,169 @@ $root.google = (function() { return CustomHttpPattern; })(); + /** + * FieldBehavior enum. + * @name google.api.FieldBehavior + * @enum {number} + * @property {string} FIELD_BEHAVIOR_UNSPECIFIED=FIELD_BEHAVIOR_UNSPECIFIED FIELD_BEHAVIOR_UNSPECIFIED value + * @property {string} OPTIONAL=OPTIONAL OPTIONAL value + * @property {string} REQUIRED=REQUIRED REQUIRED value + * @property {string} OUTPUT_ONLY=OUTPUT_ONLY OUTPUT_ONLY value + * @property {string} INPUT_ONLY=INPUT_ONLY INPUT_ONLY value + * @property {string} IMMUTABLE=IMMUTABLE IMMUTABLE value + */ + api.FieldBehavior = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "FIELD_BEHAVIOR_UNSPECIFIED"] = "FIELD_BEHAVIOR_UNSPECIFIED"; + values[valuesById[1] = "OPTIONAL"] = "OPTIONAL"; + values[valuesById[2] = "REQUIRED"] = "REQUIRED"; + values[valuesById[3] = "OUTPUT_ONLY"] = "OUTPUT_ONLY"; + values[valuesById[4] = "INPUT_ONLY"] = "INPUT_ONLY"; + values[valuesById[5] = "IMMUTABLE"] = "IMMUTABLE"; + return values; + })(); + + api.ResourceDescriptor = (function() { + + /** + * Properties of a ResourceDescriptor. + * @memberof google.api + * @interface IResourceDescriptor + * @property {string|null} [type] ResourceDescriptor type + * @property {Array.|null} [pattern] ResourceDescriptor pattern + * @property {string|null} [nameField] ResourceDescriptor nameField + * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history + * @property {string|null} [plural] ResourceDescriptor plural + * @property {string|null} [singular] ResourceDescriptor singular + */ + + /** + * Constructs a new ResourceDescriptor. + * @memberof google.api + * @classdesc Represents a ResourceDescriptor. + * @implements IResourceDescriptor + * @constructor + * @param {google.api.IResourceDescriptor=} [properties] Properties to set + */ + function ResourceDescriptor(properties) { + this.pattern = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResourceDescriptor type. + * @member {string} type + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.type = ""; + + /** + * ResourceDescriptor pattern. + * @member {Array.} pattern + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.pattern = $util.emptyArray; + + /** + * ResourceDescriptor nameField. + * @member {string} nameField + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.nameField = ""; + + /** + * ResourceDescriptor history. + * @member {google.api.ResourceDescriptor.History} history + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.history = 0; + + /** + * ResourceDescriptor plural. + * @member {string} plural + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.plural = ""; + + /** + * ResourceDescriptor singular. + * @member {string} singular + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.singular = ""; + + /** + * History enum. + * @name google.api.ResourceDescriptor.History + * @enum {number} + * @property {string} HISTORY_UNSPECIFIED=HISTORY_UNSPECIFIED HISTORY_UNSPECIFIED value + * @property {string} ORIGINALLY_SINGLE_PATTERN=ORIGINALLY_SINGLE_PATTERN ORIGINALLY_SINGLE_PATTERN value + * @property {string} FUTURE_MULTI_PATTERN=FUTURE_MULTI_PATTERN FUTURE_MULTI_PATTERN value + */ + ResourceDescriptor.History = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "HISTORY_UNSPECIFIED"] = "HISTORY_UNSPECIFIED"; + values[valuesById[1] = "ORIGINALLY_SINGLE_PATTERN"] = "ORIGINALLY_SINGLE_PATTERN"; + values[valuesById[2] = "FUTURE_MULTI_PATTERN"] = "FUTURE_MULTI_PATTERN"; + return values; + })(); + + return ResourceDescriptor; + })(); + + api.ResourceReference = (function() { + + /** + * Properties of a ResourceReference. + * @memberof google.api + * @interface IResourceReference + * @property {string|null} [type] ResourceReference type + * @property {string|null} [childType] ResourceReference childType + */ + + /** + * Constructs a new ResourceReference. + * @memberof google.api + * @classdesc Represents a ResourceReference. + * @implements IResourceReference + * @constructor + * @param {google.api.IResourceReference=} [properties] Properties to set + */ + function ResourceReference(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResourceReference type. + * @member {string} type + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.type = ""; + + /** + * ResourceReference childType. + * @member {string} childType + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.childType = ""; + + return ResourceReference; + })(); + return api; })(); @@ -7197,4 +7428,4 @@ $root.google = (function() { })(); return google; -})(); \ No newline at end of file +})(); diff --git a/dev/protos/firestore_v1beta1_proto_api.d.ts b/dev/protos/firestore_v1beta1_proto_api.d.ts new file mode 100644 index 000000000..68e3882f7 --- /dev/null +++ b/dev/protos/firestore_v1beta1_proto_api.d.ts @@ -0,0 +1,4264 @@ +/*! + * Copyright 2019 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 $protobuf from "protobufjs"; +/** Namespace google. */ +export namespace google { + + /** Namespace protobuf. */ + namespace protobuf { + + /** Properties of a Timestamp. */ + interface ITimestamp { + + /** Timestamp seconds */ + seconds?: (number|null); + + /** Timestamp nanos */ + nanos?: (number|null); + } + + /** Represents a Timestamp. */ + class Timestamp implements ITimestamp { + + /** + * Constructs a new Timestamp. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.ITimestamp); + + /** Timestamp seconds. */ + public seconds: number; + + /** Timestamp nanos. */ + public nanos: number; + } + + /** Properties of a FileDescriptorSet. */ + interface IFileDescriptorSet { + + /** FileDescriptorSet file */ + file?: (google.protobuf.IFileDescriptorProto[]|null); + } + + /** Represents a FileDescriptorSet. */ + class FileDescriptorSet implements IFileDescriptorSet { + + /** + * Constructs a new FileDescriptorSet. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileDescriptorSet); + + /** FileDescriptorSet file. */ + public file: google.protobuf.IFileDescriptorProto[]; + } + + /** Properties of a FileDescriptorProto. */ + interface IFileDescriptorProto { + + /** FileDescriptorProto name */ + name?: (string|null); + + /** FileDescriptorProto package */ + "package"?: (string|null); + + /** FileDescriptorProto dependency */ + dependency?: (string[]|null); + + /** FileDescriptorProto publicDependency */ + publicDependency?: (number[]|null); + + /** FileDescriptorProto weakDependency */ + weakDependency?: (number[]|null); + + /** FileDescriptorProto messageType */ + messageType?: (google.protobuf.IDescriptorProto[]|null); + + /** FileDescriptorProto enumType */ + enumType?: (google.protobuf.IEnumDescriptorProto[]|null); + + /** FileDescriptorProto service */ + service?: (google.protobuf.IServiceDescriptorProto[]|null); + + /** FileDescriptorProto extension */ + extension?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** FileDescriptorProto options */ + options?: (google.protobuf.IFileOptions|null); + + /** FileDescriptorProto sourceCodeInfo */ + sourceCodeInfo?: (google.protobuf.ISourceCodeInfo|null); + + /** FileDescriptorProto syntax */ + syntax?: (string|null); + } + + /** Represents a FileDescriptorProto. */ + class FileDescriptorProto implements IFileDescriptorProto { + + /** + * Constructs a new FileDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileDescriptorProto); + + /** FileDescriptorProto name. */ + public name: string; + + /** FileDescriptorProto package. */ + public package: string; + + /** FileDescriptorProto dependency. */ + public dependency: string[]; + + /** FileDescriptorProto publicDependency. */ + public publicDependency: number[]; + + /** FileDescriptorProto weakDependency. */ + public weakDependency: number[]; + + /** FileDescriptorProto messageType. */ + public messageType: google.protobuf.IDescriptorProto[]; + + /** FileDescriptorProto enumType. */ + public enumType: google.protobuf.IEnumDescriptorProto[]; + + /** FileDescriptorProto service. */ + public service: google.protobuf.IServiceDescriptorProto[]; + + /** FileDescriptorProto extension. */ + public extension: google.protobuf.IFieldDescriptorProto[]; + + /** FileDescriptorProto options. */ + public options?: (google.protobuf.IFileOptions|null); + + /** FileDescriptorProto sourceCodeInfo. */ + public sourceCodeInfo?: (google.protobuf.ISourceCodeInfo|null); + + /** FileDescriptorProto syntax. */ + public syntax: string; + } + + /** Properties of a DescriptorProto. */ + interface IDescriptorProto { + + /** DescriptorProto name */ + name?: (string|null); + + /** DescriptorProto field */ + field?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** DescriptorProto extension */ + extension?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** DescriptorProto nestedType */ + nestedType?: (google.protobuf.IDescriptorProto[]|null); + + /** DescriptorProto enumType */ + enumType?: (google.protobuf.IEnumDescriptorProto[]|null); + + /** DescriptorProto extensionRange */ + extensionRange?: (google.protobuf.DescriptorProto.IExtensionRange[]|null); + + /** DescriptorProto oneofDecl */ + oneofDecl?: (google.protobuf.IOneofDescriptorProto[]|null); + + /** DescriptorProto options */ + options?: (google.protobuf.IMessageOptions|null); + + /** DescriptorProto reservedRange */ + reservedRange?: (google.protobuf.DescriptorProto.IReservedRange[]|null); + + /** DescriptorProto reservedName */ + reservedName?: (string[]|null); + } + + /** Represents a DescriptorProto. */ + class DescriptorProto implements IDescriptorProto { + + /** + * Constructs a new DescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDescriptorProto); + + /** DescriptorProto name. */ + public name: string; + + /** DescriptorProto field. */ + public field: google.protobuf.IFieldDescriptorProto[]; + + /** DescriptorProto extension. */ + public extension: google.protobuf.IFieldDescriptorProto[]; + + /** DescriptorProto nestedType. */ + public nestedType: google.protobuf.IDescriptorProto[]; + + /** DescriptorProto enumType. */ + public enumType: google.protobuf.IEnumDescriptorProto[]; + + /** DescriptorProto extensionRange. */ + public extensionRange: google.protobuf.DescriptorProto.IExtensionRange[]; + + /** DescriptorProto oneofDecl. */ + public oneofDecl: google.protobuf.IOneofDescriptorProto[]; + + /** DescriptorProto options. */ + public options?: (google.protobuf.IMessageOptions|null); + + /** DescriptorProto reservedRange. */ + public reservedRange: google.protobuf.DescriptorProto.IReservedRange[]; + + /** DescriptorProto reservedName. */ + public reservedName: string[]; + } + + namespace DescriptorProto { + + /** Properties of an ExtensionRange. */ + interface IExtensionRange { + + /** ExtensionRange start */ + start?: (number|null); + + /** ExtensionRange end */ + end?: (number|null); + } + + /** Represents an ExtensionRange. */ + class ExtensionRange implements IExtensionRange { + + /** + * Constructs a new ExtensionRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.DescriptorProto.IExtensionRange); + + /** ExtensionRange start. */ + public start: number; + + /** ExtensionRange end. */ + public end: number; + } + + /** Properties of a ReservedRange. */ + interface IReservedRange { + + /** ReservedRange start */ + start?: (number|null); + + /** ReservedRange end */ + end?: (number|null); + } + + /** Represents a ReservedRange. */ + class ReservedRange implements IReservedRange { + + /** + * Constructs a new ReservedRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.DescriptorProto.IReservedRange); + + /** ReservedRange start. */ + public start: number; + + /** ReservedRange end. */ + public end: number; + } + } + + /** Properties of a FieldDescriptorProto. */ + interface IFieldDescriptorProto { + + /** FieldDescriptorProto name */ + name?: (string|null); + + /** FieldDescriptorProto number */ + number?: (number|null); + + /** FieldDescriptorProto label */ + label?: (google.protobuf.FieldDescriptorProto.Label|null); + + /** FieldDescriptorProto type */ + type?: (google.protobuf.FieldDescriptorProto.Type|null); + + /** FieldDescriptorProto typeName */ + typeName?: (string|null); + + /** FieldDescriptorProto extendee */ + extendee?: (string|null); + + /** FieldDescriptorProto defaultValue */ + defaultValue?: (string|null); + + /** FieldDescriptorProto oneofIndex */ + oneofIndex?: (number|null); + + /** FieldDescriptorProto jsonName */ + jsonName?: (string|null); + + /** FieldDescriptorProto options */ + options?: (google.protobuf.IFieldOptions|null); + } + + /** Represents a FieldDescriptorProto. */ + class FieldDescriptorProto implements IFieldDescriptorProto { + + /** + * Constructs a new FieldDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldDescriptorProto); + + /** FieldDescriptorProto name. */ + public name: string; + + /** FieldDescriptorProto number. */ + public number: number; + + /** FieldDescriptorProto label. */ + public label: google.protobuf.FieldDescriptorProto.Label; + + /** FieldDescriptorProto type. */ + public type: google.protobuf.FieldDescriptorProto.Type; + + /** FieldDescriptorProto typeName. */ + public typeName: string; + + /** FieldDescriptorProto extendee. */ + public extendee: string; + + /** FieldDescriptorProto defaultValue. */ + public defaultValue: string; + + /** FieldDescriptorProto oneofIndex. */ + public oneofIndex: number; + + /** FieldDescriptorProto jsonName. */ + public jsonName: string; + + /** FieldDescriptorProto options. */ + public options?: (google.protobuf.IFieldOptions|null); + } + + namespace FieldDescriptorProto { + + /** Type enum. */ + type Type = + "TYPE_DOUBLE"| "TYPE_FLOAT"| "TYPE_INT64"| "TYPE_UINT64"| "TYPE_INT32"| "TYPE_FIXED64"| "TYPE_FIXED32"| "TYPE_BOOL"| "TYPE_STRING"| "TYPE_GROUP"| "TYPE_MESSAGE"| "TYPE_BYTES"| "TYPE_UINT32"| "TYPE_ENUM"| "TYPE_SFIXED32"| "TYPE_SFIXED64"| "TYPE_SINT32"| "TYPE_SINT64"; + + /** Label enum. */ + type Label = + "LABEL_OPTIONAL"| "LABEL_REQUIRED"| "LABEL_REPEATED"; + } + + /** Properties of an OneofDescriptorProto. */ + interface IOneofDescriptorProto { + + /** OneofDescriptorProto name */ + name?: (string|null); + + /** OneofDescriptorProto options */ + options?: (google.protobuf.IOneofOptions|null); + } + + /** Represents an OneofDescriptorProto. */ + class OneofDescriptorProto implements IOneofDescriptorProto { + + /** + * Constructs a new OneofDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IOneofDescriptorProto); + + /** OneofDescriptorProto name. */ + public name: string; + + /** OneofDescriptorProto options. */ + public options?: (google.protobuf.IOneofOptions|null); + } + + /** Properties of an EnumDescriptorProto. */ + interface IEnumDescriptorProto { + + /** EnumDescriptorProto name */ + name?: (string|null); + + /** EnumDescriptorProto value */ + value?: (google.protobuf.IEnumValueDescriptorProto[]|null); + + /** EnumDescriptorProto options */ + options?: (google.protobuf.IEnumOptions|null); + } + + /** Represents an EnumDescriptorProto. */ + class EnumDescriptorProto implements IEnumDescriptorProto { + + /** + * Constructs a new EnumDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumDescriptorProto); + + /** EnumDescriptorProto name. */ + public name: string; + + /** EnumDescriptorProto value. */ + public value: google.protobuf.IEnumValueDescriptorProto[]; + + /** EnumDescriptorProto options. */ + public options?: (google.protobuf.IEnumOptions|null); + } + + /** Properties of an EnumValueDescriptorProto. */ + interface IEnumValueDescriptorProto { + + /** EnumValueDescriptorProto name */ + name?: (string|null); + + /** EnumValueDescriptorProto number */ + number?: (number|null); + + /** EnumValueDescriptorProto options */ + options?: (google.protobuf.IEnumValueOptions|null); + } + + /** Represents an EnumValueDescriptorProto. */ + class EnumValueDescriptorProto implements IEnumValueDescriptorProto { + + /** + * Constructs a new EnumValueDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumValueDescriptorProto); + + /** EnumValueDescriptorProto name. */ + public name: string; + + /** EnumValueDescriptorProto number. */ + public number: number; + + /** EnumValueDescriptorProto options. */ + public options?: (google.protobuf.IEnumValueOptions|null); + } + + /** Properties of a ServiceDescriptorProto. */ + interface IServiceDescriptorProto { + + /** ServiceDescriptorProto name */ + name?: (string|null); + + /** ServiceDescriptorProto method */ + method?: (google.protobuf.IMethodDescriptorProto[]|null); + + /** ServiceDescriptorProto options */ + options?: (google.protobuf.IServiceOptions|null); + } + + /** Represents a ServiceDescriptorProto. */ + class ServiceDescriptorProto implements IServiceDescriptorProto { + + /** + * Constructs a new ServiceDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IServiceDescriptorProto); + + /** ServiceDescriptorProto name. */ + public name: string; + + /** ServiceDescriptorProto method. */ + public method: google.protobuf.IMethodDescriptorProto[]; + + /** ServiceDescriptorProto options. */ + public options?: (google.protobuf.IServiceOptions|null); + } + + /** Properties of a MethodDescriptorProto. */ + interface IMethodDescriptorProto { + + /** MethodDescriptorProto name */ + name?: (string|null); + + /** MethodDescriptorProto inputType */ + inputType?: (string|null); + + /** MethodDescriptorProto outputType */ + outputType?: (string|null); + + /** MethodDescriptorProto options */ + options?: (google.protobuf.IMethodOptions|null); + + /** MethodDescriptorProto clientStreaming */ + clientStreaming?: (boolean|null); + + /** MethodDescriptorProto serverStreaming */ + serverStreaming?: (boolean|null); + } + + /** Represents a MethodDescriptorProto. */ + class MethodDescriptorProto implements IMethodDescriptorProto { + + /** + * Constructs a new MethodDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMethodDescriptorProto); + + /** MethodDescriptorProto name. */ + public name: string; + + /** MethodDescriptorProto inputType. */ + public inputType: string; + + /** MethodDescriptorProto outputType. */ + public outputType: string; + + /** MethodDescriptorProto options. */ + public options?: (google.protobuf.IMethodOptions|null); + + /** MethodDescriptorProto clientStreaming. */ + public clientStreaming: boolean; + + /** MethodDescriptorProto serverStreaming. */ + public serverStreaming: boolean; + } + + /** Properties of a FileOptions. */ + interface IFileOptions { + + /** FileOptions javaPackage */ + javaPackage?: (string|null); + + /** FileOptions javaOuterClassname */ + javaOuterClassname?: (string|null); + + /** FileOptions javaMultipleFiles */ + javaMultipleFiles?: (boolean|null); + + /** FileOptions javaGenerateEqualsAndHash */ + javaGenerateEqualsAndHash?: (boolean|null); + + /** FileOptions javaStringCheckUtf8 */ + javaStringCheckUtf8?: (boolean|null); + + /** FileOptions optimizeFor */ + optimizeFor?: (google.protobuf.FileOptions.OptimizeMode|null); + + /** FileOptions goPackage */ + goPackage?: (string|null); + + /** FileOptions ccGenericServices */ + ccGenericServices?: (boolean|null); + + /** FileOptions javaGenericServices */ + javaGenericServices?: (boolean|null); + + /** FileOptions pyGenericServices */ + pyGenericServices?: (boolean|null); + + /** FileOptions deprecated */ + deprecated?: (boolean|null); + + /** FileOptions ccEnableArenas */ + ccEnableArenas?: (boolean|null); + + /** FileOptions objcClassPrefix */ + objcClassPrefix?: (string|null); + + /** FileOptions csharpNamespace */ + csharpNamespace?: (string|null); + + /** FileOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** FileOptions .google.api.resourceDefinition */ + ".google.api.resourceDefinition"?: (google.api.IResourceDescriptor[]|null); + } + + /** Represents a FileOptions. */ + class FileOptions implements IFileOptions { + + /** + * Constructs a new FileOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileOptions); + + /** FileOptions javaPackage. */ + public javaPackage: string; + + /** FileOptions javaOuterClassname. */ + public javaOuterClassname: string; + + /** FileOptions javaMultipleFiles. */ + public javaMultipleFiles: boolean; + + /** FileOptions javaGenerateEqualsAndHash. */ + public javaGenerateEqualsAndHash: boolean; + + /** FileOptions javaStringCheckUtf8. */ + public javaStringCheckUtf8: boolean; + + /** FileOptions optimizeFor. */ + public optimizeFor: google.protobuf.FileOptions.OptimizeMode; + + /** FileOptions goPackage. */ + public goPackage: string; + + /** FileOptions ccGenericServices. */ + public ccGenericServices: boolean; + + /** FileOptions javaGenericServices. */ + public javaGenericServices: boolean; + + /** FileOptions pyGenericServices. */ + public pyGenericServices: boolean; + + /** FileOptions deprecated. */ + public deprecated: boolean; + + /** FileOptions ccEnableArenas. */ + public ccEnableArenas: boolean; + + /** FileOptions objcClassPrefix. */ + public objcClassPrefix: string; + + /** FileOptions csharpNamespace. */ + public csharpNamespace: string; + + /** FileOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + } + + namespace FileOptions { + + /** OptimizeMode enum. */ + type OptimizeMode = + "SPEED"| "CODE_SIZE"| "LITE_RUNTIME"; + } + + /** Properties of a MessageOptions. */ + interface IMessageOptions { + + /** MessageOptions messageSetWireFormat */ + messageSetWireFormat?: (boolean|null); + + /** MessageOptions noStandardDescriptorAccessor */ + noStandardDescriptorAccessor?: (boolean|null); + + /** MessageOptions deprecated */ + deprecated?: (boolean|null); + + /** MessageOptions mapEntry */ + mapEntry?: (boolean|null); + + /** MessageOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** MessageOptions .google.api.resource */ + ".google.api.resource"?: (google.api.IResourceDescriptor|null); + } + + /** Represents a MessageOptions. */ + class MessageOptions implements IMessageOptions { + + /** + * Constructs a new MessageOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMessageOptions); + + /** MessageOptions messageSetWireFormat. */ + public messageSetWireFormat: boolean; + + /** MessageOptions noStandardDescriptorAccessor. */ + public noStandardDescriptorAccessor: boolean; + + /** MessageOptions deprecated. */ + public deprecated: boolean; + + /** MessageOptions mapEntry. */ + public mapEntry: boolean; + + /** MessageOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + } + + /** Properties of a FieldOptions. */ + interface IFieldOptions { + + /** FieldOptions ctype */ + ctype?: (google.protobuf.FieldOptions.CType|null); + + /** FieldOptions packed */ + packed?: (boolean|null); + + /** FieldOptions jstype */ + jstype?: (google.protobuf.FieldOptions.JSType|null); + + /** FieldOptions lazy */ + lazy?: (boolean|null); + + /** FieldOptions deprecated */ + deprecated?: (boolean|null); + + /** FieldOptions weak */ + weak?: (boolean|null); + + /** FieldOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** FieldOptions .google.api.fieldBehavior */ + ".google.api.fieldBehavior"?: (google.api.FieldBehavior[]|null); + + /** FieldOptions .google.api.resourceReference */ + ".google.api.resourceReference"?: (google.api.IResourceReference|null); + } + + /** Represents a FieldOptions. */ + class FieldOptions implements IFieldOptions { + + /** + * Constructs a new FieldOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldOptions); + + /** FieldOptions ctype. */ + public ctype: google.protobuf.FieldOptions.CType; + + /** FieldOptions packed. */ + public packed: boolean; + + /** FieldOptions jstype. */ + public jstype: google.protobuf.FieldOptions.JSType; + + /** FieldOptions lazy. */ + public lazy: boolean; + + /** FieldOptions deprecated. */ + public deprecated: boolean; + + /** FieldOptions weak. */ + public weak: boolean; + + /** FieldOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + } + + namespace FieldOptions { + + /** CType enum. */ + type CType = + "STRING"| "CORD"| "STRING_PIECE"; + + /** JSType enum. */ + type JSType = + "JS_NORMAL"| "JS_STRING"| "JS_NUMBER"; + } + + /** Properties of an OneofOptions. */ + interface IOneofOptions { + + /** OneofOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an OneofOptions. */ + class OneofOptions implements IOneofOptions { + + /** + * Constructs a new OneofOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IOneofOptions); + + /** OneofOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + } + + /** Properties of an EnumOptions. */ + interface IEnumOptions { + + /** EnumOptions allowAlias */ + allowAlias?: (boolean|null); + + /** EnumOptions deprecated */ + deprecated?: (boolean|null); + + /** EnumOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an EnumOptions. */ + class EnumOptions implements IEnumOptions { + + /** + * Constructs a new EnumOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumOptions); + + /** EnumOptions allowAlias. */ + public allowAlias: boolean; + + /** EnumOptions deprecated. */ + public deprecated: boolean; + + /** EnumOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + } + + /** Properties of an EnumValueOptions. */ + interface IEnumValueOptions { + + /** EnumValueOptions deprecated */ + deprecated?: (boolean|null); + + /** EnumValueOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an EnumValueOptions. */ + class EnumValueOptions implements IEnumValueOptions { + + /** + * Constructs a new EnumValueOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumValueOptions); + + /** EnumValueOptions deprecated. */ + public deprecated: boolean; + + /** EnumValueOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + } + + /** Properties of a ServiceOptions. */ + interface IServiceOptions { + + /** ServiceOptions deprecated */ + deprecated?: (boolean|null); + + /** ServiceOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** ServiceOptions .google.api.defaultHost */ + ".google.api.defaultHost"?: (string|null); + + /** ServiceOptions .google.api.oauthScopes */ + ".google.api.oauthScopes"?: (string|null); + } + + /** Represents a ServiceOptions. */ + class ServiceOptions implements IServiceOptions { + + /** + * Constructs a new ServiceOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IServiceOptions); + + /** ServiceOptions deprecated. */ + public deprecated: boolean; + + /** ServiceOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + } + + /** Properties of a MethodOptions. */ + interface IMethodOptions { + + /** MethodOptions deprecated */ + deprecated?: (boolean|null); + + /** MethodOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** MethodOptions .google.api.http */ + ".google.api.http"?: (google.api.IHttpRule|null); + + /** MethodOptions .google.api.methodSignature */ + ".google.api.methodSignature"?: (string[]|null); + + /** MethodOptions .google.longrunning.operationInfo */ + ".google.longrunning.operationInfo"?: (google.longrunning.IOperationInfo|null); + } + + /** Represents a MethodOptions. */ + class MethodOptions implements IMethodOptions { + + /** + * Constructs a new MethodOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMethodOptions); + + /** MethodOptions deprecated. */ + public deprecated: boolean; + + /** MethodOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + } + + /** Properties of an UninterpretedOption. */ + interface IUninterpretedOption { + + /** UninterpretedOption name */ + name?: (google.protobuf.UninterpretedOption.INamePart[]|null); + + /** UninterpretedOption identifierValue */ + identifierValue?: (string|null); + + /** UninterpretedOption positiveIntValue */ + positiveIntValue?: (number|null); + + /** UninterpretedOption negativeIntValue */ + negativeIntValue?: (number|null); + + /** UninterpretedOption doubleValue */ + doubleValue?: (number|null); + + /** UninterpretedOption stringValue */ + stringValue?: (Uint8Array|null); + + /** UninterpretedOption aggregateValue */ + aggregateValue?: (string|null); + } + + /** Represents an UninterpretedOption. */ + class UninterpretedOption implements IUninterpretedOption { + + /** + * Constructs a new UninterpretedOption. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUninterpretedOption); + + /** UninterpretedOption name. */ + public name: google.protobuf.UninterpretedOption.INamePart[]; + + /** UninterpretedOption identifierValue. */ + public identifierValue: string; + + /** UninterpretedOption positiveIntValue. */ + public positiveIntValue: number; + + /** UninterpretedOption negativeIntValue. */ + public negativeIntValue: number; + + /** UninterpretedOption doubleValue. */ + public doubleValue: number; + + /** UninterpretedOption stringValue. */ + public stringValue: Uint8Array; + + /** UninterpretedOption aggregateValue. */ + public aggregateValue: string; + } + + namespace UninterpretedOption { + + /** Properties of a NamePart. */ + interface INamePart { + + /** NamePart namePart */ + namePart: string; + + /** NamePart isExtension */ + isExtension: boolean; + } + + /** Represents a NamePart. */ + class NamePart implements INamePart { + + /** + * Constructs a new NamePart. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.UninterpretedOption.INamePart); + + /** NamePart namePart. */ + public namePart: string; + + /** NamePart isExtension. */ + public isExtension: boolean; + } + } + + /** Properties of a SourceCodeInfo. */ + interface ISourceCodeInfo { + + /** SourceCodeInfo location */ + location?: (google.protobuf.SourceCodeInfo.ILocation[]|null); + } + + /** Represents a SourceCodeInfo. */ + class SourceCodeInfo implements ISourceCodeInfo { + + /** + * Constructs a new SourceCodeInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.ISourceCodeInfo); + + /** SourceCodeInfo location. */ + public location: google.protobuf.SourceCodeInfo.ILocation[]; + } + + namespace SourceCodeInfo { + + /** Properties of a Location. */ + interface ILocation { + + /** Location path */ + path?: (number[]|null); + + /** Location span */ + span?: (number[]|null); + + /** Location leadingComments */ + leadingComments?: (string|null); + + /** Location trailingComments */ + trailingComments?: (string|null); + + /** Location leadingDetachedComments */ + leadingDetachedComments?: (string[]|null); + } + + /** Represents a Location. */ + class Location implements ILocation { + + /** + * Constructs a new Location. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.SourceCodeInfo.ILocation); + + /** Location path. */ + public path: number[]; + + /** Location span. */ + public span: number[]; + + /** Location leadingComments. */ + public leadingComments: string; + + /** Location trailingComments. */ + public trailingComments: string; + + /** Location leadingDetachedComments. */ + public leadingDetachedComments: string[]; + } + } + + /** Properties of a GeneratedCodeInfo. */ + interface IGeneratedCodeInfo { + + /** GeneratedCodeInfo annotation */ + annotation?: (google.protobuf.GeneratedCodeInfo.IAnnotation[]|null); + } + + /** Represents a GeneratedCodeInfo. */ + class GeneratedCodeInfo implements IGeneratedCodeInfo { + + /** + * Constructs a new GeneratedCodeInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IGeneratedCodeInfo); + + /** GeneratedCodeInfo annotation. */ + public annotation: google.protobuf.GeneratedCodeInfo.IAnnotation[]; + } + + namespace GeneratedCodeInfo { + + /** Properties of an Annotation. */ + interface IAnnotation { + + /** Annotation path */ + path?: (number[]|null); + + /** Annotation sourceFile */ + sourceFile?: (string|null); + + /** Annotation begin */ + begin?: (number|null); + + /** Annotation end */ + end?: (number|null); + } + + /** Represents an Annotation. */ + class Annotation implements IAnnotation { + + /** + * Constructs a new Annotation. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.GeneratedCodeInfo.IAnnotation); + + /** Annotation path. */ + public path: number[]; + + /** Annotation sourceFile. */ + public sourceFile: string; + + /** Annotation begin. */ + public begin: number; + + /** Annotation end. */ + public end: number; + } + } + + /** Properties of a Struct. */ + interface IStruct { + + /** Struct fields */ + fields?: ({ [k: string]: google.protobuf.IValue }|null); + } + + /** Represents a Struct. */ + class Struct implements IStruct { + + /** + * Constructs a new Struct. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IStruct); + + /** Struct fields. */ + public fields: { [k: string]: google.protobuf.IValue }; + } + + /** Properties of a Value. */ + interface IValue { + + /** Value nullValue */ + nullValue?: (google.protobuf.NullValue|null); + + /** Value numberValue */ + numberValue?: (number|null); + + /** Value stringValue */ + stringValue?: (string|null); + + /** Value boolValue */ + boolValue?: (boolean|null); + + /** Value structValue */ + structValue?: (google.protobuf.IStruct|null); + + /** Value listValue */ + listValue?: (google.protobuf.IListValue|null); + } + + /** Represents a Value. */ + class Value implements IValue { + + /** + * Constructs a new Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IValue); + + /** Value nullValue. */ + public nullValue: google.protobuf.NullValue; + + /** Value numberValue. */ + public numberValue: number; + + /** Value stringValue. */ + public stringValue: string; + + /** Value boolValue. */ + public boolValue: boolean; + + /** Value structValue. */ + public structValue?: (google.protobuf.IStruct|null); + + /** Value listValue. */ + public listValue?: (google.protobuf.IListValue|null); + + /** Value kind. */ + public kind?: ("nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"); + } + + /** NullValue enum. */ + type NullValue = + "NULL_VALUE"; + + /** Properties of a ListValue. */ + interface IListValue { + + /** ListValue values */ + values?: (google.protobuf.IValue[]|null); + } + + /** Represents a ListValue. */ + class ListValue implements IListValue { + + /** + * Constructs a new ListValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IListValue); + + /** ListValue values. */ + public values: google.protobuf.IValue[]; + } + + /** Properties of an Empty. */ + interface IEmpty { + } + + /** Represents an Empty. */ + class Empty implements IEmpty { + + /** + * Constructs a new Empty. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEmpty); + } + + /** Properties of a DoubleValue. */ + interface IDoubleValue { + + /** DoubleValue value */ + value?: (number|null); + } + + /** Represents a DoubleValue. */ + class DoubleValue implements IDoubleValue { + + /** + * Constructs a new DoubleValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDoubleValue); + + /** DoubleValue value. */ + public value: number; + } + + /** Properties of a FloatValue. */ + interface IFloatValue { + + /** FloatValue value */ + value?: (number|null); + } + + /** Represents a FloatValue. */ + class FloatValue implements IFloatValue { + + /** + * Constructs a new FloatValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFloatValue); + + /** FloatValue value. */ + public value: number; + } + + /** Properties of an Int64Value. */ + interface IInt64Value { + + /** Int64Value value */ + value?: (number|null); + } + + /** Represents an Int64Value. */ + class Int64Value implements IInt64Value { + + /** + * Constructs a new Int64Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IInt64Value); + + /** Int64Value value. */ + public value: number; + } + + /** Properties of a UInt64Value. */ + interface IUInt64Value { + + /** UInt64Value value */ + value?: (number|null); + } + + /** Represents a UInt64Value. */ + class UInt64Value implements IUInt64Value { + + /** + * Constructs a new UInt64Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUInt64Value); + + /** UInt64Value value. */ + public value: number; + } + + /** Properties of an Int32Value. */ + interface IInt32Value { + + /** Int32Value value */ + value?: (number|null); + } + + /** Represents an Int32Value. */ + class Int32Value implements IInt32Value { + + /** + * Constructs a new Int32Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IInt32Value); + + /** Int32Value value. */ + public value: number; + } + + /** Properties of a UInt32Value. */ + interface IUInt32Value { + + /** UInt32Value value */ + value?: (number|null); + } + + /** Represents a UInt32Value. */ + class UInt32Value implements IUInt32Value { + + /** + * Constructs a new UInt32Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUInt32Value); + + /** UInt32Value value. */ + public value: number; + } + + /** Properties of a BoolValue. */ + interface IBoolValue { + + /** BoolValue value */ + value?: (boolean|null); + } + + /** Represents a BoolValue. */ + class BoolValue implements IBoolValue { + + /** + * Constructs a new BoolValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IBoolValue); + + /** BoolValue value. */ + public value: boolean; + } + + /** Properties of a StringValue. */ + interface IStringValue { + + /** StringValue value */ + value?: (string|null); + } + + /** Represents a StringValue. */ + class StringValue implements IStringValue { + + /** + * Constructs a new StringValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IStringValue); + + /** StringValue value. */ + public value: string; + } + + /** Properties of a BytesValue. */ + interface IBytesValue { + + /** BytesValue value */ + value?: (Uint8Array|null); + } + + /** Represents a BytesValue. */ + class BytesValue implements IBytesValue { + + /** + * Constructs a new BytesValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IBytesValue); + + /** BytesValue value. */ + public value: Uint8Array; + } + + /** Properties of an Any. */ + interface IAny { + + /** Any type_url */ + type_url?: (string|null); + + /** Any value */ + value?: (Uint8Array|null); + } + + /** Represents an Any. */ + class Any implements IAny { + + /** + * Constructs a new Any. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IAny); + + /** Any type_url. */ + public type_url: string; + + /** Any value. */ + public value: Uint8Array; + } + + /** Properties of a FieldMask. */ + interface IFieldMask { + + /** FieldMask paths */ + paths?: (string[]|null); + } + + /** Represents a FieldMask. */ + class FieldMask implements IFieldMask { + + /** + * Constructs a new FieldMask. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldMask); + + /** FieldMask paths. */ + public paths: string[]; + } + + /** Properties of a Duration. */ + interface IDuration { + + /** Duration seconds */ + seconds?: (number|null); + + /** Duration nanos */ + nanos?: (number|null); + } + + /** Represents a Duration. */ + class Duration implements IDuration { + + /** + * Constructs a new Duration. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDuration); + + /** Duration seconds. */ + public seconds: number; + + /** Duration nanos. */ + public nanos: number; + } + } + + /** Namespace firestore. */ + namespace firestore { + + /** Namespace v1beta1. */ + namespace v1beta1 { + + /** Properties of a DocumentMask. */ + interface IDocumentMask { + + /** DocumentMask fieldPaths */ + fieldPaths?: (string[]|null); + } + + /** Represents a DocumentMask. */ + class DocumentMask implements IDocumentMask { + + /** + * Constructs a new DocumentMask. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IDocumentMask); + + /** DocumentMask fieldPaths. */ + public fieldPaths: string[]; + } + + /** Properties of a Precondition. */ + interface IPrecondition { + + /** Precondition exists */ + exists?: (boolean|null); + + /** Precondition updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a Precondition. */ + class Precondition implements IPrecondition { + + /** + * Constructs a new Precondition. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IPrecondition); + + /** Precondition exists. */ + public exists: boolean; + + /** Precondition updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** Precondition conditionType. */ + public conditionType?: ("exists"|"updateTime"); + } + + /** Properties of a TransactionOptions. */ + interface ITransactionOptions { + + /** TransactionOptions readOnly */ + readOnly?: (google.firestore.v1beta1.TransactionOptions.IReadOnly|null); + + /** TransactionOptions readWrite */ + readWrite?: (google.firestore.v1beta1.TransactionOptions.IReadWrite|null); + } + + /** Represents a TransactionOptions. */ + class TransactionOptions implements ITransactionOptions { + + /** + * Constructs a new TransactionOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.ITransactionOptions); + + /** TransactionOptions readOnly. */ + public readOnly?: (google.firestore.v1beta1.TransactionOptions.IReadOnly|null); + + /** TransactionOptions readWrite. */ + public readWrite?: (google.firestore.v1beta1.TransactionOptions.IReadWrite|null); + + /** TransactionOptions mode. */ + public mode?: ("readOnly"|"readWrite"); + } + + namespace TransactionOptions { + + /** Properties of a ReadWrite. */ + interface IReadWrite { + + /** ReadWrite retryTransaction */ + retryTransaction?: (Uint8Array|null); + } + + /** Represents a ReadWrite. */ + class ReadWrite implements IReadWrite { + + /** + * Constructs a new ReadWrite. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.TransactionOptions.IReadWrite); + + /** ReadWrite retryTransaction. */ + public retryTransaction: Uint8Array; + } + + /** Properties of a ReadOnly. */ + interface IReadOnly { + + /** ReadOnly readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a ReadOnly. */ + class ReadOnly implements IReadOnly { + + /** + * Constructs a new ReadOnly. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.TransactionOptions.IReadOnly); + + /** ReadOnly readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** ReadOnly consistencySelector. */ + public consistencySelector?: "readTime"; + } + } + + /** Properties of a Document. */ + interface IDocument { + + /** Document name */ + name?: (string|null); + + /** Document fields */ + fields?: ({ [k: string]: google.firestore.v1beta1.IValue }|null); + + /** Document createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** Document updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a Document. */ + class Document implements IDocument { + + /** + * Constructs a new Document. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IDocument); + + /** Document name. */ + public name: string; + + /** Document fields. */ + public fields: { [k: string]: google.firestore.v1beta1.IValue }; + + /** Document createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** Document updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + } + + /** Properties of a Value. */ + interface IValue { + + /** Value nullValue */ + nullValue?: (google.protobuf.NullValue|null); + + /** Value booleanValue */ + booleanValue?: (boolean|null); + + /** Value integerValue */ + integerValue?: (number|null); + + /** Value doubleValue */ + doubleValue?: (number|null); + + /** Value timestampValue */ + timestampValue?: (google.protobuf.ITimestamp|null); + + /** Value stringValue */ + stringValue?: (string|null); + + /** Value bytesValue */ + bytesValue?: (Uint8Array|null); + + /** Value referenceValue */ + referenceValue?: (string|null); + + /** Value geoPointValue */ + geoPointValue?: (google.type.ILatLng|null); + + /** Value arrayValue */ + arrayValue?: (google.firestore.v1beta1.IArrayValue|null); + + /** Value mapValue */ + mapValue?: (google.firestore.v1beta1.IMapValue|null); + } + + /** Represents a Value. */ + class Value implements IValue { + + /** + * Constructs a new Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IValue); + + /** Value nullValue. */ + public nullValue: google.protobuf.NullValue; + + /** Value booleanValue. */ + public booleanValue: boolean; + + /** Value integerValue. */ + public integerValue: number; + + /** Value doubleValue. */ + public doubleValue: number; + + /** Value timestampValue. */ + public timestampValue?: (google.protobuf.ITimestamp|null); + + /** Value stringValue. */ + public stringValue: string; + + /** Value bytesValue. */ + public bytesValue: Uint8Array; + + /** Value referenceValue. */ + public referenceValue: string; + + /** Value geoPointValue. */ + public geoPointValue?: (google.type.ILatLng|null); + + /** Value arrayValue. */ + public arrayValue?: (google.firestore.v1beta1.IArrayValue|null); + + /** Value mapValue. */ + public mapValue?: (google.firestore.v1beta1.IMapValue|null); + + /** Value valueType. */ + public valueType?: ("nullValue"|"booleanValue"|"integerValue"|"doubleValue"|"timestampValue"|"stringValue"|"bytesValue"|"referenceValue"|"geoPointValue"|"arrayValue"|"mapValue"); + } + + /** Properties of an ArrayValue. */ + interface IArrayValue { + + /** ArrayValue values */ + values?: (google.firestore.v1beta1.IValue[]|null); + } + + /** Represents an ArrayValue. */ + class ArrayValue implements IArrayValue { + + /** + * Constructs a new ArrayValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IArrayValue); + + /** ArrayValue values. */ + public values: google.firestore.v1beta1.IValue[]; + } + + /** Properties of a MapValue. */ + interface IMapValue { + + /** MapValue fields */ + fields?: ({ [k: string]: google.firestore.v1beta1.IValue }|null); + } + + /** Represents a MapValue. */ + class MapValue implements IMapValue { + + /** + * Constructs a new MapValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IMapValue); + + /** MapValue fields. */ + public fields: { [k: string]: google.firestore.v1beta1.IValue }; + } + + /** Represents a Firestore */ + class Firestore extends $protobuf.rpc.Service { + + /** + * Constructs a new Firestore service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Calls GetDocument. + * @param request GetDocumentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Document + */ + public getDocument(request: google.firestore.v1beta1.IGetDocumentRequest, callback: google.firestore.v1beta1.Firestore.GetDocumentCallback): void; + + /** + * Calls GetDocument. + * @param request GetDocumentRequest message or plain object + * @returns Promise + */ + public getDocument(request: google.firestore.v1beta1.IGetDocumentRequest): Promise; + + /** + * Calls ListDocuments. + * @param request ListDocumentsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListDocumentsResponse + */ + public listDocuments(request: google.firestore.v1beta1.IListDocumentsRequest, callback: google.firestore.v1beta1.Firestore.ListDocumentsCallback): void; + + /** + * Calls ListDocuments. + * @param request ListDocumentsRequest message or plain object + * @returns Promise + */ + public listDocuments(request: google.firestore.v1beta1.IListDocumentsRequest): Promise; + + /** + * Calls CreateDocument. + * @param request CreateDocumentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Document + */ + public createDocument(request: google.firestore.v1beta1.ICreateDocumentRequest, callback: google.firestore.v1beta1.Firestore.CreateDocumentCallback): void; + + /** + * Calls CreateDocument. + * @param request CreateDocumentRequest message or plain object + * @returns Promise + */ + public createDocument(request: google.firestore.v1beta1.ICreateDocumentRequest): Promise; + + /** + * Calls UpdateDocument. + * @param request UpdateDocumentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Document + */ + public updateDocument(request: google.firestore.v1beta1.IUpdateDocumentRequest, callback: google.firestore.v1beta1.Firestore.UpdateDocumentCallback): void; + + /** + * Calls UpdateDocument. + * @param request UpdateDocumentRequest message or plain object + * @returns Promise + */ + public updateDocument(request: google.firestore.v1beta1.IUpdateDocumentRequest): Promise; + + /** + * Calls DeleteDocument. + * @param request DeleteDocumentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteDocument(request: google.firestore.v1beta1.IDeleteDocumentRequest, callback: google.firestore.v1beta1.Firestore.DeleteDocumentCallback): void; + + /** + * Calls DeleteDocument. + * @param request DeleteDocumentRequest message or plain object + * @returns Promise + */ + public deleteDocument(request: google.firestore.v1beta1.IDeleteDocumentRequest): Promise; + + /** + * Calls BatchGetDocuments. + * @param request BatchGetDocumentsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and BatchGetDocumentsResponse + */ + public batchGetDocuments(request: google.firestore.v1beta1.IBatchGetDocumentsRequest, callback: google.firestore.v1beta1.Firestore.BatchGetDocumentsCallback): void; + + /** + * Calls BatchGetDocuments. + * @param request BatchGetDocumentsRequest message or plain object + * @returns Promise + */ + public batchGetDocuments(request: google.firestore.v1beta1.IBatchGetDocumentsRequest): Promise; + + /** + * Calls BeginTransaction. + * @param request BeginTransactionRequest message or plain object + * @param callback Node-style callback called with the error, if any, and BeginTransactionResponse + */ + public beginTransaction(request: google.firestore.v1beta1.IBeginTransactionRequest, callback: google.firestore.v1beta1.Firestore.BeginTransactionCallback): void; + + /** + * Calls BeginTransaction. + * @param request BeginTransactionRequest message or plain object + * @returns Promise + */ + public beginTransaction(request: google.firestore.v1beta1.IBeginTransactionRequest): Promise; + + /** + * Calls Commit. + * @param request CommitRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CommitResponse + */ + public commit(request: google.firestore.v1beta1.ICommitRequest, callback: google.firestore.v1beta1.Firestore.CommitCallback): void; + + /** + * Calls Commit. + * @param request CommitRequest message or plain object + * @returns Promise + */ + public commit(request: google.firestore.v1beta1.ICommitRequest): Promise; + + /** + * Calls Rollback. + * @param request RollbackRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public rollback(request: google.firestore.v1beta1.IRollbackRequest, callback: google.firestore.v1beta1.Firestore.RollbackCallback): void; + + /** + * Calls Rollback. + * @param request RollbackRequest message or plain object + * @returns Promise + */ + public rollback(request: google.firestore.v1beta1.IRollbackRequest): Promise; + + /** + * Calls RunQuery. + * @param request RunQueryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and RunQueryResponse + */ + public runQuery(request: google.firestore.v1beta1.IRunQueryRequest, callback: google.firestore.v1beta1.Firestore.RunQueryCallback): void; + + /** + * Calls RunQuery. + * @param request RunQueryRequest message or plain object + * @returns Promise + */ + public runQuery(request: google.firestore.v1beta1.IRunQueryRequest): Promise; + + /** + * Calls Write. + * @param request WriteRequest message or plain object + * @param callback Node-style callback called with the error, if any, and WriteResponse + */ + public write(request: google.firestore.v1beta1.IWriteRequest, callback: google.firestore.v1beta1.Firestore.WriteCallback): void; + + /** + * Calls Write. + * @param request WriteRequest message or plain object + * @returns Promise + */ + public write(request: google.firestore.v1beta1.IWriteRequest): Promise; + + /** + * Calls Listen. + * @param request ListenRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListenResponse + */ + public listen(request: google.firestore.v1beta1.IListenRequest, callback: google.firestore.v1beta1.Firestore.ListenCallback): void; + + /** + * Calls Listen. + * @param request ListenRequest message or plain object + * @returns Promise + */ + public listen(request: google.firestore.v1beta1.IListenRequest): Promise; + + /** + * Calls ListCollectionIds. + * @param request ListCollectionIdsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListCollectionIdsResponse + */ + public listCollectionIds(request: google.firestore.v1beta1.IListCollectionIdsRequest, callback: google.firestore.v1beta1.Firestore.ListCollectionIdsCallback): void; + + /** + * Calls ListCollectionIds. + * @param request ListCollectionIdsRequest message or plain object + * @returns Promise + */ + public listCollectionIds(request: google.firestore.v1beta1.IListCollectionIdsRequest): Promise; + } + + namespace Firestore { + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#getDocument}. + * @param error Error, if any + * @param [response] Document + */ + type GetDocumentCallback = (error: (Error|null), response?: google.firestore.v1beta1.Document) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#listDocuments}. + * @param error Error, if any + * @param [response] ListDocumentsResponse + */ + type ListDocumentsCallback = (error: (Error|null), response?: google.firestore.v1beta1.ListDocumentsResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#createDocument}. + * @param error Error, if any + * @param [response] Document + */ + type CreateDocumentCallback = (error: (Error|null), response?: google.firestore.v1beta1.Document) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#updateDocument}. + * @param error Error, if any + * @param [response] Document + */ + type UpdateDocumentCallback = (error: (Error|null), response?: google.firestore.v1beta1.Document) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#deleteDocument}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteDocumentCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#batchGetDocuments}. + * @param error Error, if any + * @param [response] BatchGetDocumentsResponse + */ + type BatchGetDocumentsCallback = (error: (Error|null), response?: google.firestore.v1beta1.BatchGetDocumentsResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#beginTransaction}. + * @param error Error, if any + * @param [response] BeginTransactionResponse + */ + type BeginTransactionCallback = (error: (Error|null), response?: google.firestore.v1beta1.BeginTransactionResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#commit}. + * @param error Error, if any + * @param [response] CommitResponse + */ + type CommitCallback = (error: (Error|null), response?: google.firestore.v1beta1.CommitResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#rollback}. + * @param error Error, if any + * @param [response] Empty + */ + type RollbackCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#runQuery}. + * @param error Error, if any + * @param [response] RunQueryResponse + */ + type RunQueryCallback = (error: (Error|null), response?: google.firestore.v1beta1.RunQueryResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#write}. + * @param error Error, if any + * @param [response] WriteResponse + */ + type WriteCallback = (error: (Error|null), response?: google.firestore.v1beta1.WriteResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#listen}. + * @param error Error, if any + * @param [response] ListenResponse + */ + type ListenCallback = (error: (Error|null), response?: google.firestore.v1beta1.ListenResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#listCollectionIds}. + * @param error Error, if any + * @param [response] ListCollectionIdsResponse + */ + type ListCollectionIdsCallback = (error: (Error|null), response?: google.firestore.v1beta1.ListCollectionIdsResponse) => void; + } + + /** Properties of a GetDocumentRequest. */ + interface IGetDocumentRequest { + + /** GetDocumentRequest name */ + name?: (string|null); + + /** GetDocumentRequest mask */ + mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** GetDocumentRequest transaction */ + transaction?: (Uint8Array|null); + + /** GetDocumentRequest readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a GetDocumentRequest. */ + class GetDocumentRequest implements IGetDocumentRequest { + + /** + * Constructs a new GetDocumentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IGetDocumentRequest); + + /** GetDocumentRequest name. */ + public name: string; + + /** GetDocumentRequest mask. */ + public mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** GetDocumentRequest transaction. */ + public transaction: Uint8Array; + + /** GetDocumentRequest readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** GetDocumentRequest consistencySelector. */ + public consistencySelector?: ("transaction"|"readTime"); + } + + /** Properties of a ListDocumentsRequest. */ + interface IListDocumentsRequest { + + /** ListDocumentsRequest parent */ + parent?: (string|null); + + /** ListDocumentsRequest collectionId */ + collectionId?: (string|null); + + /** ListDocumentsRequest pageSize */ + pageSize?: (number|null); + + /** ListDocumentsRequest pageToken */ + pageToken?: (string|null); + + /** ListDocumentsRequest orderBy */ + orderBy?: (string|null); + + /** ListDocumentsRequest mask */ + mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** ListDocumentsRequest transaction */ + transaction?: (Uint8Array|null); + + /** ListDocumentsRequest readTime */ + readTime?: (google.protobuf.ITimestamp|null); + + /** ListDocumentsRequest showMissing */ + showMissing?: (boolean|null); + } + + /** Represents a ListDocumentsRequest. */ + class ListDocumentsRequest implements IListDocumentsRequest { + + /** + * Constructs a new ListDocumentsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IListDocumentsRequest); + + /** ListDocumentsRequest parent. */ + public parent: string; + + /** ListDocumentsRequest collectionId. */ + public collectionId: string; + + /** ListDocumentsRequest pageSize. */ + public pageSize: number; + + /** ListDocumentsRequest pageToken. */ + public pageToken: string; + + /** ListDocumentsRequest orderBy. */ + public orderBy: string; + + /** ListDocumentsRequest mask. */ + public mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** ListDocumentsRequest transaction. */ + public transaction: Uint8Array; + + /** ListDocumentsRequest readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** ListDocumentsRequest showMissing. */ + public showMissing: boolean; + + /** ListDocumentsRequest consistencySelector. */ + public consistencySelector?: ("transaction"|"readTime"); + } + + /** Properties of a ListDocumentsResponse. */ + interface IListDocumentsResponse { + + /** ListDocumentsResponse documents */ + documents?: (google.firestore.v1beta1.IDocument[]|null); + + /** ListDocumentsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListDocumentsResponse. */ + class ListDocumentsResponse implements IListDocumentsResponse { + + /** + * Constructs a new ListDocumentsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IListDocumentsResponse); + + /** ListDocumentsResponse documents. */ + public documents: google.firestore.v1beta1.IDocument[]; + + /** ListDocumentsResponse nextPageToken. */ + public nextPageToken: string; + } + + /** Properties of a CreateDocumentRequest. */ + interface ICreateDocumentRequest { + + /** CreateDocumentRequest parent */ + parent?: (string|null); + + /** CreateDocumentRequest collectionId */ + collectionId?: (string|null); + + /** CreateDocumentRequest documentId */ + documentId?: (string|null); + + /** CreateDocumentRequest document */ + document?: (google.firestore.v1beta1.IDocument|null); + + /** CreateDocumentRequest mask */ + mask?: (google.firestore.v1beta1.IDocumentMask|null); + } + + /** Represents a CreateDocumentRequest. */ + class CreateDocumentRequest implements ICreateDocumentRequest { + + /** + * Constructs a new CreateDocumentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.ICreateDocumentRequest); + + /** CreateDocumentRequest parent. */ + public parent: string; + + /** CreateDocumentRequest collectionId. */ + public collectionId: string; + + /** CreateDocumentRequest documentId. */ + public documentId: string; + + /** CreateDocumentRequest document. */ + public document?: (google.firestore.v1beta1.IDocument|null); + + /** CreateDocumentRequest mask. */ + public mask?: (google.firestore.v1beta1.IDocumentMask|null); + } + + /** Properties of an UpdateDocumentRequest. */ + interface IUpdateDocumentRequest { + + /** UpdateDocumentRequest document */ + document?: (google.firestore.v1beta1.IDocument|null); + + /** UpdateDocumentRequest updateMask */ + updateMask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** UpdateDocumentRequest mask */ + mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** UpdateDocumentRequest currentDocument */ + currentDocument?: (google.firestore.v1beta1.IPrecondition|null); + } + + /** Represents an UpdateDocumentRequest. */ + class UpdateDocumentRequest implements IUpdateDocumentRequest { + + /** + * Constructs a new UpdateDocumentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IUpdateDocumentRequest); + + /** UpdateDocumentRequest document. */ + public document?: (google.firestore.v1beta1.IDocument|null); + + /** UpdateDocumentRequest updateMask. */ + public updateMask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** UpdateDocumentRequest mask. */ + public mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** UpdateDocumentRequest currentDocument. */ + public currentDocument?: (google.firestore.v1beta1.IPrecondition|null); + } + + /** Properties of a DeleteDocumentRequest. */ + interface IDeleteDocumentRequest { + + /** DeleteDocumentRequest name */ + name?: (string|null); + + /** DeleteDocumentRequest currentDocument */ + currentDocument?: (google.firestore.v1beta1.IPrecondition|null); + } + + /** Represents a DeleteDocumentRequest. */ + class DeleteDocumentRequest implements IDeleteDocumentRequest { + + /** + * Constructs a new DeleteDocumentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IDeleteDocumentRequest); + + /** DeleteDocumentRequest name. */ + public name: string; + + /** DeleteDocumentRequest currentDocument. */ + public currentDocument?: (google.firestore.v1beta1.IPrecondition|null); + } + + /** Properties of a BatchGetDocumentsRequest. */ + interface IBatchGetDocumentsRequest { + + /** BatchGetDocumentsRequest database */ + database?: (string|null); + + /** BatchGetDocumentsRequest documents */ + documents?: (string[]|null); + + /** BatchGetDocumentsRequest mask */ + mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** BatchGetDocumentsRequest transaction */ + transaction?: (Uint8Array|null); + + /** BatchGetDocumentsRequest newTransaction */ + newTransaction?: (google.firestore.v1beta1.ITransactionOptions|null); + + /** BatchGetDocumentsRequest readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a BatchGetDocumentsRequest. */ + class BatchGetDocumentsRequest implements IBatchGetDocumentsRequest { + + /** + * Constructs a new BatchGetDocumentsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IBatchGetDocumentsRequest); + + /** BatchGetDocumentsRequest database. */ + public database: string; + + /** BatchGetDocumentsRequest documents. */ + public documents: string[]; + + /** BatchGetDocumentsRequest mask. */ + public mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** BatchGetDocumentsRequest transaction. */ + public transaction: Uint8Array; + + /** BatchGetDocumentsRequest newTransaction. */ + public newTransaction?: (google.firestore.v1beta1.ITransactionOptions|null); + + /** BatchGetDocumentsRequest readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** BatchGetDocumentsRequest consistencySelector. */ + public consistencySelector?: ("transaction"|"newTransaction"|"readTime"); + } + + /** Properties of a BatchGetDocumentsResponse. */ + interface IBatchGetDocumentsResponse { + + /** BatchGetDocumentsResponse found */ + found?: (google.firestore.v1beta1.IDocument|null); + + /** BatchGetDocumentsResponse missing */ + missing?: (string|null); + + /** BatchGetDocumentsResponse transaction */ + transaction?: (Uint8Array|null); + + /** BatchGetDocumentsResponse readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a BatchGetDocumentsResponse. */ + class BatchGetDocumentsResponse implements IBatchGetDocumentsResponse { + + /** + * Constructs a new BatchGetDocumentsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IBatchGetDocumentsResponse); + + /** BatchGetDocumentsResponse found. */ + public found?: (google.firestore.v1beta1.IDocument|null); + + /** BatchGetDocumentsResponse missing. */ + public missing: string; + + /** BatchGetDocumentsResponse transaction. */ + public transaction: Uint8Array; + + /** BatchGetDocumentsResponse readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** BatchGetDocumentsResponse result. */ + public result?: ("found"|"missing"); + } + + /** Properties of a BeginTransactionRequest. */ + interface IBeginTransactionRequest { + + /** BeginTransactionRequest database */ + database?: (string|null); + + /** BeginTransactionRequest options */ + options?: (google.firestore.v1beta1.ITransactionOptions|null); + } + + /** Represents a BeginTransactionRequest. */ + class BeginTransactionRequest implements IBeginTransactionRequest { + + /** + * Constructs a new BeginTransactionRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IBeginTransactionRequest); + + /** BeginTransactionRequest database. */ + public database: string; + + /** BeginTransactionRequest options. */ + public options?: (google.firestore.v1beta1.ITransactionOptions|null); + } + + /** Properties of a BeginTransactionResponse. */ + interface IBeginTransactionResponse { + + /** BeginTransactionResponse transaction */ + transaction?: (Uint8Array|null); + } + + /** Represents a BeginTransactionResponse. */ + class BeginTransactionResponse implements IBeginTransactionResponse { + + /** + * Constructs a new BeginTransactionResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IBeginTransactionResponse); + + /** BeginTransactionResponse transaction. */ + public transaction: Uint8Array; + } + + /** Properties of a CommitRequest. */ + interface ICommitRequest { + + /** CommitRequest database */ + database?: (string|null); + + /** CommitRequest writes */ + writes?: (google.firestore.v1beta1.IWrite[]|null); + + /** CommitRequest transaction */ + transaction?: (Uint8Array|null); + } + + /** Represents a CommitRequest. */ + class CommitRequest implements ICommitRequest { + + /** + * Constructs a new CommitRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.ICommitRequest); + + /** CommitRequest database. */ + public database: string; + + /** CommitRequest writes. */ + public writes: google.firestore.v1beta1.IWrite[]; + + /** CommitRequest transaction. */ + public transaction: Uint8Array; + } + + /** Properties of a CommitResponse. */ + interface ICommitResponse { + + /** CommitResponse writeResults */ + writeResults?: (google.firestore.v1beta1.IWriteResult[]|null); + + /** CommitResponse commitTime */ + commitTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a CommitResponse. */ + class CommitResponse implements ICommitResponse { + + /** + * Constructs a new CommitResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.ICommitResponse); + + /** CommitResponse writeResults. */ + public writeResults: google.firestore.v1beta1.IWriteResult[]; + + /** CommitResponse commitTime. */ + public commitTime?: (google.protobuf.ITimestamp|null); + } + + /** Properties of a RollbackRequest. */ + interface IRollbackRequest { + + /** RollbackRequest database */ + database?: (string|null); + + /** RollbackRequest transaction */ + transaction?: (Uint8Array|null); + } + + /** Represents a RollbackRequest. */ + class RollbackRequest implements IRollbackRequest { + + /** + * Constructs a new RollbackRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IRollbackRequest); + + /** RollbackRequest database. */ + public database: string; + + /** RollbackRequest transaction. */ + public transaction: Uint8Array; + } + + /** Properties of a RunQueryRequest. */ + interface IRunQueryRequest { + + /** RunQueryRequest parent */ + parent?: (string|null); + + /** RunQueryRequest structuredQuery */ + structuredQuery?: (google.firestore.v1beta1.IStructuredQuery|null); + + /** RunQueryRequest transaction */ + transaction?: (Uint8Array|null); + + /** RunQueryRequest newTransaction */ + newTransaction?: (google.firestore.v1beta1.ITransactionOptions|null); + + /** RunQueryRequest readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a RunQueryRequest. */ + class RunQueryRequest implements IRunQueryRequest { + + /** + * Constructs a new RunQueryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IRunQueryRequest); + + /** RunQueryRequest parent. */ + public parent: string; + + /** RunQueryRequest structuredQuery. */ + public structuredQuery?: (google.firestore.v1beta1.IStructuredQuery|null); + + /** RunQueryRequest transaction. */ + public transaction: Uint8Array; + + /** RunQueryRequest newTransaction. */ + public newTransaction?: (google.firestore.v1beta1.ITransactionOptions|null); + + /** RunQueryRequest readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** RunQueryRequest queryType. */ + public queryType?: "structuredQuery"; + + /** RunQueryRequest consistencySelector. */ + public consistencySelector?: ("transaction"|"newTransaction"|"readTime"); + } + + /** Properties of a RunQueryResponse. */ + interface IRunQueryResponse { + + /** RunQueryResponse transaction */ + transaction?: (Uint8Array|null); + + /** RunQueryResponse document */ + document?: (google.firestore.v1beta1.IDocument|null); + + /** RunQueryResponse readTime */ + readTime?: (google.protobuf.ITimestamp|null); + + /** RunQueryResponse skippedResults */ + skippedResults?: (number|null); + } + + /** Represents a RunQueryResponse. */ + class RunQueryResponse implements IRunQueryResponse { + + /** + * Constructs a new RunQueryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IRunQueryResponse); + + /** RunQueryResponse transaction. */ + public transaction: Uint8Array; + + /** RunQueryResponse document. */ + public document?: (google.firestore.v1beta1.IDocument|null); + + /** RunQueryResponse readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** RunQueryResponse skippedResults. */ + public skippedResults: number; + } + + /** Properties of a WriteRequest. */ + interface IWriteRequest { + + /** WriteRequest database */ + database?: (string|null); + + /** WriteRequest streamId */ + streamId?: (string|null); + + /** WriteRequest writes */ + writes?: (google.firestore.v1beta1.IWrite[]|null); + + /** WriteRequest streamToken */ + streamToken?: (Uint8Array|null); + + /** WriteRequest labels */ + labels?: ({ [k: string]: string }|null); + } + + /** Represents a WriteRequest. */ + class WriteRequest implements IWriteRequest { + + /** + * Constructs a new WriteRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IWriteRequest); + + /** WriteRequest database. */ + public database: string; + + /** WriteRequest streamId. */ + public streamId: string; + + /** WriteRequest writes. */ + public writes: google.firestore.v1beta1.IWrite[]; + + /** WriteRequest streamToken. */ + public streamToken: Uint8Array; + + /** WriteRequest labels. */ + public labels: { [k: string]: string }; + } + + /** Properties of a WriteResponse. */ + interface IWriteResponse { + + /** WriteResponse streamId */ + streamId?: (string|null); + + /** WriteResponse streamToken */ + streamToken?: (Uint8Array|null); + + /** WriteResponse writeResults */ + writeResults?: (google.firestore.v1beta1.IWriteResult[]|null); + + /** WriteResponse commitTime */ + commitTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a WriteResponse. */ + class WriteResponse implements IWriteResponse { + + /** + * Constructs a new WriteResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IWriteResponse); + + /** WriteResponse streamId. */ + public streamId: string; + + /** WriteResponse streamToken. */ + public streamToken: Uint8Array; + + /** WriteResponse writeResults. */ + public writeResults: google.firestore.v1beta1.IWriteResult[]; + + /** WriteResponse commitTime. */ + public commitTime?: (google.protobuf.ITimestamp|null); + } + + /** Properties of a ListenRequest. */ + interface IListenRequest { + + /** ListenRequest database */ + database?: (string|null); + + /** ListenRequest addTarget */ + addTarget?: (google.firestore.v1beta1.ITarget|null); + + /** ListenRequest removeTarget */ + removeTarget?: (number|null); + + /** ListenRequest labels */ + labels?: ({ [k: string]: string }|null); + } + + /** Represents a ListenRequest. */ + class ListenRequest implements IListenRequest { + + /** + * Constructs a new ListenRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IListenRequest); + + /** ListenRequest database. */ + public database: string; + + /** ListenRequest addTarget. */ + public addTarget?: (google.firestore.v1beta1.ITarget|null); + + /** ListenRequest removeTarget. */ + public removeTarget: number; + + /** ListenRequest labels. */ + public labels: { [k: string]: string }; + + /** ListenRequest targetChange. */ + public targetChange?: ("addTarget"|"removeTarget"); + } + + /** Properties of a ListenResponse. */ + interface IListenResponse { + + /** ListenResponse targetChange */ + targetChange?: (google.firestore.v1beta1.ITargetChange|null); + + /** ListenResponse documentChange */ + documentChange?: (google.firestore.v1beta1.IDocumentChange|null); + + /** ListenResponse documentDelete */ + documentDelete?: (google.firestore.v1beta1.IDocumentDelete|null); + + /** ListenResponse documentRemove */ + documentRemove?: (google.firestore.v1beta1.IDocumentRemove|null); + + /** ListenResponse filter */ + filter?: (google.firestore.v1beta1.IExistenceFilter|null); + } + + /** Represents a ListenResponse. */ + class ListenResponse implements IListenResponse { + + /** + * Constructs a new ListenResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IListenResponse); + + /** ListenResponse targetChange. */ + public targetChange?: (google.firestore.v1beta1.ITargetChange|null); + + /** ListenResponse documentChange. */ + public documentChange?: (google.firestore.v1beta1.IDocumentChange|null); + + /** ListenResponse documentDelete. */ + public documentDelete?: (google.firestore.v1beta1.IDocumentDelete|null); + + /** ListenResponse documentRemove. */ + public documentRemove?: (google.firestore.v1beta1.IDocumentRemove|null); + + /** ListenResponse filter. */ + public filter?: (google.firestore.v1beta1.IExistenceFilter|null); + + /** ListenResponse responseType. */ + public responseType?: ("targetChange"|"documentChange"|"documentDelete"|"documentRemove"|"filter"); + } + + /** Properties of a Target. */ + interface ITarget { + + /** Target query */ + query?: (google.firestore.v1beta1.Target.IQueryTarget|null); + + /** Target documents */ + documents?: (google.firestore.v1beta1.Target.IDocumentsTarget|null); + + /** Target resumeToken */ + resumeToken?: (Uint8Array|null); + + /** Target readTime */ + readTime?: (google.protobuf.ITimestamp|null); + + /** Target targetId */ + targetId?: (number|null); + + /** Target once */ + once?: (boolean|null); + } + + /** Represents a Target. */ + class Target implements ITarget { + + /** + * Constructs a new Target. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.ITarget); + + /** Target query. */ + public query?: (google.firestore.v1beta1.Target.IQueryTarget|null); + + /** Target documents. */ + public documents?: (google.firestore.v1beta1.Target.IDocumentsTarget|null); + + /** Target resumeToken. */ + public resumeToken: Uint8Array; + + /** Target readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** Target targetId. */ + public targetId: number; + + /** Target once. */ + public once: boolean; + + /** Target targetType. */ + public targetType?: ("query"|"documents"); + + /** Target resumeType. */ + public resumeType?: ("resumeToken"|"readTime"); + } + + namespace Target { + + /** Properties of a DocumentsTarget. */ + interface IDocumentsTarget { + + /** DocumentsTarget documents */ + documents?: (string[]|null); + } + + /** Represents a DocumentsTarget. */ + class DocumentsTarget implements IDocumentsTarget { + + /** + * Constructs a new DocumentsTarget. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.Target.IDocumentsTarget); + + /** DocumentsTarget documents. */ + public documents: string[]; + } + + /** Properties of a QueryTarget. */ + interface IQueryTarget { + + /** QueryTarget parent */ + parent?: (string|null); + + /** QueryTarget structuredQuery */ + structuredQuery?: (google.firestore.v1beta1.IStructuredQuery|null); + } + + /** Represents a QueryTarget. */ + class QueryTarget implements IQueryTarget { + + /** + * Constructs a new QueryTarget. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.Target.IQueryTarget); + + /** QueryTarget parent. */ + public parent: string; + + /** QueryTarget structuredQuery. */ + public structuredQuery?: (google.firestore.v1beta1.IStructuredQuery|null); + + /** QueryTarget queryType. */ + public queryType?: "structuredQuery"; + } + } + + /** Properties of a TargetChange. */ + interface ITargetChange { + + /** TargetChange targetChangeType */ + targetChangeType?: (google.firestore.v1beta1.TargetChange.TargetChangeType|null); + + /** TargetChange targetIds */ + targetIds?: (number[]|null); + + /** TargetChange cause */ + cause?: (google.rpc.IStatus|null); + + /** TargetChange resumeToken */ + resumeToken?: (Uint8Array|null); + + /** TargetChange readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a TargetChange. */ + class TargetChange implements ITargetChange { + + /** + * Constructs a new TargetChange. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.ITargetChange); + + /** TargetChange targetChangeType. */ + public targetChangeType: google.firestore.v1beta1.TargetChange.TargetChangeType; + + /** TargetChange targetIds. */ + public targetIds: number[]; + + /** TargetChange cause. */ + public cause?: (google.rpc.IStatus|null); + + /** TargetChange resumeToken. */ + public resumeToken: Uint8Array; + + /** TargetChange readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + } + + namespace TargetChange { + + /** TargetChangeType enum. */ + type TargetChangeType = + "NO_CHANGE"| "ADD"| "REMOVE"| "CURRENT"| "RESET"; + } + + /** Properties of a ListCollectionIdsRequest. */ + interface IListCollectionIdsRequest { + + /** ListCollectionIdsRequest parent */ + parent?: (string|null); + + /** ListCollectionIdsRequest pageSize */ + pageSize?: (number|null); + + /** ListCollectionIdsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListCollectionIdsRequest. */ + class ListCollectionIdsRequest implements IListCollectionIdsRequest { + + /** + * Constructs a new ListCollectionIdsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IListCollectionIdsRequest); + + /** ListCollectionIdsRequest parent. */ + public parent: string; + + /** ListCollectionIdsRequest pageSize. */ + public pageSize: number; + + /** ListCollectionIdsRequest pageToken. */ + public pageToken: string; + } + + /** Properties of a ListCollectionIdsResponse. */ + interface IListCollectionIdsResponse { + + /** ListCollectionIdsResponse collectionIds */ + collectionIds?: (string[]|null); + + /** ListCollectionIdsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListCollectionIdsResponse. */ + class ListCollectionIdsResponse implements IListCollectionIdsResponse { + + /** + * Constructs a new ListCollectionIdsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IListCollectionIdsResponse); + + /** ListCollectionIdsResponse collectionIds. */ + public collectionIds: string[]; + + /** ListCollectionIdsResponse nextPageToken. */ + public nextPageToken: string; + } + + /** Properties of a StructuredQuery. */ + interface IStructuredQuery { + + /** StructuredQuery select */ + select?: (google.firestore.v1beta1.StructuredQuery.IProjection|null); + + /** StructuredQuery from */ + from?: (google.firestore.v1beta1.StructuredQuery.ICollectionSelector[]|null); + + /** StructuredQuery where */ + where?: (google.firestore.v1beta1.StructuredQuery.IFilter|null); + + /** StructuredQuery orderBy */ + orderBy?: (google.firestore.v1beta1.StructuredQuery.IOrder[]|null); + + /** StructuredQuery startAt */ + startAt?: (google.firestore.v1beta1.ICursor|null); + + /** StructuredQuery endAt */ + endAt?: (google.firestore.v1beta1.ICursor|null); + + /** StructuredQuery offset */ + offset?: (number|null); + + /** StructuredQuery limit */ + limit?: (google.protobuf.IInt32Value|null); + } + + /** Represents a StructuredQuery. */ + class StructuredQuery implements IStructuredQuery { + + /** + * Constructs a new StructuredQuery. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IStructuredQuery); + + /** StructuredQuery select. */ + public select?: (google.firestore.v1beta1.StructuredQuery.IProjection|null); + + /** StructuredQuery from. */ + public from: google.firestore.v1beta1.StructuredQuery.ICollectionSelector[]; + + /** StructuredQuery where. */ + public where?: (google.firestore.v1beta1.StructuredQuery.IFilter|null); + + /** StructuredQuery orderBy. */ + public orderBy: google.firestore.v1beta1.StructuredQuery.IOrder[]; + + /** StructuredQuery startAt. */ + public startAt?: (google.firestore.v1beta1.ICursor|null); + + /** StructuredQuery endAt. */ + public endAt?: (google.firestore.v1beta1.ICursor|null); + + /** StructuredQuery offset. */ + public offset: number; + + /** StructuredQuery limit. */ + public limit?: (google.protobuf.IInt32Value|null); + } + + namespace StructuredQuery { + + /** Properties of a CollectionSelector. */ + interface ICollectionSelector { + + /** CollectionSelector collectionId */ + collectionId?: (string|null); + + /** CollectionSelector allDescendants */ + allDescendants?: (boolean|null); + } + + /** Represents a CollectionSelector. */ + class CollectionSelector implements ICollectionSelector { + + /** + * Constructs a new CollectionSelector. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.StructuredQuery.ICollectionSelector); + + /** CollectionSelector collectionId. */ + public collectionId: string; + + /** CollectionSelector allDescendants. */ + public allDescendants: boolean; + } + + /** Properties of a Filter. */ + interface IFilter { + + /** Filter compositeFilter */ + compositeFilter?: (google.firestore.v1beta1.StructuredQuery.ICompositeFilter|null); + + /** Filter fieldFilter */ + fieldFilter?: (google.firestore.v1beta1.StructuredQuery.IFieldFilter|null); + + /** Filter unaryFilter */ + unaryFilter?: (google.firestore.v1beta1.StructuredQuery.IUnaryFilter|null); + } + + /** Represents a Filter. */ + class Filter implements IFilter { + + /** + * Constructs a new Filter. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.StructuredQuery.IFilter); + + /** Filter compositeFilter. */ + public compositeFilter?: (google.firestore.v1beta1.StructuredQuery.ICompositeFilter|null); + + /** Filter fieldFilter. */ + public fieldFilter?: (google.firestore.v1beta1.StructuredQuery.IFieldFilter|null); + + /** Filter unaryFilter. */ + public unaryFilter?: (google.firestore.v1beta1.StructuredQuery.IUnaryFilter|null); + + /** Filter filterType. */ + public filterType?: ("compositeFilter"|"fieldFilter"|"unaryFilter"); + } + + /** Properties of a CompositeFilter. */ + interface ICompositeFilter { + + /** CompositeFilter op */ + op?: (google.firestore.v1beta1.StructuredQuery.CompositeFilter.Operator|null); + + /** CompositeFilter filters */ + filters?: (google.firestore.v1beta1.StructuredQuery.IFilter[]|null); + } + + /** Represents a CompositeFilter. */ + class CompositeFilter implements ICompositeFilter { + + /** + * Constructs a new CompositeFilter. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.StructuredQuery.ICompositeFilter); + + /** CompositeFilter op. */ + public op: google.firestore.v1beta1.StructuredQuery.CompositeFilter.Operator; + + /** CompositeFilter filters. */ + public filters: google.firestore.v1beta1.StructuredQuery.IFilter[]; + } + + namespace CompositeFilter { + + /** Operator enum. */ + type Operator = + "OPERATOR_UNSPECIFIED"| "AND"; + } + + /** Properties of a FieldFilter. */ + interface IFieldFilter { + + /** FieldFilter field */ + field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + + /** FieldFilter op */ + op?: (google.firestore.v1beta1.StructuredQuery.FieldFilter.Operator|null); + + /** FieldFilter value */ + value?: (google.firestore.v1beta1.IValue|null); + } + + /** Represents a FieldFilter. */ + class FieldFilter implements IFieldFilter { + + /** + * Constructs a new FieldFilter. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.StructuredQuery.IFieldFilter); + + /** FieldFilter field. */ + public field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + + /** FieldFilter op. */ + public op: google.firestore.v1beta1.StructuredQuery.FieldFilter.Operator; + + /** FieldFilter value. */ + public value?: (google.firestore.v1beta1.IValue|null); + } + + namespace FieldFilter { + + /** Operator enum. */ + type Operator = + "OPERATOR_UNSPECIFIED"| "LESS_THAN"| "LESS_THAN_OR_EQUAL"| "GREATER_THAN"| "GREATER_THAN_OR_EQUAL"| "EQUAL"| "ARRAY_CONTAINS"| "IN"| "ARRAY_CONTAINS_ANY"; + } + + /** Properties of an UnaryFilter. */ + interface IUnaryFilter { + + /** UnaryFilter op */ + op?: (google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator|null); + + /** UnaryFilter field */ + field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + } + + /** Represents an UnaryFilter. */ + class UnaryFilter implements IUnaryFilter { + + /** + * Constructs a new UnaryFilter. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.StructuredQuery.IUnaryFilter); + + /** UnaryFilter op. */ + public op: google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator; + + /** UnaryFilter field. */ + public field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + + /** UnaryFilter operandType. */ + public operandType?: "field"; + } + + namespace UnaryFilter { + + /** Operator enum. */ + type Operator = + "OPERATOR_UNSPECIFIED"| "IS_NAN"| "IS_NULL"; + } + + /** Properties of an Order. */ + interface IOrder { + + /** Order field */ + field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + + /** Order direction */ + direction?: (google.firestore.v1beta1.StructuredQuery.Direction|null); + } + + /** Represents an Order. */ + class Order implements IOrder { + + /** + * Constructs a new Order. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.StructuredQuery.IOrder); + + /** Order field. */ + public field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + + /** Order direction. */ + public direction: google.firestore.v1beta1.StructuredQuery.Direction; + } + + /** Properties of a FieldReference. */ + interface IFieldReference { + + /** FieldReference fieldPath */ + fieldPath?: (string|null); + } + + /** Represents a FieldReference. */ + class FieldReference implements IFieldReference { + + /** + * Constructs a new FieldReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.StructuredQuery.IFieldReference); + + /** FieldReference fieldPath. */ + public fieldPath: string; + } + + /** Properties of a Projection. */ + interface IProjection { + + /** Projection fields */ + fields?: (google.firestore.v1beta1.StructuredQuery.IFieldReference[]|null); + } + + /** Represents a Projection. */ + class Projection implements IProjection { + + /** + * Constructs a new Projection. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.StructuredQuery.IProjection); + + /** Projection fields. */ + public fields: google.firestore.v1beta1.StructuredQuery.IFieldReference[]; + } + + /** Direction enum. */ + type Direction = + "DIRECTION_UNSPECIFIED"| "ASCENDING"| "DESCENDING"; + } + + /** Properties of a Cursor. */ + interface ICursor { + + /** Cursor values */ + values?: (google.firestore.v1beta1.IValue[]|null); + + /** Cursor before */ + before?: (boolean|null); + } + + /** Represents a Cursor. */ + class Cursor implements ICursor { + + /** + * Constructs a new Cursor. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.ICursor); + + /** Cursor values. */ + public values: google.firestore.v1beta1.IValue[]; + + /** Cursor before. */ + public before: boolean; + } + + /** Properties of a Write. */ + interface IWrite { + + /** Write update */ + update?: (google.firestore.v1beta1.IDocument|null); + + /** Write delete */ + "delete"?: (string|null); + + /** Write transform */ + transform?: (google.firestore.v1beta1.IDocumentTransform|null); + + /** Write updateMask */ + updateMask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** Write currentDocument */ + currentDocument?: (google.firestore.v1beta1.IPrecondition|null); + } + + /** Represents a Write. */ + class Write implements IWrite { + + /** + * Constructs a new Write. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IWrite); + + /** Write update. */ + public update?: (google.firestore.v1beta1.IDocument|null); + + /** Write delete. */ + public delete: string; + + /** Write transform. */ + public transform?: (google.firestore.v1beta1.IDocumentTransform|null); + + /** Write updateMask. */ + public updateMask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** Write currentDocument. */ + public currentDocument?: (google.firestore.v1beta1.IPrecondition|null); + + /** Write operation. */ + public operation?: ("update"|"delete"|"transform"); + } + + /** Properties of a DocumentTransform. */ + interface IDocumentTransform { + + /** DocumentTransform document */ + document?: (string|null); + + /** DocumentTransform fieldTransforms */ + fieldTransforms?: (google.firestore.v1beta1.DocumentTransform.IFieldTransform[]|null); + } + + /** Represents a DocumentTransform. */ + class DocumentTransform implements IDocumentTransform { + + /** + * Constructs a new DocumentTransform. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IDocumentTransform); + + /** DocumentTransform document. */ + public document: string; + + /** DocumentTransform fieldTransforms. */ + public fieldTransforms: google.firestore.v1beta1.DocumentTransform.IFieldTransform[]; + } + + namespace DocumentTransform { + + /** Properties of a FieldTransform. */ + interface IFieldTransform { + + /** FieldTransform fieldPath */ + fieldPath?: (string|null); + + /** FieldTransform setToServerValue */ + setToServerValue?: (google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue|null); + + /** FieldTransform increment */ + increment?: (google.firestore.v1beta1.IValue|null); + + /** FieldTransform maximum */ + maximum?: (google.firestore.v1beta1.IValue|null); + + /** FieldTransform minimum */ + minimum?: (google.firestore.v1beta1.IValue|null); + + /** FieldTransform appendMissingElements */ + appendMissingElements?: (google.firestore.v1beta1.IArrayValue|null); + + /** FieldTransform removeAllFromArray */ + removeAllFromArray?: (google.firestore.v1beta1.IArrayValue|null); + } + + /** Represents a FieldTransform. */ + class FieldTransform implements IFieldTransform { + + /** + * Constructs a new FieldTransform. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.DocumentTransform.IFieldTransform); + + /** FieldTransform fieldPath. */ + public fieldPath: string; + + /** FieldTransform setToServerValue. */ + public setToServerValue: google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue; + + /** FieldTransform increment. */ + public increment?: (google.firestore.v1beta1.IValue|null); + + /** FieldTransform maximum. */ + public maximum?: (google.firestore.v1beta1.IValue|null); + + /** FieldTransform minimum. */ + public minimum?: (google.firestore.v1beta1.IValue|null); + + /** FieldTransform appendMissingElements. */ + public appendMissingElements?: (google.firestore.v1beta1.IArrayValue|null); + + /** FieldTransform removeAllFromArray. */ + public removeAllFromArray?: (google.firestore.v1beta1.IArrayValue|null); + + /** FieldTransform transformType. */ + public transformType?: ("setToServerValue"|"increment"|"maximum"|"minimum"|"appendMissingElements"|"removeAllFromArray"); + } + + namespace FieldTransform { + + /** ServerValue enum. */ + type ServerValue = + "SERVER_VALUE_UNSPECIFIED"| "REQUEST_TIME"; + } + } + + /** Properties of a WriteResult. */ + interface IWriteResult { + + /** WriteResult updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** WriteResult transformResults */ + transformResults?: (google.firestore.v1beta1.IValue[]|null); + } + + /** Represents a WriteResult. */ + class WriteResult implements IWriteResult { + + /** + * Constructs a new WriteResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IWriteResult); + + /** WriteResult updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** WriteResult transformResults. */ + public transformResults: google.firestore.v1beta1.IValue[]; + } + + /** Properties of a DocumentChange. */ + interface IDocumentChange { + + /** DocumentChange document */ + document?: (google.firestore.v1beta1.IDocument|null); + + /** DocumentChange targetIds */ + targetIds?: (number[]|null); + + /** DocumentChange removedTargetIds */ + removedTargetIds?: (number[]|null); + } + + /** Represents a DocumentChange. */ + class DocumentChange implements IDocumentChange { + + /** + * Constructs a new DocumentChange. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IDocumentChange); + + /** DocumentChange document. */ + public document?: (google.firestore.v1beta1.IDocument|null); + + /** DocumentChange targetIds. */ + public targetIds: number[]; + + /** DocumentChange removedTargetIds. */ + public removedTargetIds: number[]; + } + + /** Properties of a DocumentDelete. */ + interface IDocumentDelete { + + /** DocumentDelete document */ + document?: (string|null); + + /** DocumentDelete removedTargetIds */ + removedTargetIds?: (number[]|null); + + /** DocumentDelete readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a DocumentDelete. */ + class DocumentDelete implements IDocumentDelete { + + /** + * Constructs a new DocumentDelete. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IDocumentDelete); + + /** DocumentDelete document. */ + public document: string; + + /** DocumentDelete removedTargetIds. */ + public removedTargetIds: number[]; + + /** DocumentDelete readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + } + + /** Properties of a DocumentRemove. */ + interface IDocumentRemove { + + /** DocumentRemove document */ + document?: (string|null); + + /** DocumentRemove removedTargetIds */ + removedTargetIds?: (number[]|null); + + /** DocumentRemove readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a DocumentRemove. */ + class DocumentRemove implements IDocumentRemove { + + /** + * Constructs a new DocumentRemove. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IDocumentRemove); + + /** DocumentRemove document. */ + public document: string; + + /** DocumentRemove removedTargetIds. */ + public removedTargetIds: number[]; + + /** DocumentRemove readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + } + + /** Properties of an ExistenceFilter. */ + interface IExistenceFilter { + + /** ExistenceFilter targetId */ + targetId?: (number|null); + + /** ExistenceFilter count */ + count?: (number|null); + } + + /** Represents an ExistenceFilter. */ + class ExistenceFilter implements IExistenceFilter { + + /** + * Constructs a new ExistenceFilter. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IExistenceFilter); + + /** ExistenceFilter targetId. */ + public targetId: number; + + /** ExistenceFilter count. */ + public count: number; + } + } + } + + /** Namespace api. */ + namespace api { + + /** Properties of a Http. */ + interface IHttp { + + /** Http rules */ + rules?: (google.api.IHttpRule[]|null); + } + + /** Represents a Http. */ + class Http implements IHttp { + + /** + * Constructs a new Http. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IHttp); + + /** Http rules. */ + public rules: google.api.IHttpRule[]; + } + + /** Properties of a HttpRule. */ + interface IHttpRule { + + /** HttpRule get */ + get?: (string|null); + + /** HttpRule put */ + put?: (string|null); + + /** HttpRule post */ + post?: (string|null); + + /** HttpRule delete */ + "delete"?: (string|null); + + /** HttpRule patch */ + patch?: (string|null); + + /** HttpRule custom */ + custom?: (google.api.ICustomHttpPattern|null); + + /** HttpRule selector */ + selector?: (string|null); + + /** HttpRule body */ + body?: (string|null); + + /** HttpRule additionalBindings */ + additionalBindings?: (google.api.IHttpRule[]|null); + } + + /** Represents a HttpRule. */ + class HttpRule implements IHttpRule { + + /** + * Constructs a new HttpRule. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IHttpRule); + + /** HttpRule get. */ + public get: string; + + /** HttpRule put. */ + public put: string; + + /** HttpRule post. */ + public post: string; + + /** HttpRule delete. */ + public delete: string; + + /** HttpRule patch. */ + public patch: string; + + /** HttpRule custom. */ + public custom?: (google.api.ICustomHttpPattern|null); + + /** HttpRule selector. */ + public selector: string; + + /** HttpRule body. */ + public body: string; + + /** HttpRule additionalBindings. */ + public additionalBindings: google.api.IHttpRule[]; + + /** HttpRule pattern. */ + public pattern?: ("get"|"put"|"post"|"delete"|"patch"|"custom"); + } + + /** Properties of a CustomHttpPattern. */ + interface ICustomHttpPattern { + + /** CustomHttpPattern kind */ + kind?: (string|null); + + /** CustomHttpPattern path */ + path?: (string|null); + } + + /** Represents a CustomHttpPattern. */ + class CustomHttpPattern implements ICustomHttpPattern { + + /** + * Constructs a new CustomHttpPattern. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ICustomHttpPattern); + + /** CustomHttpPattern kind. */ + public kind: string; + + /** CustomHttpPattern path. */ + public path: string; + } + + /** FieldBehavior enum. */ + type FieldBehavior = + "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"; + + /** Properties of a ResourceDescriptor. */ + interface IResourceDescriptor { + + /** ResourceDescriptor type */ + type?: (string|null); + + /** ResourceDescriptor pattern */ + pattern?: (string[]|null); + + /** ResourceDescriptor nameField */ + nameField?: (string|null); + + /** ResourceDescriptor history */ + history?: (google.api.ResourceDescriptor.History|null); + + /** ResourceDescriptor plural */ + plural?: (string|null); + + /** ResourceDescriptor singular */ + singular?: (string|null); + } + + /** Represents a ResourceDescriptor. */ + class ResourceDescriptor implements IResourceDescriptor { + + /** + * Constructs a new ResourceDescriptor. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IResourceDescriptor); + + /** ResourceDescriptor type. */ + public type: string; + + /** ResourceDescriptor pattern. */ + public pattern: string[]; + + /** ResourceDescriptor nameField. */ + public nameField: string; + + /** ResourceDescriptor history. */ + public history: google.api.ResourceDescriptor.History; + + /** ResourceDescriptor plural. */ + public plural: string; + + /** ResourceDescriptor singular. */ + public singular: string; + } + + namespace ResourceDescriptor { + + /** History enum. */ + type History = + "HISTORY_UNSPECIFIED"| "ORIGINALLY_SINGLE_PATTERN"| "FUTURE_MULTI_PATTERN"; + } + + /** Properties of a ResourceReference. */ + interface IResourceReference { + + /** ResourceReference type */ + type?: (string|null); + + /** ResourceReference childType */ + childType?: (string|null); + } + + /** Represents a ResourceReference. */ + class ResourceReference implements IResourceReference { + + /** + * Constructs a new ResourceReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IResourceReference); + + /** ResourceReference type. */ + public type: string; + + /** ResourceReference childType. */ + public childType: string; + } + } + + /** Namespace type. */ + namespace type { + + /** Properties of a LatLng. */ + interface ILatLng { + + /** LatLng latitude */ + latitude?: (number|null); + + /** LatLng longitude */ + longitude?: (number|null); + } + + /** Represents a LatLng. */ + class LatLng implements ILatLng { + + /** + * Constructs a new LatLng. + * @param [properties] Properties to set + */ + constructor(properties?: google.type.ILatLng); + + /** LatLng latitude. */ + public latitude: number; + + /** LatLng longitude. */ + public longitude: number; + } + } + + /** Namespace rpc. */ + namespace rpc { + + /** Properties of a Status. */ + interface IStatus { + + /** Status code */ + code?: (number|null); + + /** Status message */ + message?: (string|null); + + /** Status details */ + details?: (google.protobuf.IAny[]|null); + } + + /** Represents a Status. */ + class Status implements IStatus { + + /** + * Constructs a new Status. + * @param [properties] Properties to set + */ + constructor(properties?: google.rpc.IStatus); + + /** Status code. */ + public code: number; + + /** Status message. */ + public message: string; + + /** Status details. */ + public details: google.protobuf.IAny[]; + } + } + + /** Namespace longrunning. */ + namespace longrunning { + + /** Represents an Operations */ + class Operations extends $protobuf.rpc.Service { + + /** + * Constructs a new Operations service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Calls ListOperations. + * @param request ListOperationsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListOperationsResponse + */ + public listOperations(request: google.longrunning.IListOperationsRequest, callback: google.longrunning.Operations.ListOperationsCallback): void; + + /** + * Calls ListOperations. + * @param request ListOperationsRequest message or plain object + * @returns Promise + */ + public listOperations(request: google.longrunning.IListOperationsRequest): Promise; + + /** + * Calls GetOperation. + * @param request GetOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public getOperation(request: google.longrunning.IGetOperationRequest, callback: google.longrunning.Operations.GetOperationCallback): void; + + /** + * Calls GetOperation. + * @param request GetOperationRequest message or plain object + * @returns Promise + */ + public getOperation(request: google.longrunning.IGetOperationRequest): Promise; + + /** + * Calls DeleteOperation. + * @param request DeleteOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteOperation(request: google.longrunning.IDeleteOperationRequest, callback: google.longrunning.Operations.DeleteOperationCallback): void; + + /** + * Calls DeleteOperation. + * @param request DeleteOperationRequest message or plain object + * @returns Promise + */ + public deleteOperation(request: google.longrunning.IDeleteOperationRequest): Promise; + + /** + * Calls CancelOperation. + * @param request CancelOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public cancelOperation(request: google.longrunning.ICancelOperationRequest, callback: google.longrunning.Operations.CancelOperationCallback): void; + + /** + * Calls CancelOperation. + * @param request CancelOperationRequest message or plain object + * @returns Promise + */ + public cancelOperation(request: google.longrunning.ICancelOperationRequest): Promise; + + /** + * Calls WaitOperation. + * @param request WaitOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public waitOperation(request: google.longrunning.IWaitOperationRequest, callback: google.longrunning.Operations.WaitOperationCallback): void; + + /** + * Calls WaitOperation. + * @param request WaitOperationRequest message or plain object + * @returns Promise + */ + public waitOperation(request: google.longrunning.IWaitOperationRequest): Promise; + } + + namespace Operations { + + /** + * Callback as used by {@link google.longrunning.Operations#listOperations}. + * @param error Error, if any + * @param [response] ListOperationsResponse + */ + type ListOperationsCallback = (error: (Error|null), response?: google.longrunning.ListOperationsResponse) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#getOperation}. + * @param error Error, if any + * @param [response] Operation + */ + type GetOperationCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#deleteOperation}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteOperationCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#cancelOperation}. + * @param error Error, if any + * @param [response] Empty + */ + type CancelOperationCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#waitOperation}. + * @param error Error, if any + * @param [response] Operation + */ + type WaitOperationCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of an Operation. */ + interface IOperation { + + /** Operation name */ + name?: (string|null); + + /** Operation metadata */ + metadata?: (google.protobuf.IAny|null); + + /** Operation done */ + done?: (boolean|null); + + /** Operation error */ + error?: (google.rpc.IStatus|null); + + /** Operation response */ + response?: (google.protobuf.IAny|null); + } + + /** Represents an Operation. */ + class Operation implements IOperation { + + /** + * Constructs a new Operation. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IOperation); + + /** Operation name. */ + public name: string; + + /** Operation metadata. */ + public metadata?: (google.protobuf.IAny|null); + + /** Operation done. */ + public done: boolean; + + /** Operation error. */ + public error?: (google.rpc.IStatus|null); + + /** Operation response. */ + public response?: (google.protobuf.IAny|null); + + /** Operation result. */ + public result?: ("error"|"response"); + } + + /** Properties of a GetOperationRequest. */ + interface IGetOperationRequest { + + /** GetOperationRequest name */ + name?: (string|null); + } + + /** Represents a GetOperationRequest. */ + class GetOperationRequest implements IGetOperationRequest { + + /** + * Constructs a new GetOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IGetOperationRequest); + + /** GetOperationRequest name. */ + public name: string; + } + + /** Properties of a ListOperationsRequest. */ + interface IListOperationsRequest { + + /** ListOperationsRequest name */ + name?: (string|null); + + /** ListOperationsRequest filter */ + filter?: (string|null); + + /** ListOperationsRequest pageSize */ + pageSize?: (number|null); + + /** ListOperationsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListOperationsRequest. */ + class ListOperationsRequest implements IListOperationsRequest { + + /** + * Constructs a new ListOperationsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IListOperationsRequest); + + /** ListOperationsRequest name. */ + public name: string; + + /** ListOperationsRequest filter. */ + public filter: string; + + /** ListOperationsRequest pageSize. */ + public pageSize: number; + + /** ListOperationsRequest pageToken. */ + public pageToken: string; + } + + /** Properties of a ListOperationsResponse. */ + interface IListOperationsResponse { + + /** ListOperationsResponse operations */ + operations?: (google.longrunning.IOperation[]|null); + + /** ListOperationsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListOperationsResponse. */ + class ListOperationsResponse implements IListOperationsResponse { + + /** + * Constructs a new ListOperationsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IListOperationsResponse); + + /** ListOperationsResponse operations. */ + public operations: google.longrunning.IOperation[]; + + /** ListOperationsResponse nextPageToken. */ + public nextPageToken: string; + } + + /** Properties of a CancelOperationRequest. */ + interface ICancelOperationRequest { + + /** CancelOperationRequest name */ + name?: (string|null); + } + + /** Represents a CancelOperationRequest. */ + class CancelOperationRequest implements ICancelOperationRequest { + + /** + * Constructs a new CancelOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.ICancelOperationRequest); + + /** CancelOperationRequest name. */ + public name: string; + } + + /** Properties of a DeleteOperationRequest. */ + interface IDeleteOperationRequest { + + /** DeleteOperationRequest name */ + name?: (string|null); + } + + /** Represents a DeleteOperationRequest. */ + class DeleteOperationRequest implements IDeleteOperationRequest { + + /** + * Constructs a new DeleteOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IDeleteOperationRequest); + + /** DeleteOperationRequest name. */ + public name: string; + } + + /** Properties of a WaitOperationRequest. */ + interface IWaitOperationRequest { + + /** WaitOperationRequest name */ + name?: (string|null); + + /** WaitOperationRequest timeout */ + timeout?: (google.protobuf.IDuration|null); + } + + /** Represents a WaitOperationRequest. */ + class WaitOperationRequest implements IWaitOperationRequest { + + /** + * Constructs a new WaitOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IWaitOperationRequest); + + /** WaitOperationRequest name. */ + public name: string; + + /** WaitOperationRequest timeout. */ + public timeout?: (google.protobuf.IDuration|null); + } + + /** Properties of an OperationInfo. */ + interface IOperationInfo { + + /** OperationInfo responseType */ + responseType?: (string|null); + + /** OperationInfo metadataType */ + metadataType?: (string|null); + } + + /** Represents an OperationInfo. */ + class OperationInfo implements IOperationInfo { + + /** + * Constructs a new OperationInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IOperationInfo); + + /** OperationInfo responseType. */ + public responseType: string; + + /** OperationInfo metadataType. */ + public metadataType: string; + } + } +} diff --git a/dev/protos/firestore_v1beta1_proto_api.js b/dev/protos/firestore_v1beta1_proto_api.js new file mode 100644 index 000000000..1c34a763c --- /dev/null +++ b/dev/protos/firestore_v1beta1_proto_api.js @@ -0,0 +1,7431 @@ +/*! + * Copyright 2019 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. + */ + +// Common aliases +var $util = $protobuf.util; + +// Exported root namespace +var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); + +$root.google = (function() { + + /** + * Namespace google. + * @exports google + * @namespace + */ + var google = {}; + + google.protobuf = (function() { + + /** + * Namespace protobuf. + * @memberof google + * @namespace + */ + var protobuf = {}; + + protobuf.Timestamp = (function() { + + /** + * Properties of a Timestamp. + * @memberof google.protobuf + * @interface ITimestamp + * @property {number|null} [seconds] Timestamp seconds + * @property {number|null} [nanos] Timestamp nanos + */ + + /** + * Constructs a new Timestamp. + * @memberof google.protobuf + * @classdesc Represents a Timestamp. + * @implements ITimestamp + * @constructor + * @param {google.protobuf.ITimestamp=} [properties] Properties to set + */ + function Timestamp(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Timestamp seconds. + * @member {number} seconds + * @memberof google.protobuf.Timestamp + * @instance + */ + Timestamp.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Timestamp nanos. + * @member {number} nanos + * @memberof google.protobuf.Timestamp + * @instance + */ + Timestamp.prototype.nanos = 0; + + return Timestamp; + })(); + + protobuf.FileDescriptorSet = (function() { + + /** + * Properties of a FileDescriptorSet. + * @memberof google.protobuf + * @interface IFileDescriptorSet + * @property {Array.|null} [file] FileDescriptorSet file + */ + + /** + * Constructs a new FileDescriptorSet. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorSet. + * @implements IFileDescriptorSet + * @constructor + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + */ + function FileDescriptorSet(properties) { + this.file = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FileDescriptorSet file. + * @member {Array.} file + * @memberof google.protobuf.FileDescriptorSet + * @instance + */ + FileDescriptorSet.prototype.file = $util.emptyArray; + + return FileDescriptorSet; + })(); + + protobuf.FileDescriptorProto = (function() { + + /** + * Properties of a FileDescriptorProto. + * @memberof google.protobuf + * @interface IFileDescriptorProto + * @property {string|null} [name] FileDescriptorProto name + * @property {string|null} ["package"] FileDescriptorProto package + * @property {Array.|null} [dependency] FileDescriptorProto dependency + * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency + * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [messageType] FileDescriptorProto messageType + * @property {Array.|null} [enumType] FileDescriptorProto enumType + * @property {Array.|null} [service] FileDescriptorProto service + * @property {Array.|null} [extension] FileDescriptorProto extension + * @property {google.protobuf.IFileOptions|null} [options] FileDescriptorProto options + * @property {google.protobuf.ISourceCodeInfo|null} [sourceCodeInfo] FileDescriptorProto sourceCodeInfo + * @property {string|null} [syntax] FileDescriptorProto syntax + */ + + /** + * Constructs a new FileDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorProto. + * @implements IFileDescriptorProto + * @constructor + * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set + */ + function FileDescriptorProto(properties) { + this.dependency = []; + this.publicDependency = []; + this.weakDependency = []; + this.messageType = []; + this.enumType = []; + this.service = []; + this.extension = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FileDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.name = ""; + + /** + * FileDescriptorProto package. + * @member {string} package + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype["package"] = ""; + + /** + * FileDescriptorProto dependency. + * @member {Array.} dependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.dependency = $util.emptyArray; + + /** + * FileDescriptorProto publicDependency. + * @member {Array.} publicDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.publicDependency = $util.emptyArray; + + /** + * FileDescriptorProto weakDependency. + * @member {Array.} weakDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + + /** + * FileDescriptorProto messageType. + * @member {Array.} messageType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.messageType = $util.emptyArray; + + /** + * FileDescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.enumType = $util.emptyArray; + + /** + * FileDescriptorProto service. + * @member {Array.} service + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.service = $util.emptyArray; + + /** + * FileDescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.extension = $util.emptyArray; + + /** + * FileDescriptorProto options. + * @member {google.protobuf.IFileOptions|null|undefined} options + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.options = null; + + /** + * FileDescriptorProto sourceCodeInfo. + * @member {google.protobuf.ISourceCodeInfo|null|undefined} sourceCodeInfo + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.sourceCodeInfo = null; + + /** + * FileDescriptorProto syntax. + * @member {string} syntax + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.syntax = ""; + + return FileDescriptorProto; + })(); + + protobuf.DescriptorProto = (function() { + + /** + * Properties of a DescriptorProto. + * @memberof google.protobuf + * @interface IDescriptorProto + * @property {string|null} [name] DescriptorProto name + * @property {Array.|null} [field] DescriptorProto field + * @property {Array.|null} [extension] DescriptorProto extension + * @property {Array.|null} [nestedType] DescriptorProto nestedType + * @property {Array.|null} [enumType] DescriptorProto enumType + * @property {Array.|null} [extensionRange] DescriptorProto extensionRange + * @property {Array.|null} [oneofDecl] DescriptorProto oneofDecl + * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options + * @property {Array.|null} [reservedRange] DescriptorProto reservedRange + * @property {Array.|null} [reservedName] DescriptorProto reservedName + */ + + /** + * Constructs a new DescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a DescriptorProto. + * @implements IDescriptorProto + * @constructor + * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set + */ + function DescriptorProto(properties) { + this.field = []; + this.extension = []; + this.nestedType = []; + this.enumType = []; + this.extensionRange = []; + this.oneofDecl = []; + this.reservedRange = []; + this.reservedName = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DescriptorProto name. + * @member {string} name + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.name = ""; + + /** + * DescriptorProto field. + * @member {Array.} field + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.field = $util.emptyArray; + + /** + * DescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extension = $util.emptyArray; + + /** + * DescriptorProto nestedType. + * @member {Array.} nestedType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.nestedType = $util.emptyArray; + + /** + * DescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.enumType = $util.emptyArray; + + /** + * DescriptorProto extensionRange. + * @member {Array.} extensionRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extensionRange = $util.emptyArray; + + /** + * DescriptorProto oneofDecl. + * @member {Array.} oneofDecl + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.oneofDecl = $util.emptyArray; + + /** + * DescriptorProto options. + * @member {google.protobuf.IMessageOptions|null|undefined} options + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.options = null; + + /** + * DescriptorProto reservedRange. + * @member {Array.} reservedRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedRange = $util.emptyArray; + + /** + * DescriptorProto reservedName. + * @member {Array.} reservedName + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedName = $util.emptyArray; + + DescriptorProto.ExtensionRange = (function() { + + /** + * Properties of an ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @interface IExtensionRange + * @property {number|null} [start] ExtensionRange start + * @property {number|null} [end] ExtensionRange end + */ + + /** + * Constructs a new ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents an ExtensionRange. + * @implements IExtensionRange + * @constructor + * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set + */ + function ExtensionRange(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExtensionRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.start = 0; + + /** + * ExtensionRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.end = 0; + + return ExtensionRange; + })(); + + DescriptorProto.ReservedRange = (function() { + + /** + * Properties of a ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @interface IReservedRange + * @property {number|null} [start] ReservedRange start + * @property {number|null} [end] ReservedRange end + */ + + /** + * Constructs a new ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents a ReservedRange. + * @implements IReservedRange + * @constructor + * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set + */ + function ReservedRange(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReservedRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.start = 0; + + /** + * ReservedRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.end = 0; + + return ReservedRange; + })(); + + return DescriptorProto; + })(); + + protobuf.FieldDescriptorProto = (function() { + + /** + * Properties of a FieldDescriptorProto. + * @memberof google.protobuf + * @interface IFieldDescriptorProto + * @property {string|null} [name] FieldDescriptorProto name + * @property {number|null} [number] FieldDescriptorProto number + * @property {google.protobuf.FieldDescriptorProto.Label|null} [label] FieldDescriptorProto label + * @property {google.protobuf.FieldDescriptorProto.Type|null} [type] FieldDescriptorProto type + * @property {string|null} [typeName] FieldDescriptorProto typeName + * @property {string|null} [extendee] FieldDescriptorProto extendee + * @property {string|null} [defaultValue] FieldDescriptorProto defaultValue + * @property {number|null} [oneofIndex] FieldDescriptorProto oneofIndex + * @property {string|null} [jsonName] FieldDescriptorProto jsonName + * @property {google.protobuf.IFieldOptions|null} [options] FieldDescriptorProto options + */ + + /** + * Constructs a new FieldDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FieldDescriptorProto. + * @implements IFieldDescriptorProto + * @constructor + * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set + */ + function FieldDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.name = ""; + + /** + * FieldDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.number = 0; + + /** + * FieldDescriptorProto label. + * @member {google.protobuf.FieldDescriptorProto.Label} label + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.label = 1; + + /** + * FieldDescriptorProto type. + * @member {google.protobuf.FieldDescriptorProto.Type} type + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.type = 1; + + /** + * FieldDescriptorProto typeName. + * @member {string} typeName + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.typeName = ""; + + /** + * FieldDescriptorProto extendee. + * @member {string} extendee + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.extendee = ""; + + /** + * FieldDescriptorProto defaultValue. + * @member {string} defaultValue + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.defaultValue = ""; + + /** + * FieldDescriptorProto oneofIndex. + * @member {number} oneofIndex + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.oneofIndex = 0; + + /** + * FieldDescriptorProto jsonName. + * @member {string} jsonName + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.jsonName = ""; + + /** + * FieldDescriptorProto options. + * @member {google.protobuf.IFieldOptions|null|undefined} options + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.options = null; + + /** + * Type enum. + * @name google.protobuf.FieldDescriptorProto.Type + * @enum {number} + * @property {string} TYPE_DOUBLE=TYPE_DOUBLE TYPE_DOUBLE value + * @property {string} TYPE_FLOAT=TYPE_FLOAT TYPE_FLOAT value + * @property {string} TYPE_INT64=TYPE_INT64 TYPE_INT64 value + * @property {string} TYPE_UINT64=TYPE_UINT64 TYPE_UINT64 value + * @property {string} TYPE_INT32=TYPE_INT32 TYPE_INT32 value + * @property {string} TYPE_FIXED64=TYPE_FIXED64 TYPE_FIXED64 value + * @property {string} TYPE_FIXED32=TYPE_FIXED32 TYPE_FIXED32 value + * @property {string} TYPE_BOOL=TYPE_BOOL TYPE_BOOL value + * @property {string} TYPE_STRING=TYPE_STRING TYPE_STRING value + * @property {string} TYPE_GROUP=TYPE_GROUP TYPE_GROUP value + * @property {string} TYPE_MESSAGE=TYPE_MESSAGE TYPE_MESSAGE value + * @property {string} TYPE_BYTES=TYPE_BYTES TYPE_BYTES value + * @property {string} TYPE_UINT32=TYPE_UINT32 TYPE_UINT32 value + * @property {string} TYPE_ENUM=TYPE_ENUM TYPE_ENUM value + * @property {string} TYPE_SFIXED32=TYPE_SFIXED32 TYPE_SFIXED32 value + * @property {string} TYPE_SFIXED64=TYPE_SFIXED64 TYPE_SFIXED64 value + * @property {string} TYPE_SINT32=TYPE_SINT32 TYPE_SINT32 value + * @property {string} TYPE_SINT64=TYPE_SINT64 TYPE_SINT64 value + */ + FieldDescriptorProto.Type = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "TYPE_DOUBLE"] = "TYPE_DOUBLE"; + values[valuesById[2] = "TYPE_FLOAT"] = "TYPE_FLOAT"; + values[valuesById[3] = "TYPE_INT64"] = "TYPE_INT64"; + values[valuesById[4] = "TYPE_UINT64"] = "TYPE_UINT64"; + values[valuesById[5] = "TYPE_INT32"] = "TYPE_INT32"; + values[valuesById[6] = "TYPE_FIXED64"] = "TYPE_FIXED64"; + values[valuesById[7] = "TYPE_FIXED32"] = "TYPE_FIXED32"; + values[valuesById[8] = "TYPE_BOOL"] = "TYPE_BOOL"; + values[valuesById[9] = "TYPE_STRING"] = "TYPE_STRING"; + values[valuesById[10] = "TYPE_GROUP"] = "TYPE_GROUP"; + values[valuesById[11] = "TYPE_MESSAGE"] = "TYPE_MESSAGE"; + values[valuesById[12] = "TYPE_BYTES"] = "TYPE_BYTES"; + values[valuesById[13] = "TYPE_UINT32"] = "TYPE_UINT32"; + values[valuesById[14] = "TYPE_ENUM"] = "TYPE_ENUM"; + values[valuesById[15] = "TYPE_SFIXED32"] = "TYPE_SFIXED32"; + values[valuesById[16] = "TYPE_SFIXED64"] = "TYPE_SFIXED64"; + values[valuesById[17] = "TYPE_SINT32"] = "TYPE_SINT32"; + values[valuesById[18] = "TYPE_SINT64"] = "TYPE_SINT64"; + return values; + })(); + + /** + * Label enum. + * @name google.protobuf.FieldDescriptorProto.Label + * @enum {number} + * @property {string} LABEL_OPTIONAL=LABEL_OPTIONAL LABEL_OPTIONAL value + * @property {string} LABEL_REQUIRED=LABEL_REQUIRED LABEL_REQUIRED value + * @property {string} LABEL_REPEATED=LABEL_REPEATED LABEL_REPEATED value + */ + FieldDescriptorProto.Label = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "LABEL_OPTIONAL"] = "LABEL_OPTIONAL"; + values[valuesById[2] = "LABEL_REQUIRED"] = "LABEL_REQUIRED"; + values[valuesById[3] = "LABEL_REPEATED"] = "LABEL_REPEATED"; + return values; + })(); + + return FieldDescriptorProto; + })(); + + protobuf.OneofDescriptorProto = (function() { + + /** + * Properties of an OneofDescriptorProto. + * @memberof google.protobuf + * @interface IOneofDescriptorProto + * @property {string|null} [name] OneofDescriptorProto name + * @property {google.protobuf.IOneofOptions|null} [options] OneofDescriptorProto options + */ + + /** + * Constructs a new OneofDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an OneofDescriptorProto. + * @implements IOneofDescriptorProto + * @constructor + * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set + */ + function OneofDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OneofDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.OneofDescriptorProto + * @instance + */ + OneofDescriptorProto.prototype.name = ""; + + /** + * OneofDescriptorProto options. + * @member {google.protobuf.IOneofOptions|null|undefined} options + * @memberof google.protobuf.OneofDescriptorProto + * @instance + */ + OneofDescriptorProto.prototype.options = null; + + return OneofDescriptorProto; + })(); + + protobuf.EnumDescriptorProto = (function() { + + /** + * Properties of an EnumDescriptorProto. + * @memberof google.protobuf + * @interface IEnumDescriptorProto + * @property {string|null} [name] EnumDescriptorProto name + * @property {Array.|null} [value] EnumDescriptorProto value + * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options + */ + + /** + * Constructs a new EnumDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumDescriptorProto. + * @implements IEnumDescriptorProto + * @constructor + * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set + */ + function EnumDescriptorProto(properties) { + this.value = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.name = ""; + + /** + * EnumDescriptorProto value. + * @member {Array.} value + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.value = $util.emptyArray; + + /** + * EnumDescriptorProto options. + * @member {google.protobuf.IEnumOptions|null|undefined} options + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.options = null; + + return EnumDescriptorProto; + })(); + + protobuf.EnumValueDescriptorProto = (function() { + + /** + * Properties of an EnumValueDescriptorProto. + * @memberof google.protobuf + * @interface IEnumValueDescriptorProto + * @property {string|null} [name] EnumValueDescriptorProto name + * @property {number|null} [number] EnumValueDescriptorProto number + * @property {google.protobuf.IEnumValueOptions|null} [options] EnumValueDescriptorProto options + */ + + /** + * Constructs a new EnumValueDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumValueDescriptorProto. + * @implements IEnumValueDescriptorProto + * @constructor + * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set + */ + function EnumValueDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumValueDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.name = ""; + + /** + * EnumValueDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.number = 0; + + /** + * EnumValueDescriptorProto options. + * @member {google.protobuf.IEnumValueOptions|null|undefined} options + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.options = null; + + return EnumValueDescriptorProto; + })(); + + protobuf.ServiceDescriptorProto = (function() { + + /** + * Properties of a ServiceDescriptorProto. + * @memberof google.protobuf + * @interface IServiceDescriptorProto + * @property {string|null} [name] ServiceDescriptorProto name + * @property {Array.|null} [method] ServiceDescriptorProto method + * @property {google.protobuf.IServiceOptions|null} [options] ServiceDescriptorProto options + */ + + /** + * Constructs a new ServiceDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a ServiceDescriptorProto. + * @implements IServiceDescriptorProto + * @constructor + * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set + */ + function ServiceDescriptorProto(properties) { + this.method = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ServiceDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.name = ""; + + /** + * ServiceDescriptorProto method. + * @member {Array.} method + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.method = $util.emptyArray; + + /** + * ServiceDescriptorProto options. + * @member {google.protobuf.IServiceOptions|null|undefined} options + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.options = null; + + return ServiceDescriptorProto; + })(); + + protobuf.MethodDescriptorProto = (function() { + + /** + * Properties of a MethodDescriptorProto. + * @memberof google.protobuf + * @interface IMethodDescriptorProto + * @property {string|null} [name] MethodDescriptorProto name + * @property {string|null} [inputType] MethodDescriptorProto inputType + * @property {string|null} [outputType] MethodDescriptorProto outputType + * @property {google.protobuf.IMethodOptions|null} [options] MethodDescriptorProto options + * @property {boolean|null} [clientStreaming] MethodDescriptorProto clientStreaming + * @property {boolean|null} [serverStreaming] MethodDescriptorProto serverStreaming + */ + + /** + * Constructs a new MethodDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a MethodDescriptorProto. + * @implements IMethodDescriptorProto + * @constructor + * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set + */ + function MethodDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MethodDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.name = ""; + + /** + * MethodDescriptorProto inputType. + * @member {string} inputType + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.inputType = ""; + + /** + * MethodDescriptorProto outputType. + * @member {string} outputType + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.outputType = ""; + + /** + * MethodDescriptorProto options. + * @member {google.protobuf.IMethodOptions|null|undefined} options + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.options = null; + + /** + * MethodDescriptorProto clientStreaming. + * @member {boolean} clientStreaming + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.clientStreaming = false; + + /** + * MethodDescriptorProto serverStreaming. + * @member {boolean} serverStreaming + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.serverStreaming = false; + + return MethodDescriptorProto; + })(); + + protobuf.FileOptions = (function() { + + /** + * Properties of a FileOptions. + * @memberof google.protobuf + * @interface IFileOptions + * @property {string|null} [javaPackage] FileOptions javaPackage + * @property {string|null} [javaOuterClassname] FileOptions javaOuterClassname + * @property {boolean|null} [javaMultipleFiles] FileOptions javaMultipleFiles + * @property {boolean|null} [javaGenerateEqualsAndHash] FileOptions javaGenerateEqualsAndHash + * @property {boolean|null} [javaStringCheckUtf8] FileOptions javaStringCheckUtf8 + * @property {google.protobuf.FileOptions.OptimizeMode|null} [optimizeFor] FileOptions optimizeFor + * @property {string|null} [goPackage] FileOptions goPackage + * @property {boolean|null} [ccGenericServices] FileOptions ccGenericServices + * @property {boolean|null} [javaGenericServices] FileOptions javaGenericServices + * @property {boolean|null} [pyGenericServices] FileOptions pyGenericServices + * @property {boolean|null} [deprecated] FileOptions deprecated + * @property {boolean|null} [ccEnableArenas] FileOptions ccEnableArenas + * @property {string|null} [objcClassPrefix] FileOptions objcClassPrefix + * @property {string|null} [csharpNamespace] FileOptions csharpNamespace + * @property {Array.|null} [uninterpretedOption] FileOptions uninterpretedOption + * @property {Array.|null} [".google.api.resourceDefinition"] FileOptions .google.api.resourceDefinition + */ + + /** + * Constructs a new FileOptions. + * @memberof google.protobuf + * @classdesc Represents a FileOptions. + * @implements IFileOptions + * @constructor + * @param {google.protobuf.IFileOptions=} [properties] Properties to set + */ + function FileOptions(properties) { + this.uninterpretedOption = []; + this[".google.api.resourceDefinition"] = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FileOptions javaPackage. + * @member {string} javaPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaPackage = ""; + + /** + * FileOptions javaOuterClassname. + * @member {string} javaOuterClassname + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaOuterClassname = ""; + + /** + * FileOptions javaMultipleFiles. + * @member {boolean} javaMultipleFiles + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaMultipleFiles = false; + + /** + * FileOptions javaGenerateEqualsAndHash. + * @member {boolean} javaGenerateEqualsAndHash + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaGenerateEqualsAndHash = false; + + /** + * FileOptions javaStringCheckUtf8. + * @member {boolean} javaStringCheckUtf8 + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaStringCheckUtf8 = false; + + /** + * FileOptions optimizeFor. + * @member {google.protobuf.FileOptions.OptimizeMode} optimizeFor + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.optimizeFor = 1; + + /** + * FileOptions goPackage. + * @member {string} goPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.goPackage = ""; + + /** + * FileOptions ccGenericServices. + * @member {boolean} ccGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.ccGenericServices = false; + + /** + * FileOptions javaGenericServices. + * @member {boolean} javaGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaGenericServices = false; + + /** + * FileOptions pyGenericServices. + * @member {boolean} pyGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.pyGenericServices = false; + + /** + * FileOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.deprecated = false; + + /** + * FileOptions ccEnableArenas. + * @member {boolean} ccEnableArenas + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.ccEnableArenas = false; + + /** + * FileOptions objcClassPrefix. + * @member {string} objcClassPrefix + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.objcClassPrefix = ""; + + /** + * FileOptions csharpNamespace. + * @member {string} csharpNamespace + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.csharpNamespace = ""; + + /** + * FileOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * FileOptions .google.api.resourceDefinition. + * @member {Array.} .google.api.resourceDefinition + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype[".google.api.resourceDefinition"] = $util.emptyArray; + + /** + * OptimizeMode enum. + * @name google.protobuf.FileOptions.OptimizeMode + * @enum {number} + * @property {string} SPEED=SPEED SPEED value + * @property {string} CODE_SIZE=CODE_SIZE CODE_SIZE value + * @property {string} LITE_RUNTIME=LITE_RUNTIME LITE_RUNTIME value + */ + FileOptions.OptimizeMode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "SPEED"] = "SPEED"; + values[valuesById[2] = "CODE_SIZE"] = "CODE_SIZE"; + values[valuesById[3] = "LITE_RUNTIME"] = "LITE_RUNTIME"; + return values; + })(); + + return FileOptions; + })(); + + protobuf.MessageOptions = (function() { + + /** + * Properties of a MessageOptions. + * @memberof google.protobuf + * @interface IMessageOptions + * @property {boolean|null} [messageSetWireFormat] MessageOptions messageSetWireFormat + * @property {boolean|null} [noStandardDescriptorAccessor] MessageOptions noStandardDescriptorAccessor + * @property {boolean|null} [deprecated] MessageOptions deprecated + * @property {boolean|null} [mapEntry] MessageOptions mapEntry + * @property {Array.|null} [uninterpretedOption] MessageOptions uninterpretedOption + * @property {google.api.IResourceDescriptor|null} [".google.api.resource"] MessageOptions .google.api.resource + */ + + /** + * Constructs a new MessageOptions. + * @memberof google.protobuf + * @classdesc Represents a MessageOptions. + * @implements IMessageOptions + * @constructor + * @param {google.protobuf.IMessageOptions=} [properties] Properties to set + */ + function MessageOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MessageOptions messageSetWireFormat. + * @member {boolean} messageSetWireFormat + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.messageSetWireFormat = false; + + /** + * MessageOptions noStandardDescriptorAccessor. + * @member {boolean} noStandardDescriptorAccessor + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.noStandardDescriptorAccessor = false; + + /** + * MessageOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.deprecated = false; + + /** + * MessageOptions mapEntry. + * @member {boolean} mapEntry + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.mapEntry = false; + + /** + * MessageOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * MessageOptions .google.api.resource. + * @member {google.api.IResourceDescriptor|null|undefined} .google.api.resource + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype[".google.api.resource"] = null; + + return MessageOptions; + })(); + + protobuf.FieldOptions = (function() { + + /** + * Properties of a FieldOptions. + * @memberof google.protobuf + * @interface IFieldOptions + * @property {google.protobuf.FieldOptions.CType|null} [ctype] FieldOptions ctype + * @property {boolean|null} [packed] FieldOptions packed + * @property {google.protobuf.FieldOptions.JSType|null} [jstype] FieldOptions jstype + * @property {boolean|null} [lazy] FieldOptions lazy + * @property {boolean|null} [deprecated] FieldOptions deprecated + * @property {boolean|null} [weak] FieldOptions weak + * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption + * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior + * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference + */ + + /** + * Constructs a new FieldOptions. + * @memberof google.protobuf + * @classdesc Represents a FieldOptions. + * @implements IFieldOptions + * @constructor + * @param {google.protobuf.IFieldOptions=} [properties] Properties to set + */ + function FieldOptions(properties) { + this.uninterpretedOption = []; + this[".google.api.fieldBehavior"] = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldOptions ctype. + * @member {google.protobuf.FieldOptions.CType} ctype + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.ctype = 0; + + /** + * FieldOptions packed. + * @member {boolean} packed + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.packed = false; + + /** + * FieldOptions jstype. + * @member {google.protobuf.FieldOptions.JSType} jstype + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.jstype = 0; + + /** + * FieldOptions lazy. + * @member {boolean} lazy + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.lazy = false; + + /** + * FieldOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.deprecated = false; + + /** + * FieldOptions weak. + * @member {boolean} weak + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.weak = false; + + /** + * FieldOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * FieldOptions .google.api.fieldBehavior. + * @member {Array.} .google.api.fieldBehavior + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype[".google.api.fieldBehavior"] = $util.emptyArray; + + /** + * FieldOptions .google.api.resourceReference. + * @member {google.api.IResourceReference|null|undefined} .google.api.resourceReference + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype[".google.api.resourceReference"] = null; + + /** + * CType enum. + * @name google.protobuf.FieldOptions.CType + * @enum {number} + * @property {string} STRING=STRING STRING value + * @property {string} CORD=CORD CORD value + * @property {string} STRING_PIECE=STRING_PIECE STRING_PIECE value + */ + FieldOptions.CType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STRING"] = "STRING"; + values[valuesById[1] = "CORD"] = "CORD"; + values[valuesById[2] = "STRING_PIECE"] = "STRING_PIECE"; + return values; + })(); + + /** + * JSType enum. + * @name google.protobuf.FieldOptions.JSType + * @enum {number} + * @property {string} JS_NORMAL=JS_NORMAL JS_NORMAL value + * @property {string} JS_STRING=JS_STRING JS_STRING value + * @property {string} JS_NUMBER=JS_NUMBER JS_NUMBER value + */ + FieldOptions.JSType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "JS_NORMAL"] = "JS_NORMAL"; + values[valuesById[1] = "JS_STRING"] = "JS_STRING"; + values[valuesById[2] = "JS_NUMBER"] = "JS_NUMBER"; + return values; + })(); + + return FieldOptions; + })(); + + protobuf.OneofOptions = (function() { + + /** + * Properties of an OneofOptions. + * @memberof google.protobuf + * @interface IOneofOptions + * @property {Array.|null} [uninterpretedOption] OneofOptions uninterpretedOption + */ + + /** + * Constructs a new OneofOptions. + * @memberof google.protobuf + * @classdesc Represents an OneofOptions. + * @implements IOneofOptions + * @constructor + * @param {google.protobuf.IOneofOptions=} [properties] Properties to set + */ + function OneofOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OneofOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.OneofOptions + * @instance + */ + OneofOptions.prototype.uninterpretedOption = $util.emptyArray; + + return OneofOptions; + })(); + + protobuf.EnumOptions = (function() { + + /** + * Properties of an EnumOptions. + * @memberof google.protobuf + * @interface IEnumOptions + * @property {boolean|null} [allowAlias] EnumOptions allowAlias + * @property {boolean|null} [deprecated] EnumOptions deprecated + * @property {Array.|null} [uninterpretedOption] EnumOptions uninterpretedOption + */ + + /** + * Constructs a new EnumOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumOptions. + * @implements IEnumOptions + * @constructor + * @param {google.protobuf.IEnumOptions=} [properties] Properties to set + */ + function EnumOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumOptions allowAlias. + * @member {boolean} allowAlias + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.allowAlias = false; + + /** + * EnumOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.deprecated = false; + + /** + * EnumOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.uninterpretedOption = $util.emptyArray; + + return EnumOptions; + })(); + + protobuf.EnumValueOptions = (function() { + + /** + * Properties of an EnumValueOptions. + * @memberof google.protobuf + * @interface IEnumValueOptions + * @property {boolean|null} [deprecated] EnumValueOptions deprecated + * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption + */ + + /** + * Constructs a new EnumValueOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumValueOptions. + * @implements IEnumValueOptions + * @constructor + * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set + */ + function EnumValueOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumValueOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.deprecated = false; + + /** + * EnumValueOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.uninterpretedOption = $util.emptyArray; + + return EnumValueOptions; + })(); + + protobuf.ServiceOptions = (function() { + + /** + * Properties of a ServiceOptions. + * @memberof google.protobuf + * @interface IServiceOptions + * @property {boolean|null} [deprecated] ServiceOptions deprecated + * @property {Array.|null} [uninterpretedOption] ServiceOptions uninterpretedOption + * @property {string|null} [".google.api.defaultHost"] ServiceOptions .google.api.defaultHost + * @property {string|null} [".google.api.oauthScopes"] ServiceOptions .google.api.oauthScopes + */ + + /** + * Constructs a new ServiceOptions. + * @memberof google.protobuf + * @classdesc Represents a ServiceOptions. + * @implements IServiceOptions + * @constructor + * @param {google.protobuf.IServiceOptions=} [properties] Properties to set + */ + function ServiceOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ServiceOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.deprecated = false; + + /** + * ServiceOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * ServiceOptions .google.api.defaultHost. + * @member {string} .google.api.defaultHost + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype[".google.api.defaultHost"] = ""; + + /** + * ServiceOptions .google.api.oauthScopes. + * @member {string} .google.api.oauthScopes + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype[".google.api.oauthScopes"] = ""; + + return ServiceOptions; + })(); + + protobuf.MethodOptions = (function() { + + /** + * Properties of a MethodOptions. + * @memberof google.protobuf + * @interface IMethodOptions + * @property {boolean|null} [deprecated] MethodOptions deprecated + * @property {Array.|null} [uninterpretedOption] MethodOptions uninterpretedOption + * @property {google.api.IHttpRule|null} [".google.api.http"] MethodOptions .google.api.http + * @property {Array.|null} [".google.api.methodSignature"] MethodOptions .google.api.methodSignature + * @property {google.longrunning.IOperationInfo|null} [".google.longrunning.operationInfo"] MethodOptions .google.longrunning.operationInfo + */ + + /** + * Constructs a new MethodOptions. + * @memberof google.protobuf + * @classdesc Represents a MethodOptions. + * @implements IMethodOptions + * @constructor + * @param {google.protobuf.IMethodOptions=} [properties] Properties to set + */ + function MethodOptions(properties) { + this.uninterpretedOption = []; + this[".google.api.methodSignature"] = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MethodOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.deprecated = false; + + /** + * MethodOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * MethodOptions .google.api.http. + * @member {google.api.IHttpRule|null|undefined} .google.api.http + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.api.http"] = null; + + /** + * MethodOptions .google.api.methodSignature. + * @member {Array.} .google.api.methodSignature + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.api.methodSignature"] = $util.emptyArray; + + /** + * MethodOptions .google.longrunning.operationInfo. + * @member {google.longrunning.IOperationInfo|null|undefined} .google.longrunning.operationInfo + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.longrunning.operationInfo"] = null; + + return MethodOptions; + })(); + + protobuf.UninterpretedOption = (function() { + + /** + * Properties of an UninterpretedOption. + * @memberof google.protobuf + * @interface IUninterpretedOption + * @property {Array.|null} [name] UninterpretedOption name + * @property {string|null} [identifierValue] UninterpretedOption identifierValue + * @property {number|null} [positiveIntValue] UninterpretedOption positiveIntValue + * @property {number|null} [negativeIntValue] UninterpretedOption negativeIntValue + * @property {number|null} [doubleValue] UninterpretedOption doubleValue + * @property {Uint8Array|null} [stringValue] UninterpretedOption stringValue + * @property {string|null} [aggregateValue] UninterpretedOption aggregateValue + */ + + /** + * Constructs a new UninterpretedOption. + * @memberof google.protobuf + * @classdesc Represents an UninterpretedOption. + * @implements IUninterpretedOption + * @constructor + * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set + */ + function UninterpretedOption(properties) { + this.name = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UninterpretedOption name. + * @member {Array.} name + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.name = $util.emptyArray; + + /** + * UninterpretedOption identifierValue. + * @member {string} identifierValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.identifierValue = ""; + + /** + * UninterpretedOption positiveIntValue. + * @member {number} positiveIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.positiveIntValue = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * UninterpretedOption negativeIntValue. + * @member {number} negativeIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.negativeIntValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * UninterpretedOption doubleValue. + * @member {number} doubleValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.doubleValue = 0; + + /** + * UninterpretedOption stringValue. + * @member {Uint8Array} stringValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.stringValue = $util.newBuffer([]); + + /** + * UninterpretedOption aggregateValue. + * @member {string} aggregateValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.aggregateValue = ""; + + UninterpretedOption.NamePart = (function() { + + /** + * Properties of a NamePart. + * @memberof google.protobuf.UninterpretedOption + * @interface INamePart + * @property {string} namePart NamePart namePart + * @property {boolean} isExtension NamePart isExtension + */ + + /** + * Constructs a new NamePart. + * @memberof google.protobuf.UninterpretedOption + * @classdesc Represents a NamePart. + * @implements INamePart + * @constructor + * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set + */ + function NamePart(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * NamePart namePart. + * @member {string} namePart + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.namePart = ""; + + /** + * NamePart isExtension. + * @member {boolean} isExtension + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.isExtension = false; + + return NamePart; + })(); + + return UninterpretedOption; + })(); + + protobuf.SourceCodeInfo = (function() { + + /** + * Properties of a SourceCodeInfo. + * @memberof google.protobuf + * @interface ISourceCodeInfo + * @property {Array.|null} [location] SourceCodeInfo location + */ + + /** + * Constructs a new SourceCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a SourceCodeInfo. + * @implements ISourceCodeInfo + * @constructor + * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set + */ + function SourceCodeInfo(properties) { + this.location = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SourceCodeInfo location. + * @member {Array.} location + * @memberof google.protobuf.SourceCodeInfo + * @instance + */ + SourceCodeInfo.prototype.location = $util.emptyArray; + + SourceCodeInfo.Location = (function() { + + /** + * Properties of a Location. + * @memberof google.protobuf.SourceCodeInfo + * @interface ILocation + * @property {Array.|null} [path] Location path + * @property {Array.|null} [span] Location span + * @property {string|null} [leadingComments] Location leadingComments + * @property {string|null} [trailingComments] Location trailingComments + * @property {Array.|null} [leadingDetachedComments] Location leadingDetachedComments + */ + + /** + * Constructs a new Location. + * @memberof google.protobuf.SourceCodeInfo + * @classdesc Represents a Location. + * @implements ILocation + * @constructor + * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set + */ + function Location(properties) { + this.path = []; + this.span = []; + this.leadingDetachedComments = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Location path. + * @member {Array.} path + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.path = $util.emptyArray; + + /** + * Location span. + * @member {Array.} span + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.span = $util.emptyArray; + + /** + * Location leadingComments. + * @member {string} leadingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingComments = ""; + + /** + * Location trailingComments. + * @member {string} trailingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.trailingComments = ""; + + /** + * Location leadingDetachedComments. + * @member {Array.} leadingDetachedComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingDetachedComments = $util.emptyArray; + + return Location; + })(); + + return SourceCodeInfo; + })(); + + protobuf.GeneratedCodeInfo = (function() { + + /** + * Properties of a GeneratedCodeInfo. + * @memberof google.protobuf + * @interface IGeneratedCodeInfo + * @property {Array.|null} [annotation] GeneratedCodeInfo annotation + */ + + /** + * Constructs a new GeneratedCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a GeneratedCodeInfo. + * @implements IGeneratedCodeInfo + * @constructor + * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set + */ + function GeneratedCodeInfo(properties) { + this.annotation = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GeneratedCodeInfo annotation. + * @member {Array.} annotation + * @memberof google.protobuf.GeneratedCodeInfo + * @instance + */ + GeneratedCodeInfo.prototype.annotation = $util.emptyArray; + + GeneratedCodeInfo.Annotation = (function() { + + /** + * Properties of an Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @interface IAnnotation + * @property {Array.|null} [path] Annotation path + * @property {string|null} [sourceFile] Annotation sourceFile + * @property {number|null} [begin] Annotation begin + * @property {number|null} [end] Annotation end + */ + + /** + * Constructs a new Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @classdesc Represents an Annotation. + * @implements IAnnotation + * @constructor + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set + */ + function Annotation(properties) { + this.path = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Annotation path. + * @member {Array.} path + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.path = $util.emptyArray; + + /** + * Annotation sourceFile. + * @member {string} sourceFile + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.sourceFile = ""; + + /** + * Annotation begin. + * @member {number} begin + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.begin = 0; + + /** + * Annotation end. + * @member {number} end + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.end = 0; + + return Annotation; + })(); + + return GeneratedCodeInfo; + })(); + + protobuf.Struct = (function() { + + /** + * Properties of a Struct. + * @memberof google.protobuf + * @interface IStruct + * @property {Object.|null} [fields] Struct fields + */ + + /** + * Constructs a new Struct. + * @memberof google.protobuf + * @classdesc Represents a Struct. + * @implements IStruct + * @constructor + * @param {google.protobuf.IStruct=} [properties] Properties to set + */ + function Struct(properties) { + this.fields = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Struct fields. + * @member {Object.} fields + * @memberof google.protobuf.Struct + * @instance + */ + Struct.prototype.fields = $util.emptyObject; + + return Struct; + })(); + + protobuf.Value = (function() { + + /** + * Properties of a Value. + * @memberof google.protobuf + * @interface IValue + * @property {google.protobuf.NullValue|null} [nullValue] Value nullValue + * @property {number|null} [numberValue] Value numberValue + * @property {string|null} [stringValue] Value stringValue + * @property {boolean|null} [boolValue] Value boolValue + * @property {google.protobuf.IStruct|null} [structValue] Value structValue + * @property {google.protobuf.IListValue|null} [listValue] Value listValue + */ + + /** + * Constructs a new Value. + * @memberof google.protobuf + * @classdesc Represents a Value. + * @implements IValue + * @constructor + * @param {google.protobuf.IValue=} [properties] Properties to set + */ + function Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Value nullValue. + * @member {google.protobuf.NullValue} nullValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.nullValue = 0; + + /** + * Value numberValue. + * @member {number} numberValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.numberValue = 0; + + /** + * Value stringValue. + * @member {string} stringValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.stringValue = ""; + + /** + * Value boolValue. + * @member {boolean} boolValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.boolValue = false; + + /** + * Value structValue. + * @member {google.protobuf.IStruct|null|undefined} structValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.structValue = null; + + /** + * Value listValue. + * @member {google.protobuf.IListValue|null|undefined} listValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.listValue = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Value kind. + * @member {"nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"|undefined} kind + * @memberof google.protobuf.Value + * @instance + */ + Object.defineProperty(Value.prototype, "kind", { + get: $util.oneOfGetter($oneOfFields = ["nullValue", "numberValue", "stringValue", "boolValue", "structValue", "listValue"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return Value; + })(); + + /** + * NullValue enum. + * @name google.protobuf.NullValue + * @enum {number} + * @property {string} NULL_VALUE=NULL_VALUE NULL_VALUE value + */ + protobuf.NullValue = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "NULL_VALUE"] = "NULL_VALUE"; + return values; + })(); + + protobuf.ListValue = (function() { + + /** + * Properties of a ListValue. + * @memberof google.protobuf + * @interface IListValue + * @property {Array.|null} [values] ListValue values + */ + + /** + * Constructs a new ListValue. + * @memberof google.protobuf + * @classdesc Represents a ListValue. + * @implements IListValue + * @constructor + * @param {google.protobuf.IListValue=} [properties] Properties to set + */ + function ListValue(properties) { + this.values = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListValue values. + * @member {Array.} values + * @memberof google.protobuf.ListValue + * @instance + */ + ListValue.prototype.values = $util.emptyArray; + + return ListValue; + })(); + + protobuf.Empty = (function() { + + /** + * Properties of an Empty. + * @memberof google.protobuf + * @interface IEmpty + */ + + /** + * Constructs a new Empty. + * @memberof google.protobuf + * @classdesc Represents an Empty. + * @implements IEmpty + * @constructor + * @param {google.protobuf.IEmpty=} [properties] Properties to set + */ + function Empty(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + return Empty; + })(); + + protobuf.DoubleValue = (function() { + + /** + * Properties of a DoubleValue. + * @memberof google.protobuf + * @interface IDoubleValue + * @property {number|null} [value] DoubleValue value + */ + + /** + * Constructs a new DoubleValue. + * @memberof google.protobuf + * @classdesc Represents a DoubleValue. + * @implements IDoubleValue + * @constructor + * @param {google.protobuf.IDoubleValue=} [properties] Properties to set + */ + function DoubleValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DoubleValue value. + * @member {number} value + * @memberof google.protobuf.DoubleValue + * @instance + */ + DoubleValue.prototype.value = 0; + + return DoubleValue; + })(); + + protobuf.FloatValue = (function() { + + /** + * Properties of a FloatValue. + * @memberof google.protobuf + * @interface IFloatValue + * @property {number|null} [value] FloatValue value + */ + + /** + * Constructs a new FloatValue. + * @memberof google.protobuf + * @classdesc Represents a FloatValue. + * @implements IFloatValue + * @constructor + * @param {google.protobuf.IFloatValue=} [properties] Properties to set + */ + function FloatValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FloatValue value. + * @member {number} value + * @memberof google.protobuf.FloatValue + * @instance + */ + FloatValue.prototype.value = 0; + + return FloatValue; + })(); + + protobuf.Int64Value = (function() { + + /** + * Properties of an Int64Value. + * @memberof google.protobuf + * @interface IInt64Value + * @property {number|null} [value] Int64Value value + */ + + /** + * Constructs a new Int64Value. + * @memberof google.protobuf + * @classdesc Represents an Int64Value. + * @implements IInt64Value + * @constructor + * @param {google.protobuf.IInt64Value=} [properties] Properties to set + */ + function Int64Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Int64Value value. + * @member {number} value + * @memberof google.protobuf.Int64Value + * @instance + */ + Int64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + return Int64Value; + })(); + + protobuf.UInt64Value = (function() { + + /** + * Properties of a UInt64Value. + * @memberof google.protobuf + * @interface IUInt64Value + * @property {number|null} [value] UInt64Value value + */ + + /** + * Constructs a new UInt64Value. + * @memberof google.protobuf + * @classdesc Represents a UInt64Value. + * @implements IUInt64Value + * @constructor + * @param {google.protobuf.IUInt64Value=} [properties] Properties to set + */ + function UInt64Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UInt64Value value. + * @member {number} value + * @memberof google.protobuf.UInt64Value + * @instance + */ + UInt64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + return UInt64Value; + })(); + + protobuf.Int32Value = (function() { + + /** + * Properties of an Int32Value. + * @memberof google.protobuf + * @interface IInt32Value + * @property {number|null} [value] Int32Value value + */ + + /** + * Constructs a new Int32Value. + * @memberof google.protobuf + * @classdesc Represents an Int32Value. + * @implements IInt32Value + * @constructor + * @param {google.protobuf.IInt32Value=} [properties] Properties to set + */ + function Int32Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Int32Value value. + * @member {number} value + * @memberof google.protobuf.Int32Value + * @instance + */ + Int32Value.prototype.value = 0; + + return Int32Value; + })(); + + protobuf.UInt32Value = (function() { + + /** + * Properties of a UInt32Value. + * @memberof google.protobuf + * @interface IUInt32Value + * @property {number|null} [value] UInt32Value value + */ + + /** + * Constructs a new UInt32Value. + * @memberof google.protobuf + * @classdesc Represents a UInt32Value. + * @implements IUInt32Value + * @constructor + * @param {google.protobuf.IUInt32Value=} [properties] Properties to set + */ + function UInt32Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UInt32Value value. + * @member {number} value + * @memberof google.protobuf.UInt32Value + * @instance + */ + UInt32Value.prototype.value = 0; + + return UInt32Value; + })(); + + protobuf.BoolValue = (function() { + + /** + * Properties of a BoolValue. + * @memberof google.protobuf + * @interface IBoolValue + * @property {boolean|null} [value] BoolValue value + */ + + /** + * Constructs a new BoolValue. + * @memberof google.protobuf + * @classdesc Represents a BoolValue. + * @implements IBoolValue + * @constructor + * @param {google.protobuf.IBoolValue=} [properties] Properties to set + */ + function BoolValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BoolValue value. + * @member {boolean} value + * @memberof google.protobuf.BoolValue + * @instance + */ + BoolValue.prototype.value = false; + + return BoolValue; + })(); + + protobuf.StringValue = (function() { + + /** + * Properties of a StringValue. + * @memberof google.protobuf + * @interface IStringValue + * @property {string|null} [value] StringValue value + */ + + /** + * Constructs a new StringValue. + * @memberof google.protobuf + * @classdesc Represents a StringValue. + * @implements IStringValue + * @constructor + * @param {google.protobuf.IStringValue=} [properties] Properties to set + */ + function StringValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StringValue value. + * @member {string} value + * @memberof google.protobuf.StringValue + * @instance + */ + StringValue.prototype.value = ""; + + return StringValue; + })(); + + protobuf.BytesValue = (function() { + + /** + * Properties of a BytesValue. + * @memberof google.protobuf + * @interface IBytesValue + * @property {Uint8Array|null} [value] BytesValue value + */ + + /** + * Constructs a new BytesValue. + * @memberof google.protobuf + * @classdesc Represents a BytesValue. + * @implements IBytesValue + * @constructor + * @param {google.protobuf.IBytesValue=} [properties] Properties to set + */ + function BytesValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BytesValue value. + * @member {Uint8Array} value + * @memberof google.protobuf.BytesValue + * @instance + */ + BytesValue.prototype.value = $util.newBuffer([]); + + return BytesValue; + })(); + + protobuf.Any = (function() { + + /** + * Properties of an Any. + * @memberof google.protobuf + * @interface IAny + * @property {string|null} [type_url] Any type_url + * @property {Uint8Array|null} [value] Any value + */ + + /** + * Constructs a new Any. + * @memberof google.protobuf + * @classdesc Represents an Any. + * @implements IAny + * @constructor + * @param {google.protobuf.IAny=} [properties] Properties to set + */ + function Any(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Any type_url. + * @member {string} type_url + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.type_url = ""; + + /** + * Any value. + * @member {Uint8Array} value + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.value = $util.newBuffer([]); + + return Any; + })(); + + protobuf.FieldMask = (function() { + + /** + * Properties of a FieldMask. + * @memberof google.protobuf + * @interface IFieldMask + * @property {Array.|null} [paths] FieldMask paths + */ + + /** + * Constructs a new FieldMask. + * @memberof google.protobuf + * @classdesc Represents a FieldMask. + * @implements IFieldMask + * @constructor + * @param {google.protobuf.IFieldMask=} [properties] Properties to set + */ + function FieldMask(properties) { + this.paths = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldMask paths. + * @member {Array.} paths + * @memberof google.protobuf.FieldMask + * @instance + */ + FieldMask.prototype.paths = $util.emptyArray; + + return FieldMask; + })(); + + protobuf.Duration = (function() { + + /** + * Properties of a Duration. + * @memberof google.protobuf + * @interface IDuration + * @property {number|null} [seconds] Duration seconds + * @property {number|null} [nanos] Duration nanos + */ + + /** + * Constructs a new Duration. + * @memberof google.protobuf + * @classdesc Represents a Duration. + * @implements IDuration + * @constructor + * @param {google.protobuf.IDuration=} [properties] Properties to set + */ + function Duration(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Duration seconds. + * @member {number} seconds + * @memberof google.protobuf.Duration + * @instance + */ + Duration.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Duration nanos. + * @member {number} nanos + * @memberof google.protobuf.Duration + * @instance + */ + Duration.prototype.nanos = 0; + + return Duration; + })(); + + return protobuf; + })(); + + google.firestore = (function() { + + /** + * Namespace firestore. + * @memberof google + * @namespace + */ + var firestore = {}; + + firestore.v1beta1 = (function() { + + /** + * Namespace v1beta1. + * @memberof google.firestore + * @namespace + */ + var v1beta1 = {}; + + v1beta1.DocumentMask = (function() { + + /** + * Properties of a DocumentMask. + * @memberof google.firestore.v1beta1 + * @interface IDocumentMask + * @property {Array.|null} [fieldPaths] DocumentMask fieldPaths + */ + + /** + * Constructs a new DocumentMask. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a DocumentMask. + * @implements IDocumentMask + * @constructor + * @param {google.firestore.v1beta1.IDocumentMask=} [properties] Properties to set + */ + function DocumentMask(properties) { + this.fieldPaths = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentMask fieldPaths. + * @member {Array.} fieldPaths + * @memberof google.firestore.v1beta1.DocumentMask + * @instance + */ + DocumentMask.prototype.fieldPaths = $util.emptyArray; + + return DocumentMask; + })(); + + v1beta1.Precondition = (function() { + + /** + * Properties of a Precondition. + * @memberof google.firestore.v1beta1 + * @interface IPrecondition + * @property {boolean|null} [exists] Precondition exists + * @property {google.protobuf.ITimestamp|null} [updateTime] Precondition updateTime + */ + + /** + * Constructs a new Precondition. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a Precondition. + * @implements IPrecondition + * @constructor + * @param {google.firestore.v1beta1.IPrecondition=} [properties] Properties to set + */ + function Precondition(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Precondition exists. + * @member {boolean} exists + * @memberof google.firestore.v1beta1.Precondition + * @instance + */ + Precondition.prototype.exists = false; + + /** + * Precondition updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.firestore.v1beta1.Precondition + * @instance + */ + Precondition.prototype.updateTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Precondition conditionType. + * @member {"exists"|"updateTime"|undefined} conditionType + * @memberof google.firestore.v1beta1.Precondition + * @instance + */ + Object.defineProperty(Precondition.prototype, "conditionType", { + get: $util.oneOfGetter($oneOfFields = ["exists", "updateTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return Precondition; + })(); + + v1beta1.TransactionOptions = (function() { + + /** + * Properties of a TransactionOptions. + * @memberof google.firestore.v1beta1 + * @interface ITransactionOptions + * @property {google.firestore.v1beta1.TransactionOptions.IReadOnly|null} [readOnly] TransactionOptions readOnly + * @property {google.firestore.v1beta1.TransactionOptions.IReadWrite|null} [readWrite] TransactionOptions readWrite + */ + + /** + * Constructs a new TransactionOptions. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a TransactionOptions. + * @implements ITransactionOptions + * @constructor + * @param {google.firestore.v1beta1.ITransactionOptions=} [properties] Properties to set + */ + function TransactionOptions(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * TransactionOptions readOnly. + * @member {google.firestore.v1beta1.TransactionOptions.IReadOnly|null|undefined} readOnly + * @memberof google.firestore.v1beta1.TransactionOptions + * @instance + */ + TransactionOptions.prototype.readOnly = null; + + /** + * TransactionOptions readWrite. + * @member {google.firestore.v1beta1.TransactionOptions.IReadWrite|null|undefined} readWrite + * @memberof google.firestore.v1beta1.TransactionOptions + * @instance + */ + TransactionOptions.prototype.readWrite = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * TransactionOptions mode. + * @member {"readOnly"|"readWrite"|undefined} mode + * @memberof google.firestore.v1beta1.TransactionOptions + * @instance + */ + Object.defineProperty(TransactionOptions.prototype, "mode", { + get: $util.oneOfGetter($oneOfFields = ["readOnly", "readWrite"]), + set: $util.oneOfSetter($oneOfFields) + }); + + TransactionOptions.ReadWrite = (function() { + + /** + * Properties of a ReadWrite. + * @memberof google.firestore.v1beta1.TransactionOptions + * @interface IReadWrite + * @property {Uint8Array|null} [retryTransaction] ReadWrite retryTransaction + */ + + /** + * Constructs a new ReadWrite. + * @memberof google.firestore.v1beta1.TransactionOptions + * @classdesc Represents a ReadWrite. + * @implements IReadWrite + * @constructor + * @param {google.firestore.v1beta1.TransactionOptions.IReadWrite=} [properties] Properties to set + */ + function ReadWrite(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReadWrite retryTransaction. + * @member {Uint8Array} retryTransaction + * @memberof google.firestore.v1beta1.TransactionOptions.ReadWrite + * @instance + */ + ReadWrite.prototype.retryTransaction = $util.newBuffer([]); + + return ReadWrite; + })(); + + TransactionOptions.ReadOnly = (function() { + + /** + * Properties of a ReadOnly. + * @memberof google.firestore.v1beta1.TransactionOptions + * @interface IReadOnly + * @property {google.protobuf.ITimestamp|null} [readTime] ReadOnly readTime + */ + + /** + * Constructs a new ReadOnly. + * @memberof google.firestore.v1beta1.TransactionOptions + * @classdesc Represents a ReadOnly. + * @implements IReadOnly + * @constructor + * @param {google.firestore.v1beta1.TransactionOptions.IReadOnly=} [properties] Properties to set + */ + function ReadOnly(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReadOnly readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.TransactionOptions.ReadOnly + * @instance + */ + ReadOnly.prototype.readTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ReadOnly consistencySelector. + * @member {"readTime"|undefined} consistencySelector + * @memberof google.firestore.v1beta1.TransactionOptions.ReadOnly + * @instance + */ + Object.defineProperty(ReadOnly.prototype, "consistencySelector", { + get: $util.oneOfGetter($oneOfFields = ["readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return ReadOnly; + })(); + + return TransactionOptions; + })(); + + v1beta1.Document = (function() { + + /** + * Properties of a Document. + * @memberof google.firestore.v1beta1 + * @interface IDocument + * @property {string|null} [name] Document name + * @property {Object.|null} [fields] Document fields + * @property {google.protobuf.ITimestamp|null} [createTime] Document createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] Document updateTime + */ + + /** + * Constructs a new Document. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a Document. + * @implements IDocument + * @constructor + * @param {google.firestore.v1beta1.IDocument=} [properties] Properties to set + */ + function Document(properties) { + this.fields = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Document name. + * @member {string} name + * @memberof google.firestore.v1beta1.Document + * @instance + */ + Document.prototype.name = ""; + + /** + * Document fields. + * @member {Object.} fields + * @memberof google.firestore.v1beta1.Document + * @instance + */ + Document.prototype.fields = $util.emptyObject; + + /** + * Document createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.firestore.v1beta1.Document + * @instance + */ + Document.prototype.createTime = null; + + /** + * Document updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.firestore.v1beta1.Document + * @instance + */ + Document.prototype.updateTime = null; + + return Document; + })(); + + v1beta1.Value = (function() { + + /** + * Properties of a Value. + * @memberof google.firestore.v1beta1 + * @interface IValue + * @property {google.protobuf.NullValue|null} [nullValue] Value nullValue + * @property {boolean|null} [booleanValue] Value booleanValue + * @property {number|null} [integerValue] Value integerValue + * @property {number|null} [doubleValue] Value doubleValue + * @property {google.protobuf.ITimestamp|null} [timestampValue] Value timestampValue + * @property {string|null} [stringValue] Value stringValue + * @property {Uint8Array|null} [bytesValue] Value bytesValue + * @property {string|null} [referenceValue] Value referenceValue + * @property {google.type.ILatLng|null} [geoPointValue] Value geoPointValue + * @property {google.firestore.v1beta1.IArrayValue|null} [arrayValue] Value arrayValue + * @property {google.firestore.v1beta1.IMapValue|null} [mapValue] Value mapValue + */ + + /** + * Constructs a new Value. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a Value. + * @implements IValue + * @constructor + * @param {google.firestore.v1beta1.IValue=} [properties] Properties to set + */ + function Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Value nullValue. + * @member {google.protobuf.NullValue} nullValue + * @memberof google.firestore.v1beta1.Value + * @instance + */ + Value.prototype.nullValue = 0; + + /** + * Value booleanValue. + * @member {boolean} booleanValue + * @memberof google.firestore.v1beta1.Value + * @instance + */ + Value.prototype.booleanValue = false; + + /** + * Value integerValue. + * @member {number} integerValue + * @memberof google.firestore.v1beta1.Value + * @instance + */ + Value.prototype.integerValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Value doubleValue. + * @member {number} doubleValue + * @memberof google.firestore.v1beta1.Value + * @instance + */ + Value.prototype.doubleValue = 0; + + /** + * Value timestampValue. + * @member {google.protobuf.ITimestamp|null|undefined} timestampValue + * @memberof google.firestore.v1beta1.Value + * @instance + */ + Value.prototype.timestampValue = null; + + /** + * Value stringValue. + * @member {string} stringValue + * @memberof google.firestore.v1beta1.Value + * @instance + */ + Value.prototype.stringValue = ""; + + /** + * Value bytesValue. + * @member {Uint8Array} bytesValue + * @memberof google.firestore.v1beta1.Value + * @instance + */ + Value.prototype.bytesValue = $util.newBuffer([]); + + /** + * Value referenceValue. + * @member {string} referenceValue + * @memberof google.firestore.v1beta1.Value + * @instance + */ + Value.prototype.referenceValue = ""; + + /** + * Value geoPointValue. + * @member {google.type.ILatLng|null|undefined} geoPointValue + * @memberof google.firestore.v1beta1.Value + * @instance + */ + Value.prototype.geoPointValue = null; + + /** + * Value arrayValue. + * @member {google.firestore.v1beta1.IArrayValue|null|undefined} arrayValue + * @memberof google.firestore.v1beta1.Value + * @instance + */ + Value.prototype.arrayValue = null; + + /** + * Value mapValue. + * @member {google.firestore.v1beta1.IMapValue|null|undefined} mapValue + * @memberof google.firestore.v1beta1.Value + * @instance + */ + Value.prototype.mapValue = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Value valueType. + * @member {"nullValue"|"booleanValue"|"integerValue"|"doubleValue"|"timestampValue"|"stringValue"|"bytesValue"|"referenceValue"|"geoPointValue"|"arrayValue"|"mapValue"|undefined} valueType + * @memberof google.firestore.v1beta1.Value + * @instance + */ + Object.defineProperty(Value.prototype, "valueType", { + get: $util.oneOfGetter($oneOfFields = ["nullValue", "booleanValue", "integerValue", "doubleValue", "timestampValue", "stringValue", "bytesValue", "referenceValue", "geoPointValue", "arrayValue", "mapValue"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return Value; + })(); + + v1beta1.ArrayValue = (function() { + + /** + * Properties of an ArrayValue. + * @memberof google.firestore.v1beta1 + * @interface IArrayValue + * @property {Array.|null} [values] ArrayValue values + */ + + /** + * Constructs a new ArrayValue. + * @memberof google.firestore.v1beta1 + * @classdesc Represents an ArrayValue. + * @implements IArrayValue + * @constructor + * @param {google.firestore.v1beta1.IArrayValue=} [properties] Properties to set + */ + function ArrayValue(properties) { + this.values = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ArrayValue values. + * @member {Array.} values + * @memberof google.firestore.v1beta1.ArrayValue + * @instance + */ + ArrayValue.prototype.values = $util.emptyArray; + + return ArrayValue; + })(); + + v1beta1.MapValue = (function() { + + /** + * Properties of a MapValue. + * @memberof google.firestore.v1beta1 + * @interface IMapValue + * @property {Object.|null} [fields] MapValue fields + */ + + /** + * Constructs a new MapValue. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a MapValue. + * @implements IMapValue + * @constructor + * @param {google.firestore.v1beta1.IMapValue=} [properties] Properties to set + */ + function MapValue(properties) { + this.fields = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MapValue fields. + * @member {Object.} fields + * @memberof google.firestore.v1beta1.MapValue + * @instance + */ + MapValue.prototype.fields = $util.emptyObject; + + return MapValue; + })(); + + v1beta1.Firestore = (function() { + + /** + * Constructs a new Firestore service. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a Firestore + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function Firestore(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (Firestore.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Firestore; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#getDocument}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef GetDocumentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.Document} [response] Document + */ + + /** + * Calls GetDocument. + * @function getDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IGetDocumentRequest} request GetDocumentRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.GetDocumentCallback} callback Node-style callback called with the error, if any, and Document + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.getDocument = function getDocument(request, callback) { + return this.rpcCall(getDocument, $root.google.firestore.v1beta1.GetDocumentRequest, $root.google.firestore.v1beta1.Document, request, callback); + }, "name", { value: "GetDocument" }); + + /** + * Calls GetDocument. + * @function getDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IGetDocumentRequest} request GetDocumentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#listDocuments}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef ListDocumentsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.ListDocumentsResponse} [response] ListDocumentsResponse + */ + + /** + * Calls ListDocuments. + * @function listDocuments + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IListDocumentsRequest} request ListDocumentsRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.ListDocumentsCallback} callback Node-style callback called with the error, if any, and ListDocumentsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.listDocuments = function listDocuments(request, callback) { + return this.rpcCall(listDocuments, $root.google.firestore.v1beta1.ListDocumentsRequest, $root.google.firestore.v1beta1.ListDocumentsResponse, request, callback); + }, "name", { value: "ListDocuments" }); + + /** + * Calls ListDocuments. + * @function listDocuments + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IListDocumentsRequest} request ListDocumentsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#createDocument}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef CreateDocumentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.Document} [response] Document + */ + + /** + * Calls CreateDocument. + * @function createDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.CreateDocumentCallback} callback Node-style callback called with the error, if any, and Document + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.createDocument = function createDocument(request, callback) { + return this.rpcCall(createDocument, $root.google.firestore.v1beta1.CreateDocumentRequest, $root.google.firestore.v1beta1.Document, request, callback); + }, "name", { value: "CreateDocument" }); + + /** + * Calls CreateDocument. + * @function createDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#updateDocument}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef UpdateDocumentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.Document} [response] Document + */ + + /** + * Calls UpdateDocument. + * @function updateDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IUpdateDocumentRequest} request UpdateDocumentRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.UpdateDocumentCallback} callback Node-style callback called with the error, if any, and Document + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.updateDocument = function updateDocument(request, callback) { + return this.rpcCall(updateDocument, $root.google.firestore.v1beta1.UpdateDocumentRequest, $root.google.firestore.v1beta1.Document, request, callback); + }, "name", { value: "UpdateDocument" }); + + /** + * Calls UpdateDocument. + * @function updateDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IUpdateDocumentRequest} request UpdateDocumentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#deleteDocument}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef DeleteDocumentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteDocument. + * @function deleteDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IDeleteDocumentRequest} request DeleteDocumentRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.DeleteDocumentCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.deleteDocument = function deleteDocument(request, callback) { + return this.rpcCall(deleteDocument, $root.google.firestore.v1beta1.DeleteDocumentRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteDocument" }); + + /** + * Calls DeleteDocument. + * @function deleteDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IDeleteDocumentRequest} request DeleteDocumentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#batchGetDocuments}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef BatchGetDocumentsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.BatchGetDocumentsResponse} [response] BatchGetDocumentsResponse + */ + + /** + * Calls BatchGetDocuments. + * @function batchGetDocuments + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IBatchGetDocumentsRequest} request BatchGetDocumentsRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.BatchGetDocumentsCallback} callback Node-style callback called with the error, if any, and BatchGetDocumentsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.batchGetDocuments = function batchGetDocuments(request, callback) { + return this.rpcCall(batchGetDocuments, $root.google.firestore.v1beta1.BatchGetDocumentsRequest, $root.google.firestore.v1beta1.BatchGetDocumentsResponse, request, callback); + }, "name", { value: "BatchGetDocuments" }); + + /** + * Calls BatchGetDocuments. + * @function batchGetDocuments + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IBatchGetDocumentsRequest} request BatchGetDocumentsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#beginTransaction}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef BeginTransactionCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.BeginTransactionResponse} [response] BeginTransactionResponse + */ + + /** + * Calls BeginTransaction. + * @function beginTransaction + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IBeginTransactionRequest} request BeginTransactionRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.BeginTransactionCallback} callback Node-style callback called with the error, if any, and BeginTransactionResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.beginTransaction = function beginTransaction(request, callback) { + return this.rpcCall(beginTransaction, $root.google.firestore.v1beta1.BeginTransactionRequest, $root.google.firestore.v1beta1.BeginTransactionResponse, request, callback); + }, "name", { value: "BeginTransaction" }); + + /** + * Calls BeginTransaction. + * @function beginTransaction + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IBeginTransactionRequest} request BeginTransactionRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#commit}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef CommitCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.CommitResponse} [response] CommitResponse + */ + + /** + * Calls Commit. + * @function commit + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.ICommitRequest} request CommitRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.CommitCallback} callback Node-style callback called with the error, if any, and CommitResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.commit = function commit(request, callback) { + return this.rpcCall(commit, $root.google.firestore.v1beta1.CommitRequest, $root.google.firestore.v1beta1.CommitResponse, request, callback); + }, "name", { value: "Commit" }); + + /** + * Calls Commit. + * @function commit + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.ICommitRequest} request CommitRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#rollback}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef RollbackCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls Rollback. + * @function rollback + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IRollbackRequest} request RollbackRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.RollbackCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.rollback = function rollback(request, callback) { + return this.rpcCall(rollback, $root.google.firestore.v1beta1.RollbackRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "Rollback" }); + + /** + * Calls Rollback. + * @function rollback + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IRollbackRequest} request RollbackRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#runQuery}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef RunQueryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.RunQueryResponse} [response] RunQueryResponse + */ + + /** + * Calls RunQuery. + * @function runQuery + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IRunQueryRequest} request RunQueryRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.RunQueryCallback} callback Node-style callback called with the error, if any, and RunQueryResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.runQuery = function runQuery(request, callback) { + return this.rpcCall(runQuery, $root.google.firestore.v1beta1.RunQueryRequest, $root.google.firestore.v1beta1.RunQueryResponse, request, callback); + }, "name", { value: "RunQuery" }); + + /** + * Calls RunQuery. + * @function runQuery + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IRunQueryRequest} request RunQueryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#write}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef WriteCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.WriteResponse} [response] WriteResponse + */ + + /** + * Calls Write. + * @function write + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IWriteRequest} request WriteRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.WriteCallback} callback Node-style callback called with the error, if any, and WriteResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.write = function write(request, callback) { + return this.rpcCall(write, $root.google.firestore.v1beta1.WriteRequest, $root.google.firestore.v1beta1.WriteResponse, request, callback); + }, "name", { value: "Write" }); + + /** + * Calls Write. + * @function write + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IWriteRequest} request WriteRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#listen}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef ListenCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.ListenResponse} [response] ListenResponse + */ + + /** + * Calls Listen. + * @function listen + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IListenRequest} request ListenRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.ListenCallback} callback Node-style callback called with the error, if any, and ListenResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.listen = function listen(request, callback) { + return this.rpcCall(listen, $root.google.firestore.v1beta1.ListenRequest, $root.google.firestore.v1beta1.ListenResponse, request, callback); + }, "name", { value: "Listen" }); + + /** + * Calls Listen. + * @function listen + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IListenRequest} request ListenRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#listCollectionIds}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef ListCollectionIdsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.ListCollectionIdsResponse} [response] ListCollectionIdsResponse + */ + + /** + * Calls ListCollectionIds. + * @function listCollectionIds + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IListCollectionIdsRequest} request ListCollectionIdsRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.ListCollectionIdsCallback} callback Node-style callback called with the error, if any, and ListCollectionIdsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.listCollectionIds = function listCollectionIds(request, callback) { + return this.rpcCall(listCollectionIds, $root.google.firestore.v1beta1.ListCollectionIdsRequest, $root.google.firestore.v1beta1.ListCollectionIdsResponse, request, callback); + }, "name", { value: "ListCollectionIds" }); + + /** + * Calls ListCollectionIds. + * @function listCollectionIds + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IListCollectionIdsRequest} request ListCollectionIdsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return Firestore; + })(); + + v1beta1.GetDocumentRequest = (function() { + + /** + * Properties of a GetDocumentRequest. + * @memberof google.firestore.v1beta1 + * @interface IGetDocumentRequest + * @property {string|null} [name] GetDocumentRequest name + * @property {google.firestore.v1beta1.IDocumentMask|null} [mask] GetDocumentRequest mask + * @property {Uint8Array|null} [transaction] GetDocumentRequest transaction + * @property {google.protobuf.ITimestamp|null} [readTime] GetDocumentRequest readTime + */ + + /** + * Constructs a new GetDocumentRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a GetDocumentRequest. + * @implements IGetDocumentRequest + * @constructor + * @param {google.firestore.v1beta1.IGetDocumentRequest=} [properties] Properties to set + */ + function GetDocumentRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetDocumentRequest name. + * @member {string} name + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @instance + */ + GetDocumentRequest.prototype.name = ""; + + /** + * GetDocumentRequest mask. + * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} mask + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @instance + */ + GetDocumentRequest.prototype.mask = null; + + /** + * GetDocumentRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @instance + */ + GetDocumentRequest.prototype.transaction = $util.newBuffer([]); + + /** + * GetDocumentRequest readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @instance + */ + GetDocumentRequest.prototype.readTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetDocumentRequest consistencySelector. + * @member {"transaction"|"readTime"|undefined} consistencySelector + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @instance + */ + Object.defineProperty(GetDocumentRequest.prototype, "consistencySelector", { + get: $util.oneOfGetter($oneOfFields = ["transaction", "readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return GetDocumentRequest; + })(); + + v1beta1.ListDocumentsRequest = (function() { + + /** + * Properties of a ListDocumentsRequest. + * @memberof google.firestore.v1beta1 + * @interface IListDocumentsRequest + * @property {string|null} [parent] ListDocumentsRequest parent + * @property {string|null} [collectionId] ListDocumentsRequest collectionId + * @property {number|null} [pageSize] ListDocumentsRequest pageSize + * @property {string|null} [pageToken] ListDocumentsRequest pageToken + * @property {string|null} [orderBy] ListDocumentsRequest orderBy + * @property {google.firestore.v1beta1.IDocumentMask|null} [mask] ListDocumentsRequest mask + * @property {Uint8Array|null} [transaction] ListDocumentsRequest transaction + * @property {google.protobuf.ITimestamp|null} [readTime] ListDocumentsRequest readTime + * @property {boolean|null} [showMissing] ListDocumentsRequest showMissing + */ + + /** + * Constructs a new ListDocumentsRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a ListDocumentsRequest. + * @implements IListDocumentsRequest + * @constructor + * @param {google.firestore.v1beta1.IListDocumentsRequest=} [properties] Properties to set + */ + function ListDocumentsRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListDocumentsRequest parent. + * @member {string} parent + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.parent = ""; + + /** + * ListDocumentsRequest collectionId. + * @member {string} collectionId + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.collectionId = ""; + + /** + * ListDocumentsRequest pageSize. + * @member {number} pageSize + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.pageSize = 0; + + /** + * ListDocumentsRequest pageToken. + * @member {string} pageToken + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.pageToken = ""; + + /** + * ListDocumentsRequest orderBy. + * @member {string} orderBy + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.orderBy = ""; + + /** + * ListDocumentsRequest mask. + * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} mask + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.mask = null; + + /** + * ListDocumentsRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.transaction = $util.newBuffer([]); + + /** + * ListDocumentsRequest readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.readTime = null; + + /** + * ListDocumentsRequest showMissing. + * @member {boolean} showMissing + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.showMissing = false; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ListDocumentsRequest consistencySelector. + * @member {"transaction"|"readTime"|undefined} consistencySelector + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @instance + */ + Object.defineProperty(ListDocumentsRequest.prototype, "consistencySelector", { + get: $util.oneOfGetter($oneOfFields = ["transaction", "readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return ListDocumentsRequest; + })(); + + v1beta1.ListDocumentsResponse = (function() { + + /** + * Properties of a ListDocumentsResponse. + * @memberof google.firestore.v1beta1 + * @interface IListDocumentsResponse + * @property {Array.|null} [documents] ListDocumentsResponse documents + * @property {string|null} [nextPageToken] ListDocumentsResponse nextPageToken + */ + + /** + * Constructs a new ListDocumentsResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a ListDocumentsResponse. + * @implements IListDocumentsResponse + * @constructor + * @param {google.firestore.v1beta1.IListDocumentsResponse=} [properties] Properties to set + */ + function ListDocumentsResponse(properties) { + this.documents = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListDocumentsResponse documents. + * @member {Array.} documents + * @memberof google.firestore.v1beta1.ListDocumentsResponse + * @instance + */ + ListDocumentsResponse.prototype.documents = $util.emptyArray; + + /** + * ListDocumentsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.firestore.v1beta1.ListDocumentsResponse + * @instance + */ + ListDocumentsResponse.prototype.nextPageToken = ""; + + return ListDocumentsResponse; + })(); + + v1beta1.CreateDocumentRequest = (function() { + + /** + * Properties of a CreateDocumentRequest. + * @memberof google.firestore.v1beta1 + * @interface ICreateDocumentRequest + * @property {string|null} [parent] CreateDocumentRequest parent + * @property {string|null} [collectionId] CreateDocumentRequest collectionId + * @property {string|null} [documentId] CreateDocumentRequest documentId + * @property {google.firestore.v1beta1.IDocument|null} [document] CreateDocumentRequest document + * @property {google.firestore.v1beta1.IDocumentMask|null} [mask] CreateDocumentRequest mask + */ + + /** + * Constructs a new CreateDocumentRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a CreateDocumentRequest. + * @implements ICreateDocumentRequest + * @constructor + * @param {google.firestore.v1beta1.ICreateDocumentRequest=} [properties] Properties to set + */ + function CreateDocumentRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CreateDocumentRequest parent. + * @member {string} parent + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @instance + */ + CreateDocumentRequest.prototype.parent = ""; + + /** + * CreateDocumentRequest collectionId. + * @member {string} collectionId + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @instance + */ + CreateDocumentRequest.prototype.collectionId = ""; + + /** + * CreateDocumentRequest documentId. + * @member {string} documentId + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @instance + */ + CreateDocumentRequest.prototype.documentId = ""; + + /** + * CreateDocumentRequest document. + * @member {google.firestore.v1beta1.IDocument|null|undefined} document + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @instance + */ + CreateDocumentRequest.prototype.document = null; + + /** + * CreateDocumentRequest mask. + * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} mask + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @instance + */ + CreateDocumentRequest.prototype.mask = null; + + return CreateDocumentRequest; + })(); + + v1beta1.UpdateDocumentRequest = (function() { + + /** + * Properties of an UpdateDocumentRequest. + * @memberof google.firestore.v1beta1 + * @interface IUpdateDocumentRequest + * @property {google.firestore.v1beta1.IDocument|null} [document] UpdateDocumentRequest document + * @property {google.firestore.v1beta1.IDocumentMask|null} [updateMask] UpdateDocumentRequest updateMask + * @property {google.firestore.v1beta1.IDocumentMask|null} [mask] UpdateDocumentRequest mask + * @property {google.firestore.v1beta1.IPrecondition|null} [currentDocument] UpdateDocumentRequest currentDocument + */ + + /** + * Constructs a new UpdateDocumentRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents an UpdateDocumentRequest. + * @implements IUpdateDocumentRequest + * @constructor + * @param {google.firestore.v1beta1.IUpdateDocumentRequest=} [properties] Properties to set + */ + function UpdateDocumentRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UpdateDocumentRequest document. + * @member {google.firestore.v1beta1.IDocument|null|undefined} document + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @instance + */ + UpdateDocumentRequest.prototype.document = null; + + /** + * UpdateDocumentRequest updateMask. + * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} updateMask + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @instance + */ + UpdateDocumentRequest.prototype.updateMask = null; + + /** + * UpdateDocumentRequest mask. + * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} mask + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @instance + */ + UpdateDocumentRequest.prototype.mask = null; + + /** + * UpdateDocumentRequest currentDocument. + * @member {google.firestore.v1beta1.IPrecondition|null|undefined} currentDocument + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @instance + */ + UpdateDocumentRequest.prototype.currentDocument = null; + + return UpdateDocumentRequest; + })(); + + v1beta1.DeleteDocumentRequest = (function() { + + /** + * Properties of a DeleteDocumentRequest. + * @memberof google.firestore.v1beta1 + * @interface IDeleteDocumentRequest + * @property {string|null} [name] DeleteDocumentRequest name + * @property {google.firestore.v1beta1.IPrecondition|null} [currentDocument] DeleteDocumentRequest currentDocument + */ + + /** + * Constructs a new DeleteDocumentRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a DeleteDocumentRequest. + * @implements IDeleteDocumentRequest + * @constructor + * @param {google.firestore.v1beta1.IDeleteDocumentRequest=} [properties] Properties to set + */ + function DeleteDocumentRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteDocumentRequest name. + * @member {string} name + * @memberof google.firestore.v1beta1.DeleteDocumentRequest + * @instance + */ + DeleteDocumentRequest.prototype.name = ""; + + /** + * DeleteDocumentRequest currentDocument. + * @member {google.firestore.v1beta1.IPrecondition|null|undefined} currentDocument + * @memberof google.firestore.v1beta1.DeleteDocumentRequest + * @instance + */ + DeleteDocumentRequest.prototype.currentDocument = null; + + return DeleteDocumentRequest; + })(); + + v1beta1.BatchGetDocumentsRequest = (function() { + + /** + * Properties of a BatchGetDocumentsRequest. + * @memberof google.firestore.v1beta1 + * @interface IBatchGetDocumentsRequest + * @property {string|null} [database] BatchGetDocumentsRequest database + * @property {Array.|null} [documents] BatchGetDocumentsRequest documents + * @property {google.firestore.v1beta1.IDocumentMask|null} [mask] BatchGetDocumentsRequest mask + * @property {Uint8Array|null} [transaction] BatchGetDocumentsRequest transaction + * @property {google.firestore.v1beta1.ITransactionOptions|null} [newTransaction] BatchGetDocumentsRequest newTransaction + * @property {google.protobuf.ITimestamp|null} [readTime] BatchGetDocumentsRequest readTime + */ + + /** + * Constructs a new BatchGetDocumentsRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a BatchGetDocumentsRequest. + * @implements IBatchGetDocumentsRequest + * @constructor + * @param {google.firestore.v1beta1.IBatchGetDocumentsRequest=} [properties] Properties to set + */ + function BatchGetDocumentsRequest(properties) { + this.documents = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BatchGetDocumentsRequest database. + * @member {string} database + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.database = ""; + + /** + * BatchGetDocumentsRequest documents. + * @member {Array.} documents + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.documents = $util.emptyArray; + + /** + * BatchGetDocumentsRequest mask. + * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} mask + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.mask = null; + + /** + * BatchGetDocumentsRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.transaction = $util.newBuffer([]); + + /** + * BatchGetDocumentsRequest newTransaction. + * @member {google.firestore.v1beta1.ITransactionOptions|null|undefined} newTransaction + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.newTransaction = null; + + /** + * BatchGetDocumentsRequest readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.readTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * BatchGetDocumentsRequest consistencySelector. + * @member {"transaction"|"newTransaction"|"readTime"|undefined} consistencySelector + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @instance + */ + Object.defineProperty(BatchGetDocumentsRequest.prototype, "consistencySelector", { + get: $util.oneOfGetter($oneOfFields = ["transaction", "newTransaction", "readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return BatchGetDocumentsRequest; + })(); + + v1beta1.BatchGetDocumentsResponse = (function() { + + /** + * Properties of a BatchGetDocumentsResponse. + * @memberof google.firestore.v1beta1 + * @interface IBatchGetDocumentsResponse + * @property {google.firestore.v1beta1.IDocument|null} [found] BatchGetDocumentsResponse found + * @property {string|null} [missing] BatchGetDocumentsResponse missing + * @property {Uint8Array|null} [transaction] BatchGetDocumentsResponse transaction + * @property {google.protobuf.ITimestamp|null} [readTime] BatchGetDocumentsResponse readTime + */ + + /** + * Constructs a new BatchGetDocumentsResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a BatchGetDocumentsResponse. + * @implements IBatchGetDocumentsResponse + * @constructor + * @param {google.firestore.v1beta1.IBatchGetDocumentsResponse=} [properties] Properties to set + */ + function BatchGetDocumentsResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BatchGetDocumentsResponse found. + * @member {google.firestore.v1beta1.IDocument|null|undefined} found + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @instance + */ + BatchGetDocumentsResponse.prototype.found = null; + + /** + * BatchGetDocumentsResponse missing. + * @member {string} missing + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @instance + */ + BatchGetDocumentsResponse.prototype.missing = ""; + + /** + * BatchGetDocumentsResponse transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @instance + */ + BatchGetDocumentsResponse.prototype.transaction = $util.newBuffer([]); + + /** + * BatchGetDocumentsResponse readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @instance + */ + BatchGetDocumentsResponse.prototype.readTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * BatchGetDocumentsResponse result. + * @member {"found"|"missing"|undefined} result + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @instance + */ + Object.defineProperty(BatchGetDocumentsResponse.prototype, "result", { + get: $util.oneOfGetter($oneOfFields = ["found", "missing"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return BatchGetDocumentsResponse; + })(); + + v1beta1.BeginTransactionRequest = (function() { + + /** + * Properties of a BeginTransactionRequest. + * @memberof google.firestore.v1beta1 + * @interface IBeginTransactionRequest + * @property {string|null} [database] BeginTransactionRequest database + * @property {google.firestore.v1beta1.ITransactionOptions|null} [options] BeginTransactionRequest options + */ + + /** + * Constructs a new BeginTransactionRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a BeginTransactionRequest. + * @implements IBeginTransactionRequest + * @constructor + * @param {google.firestore.v1beta1.IBeginTransactionRequest=} [properties] Properties to set + */ + function BeginTransactionRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BeginTransactionRequest database. + * @member {string} database + * @memberof google.firestore.v1beta1.BeginTransactionRequest + * @instance + */ + BeginTransactionRequest.prototype.database = ""; + + /** + * BeginTransactionRequest options. + * @member {google.firestore.v1beta1.ITransactionOptions|null|undefined} options + * @memberof google.firestore.v1beta1.BeginTransactionRequest + * @instance + */ + BeginTransactionRequest.prototype.options = null; + + return BeginTransactionRequest; + })(); + + v1beta1.BeginTransactionResponse = (function() { + + /** + * Properties of a BeginTransactionResponse. + * @memberof google.firestore.v1beta1 + * @interface IBeginTransactionResponse + * @property {Uint8Array|null} [transaction] BeginTransactionResponse transaction + */ + + /** + * Constructs a new BeginTransactionResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a BeginTransactionResponse. + * @implements IBeginTransactionResponse + * @constructor + * @param {google.firestore.v1beta1.IBeginTransactionResponse=} [properties] Properties to set + */ + function BeginTransactionResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BeginTransactionResponse transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.BeginTransactionResponse + * @instance + */ + BeginTransactionResponse.prototype.transaction = $util.newBuffer([]); + + return BeginTransactionResponse; + })(); + + v1beta1.CommitRequest = (function() { + + /** + * Properties of a CommitRequest. + * @memberof google.firestore.v1beta1 + * @interface ICommitRequest + * @property {string|null} [database] CommitRequest database + * @property {Array.|null} [writes] CommitRequest writes + * @property {Uint8Array|null} [transaction] CommitRequest transaction + */ + + /** + * Constructs a new CommitRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a CommitRequest. + * @implements ICommitRequest + * @constructor + * @param {google.firestore.v1beta1.ICommitRequest=} [properties] Properties to set + */ + function CommitRequest(properties) { + this.writes = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CommitRequest database. + * @member {string} database + * @memberof google.firestore.v1beta1.CommitRequest + * @instance + */ + CommitRequest.prototype.database = ""; + + /** + * CommitRequest writes. + * @member {Array.} writes + * @memberof google.firestore.v1beta1.CommitRequest + * @instance + */ + CommitRequest.prototype.writes = $util.emptyArray; + + /** + * CommitRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.CommitRequest + * @instance + */ + CommitRequest.prototype.transaction = $util.newBuffer([]); + + return CommitRequest; + })(); + + v1beta1.CommitResponse = (function() { + + /** + * Properties of a CommitResponse. + * @memberof google.firestore.v1beta1 + * @interface ICommitResponse + * @property {Array.|null} [writeResults] CommitResponse writeResults + * @property {google.protobuf.ITimestamp|null} [commitTime] CommitResponse commitTime + */ + + /** + * Constructs a new CommitResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a CommitResponse. + * @implements ICommitResponse + * @constructor + * @param {google.firestore.v1beta1.ICommitResponse=} [properties] Properties to set + */ + function CommitResponse(properties) { + this.writeResults = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CommitResponse writeResults. + * @member {Array.} writeResults + * @memberof google.firestore.v1beta1.CommitResponse + * @instance + */ + CommitResponse.prototype.writeResults = $util.emptyArray; + + /** + * CommitResponse commitTime. + * @member {google.protobuf.ITimestamp|null|undefined} commitTime + * @memberof google.firestore.v1beta1.CommitResponse + * @instance + */ + CommitResponse.prototype.commitTime = null; + + return CommitResponse; + })(); + + v1beta1.RollbackRequest = (function() { + + /** + * Properties of a RollbackRequest. + * @memberof google.firestore.v1beta1 + * @interface IRollbackRequest + * @property {string|null} [database] RollbackRequest database + * @property {Uint8Array|null} [transaction] RollbackRequest transaction + */ + + /** + * Constructs a new RollbackRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a RollbackRequest. + * @implements IRollbackRequest + * @constructor + * @param {google.firestore.v1beta1.IRollbackRequest=} [properties] Properties to set + */ + function RollbackRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RollbackRequest database. + * @member {string} database + * @memberof google.firestore.v1beta1.RollbackRequest + * @instance + */ + RollbackRequest.prototype.database = ""; + + /** + * RollbackRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.RollbackRequest + * @instance + */ + RollbackRequest.prototype.transaction = $util.newBuffer([]); + + return RollbackRequest; + })(); + + v1beta1.RunQueryRequest = (function() { + + /** + * Properties of a RunQueryRequest. + * @memberof google.firestore.v1beta1 + * @interface IRunQueryRequest + * @property {string|null} [parent] RunQueryRequest parent + * @property {google.firestore.v1beta1.IStructuredQuery|null} [structuredQuery] RunQueryRequest structuredQuery + * @property {Uint8Array|null} [transaction] RunQueryRequest transaction + * @property {google.firestore.v1beta1.ITransactionOptions|null} [newTransaction] RunQueryRequest newTransaction + * @property {google.protobuf.ITimestamp|null} [readTime] RunQueryRequest readTime + */ + + /** + * Constructs a new RunQueryRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a RunQueryRequest. + * @implements IRunQueryRequest + * @constructor + * @param {google.firestore.v1beta1.IRunQueryRequest=} [properties] Properties to set + */ + function RunQueryRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RunQueryRequest parent. + * @member {string} parent + * @memberof google.firestore.v1beta1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.parent = ""; + + /** + * RunQueryRequest structuredQuery. + * @member {google.firestore.v1beta1.IStructuredQuery|null|undefined} structuredQuery + * @memberof google.firestore.v1beta1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.structuredQuery = null; + + /** + * RunQueryRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.transaction = $util.newBuffer([]); + + /** + * RunQueryRequest newTransaction. + * @member {google.firestore.v1beta1.ITransactionOptions|null|undefined} newTransaction + * @memberof google.firestore.v1beta1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.newTransaction = null; + + /** + * RunQueryRequest readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.readTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * RunQueryRequest queryType. + * @member {"structuredQuery"|undefined} queryType + * @memberof google.firestore.v1beta1.RunQueryRequest + * @instance + */ + Object.defineProperty(RunQueryRequest.prototype, "queryType", { + get: $util.oneOfGetter($oneOfFields = ["structuredQuery"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * RunQueryRequest consistencySelector. + * @member {"transaction"|"newTransaction"|"readTime"|undefined} consistencySelector + * @memberof google.firestore.v1beta1.RunQueryRequest + * @instance + */ + Object.defineProperty(RunQueryRequest.prototype, "consistencySelector", { + get: $util.oneOfGetter($oneOfFields = ["transaction", "newTransaction", "readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return RunQueryRequest; + })(); + + v1beta1.RunQueryResponse = (function() { + + /** + * Properties of a RunQueryResponse. + * @memberof google.firestore.v1beta1 + * @interface IRunQueryResponse + * @property {Uint8Array|null} [transaction] RunQueryResponse transaction + * @property {google.firestore.v1beta1.IDocument|null} [document] RunQueryResponse document + * @property {google.protobuf.ITimestamp|null} [readTime] RunQueryResponse readTime + * @property {number|null} [skippedResults] RunQueryResponse skippedResults + */ + + /** + * Constructs a new RunQueryResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a RunQueryResponse. + * @implements IRunQueryResponse + * @constructor + * @param {google.firestore.v1beta1.IRunQueryResponse=} [properties] Properties to set + */ + function RunQueryResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RunQueryResponse transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.transaction = $util.newBuffer([]); + + /** + * RunQueryResponse document. + * @member {google.firestore.v1beta1.IDocument|null|undefined} document + * @memberof google.firestore.v1beta1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.document = null; + + /** + * RunQueryResponse readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.readTime = null; + + /** + * RunQueryResponse skippedResults. + * @member {number} skippedResults + * @memberof google.firestore.v1beta1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.skippedResults = 0; + + return RunQueryResponse; + })(); + + v1beta1.WriteRequest = (function() { + + /** + * Properties of a WriteRequest. + * @memberof google.firestore.v1beta1 + * @interface IWriteRequest + * @property {string|null} [database] WriteRequest database + * @property {string|null} [streamId] WriteRequest streamId + * @property {Array.|null} [writes] WriteRequest writes + * @property {Uint8Array|null} [streamToken] WriteRequest streamToken + * @property {Object.|null} [labels] WriteRequest labels + */ + + /** + * Constructs a new WriteRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a WriteRequest. + * @implements IWriteRequest + * @constructor + * @param {google.firestore.v1beta1.IWriteRequest=} [properties] Properties to set + */ + function WriteRequest(properties) { + this.writes = []; + this.labels = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WriteRequest database. + * @member {string} database + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + */ + WriteRequest.prototype.database = ""; + + /** + * WriteRequest streamId. + * @member {string} streamId + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + */ + WriteRequest.prototype.streamId = ""; + + /** + * WriteRequest writes. + * @member {Array.} writes + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + */ + WriteRequest.prototype.writes = $util.emptyArray; + + /** + * WriteRequest streamToken. + * @member {Uint8Array} streamToken + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + */ + WriteRequest.prototype.streamToken = $util.newBuffer([]); + + /** + * WriteRequest labels. + * @member {Object.} labels + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + */ + WriteRequest.prototype.labels = $util.emptyObject; + + return WriteRequest; + })(); + + v1beta1.WriteResponse = (function() { + + /** + * Properties of a WriteResponse. + * @memberof google.firestore.v1beta1 + * @interface IWriteResponse + * @property {string|null} [streamId] WriteResponse streamId + * @property {Uint8Array|null} [streamToken] WriteResponse streamToken + * @property {Array.|null} [writeResults] WriteResponse writeResults + * @property {google.protobuf.ITimestamp|null} [commitTime] WriteResponse commitTime + */ + + /** + * Constructs a new WriteResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a WriteResponse. + * @implements IWriteResponse + * @constructor + * @param {google.firestore.v1beta1.IWriteResponse=} [properties] Properties to set + */ + function WriteResponse(properties) { + this.writeResults = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WriteResponse streamId. + * @member {string} streamId + * @memberof google.firestore.v1beta1.WriteResponse + * @instance + */ + WriteResponse.prototype.streamId = ""; + + /** + * WriteResponse streamToken. + * @member {Uint8Array} streamToken + * @memberof google.firestore.v1beta1.WriteResponse + * @instance + */ + WriteResponse.prototype.streamToken = $util.newBuffer([]); + + /** + * WriteResponse writeResults. + * @member {Array.} writeResults + * @memberof google.firestore.v1beta1.WriteResponse + * @instance + */ + WriteResponse.prototype.writeResults = $util.emptyArray; + + /** + * WriteResponse commitTime. + * @member {google.protobuf.ITimestamp|null|undefined} commitTime + * @memberof google.firestore.v1beta1.WriteResponse + * @instance + */ + WriteResponse.prototype.commitTime = null; + + return WriteResponse; + })(); + + v1beta1.ListenRequest = (function() { + + /** + * Properties of a ListenRequest. + * @memberof google.firestore.v1beta1 + * @interface IListenRequest + * @property {string|null} [database] ListenRequest database + * @property {google.firestore.v1beta1.ITarget|null} [addTarget] ListenRequest addTarget + * @property {number|null} [removeTarget] ListenRequest removeTarget + * @property {Object.|null} [labels] ListenRequest labels + */ + + /** + * Constructs a new ListenRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a ListenRequest. + * @implements IListenRequest + * @constructor + * @param {google.firestore.v1beta1.IListenRequest=} [properties] Properties to set + */ + function ListenRequest(properties) { + this.labels = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListenRequest database. + * @member {string} database + * @memberof google.firestore.v1beta1.ListenRequest + * @instance + */ + ListenRequest.prototype.database = ""; + + /** + * ListenRequest addTarget. + * @member {google.firestore.v1beta1.ITarget|null|undefined} addTarget + * @memberof google.firestore.v1beta1.ListenRequest + * @instance + */ + ListenRequest.prototype.addTarget = null; + + /** + * ListenRequest removeTarget. + * @member {number} removeTarget + * @memberof google.firestore.v1beta1.ListenRequest + * @instance + */ + ListenRequest.prototype.removeTarget = 0; + + /** + * ListenRequest labels. + * @member {Object.} labels + * @memberof google.firestore.v1beta1.ListenRequest + * @instance + */ + ListenRequest.prototype.labels = $util.emptyObject; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ListenRequest targetChange. + * @member {"addTarget"|"removeTarget"|undefined} targetChange + * @memberof google.firestore.v1beta1.ListenRequest + * @instance + */ + Object.defineProperty(ListenRequest.prototype, "targetChange", { + get: $util.oneOfGetter($oneOfFields = ["addTarget", "removeTarget"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return ListenRequest; + })(); + + v1beta1.ListenResponse = (function() { + + /** + * Properties of a ListenResponse. + * @memberof google.firestore.v1beta1 + * @interface IListenResponse + * @property {google.firestore.v1beta1.ITargetChange|null} [targetChange] ListenResponse targetChange + * @property {google.firestore.v1beta1.IDocumentChange|null} [documentChange] ListenResponse documentChange + * @property {google.firestore.v1beta1.IDocumentDelete|null} [documentDelete] ListenResponse documentDelete + * @property {google.firestore.v1beta1.IDocumentRemove|null} [documentRemove] ListenResponse documentRemove + * @property {google.firestore.v1beta1.IExistenceFilter|null} [filter] ListenResponse filter + */ + + /** + * Constructs a new ListenResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a ListenResponse. + * @implements IListenResponse + * @constructor + * @param {google.firestore.v1beta1.IListenResponse=} [properties] Properties to set + */ + function ListenResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListenResponse targetChange. + * @member {google.firestore.v1beta1.ITargetChange|null|undefined} targetChange + * @memberof google.firestore.v1beta1.ListenResponse + * @instance + */ + ListenResponse.prototype.targetChange = null; + + /** + * ListenResponse documentChange. + * @member {google.firestore.v1beta1.IDocumentChange|null|undefined} documentChange + * @memberof google.firestore.v1beta1.ListenResponse + * @instance + */ + ListenResponse.prototype.documentChange = null; + + /** + * ListenResponse documentDelete. + * @member {google.firestore.v1beta1.IDocumentDelete|null|undefined} documentDelete + * @memberof google.firestore.v1beta1.ListenResponse + * @instance + */ + ListenResponse.prototype.documentDelete = null; + + /** + * ListenResponse documentRemove. + * @member {google.firestore.v1beta1.IDocumentRemove|null|undefined} documentRemove + * @memberof google.firestore.v1beta1.ListenResponse + * @instance + */ + ListenResponse.prototype.documentRemove = null; + + /** + * ListenResponse filter. + * @member {google.firestore.v1beta1.IExistenceFilter|null|undefined} filter + * @memberof google.firestore.v1beta1.ListenResponse + * @instance + */ + ListenResponse.prototype.filter = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ListenResponse responseType. + * @member {"targetChange"|"documentChange"|"documentDelete"|"documentRemove"|"filter"|undefined} responseType + * @memberof google.firestore.v1beta1.ListenResponse + * @instance + */ + Object.defineProperty(ListenResponse.prototype, "responseType", { + get: $util.oneOfGetter($oneOfFields = ["targetChange", "documentChange", "documentDelete", "documentRemove", "filter"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return ListenResponse; + })(); + + v1beta1.Target = (function() { + + /** + * Properties of a Target. + * @memberof google.firestore.v1beta1 + * @interface ITarget + * @property {google.firestore.v1beta1.Target.IQueryTarget|null} [query] Target query + * @property {google.firestore.v1beta1.Target.IDocumentsTarget|null} [documents] Target documents + * @property {Uint8Array|null} [resumeToken] Target resumeToken + * @property {google.protobuf.ITimestamp|null} [readTime] Target readTime + * @property {number|null} [targetId] Target targetId + * @property {boolean|null} [once] Target once + */ + + /** + * Constructs a new Target. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a Target. + * @implements ITarget + * @constructor + * @param {google.firestore.v1beta1.ITarget=} [properties] Properties to set + */ + function Target(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Target query. + * @member {google.firestore.v1beta1.Target.IQueryTarget|null|undefined} query + * @memberof google.firestore.v1beta1.Target + * @instance + */ + Target.prototype.query = null; + + /** + * Target documents. + * @member {google.firestore.v1beta1.Target.IDocumentsTarget|null|undefined} documents + * @memberof google.firestore.v1beta1.Target + * @instance + */ + Target.prototype.documents = null; + + /** + * Target resumeToken. + * @member {Uint8Array} resumeToken + * @memberof google.firestore.v1beta1.Target + * @instance + */ + Target.prototype.resumeToken = $util.newBuffer([]); + + /** + * Target readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.Target + * @instance + */ + Target.prototype.readTime = null; + + /** + * Target targetId. + * @member {number} targetId + * @memberof google.firestore.v1beta1.Target + * @instance + */ + Target.prototype.targetId = 0; + + /** + * Target once. + * @member {boolean} once + * @memberof google.firestore.v1beta1.Target + * @instance + */ + Target.prototype.once = false; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Target targetType. + * @member {"query"|"documents"|undefined} targetType + * @memberof google.firestore.v1beta1.Target + * @instance + */ + Object.defineProperty(Target.prototype, "targetType", { + get: $util.oneOfGetter($oneOfFields = ["query", "documents"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Target resumeType. + * @member {"resumeToken"|"readTime"|undefined} resumeType + * @memberof google.firestore.v1beta1.Target + * @instance + */ + Object.defineProperty(Target.prototype, "resumeType", { + get: $util.oneOfGetter($oneOfFields = ["resumeToken", "readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + Target.DocumentsTarget = (function() { + + /** + * Properties of a DocumentsTarget. + * @memberof google.firestore.v1beta1.Target + * @interface IDocumentsTarget + * @property {Array.|null} [documents] DocumentsTarget documents + */ + + /** + * Constructs a new DocumentsTarget. + * @memberof google.firestore.v1beta1.Target + * @classdesc Represents a DocumentsTarget. + * @implements IDocumentsTarget + * @constructor + * @param {google.firestore.v1beta1.Target.IDocumentsTarget=} [properties] Properties to set + */ + function DocumentsTarget(properties) { + this.documents = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentsTarget documents. + * @member {Array.} documents + * @memberof google.firestore.v1beta1.Target.DocumentsTarget + * @instance + */ + DocumentsTarget.prototype.documents = $util.emptyArray; + + return DocumentsTarget; + })(); + + Target.QueryTarget = (function() { + + /** + * Properties of a QueryTarget. + * @memberof google.firestore.v1beta1.Target + * @interface IQueryTarget + * @property {string|null} [parent] QueryTarget parent + * @property {google.firestore.v1beta1.IStructuredQuery|null} [structuredQuery] QueryTarget structuredQuery + */ + + /** + * Constructs a new QueryTarget. + * @memberof google.firestore.v1beta1.Target + * @classdesc Represents a QueryTarget. + * @implements IQueryTarget + * @constructor + * @param {google.firestore.v1beta1.Target.IQueryTarget=} [properties] Properties to set + */ + function QueryTarget(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * QueryTarget parent. + * @member {string} parent + * @memberof google.firestore.v1beta1.Target.QueryTarget + * @instance + */ + QueryTarget.prototype.parent = ""; + + /** + * QueryTarget structuredQuery. + * @member {google.firestore.v1beta1.IStructuredQuery|null|undefined} structuredQuery + * @memberof google.firestore.v1beta1.Target.QueryTarget + * @instance + */ + QueryTarget.prototype.structuredQuery = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * QueryTarget queryType. + * @member {"structuredQuery"|undefined} queryType + * @memberof google.firestore.v1beta1.Target.QueryTarget + * @instance + */ + Object.defineProperty(QueryTarget.prototype, "queryType", { + get: $util.oneOfGetter($oneOfFields = ["structuredQuery"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return QueryTarget; + })(); + + return Target; + })(); + + v1beta1.TargetChange = (function() { + + /** + * Properties of a TargetChange. + * @memberof google.firestore.v1beta1 + * @interface ITargetChange + * @property {google.firestore.v1beta1.TargetChange.TargetChangeType|null} [targetChangeType] TargetChange targetChangeType + * @property {Array.|null} [targetIds] TargetChange targetIds + * @property {google.rpc.IStatus|null} [cause] TargetChange cause + * @property {Uint8Array|null} [resumeToken] TargetChange resumeToken + * @property {google.protobuf.ITimestamp|null} [readTime] TargetChange readTime + */ + + /** + * Constructs a new TargetChange. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a TargetChange. + * @implements ITargetChange + * @constructor + * @param {google.firestore.v1beta1.ITargetChange=} [properties] Properties to set + */ + function TargetChange(properties) { + this.targetIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * TargetChange targetChangeType. + * @member {google.firestore.v1beta1.TargetChange.TargetChangeType} targetChangeType + * @memberof google.firestore.v1beta1.TargetChange + * @instance + */ + TargetChange.prototype.targetChangeType = 0; + + /** + * TargetChange targetIds. + * @member {Array.} targetIds + * @memberof google.firestore.v1beta1.TargetChange + * @instance + */ + TargetChange.prototype.targetIds = $util.emptyArray; + + /** + * TargetChange cause. + * @member {google.rpc.IStatus|null|undefined} cause + * @memberof google.firestore.v1beta1.TargetChange + * @instance + */ + TargetChange.prototype.cause = null; + + /** + * TargetChange resumeToken. + * @member {Uint8Array} resumeToken + * @memberof google.firestore.v1beta1.TargetChange + * @instance + */ + TargetChange.prototype.resumeToken = $util.newBuffer([]); + + /** + * TargetChange readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.TargetChange + * @instance + */ + TargetChange.prototype.readTime = null; + + /** + * TargetChangeType enum. + * @name google.firestore.v1beta1.TargetChange.TargetChangeType + * @enum {number} + * @property {string} NO_CHANGE=NO_CHANGE NO_CHANGE value + * @property {string} ADD=ADD ADD value + * @property {string} REMOVE=REMOVE REMOVE value + * @property {string} CURRENT=CURRENT CURRENT value + * @property {string} RESET=RESET RESET value + */ + TargetChange.TargetChangeType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "NO_CHANGE"] = "NO_CHANGE"; + values[valuesById[1] = "ADD"] = "ADD"; + values[valuesById[2] = "REMOVE"] = "REMOVE"; + values[valuesById[3] = "CURRENT"] = "CURRENT"; + values[valuesById[4] = "RESET"] = "RESET"; + return values; + })(); + + return TargetChange; + })(); + + v1beta1.ListCollectionIdsRequest = (function() { + + /** + * Properties of a ListCollectionIdsRequest. + * @memberof google.firestore.v1beta1 + * @interface IListCollectionIdsRequest + * @property {string|null} [parent] ListCollectionIdsRequest parent + * @property {number|null} [pageSize] ListCollectionIdsRequest pageSize + * @property {string|null} [pageToken] ListCollectionIdsRequest pageToken + */ + + /** + * Constructs a new ListCollectionIdsRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a ListCollectionIdsRequest. + * @implements IListCollectionIdsRequest + * @constructor + * @param {google.firestore.v1beta1.IListCollectionIdsRequest=} [properties] Properties to set + */ + function ListCollectionIdsRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListCollectionIdsRequest parent. + * @member {string} parent + * @memberof google.firestore.v1beta1.ListCollectionIdsRequest + * @instance + */ + ListCollectionIdsRequest.prototype.parent = ""; + + /** + * ListCollectionIdsRequest pageSize. + * @member {number} pageSize + * @memberof google.firestore.v1beta1.ListCollectionIdsRequest + * @instance + */ + ListCollectionIdsRequest.prototype.pageSize = 0; + + /** + * ListCollectionIdsRequest pageToken. + * @member {string} pageToken + * @memberof google.firestore.v1beta1.ListCollectionIdsRequest + * @instance + */ + ListCollectionIdsRequest.prototype.pageToken = ""; + + return ListCollectionIdsRequest; + })(); + + v1beta1.ListCollectionIdsResponse = (function() { + + /** + * Properties of a ListCollectionIdsResponse. + * @memberof google.firestore.v1beta1 + * @interface IListCollectionIdsResponse + * @property {Array.|null} [collectionIds] ListCollectionIdsResponse collectionIds + * @property {string|null} [nextPageToken] ListCollectionIdsResponse nextPageToken + */ + + /** + * Constructs a new ListCollectionIdsResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a ListCollectionIdsResponse. + * @implements IListCollectionIdsResponse + * @constructor + * @param {google.firestore.v1beta1.IListCollectionIdsResponse=} [properties] Properties to set + */ + function ListCollectionIdsResponse(properties) { + this.collectionIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListCollectionIdsResponse collectionIds. + * @member {Array.} collectionIds + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @instance + */ + ListCollectionIdsResponse.prototype.collectionIds = $util.emptyArray; + + /** + * ListCollectionIdsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @instance + */ + ListCollectionIdsResponse.prototype.nextPageToken = ""; + + return ListCollectionIdsResponse; + })(); + + v1beta1.StructuredQuery = (function() { + + /** + * Properties of a StructuredQuery. + * @memberof google.firestore.v1beta1 + * @interface IStructuredQuery + * @property {google.firestore.v1beta1.StructuredQuery.IProjection|null} [select] StructuredQuery select + * @property {Array.|null} [from] StructuredQuery from + * @property {google.firestore.v1beta1.StructuredQuery.IFilter|null} [where] StructuredQuery where + * @property {Array.|null} [orderBy] StructuredQuery orderBy + * @property {google.firestore.v1beta1.ICursor|null} [startAt] StructuredQuery startAt + * @property {google.firestore.v1beta1.ICursor|null} [endAt] StructuredQuery endAt + * @property {number|null} [offset] StructuredQuery offset + * @property {google.protobuf.IInt32Value|null} [limit] StructuredQuery limit + */ + + /** + * Constructs a new StructuredQuery. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a StructuredQuery. + * @implements IStructuredQuery + * @constructor + * @param {google.firestore.v1beta1.IStructuredQuery=} [properties] Properties to set + */ + function StructuredQuery(properties) { + this.from = []; + this.orderBy = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StructuredQuery select. + * @member {google.firestore.v1beta1.StructuredQuery.IProjection|null|undefined} select + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.select = null; + + /** + * StructuredQuery from. + * @member {Array.} from + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.from = $util.emptyArray; + + /** + * StructuredQuery where. + * @member {google.firestore.v1beta1.StructuredQuery.IFilter|null|undefined} where + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.where = null; + + /** + * StructuredQuery orderBy. + * @member {Array.} orderBy + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.orderBy = $util.emptyArray; + + /** + * StructuredQuery startAt. + * @member {google.firestore.v1beta1.ICursor|null|undefined} startAt + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.startAt = null; + + /** + * StructuredQuery endAt. + * @member {google.firestore.v1beta1.ICursor|null|undefined} endAt + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.endAt = null; + + /** + * StructuredQuery offset. + * @member {number} offset + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.offset = 0; + + /** + * StructuredQuery limit. + * @member {google.protobuf.IInt32Value|null|undefined} limit + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.limit = null; + + StructuredQuery.CollectionSelector = (function() { + + /** + * Properties of a CollectionSelector. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface ICollectionSelector + * @property {string|null} [collectionId] CollectionSelector collectionId + * @property {boolean|null} [allDescendants] CollectionSelector allDescendants + */ + + /** + * Constructs a new CollectionSelector. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents a CollectionSelector. + * @implements ICollectionSelector + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.ICollectionSelector=} [properties] Properties to set + */ + function CollectionSelector(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CollectionSelector collectionId. + * @member {string} collectionId + * @memberof google.firestore.v1beta1.StructuredQuery.CollectionSelector + * @instance + */ + CollectionSelector.prototype.collectionId = ""; + + /** + * CollectionSelector allDescendants. + * @member {boolean} allDescendants + * @memberof google.firestore.v1beta1.StructuredQuery.CollectionSelector + * @instance + */ + CollectionSelector.prototype.allDescendants = false; + + return CollectionSelector; + })(); + + StructuredQuery.Filter = (function() { + + /** + * Properties of a Filter. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface IFilter + * @property {google.firestore.v1beta1.StructuredQuery.ICompositeFilter|null} [compositeFilter] Filter compositeFilter + * @property {google.firestore.v1beta1.StructuredQuery.IFieldFilter|null} [fieldFilter] Filter fieldFilter + * @property {google.firestore.v1beta1.StructuredQuery.IUnaryFilter|null} [unaryFilter] Filter unaryFilter + */ + + /** + * Constructs a new Filter. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents a Filter. + * @implements IFilter + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.IFilter=} [properties] Properties to set + */ + function Filter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Filter compositeFilter. + * @member {google.firestore.v1beta1.StructuredQuery.ICompositeFilter|null|undefined} compositeFilter + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @instance + */ + Filter.prototype.compositeFilter = null; + + /** + * Filter fieldFilter. + * @member {google.firestore.v1beta1.StructuredQuery.IFieldFilter|null|undefined} fieldFilter + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @instance + */ + Filter.prototype.fieldFilter = null; + + /** + * Filter unaryFilter. + * @member {google.firestore.v1beta1.StructuredQuery.IUnaryFilter|null|undefined} unaryFilter + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @instance + */ + Filter.prototype.unaryFilter = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Filter filterType. + * @member {"compositeFilter"|"fieldFilter"|"unaryFilter"|undefined} filterType + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @instance + */ + Object.defineProperty(Filter.prototype, "filterType", { + get: $util.oneOfGetter($oneOfFields = ["compositeFilter", "fieldFilter", "unaryFilter"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return Filter; + })(); + + StructuredQuery.CompositeFilter = (function() { + + /** + * Properties of a CompositeFilter. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface ICompositeFilter + * @property {google.firestore.v1beta1.StructuredQuery.CompositeFilter.Operator|null} [op] CompositeFilter op + * @property {Array.|null} [filters] CompositeFilter filters + */ + + /** + * Constructs a new CompositeFilter. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents a CompositeFilter. + * @implements ICompositeFilter + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.ICompositeFilter=} [properties] Properties to set + */ + function CompositeFilter(properties) { + this.filters = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CompositeFilter op. + * @member {google.firestore.v1beta1.StructuredQuery.CompositeFilter.Operator} op + * @memberof google.firestore.v1beta1.StructuredQuery.CompositeFilter + * @instance + */ + CompositeFilter.prototype.op = 0; + + /** + * CompositeFilter filters. + * @member {Array.} filters + * @memberof google.firestore.v1beta1.StructuredQuery.CompositeFilter + * @instance + */ + CompositeFilter.prototype.filters = $util.emptyArray; + + /** + * Operator enum. + * @name google.firestore.v1beta1.StructuredQuery.CompositeFilter.Operator + * @enum {number} + * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value + * @property {string} AND=AND AND value + */ + CompositeFilter.Operator = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; + values[valuesById[1] = "AND"] = "AND"; + return values; + })(); + + return CompositeFilter; + })(); + + StructuredQuery.FieldFilter = (function() { + + /** + * Properties of a FieldFilter. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface IFieldFilter + * @property {google.firestore.v1beta1.StructuredQuery.IFieldReference|null} [field] FieldFilter field + * @property {google.firestore.v1beta1.StructuredQuery.FieldFilter.Operator|null} [op] FieldFilter op + * @property {google.firestore.v1beta1.IValue|null} [value] FieldFilter value + */ + + /** + * Constructs a new FieldFilter. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents a FieldFilter. + * @implements IFieldFilter + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.IFieldFilter=} [properties] Properties to set + */ + function FieldFilter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldFilter field. + * @member {google.firestore.v1beta1.StructuredQuery.IFieldReference|null|undefined} field + * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * @instance + */ + FieldFilter.prototype.field = null; + + /** + * FieldFilter op. + * @member {google.firestore.v1beta1.StructuredQuery.FieldFilter.Operator} op + * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * @instance + */ + FieldFilter.prototype.op = 0; + + /** + * FieldFilter value. + * @member {google.firestore.v1beta1.IValue|null|undefined} value + * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * @instance + */ + FieldFilter.prototype.value = null; + + /** + * Operator enum. + * @name google.firestore.v1beta1.StructuredQuery.FieldFilter.Operator + * @enum {number} + * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value + * @property {string} LESS_THAN=LESS_THAN LESS_THAN value + * @property {string} LESS_THAN_OR_EQUAL=LESS_THAN_OR_EQUAL LESS_THAN_OR_EQUAL value + * @property {string} GREATER_THAN=GREATER_THAN GREATER_THAN value + * @property {string} GREATER_THAN_OR_EQUAL=GREATER_THAN_OR_EQUAL GREATER_THAN_OR_EQUAL value + * @property {string} EQUAL=EQUAL EQUAL value + * @property {string} ARRAY_CONTAINS=ARRAY_CONTAINS ARRAY_CONTAINS value + * @property {string} IN=IN IN value + * @property {string} ARRAY_CONTAINS_ANY=ARRAY_CONTAINS_ANY ARRAY_CONTAINS_ANY value + */ + FieldFilter.Operator = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; + values[valuesById[1] = "LESS_THAN"] = "LESS_THAN"; + values[valuesById[2] = "LESS_THAN_OR_EQUAL"] = "LESS_THAN_OR_EQUAL"; + values[valuesById[3] = "GREATER_THAN"] = "GREATER_THAN"; + values[valuesById[4] = "GREATER_THAN_OR_EQUAL"] = "GREATER_THAN_OR_EQUAL"; + values[valuesById[5] = "EQUAL"] = "EQUAL"; + values[valuesById[7] = "ARRAY_CONTAINS"] = "ARRAY_CONTAINS"; + values[valuesById[8] = "IN"] = "IN"; + values[valuesById[9] = "ARRAY_CONTAINS_ANY"] = "ARRAY_CONTAINS_ANY"; + return values; + })(); + + return FieldFilter; + })(); + + StructuredQuery.UnaryFilter = (function() { + + /** + * Properties of an UnaryFilter. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface IUnaryFilter + * @property {google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator|null} [op] UnaryFilter op + * @property {google.firestore.v1beta1.StructuredQuery.IFieldReference|null} [field] UnaryFilter field + */ + + /** + * Constructs a new UnaryFilter. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents an UnaryFilter. + * @implements IUnaryFilter + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.IUnaryFilter=} [properties] Properties to set + */ + function UnaryFilter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UnaryFilter op. + * @member {google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator} op + * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * @instance + */ + UnaryFilter.prototype.op = 0; + + /** + * UnaryFilter field. + * @member {google.firestore.v1beta1.StructuredQuery.IFieldReference|null|undefined} field + * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * @instance + */ + UnaryFilter.prototype.field = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * UnaryFilter operandType. + * @member {"field"|undefined} operandType + * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * @instance + */ + Object.defineProperty(UnaryFilter.prototype, "operandType", { + get: $util.oneOfGetter($oneOfFields = ["field"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Operator enum. + * @name google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator + * @enum {number} + * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value + * @property {string} IS_NAN=IS_NAN IS_NAN value + * @property {string} IS_NULL=IS_NULL IS_NULL value + */ + UnaryFilter.Operator = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; + values[valuesById[2] = "IS_NAN"] = "IS_NAN"; + values[valuesById[3] = "IS_NULL"] = "IS_NULL"; + return values; + })(); + + return UnaryFilter; + })(); + + StructuredQuery.Order = (function() { + + /** + * Properties of an Order. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface IOrder + * @property {google.firestore.v1beta1.StructuredQuery.IFieldReference|null} [field] Order field + * @property {google.firestore.v1beta1.StructuredQuery.Direction|null} [direction] Order direction + */ + + /** + * Constructs a new Order. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents an Order. + * @implements IOrder + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.IOrder=} [properties] Properties to set + */ + function Order(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Order field. + * @member {google.firestore.v1beta1.StructuredQuery.IFieldReference|null|undefined} field + * @memberof google.firestore.v1beta1.StructuredQuery.Order + * @instance + */ + Order.prototype.field = null; + + /** + * Order direction. + * @member {google.firestore.v1beta1.StructuredQuery.Direction} direction + * @memberof google.firestore.v1beta1.StructuredQuery.Order + * @instance + */ + Order.prototype.direction = 0; + + return Order; + })(); + + StructuredQuery.FieldReference = (function() { + + /** + * Properties of a FieldReference. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface IFieldReference + * @property {string|null} [fieldPath] FieldReference fieldPath + */ + + /** + * Constructs a new FieldReference. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents a FieldReference. + * @implements IFieldReference + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.IFieldReference=} [properties] Properties to set + */ + function FieldReference(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldReference fieldPath. + * @member {string} fieldPath + * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference + * @instance + */ + FieldReference.prototype.fieldPath = ""; + + return FieldReference; + })(); + + StructuredQuery.Projection = (function() { + + /** + * Properties of a Projection. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface IProjection + * @property {Array.|null} [fields] Projection fields + */ + + /** + * Constructs a new Projection. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents a Projection. + * @implements IProjection + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.IProjection=} [properties] Properties to set + */ + function Projection(properties) { + this.fields = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Projection fields. + * @member {Array.} fields + * @memberof google.firestore.v1beta1.StructuredQuery.Projection + * @instance + */ + Projection.prototype.fields = $util.emptyArray; + + return Projection; + })(); + + /** + * Direction enum. + * @name google.firestore.v1beta1.StructuredQuery.Direction + * @enum {number} + * @property {string} DIRECTION_UNSPECIFIED=DIRECTION_UNSPECIFIED DIRECTION_UNSPECIFIED value + * @property {string} ASCENDING=ASCENDING ASCENDING value + * @property {string} DESCENDING=DESCENDING DESCENDING value + */ + StructuredQuery.Direction = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DIRECTION_UNSPECIFIED"] = "DIRECTION_UNSPECIFIED"; + values[valuesById[1] = "ASCENDING"] = "ASCENDING"; + values[valuesById[2] = "DESCENDING"] = "DESCENDING"; + return values; + })(); + + return StructuredQuery; + })(); + + v1beta1.Cursor = (function() { + + /** + * Properties of a Cursor. + * @memberof google.firestore.v1beta1 + * @interface ICursor + * @property {Array.|null} [values] Cursor values + * @property {boolean|null} [before] Cursor before + */ + + /** + * Constructs a new Cursor. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a Cursor. + * @implements ICursor + * @constructor + * @param {google.firestore.v1beta1.ICursor=} [properties] Properties to set + */ + function Cursor(properties) { + this.values = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Cursor values. + * @member {Array.} values + * @memberof google.firestore.v1beta1.Cursor + * @instance + */ + Cursor.prototype.values = $util.emptyArray; + + /** + * Cursor before. + * @member {boolean} before + * @memberof google.firestore.v1beta1.Cursor + * @instance + */ + Cursor.prototype.before = false; + + return Cursor; + })(); + + v1beta1.Write = (function() { + + /** + * Properties of a Write. + * @memberof google.firestore.v1beta1 + * @interface IWrite + * @property {google.firestore.v1beta1.IDocument|null} [update] Write update + * @property {string|null} ["delete"] Write delete + * @property {google.firestore.v1beta1.IDocumentTransform|null} [transform] Write transform + * @property {google.firestore.v1beta1.IDocumentMask|null} [updateMask] Write updateMask + * @property {google.firestore.v1beta1.IPrecondition|null} [currentDocument] Write currentDocument + */ + + /** + * Constructs a new Write. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a Write. + * @implements IWrite + * @constructor + * @param {google.firestore.v1beta1.IWrite=} [properties] Properties to set + */ + function Write(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Write update. + * @member {google.firestore.v1beta1.IDocument|null|undefined} update + * @memberof google.firestore.v1beta1.Write + * @instance + */ + Write.prototype.update = null; + + /** + * Write delete. + * @member {string} delete + * @memberof google.firestore.v1beta1.Write + * @instance + */ + Write.prototype["delete"] = ""; + + /** + * Write transform. + * @member {google.firestore.v1beta1.IDocumentTransform|null|undefined} transform + * @memberof google.firestore.v1beta1.Write + * @instance + */ + Write.prototype.transform = null; + + /** + * Write updateMask. + * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} updateMask + * @memberof google.firestore.v1beta1.Write + * @instance + */ + Write.prototype.updateMask = null; + + /** + * Write currentDocument. + * @member {google.firestore.v1beta1.IPrecondition|null|undefined} currentDocument + * @memberof google.firestore.v1beta1.Write + * @instance + */ + Write.prototype.currentDocument = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Write operation. + * @member {"update"|"delete"|"transform"|undefined} operation + * @memberof google.firestore.v1beta1.Write + * @instance + */ + Object.defineProperty(Write.prototype, "operation", { + get: $util.oneOfGetter($oneOfFields = ["update", "delete", "transform"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return Write; + })(); + + v1beta1.DocumentTransform = (function() { + + /** + * Properties of a DocumentTransform. + * @memberof google.firestore.v1beta1 + * @interface IDocumentTransform + * @property {string|null} [document] DocumentTransform document + * @property {Array.|null} [fieldTransforms] DocumentTransform fieldTransforms + */ + + /** + * Constructs a new DocumentTransform. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a DocumentTransform. + * @implements IDocumentTransform + * @constructor + * @param {google.firestore.v1beta1.IDocumentTransform=} [properties] Properties to set + */ + function DocumentTransform(properties) { + this.fieldTransforms = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentTransform document. + * @member {string} document + * @memberof google.firestore.v1beta1.DocumentTransform + * @instance + */ + DocumentTransform.prototype.document = ""; + + /** + * DocumentTransform fieldTransforms. + * @member {Array.} fieldTransforms + * @memberof google.firestore.v1beta1.DocumentTransform + * @instance + */ + DocumentTransform.prototype.fieldTransforms = $util.emptyArray; + + DocumentTransform.FieldTransform = (function() { + + /** + * Properties of a FieldTransform. + * @memberof google.firestore.v1beta1.DocumentTransform + * @interface IFieldTransform + * @property {string|null} [fieldPath] FieldTransform fieldPath + * @property {google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue|null} [setToServerValue] FieldTransform setToServerValue + * @property {google.firestore.v1beta1.IValue|null} [increment] FieldTransform increment + * @property {google.firestore.v1beta1.IValue|null} [maximum] FieldTransform maximum + * @property {google.firestore.v1beta1.IValue|null} [minimum] FieldTransform minimum + * @property {google.firestore.v1beta1.IArrayValue|null} [appendMissingElements] FieldTransform appendMissingElements + * @property {google.firestore.v1beta1.IArrayValue|null} [removeAllFromArray] FieldTransform removeAllFromArray + */ + + /** + * Constructs a new FieldTransform. + * @memberof google.firestore.v1beta1.DocumentTransform + * @classdesc Represents a FieldTransform. + * @implements IFieldTransform + * @constructor + * @param {google.firestore.v1beta1.DocumentTransform.IFieldTransform=} [properties] Properties to set + */ + function FieldTransform(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldTransform fieldPath. + * @member {string} fieldPath + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.fieldPath = ""; + + /** + * FieldTransform setToServerValue. + * @member {google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue} setToServerValue + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.setToServerValue = 0; + + /** + * FieldTransform increment. + * @member {google.firestore.v1beta1.IValue|null|undefined} increment + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.increment = null; + + /** + * FieldTransform maximum. + * @member {google.firestore.v1beta1.IValue|null|undefined} maximum + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.maximum = null; + + /** + * FieldTransform minimum. + * @member {google.firestore.v1beta1.IValue|null|undefined} minimum + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.minimum = null; + + /** + * FieldTransform appendMissingElements. + * @member {google.firestore.v1beta1.IArrayValue|null|undefined} appendMissingElements + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.appendMissingElements = null; + + /** + * FieldTransform removeAllFromArray. + * @member {google.firestore.v1beta1.IArrayValue|null|undefined} removeAllFromArray + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.removeAllFromArray = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * FieldTransform transformType. + * @member {"setToServerValue"|"increment"|"maximum"|"minimum"|"appendMissingElements"|"removeAllFromArray"|undefined} transformType + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + Object.defineProperty(FieldTransform.prototype, "transformType", { + get: $util.oneOfGetter($oneOfFields = ["setToServerValue", "increment", "maximum", "minimum", "appendMissingElements", "removeAllFromArray"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * ServerValue enum. + * @name google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue + * @enum {number} + * @property {string} SERVER_VALUE_UNSPECIFIED=SERVER_VALUE_UNSPECIFIED SERVER_VALUE_UNSPECIFIED value + * @property {string} REQUEST_TIME=REQUEST_TIME REQUEST_TIME value + */ + FieldTransform.ServerValue = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SERVER_VALUE_UNSPECIFIED"] = "SERVER_VALUE_UNSPECIFIED"; + values[valuesById[1] = "REQUEST_TIME"] = "REQUEST_TIME"; + return values; + })(); + + return FieldTransform; + })(); + + return DocumentTransform; + })(); + + v1beta1.WriteResult = (function() { + + /** + * Properties of a WriteResult. + * @memberof google.firestore.v1beta1 + * @interface IWriteResult + * @property {google.protobuf.ITimestamp|null} [updateTime] WriteResult updateTime + * @property {Array.|null} [transformResults] WriteResult transformResults + */ + + /** + * Constructs a new WriteResult. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a WriteResult. + * @implements IWriteResult + * @constructor + * @param {google.firestore.v1beta1.IWriteResult=} [properties] Properties to set + */ + function WriteResult(properties) { + this.transformResults = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WriteResult updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.firestore.v1beta1.WriteResult + * @instance + */ + WriteResult.prototype.updateTime = null; + + /** + * WriteResult transformResults. + * @member {Array.} transformResults + * @memberof google.firestore.v1beta1.WriteResult + * @instance + */ + WriteResult.prototype.transformResults = $util.emptyArray; + + return WriteResult; + })(); + + v1beta1.DocumentChange = (function() { + + /** + * Properties of a DocumentChange. + * @memberof google.firestore.v1beta1 + * @interface IDocumentChange + * @property {google.firestore.v1beta1.IDocument|null} [document] DocumentChange document + * @property {Array.|null} [targetIds] DocumentChange targetIds + * @property {Array.|null} [removedTargetIds] DocumentChange removedTargetIds + */ + + /** + * Constructs a new DocumentChange. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a DocumentChange. + * @implements IDocumentChange + * @constructor + * @param {google.firestore.v1beta1.IDocumentChange=} [properties] Properties to set + */ + function DocumentChange(properties) { + this.targetIds = []; + this.removedTargetIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentChange document. + * @member {google.firestore.v1beta1.IDocument|null|undefined} document + * @memberof google.firestore.v1beta1.DocumentChange + * @instance + */ + DocumentChange.prototype.document = null; + + /** + * DocumentChange targetIds. + * @member {Array.} targetIds + * @memberof google.firestore.v1beta1.DocumentChange + * @instance + */ + DocumentChange.prototype.targetIds = $util.emptyArray; + + /** + * DocumentChange removedTargetIds. + * @member {Array.} removedTargetIds + * @memberof google.firestore.v1beta1.DocumentChange + * @instance + */ + DocumentChange.prototype.removedTargetIds = $util.emptyArray; + + return DocumentChange; + })(); + + v1beta1.DocumentDelete = (function() { + + /** + * Properties of a DocumentDelete. + * @memberof google.firestore.v1beta1 + * @interface IDocumentDelete + * @property {string|null} [document] DocumentDelete document + * @property {Array.|null} [removedTargetIds] DocumentDelete removedTargetIds + * @property {google.protobuf.ITimestamp|null} [readTime] DocumentDelete readTime + */ + + /** + * Constructs a new DocumentDelete. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a DocumentDelete. + * @implements IDocumentDelete + * @constructor + * @param {google.firestore.v1beta1.IDocumentDelete=} [properties] Properties to set + */ + function DocumentDelete(properties) { + this.removedTargetIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentDelete document. + * @member {string} document + * @memberof google.firestore.v1beta1.DocumentDelete + * @instance + */ + DocumentDelete.prototype.document = ""; + + /** + * DocumentDelete removedTargetIds. + * @member {Array.} removedTargetIds + * @memberof google.firestore.v1beta1.DocumentDelete + * @instance + */ + DocumentDelete.prototype.removedTargetIds = $util.emptyArray; + + /** + * DocumentDelete readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.DocumentDelete + * @instance + */ + DocumentDelete.prototype.readTime = null; + + return DocumentDelete; + })(); + + v1beta1.DocumentRemove = (function() { + + /** + * Properties of a DocumentRemove. + * @memberof google.firestore.v1beta1 + * @interface IDocumentRemove + * @property {string|null} [document] DocumentRemove document + * @property {Array.|null} [removedTargetIds] DocumentRemove removedTargetIds + * @property {google.protobuf.ITimestamp|null} [readTime] DocumentRemove readTime + */ + + /** + * Constructs a new DocumentRemove. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a DocumentRemove. + * @implements IDocumentRemove + * @constructor + * @param {google.firestore.v1beta1.IDocumentRemove=} [properties] Properties to set + */ + function DocumentRemove(properties) { + this.removedTargetIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentRemove document. + * @member {string} document + * @memberof google.firestore.v1beta1.DocumentRemove + * @instance + */ + DocumentRemove.prototype.document = ""; + + /** + * DocumentRemove removedTargetIds. + * @member {Array.} removedTargetIds + * @memberof google.firestore.v1beta1.DocumentRemove + * @instance + */ + DocumentRemove.prototype.removedTargetIds = $util.emptyArray; + + /** + * DocumentRemove readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.DocumentRemove + * @instance + */ + DocumentRemove.prototype.readTime = null; + + return DocumentRemove; + })(); + + v1beta1.ExistenceFilter = (function() { + + /** + * Properties of an ExistenceFilter. + * @memberof google.firestore.v1beta1 + * @interface IExistenceFilter + * @property {number|null} [targetId] ExistenceFilter targetId + * @property {number|null} [count] ExistenceFilter count + */ + + /** + * Constructs a new ExistenceFilter. + * @memberof google.firestore.v1beta1 + * @classdesc Represents an ExistenceFilter. + * @implements IExistenceFilter + * @constructor + * @param {google.firestore.v1beta1.IExistenceFilter=} [properties] Properties to set + */ + function ExistenceFilter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExistenceFilter targetId. + * @member {number} targetId + * @memberof google.firestore.v1beta1.ExistenceFilter + * @instance + */ + ExistenceFilter.prototype.targetId = 0; + + /** + * ExistenceFilter count. + * @member {number} count + * @memberof google.firestore.v1beta1.ExistenceFilter + * @instance + */ + ExistenceFilter.prototype.count = 0; + + return ExistenceFilter; + })(); + + return v1beta1; + })(); + + return firestore; + })(); + + google.api = (function() { + + /** + * Namespace api. + * @memberof google + * @namespace + */ + var api = {}; + + api.Http = (function() { + + /** + * Properties of a Http. + * @memberof google.api + * @interface IHttp + * @property {Array.|null} [rules] Http rules + */ + + /** + * Constructs a new Http. + * @memberof google.api + * @classdesc Represents a Http. + * @implements IHttp + * @constructor + * @param {google.api.IHttp=} [properties] Properties to set + */ + function Http(properties) { + this.rules = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Http rules. + * @member {Array.} rules + * @memberof google.api.Http + * @instance + */ + Http.prototype.rules = $util.emptyArray; + + return Http; + })(); + + api.HttpRule = (function() { + + /** + * Properties of a HttpRule. + * @memberof google.api + * @interface IHttpRule + * @property {string|null} [get] HttpRule get + * @property {string|null} [put] HttpRule put + * @property {string|null} [post] HttpRule post + * @property {string|null} ["delete"] HttpRule delete + * @property {string|null} [patch] HttpRule patch + * @property {google.api.ICustomHttpPattern|null} [custom] HttpRule custom + * @property {string|null} [selector] HttpRule selector + * @property {string|null} [body] HttpRule body + * @property {Array.|null} [additionalBindings] HttpRule additionalBindings + */ + + /** + * Constructs a new HttpRule. + * @memberof google.api + * @classdesc Represents a HttpRule. + * @implements IHttpRule + * @constructor + * @param {google.api.IHttpRule=} [properties] Properties to set + */ + function HttpRule(properties) { + this.additionalBindings = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * HttpRule get. + * @member {string} get + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.get = ""; + + /** + * HttpRule put. + * @member {string} put + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.put = ""; + + /** + * HttpRule post. + * @member {string} post + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.post = ""; + + /** + * HttpRule delete. + * @member {string} delete + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype["delete"] = ""; + + /** + * HttpRule patch. + * @member {string} patch + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.patch = ""; + + /** + * HttpRule custom. + * @member {google.api.ICustomHttpPattern|null|undefined} custom + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.custom = null; + + /** + * HttpRule selector. + * @member {string} selector + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.selector = ""; + + /** + * HttpRule body. + * @member {string} body + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.body = ""; + + /** + * HttpRule additionalBindings. + * @member {Array.} additionalBindings + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.additionalBindings = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * HttpRule pattern. + * @member {"get"|"put"|"post"|"delete"|"patch"|"custom"|undefined} pattern + * @memberof google.api.HttpRule + * @instance + */ + Object.defineProperty(HttpRule.prototype, "pattern", { + get: $util.oneOfGetter($oneOfFields = ["get", "put", "post", "delete", "patch", "custom"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return HttpRule; + })(); + + api.CustomHttpPattern = (function() { + + /** + * Properties of a CustomHttpPattern. + * @memberof google.api + * @interface ICustomHttpPattern + * @property {string|null} [kind] CustomHttpPattern kind + * @property {string|null} [path] CustomHttpPattern path + */ + + /** + * Constructs a new CustomHttpPattern. + * @memberof google.api + * @classdesc Represents a CustomHttpPattern. + * @implements ICustomHttpPattern + * @constructor + * @param {google.api.ICustomHttpPattern=} [properties] Properties to set + */ + function CustomHttpPattern(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CustomHttpPattern kind. + * @member {string} kind + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.kind = ""; + + /** + * CustomHttpPattern path. + * @member {string} path + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.path = ""; + + return CustomHttpPattern; + })(); + + /** + * FieldBehavior enum. + * @name google.api.FieldBehavior + * @enum {number} + * @property {string} FIELD_BEHAVIOR_UNSPECIFIED=FIELD_BEHAVIOR_UNSPECIFIED FIELD_BEHAVIOR_UNSPECIFIED value + * @property {string} OPTIONAL=OPTIONAL OPTIONAL value + * @property {string} REQUIRED=REQUIRED REQUIRED value + * @property {string} OUTPUT_ONLY=OUTPUT_ONLY OUTPUT_ONLY value + * @property {string} INPUT_ONLY=INPUT_ONLY INPUT_ONLY value + * @property {string} IMMUTABLE=IMMUTABLE IMMUTABLE value + */ + api.FieldBehavior = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "FIELD_BEHAVIOR_UNSPECIFIED"] = "FIELD_BEHAVIOR_UNSPECIFIED"; + values[valuesById[1] = "OPTIONAL"] = "OPTIONAL"; + values[valuesById[2] = "REQUIRED"] = "REQUIRED"; + values[valuesById[3] = "OUTPUT_ONLY"] = "OUTPUT_ONLY"; + values[valuesById[4] = "INPUT_ONLY"] = "INPUT_ONLY"; + values[valuesById[5] = "IMMUTABLE"] = "IMMUTABLE"; + return values; + })(); + + api.ResourceDescriptor = (function() { + + /** + * Properties of a ResourceDescriptor. + * @memberof google.api + * @interface IResourceDescriptor + * @property {string|null} [type] ResourceDescriptor type + * @property {Array.|null} [pattern] ResourceDescriptor pattern + * @property {string|null} [nameField] ResourceDescriptor nameField + * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history + * @property {string|null} [plural] ResourceDescriptor plural + * @property {string|null} [singular] ResourceDescriptor singular + */ + + /** + * Constructs a new ResourceDescriptor. + * @memberof google.api + * @classdesc Represents a ResourceDescriptor. + * @implements IResourceDescriptor + * @constructor + * @param {google.api.IResourceDescriptor=} [properties] Properties to set + */ + function ResourceDescriptor(properties) { + this.pattern = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResourceDescriptor type. + * @member {string} type + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.type = ""; + + /** + * ResourceDescriptor pattern. + * @member {Array.} pattern + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.pattern = $util.emptyArray; + + /** + * ResourceDescriptor nameField. + * @member {string} nameField + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.nameField = ""; + + /** + * ResourceDescriptor history. + * @member {google.api.ResourceDescriptor.History} history + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.history = 0; + + /** + * ResourceDescriptor plural. + * @member {string} plural + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.plural = ""; + + /** + * ResourceDescriptor singular. + * @member {string} singular + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.singular = ""; + + /** + * History enum. + * @name google.api.ResourceDescriptor.History + * @enum {number} + * @property {string} HISTORY_UNSPECIFIED=HISTORY_UNSPECIFIED HISTORY_UNSPECIFIED value + * @property {string} ORIGINALLY_SINGLE_PATTERN=ORIGINALLY_SINGLE_PATTERN ORIGINALLY_SINGLE_PATTERN value + * @property {string} FUTURE_MULTI_PATTERN=FUTURE_MULTI_PATTERN FUTURE_MULTI_PATTERN value + */ + ResourceDescriptor.History = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "HISTORY_UNSPECIFIED"] = "HISTORY_UNSPECIFIED"; + values[valuesById[1] = "ORIGINALLY_SINGLE_PATTERN"] = "ORIGINALLY_SINGLE_PATTERN"; + values[valuesById[2] = "FUTURE_MULTI_PATTERN"] = "FUTURE_MULTI_PATTERN"; + return values; + })(); + + return ResourceDescriptor; + })(); + + api.ResourceReference = (function() { + + /** + * Properties of a ResourceReference. + * @memberof google.api + * @interface IResourceReference + * @property {string|null} [type] ResourceReference type + * @property {string|null} [childType] ResourceReference childType + */ + + /** + * Constructs a new ResourceReference. + * @memberof google.api + * @classdesc Represents a ResourceReference. + * @implements IResourceReference + * @constructor + * @param {google.api.IResourceReference=} [properties] Properties to set + */ + function ResourceReference(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResourceReference type. + * @member {string} type + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.type = ""; + + /** + * ResourceReference childType. + * @member {string} childType + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.childType = ""; + + return ResourceReference; + })(); + + return api; + })(); + + google.type = (function() { + + /** + * Namespace type. + * @memberof google + * @namespace + */ + var type = {}; + + type.LatLng = (function() { + + /** + * Properties of a LatLng. + * @memberof google.type + * @interface ILatLng + * @property {number|null} [latitude] LatLng latitude + * @property {number|null} [longitude] LatLng longitude + */ + + /** + * Constructs a new LatLng. + * @memberof google.type + * @classdesc Represents a LatLng. + * @implements ILatLng + * @constructor + * @param {google.type.ILatLng=} [properties] Properties to set + */ + function LatLng(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LatLng latitude. + * @member {number} latitude + * @memberof google.type.LatLng + * @instance + */ + LatLng.prototype.latitude = 0; + + /** + * LatLng longitude. + * @member {number} longitude + * @memberof google.type.LatLng + * @instance + */ + LatLng.prototype.longitude = 0; + + return LatLng; + })(); + + return type; + })(); + + google.rpc = (function() { + + /** + * Namespace rpc. + * @memberof google + * @namespace + */ + var rpc = {}; + + rpc.Status = (function() { + + /** + * Properties of a Status. + * @memberof google.rpc + * @interface IStatus + * @property {number|null} [code] Status code + * @property {string|null} [message] Status message + * @property {Array.|null} [details] Status details + */ + + /** + * Constructs a new Status. + * @memberof google.rpc + * @classdesc Represents a Status. + * @implements IStatus + * @constructor + * @param {google.rpc.IStatus=} [properties] Properties to set + */ + function Status(properties) { + this.details = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Status code. + * @member {number} code + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.code = 0; + + /** + * Status message. + * @member {string} message + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.message = ""; + + /** + * Status details. + * @member {Array.} details + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.details = $util.emptyArray; + + return Status; + })(); + + return rpc; + })(); + + google.longrunning = (function() { + + /** + * Namespace longrunning. + * @memberof google + * @namespace + */ + var longrunning = {}; + + longrunning.Operations = (function() { + + /** + * Constructs a new Operations service. + * @memberof google.longrunning + * @classdesc Represents an Operations + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function Operations(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (Operations.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Operations; + + /** + * Callback as used by {@link google.longrunning.Operations#listOperations}. + * @memberof google.longrunning.Operations + * @typedef ListOperationsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.ListOperationsResponse} [response] ListOperationsResponse + */ + + /** + * Calls ListOperations. + * @function listOperations + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object + * @param {google.longrunning.Operations.ListOperationsCallback} callback Node-style callback called with the error, if any, and ListOperationsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.listOperations = function listOperations(request, callback) { + return this.rpcCall(listOperations, $root.google.longrunning.ListOperationsRequest, $root.google.longrunning.ListOperationsResponse, request, callback); + }, "name", { value: "ListOperations" }); + + /** + * Calls ListOperations. + * @function listOperations + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#getOperation}. + * @memberof google.longrunning.Operations + * @typedef GetOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls GetOperation. + * @function getOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object + * @param {google.longrunning.Operations.GetOperationCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.getOperation = function getOperation(request, callback) { + return this.rpcCall(getOperation, $root.google.longrunning.GetOperationRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "GetOperation" }); + + /** + * Calls GetOperation. + * @function getOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#deleteOperation}. + * @memberof google.longrunning.Operations + * @typedef DeleteOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteOperation. + * @function deleteOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object + * @param {google.longrunning.Operations.DeleteOperationCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.deleteOperation = function deleteOperation(request, callback) { + return this.rpcCall(deleteOperation, $root.google.longrunning.DeleteOperationRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteOperation" }); + + /** + * Calls DeleteOperation. + * @function deleteOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#cancelOperation}. + * @memberof google.longrunning.Operations + * @typedef CancelOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls CancelOperation. + * @function cancelOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object + * @param {google.longrunning.Operations.CancelOperationCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.cancelOperation = function cancelOperation(request, callback) { + return this.rpcCall(cancelOperation, $root.google.longrunning.CancelOperationRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "CancelOperation" }); + + /** + * Calls CancelOperation. + * @function cancelOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#waitOperation}. + * @memberof google.longrunning.Operations + * @typedef WaitOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls WaitOperation. + * @function waitOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object + * @param {google.longrunning.Operations.WaitOperationCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.waitOperation = function waitOperation(request, callback) { + return this.rpcCall(waitOperation, $root.google.longrunning.WaitOperationRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "WaitOperation" }); + + /** + * Calls WaitOperation. + * @function waitOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return Operations; + })(); + + longrunning.Operation = (function() { + + /** + * Properties of an Operation. + * @memberof google.longrunning + * @interface IOperation + * @property {string|null} [name] Operation name + * @property {google.protobuf.IAny|null} [metadata] Operation metadata + * @property {boolean|null} [done] Operation done + * @property {google.rpc.IStatus|null} [error] Operation error + * @property {google.protobuf.IAny|null} [response] Operation response + */ + + /** + * Constructs a new Operation. + * @memberof google.longrunning + * @classdesc Represents an Operation. + * @implements IOperation + * @constructor + * @param {google.longrunning.IOperation=} [properties] Properties to set + */ + function Operation(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Operation name. + * @member {string} name + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.name = ""; + + /** + * Operation metadata. + * @member {google.protobuf.IAny|null|undefined} metadata + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.metadata = null; + + /** + * Operation done. + * @member {boolean} done + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.done = false; + + /** + * Operation error. + * @member {google.rpc.IStatus|null|undefined} error + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.error = null; + + /** + * Operation response. + * @member {google.protobuf.IAny|null|undefined} response + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.response = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Operation result. + * @member {"error"|"response"|undefined} result + * @memberof google.longrunning.Operation + * @instance + */ + Object.defineProperty(Operation.prototype, "result", { + get: $util.oneOfGetter($oneOfFields = ["error", "response"]), + set: $util.oneOfSetter($oneOfFields) + }); + + return Operation; + })(); + + longrunning.GetOperationRequest = (function() { + + /** + * Properties of a GetOperationRequest. + * @memberof google.longrunning + * @interface IGetOperationRequest + * @property {string|null} [name] GetOperationRequest name + */ + + /** + * Constructs a new GetOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a GetOperationRequest. + * @implements IGetOperationRequest + * @constructor + * @param {google.longrunning.IGetOperationRequest=} [properties] Properties to set + */ + function GetOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetOperationRequest name. + * @member {string} name + * @memberof google.longrunning.GetOperationRequest + * @instance + */ + GetOperationRequest.prototype.name = ""; + + return GetOperationRequest; + })(); + + longrunning.ListOperationsRequest = (function() { + + /** + * Properties of a ListOperationsRequest. + * @memberof google.longrunning + * @interface IListOperationsRequest + * @property {string|null} [name] ListOperationsRequest name + * @property {string|null} [filter] ListOperationsRequest filter + * @property {number|null} [pageSize] ListOperationsRequest pageSize + * @property {string|null} [pageToken] ListOperationsRequest pageToken + */ + + /** + * Constructs a new ListOperationsRequest. + * @memberof google.longrunning + * @classdesc Represents a ListOperationsRequest. + * @implements IListOperationsRequest + * @constructor + * @param {google.longrunning.IListOperationsRequest=} [properties] Properties to set + */ + function ListOperationsRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListOperationsRequest name. + * @member {string} name + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.name = ""; + + /** + * ListOperationsRequest filter. + * @member {string} filter + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.filter = ""; + + /** + * ListOperationsRequest pageSize. + * @member {number} pageSize + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.pageSize = 0; + + /** + * ListOperationsRequest pageToken. + * @member {string} pageToken + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.pageToken = ""; + + return ListOperationsRequest; + })(); + + longrunning.ListOperationsResponse = (function() { + + /** + * Properties of a ListOperationsResponse. + * @memberof google.longrunning + * @interface IListOperationsResponse + * @property {Array.|null} [operations] ListOperationsResponse operations + * @property {string|null} [nextPageToken] ListOperationsResponse nextPageToken + */ + + /** + * Constructs a new ListOperationsResponse. + * @memberof google.longrunning + * @classdesc Represents a ListOperationsResponse. + * @implements IListOperationsResponse + * @constructor + * @param {google.longrunning.IListOperationsResponse=} [properties] Properties to set + */ + function ListOperationsResponse(properties) { + this.operations = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListOperationsResponse operations. + * @member {Array.} operations + * @memberof google.longrunning.ListOperationsResponse + * @instance + */ + ListOperationsResponse.prototype.operations = $util.emptyArray; + + /** + * ListOperationsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.longrunning.ListOperationsResponse + * @instance + */ + ListOperationsResponse.prototype.nextPageToken = ""; + + return ListOperationsResponse; + })(); + + longrunning.CancelOperationRequest = (function() { + + /** + * Properties of a CancelOperationRequest. + * @memberof google.longrunning + * @interface ICancelOperationRequest + * @property {string|null} [name] CancelOperationRequest name + */ + + /** + * Constructs a new CancelOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a CancelOperationRequest. + * @implements ICancelOperationRequest + * @constructor + * @param {google.longrunning.ICancelOperationRequest=} [properties] Properties to set + */ + function CancelOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CancelOperationRequest name. + * @member {string} name + * @memberof google.longrunning.CancelOperationRequest + * @instance + */ + CancelOperationRequest.prototype.name = ""; + + return CancelOperationRequest; + })(); + + longrunning.DeleteOperationRequest = (function() { + + /** + * Properties of a DeleteOperationRequest. + * @memberof google.longrunning + * @interface IDeleteOperationRequest + * @property {string|null} [name] DeleteOperationRequest name + */ + + /** + * Constructs a new DeleteOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a DeleteOperationRequest. + * @implements IDeleteOperationRequest + * @constructor + * @param {google.longrunning.IDeleteOperationRequest=} [properties] Properties to set + */ + function DeleteOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteOperationRequest name. + * @member {string} name + * @memberof google.longrunning.DeleteOperationRequest + * @instance + */ + DeleteOperationRequest.prototype.name = ""; + + return DeleteOperationRequest; + })(); + + longrunning.WaitOperationRequest = (function() { + + /** + * Properties of a WaitOperationRequest. + * @memberof google.longrunning + * @interface IWaitOperationRequest + * @property {string|null} [name] WaitOperationRequest name + * @property {google.protobuf.IDuration|null} [timeout] WaitOperationRequest timeout + */ + + /** + * Constructs a new WaitOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a WaitOperationRequest. + * @implements IWaitOperationRequest + * @constructor + * @param {google.longrunning.IWaitOperationRequest=} [properties] Properties to set + */ + function WaitOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WaitOperationRequest name. + * @member {string} name + * @memberof google.longrunning.WaitOperationRequest + * @instance + */ + WaitOperationRequest.prototype.name = ""; + + /** + * WaitOperationRequest timeout. + * @member {google.protobuf.IDuration|null|undefined} timeout + * @memberof google.longrunning.WaitOperationRequest + * @instance + */ + WaitOperationRequest.prototype.timeout = null; + + return WaitOperationRequest; + })(); + + longrunning.OperationInfo = (function() { + + /** + * Properties of an OperationInfo. + * @memberof google.longrunning + * @interface IOperationInfo + * @property {string|null} [responseType] OperationInfo responseType + * @property {string|null} [metadataType] OperationInfo metadataType + */ + + /** + * Constructs a new OperationInfo. + * @memberof google.longrunning + * @classdesc Represents an OperationInfo. + * @implements IOperationInfo + * @constructor + * @param {google.longrunning.IOperationInfo=} [properties] Properties to set + */ + function OperationInfo(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OperationInfo responseType. + * @member {string} responseType + * @memberof google.longrunning.OperationInfo + * @instance + */ + OperationInfo.prototype.responseType = ""; + + /** + * OperationInfo metadataType. + * @member {string} metadataType + * @memberof google.longrunning.OperationInfo + * @instance + */ + OperationInfo.prototype.metadataType = ""; + + return OperationInfo; + })(); + + return longrunning; + })(); + + return google; +})(); diff --git a/dev/protos/google/api/client.proto b/dev/protos/google/api/client.proto new file mode 100644 index 000000000..56f8664aa --- /dev/null +++ b/dev/protos/google/api/client.proto @@ -0,0 +1,100 @@ +// Copyright 2019 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. +// + +syntax = "proto3"; + +package google.api; + +import "google/protobuf/descriptor.proto"; + +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "ClientProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +extend google.protobuf.MethodOptions { + // A definition of a client library method signature. + // + // In client libraries, each proto RPC corresponds to one or more methods + // which the end user is able to call, and calls the underlying RPC. + // Normally, this method receives a single argument (a struct or instance + // corresponding to the RPC request object). Defining this field will + // add one or more overloads providing flattened or simpler method signatures + // in some languages. + // + // The fields on the method signature are provided as a comma-separated + // string. + // + // For example, the proto RPC and annotation: + // + // rpc CreateSubscription(CreateSubscriptionRequest) + // returns (Subscription) { + // option (google.api.method_signature) = "name,topic"; + // } + // + // Would add the following Java overload (in addition to the method accepting + // the request object): + // + // public final Subscription createSubscription(String name, String topic) + // + // The following backwards-compatibility guidelines apply: + // + // * Adding this annotation to an unannotated method is backwards + // compatible. + // * Adding this annotation to a method which already has existing + // method signature annotations is backwards compatible if and only if + // the new method signature annotation is last in the sequence. + // * Modifying or removing an existing method signature annotation is + // a breaking change. + // * Re-ordering existing method signature annotations is a breaking + // change. + repeated string method_signature = 1051; +} + +extend google.protobuf.ServiceOptions { + // The hostname for this service. + // This should be specified with no prefix or protocol. + // + // Example: + // + // service Foo { + // option (google.api.default_host) = "foo.googleapi.com"; + // ... + // } + string default_host = 1049; + + // OAuth scopes needed for the client. + // + // Example: + // + // service Foo { + // option (google.api.oauth_scopes) = \ + // "https://www.googleapis.com/auth/cloud-platform"; + // ... + // } + // + // If there is more than one scope, use a comma-separated string: + // + // Example: + // + // service Foo { + // option (google.api.oauth_scopes) = \ + // "https://www.googleapis.com/auth/cloud-platform," + // "https://www.googleapis.com/auth/monitoring"; + // ... + // } + string oauth_scopes = 1050; +} diff --git a/dev/protos/google/api/field_behavior.proto b/dev/protos/google/api/field_behavior.proto new file mode 100644 index 000000000..eb7f78ef1 --- /dev/null +++ b/dev/protos/google/api/field_behavior.proto @@ -0,0 +1,79 @@ +// Copyright 2019 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. +// + +syntax = "proto3"; + +package google.api; + +import "google/protobuf/descriptor.proto"; + +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "FieldBehaviorProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +extend google.protobuf.FieldOptions { + // A designation of a specific field behavior (required, output only, etc.) + // in protobuf messages. + // + // Examples: + // + // string name = 1 [(google.api.field_behavior) = REQUIRED]; + // State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + // google.protobuf.Duration ttl = 1 + // [(google.api.field_behavior) = INPUT_ONLY]; + // google.protobuf.Timestamp expire_time = 1 + // [(google.api.field_behavior) = OUTPUT_ONLY, + // (google.api.field_behavior) = IMMUTABLE]; + repeated google.api.FieldBehavior field_behavior = 1052; +} + +// An indicator of the behavior of a given field (for example, that a field +// is required in requests, or given as output but ignored as input). +// This **does not** change the behavior in protocol buffers itself; it only +// denotes the behavior and may affect how API tooling handles the field. +// +// Note: This enum **may** receive new values in the future. +enum FieldBehavior { + // Conventional default for enums. Do not use this. + FIELD_BEHAVIOR_UNSPECIFIED = 0; + + // Specifically denotes a field as optional. + // While all fields in protocol buffers are optional, this may be specified + // for emphasis if appropriate. + OPTIONAL = 1; + + // Denotes a field as required. + // This indicates that the field **must** be provided as part of the request, + // and failure to do so will cause an error (usually `INVALID_ARGUMENT`). + REQUIRED = 2; + + // Denotes a field as output only. + // This indicates that the field is provided in responses, but including the + // field in a request does nothing (the server *must* ignore it and + // *must not* throw an error as a result of the field's presence). + OUTPUT_ONLY = 3; + + // Denotes a field as input only. + // This indicates that the field is provided in requests, and the + // corresponding field is not included in output. + INPUT_ONLY = 4; + + // Denotes a field as immutable. + // This indicates that the field may be set once in a request to create a + // resource, but may not be changed thereafter. + IMMUTABLE = 5; +} diff --git a/dev/protos/google/api/resource.proto b/dev/protos/google/api/resource.proto new file mode 100644 index 000000000..fdb7001ad --- /dev/null +++ b/dev/protos/google/api/resource.proto @@ -0,0 +1,264 @@ +// Copyright 2019 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. +// + +syntax = "proto3"; + +package google.api; + +import "google/protobuf/descriptor.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "ResourceProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +extend google.protobuf.FieldOptions { + // An annotation that describes a resource reference, see + // [ResourceReference][]. + google.api.ResourceReference resource_reference = 1055; +} + +extend google.protobuf.FileOptions { + // An annotation that describes a resource definition without a corresponding + // message; see [ResourceDescriptor][]. + repeated google.api.ResourceDescriptor resource_definition = 1053; +} + +extend google.protobuf.MessageOptions { + // An annotation that describes a resource definition, see + // [ResourceDescriptor][]. + google.api.ResourceDescriptor resource = 1053; +} + +// A simple descriptor of a resource type. +// +// ResourceDescriptor annotates a resource message (either by means of a +// protobuf annotation or use in the service config), and associates the +// resource's schema, the resource type, and the pattern of the resource name. +// +// Example: +// +// message Topic { +// // Indicates this message defines a resource schema. +// // Declares the resource type in the format of {service}/{kind}. +// // For Kubernetes resources, the format is {api group}/{kind}. +// option (google.api.resource) = { +// type: "pubsub.googleapis.com/Topic" +// name_descriptor: { +// pattern: "projects/{project}/topics/{topic}" +// parent_type: "cloudresourcemanager.googleapis.com/Project" +// parent_name_extractor: "projects/{project}" +// } +// }; +// } +// +// The ResourceDescriptor Yaml config will look like: +// +// resources: +// - type: "pubsub.googleapis.com/Topic" +// name_descriptor: +// - pattern: "projects/{project}/topics/{topic}" +// parent_type: "cloudresourcemanager.googleapis.com/Project" +// parent_name_extractor: "projects/{project}" +// +// Sometimes, resources have multiple patterns, typically because they can +// live under multiple parents. +// +// Example: +// +// message LogEntry { +// option (google.api.resource) = { +// type: "logging.googleapis.com/LogEntry" +// name_descriptor: { +// pattern: "projects/{project}/logs/{log}" +// parent_type: "cloudresourcemanager.googleapis.com/Project" +// parent_name_extractor: "projects/{project}" +// } +// name_descriptor: { +// pattern: "folders/{folder}/logs/{log}" +// parent_type: "cloudresourcemanager.googleapis.com/Folder" +// parent_name_extractor: "folders/{folder}" +// } +// name_descriptor: { +// pattern: "organizations/{organization}/logs/{log}" +// parent_type: "cloudresourcemanager.googleapis.com/Organization" +// parent_name_extractor: "organizations/{organization}" +// } +// name_descriptor: { +// pattern: "billingAccounts/{billing_account}/logs/{log}" +// parent_type: "billing.googleapis.com/BillingAccount" +// parent_name_extractor: "billingAccounts/{billing_account}" +// } +// }; +// } +// +// The ResourceDescriptor Yaml config will look like: +// +// resources: +// - type: 'logging.googleapis.com/LogEntry' +// name_descriptor: +// - pattern: "projects/{project}/logs/{log}" +// parent_type: "cloudresourcemanager.googleapis.com/Project" +// parent_name_extractor: "projects/{project}" +// - pattern: "folders/{folder}/logs/{log}" +// parent_type: "cloudresourcemanager.googleapis.com/Folder" +// parent_name_extractor: "folders/{folder}" +// - pattern: "organizations/{organization}/logs/{log}" +// parent_type: "cloudresourcemanager.googleapis.com/Organization" +// parent_name_extractor: "organizations/{organization}" +// - pattern: "billingAccounts/{billing_account}/logs/{log}" +// parent_type: "billing.googleapis.com/BillingAccount" +// parent_name_extractor: "billingAccounts/{billing_account}" +// +// For flexible resources, the resource name doesn't contain parent names, but +// the resource itself has parents for policy evaluation. +// +// Example: +// +// message Shelf { +// option (google.api.resource) = { +// type: "library.googleapis.com/Shelf" +// name_descriptor: { +// pattern: "shelves/{shelf}" +// parent_type: "cloudresourcemanager.googleapis.com/Project" +// } +// name_descriptor: { +// pattern: "shelves/{shelf}" +// parent_type: "cloudresourcemanager.googleapis.com/Folder" +// } +// }; +// } +// +// The ResourceDescriptor Yaml config will look like: +// +// resources: +// - type: 'library.googleapis.com/Shelf' +// name_descriptor: +// - pattern: "shelves/{shelf}" +// parent_type: "cloudresourcemanager.googleapis.com/Project" +// - pattern: "shelves/{shelf}" +// parent_type: "cloudresourcemanager.googleapis.com/Folder" +message ResourceDescriptor { + // A description of the historical or future-looking state of the + // resource pattern. + enum History { + // The "unset" value. + HISTORY_UNSPECIFIED = 0; + + // The resource originally had one pattern and launched as such, and + // additional patterns were added later. + ORIGINALLY_SINGLE_PATTERN = 1; + + // The resource has one pattern, but the API owner expects to add more + // later. (This is the inverse of ORIGINALLY_SINGLE_PATTERN, and prevents + // that from being necessary once there are multiple patterns.) + FUTURE_MULTI_PATTERN = 2; + } + + // The resource type. It must be in the format of + // {service_name}/{resource_type_kind}. The `resource_type_kind` must be + // singular and must not include version numbers. + // + // Example: `storage.googleapis.com/Bucket` + // + // The value of the resource_type_kind must follow the regular expression + // /[A-Za-z][a-zA-Z0-9]+/. It should start with an upper case character and + // should use PascalCase (UpperCamelCase). The maximum number of + // characters allowed for the `resource_type_kind` is 100. + string type = 1; + + // Optional. The relative resource name pattern associated with this resource + // type. The DNS prefix of the full resource name shouldn't be specified here. + // + // The path pattern must follow the syntax, which aligns with HTTP binding + // syntax: + // + // Template = Segment { "/" Segment } ; + // Segment = LITERAL | Variable ; + // Variable = "{" LITERAL "}" ; + // + // Examples: + // + // - "projects/{project}/topics/{topic}" + // - "projects/{project}/knowledgeBases/{knowledge_base}" + // + // The components in braces correspond to the IDs for each resource in the + // hierarchy. It is expected that, if multiple patterns are provided, + // the same component name (e.g. "project") refers to IDs of the same + // type of resource. + repeated string pattern = 2; + + // Optional. The field on the resource that designates the resource name + // field. If omitted, this is assumed to be "name". + string name_field = 3; + + // Optional. The historical or future-looking state of the resource pattern. + // + // Example: + // + // // The InspectTemplate message originally only supported resource + // // names with organization, and project was added later. + // message InspectTemplate { + // option (google.api.resource) = { + // type: "dlp.googleapis.com/InspectTemplate" + // pattern: + // "organizations/{organization}/inspectTemplates/{inspect_template}" + // pattern: "projects/{project}/inspectTemplates/{inspect_template}" + // history: ORIGINALLY_SINGLE_PATTERN + // }; + // } + History history = 4; + + // The plural name used in the resource name, such as 'projects' for + // the name of 'projects/{project}'. It is the same concept of the `plural` + // field in k8s CRD spec + // https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ + string plural = 5; + + // The same concept of the `singular` field in k8s CRD spec + // https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ + // Such as "project" for the `resourcemanager.googleapis.com/Project` type. + string singular = 6; +} + +// Defines a proto annotation that describes a string field that refers to +// an API resource. +message ResourceReference { + // The resource type that the annotated field references. + // + // Example: + // + // message Subscription { + // string topic = 2 [(google.api.resource_reference) = { + // type: "pubsub.googleapis.com/Topic" + // }]; + // } + string type = 1; + + // The resource type of a child collection that the annotated field + // references. This is useful for annotating the `parent` field that + // doesn't have a fixed resource type. + // + // Example: + // + // message ListLogEntriesRequest { + // string parent = 1 [(google.api.resource_reference) = { + // child_type: "logging.googleapis.com/LogEntry" + // }; + // } + string child_type = 2; +} diff --git a/dev/protos/google/firestore/admin/v1/field.proto b/dev/protos/google/firestore/admin/v1/field.proto index 14891596d..48430d87c 100644 --- a/dev/protos/google/firestore/admin/v1/field.proto +++ b/dev/protos/google/firestore/admin/v1/field.proto @@ -17,6 +17,7 @@ syntax = "proto3"; package google.firestore.admin.v1; +import "google/api/resource.proto"; import "google/firestore/admin/v1/index.proto"; import "google/api/annotations.proto"; @@ -33,6 +34,11 @@ option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; // Fields are grouped by their "Collection Group", which represent all // collections in the database with the same id. message Field { + option (google.api.resource) = { + type: "firestore.googleapis.com/Field" + pattern: "projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}" + }; + // The index configuration for this field. message IndexConfig { // The indexes supported for this field. diff --git a/dev/protos/google/firestore/admin/v1/firestore_admin.proto b/dev/protos/google/firestore/admin/v1/firestore_admin.proto index 234827bef..75dd2d311 100644 --- a/dev/protos/google/firestore/admin/v1/firestore_admin.proto +++ b/dev/protos/google/firestore/admin/v1/firestore_admin.proto @@ -18,12 +18,14 @@ syntax = "proto3"; package google.firestore.admin.v1; import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; import "google/firestore/admin/v1/field.proto"; import "google/firestore/admin/v1/index.proto"; import "google/longrunning/operations.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/field_mask.proto"; -import "google/api/client.proto"; option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; option go_package = "google.golang.org/genproto/googleapis/firestore/admin/v1;admin"; @@ -32,6 +34,14 @@ option java_outer_classname = "FirestoreAdminProto"; option java_package = "com.google.firestore.admin.v1"; option objc_class_prefix = "GCFS"; option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option (google.api.resource_definition) = { + type: "firestore.googleapis.com/Database" + pattern: "projects/{project}/databases/{database}" +}; +option (google.api.resource_definition) = { + type: "firestore.googleapis.com/CollectionGroup" + pattern: "projects/{project}/databases/{database}/collectionGroups/{collection}" +}; // Operations are created by service `FirestoreAdmin`, but are accessed via // service `google.longrunning.Operations`. @@ -49,6 +59,11 @@ service FirestoreAdmin { post: "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes" body: "index" }; + option (google.api.method_signature) = "parent,index"; + option (google.longrunning.operation_info) = { + response_type: "Index" + metadata_type: "IndexOperationMetadata" + }; } // Lists composite indexes. @@ -56,6 +71,7 @@ service FirestoreAdmin { option (google.api.http) = { get: "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes" }; + option (google.api.method_signature) = "parent"; } // Gets a composite index. @@ -63,6 +79,7 @@ service FirestoreAdmin { option (google.api.http) = { get: "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}" }; + option (google.api.method_signature) = "name"; } // Deletes a composite index. @@ -70,6 +87,7 @@ service FirestoreAdmin { option (google.api.http) = { delete: "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}" }; + option (google.api.method_signature) = "name"; } // Gets the metadata and configuration for a Field. @@ -77,6 +95,7 @@ service FirestoreAdmin { option (google.api.http) = { get: "/v1/{name=projects/*/databases/*/collectionGroups/*/fields/*}" }; + option (google.api.method_signature) = "name"; } // Updates a field configuration. Currently, field updates apply only to @@ -97,6 +116,11 @@ service FirestoreAdmin { patch: "/v1/{field.name=projects/*/databases/*/collectionGroups/*/fields/*}" body: "field" }; + option (google.api.method_signature) = "field"; + option (google.longrunning.operation_info) = { + response_type: "Field" + metadata_type: "FieldOperationMetadata" + }; } // Lists the field configuration and metadata for this database. @@ -109,6 +133,7 @@ service FirestoreAdmin { option (google.api.http) = { get: "/v1/{parent=projects/*/databases/*/collectionGroups/*}/fields" }; + option (google.api.method_signature) = "parent"; } // Exports a copy of all or a subset of documents from Google Cloud Firestore @@ -124,6 +149,11 @@ service FirestoreAdmin { post: "/v1/{name=projects/*/databases/*}:exportDocuments" body: "*" }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "ExportDocumentsResponse" + metadata_type: "ExportDocumentsMetadata" + }; } // Imports documents into Google Cloud Firestore. Existing documents with the @@ -136,24 +166,39 @@ service FirestoreAdmin { post: "/v1/{name=projects/*/databases/*}:importDocuments" body: "*" }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "ImportDocumentsMetadata" + }; } } // The request for [FirestoreAdmin.CreateIndex][google.firestore.admin.v1.FirestoreAdmin.CreateIndex]. message CreateIndexRequest { - // A parent name of the form + // Required. A parent name of the form // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - string parent = 1; - - // The composite index to create. - Index index = 2; + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/CollectionGroup" + } + ]; + + // Required. The composite index to create. + Index index = 2 [(google.api.field_behavior) = REQUIRED]; } // The request for [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes]. message ListIndexesRequest { - // A parent name of the form + // Required. A parent name of the form // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - string parent = 1; + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/CollectionGroup" + } + ]; // The filter to apply to list results. string filter = 2; @@ -179,22 +224,32 @@ message ListIndexesResponse { // The request for [FirestoreAdmin.GetIndex][google.firestore.admin.v1.FirestoreAdmin.GetIndex]. message GetIndexRequest { - // A name of the form + // Required. A name of the form // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` - string name = 1; + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Index" + } + ]; } // The request for [FirestoreAdmin.DeleteIndex][google.firestore.admin.v1.FirestoreAdmin.DeleteIndex]. message DeleteIndexRequest { - // A name of the form + // Required. A name of the form // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` - string name = 1; + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Index" + } + ]; } // The request for [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField]. message UpdateFieldRequest { - // The field to be updated. - Field field = 1; + // Required. The field to be updated. + Field field = 1 [(google.api.field_behavior) = REQUIRED]; // A mask, relative to the field. If specified, only configuration specified // by this field_mask will be updated in the field. @@ -203,16 +258,26 @@ message UpdateFieldRequest { // The request for [FirestoreAdmin.GetField][google.firestore.admin.v1.FirestoreAdmin.GetField]. message GetFieldRequest { - // A name of the form + // Required. A name of the form // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}` - string name = 1; + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Field" + } + ]; } // The request for [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]. message ListFieldsRequest { - // A parent name of the form + // Required. A parent name of the form // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - string parent = 1; + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/CollectionGroup" + } + ]; // The filter to apply to list results. Currently, // [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields @@ -242,9 +307,14 @@ message ListFieldsResponse { // The request for [FirestoreAdmin.ExportDocuments][google.firestore.admin.v1.FirestoreAdmin.ExportDocuments]. message ExportDocumentsRequest { - // Database to export. Should be of the form: + // Required. Database to export. Should be of the form: // `projects/{project_id}/databases/{database_id}`. - string name = 1; + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; // Which collection ids to export. Unspecified means all collections. repeated string collection_ids = 2; @@ -262,9 +332,14 @@ message ExportDocumentsRequest { // The request for [FirestoreAdmin.ImportDocuments][google.firestore.admin.v1.FirestoreAdmin.ImportDocuments]. message ImportDocumentsRequest { - // Database to import into. Should be of the form: + // Required. Database to import into. Should be of the form: // `projects/{project_id}/databases/{database_id}`. - string name = 1; + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; // Which collection ids to import. Unspecified means all collections included // in the import. diff --git a/dev/protos/google/firestore/admin/v1/index.proto b/dev/protos/google/firestore/admin/v1/index.proto index f2038c581..4b9c6e35b 100644 --- a/dev/protos/google/firestore/admin/v1/index.proto +++ b/dev/protos/google/firestore/admin/v1/index.proto @@ -17,6 +17,7 @@ syntax = "proto3"; package google.firestore.admin.v1; +import "google/api/resource.proto"; import "google/api/annotations.proto"; option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; @@ -30,6 +31,11 @@ option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; // Cloud Firestore indexes enable simple and complex queries against // documents in a database. message Index { + option (google.api.resource) = { + type: "firestore.googleapis.com/Index" + pattern: "projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}" + }; + // A field in an index. // The field_path describes which field is indexed, the value_mode describes // how the field value is indexed. diff --git a/dev/protos/google/firestore/admin/v1/operation.proto b/dev/protos/google/firestore/admin/v1/operation.proto index 6494ab7cb..08194fe09 100644 --- a/dev/protos/google/firestore/admin/v1/operation.proto +++ b/dev/protos/google/firestore/admin/v1/operation.proto @@ -162,6 +162,17 @@ message ExportDocumentsResponse { string output_uri_prefix = 1; } +// Describes the progress of the operation. +// Unit of work is generic and must be interpreted based on where [Progress][google.firestore.admin.v1.Progress] +// is used. +message Progress { + // The amount of work estimated. + int64 estimated_work = 1; + + // The amount of work completed. + int64 completed_work = 2; +} + // Describes the state of the operation. enum OperationState { // Unspecified. @@ -190,14 +201,3 @@ enum OperationState { // google.longrunning.Operations.CancelOperation. CANCELLED = 7; } - -// Describes the progress of the operation. -// Unit of work is generic and must be interpreted based on where [Progress][google.firestore.admin.v1.Progress] -// is used. -message Progress { - // The amount of work estimated. - int64 estimated_work = 1; - - // The amount of work completed. - int64 completed_work = 2; -} diff --git a/dev/protos/google/firestore/v1/firestore.proto b/dev/protos/google/firestore/v1/firestore.proto index 2fb25deb7..a07b267d7 100644 --- a/dev/protos/google/firestore/v1/firestore.proto +++ b/dev/protos/google/firestore/v1/firestore.proto @@ -18,6 +18,8 @@ syntax = "proto3"; package google.firestore.v1; import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; import "google/firestore/v1/common.proto"; import "google/firestore/v1/document.proto"; import "google/firestore/v1/query.proto"; @@ -25,7 +27,6 @@ import "google/firestore/v1/write.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/timestamp.proto"; import "google/rpc/status.proto"; -import "google/api/client.proto"; option csharp_namespace = "Google.Cloud.Firestore.V1"; option go_package = "google.golang.org/genproto/googleapis/firestore/v1;firestore"; @@ -87,6 +88,7 @@ service Firestore { patch: "/v1/{document.name=projects/*/databases/*/documents/*/**}" body: "document" }; + option (google.api.method_signature) = "document,update_mask"; } // Deletes a document. @@ -94,6 +96,7 @@ service Firestore { option (google.api.http) = { delete: "/v1/{name=projects/*/databases/*/documents/*/**}" }; + option (google.api.method_signature) = "name"; } // Gets multiple documents. @@ -113,6 +116,7 @@ service Firestore { post: "/v1/{database=projects/*/databases/*}/documents:beginTransaction" body: "*" }; + option (google.api.method_signature) = "database"; } // Commits a transaction, while optionally updating documents. @@ -121,6 +125,7 @@ service Firestore { post: "/v1/{database=projects/*/databases/*}/documents:commit" body: "*" }; + option (google.api.method_signature) = "database,writes"; } // Rolls back a transaction. @@ -129,6 +134,7 @@ service Firestore { post: "/v1/{database=projects/*/databases/*}/documents:rollback" body: "*" }; + option (google.api.method_signature) = "database,transaction"; } // Runs a query. @@ -169,14 +175,15 @@ service Firestore { body: "*" } }; + option (google.api.method_signature) = "parent"; } } // The request for [Firestore.GetDocument][google.firestore.v1.Firestore.GetDocument]. message GetDocumentRequest { - // The resource name of the Document to get. In the format: + // Required. The resource name of the Document to get. In the format: // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - string name = 1; + string name = 1 [(google.api.field_behavior) = REQUIRED]; // The fields to return. If not set, returns all fields. // @@ -198,17 +205,17 @@ message GetDocumentRequest { // The request for [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments]. message ListDocumentsRequest { - // The parent resource name. In the format: + // 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` - string parent = 1; + string parent = 1 [(google.api.field_behavior) = REQUIRED]; - // The collection ID, relative to `parent`, to list. For example: `chatrooms` + // Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` // or `messages`. - string collection_id = 2; + string collection_id = 2 [(google.api.field_behavior) = REQUIRED]; // The maximum number of documents to return. int32 page_size = 3; @@ -257,21 +264,21 @@ message ListDocumentsResponse { // The request for [Firestore.CreateDocument][google.firestore.v1.Firestore.CreateDocument]. message CreateDocumentRequest { - // The parent resource. For example: + // Required. The parent resource. For example: // `projects/{project_id}/databases/{database_id}/documents` or // `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` - string parent = 1; + string parent = 1 [(google.api.field_behavior) = REQUIRED]; - // The collection ID, relative to `parent`, to list. For example: `chatrooms`. - string collection_id = 2; + // Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. + string collection_id = 2 [(google.api.field_behavior) = REQUIRED]; // The client-assigned document ID to use for this document. // // Optional. If not specified, an ID will be assigned by the service. string document_id = 3; - // The document to create. `name` must not be set. - Document document = 4; + // Required. The document to create. `name` must not be set. + Document document = 4 [(google.api.field_behavior) = REQUIRED]; // The fields to return. If not set, returns all fields. // @@ -282,9 +289,9 @@ message CreateDocumentRequest { // The request for [Firestore.UpdateDocument][google.firestore.v1.Firestore.UpdateDocument]. message UpdateDocumentRequest { - // The updated document. + // Required. The updated document. // Creates the document if it does not already exist. - Document document = 1; + Document document = 1 [(google.api.field_behavior) = REQUIRED]; // The fields to update. // None of the field paths in the mask may contain a reserved name. @@ -308,9 +315,9 @@ message UpdateDocumentRequest { // The request for [Firestore.DeleteDocument][google.firestore.v1.Firestore.DeleteDocument]. message DeleteDocumentRequest { - // The resource name of the Document to delete. In the format: + // Required. The resource name of the Document to delete. In the format: // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - string name = 1; + string name = 1 [(google.api.field_behavior) = REQUIRED]; // An optional precondition on the document. // The request will fail if this is set and not met by the target document. @@ -319,9 +326,9 @@ message DeleteDocumentRequest { // The request for [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments]. message BatchGetDocumentsRequest { - // The database name. In the format: + // Required. The database name. In the format: // `projects/{project_id}/databases/{database_id}`. - string database = 1; + string database = 1 [(google.api.field_behavior) = REQUIRED]; // The names of the documents to retrieve. In the format: // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. @@ -380,9 +387,9 @@ message BatchGetDocumentsResponse { // The request for [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction]. message BeginTransactionRequest { - // The database name. In the format: + // Required. The database name. In the format: // `projects/{project_id}/databases/{database_id}`. - string database = 1; + string database = 1 [(google.api.field_behavior) = REQUIRED]; // The options for the transaction. // Defaults to a read-write transaction. @@ -397,9 +404,9 @@ message BeginTransactionResponse { // The request for [Firestore.Commit][google.firestore.v1.Firestore.Commit]. message CommitRequest { - // The database name. In the format: + // Required. The database name. In the format: // `projects/{project_id}/databases/{database_id}`. - string database = 1; + string database = 1 [(google.api.field_behavior) = REQUIRED]; // The writes to apply. // @@ -424,23 +431,23 @@ message CommitResponse { // The request for [Firestore.Rollback][google.firestore.v1.Firestore.Rollback]. message RollbackRequest { - // The database name. In the format: + // Required. The database name. In the format: // `projects/{project_id}/databases/{database_id}`. - string database = 1; + string database = 1 [(google.api.field_behavior) = REQUIRED]; - // The transaction to roll back. - bytes transaction = 2; + // Required. The transaction to roll back. + bytes transaction = 2 [(google.api.field_behavior) = REQUIRED]; } // The request for [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery]. message RunQueryRequest { - // The parent resource name. In the format: + // 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` - string parent = 1; + string parent = 1 [(google.api.field_behavior) = REQUIRED]; // The query to run. oneof query_type { @@ -503,10 +510,10 @@ message RunQueryResponse { // given token, then a response containing only an up-to-date token, to use in // the next request. message WriteRequest { - // The database name. In the format: + // Required. The database name. In the format: // `projects/{project_id}/databases/{database_id}`. // This is only required in the first message. - string database = 1; + string database = 1 [(google.api.field_behavior) = REQUIRED]; // The ID of the write stream to resume. // This may only be set in the first message. When left empty, a new write @@ -565,9 +572,9 @@ message WriteResponse { // A request for [Firestore.Listen][google.firestore.v1.Firestore.Listen] message ListenRequest { - // The database name. In the format: + // Required. The database name. In the format: // `projects/{project_id}/databases/{database_id}`. - string database = 1; + string database = 1 [(google.api.field_behavior) = REQUIRED]; // The supported target changes. oneof target_change { @@ -734,11 +741,11 @@ message TargetChange { // The request for [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds]. message ListCollectionIdsRequest { - // The parent document. In the format: + // 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` - string parent = 1; + string parent = 1 [(google.api.field_behavior) = REQUIRED]; // The maximum number of results to return. int32 page_size = 2; diff --git a/dev/protos/google/firestore/v1/query.proto b/dev/protos/google/firestore/v1/query.proto index a8d5e7a2e..12d80b255 100644 --- a/dev/protos/google/firestore/v1/query.proto +++ b/dev/protos/google/firestore/v1/query.proto @@ -146,15 +146,6 @@ message StructuredQuery { } } - // The projection of document's fields to return. - message Projection { - // The fields to return. - // - // If empty, all fields are returned. To only return the name - // of the document, use `['__name__']`. - repeated FieldReference fields = 2; - } - // An order on a field. message Order { // The field to order by. @@ -164,11 +155,6 @@ message StructuredQuery { Direction direction = 2; } - // A reference to a field, such as `max(messages.time) as max_time`. - message FieldReference { - string field_path = 2; - } - // A sort direction. enum Direction { // Unspecified. @@ -181,6 +167,20 @@ message StructuredQuery { DESCENDING = 2; } + // A reference to a field, such as `max(messages.time) as max_time`. + message FieldReference { + string field_path = 2; + } + + // The projection of document's fields to return. + message Projection { + // The fields to return. + // + // If empty, all fields are returned. To only return the name + // of the document, use `['__name__']`. + repeated FieldReference fields = 2; + } + // The projection to return. Projection select = 1; diff --git a/dev/protos/google/firestore/v1beta1/firestore.proto b/dev/protos/google/firestore/v1beta1/firestore.proto index ff0f03c70..c2b15b048 100644 --- a/dev/protos/google/firestore/v1beta1/firestore.proto +++ b/dev/protos/google/firestore/v1beta1/firestore.proto @@ -18,6 +18,8 @@ syntax = "proto3"; package google.firestore.v1beta1; import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; import "google/firestore/v1beta1/common.proto"; import "google/firestore/v1beta1/document.proto"; import "google/firestore/v1beta1/query.proto"; @@ -25,7 +27,6 @@ import "google/firestore/v1beta1/write.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/timestamp.proto"; import "google/rpc/status.proto"; -import "google/api/client.proto"; option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore"; @@ -87,6 +88,7 @@ service Firestore { patch: "/v1beta1/{document.name=projects/*/databases/*/documents/*/**}" body: "document" }; + option (google.api.method_signature) = "document,update_mask"; } // Deletes a document. @@ -94,6 +96,7 @@ service Firestore { option (google.api.http) = { delete: "/v1beta1/{name=projects/*/databases/*/documents/*/**}" }; + option (google.api.method_signature) = "name"; } // Gets multiple documents. @@ -113,6 +116,7 @@ service Firestore { post: "/v1beta1/{database=projects/*/databases/*}/documents:beginTransaction" body: "*" }; + option (google.api.method_signature) = "database"; } // Commits a transaction, while optionally updating documents. @@ -121,6 +125,7 @@ service Firestore { post: "/v1beta1/{database=projects/*/databases/*}/documents:commit" body: "*" }; + option (google.api.method_signature) = "database,writes"; } // Rolls back a transaction. @@ -129,6 +134,7 @@ service Firestore { post: "/v1beta1/{database=projects/*/databases/*}/documents:rollback" body: "*" }; + option (google.api.method_signature) = "database,transaction"; } // Runs a query. @@ -169,14 +175,15 @@ service Firestore { body: "*" } }; + option (google.api.method_signature) = "parent"; } } // The request for [Firestore.GetDocument][google.firestore.v1beta1.Firestore.GetDocument]. message GetDocumentRequest { - // The resource name of the Document to get. In the format: + // Required. The resource name of the Document to get. In the format: // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - string name = 1; + string name = 1 [(google.api.field_behavior) = REQUIRED]; // The fields to return. If not set, returns all fields. // @@ -198,17 +205,17 @@ message GetDocumentRequest { // The request for [Firestore.ListDocuments][google.firestore.v1beta1.Firestore.ListDocuments]. message ListDocumentsRequest { - // The parent resource name. In the format: + // 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` - string parent = 1; + string parent = 1 [(google.api.field_behavior) = REQUIRED]; - // The collection ID, relative to `parent`, to list. For example: `chatrooms` + // Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` // or `messages`. - string collection_id = 2; + string collection_id = 2 [(google.api.field_behavior) = REQUIRED]; // The maximum number of documents to return. int32 page_size = 3; @@ -257,21 +264,21 @@ message ListDocumentsResponse { // The request for [Firestore.CreateDocument][google.firestore.v1beta1.Firestore.CreateDocument]. message CreateDocumentRequest { - // The parent resource. For example: + // Required. The parent resource. For example: // `projects/{project_id}/databases/{database_id}/documents` or // `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` - string parent = 1; + string parent = 1 [(google.api.field_behavior) = REQUIRED]; - // The collection ID, relative to `parent`, to list. For example: `chatrooms`. - string collection_id = 2; + // Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. + string collection_id = 2 [(google.api.field_behavior) = REQUIRED]; // The client-assigned document ID to use for this document. // // Optional. If not specified, an ID will be assigned by the service. string document_id = 3; - // The document to create. `name` must not be set. - Document document = 4; + // Required. The document to create. `name` must not be set. + Document document = 4 [(google.api.field_behavior) = REQUIRED]; // The fields to return. If not set, returns all fields. // @@ -282,9 +289,9 @@ message CreateDocumentRequest { // The request for [Firestore.UpdateDocument][google.firestore.v1beta1.Firestore.UpdateDocument]. message UpdateDocumentRequest { - // The updated document. + // Required. The updated document. // Creates the document if it does not already exist. - Document document = 1; + Document document = 1 [(google.api.field_behavior) = REQUIRED]; // The fields to update. // None of the field paths in the mask may contain a reserved name. @@ -308,9 +315,9 @@ message UpdateDocumentRequest { // The request for [Firestore.DeleteDocument][google.firestore.v1beta1.Firestore.DeleteDocument]. message DeleteDocumentRequest { - // The resource name of the Document to delete. In the format: + // Required. The resource name of the Document to delete. In the format: // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - string name = 1; + string name = 1 [(google.api.field_behavior) = REQUIRED]; // An optional precondition on the document. // The request will fail if this is set and not met by the target document. @@ -319,9 +326,9 @@ message DeleteDocumentRequest { // The request for [Firestore.BatchGetDocuments][google.firestore.v1beta1.Firestore.BatchGetDocuments]. message BatchGetDocumentsRequest { - // The database name. In the format: + // Required. The database name. In the format: // `projects/{project_id}/databases/{database_id}`. - string database = 1; + string database = 1 [(google.api.field_behavior) = REQUIRED]; // The names of the documents to retrieve. In the format: // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. @@ -380,9 +387,9 @@ message BatchGetDocumentsResponse { // The request for [Firestore.BeginTransaction][google.firestore.v1beta1.Firestore.BeginTransaction]. message BeginTransactionRequest { - // The database name. In the format: + // Required. The database name. In the format: // `projects/{project_id}/databases/{database_id}`. - string database = 1; + string database = 1 [(google.api.field_behavior) = REQUIRED]; // The options for the transaction. // Defaults to a read-write transaction. @@ -397,9 +404,9 @@ message BeginTransactionResponse { // The request for [Firestore.Commit][google.firestore.v1beta1.Firestore.Commit]. message CommitRequest { - // The database name. In the format: + // Required. The database name. In the format: // `projects/{project_id}/databases/{database_id}`. - string database = 1; + string database = 1 [(google.api.field_behavior) = REQUIRED]; // The writes to apply. // @@ -424,23 +431,23 @@ message CommitResponse { // The request for [Firestore.Rollback][google.firestore.v1beta1.Firestore.Rollback]. message RollbackRequest { - // The database name. In the format: + // Required. The database name. In the format: // `projects/{project_id}/databases/{database_id}`. - string database = 1; + string database = 1 [(google.api.field_behavior) = REQUIRED]; - // The transaction to roll back. - bytes transaction = 2; + // Required. The transaction to roll back. + bytes transaction = 2 [(google.api.field_behavior) = REQUIRED]; } // The request for [Firestore.RunQuery][google.firestore.v1beta1.Firestore.RunQuery]. message RunQueryRequest { - // The parent resource name. In the format: + // 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` - string parent = 1; + string parent = 1 [(google.api.field_behavior) = REQUIRED]; // The query to run. oneof query_type { @@ -503,10 +510,10 @@ message RunQueryResponse { // given token, then a response containing only an up-to-date token, to use in // the next request. message WriteRequest { - // The database name. In the format: + // Required. The database name. In the format: // `projects/{project_id}/databases/{database_id}`. // This is only required in the first message. - string database = 1; + string database = 1 [(google.api.field_behavior) = REQUIRED]; // The ID of the write stream to resume. // This may only be set in the first message. When left empty, a new write @@ -565,9 +572,9 @@ message WriteResponse { // A request for [Firestore.Listen][google.firestore.v1beta1.Firestore.Listen] message ListenRequest { - // The database name. In the format: + // Required. The database name. In the format: // `projects/{project_id}/databases/{database_id}`. - string database = 1; + string database = 1 [(google.api.field_behavior) = REQUIRED]; // The supported target changes. oneof target_change { @@ -734,11 +741,11 @@ message TargetChange { // The request for [Firestore.ListCollectionIds][google.firestore.v1beta1.Firestore.ListCollectionIds]. message ListCollectionIdsRequest { - // The parent document. In the format: + // 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` - string parent = 1; + string parent = 1 [(google.api.field_behavior) = REQUIRED]; // The maximum number of results to return. int32 page_size = 2; diff --git a/dev/protos/google/firestore/v1beta1/query.proto b/dev/protos/google/firestore/v1beta1/query.proto index a8068ae6c..4f515fabe 100644 --- a/dev/protos/google/firestore/v1beta1/query.proto +++ b/dev/protos/google/firestore/v1beta1/query.proto @@ -155,6 +155,11 @@ message StructuredQuery { Direction direction = 2; } + // A reference to a field, such as `max(messages.time) as max_time`. + message FieldReference { + string field_path = 2; + } + // The projection of document's fields to return. message Projection { // The fields to return. @@ -164,11 +169,6 @@ message StructuredQuery { repeated FieldReference fields = 2; } - // A reference to a field, such as `max(messages.time) as max_time`. - message FieldReference { - string field_path = 2; - } - // A sort direction. enum Direction { // Unspecified. diff --git a/dev/protos/google/protobuf/field_mask.proto b/dev/protos/google/protobuf/field_mask.proto index 4015b1a3e..baac8744c 100644 --- a/dev/protos/google/protobuf/field_mask.proto +++ b/dev/protos/google/protobuf/field_mask.proto @@ -238,7 +238,7 @@ option cc_enable_arenas = true; // // The implementation of any API method which has a FieldMask type field in the // request should verify the included field paths, and return an -// `INVALID_ARGUMENT` error if any path is duplicated or unmappable. +// `INVALID_ARGUMENT` error if any path is unmappable. message FieldMask { // The set of field mask paths. repeated string paths = 1; diff --git a/dev/protos/google/type/latlng.proto b/dev/protos/google/type/latlng.proto index 8aec8c0a0..473856f98 100644 --- a/dev/protos/google/type/latlng.proto +++ b/dev/protos/google/type/latlng.proto @@ -24,7 +24,6 @@ option java_outer_classname = "LatLngProto"; option java_package = "com.google.type"; option objc_class_prefix = "GTP"; - // An object representing a latitude/longitude pair. This is expressed as a pair // of doubles representing degrees latitude and degrees longitude. Unless // specified otherwise, this must conform to the diff --git a/dev/protos/insert-license.sh b/dev/protos/insert-license.sh new file mode 100755 index 000000000..c6d932f69 --- /dev/null +++ b/dev/protos/insert-license.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Copyright 2019 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. + +read -r -d '' LICENSE_HEADER << LICENSE +/*! + * Copyright 2019 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. + */ +LICENSE + +for n in "$@" +do + printf "%s\n\n%s\n" "$LICENSE_HEADER" "`cat $n`" > $n +done diff --git a/dev/protos/protos.json b/dev/protos/protos.json index 8056132c9..59f318626 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -11,12 +11,134 @@ "csharp_namespace": "Google.Cloud.Firestore.Admin.V1", "go_package": "google.golang.org/genproto/googleapis/firestore/admin/v1;admin", "java_multiple_files": true, - "java_outer_classname": "IndexProto", + "java_outer_classname": "LocationProto", "java_package": "com.google.firestore.admin.v1", "objc_class_prefix": "GCFS", - "php_namespace": "Google\\Cloud\\Firestore\\Admin\\V1" + "php_namespace": "Google\\Cloud\\Firestore\\Admin\\V1", + "(google.api.resource_definition).type": "firestore.googleapis.com/CollectionGroup", + "(google.api.resource_definition).pattern": "projects/{project}/databases/{database}/collectionGroups/{collection}" }, "nested": { + "Index": { + "options": { + "(google.api.resource).type": "firestore.googleapis.com/Index", + "(google.api.resource).pattern": "projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}" + }, + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "queryScope": { + "type": "QueryScope", + "id": 2 + }, + "fields": { + "rule": "repeated", + "type": "IndexField", + "id": 3 + }, + "state": { + "type": "State", + "id": 4 + } + }, + "nested": { + "IndexField": { + "oneofs": { + "valueMode": { + "oneof": [ + "order", + "arrayConfig" + ] + } + }, + "fields": { + "fieldPath": { + "type": "string", + "id": 1 + }, + "order": { + "type": "Order", + "id": 2 + }, + "arrayConfig": { + "type": "ArrayConfig", + "id": 3 + } + }, + "nested": { + "Order": { + "values": { + "ORDER_UNSPECIFIED": 0, + "ASCENDING": 1, + "DESCENDING": 2 + } + }, + "ArrayConfig": { + "values": { + "ARRAY_CONFIG_UNSPECIFIED": 0, + "CONTAINS": 1 + } + } + } + }, + "QueryScope": { + "values": { + "QUERY_SCOPE_UNSPECIFIED": 0, + "COLLECTION": 1, + "COLLECTION_GROUP": 2 + } + }, + "State": { + "values": { + "STATE_UNSPECIFIED": 0, + "CREATING": 1, + "READY": 2, + "NEEDS_REPAIR": 3 + } + } + } + }, + "Field": { + "options": { + "(google.api.resource).type": "firestore.googleapis.com/Field", + "(google.api.resource).pattern": "projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}" + }, + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "indexConfig": { + "type": "IndexConfig", + "id": 2 + } + }, + "nested": { + "IndexConfig": { + "fields": { + "indexes": { + "rule": "repeated", + "type": "Index", + "id": 1 + }, + "usesAncestorConfig": { + "type": "bool", + "id": 2 + }, + "ancestorField": { + "type": "string", + "id": 3 + }, + "reverting": { + "type": "bool", + "id": 4 + } + } + } + } + }, "FirestoreAdmin": { "options": { "(google.api.default_host)": "firestore.googleapis.com", @@ -28,35 +150,42 @@ "responseType": "google.longrunning.Operation", "options": { "(google.api.http).post": "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes", - "(google.api.http).body": "index" + "(google.api.http).body": "index", + "(google.api.method_signature)": "parent,index", + "(google.longrunning.operation_info).response_type": "Index", + "(google.longrunning.operation_info).metadata_type": "IndexOperationMetadata" } }, "ListIndexes": { "requestType": "ListIndexesRequest", "responseType": "ListIndexesResponse", "options": { - "(google.api.http).get": "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes" + "(google.api.http).get": "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes", + "(google.api.method_signature)": "parent" } }, "GetIndex": { "requestType": "GetIndexRequest", "responseType": "Index", "options": { - "(google.api.http).get": "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}" + "(google.api.http).get": "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}", + "(google.api.method_signature)": "name" } }, "DeleteIndex": { "requestType": "DeleteIndexRequest", "responseType": "google.protobuf.Empty", "options": { - "(google.api.http).delete": "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}" + "(google.api.http).delete": "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}", + "(google.api.method_signature)": "name" } }, "GetField": { "requestType": "GetFieldRequest", "responseType": "Field", "options": { - "(google.api.http).get": "/v1/{name=projects/*/databases/*/collectionGroups/*/fields/*}" + "(google.api.http).get": "/v1/{name=projects/*/databases/*/collectionGroups/*/fields/*}", + "(google.api.method_signature)": "name" } }, "UpdateField": { @@ -64,14 +193,18 @@ "responseType": "google.longrunning.Operation", "options": { "(google.api.http).patch": "/v1/{field.name=projects/*/databases/*/collectionGroups/*/fields/*}", - "(google.api.http).body": "field" + "(google.api.http).body": "field", + "(google.api.method_signature)": "field", + "(google.longrunning.operation_info).response_type": "Field", + "(google.longrunning.operation_info).metadata_type": "FieldOperationMetadata" } }, "ListFields": { "requestType": "ListFieldsRequest", "responseType": "ListFieldsResponse", "options": { - "(google.api.http).get": "/v1/{parent=projects/*/databases/*/collectionGroups/*}/fields" + "(google.api.http).get": "/v1/{parent=projects/*/databases/*/collectionGroups/*}/fields", + "(google.api.method_signature)": "parent" } }, "ExportDocuments": { @@ -79,7 +212,10 @@ "responseType": "google.longrunning.Operation", "options": { "(google.api.http).post": "/v1/{name=projects/*/databases/*}:exportDocuments", - "(google.api.http).body": "*" + "(google.api.http).body": "*", + "(google.api.method_signature)": "name", + "(google.longrunning.operation_info).response_type": "ExportDocumentsResponse", + "(google.longrunning.operation_info).metadata_type": "ExportDocumentsMetadata" } }, "ImportDocuments": { @@ -87,7 +223,10 @@ "responseType": "google.longrunning.Operation", "options": { "(google.api.http).post": "/v1/{name=projects/*/databases/*}:importDocuments", - "(google.api.http).body": "*" + "(google.api.http).body": "*", + "(google.api.method_signature)": "name", + "(google.longrunning.operation_info).response_type": "google.protobuf.Empty", + "(google.longrunning.operation_info).metadata_type": "ImportDocumentsMetadata" } } } @@ -96,11 +235,18 @@ "fields": { "parent": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "firestore.googleapis.com/CollectionGroup" + } }, "index": { "type": "Index", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } } } }, @@ -108,7 +254,11 @@ "fields": { "parent": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "firestore.googleapis.com/CollectionGroup" + } }, "filter": { "type": "string", @@ -141,7 +291,11 @@ "fields": { "name": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "firestore.googleapis.com/Index" + } } } }, @@ -149,7 +303,11 @@ "fields": { "name": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "firestore.googleapis.com/Index" + } } } }, @@ -157,7 +315,10 @@ "fields": { "field": { "type": "Field", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, "updateMask": { "type": "google.protobuf.FieldMask", @@ -169,7 +330,11 @@ "fields": { "name": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "firestore.googleapis.com/Field" + } } } }, @@ -177,7 +342,11 @@ "fields": { "parent": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "firestore.googleapis.com/CollectionGroup" + } }, "filter": { "type": "string", @@ -210,7 +379,11 @@ "fields": { "name": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "firestore.googleapis.com/Database" + } }, "collectionIds": { "rule": "repeated", @@ -227,7 +400,11 @@ "fields": { "name": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "firestore.googleapis.com/Database" + } }, "collectionIds": { "rule": "repeated", @@ -240,2660 +417,2847 @@ } } }, - "Field": { + "IndexOperationMetadata": { "fields": { - "name": { - "type": "string", + "startTime": { + "type": "google.protobuf.Timestamp", "id": 1 }, - "indexConfig": { - "type": "IndexConfig", + "endTime": { + "type": "google.protobuf.Timestamp", "id": 2 - } - }, - "nested": { - "IndexConfig": { - "fields": { - "indexes": { - "rule": "repeated", - "type": "Index", - "id": 1 - }, - "usesAncestorConfig": { - "type": "bool", - "id": 2 - }, - "ancestorField": { - "type": "string", - "id": 3 - }, - "reverting": { - "type": "bool", - "id": 4 - } - } + }, + "index": { + "type": "string", + "id": 3 + }, + "state": { + "type": "OperationState", + "id": 4 + }, + "progressDocuments": { + "type": "Progress", + "id": 5 + }, + "progressBytes": { + "type": "Progress", + "id": 6 } } }, - "Index": { + "FieldOperationMetadata": { "fields": { - "name": { - "type": "string", + "startTime": { + "type": "google.protobuf.Timestamp", "id": 1 }, - "queryScope": { - "type": "QueryScope", + "endTime": { + "type": "google.protobuf.Timestamp", "id": 2 }, - "fields": { - "rule": "repeated", - "type": "IndexField", + "field": { + "type": "string", "id": 3 }, - "state": { - "type": "State", + "indexConfigDeltas": { + "rule": "repeated", + "type": "IndexConfigDelta", "id": 4 + }, + "state": { + "type": "OperationState", + "id": 5 + }, + "progressDocuments": { + "type": "Progress", + "id": 6 + }, + "progressBytes": { + "type": "Progress", + "id": 7 } }, "nested": { - "IndexField": { - "oneofs": { - "valueMode": { - "oneof": [ - "order", - "arrayConfig" - ] - } - }, + "IndexConfigDelta": { "fields": { - "fieldPath": { - "type": "string", + "changeType": { + "type": "ChangeType", "id": 1 }, - "order": { - "type": "Order", + "index": { + "type": "Index", "id": 2 - }, - "arrayConfig": { - "type": "ArrayConfig", - "id": 3 } }, "nested": { - "Order": { - "values": { - "ORDER_UNSPECIFIED": 0, - "ASCENDING": 1, - "DESCENDING": 2 - } - }, - "ArrayConfig": { + "ChangeType": { "values": { - "ARRAY_CONFIG_UNSPECIFIED": 0, - "CONTAINS": 1 + "CHANGE_TYPE_UNSPECIFIED": 0, + "ADD": 1, + "REMOVE": 2 } } } - }, - "QueryScope": { - "values": { - "QUERY_SCOPE_UNSPECIFIED": 0, - "COLLECTION": 1, - "COLLECTION_GROUP": 2 - } - }, - "State": { - "values": { - "STATE_UNSPECIFIED": 0, - "CREATING": 1, - "READY": 2, - "NEEDS_REPAIR": 3 - } } } - } - } - } - } - }, - "v1": { - "options": { - "csharp_namespace": "Google.Cloud.Firestore.V1", - "go_package": "google.golang.org/genproto/googleapis/firestore/v1;firestore", - "java_multiple_files": true, - "java_outer_classname": "WriteProto", - "java_package": "com.google.firestore.v1", - "objc_class_prefix": "GCFS", - "php_namespace": "Google\\Cloud\\Firestore\\V1" - }, - "nested": { - "Firestore": { - "options": { - "(google.api.default_host)": "firestore.googleapis.com", - "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/datastore" - }, - "methods": { - "GetDocument": { - "requestType": "GetDocumentRequest", - "responseType": "Document", - "options": { - "(google.api.http).get": "/v1/{name=projects/*/databases/*/documents/*/**}" - } - }, - "ListDocuments": { - "requestType": "ListDocumentsRequest", - "responseType": "ListDocumentsResponse", - "options": { - "(google.api.http).get": "/v1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" - } - }, - "CreateDocument": { - "requestType": "CreateDocumentRequest", - "responseType": "Document", - "options": { - "(google.api.http).post": "/v1/{parent=projects/*/databases/*/documents/**}/{collection_id}", - "(google.api.http).body": "document" - } - }, - "UpdateDocument": { - "requestType": "UpdateDocumentRequest", - "responseType": "Document", - "options": { - "(google.api.http).patch": "/v1/{document.name=projects/*/databases/*/documents/*/**}", - "(google.api.http).body": "document" - } - }, - "DeleteDocument": { - "requestType": "DeleteDocumentRequest", - "responseType": "google.protobuf.Empty", - "options": { - "(google.api.http).delete": "/v1/{name=projects/*/databases/*/documents/*/**}" - } - }, - "BatchGetDocuments": { - "requestType": "BatchGetDocumentsRequest", - "responseType": "BatchGetDocumentsResponse", - "responseStream": true, - "options": { - "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:batchGet", - "(google.api.http).body": "*" - } - }, - "BeginTransaction": { - "requestType": "BeginTransactionRequest", - "responseType": "BeginTransactionResponse", - "options": { - "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:beginTransaction", - "(google.api.http).body": "*" - } }, - "Commit": { - "requestType": "CommitRequest", - "responseType": "CommitResponse", - "options": { - "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:commit", - "(google.api.http).body": "*" + "ExportDocumentsMetadata": { + "fields": { + "startTime": { + "type": "google.protobuf.Timestamp", + "id": 1 + }, + "endTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + }, + "operationState": { + "type": "OperationState", + "id": 3 + }, + "progressDocuments": { + "type": "Progress", + "id": 4 + }, + "progressBytes": { + "type": "Progress", + "id": 5 + }, + "collectionIds": { + "rule": "repeated", + "type": "string", + "id": 6 + }, + "outputUriPrefix": { + "type": "string", + "id": 7 + } } }, - "Rollback": { - "requestType": "RollbackRequest", - "responseType": "google.protobuf.Empty", - "options": { - "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:rollback", - "(google.api.http).body": "*" + "ImportDocumentsMetadata": { + "fields": { + "startTime": { + "type": "google.protobuf.Timestamp", + "id": 1 + }, + "endTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + }, + "operationState": { + "type": "OperationState", + "id": 3 + }, + "progressDocuments": { + "type": "Progress", + "id": 4 + }, + "progressBytes": { + "type": "Progress", + "id": 5 + }, + "collectionIds": { + "rule": "repeated", + "type": "string", + "id": 6 + }, + "inputUriPrefix": { + "type": "string", + "id": 7 + } } }, - "RunQuery": { - "requestType": "RunQueryRequest", - "responseType": "RunQueryResponse", - "responseStream": true, - "options": { - "(google.api.http).post": "/v1/{parent=projects/*/databases/*/documents}:runQuery", - "(google.api.http).body": "*", - "(google.api.http).additional_bindings.post": "/v1/{parent=projects/*/databases/*/documents/*/**}:runQuery", - "(google.api.http).additional_bindings.body": "*" + "ExportDocumentsResponse": { + "fields": { + "outputUriPrefix": { + "type": "string", + "id": 1 + } } }, - "Write": { - "requestType": "WriteRequest", - "requestStream": true, - "responseType": "WriteResponse", - "responseStream": true, - "options": { - "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:write", - "(google.api.http).body": "*" + "Progress": { + "fields": { + "estimatedWork": { + "type": "int64", + "id": 1 + }, + "completedWork": { + "type": "int64", + "id": 2 + } } }, - "Listen": { - "requestType": "ListenRequest", - "requestStream": true, - "responseType": "ListenResponse", - "responseStream": true, - "options": { - "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:listen", - "(google.api.http).body": "*" + "OperationState": { + "values": { + "OPERATION_STATE_UNSPECIFIED": 0, + "INITIALIZING": 1, + "PROCESSING": 2, + "CANCELLING": 3, + "FINALIZING": 4, + "SUCCESSFUL": 5, + "FAILED": 6, + "CANCELLED": 7 } }, - "ListCollectionIds": { - "requestType": "ListCollectionIdsRequest", - "responseType": "ListCollectionIdsResponse", - "options": { - "(google.api.http).post": "/v1/{parent=projects/*/databases/*/documents}:listCollectionIds", - "(google.api.http).body": "*", - "(google.api.http).additional_bindings.post": "/v1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds", - "(google.api.http).additional_bindings.body": "*" - } + "LocationMetadata": { + "fields": {} + } + } + } + } + }, + "v1": { + "options": { + "csharp_namespace": "Google.Cloud.Firestore.V1", + "go_package": "google.golang.org/genproto/googleapis/firestore/v1;firestore", + "java_multiple_files": true, + "java_outer_classname": "FirestoreProto", + "java_package": "com.google.firestore.v1", + "objc_class_prefix": "GCFS", + "php_namespace": "Google\\Cloud\\Firestore\\V1" + }, + "nested": { + "DocumentMask": { + "fields": { + "fieldPaths": { + "rule": "repeated", + "type": "string", + "id": 1 } } }, - "GetDocumentRequest": { + "Precondition": { "oneofs": { - "consistencySelector": { + "conditionType": { "oneof": [ - "transaction", - "readTime" + "exists", + "updateTime" ] } }, "fields": { - "name": { - "type": "string", + "exists": { + "type": "bool", "id": 1 }, - "mask": { - "type": "DocumentMask", - "id": 2 - }, - "transaction": { - "type": "bytes", - "id": 3 - }, - "readTime": { + "updateTime": { "type": "google.protobuf.Timestamp", - "id": 5 + "id": 2 } } }, - "ListDocumentsRequest": { + "TransactionOptions": { "oneofs": { - "consistencySelector": { + "mode": { "oneof": [ - "transaction", - "readTime" + "readOnly", + "readWrite" ] } }, "fields": { - "parent": { - "type": "string", - "id": 1 - }, - "collectionId": { - "type": "string", + "readOnly": { + "type": "ReadOnly", "id": 2 }, - "pageSize": { - "type": "int32", + "readWrite": { + "type": "ReadWrite", "id": 3 + } + }, + "nested": { + "ReadWrite": { + "fields": { + "retryTransaction": { + "type": "bytes", + "id": 1 + } + } }, - "pageToken": { - "type": "string", - "id": 4 - }, - "orderBy": { - "type": "string", - "id": 6 - }, - "mask": { - "type": "DocumentMask", - "id": 7 - }, - "transaction": { - "type": "bytes", - "id": 8 - }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 10 - }, - "showMissing": { - "type": "bool", - "id": 12 - } - } - }, - "ListDocumentsResponse": { - "fields": { - "documents": { - "rule": "repeated", - "type": "Document", - "id": 1 - }, - "nextPageToken": { - "type": "string", - "id": 2 + "ReadOnly": { + "oneofs": { + "consistencySelector": { + "oneof": [ + "readTime" + ] + } + }, + "fields": { + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + } + } } } }, - "CreateDocumentRequest": { + "Document": { "fields": { - "parent": { - "type": "string", - "id": 1 - }, - "collectionId": { - "type": "string", - "id": 2 - }, - "documentId": { + "name": { "type": "string", - "id": 3 - }, - "document": { - "type": "Document", - "id": 4 - }, - "mask": { - "type": "DocumentMask", - "id": 5 - } - } - }, - "UpdateDocumentRequest": { - "fields": { - "document": { - "type": "Document", "id": 1 }, - "updateMask": { - "type": "DocumentMask", + "fields": { + "keyType": "string", + "type": "Value", "id": 2 }, - "mask": { - "type": "DocumentMask", + "createTime": { + "type": "google.protobuf.Timestamp", "id": 3 }, - "currentDocument": { - "type": "Precondition", + "updateTime": { + "type": "google.protobuf.Timestamp", "id": 4 } } }, - "DeleteDocumentRequest": { - "fields": { - "name": { - "type": "string", - "id": 1 - }, - "currentDocument": { - "type": "Precondition", - "id": 2 - } - } - }, - "BatchGetDocumentsRequest": { + "Value": { "oneofs": { - "consistencySelector": { + "valueType": { "oneof": [ - "transaction", - "newTransaction", - "readTime" + "nullValue", + "booleanValue", + "integerValue", + "doubleValue", + "timestampValue", + "stringValue", + "bytesValue", + "referenceValue", + "geoPointValue", + "arrayValue", + "mapValue" ] } }, "fields": { - "database": { - "type": "string", + "nullValue": { + "type": "google.protobuf.NullValue", + "id": 11 + }, + "booleanValue": { + "type": "bool", "id": 1 }, - "documents": { - "rule": "repeated", - "type": "string", + "integerValue": { + "type": "int64", "id": 2 }, - "mask": { - "type": "DocumentMask", + "doubleValue": { + "type": "double", "id": 3 }, - "transaction": { - "type": "bytes", - "id": 4 - }, - "newTransaction": { - "type": "TransactionOptions", - "id": 5 - }, - "readTime": { + "timestampValue": { "type": "google.protobuf.Timestamp", - "id": 7 - } - } - }, - "BatchGetDocumentsResponse": { - "oneofs": { - "result": { - "oneof": [ - "found", - "missing" - ] - } - }, - "fields": { - "found": { - "type": "Document", - "id": 1 + "id": 10 }, - "missing": { + "stringValue": { "type": "string", - "id": 2 + "id": 17 }, - "transaction": { + "bytesValue": { "type": "bytes", - "id": 3 + "id": 18 }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 4 + "referenceValue": { + "type": "string", + "id": 5 + }, + "geoPointValue": { + "type": "google.type.LatLng", + "id": 8 + }, + "arrayValue": { + "type": "ArrayValue", + "id": 9 + }, + "mapValue": { + "type": "MapValue", + "id": 6 } } }, - "BeginTransactionRequest": { + "ArrayValue": { "fields": { - "database": { - "type": "string", + "values": { + "rule": "repeated", + "type": "Value", "id": 1 - }, - "options": { - "type": "TransactionOptions", - "id": 2 } } }, - "BeginTransactionResponse": { + "MapValue": { "fields": { - "transaction": { - "type": "bytes", + "fields": { + "keyType": "string", + "type": "Value", "id": 1 } } }, - "CommitRequest": { + "Write": { + "oneofs": { + "operation": { + "oneof": [ + "update", + "delete", + "transform" + ] + } + }, "fields": { - "database": { - "type": "string", + "update": { + "type": "Document", "id": 1 }, - "writes": { - "rule": "repeated", - "type": "Write", + "delete": { + "type": "string", "id": 2 }, - "transaction": { - "type": "bytes", + "transform": { + "type": "DocumentTransform", + "id": 6 + }, + "updateMask": { + "type": "DocumentMask", "id": 3 - } - } - }, - "CommitResponse": { - "fields": { - "writeResults": { - "rule": "repeated", - "type": "WriteResult", - "id": 1 }, - "commitTime": { - "type": "google.protobuf.Timestamp", - "id": 2 + "currentDocument": { + "type": "Precondition", + "id": 4 } } }, - "RollbackRequest": { + "DocumentTransform": { "fields": { - "database": { + "document": { "type": "string", "id": 1 }, - "transaction": { - "type": "bytes", + "fieldTransforms": { + "rule": "repeated", + "type": "FieldTransform", "id": 2 } - } - }, - "RunQueryRequest": { - "oneofs": { - "queryType": { - "oneof": [ - "structuredQuery" - ] - }, - "consistencySelector": { - "oneof": [ - "transaction", - "newTransaction", - "readTime" - ] - } }, + "nested": { + "FieldTransform": { + "oneofs": { + "transformType": { + "oneof": [ + "setToServerValue", + "increment", + "maximum", + "minimum", + "appendMissingElements", + "removeAllFromArray" + ] + } + }, + "fields": { + "fieldPath": { + "type": "string", + "id": 1 + }, + "setToServerValue": { + "type": "ServerValue", + "id": 2 + }, + "increment": { + "type": "Value", + "id": 3 + }, + "maximum": { + "type": "Value", + "id": 4 + }, + "minimum": { + "type": "Value", + "id": 5 + }, + "appendMissingElements": { + "type": "ArrayValue", + "id": 6 + }, + "removeAllFromArray": { + "type": "ArrayValue", + "id": 7 + } + }, + "nested": { + "ServerValue": { + "values": { + "SERVER_VALUE_UNSPECIFIED": 0, + "REQUEST_TIME": 1 + } + } + } + } + } + }, + "WriteResult": { "fields": { - "parent": { - "type": "string", + "updateTime": { + "type": "google.protobuf.Timestamp", "id": 1 }, - "structuredQuery": { - "type": "StructuredQuery", + "transformResults": { + "rule": "repeated", + "type": "Value", "id": 2 - }, - "transaction": { - "type": "bytes", - "id": 5 - }, - "newTransaction": { - "type": "TransactionOptions", - "id": 6 - }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 7 } } }, - "RunQueryResponse": { + "DocumentChange": { "fields": { - "transaction": { - "type": "bytes", - "id": 2 - }, "document": { "type": "Document", "id": 1 }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 3 + "targetIds": { + "rule": "repeated", + "type": "int32", + "id": 5 }, - "skippedResults": { + "removedTargetIds": { + "rule": "repeated", "type": "int32", - "id": 4 + "id": 6 } } }, - "WriteRequest": { + "DocumentDelete": { "fields": { - "database": { + "document": { "type": "string", "id": 1 }, - "streamId": { - "type": "string", - "id": 2 - }, - "writes": { + "removedTargetIds": { "rule": "repeated", - "type": "Write", - "id": 3 + "type": "int32", + "id": 6 }, - "streamToken": { - "type": "bytes", + "readTime": { + "type": "google.protobuf.Timestamp", "id": 4 - }, - "labels": { - "keyType": "string", - "type": "string", - "id": 5 } } }, - "WriteResponse": { + "DocumentRemove": { "fields": { - "streamId": { + "document": { "type": "string", "id": 1 }, - "streamToken": { - "type": "bytes", - "id": 2 - }, - "writeResults": { + "removedTargetIds": { "rule": "repeated", - "type": "WriteResult", - "id": 3 + "type": "int32", + "id": 2 }, - "commitTime": { + "readTime": { "type": "google.protobuf.Timestamp", "id": 4 } } }, - "ListenRequest": { - "oneofs": { - "targetChange": { - "oneof": [ - "addTarget", - "removeTarget" - ] - } - }, + "ExistenceFilter": { "fields": { - "database": { - "type": "string", + "targetId": { + "type": "int32", "id": 1 }, - "addTarget": { - "type": "Target", - "id": 2 - }, - "removeTarget": { + "count": { "type": "int32", - "id": 3 - }, - "labels": { - "keyType": "string", - "type": "string", - "id": 4 + "id": 2 } } }, - "ListenResponse": { - "oneofs": { - "responseType": { - "oneof": [ - "targetChange", - "documentChange", - "documentDelete", - "documentRemove", - "filter" - ] - } - }, + "StructuredQuery": { "fields": { - "targetChange": { - "type": "TargetChange", + "select": { + "type": "Projection", + "id": 1 + }, + "from": { + "rule": "repeated", + "type": "CollectionSelector", "id": 2 }, - "documentChange": { - "type": "DocumentChange", + "where": { + "type": "Filter", "id": 3 }, - "documentDelete": { - "type": "DocumentDelete", + "orderBy": { + "rule": "repeated", + "type": "Order", "id": 4 }, - "documentRemove": { - "type": "DocumentRemove", + "startAt": { + "type": "Cursor", + "id": 7 + }, + "endAt": { + "type": "Cursor", + "id": 8 + }, + "offset": { + "type": "int32", "id": 6 }, - "filter": { - "type": "ExistenceFilter", + "limit": { + "type": "google.protobuf.Int32Value", "id": 5 } - } - }, - "Target": { - "oneofs": { - "targetType": { - "oneof": [ - "query", - "documents" - ] - }, - "resumeType": { - "oneof": [ - "resumeToken", - "readTime" - ] - } }, - "fields": { - "query": { - "type": "QueryTarget", - "id": 2 - }, - "documents": { - "type": "DocumentsTarget", - "id": 3 + "nested": { + "CollectionSelector": { + "fields": { + "collectionId": { + "type": "string", + "id": 2 + }, + "allDescendants": { + "type": "bool", + "id": 3 + } + } }, - "resumeToken": { - "type": "bytes", - "id": 4 - }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 11 - }, - "targetId": { - "type": "int32", - "id": 5 + "Filter": { + "oneofs": { + "filterType": { + "oneof": [ + "compositeFilter", + "fieldFilter", + "unaryFilter" + ] + } + }, + "fields": { + "compositeFilter": { + "type": "CompositeFilter", + "id": 1 + }, + "fieldFilter": { + "type": "FieldFilter", + "id": 2 + }, + "unaryFilter": { + "type": "UnaryFilter", + "id": 3 + } + } }, - "once": { - "type": "bool", - "id": 6 - } - }, - "nested": { - "DocumentsTarget": { + "CompositeFilter": { "fields": { - "documents": { + "op": { + "type": "Operator", + "id": 1 + }, + "filters": { "rule": "repeated", - "type": "string", + "type": "Filter", "id": 2 } + }, + "nested": { + "Operator": { + "values": { + "OPERATOR_UNSPECIFIED": 0, + "AND": 1 + } + } } }, - "QueryTarget": { + "FieldFilter": { + "fields": { + "field": { + "type": "FieldReference", + "id": 1 + }, + "op": { + "type": "Operator", + "id": 2 + }, + "value": { + "type": "Value", + "id": 3 + } + }, + "nested": { + "Operator": { + "values": { + "OPERATOR_UNSPECIFIED": 0, + "LESS_THAN": 1, + "LESS_THAN_OR_EQUAL": 2, + "GREATER_THAN": 3, + "GREATER_THAN_OR_EQUAL": 4, + "EQUAL": 5, + "ARRAY_CONTAINS": 7, + "IN": 8, + "ARRAY_CONTAINS_ANY": 9 + } + } + } + }, + "UnaryFilter": { "oneofs": { - "queryType": { + "operandType": { "oneof": [ - "structuredQuery" + "field" ] } }, "fields": { - "parent": { - "type": "string", + "op": { + "type": "Operator", "id": 1 }, - "structuredQuery": { - "type": "StructuredQuery", + "field": { + "type": "FieldReference", "id": 2 } + }, + "nested": { + "Operator": { + "values": { + "OPERATOR_UNSPECIFIED": 0, + "IS_NAN": 2, + "IS_NULL": 3 + } + } } - } - } - }, - "TargetChange": { - "fields": { - "targetChangeType": { - "type": "TargetChangeType", - "id": 1 - }, - "targetIds": { - "rule": "repeated", - "type": "int32", - "id": 2 - }, - "cause": { - "type": "google.rpc.Status", - "id": 3 }, - "resumeToken": { - "type": "bytes", - "id": 4 + "Order": { + "fields": { + "field": { + "type": "FieldReference", + "id": 1 + }, + "direction": { + "type": "Direction", + "id": 2 + } + } }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 6 - } - }, - "nested": { - "TargetChangeType": { + "Direction": { "values": { - "NO_CHANGE": 0, - "ADD": 1, - "REMOVE": 2, - "CURRENT": 3, - "RESET": 4 + "DIRECTION_UNSPECIFIED": 0, + "ASCENDING": 1, + "DESCENDING": 2 } - } - } - }, - "ListCollectionIdsRequest": { - "fields": { - "parent": { - "type": "string", - "id": 1 }, - "pageSize": { - "type": "int32", - "id": 2 + "FieldReference": { + "fields": { + "fieldPath": { + "type": "string", + "id": 2 + } + } }, - "pageToken": { - "type": "string", - "id": 3 + "Projection": { + "fields": { + "fields": { + "rule": "repeated", + "type": "FieldReference", + "id": 2 + } + } } } }, - "ListCollectionIdsResponse": { + "Cursor": { "fields": { - "collectionIds": { + "values": { "rule": "repeated", - "type": "string", + "type": "Value", "id": 1 }, - "nextPageToken": { - "type": "string", - "id": 2 - } - } - }, - "DocumentMask": { - "fields": { - "fieldPaths": { - "rule": "repeated", - "type": "string", - "id": 1 - } - } - }, - "Precondition": { - "oneofs": { - "conditionType": { - "oneof": [ - "exists", - "updateTime" - ] - } - }, - "fields": { - "exists": { + "before": { "type": "bool", - "id": 1 - }, - "updateTime": { - "type": "google.protobuf.Timestamp", "id": 2 } } }, - "TransactionOptions": { - "oneofs": { - "mode": { - "oneof": [ - "readOnly", - "readWrite" - ] - } + "Firestore": { + "options": { + "(google.api.default_host)": "firestore.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/datastore" }, - "fields": { - "readOnly": { - "type": "ReadOnly", - "id": 2 + "methods": { + "GetDocument": { + "requestType": "GetDocumentRequest", + "responseType": "Document", + "options": { + "(google.api.http).get": "/v1/{name=projects/*/databases/*/documents/*/**}" + } }, - "readWrite": { - "type": "ReadWrite", - "id": 3 - } - }, - "nested": { - "ReadWrite": { - "fields": { - "retryTransaction": { - "type": "bytes", - "id": 1 - } + "ListDocuments": { + "requestType": "ListDocumentsRequest", + "responseType": "ListDocumentsResponse", + "options": { + "(google.api.http).get": "/v1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" } }, - "ReadOnly": { - "oneofs": { - "consistencySelector": { - "oneof": [ - "readTime" - ] - } - }, - "fields": { - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 2 - } + "CreateDocument": { + "requestType": "CreateDocumentRequest", + "responseType": "Document", + "options": { + "(google.api.http).post": "/v1/{parent=projects/*/databases/*/documents/**}/{collection_id}", + "(google.api.http).body": "document" + } + }, + "UpdateDocument": { + "requestType": "UpdateDocumentRequest", + "responseType": "Document", + "options": { + "(google.api.http).patch": "/v1/{document.name=projects/*/databases/*/documents/*/**}", + "(google.api.http).body": "document", + "(google.api.method_signature)": "document,update_mask" + } + }, + "DeleteDocument": { + "requestType": "DeleteDocumentRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v1/{name=projects/*/databases/*/documents/*/**}", + "(google.api.method_signature)": "name" + } + }, + "BatchGetDocuments": { + "requestType": "BatchGetDocumentsRequest", + "responseType": "BatchGetDocumentsResponse", + "responseStream": true, + "options": { + "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:batchGet", + "(google.api.http).body": "*" + } + }, + "BeginTransaction": { + "requestType": "BeginTransactionRequest", + "responseType": "BeginTransactionResponse", + "options": { + "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:beginTransaction", + "(google.api.http).body": "*", + "(google.api.method_signature)": "database" + } + }, + "Commit": { + "requestType": "CommitRequest", + "responseType": "CommitResponse", + "options": { + "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:commit", + "(google.api.http).body": "*", + "(google.api.method_signature)": "database,writes" + } + }, + "Rollback": { + "requestType": "RollbackRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:rollback", + "(google.api.http).body": "*", + "(google.api.method_signature)": "database,transaction" + } + }, + "RunQuery": { + "requestType": "RunQueryRequest", + "responseType": "RunQueryResponse", + "responseStream": true, + "options": { + "(google.api.http).post": "/v1/{parent=projects/*/databases/*/documents}:runQuery", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v1/{parent=projects/*/databases/*/documents/*/**}:runQuery", + "(google.api.http).additional_bindings.body": "*" + } + }, + "Write": { + "requestType": "WriteRequest", + "requestStream": true, + "responseType": "WriteResponse", + "responseStream": true, + "options": { + "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:write", + "(google.api.http).body": "*" + } + }, + "Listen": { + "requestType": "ListenRequest", + "requestStream": true, + "responseType": "ListenResponse", + "responseStream": true, + "options": { + "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:listen", + "(google.api.http).body": "*" + } + }, + "ListCollectionIds": { + "requestType": "ListCollectionIdsRequest", + "responseType": "ListCollectionIdsResponse", + "options": { + "(google.api.http).post": "/v1/{parent=projects/*/databases/*/documents}:listCollectionIds", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds", + "(google.api.http).additional_bindings.body": "*", + "(google.api.method_signature)": "parent" } } } }, - "Document": { + "GetDocumentRequest": { + "oneofs": { + "consistencySelector": { + "oneof": [ + "transaction", + "readTime" + ] + } + }, "fields": { "name": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "fields": { - "keyType": "string", - "type": "Value", + "mask": { + "type": "DocumentMask", "id": 2 }, - "createTime": { - "type": "google.protobuf.Timestamp", + "transaction": { + "type": "bytes", "id": 3 }, - "updateTime": { + "readTime": { "type": "google.protobuf.Timestamp", - "id": 4 + "id": 5 } } }, - "Value": { + "ListDocumentsRequest": { "oneofs": { - "valueType": { + "consistencySelector": { "oneof": [ - "nullValue", - "booleanValue", - "integerValue", - "doubleValue", - "timestampValue", - "stringValue", - "bytesValue", - "referenceValue", - "geoPointValue", - "arrayValue", - "mapValue" + "transaction", + "readTime" ] } }, "fields": { - "nullValue": { - "type": "google.protobuf.NullValue", - "id": 11 - }, - "booleanValue": { - "type": "bool", - "id": 1 + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "integerValue": { - "type": "int64", - "id": 2 + "collectionId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "doubleValue": { - "type": "double", + "pageSize": { + "type": "int32", "id": 3 }, - "timestampValue": { - "type": "google.protobuf.Timestamp", - "id": 10 - }, - "stringValue": { + "pageToken": { "type": "string", - "id": 17 - }, - "bytesValue": { - "type": "bytes", - "id": 18 + "id": 4 }, - "referenceValue": { + "orderBy": { "type": "string", - "id": 5 + "id": 6 }, - "geoPointValue": { - "type": "google.type.LatLng", + "mask": { + "type": "DocumentMask", + "id": 7 + }, + "transaction": { + "type": "bytes", "id": 8 }, - "arrayValue": { - "type": "ArrayValue", - "id": 9 + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 10 }, - "mapValue": { - "type": "MapValue", - "id": 6 + "showMissing": { + "type": "bool", + "id": 12 } } }, - "ArrayValue": { + "ListDocumentsResponse": { "fields": { - "values": { + "documents": { "rule": "repeated", - "type": "Value", - "id": 1 - } - } - }, - "MapValue": { - "fields": { - "fields": { - "keyType": "string", - "type": "Value", + "type": "Document", "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 } } }, - "StructuredQuery": { + "CreateDocumentRequest": { "fields": { - "select": { - "type": "Projection", - "id": 1 + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "from": { - "rule": "repeated", - "type": "CollectionSelector", - "id": 2 + "collectionId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "where": { - "type": "Filter", + "documentId": { + "type": "string", "id": 3 }, - "orderBy": { - "rule": "repeated", - "type": "Order", - "id": 4 - }, - "startAt": { - "type": "Cursor", - "id": 7 - }, - "endAt": { - "type": "Cursor", - "id": 8 - }, - "offset": { - "type": "int32", - "id": 6 + "document": { + "type": "Document", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "limit": { - "type": "google.protobuf.Int32Value", + "mask": { + "type": "DocumentMask", "id": 5 } - }, - "nested": { - "CollectionSelector": { - "fields": { - "collectionId": { - "type": "string", - "id": 2 - }, - "allDescendants": { - "type": "bool", - "id": 3 - } - } - }, - "Filter": { - "oneofs": { - "filterType": { - "oneof": [ - "compositeFilter", - "fieldFilter", - "unaryFilter" - ] - } - }, - "fields": { - "compositeFilter": { - "type": "CompositeFilter", - "id": 1 - }, - "fieldFilter": { - "type": "FieldFilter", - "id": 2 - }, - "unaryFilter": { - "type": "UnaryFilter", - "id": 3 - } - } - }, - "CompositeFilter": { - "fields": { - "op": { - "type": "Operator", - "id": 1 - }, - "filters": { - "rule": "repeated", - "type": "Filter", - "id": 2 - } - }, - "nested": { - "Operator": { - "values": { - "OPERATOR_UNSPECIFIED": 0, - "AND": 1 - } - } - } - }, - "FieldFilter": { - "fields": { - "field": { - "type": "FieldReference", - "id": 1 - }, - "op": { - "type": "Operator", - "id": 2 - }, - "value": { - "type": "Value", - "id": 3 - } - }, - "nested": { - "Operator": { - "values": { - "OPERATOR_UNSPECIFIED": 0, - "LESS_THAN": 1, - "LESS_THAN_OR_EQUAL": 2, - "GREATER_THAN": 3, - "GREATER_THAN_OR_EQUAL": 4, - "EQUAL": 5, - "ARRAY_CONTAINS": 7, - "IN": 8, - "ARRAY_CONTAINS_ANY": 9 - } - } - } - }, - "UnaryFilter": { - "oneofs": { - "operandType": { - "oneof": [ - "field" - ] - } - }, - "fields": { - "op": { - "type": "Operator", - "id": 1 - }, - "field": { - "type": "FieldReference", - "id": 2 - } - }, - "nested": { - "Operator": { - "values": { - "OPERATOR_UNSPECIFIED": 0, - "IS_NAN": 2, - "IS_NULL": 3 - } - } - } - }, - "Projection": { - "fields": { - "fields": { - "rule": "repeated", - "type": "FieldReference", - "id": 2 - } + } + }, + "UpdateDocumentRequest": { + "fields": { + "document": { + "type": "Document", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" } }, - "Order": { - "fields": { - "field": { - "type": "FieldReference", - "id": 1 - }, - "direction": { - "type": "Direction", - "id": 2 - } - } + "updateMask": { + "type": "DocumentMask", + "id": 2 }, - "FieldReference": { - "fields": { - "fieldPath": { - "type": "string", - "id": 2 - } - } + "mask": { + "type": "DocumentMask", + "id": 3 }, - "Direction": { - "values": { - "DIRECTION_UNSPECIFIED": 0, - "ASCENDING": 1, - "DESCENDING": 2 - } + "currentDocument": { + "type": "Precondition", + "id": 4 } } }, - "Cursor": { + "DeleteDocumentRequest": { "fields": { - "values": { - "rule": "repeated", - "type": "Value", - "id": 1 + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "before": { - "type": "bool", + "currentDocument": { + "type": "Precondition", "id": 2 } } }, - "Write": { + "BatchGetDocumentsRequest": { "oneofs": { - "operation": { + "consistencySelector": { "oneof": [ - "update", - "delete", - "transform" + "transaction", + "newTransaction", + "readTime" ] } }, "fields": { - "update": { - "type": "Document", - "id": 1 + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "delete": { + "documents": { + "rule": "repeated", "type": "string", "id": 2 }, - "transform": { - "type": "DocumentTransform", - "id": 6 - }, - "updateMask": { + "mask": { "type": "DocumentMask", "id": 3 }, - "currentDocument": { - "type": "Precondition", + "transaction": { + "type": "bytes", "id": 4 + }, + "newTransaction": { + "type": "TransactionOptions", + "id": 5 + }, + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 7 } } }, - "DocumentTransform": { + "BatchGetDocumentsResponse": { + "oneofs": { + "result": { + "oneof": [ + "found", + "missing" + ] + } + }, "fields": { - "document": { - "type": "string", + "found": { + "type": "Document", "id": 1 }, - "fieldTransforms": { - "rule": "repeated", - "type": "FieldTransform", + "missing": { + "type": "string", "id": 2 + }, + "transaction": { + "type": "bytes", + "id": 3 + }, + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 4 } - }, - "nested": { - "FieldTransform": { - "oneofs": { - "transformType": { - "oneof": [ - "setToServerValue", - "increment", - "maximum", - "minimum", - "appendMissingElements", - "removeAllFromArray" - ] - } - }, - "fields": { - "fieldPath": { - "type": "string", - "id": 1 - }, - "setToServerValue": { - "type": "ServerValue", - "id": 2 - }, - "increment": { - "type": "Value", - "id": 3 - }, - "maximum": { - "type": "Value", - "id": 4 - }, - "minimum": { - "type": "Value", - "id": 5 - }, - "appendMissingElements": { - "type": "ArrayValue", - "id": 6 - }, - "removeAllFromArray": { - "type": "ArrayValue", - "id": 7 - } - }, - "nested": { - "ServerValue": { - "values": { - "SERVER_VALUE_UNSPECIFIED": 0, - "REQUEST_TIME": 1 - } - } + } + }, + "BeginTransactionRequest": { + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" } + }, + "options": { + "type": "TransactionOptions", + "id": 2 } } }, - "WriteResult": { + "BeginTransactionResponse": { "fields": { - "updateTime": { - "type": "google.protobuf.Timestamp", + "transaction": { + "type": "bytes", "id": 1 + } + } + }, + "CommitRequest": { + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "transformResults": { + "writes": { "rule": "repeated", - "type": "Value", + "type": "Write", "id": 2 + }, + "transaction": { + "type": "bytes", + "id": 3 } } }, - "DocumentChange": { + "CommitResponse": { "fields": { - "document": { - "type": "Document", + "writeResults": { + "rule": "repeated", + "type": "WriteResult", "id": 1 }, - "targetIds": { - "rule": "repeated", - "type": "int32", - "id": 5 + "commitTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + } + } + }, + "RollbackRequest": { + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "removedTargetIds": { - "rule": "repeated", - "type": "int32", - "id": 6 + "transaction": { + "type": "bytes", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } } } }, - "DocumentDelete": { + "RunQueryRequest": { + "oneofs": { + "queryType": { + "oneof": [ + "structuredQuery" + ] + }, + "consistencySelector": { + "oneof": [ + "transaction", + "newTransaction", + "readTime" + ] + } + }, "fields": { - "document": { + "parent": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "removedTargetIds": { - "rule": "repeated", - "type": "int32", + "structuredQuery": { + "type": "StructuredQuery", + "id": 2 + }, + "transaction": { + "type": "bytes", + "id": 5 + }, + "newTransaction": { + "type": "TransactionOptions", "id": 6 }, "readTime": { "type": "google.protobuf.Timestamp", - "id": 4 + "id": 7 } } }, - "DocumentRemove": { + "RunQueryResponse": { "fields": { + "transaction": { + "type": "bytes", + "id": 2 + }, "document": { - "type": "string", + "type": "Document", "id": 1 }, - "removedTargetIds": { - "rule": "repeated", + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + }, + "skippedResults": { "type": "int32", + "id": 4 + } + } + }, + "WriteRequest": { + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "streamId": { + "type": "string", "id": 2 }, - "readTime": { - "type": "google.protobuf.Timestamp", + "writes": { + "rule": "repeated", + "type": "Write", + "id": 3 + }, + "streamToken": { + "type": "bytes", "id": 4 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 5 } } }, - "ExistenceFilter": { + "WriteResponse": { "fields": { - "targetId": { - "type": "int32", + "streamId": { + "type": "string", "id": 1 }, - "count": { - "type": "int32", + "streamToken": { + "type": "bytes", "id": 2 + }, + "writeResults": { + "rule": "repeated", + "type": "WriteResult", + "id": 3 + }, + "commitTime": { + "type": "google.protobuf.Timestamp", + "id": 4 } } - } - } - }, - "v1beta1": { - "options": { - "csharp_namespace": "Google.Cloud.Firestore.V1Beta1", - "go_package": "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore", - "java_multiple_files": true, - "java_outer_classname": "WriteProto", - "java_package": "com.google.firestore.v1beta1", - "objc_class_prefix": "GCFS", - "php_namespace": "Google\\Cloud\\Firestore\\V1beta1" - }, - "nested": { - "Firestore": { - "options": { - "(google.api.default_host)": "firestore.googleapis.com", - "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/datastore" + }, + "ListenRequest": { + "oneofs": { + "targetChange": { + "oneof": [ + "addTarget", + "removeTarget" + ] + } }, - "methods": { - "GetDocument": { - "requestType": "GetDocumentRequest", - "responseType": "Document", - "options": { - "(google.api.http).get": "/v1beta1/{name=projects/*/databases/*/documents/*/**}" - } - }, - "ListDocuments": { - "requestType": "ListDocumentsRequest", - "responseType": "ListDocumentsResponse", - "options": { - "(google.api.http).get": "/v1beta1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" - } - }, - "CreateDocument": { - "requestType": "CreateDocumentRequest", - "responseType": "Document", - "options": { - "(google.api.http).post": "/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}", - "(google.api.http).body": "document" - } - }, - "UpdateDocument": { - "requestType": "UpdateDocumentRequest", - "responseType": "Document", - "options": { - "(google.api.http).patch": "/v1beta1/{document.name=projects/*/databases/*/documents/*/**}", - "(google.api.http).body": "document" - } - }, - "DeleteDocument": { - "requestType": "DeleteDocumentRequest", - "responseType": "google.protobuf.Empty", - "options": { - "(google.api.http).delete": "/v1beta1/{name=projects/*/databases/*/documents/*/**}" - } - }, - "BatchGetDocuments": { - "requestType": "BatchGetDocumentsRequest", - "responseType": "BatchGetDocumentsResponse", - "responseStream": true, - "options": { - "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:batchGet", - "(google.api.http).body": "*" - } - }, - "BeginTransaction": { - "requestType": "BeginTransactionRequest", - "responseType": "BeginTransactionResponse", - "options": { - "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:beginTransaction", - "(google.api.http).body": "*" - } - }, - "Commit": { - "requestType": "CommitRequest", - "responseType": "CommitResponse", - "options": { - "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:commit", - "(google.api.http).body": "*" - } - }, - "Rollback": { - "requestType": "RollbackRequest", - "responseType": "google.protobuf.Empty", - "options": { - "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:rollback", - "(google.api.http).body": "*" - } - }, - "RunQuery": { - "requestType": "RunQueryRequest", - "responseType": "RunQueryResponse", - "responseStream": true, + "fields": { + "database": { + "type": "string", + "id": 1, "options": { - "(google.api.http).post": "/v1beta1/{parent=projects/*/databases/*/documents}:runQuery", - "(google.api.http).body": "*", - "(google.api.http).additional_bindings.post": "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:runQuery", - "(google.api.http).additional_bindings.body": "*" + "(google.api.field_behavior)": "REQUIRED" } }, - "Write": { - "requestType": "WriteRequest", - "requestStream": true, - "responseType": "WriteResponse", - "responseStream": true, - "options": { - "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:write", - "(google.api.http).body": "*" - } + "addTarget": { + "type": "Target", + "id": 2 }, - "Listen": { - "requestType": "ListenRequest", - "requestStream": true, - "responseType": "ListenResponse", - "responseStream": true, - "options": { - "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:listen", - "(google.api.http).body": "*" - } + "removeTarget": { + "type": "int32", + "id": 3 }, - "ListCollectionIds": { - "requestType": "ListCollectionIdsRequest", - "responseType": "ListCollectionIdsResponse", - "options": { - "(google.api.http).post": "/v1beta1/{parent=projects/*/databases/*/documents}:listCollectionIds", - "(google.api.http).body": "*", - "(google.api.http).additional_bindings.post": "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds", - "(google.api.http).additional_bindings.body": "*" - } + "labels": { + "keyType": "string", + "type": "string", + "id": 4 } } }, - "GetDocumentRequest": { + "ListenResponse": { "oneofs": { - "consistencySelector": { + "responseType": { "oneof": [ - "transaction", - "readTime" + "targetChange", + "documentChange", + "documentDelete", + "documentRemove", + "filter" ] } }, "fields": { - "name": { - "type": "string", - "id": 1 - }, - "mask": { - "type": "DocumentMask", + "targetChange": { + "type": "TargetChange", "id": 2 }, - "transaction": { - "type": "bytes", + "documentChange": { + "type": "DocumentChange", "id": 3 }, - "readTime": { - "type": "google.protobuf.Timestamp", + "documentDelete": { + "type": "DocumentDelete", + "id": 4 + }, + "documentRemove": { + "type": "DocumentRemove", + "id": 6 + }, + "filter": { + "type": "ExistenceFilter", "id": 5 } } }, - "ListDocumentsRequest": { + "Target": { "oneofs": { - "consistencySelector": { + "targetType": { "oneof": [ - "transaction", + "query", + "documents" + ] + }, + "resumeType": { + "oneof": [ + "resumeToken", "readTime" ] } }, "fields": { - "parent": { - "type": "string", - "id": 1 - }, - "collectionId": { - "type": "string", + "query": { + "type": "QueryTarget", "id": 2 }, - "pageSize": { - "type": "int32", + "documents": { + "type": "DocumentsTarget", "id": 3 }, - "pageToken": { - "type": "string", - "id": 4 - }, - "orderBy": { - "type": "string", - "id": 6 - }, - "mask": { - "type": "DocumentMask", - "id": 7 - }, - "transaction": { + "resumeToken": { "type": "bytes", - "id": 8 + "id": 4 }, "readTime": { "type": "google.protobuf.Timestamp", - "id": 10 + "id": 11 }, - "showMissing": { + "targetId": { + "type": "int32", + "id": 5 + }, + "once": { "type": "bool", - "id": 12 + "id": 6 } - } - }, - "ListDocumentsResponse": { - "fields": { - "documents": { - "rule": "repeated", - "type": "Document", - "id": 1 + }, + "nested": { + "DocumentsTarget": { + "fields": { + "documents": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } }, - "nextPageToken": { - "type": "string", - "id": 2 + "QueryTarget": { + "oneofs": { + "queryType": { + "oneof": [ + "structuredQuery" + ] + } + }, + "fields": { + "parent": { + "type": "string", + "id": 1 + }, + "structuredQuery": { + "type": "StructuredQuery", + "id": 2 + } + } } } }, - "CreateDocumentRequest": { + "TargetChange": { "fields": { - "parent": { - "type": "string", + "targetChangeType": { + "type": "TargetChangeType", "id": 1 }, - "collectionId": { - "type": "string", + "targetIds": { + "rule": "repeated", + "type": "int32", "id": 2 }, - "documentId": { - "type": "string", + "cause": { + "type": "google.rpc.Status", "id": 3 }, - "document": { - "type": "Document", - "id": 4 + "resumeToken": { + "type": "bytes", + "id": 4 }, - "mask": { - "type": "DocumentMask", - "id": 5 + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 6 + } + }, + "nested": { + "TargetChangeType": { + "values": { + "NO_CHANGE": 0, + "ADD": 1, + "REMOVE": 2, + "CURRENT": 3, + "RESET": 4 + } } } }, - "UpdateDocumentRequest": { + "ListCollectionIdsRequest": { "fields": { - "document": { - "type": "Document", - "id": 1 + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "updateMask": { - "type": "DocumentMask", + "pageSize": { + "type": "int32", "id": 2 }, - "mask": { - "type": "DocumentMask", + "pageToken": { + "type": "string", "id": 3 - }, - "currentDocument": { - "type": "Precondition", - "id": 4 } } }, - "DeleteDocumentRequest": { + "ListCollectionIdsResponse": { "fields": { - "name": { + "collectionIds": { + "rule": "repeated", "type": "string", "id": 1 }, - "currentDocument": { - "type": "Precondition", + "nextPageToken": { + "type": "string", "id": 2 } } + } + } + }, + "v1beta1": { + "options": { + "csharp_namespace": "Google.Cloud.Firestore.V1Beta1", + "go_package": "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore", + "java_multiple_files": true, + "java_outer_classname": "FirestoreProto", + "java_package": "com.google.firestore.v1beta1", + "objc_class_prefix": "GCFS", + "php_namespace": "Google\\Cloud\\Firestore\\V1beta1" + }, + "nested": { + "DocumentMask": { + "fields": { + "fieldPaths": { + "rule": "repeated", + "type": "string", + "id": 1 + } + } }, - "BatchGetDocumentsRequest": { + "Precondition": { "oneofs": { - "consistencySelector": { + "conditionType": { "oneof": [ - "transaction", - "newTransaction", - "readTime" + "exists", + "updateTime" ] } }, "fields": { - "database": { - "type": "string", + "exists": { + "type": "bool", "id": 1 }, - "documents": { - "rule": "repeated", - "type": "string", - "id": 2 - }, - "mask": { - "type": "DocumentMask", - "id": 3 - }, - "transaction": { - "type": "bytes", - "id": 4 - }, - "newTransaction": { - "type": "TransactionOptions", - "id": 5 - }, - "readTime": { + "updateTime": { "type": "google.protobuf.Timestamp", - "id": 7 + "id": 2 } } }, - "BatchGetDocumentsResponse": { + "TransactionOptions": { "oneofs": { - "result": { + "mode": { "oneof": [ - "found", - "missing" + "readOnly", + "readWrite" ] } }, "fields": { - "found": { - "type": "Document", - "id": 1 - }, - "missing": { - "type": "string", + "readOnly": { + "type": "ReadOnly", "id": 2 }, - "transaction": { - "type": "bytes", + "readWrite": { + "type": "ReadWrite", "id": 3 + } + }, + "nested": { + "ReadWrite": { + "fields": { + "retryTransaction": { + "type": "bytes", + "id": 1 + } + } }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 4 + "ReadOnly": { + "oneofs": { + "consistencySelector": { + "oneof": [ + "readTime" + ] + } + }, + "fields": { + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + } + } } } }, - "BeginTransactionRequest": { + "Document": { "fields": { - "database": { + "name": { "type": "string", "id": 1 }, - "options": { - "type": "TransactionOptions", + "fields": { + "keyType": "string", + "type": "Value", "id": 2 + }, + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 4 } } }, - "BeginTransactionResponse": { - "fields": { - "transaction": { - "type": "bytes", - "id": 1 + "Value": { + "oneofs": { + "valueType": { + "oneof": [ + "nullValue", + "booleanValue", + "integerValue", + "doubleValue", + "timestampValue", + "stringValue", + "bytesValue", + "referenceValue", + "geoPointValue", + "arrayValue", + "mapValue" + ] } - } - }, - "CommitRequest": { + }, "fields": { - "database": { - "type": "string", + "nullValue": { + "type": "google.protobuf.NullValue", + "id": 11 + }, + "booleanValue": { + "type": "bool", "id": 1 }, - "writes": { - "rule": "repeated", - "type": "Write", + "integerValue": { + "type": "int64", "id": 2 }, - "transaction": { - "type": "bytes", + "doubleValue": { + "type": "double", "id": 3 + }, + "timestampValue": { + "type": "google.protobuf.Timestamp", + "id": 10 + }, + "stringValue": { + "type": "string", + "id": 17 + }, + "bytesValue": { + "type": "bytes", + "id": 18 + }, + "referenceValue": { + "type": "string", + "id": 5 + }, + "geoPointValue": { + "type": "google.type.LatLng", + "id": 8 + }, + "arrayValue": { + "type": "ArrayValue", + "id": 9 + }, + "mapValue": { + "type": "MapValue", + "id": 6 } } }, - "CommitResponse": { + "ArrayValue": { "fields": { - "writeResults": { + "values": { "rule": "repeated", - "type": "WriteResult", + "type": "Value", "id": 1 - }, - "commitTime": { - "type": "google.protobuf.Timestamp", - "id": 2 } } }, - "RollbackRequest": { + "MapValue": { "fields": { - "database": { - "type": "string", + "fields": { + "keyType": "string", + "type": "Value", "id": 1 - }, - "transaction": { - "type": "bytes", - "id": 2 } } }, - "RunQueryRequest": { + "Write": { "oneofs": { - "queryType": { - "oneof": [ - "structuredQuery" - ] - }, - "consistencySelector": { + "operation": { "oneof": [ - "transaction", - "newTransaction", - "readTime" + "update", + "delete", + "transform" ] } }, "fields": { - "parent": { - "type": "string", + "update": { + "type": "Document", "id": 1 }, - "structuredQuery": { - "type": "StructuredQuery", + "delete": { + "type": "string", "id": 2 }, - "transaction": { - "type": "bytes", - "id": 5 - }, - "newTransaction": { - "type": "TransactionOptions", + "transform": { + "type": "DocumentTransform", "id": 6 }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 7 + "updateMask": { + "type": "DocumentMask", + "id": 3 + }, + "currentDocument": { + "type": "Precondition", + "id": 4 } } }, - "RunQueryResponse": { + "DocumentTransform": { "fields": { - "transaction": { - "type": "bytes", + "document": { + "type": "string", + "id": 1 + }, + "fieldTransforms": { + "rule": "repeated", + "type": "FieldTransform", "id": 2 + } + }, + "nested": { + "FieldTransform": { + "oneofs": { + "transformType": { + "oneof": [ + "setToServerValue", + "increment", + "maximum", + "minimum", + "appendMissingElements", + "removeAllFromArray" + ] + } + }, + "fields": { + "fieldPath": { + "type": "string", + "id": 1 + }, + "setToServerValue": { + "type": "ServerValue", + "id": 2 + }, + "increment": { + "type": "Value", + "id": 3 + }, + "maximum": { + "type": "Value", + "id": 4 + }, + "minimum": { + "type": "Value", + "id": 5 + }, + "appendMissingElements": { + "type": "ArrayValue", + "id": 6 + }, + "removeAllFromArray": { + "type": "ArrayValue", + "id": 7 + } + }, + "nested": { + "ServerValue": { + "values": { + "SERVER_VALUE_UNSPECIFIED": 0, + "REQUEST_TIME": 1 + } + } + } + } + } + }, + "WriteResult": { + "fields": { + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 1 }, + "transformResults": { + "rule": "repeated", + "type": "Value", + "id": 2 + } + } + }, + "DocumentChange": { + "fields": { "document": { "type": "Document", "id": 1 }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 3 + "targetIds": { + "rule": "repeated", + "type": "int32", + "id": 5 }, - "skippedResults": { + "removedTargetIds": { + "rule": "repeated", "type": "int32", - "id": 4 + "id": 6 } } }, - "WriteRequest": { + "DocumentDelete": { "fields": { - "database": { + "document": { "type": "string", "id": 1 }, - "streamId": { - "type": "string", - "id": 2 - }, - "writes": { + "removedTargetIds": { "rule": "repeated", - "type": "Write", - "id": 3 + "type": "int32", + "id": 6 }, - "streamToken": { - "type": "bytes", + "readTime": { + "type": "google.protobuf.Timestamp", "id": 4 - }, - "labels": { - "keyType": "string", - "type": "string", - "id": 5 } } }, - "WriteResponse": { + "DocumentRemove": { "fields": { - "streamId": { + "document": { "type": "string", "id": 1 }, - "streamToken": { - "type": "bytes", - "id": 2 - }, - "writeResults": { + "removedTargetIds": { "rule": "repeated", - "type": "WriteResult", - "id": 3 + "type": "int32", + "id": 2 }, - "commitTime": { + "readTime": { "type": "google.protobuf.Timestamp", "id": 4 } } }, - "ListenRequest": { - "oneofs": { - "targetChange": { - "oneof": [ - "addTarget", - "removeTarget" - ] - } - }, + "ExistenceFilter": { "fields": { - "database": { - "type": "string", + "targetId": { + "type": "int32", "id": 1 }, - "addTarget": { - "type": "Target", - "id": 2 - }, - "removeTarget": { + "count": { "type": "int32", - "id": 3 - }, - "labels": { - "keyType": "string", - "type": "string", - "id": 4 + "id": 2 } } }, - "ListenResponse": { - "oneofs": { - "responseType": { - "oneof": [ - "targetChange", - "documentChange", - "documentDelete", - "documentRemove", - "filter" - ] - } - }, + "StructuredQuery": { "fields": { - "targetChange": { - "type": "TargetChange", + "select": { + "type": "Projection", + "id": 1 + }, + "from": { + "rule": "repeated", + "type": "CollectionSelector", "id": 2 }, - "documentChange": { - "type": "DocumentChange", + "where": { + "type": "Filter", "id": 3 }, - "documentDelete": { - "type": "DocumentDelete", + "orderBy": { + "rule": "repeated", + "type": "Order", "id": 4 }, - "documentRemove": { - "type": "DocumentRemove", + "startAt": { + "type": "Cursor", + "id": 7 + }, + "endAt": { + "type": "Cursor", + "id": 8 + }, + "offset": { + "type": "int32", "id": 6 }, - "filter": { - "type": "ExistenceFilter", + "limit": { + "type": "google.protobuf.Int32Value", "id": 5 } - } - }, - "Target": { - "oneofs": { - "targetType": { - "oneof": [ - "query", - "documents" - ] - }, - "resumeType": { - "oneof": [ - "resumeToken", - "readTime" - ] - } - }, - "fields": { - "query": { - "type": "QueryTarget", - "id": 2 - }, - "documents": { - "type": "DocumentsTarget", - "id": 3 - }, - "resumeToken": { - "type": "bytes", - "id": 4 - }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 11 - }, - "targetId": { - "type": "int32", - "id": 5 - }, - "once": { - "type": "bool", - "id": 6 - } }, "nested": { - "DocumentsTarget": { + "CollectionSelector": { "fields": { - "documents": { - "rule": "repeated", + "collectionId": { "type": "string", "id": 2 + }, + "allDescendants": { + "type": "bool", + "id": 3 } } }, - "QueryTarget": { + "Filter": { "oneofs": { - "queryType": { + "filterType": { "oneof": [ - "structuredQuery" + "compositeFilter", + "fieldFilter", + "unaryFilter" ] } }, "fields": { - "parent": { - "type": "string", + "compositeFilter": { + "type": "CompositeFilter", "id": 1 }, - "structuredQuery": { - "type": "StructuredQuery", + "fieldFilter": { + "type": "FieldFilter", "id": 2 + }, + "unaryFilter": { + "type": "UnaryFilter", + "id": 3 } } - } - } - }, - "TargetChange": { - "fields": { - "targetChangeType": { - "type": "TargetChangeType", - "id": 1 }, - "targetIds": { - "rule": "repeated", - "type": "int32", - "id": 2 + "CompositeFilter": { + "fields": { + "op": { + "type": "Operator", + "id": 1 + }, + "filters": { + "rule": "repeated", + "type": "Filter", + "id": 2 + } + }, + "nested": { + "Operator": { + "values": { + "OPERATOR_UNSPECIFIED": 0, + "AND": 1 + } + } + } }, - "cause": { - "type": "google.rpc.Status", - "id": 3 + "FieldFilter": { + "fields": { + "field": { + "type": "FieldReference", + "id": 1 + }, + "op": { + "type": "Operator", + "id": 2 + }, + "value": { + "type": "Value", + "id": 3 + } + }, + "nested": { + "Operator": { + "values": { + "OPERATOR_UNSPECIFIED": 0, + "LESS_THAN": 1, + "LESS_THAN_OR_EQUAL": 2, + "GREATER_THAN": 3, + "GREATER_THAN_OR_EQUAL": 4, + "EQUAL": 5, + "ARRAY_CONTAINS": 7, + "IN": 8, + "ARRAY_CONTAINS_ANY": 9 + } + } + } }, - "resumeToken": { - "type": "bytes", - "id": 4 + "UnaryFilter": { + "oneofs": { + "operandType": { + "oneof": [ + "field" + ] + } + }, + "fields": { + "op": { + "type": "Operator", + "id": 1 + }, + "field": { + "type": "FieldReference", + "id": 2 + } + }, + "nested": { + "Operator": { + "values": { + "OPERATOR_UNSPECIFIED": 0, + "IS_NAN": 2, + "IS_NULL": 3 + } + } + } }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 6 - } - }, - "nested": { - "TargetChangeType": { - "values": { - "NO_CHANGE": 0, - "ADD": 1, - "REMOVE": 2, - "CURRENT": 3, - "RESET": 4 + "Order": { + "fields": { + "field": { + "type": "FieldReference", + "id": 1 + }, + "direction": { + "type": "Direction", + "id": 2 + } } - } - } - }, - "ListCollectionIdsRequest": { - "fields": { - "parent": { - "type": "string", - "id": 1 }, - "pageSize": { - "type": "int32", - "id": 2 + "FieldReference": { + "fields": { + "fieldPath": { + "type": "string", + "id": 2 + } + } }, - "pageToken": { - "type": "string", - "id": 3 + "Projection": { + "fields": { + "fields": { + "rule": "repeated", + "type": "FieldReference", + "id": 2 + } + } + }, + "Direction": { + "values": { + "DIRECTION_UNSPECIFIED": 0, + "ASCENDING": 1, + "DESCENDING": 2 + } } } }, - "ListCollectionIdsResponse": { + "Cursor": { "fields": { - "collectionIds": { + "values": { "rule": "repeated", - "type": "string", + "type": "Value", "id": 1 }, - "nextPageToken": { - "type": "string", + "before": { + "type": "bool", "id": 2 } } }, - "DocumentMask": { - "fields": { - "fieldPaths": { - "rule": "repeated", - "type": "string", - "id": 1 - } - } - }, - "Precondition": { - "oneofs": { - "conditionType": { - "oneof": [ - "exists", - "updateTime" - ] - } + "Firestore": { + "options": { + "(google.api.default_host)": "firestore.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/datastore" }, - "fields": { - "exists": { - "type": "bool", - "id": 1 + "methods": { + "GetDocument": { + "requestType": "GetDocumentRequest", + "responseType": "Document", + "options": { + "(google.api.http).get": "/v1beta1/{name=projects/*/databases/*/documents/*/**}" + } }, - "updateTime": { - "type": "google.protobuf.Timestamp", - "id": 2 + "ListDocuments": { + "requestType": "ListDocumentsRequest", + "responseType": "ListDocumentsResponse", + "options": { + "(google.api.http).get": "/v1beta1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" + } + }, + "CreateDocument": { + "requestType": "CreateDocumentRequest", + "responseType": "Document", + "options": { + "(google.api.http).post": "/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}", + "(google.api.http).body": "document" + } + }, + "UpdateDocument": { + "requestType": "UpdateDocumentRequest", + "responseType": "Document", + "options": { + "(google.api.http).patch": "/v1beta1/{document.name=projects/*/databases/*/documents/*/**}", + "(google.api.http).body": "document", + "(google.api.method_signature)": "document,update_mask" + } + }, + "DeleteDocument": { + "requestType": "DeleteDocumentRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v1beta1/{name=projects/*/databases/*/documents/*/**}", + "(google.api.method_signature)": "name" + } + }, + "BatchGetDocuments": { + "requestType": "BatchGetDocumentsRequest", + "responseType": "BatchGetDocumentsResponse", + "responseStream": true, + "options": { + "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:batchGet", + "(google.api.http).body": "*" + } + }, + "BeginTransaction": { + "requestType": "BeginTransactionRequest", + "responseType": "BeginTransactionResponse", + "options": { + "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:beginTransaction", + "(google.api.http).body": "*", + "(google.api.method_signature)": "database" + } + }, + "Commit": { + "requestType": "CommitRequest", + "responseType": "CommitResponse", + "options": { + "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:commit", + "(google.api.http).body": "*", + "(google.api.method_signature)": "database,writes" + } + }, + "Rollback": { + "requestType": "RollbackRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:rollback", + "(google.api.http).body": "*", + "(google.api.method_signature)": "database,transaction" + } + }, + "RunQuery": { + "requestType": "RunQueryRequest", + "responseType": "RunQueryResponse", + "responseStream": true, + "options": { + "(google.api.http).post": "/v1beta1/{parent=projects/*/databases/*/documents}:runQuery", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:runQuery", + "(google.api.http).additional_bindings.body": "*" + } + }, + "Write": { + "requestType": "WriteRequest", + "requestStream": true, + "responseType": "WriteResponse", + "responseStream": true, + "options": { + "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:write", + "(google.api.http).body": "*" + } + }, + "Listen": { + "requestType": "ListenRequest", + "requestStream": true, + "responseType": "ListenResponse", + "responseStream": true, + "options": { + "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:listen", + "(google.api.http).body": "*" + } + }, + "ListCollectionIds": { + "requestType": "ListCollectionIdsRequest", + "responseType": "ListCollectionIdsResponse", + "options": { + "(google.api.http).post": "/v1beta1/{parent=projects/*/databases/*/documents}:listCollectionIds", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds", + "(google.api.http).additional_bindings.body": "*", + "(google.api.method_signature)": "parent" + } } } }, - "TransactionOptions": { + "GetDocumentRequest": { "oneofs": { - "mode": { + "consistencySelector": { "oneof": [ - "readOnly", - "readWrite" + "transaction", + "readTime" ] } }, - "fields": { - "readOnly": { - "type": "ReadOnly", - "id": 2 - }, - "readWrite": { - "type": "ReadWrite", - "id": 3 - } - }, - "nested": { - "ReadWrite": { - "fields": { - "retryTransaction": { - "type": "bytes", - "id": 1 - } - } - }, - "ReadOnly": { - "oneofs": { - "consistencySelector": { - "oneof": [ - "readTime" - ] - } - }, - "fields": { - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 2 - } - } - } - } - }, - "Document": { "fields": { "name": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "fields": { - "keyType": "string", - "type": "Value", + "mask": { + "type": "DocumentMask", "id": 2 }, - "createTime": { - "type": "google.protobuf.Timestamp", + "transaction": { + "type": "bytes", "id": 3 }, - "updateTime": { + "readTime": { "type": "google.protobuf.Timestamp", - "id": 4 + "id": 5 } } }, - "Value": { + "ListDocumentsRequest": { "oneofs": { - "valueType": { + "consistencySelector": { "oneof": [ - "nullValue", - "booleanValue", - "integerValue", - "doubleValue", - "timestampValue", - "stringValue", - "bytesValue", - "referenceValue", - "geoPointValue", - "arrayValue", - "mapValue" + "transaction", + "readTime" ] } }, "fields": { - "nullValue": { - "type": "google.protobuf.NullValue", - "id": 11 - }, - "booleanValue": { - "type": "bool", - "id": 1 + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "integerValue": { - "type": "int64", - "id": 2 + "collectionId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "doubleValue": { - "type": "double", + "pageSize": { + "type": "int32", "id": 3 }, - "timestampValue": { - "type": "google.protobuf.Timestamp", - "id": 10 - }, - "stringValue": { + "pageToken": { "type": "string", - "id": 17 - }, - "bytesValue": { - "type": "bytes", - "id": 18 + "id": 4 }, - "referenceValue": { + "orderBy": { "type": "string", - "id": 5 + "id": 6 }, - "geoPointValue": { - "type": "google.type.LatLng", + "mask": { + "type": "DocumentMask", + "id": 7 + }, + "transaction": { + "type": "bytes", "id": 8 }, - "arrayValue": { - "type": "ArrayValue", - "id": 9 + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 10 }, - "mapValue": { - "type": "MapValue", - "id": 6 + "showMissing": { + "type": "bool", + "id": 12 } } }, - "ArrayValue": { + "ListDocumentsResponse": { "fields": { - "values": { + "documents": { "rule": "repeated", - "type": "Value", + "type": "Document", "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 } } }, - "MapValue": { + "CreateDocumentRequest": { "fields": { - "fields": { - "keyType": "string", - "type": "Value", - "id": 1 + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "collectionId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "documentId": { + "type": "string", + "id": 3 + }, + "document": { + "type": "Document", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "mask": { + "type": "DocumentMask", + "id": 5 } } }, - "StructuredQuery": { + "UpdateDocumentRequest": { "fields": { - "select": { - "type": "Projection", - "id": 1 + "document": { + "type": "Document", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "from": { - "rule": "repeated", - "type": "CollectionSelector", + "updateMask": { + "type": "DocumentMask", "id": 2 }, - "where": { - "type": "Filter", + "mask": { + "type": "DocumentMask", "id": 3 }, - "orderBy": { - "rule": "repeated", - "type": "Order", + "currentDocument": { + "type": "Precondition", "id": 4 + } + } + }, + "DeleteDocumentRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "startAt": { - "type": "Cursor", - "id": 7 + "currentDocument": { + "type": "Precondition", + "id": 2 + } + } + }, + "BatchGetDocumentsRequest": { + "oneofs": { + "consistencySelector": { + "oneof": [ + "transaction", + "newTransaction", + "readTime" + ] + } + }, + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "endAt": { - "type": "Cursor", - "id": 8 + "documents": { + "rule": "repeated", + "type": "string", + "id": 2 }, - "offset": { - "type": "int32", - "id": 6 + "mask": { + "type": "DocumentMask", + "id": 3 }, - "limit": { - "type": "google.protobuf.Int32Value", + "transaction": { + "type": "bytes", + "id": 4 + }, + "newTransaction": { + "type": "TransactionOptions", "id": 5 + }, + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 7 + } + } + }, + "BatchGetDocumentsResponse": { + "oneofs": { + "result": { + "oneof": [ + "found", + "missing" + ] } }, - "nested": { - "CollectionSelector": { - "fields": { - "collectionId": { - "type": "string", - "id": 2 - }, - "allDescendants": { - "type": "bool", - "id": 3 - } - } + "fields": { + "found": { + "type": "Document", + "id": 1 }, - "Filter": { - "oneofs": { - "filterType": { - "oneof": [ - "compositeFilter", - "fieldFilter", - "unaryFilter" - ] - } - }, - "fields": { - "compositeFilter": { - "type": "CompositeFilter", - "id": 1 - }, - "fieldFilter": { - "type": "FieldFilter", - "id": 2 - }, - "unaryFilter": { - "type": "UnaryFilter", - "id": 3 - } - } + "missing": { + "type": "string", + "id": 2 }, - "CompositeFilter": { - "fields": { - "op": { - "type": "Operator", - "id": 1 - }, - "filters": { - "rule": "repeated", - "type": "Filter", - "id": 2 - } - }, - "nested": { - "Operator": { - "values": { - "OPERATOR_UNSPECIFIED": 0, - "AND": 1 - } - } - } + "transaction": { + "type": "bytes", + "id": 3 }, - "FieldFilter": { - "fields": { - "field": { - "type": "FieldReference", - "id": 1 - }, - "op": { - "type": "Operator", - "id": 2 - }, - "value": { - "type": "Value", - "id": 3 - } - }, - "nested": { - "Operator": { - "values": { - "OPERATOR_UNSPECIFIED": 0, - "LESS_THAN": 1, - "LESS_THAN_OR_EQUAL": 2, - "GREATER_THAN": 3, - "GREATER_THAN_OR_EQUAL": 4, - "EQUAL": 5, - "ARRAY_CONTAINS": 7, - "IN": 8, - "ARRAY_CONTAINS_ANY": 9 - } - } + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 4 + } + } + }, + "BeginTransactionRequest": { + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" } }, - "UnaryFilter": { - "oneofs": { - "operandType": { - "oneof": [ - "field" - ] - } - }, - "fields": { - "op": { - "type": "Operator", - "id": 1 - }, - "field": { - "type": "FieldReference", - "id": 2 - } - }, - "nested": { - "Operator": { - "values": { - "OPERATOR_UNSPECIFIED": 0, - "IS_NAN": 2, - "IS_NULL": 3 - } - } + "options": { + "type": "TransactionOptions", + "id": 2 + } + } + }, + "BeginTransactionResponse": { + "fields": { + "transaction": { + "type": "bytes", + "id": 1 + } + } + }, + "CommitRequest": { + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" } }, - "Order": { - "fields": { - "field": { - "type": "FieldReference", - "id": 1 - }, - "direction": { - "type": "Direction", - "id": 2 - } - } + "writes": { + "rule": "repeated", + "type": "Write", + "id": 2 }, - "Projection": { - "fields": { - "fields": { - "rule": "repeated", - "type": "FieldReference", - "id": 2 - } + "transaction": { + "type": "bytes", + "id": 3 + } + } + }, + "CommitResponse": { + "fields": { + "writeResults": { + "rule": "repeated", + "type": "WriteResult", + "id": 1 + }, + "commitTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + } + } + }, + "RollbackRequest": { + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" } }, - "FieldReference": { - "fields": { - "fieldPath": { - "type": "string", - "id": 2 - } + "transaction": { + "type": "bytes", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" } + } + } + }, + "RunQueryRequest": { + "oneofs": { + "queryType": { + "oneof": [ + "structuredQuery" + ] }, - "Direction": { - "values": { - "DIRECTION_UNSPECIFIED": 0, - "ASCENDING": 1, - "DESCENDING": 2 + "consistencySelector": { + "oneof": [ + "transaction", + "newTransaction", + "readTime" + ] + } + }, + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" } + }, + "structuredQuery": { + "type": "StructuredQuery", + "id": 2 + }, + "transaction": { + "type": "bytes", + "id": 5 + }, + "newTransaction": { + "type": "TransactionOptions", + "id": 6 + }, + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 7 } } }, - "Cursor": { + "RunQueryResponse": { "fields": { - "values": { + "transaction": { + "type": "bytes", + "id": 2 + }, + "document": { + "type": "Document", + "id": 1 + }, + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + }, + "skippedResults": { + "type": "int32", + "id": 4 + } + } + }, + "WriteRequest": { + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "streamId": { + "type": "string", + "id": 2 + }, + "writes": { "rule": "repeated", - "type": "Value", + "type": "Write", + "id": 3 + }, + "streamToken": { + "type": "bytes", + "id": 4 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 5 + } + } + }, + "WriteResponse": { + "fields": { + "streamId": { + "type": "string", "id": 1 }, - "before": { - "type": "bool", - "id": 2 + "streamToken": { + "type": "bytes", + "id": 2 + }, + "writeResults": { + "rule": "repeated", + "type": "WriteResult", + "id": 3 + }, + "commitTime": { + "type": "google.protobuf.Timestamp", + "id": 4 + } + } + }, + "ListenRequest": { + "oneofs": { + "targetChange": { + "oneof": [ + "addTarget", + "removeTarget" + ] + } + }, + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "addTarget": { + "type": "Target", + "id": 2 + }, + "removeTarget": { + "type": "int32", + "id": 3 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 4 + } + } + }, + "ListenResponse": { + "oneofs": { + "responseType": { + "oneof": [ + "targetChange", + "documentChange", + "documentDelete", + "documentRemove", + "filter" + ] + } + }, + "fields": { + "targetChange": { + "type": "TargetChange", + "id": 2 + }, + "documentChange": { + "type": "DocumentChange", + "id": 3 + }, + "documentDelete": { + "type": "DocumentDelete", + "id": 4 + }, + "documentRemove": { + "type": "DocumentRemove", + "id": 6 + }, + "filter": { + "type": "ExistenceFilter", + "id": 5 } } }, - "Write": { + "Target": { "oneofs": { - "operation": { + "targetType": { "oneof": [ - "update", - "delete", - "transform" + "query", + "documents" + ] + }, + "resumeType": { + "oneof": [ + "resumeToken", + "readTime" ] } }, "fields": { - "update": { - "type": "Document", - "id": 1 - }, - "delete": { - "type": "string", + "query": { + "type": "QueryTarget", "id": 2 }, - "transform": { - "type": "DocumentTransform", - "id": 6 - }, - "updateMask": { - "type": "DocumentMask", + "documents": { + "type": "DocumentsTarget", "id": 3 }, - "currentDocument": { - "type": "Precondition", + "resumeToken": { + "type": "bytes", "id": 4 - } - } - }, - "DocumentTransform": { - "fields": { - "document": { - "type": "string", - "id": 1 }, - "fieldTransforms": { - "rule": "repeated", - "type": "FieldTransform", - "id": 2 + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 11 + }, + "targetId": { + "type": "int32", + "id": 5 + }, + "once": { + "type": "bool", + "id": 6 } }, "nested": { - "FieldTransform": { + "DocumentsTarget": { + "fields": { + "documents": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } + }, + "QueryTarget": { "oneofs": { - "transformType": { + "queryType": { "oneof": [ - "setToServerValue", - "increment", - "maximum", - "minimum", - "appendMissingElements", - "removeAllFromArray" + "structuredQuery" ] } }, "fields": { - "fieldPath": { + "parent": { "type": "string", "id": 1 }, - "setToServerValue": { - "type": "ServerValue", + "structuredQuery": { + "type": "StructuredQuery", "id": 2 - }, - "increment": { - "type": "Value", - "id": 3 - }, - "maximum": { - "type": "Value", - "id": 4 - }, - "minimum": { - "type": "Value", - "id": 5 - }, - "appendMissingElements": { - "type": "ArrayValue", - "id": 6 - }, - "removeAllFromArray": { - "type": "ArrayValue", - "id": 7 - } - }, - "nested": { - "ServerValue": { - "values": { - "SERVER_VALUE_UNSPECIFIED": 0, - "REQUEST_TIME": 1 - } } } } } }, - "WriteResult": { - "fields": { - "updateTime": { - "type": "google.protobuf.Timestamp", - "id": 1 - }, - "transformResults": { - "rule": "repeated", - "type": "Value", - "id": 2 - } - } - }, - "DocumentChange": { + "TargetChange": { "fields": { - "document": { - "type": "Document", + "targetChangeType": { + "type": "TargetChangeType", "id": 1 }, "targetIds": { "rule": "repeated", "type": "int32", - "id": 5 + "id": 2 }, - "removedTargetIds": { - "rule": "repeated", - "type": "int32", - "id": 6 - } - } - }, - "DocumentDelete": { - "fields": { - "document": { - "type": "string", - "id": 1 + "cause": { + "type": "google.rpc.Status", + "id": 3 }, - "removedTargetIds": { - "rule": "repeated", - "type": "int32", - "id": 6 + "resumeToken": { + "type": "bytes", + "id": 4 }, "readTime": { "type": "google.protobuf.Timestamp", - "id": 4 + "id": 6 + } + }, + "nested": { + "TargetChangeType": { + "values": { + "NO_CHANGE": 0, + "ADD": 1, + "REMOVE": 2, + "CURRENT": 3, + "RESET": 4 + } } } }, - "DocumentRemove": { + "ListCollectionIdsRequest": { "fields": { - "document": { + "parent": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "removedTargetIds": { - "rule": "repeated", + "pageSize": { "type": "int32", "id": 2 }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 4 + "pageToken": { + "type": "string", + "id": 3 } } }, - "ExistenceFilter": { + "ListCollectionIdsResponse": { "fields": { - "targetId": { - "type": "int32", + "collectionIds": { + "rule": "repeated", + "type": "string", "id": 1 }, - "count": { - "type": "int32", + "nextPageToken": { + "type": "string", "id": 2 } } @@ -2904,14 +3268,80 @@ }, "api": { "options": { + "cc_enable_arenas": true, "go_package": "google.golang.org/genproto/googleapis/api/annotations;annotations", "java_multiple_files": true, - "java_outer_classname": "ClientProto", + "java_outer_classname": "FieldBehaviorProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { + "resourceReference": { + "type": "google.api.ResourceReference", + "id": 1055, + "extend": "google.protobuf.FieldOptions" + }, + "resourceDefinition": { + "rule": "repeated", + "type": "google.api.ResourceDescriptor", + "id": 1053, + "extend": "google.protobuf.FileOptions" + }, + "resource": { + "type": "google.api.ResourceDescriptor", + "id": 1053, + "extend": "google.protobuf.MessageOptions" + }, + "ResourceDescriptor": { + "fields": { + "type": { + "type": "string", + "id": 1 + }, + "pattern": { + "rule": "repeated", + "type": "string", + "id": 2 + }, + "nameField": { + "type": "string", + "id": 3 + }, + "history": { + "type": "History", + "id": 4 + }, + "plural": { + "type": "string", + "id": 5 + }, + "singular": { + "type": "string", + "id": 6 + } + }, + "nested": { + "History": { + "values": { + "HISTORY_UNSPECIFIED": 0, + "ORIGINALLY_SINGLE_PATTERN": 1, + "FUTURE_MULTI_PATTERN": 2 + } + } + } + }, + "ResourceReference": { + "fields": { + "type": { + "type": "string", + "id": 1 + }, + "childType": { + "type": "string", + "id": 2 + } + } + }, "http": { "type": "HttpRule", "id": 72295728, @@ -3014,6 +3444,22 @@ "type": "string", "id": 1050, "extend": "google.protobuf.ServiceOptions" + }, + "fieldBehavior": { + "rule": "repeated", + "type": "google.api.FieldBehavior", + "id": 1052, + "extend": "google.protobuf.FieldOptions" + }, + "FieldBehavior": { + "values": { + "FIELD_BEHAVIOR_UNSPECIFIED": 0, + "OPTIONAL": 1, + "REQUIRED": 2, + "OUTPUT_ONLY": 3, + "INPUT_ONLY": 4, + "IMMUTABLE": 5 + } } } }, diff --git a/dev/protos/update.sh b/dev/protos/update.sh index eef115234..cccf6b86d 100755 --- a/dev/protos/update.sh +++ b/dev/protos/update.sh @@ -43,13 +43,21 @@ git clone https://github.com/google/protobuf.git # Copy necessary protos. mkdir -p "${PROTOS_DIR}/google/api" -cp googleapis/google/api/{annotations.proto,http.proto} \ +cp googleapis/google/api/{annotations,client,field_behavior,http,resource}.proto \ "${PROTOS_DIR}/google/api/" mkdir -p "${PROTOS_DIR}/google/firestore/v1" cp googleapis/google/firestore/v1/*.proto \ "${PROTOS_DIR}/google/firestore/v1/" +mkdir -p "${PROTOS_DIR}/google/firestore/v1beta1" +cp googleapis/google/firestore/v1beta1/*.proto \ + "${PROTOS_DIR}/google/firestore/v1beta1/" + +mkdir -p "${PROTOS_DIR}/google/firestore/admin/v1" +cp googleapis/google/firestore/admin/v1/*.proto \ + "${PROTOS_DIR}/google/firestore/admin/v1/" + mkdir -p "${PROTOS_DIR}/google/longrunning" cp googleapis/google/longrunning/operations.proto \ "${PROTOS_DIR}/google/longrunning/" @@ -67,16 +75,44 @@ cp protobuf/src/google/protobuf/{any,empty,field_mask,struct,timestamp,wrappers} "${PROTOS_DIR}/google/protobuf/" # Generate the Protobuf typings -"${PBJS}" --proto_path=. --js_out=import_style=commonjs,binary:library \ - --target=static --no-create --no-encode --no-decode --no-verify \ - --no-convert --no-delimited --force-enum-string --force-number -o \ - firestore_proto_api.js "${PROTOS_DIR}/google/firestore/v1/*.proto" \ +PBJS_ARGS=( --proto_path=. \ + --js_out=import_style=commonjs,binary:library \ + --target=static \ + --no-create \ + --no-encode \ + --no-decode \ + --no-verify \ + --no-convert \ + --no-delimited \ + --force-enum-string \ + --force-number) + +"${PBJS}" "${PBJS_ARGS[@]}" -o firestore_v1_proto_api.js \ + "${PROTOS_DIR}/google/firestore/v1/*.proto" \ + "${PROTOS_DIR}/google/protobuf/*.proto" "${PROTOS_DIR}/google/type/*.proto" \ + "${PROTOS_DIR}/google/rpc/*.proto" "${PROTOS_DIR}/google/api/*.proto" \ + "${PROTOS_DIR}/google/longrunning/*.proto" +"${PBTS}" -o firestore_v1_proto_api.d.ts firestore_v1_proto_api.js + +"${PBJS}" "${PBJS_ARGS[@]}" -o firestore_admin_v1_proto_api.js \ + "${PROTOS_DIR}/google/firestore/admin/v1/*.proto" \ "${PROTOS_DIR}/google/protobuf/*.proto" "${PROTOS_DIR}/google/type/*.proto" \ "${PROTOS_DIR}/google/rpc/*.proto" "${PROTOS_DIR}/google/api/*.proto" \ "${PROTOS_DIR}/google/longrunning/*.proto" -"${PBTS}" -o firestore_proto_api.d.ts firestore_proto_api.js +"${PBTS}" -o firestore_admin_v1_proto_api.d.ts firestore_admin_v1_proto_api.js + +"${PBJS}" "${PBJS_ARGS[@]}" -o firestore_v1beta1_proto_api.js \ + "${PROTOS_DIR}/google/firestore/v1beta1/*.proto" \ + "${PROTOS_DIR}/google/protobuf/*.proto" "${PROTOS_DIR}/google/type/*.proto" \ + "${PROTOS_DIR}/google/rpc/*.proto" "${PROTOS_DIR}/google/api/*.proto" \ + "${PROTOS_DIR}/google/longrunning/*.proto" +"${PBTS}" -o firestore_v1beta1_proto_api.d.ts firestore_v1beta1_proto_api.js + +"${PROTOS_DIR}"/insert-license.sh *.d.ts *.js # Copy typings into source repo -cp {firestore_proto_api.d.ts,firestore_proto_api.js} ${PROTOS_DIR} +cp {firestore_v1_proto_api.d.ts,firestore_v1_proto_api.js} ${PROTOS_DIR} +cp {firestore_admin_v1_proto_api.d.ts,firestore_admin_v1_proto_api.js} ${PROTOS_DIR} +cp {firestore_v1beta1_proto_api.d.ts,firestore_v1beta1_proto_api.js} ${PROTOS_DIR} popd diff --git a/dev/src/convert.ts b/dev/src/convert.ts index 4dbf682e7..61399d38d 100644 --- a/dev/src/convert.ts +++ b/dev/src/convert.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {google} from '../protos/firestore_proto_api'; +import {google} from '../protos/firestore_v1_proto_api'; import {ApiMapValue, ProtobufJsValue} from './types'; import {validateObject} from './validate'; diff --git a/dev/src/document.ts b/dev/src/document.ts index 250fece68..434f78656 100644 --- a/dev/src/document.ts +++ b/dev/src/document.ts @@ -18,7 +18,7 @@ const deepEqual = require('deep-equal'); import * as assert from 'assert'; -import {google} from '../protos/firestore_proto_api'; +import {google} from '../protos/firestore_v1_proto_api'; import {FieldTransform} from './field-value'; import {FieldPath, validateFieldPath} from './path'; import {DocumentReference} from './reference'; diff --git a/dev/src/field-value.ts b/dev/src/field-value.ts index 7f65e1ff4..f07aaa7c3 100644 --- a/dev/src/field-value.ts +++ b/dev/src/field-value.ts @@ -16,7 +16,7 @@ const deepEqual = require('deep-equal'); -import * as proto from '../protos/firestore_proto_api'; +import * as proto from '../protos/firestore_v1_proto_api'; import {FieldPath} from './path'; import {Serializer, validateUserInput} from './serializer'; diff --git a/dev/src/geo-point.ts b/dev/src/geo-point.ts index 10a740471..37efc8b72 100644 --- a/dev/src/geo-point.ts +++ b/dev/src/geo-point.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {google} from '../protos/firestore_proto_api'; +import {google} from '../protos/firestore_v1_proto_api'; import {Serializable} from './serializer'; import {validateNumber} from './validate'; diff --git a/dev/src/index.ts b/dev/src/index.ts index df3510023..001c58fd7 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -19,7 +19,7 @@ import {CallOptions} from 'google-gax'; import * as through2 from 'through2'; import {URL} from 'url'; -import {google} from '../protos/firestore_proto_api'; +import {google} from '../protos/firestore_v1_proto_api'; import {fieldsFromJson, timestampFromJson} from './convert'; import { DocumentSnapshot, diff --git a/dev/src/order.ts b/dev/src/order.ts index 4d1351548..88c62c63b 100644 --- a/dev/src/order.ts +++ b/dev/src/order.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {google} from '../protos/firestore_proto_api'; +import {google} from '../protos/firestore_v1_proto_api'; import {detectValueType} from './convert'; import {QualifiedResourcePath} from './path'; import {ApiMapValue} from './types'; diff --git a/dev/src/path.ts b/dev/src/path.ts index fbf35c432..0023bac34 100644 --- a/dev/src/path.ts +++ b/dev/src/path.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {google} from '../protos/firestore_proto_api'; +import {google} from '../protos/firestore_v1_proto_api'; import {isObject} from './util'; import { diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 96560dc3b..25dbed75a 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -19,7 +19,7 @@ const deepEqual = require('deep-equal'); import * as bun from 'bun'; import * as through2 from 'through2'; -import * as proto from '../protos/firestore_proto_api'; +import * as proto from '../protos/firestore_v1_proto_api'; import { DocumentSnapshot, diff --git a/dev/src/serializer.ts b/dev/src/serializer.ts index 8828a9f1e..55f0231fe 100644 --- a/dev/src/serializer.ts +++ b/dev/src/serializer.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as proto from '../protos/firestore_proto_api'; +import * as proto from '../protos/firestore_v1_proto_api'; import {detectValueType} from './convert'; import {FieldTransform} from './field-value'; diff --git a/dev/src/timestamp.ts b/dev/src/timestamp.ts index c8a616cf9..be8828c3f 100644 --- a/dev/src/timestamp.ts +++ b/dev/src/timestamp.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {google} from '../protos/firestore_proto_api'; +import {google} from '../protos/firestore_v1_proto_api'; import {validateInteger} from './validate'; import api = google.firestore.v1; diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index 1fffb98c4..5d260a1c8 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as proto from '../protos/firestore_proto_api'; +import * as proto from '../protos/firestore_v1_proto_api'; import {DocumentSnapshot, Precondition} from './document'; import {Firestore, WriteBatch} from './index'; diff --git a/dev/src/types.ts b/dev/src/types.ts index 1b216bfcb..7085284c4 100644 --- a/dev/src/types.ts +++ b/dev/src/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {google} from '../protos/firestore_proto_api'; +import {google} from '../protos/firestore_v1_proto_api'; import {FieldPath} from './path'; import {Timestamp} from './timestamp'; diff --git a/dev/src/v1/doc/google/firestore/admin/v1/doc_field.js b/dev/src/v1/doc/google/firestore/admin/v1/doc_field.js deleted file mode 100644 index dcb7d65fa..000000000 --- a/dev/src/v1/doc/google/firestore/admin/v1/doc_field.js +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * Represents a single field in the database. - * - * Fields are grouped by their "Collection Group", which represent all - * collections in the database with the same id. - * - * @property {string} name - * A field name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}` - * - * A field path may be a simple field name, e.g. `address` or a path to fields - * within map_value , e.g. `address.city`, - * or a special field path. The only valid special field is `*`, which - * represents any field. - * - * Field paths may be quoted using ` (backtick). The only character that needs - * to be escaped within a quoted field path is the backtick character itself, - * escaped using a backslash. Special characters in field paths that - * must be quoted include: `*`, `.`, - * ``` (backtick), `[`, `]`, as well as any ascii symbolic characters. - * - * Examples: - * (Note: Comments here are written in markdown syntax, so there is an - * additional layer of backticks to represent a code block) - * `\`address.city\`` represents a field named `address.city`, not the map key - * `city` in the field `address`. - * `\`*\`` represents a field named `*`, not any field. - * - * A special `Field` contains the default indexing settings for all fields. - * This field's resource name is: - * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*` - * Indexes defined on this `Field` will be applied to all fields which do not - * have their own `Field` index configuration. - * - * @property {Object} indexConfig - * The index configuration for this field. If unset, field indexing will - * revert to the configuration defined by the `ancestor_field`. To - * explicitly remove all indexes for this field, specify an index config - * with an empty list of indexes. - * - * This object should have the same structure as [IndexConfig]{@link google.firestore.admin.v1.IndexConfig} - * - * @typedef Field - * @memberof google.firestore.admin.v1 - * @see [google.firestore.admin.v1.Field definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/admin/v1/field.proto} - */ -const Field = { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * The index configuration for this field. - * - * @property {Object[]} indexes - * The indexes supported for this field. - * - * This object should have the same structure as [Index]{@link google.firestore.admin.v1.Index} - * - * @property {boolean} usesAncestorConfig - * Output only. When true, the `Field`'s index configuration is set from the - * configuration specified by the `ancestor_field`. - * When false, the `Field`'s index configuration is defined explicitly. - * - * @property {string} ancestorField - * Output only. Specifies the resource name of the `Field` from which this field's - * index configuration is set (when `uses_ancestor_config` is true), - * or from which it *would* be set if this field had no index configuration - * (when `uses_ancestor_config` is false). - * - * @property {boolean} reverting - * Output only - * When true, the `Field`'s index configuration is in the process of being - * reverted. Once complete, the index config will transition to the same - * state as the field specified by `ancestor_field`, at which point - * `uses_ancestor_config` will be `true` and `reverting` will be `false`. - * - * @typedef IndexConfig - * @memberof google.firestore.admin.v1 - * @see [google.firestore.admin.v1.Field.IndexConfig definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/admin/v1/field.proto} - */ - IndexConfig: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, -}; diff --git a/dev/src/v1/doc/google/firestore/admin/v1/doc_firestore_admin.js b/dev/src/v1/doc/google/firestore/admin/v1/doc_firestore_admin.js deleted file mode 100644 index b0cce44c0..000000000 --- a/dev/src/v1/doc/google/firestore/admin/v1/doc_firestore_admin.js +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * The request for FirestoreAdmin.CreateIndex. - * - * @property {string} parent - * A parent name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - * - * @property {Object} index - * The composite index to create. - * - * This object should have the same structure as [Index]{@link google.firestore.admin.v1.Index} - * - * @typedef CreateIndexRequest - * @memberof google.firestore.admin.v1 - * @see [google.firestore.admin.v1.CreateIndexRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/admin/v1/firestore_admin.proto} - */ -const CreateIndexRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for FirestoreAdmin.ListIndexes. - * - * @property {string} parent - * A parent name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - * - * @property {string} filter - * The filter to apply to list results. - * - * @property {number} pageSize - * The number of results to return. - * - * @property {string} pageToken - * A page token, returned from a previous call to - * FirestoreAdmin.ListIndexes, that may be used to get the next - * page of results. - * - * @typedef ListIndexesRequest - * @memberof google.firestore.admin.v1 - * @see [google.firestore.admin.v1.ListIndexesRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/admin/v1/firestore_admin.proto} - */ -const ListIndexesRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The response for FirestoreAdmin.ListIndexes. - * - * @property {Object[]} indexes - * The requested indexes. - * - * This object should have the same structure as [Index]{@link google.firestore.admin.v1.Index} - * - * @property {string} nextPageToken - * A page token that may be used to request another page of results. If blank, - * this is the last page. - * - * @typedef ListIndexesResponse - * @memberof google.firestore.admin.v1 - * @see [google.firestore.admin.v1.ListIndexesResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/admin/v1/firestore_admin.proto} - */ -const ListIndexesResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for FirestoreAdmin.GetIndex. - * - * @property {string} name - * A name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` - * - * @typedef GetIndexRequest - * @memberof google.firestore.admin.v1 - * @see [google.firestore.admin.v1.GetIndexRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/admin/v1/firestore_admin.proto} - */ -const GetIndexRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for FirestoreAdmin.DeleteIndex. - * - * @property {string} name - * A name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` - * - * @typedef DeleteIndexRequest - * @memberof google.firestore.admin.v1 - * @see [google.firestore.admin.v1.DeleteIndexRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/admin/v1/firestore_admin.proto} - */ -const DeleteIndexRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for FirestoreAdmin.UpdateField. - * - * @property {Object} field - * The field to be updated. - * - * This object should have the same structure as [Field]{@link google.firestore.admin.v1.Field} - * - * @property {Object} updateMask - * A mask, relative to the field. If specified, only configuration specified - * by this field_mask will be updated in the field. - * - * This object should have the same structure as [FieldMask]{@link google.protobuf.FieldMask} - * - * @typedef UpdateFieldRequest - * @memberof google.firestore.admin.v1 - * @see [google.firestore.admin.v1.UpdateFieldRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/admin/v1/firestore_admin.proto} - */ -const UpdateFieldRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for FirestoreAdmin.GetField. - * - * @property {string} name - * A name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}` - * - * @typedef GetFieldRequest - * @memberof google.firestore.admin.v1 - * @see [google.firestore.admin.v1.GetFieldRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/admin/v1/firestore_admin.proto} - */ -const GetFieldRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for FirestoreAdmin.ListFields. - * - * @property {string} parent - * A parent name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - * - * @property {string} filter - * The filter to apply to list results. Currently, - * FirestoreAdmin.ListFields only supports listing fields - * that have been explicitly overridden. To issue this query, call - * FirestoreAdmin.ListFields with the filter set to - * `indexConfig.usesAncestorConfig:false`. - * - * @property {number} pageSize - * The number of results to return. - * - * @property {string} pageToken - * A page token, returned from a previous call to - * FirestoreAdmin.ListFields, that may be used to get the next - * page of results. - * - * @typedef ListFieldsRequest - * @memberof google.firestore.admin.v1 - * @see [google.firestore.admin.v1.ListFieldsRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/admin/v1/firestore_admin.proto} - */ -const ListFieldsRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The response for FirestoreAdmin.ListFields. - * - * @property {Object[]} fields - * The requested fields. - * - * This object should have the same structure as [Field]{@link google.firestore.admin.v1.Field} - * - * @property {string} nextPageToken - * A page token that may be used to request another page of results. If blank, - * this is the last page. - * - * @typedef ListFieldsResponse - * @memberof google.firestore.admin.v1 - * @see [google.firestore.admin.v1.ListFieldsResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/admin/v1/firestore_admin.proto} - */ -const ListFieldsResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for FirestoreAdmin.ExportDocuments. - * - * @property {string} name - * Database to export. Should be of the form: - * `projects/{project_id}/databases/{database_id}`. - * - * @property {string[]} collectionIds - * Which collection ids to export. Unspecified means all collections. - * - * @property {string} outputUriPrefix - * The output URI. Currently only supports Google Cloud Storage URIs of the - * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name - * of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional - * Google Cloud Storage namespace path. When - * choosing a name, be sure to consider Google Cloud Storage naming - * guidelines: https://cloud.google.com/storage/docs/naming. - * If the URI is a bucket (without a namespace path), a prefix will be - * generated based on the start time. - * - * @typedef ExportDocumentsRequest - * @memberof google.firestore.admin.v1 - * @see [google.firestore.admin.v1.ExportDocumentsRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/admin/v1/firestore_admin.proto} - */ -const ExportDocumentsRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for FirestoreAdmin.ImportDocuments. - * - * @property {string} name - * Database to import into. Should be of the form: - * `projects/{project_id}/databases/{database_id}`. - * - * @property {string[]} collectionIds - * Which collection ids to import. Unspecified means all collections included - * in the import. - * - * @property {string} inputUriPrefix - * Location of the exported files. - * This must match the output_uri_prefix of an ExportDocumentsResponse from - * an export that has completed successfully. - * See: - * google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix. - * - * @typedef ImportDocumentsRequest - * @memberof google.firestore.admin.v1 - * @see [google.firestore.admin.v1.ImportDocumentsRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/admin/v1/firestore_admin.proto} - */ -const ImportDocumentsRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1/doc/google/firestore/admin/v1/doc_index.js b/dev/src/v1/doc/google/firestore/admin/v1/doc_index.js deleted file mode 100644 index 528ba952d..000000000 --- a/dev/src/v1/doc/google/firestore/admin/v1/doc_index.js +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * Cloud Firestore indexes enable simple and complex queries against - * documents in a database. - * - * @property {string} name - * Output only. A server defined name for this index. - * The form of this name for composite indexes will be: - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}` - * For single field indexes, this field will be empty. - * - * @property {number} queryScope - * Indexes with a collection query scope specified allow queries - * against a collection that is the child of a specific document, specified at - * query time, and that has the same collection id. - * - * Indexes with a collection group query scope specified allow queries against - * all collections descended from a specific document, specified at query - * time, and that have the same collection id as this index. - * - * The number should be among the values of [QueryScope]{@link google.firestore.admin.v1.QueryScope} - * - * @property {Object[]} fields - * The fields supported by this index. - * - * For composite indexes, this is always 2 or more fields. - * The last field entry is always for the field path `__name__`. If, on - * creation, `__name__` was not specified as the last field, it will be added - * automatically with the same direction as that of the last field defined. If - * the final field in a composite index is not directional, the `__name__` - * will be ordered ASCENDING (unless explicitly specified). - * - * For single field indexes, this will always be exactly one entry with a - * field path equal to the field path of the associated field. - * - * This object should have the same structure as [IndexField]{@link google.firestore.admin.v1.IndexField} - * - * @property {number} state - * Output only. The serving state of the index. - * - * The number should be among the values of [State]{@link google.firestore.admin.v1.State} - * - * @typedef Index - * @memberof google.firestore.admin.v1 - * @see [google.firestore.admin.v1.Index definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/admin/v1/index.proto} - */ -const Index = { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * A field in an index. - * The field_path describes which field is indexed, the value_mode describes - * how the field value is indexed. - * - * @property {string} fieldPath - * Can be __name__. - * For single field indexes, this must match the name of the field or may - * be omitted. - * - * @property {number} order - * Indicates that this field supports ordering by the specified order or - * comparing using =, <, <=, >, >=. - * - * The number should be among the values of [Order]{@link google.firestore.admin.v1.Order} - * - * @property {number} arrayConfig - * Indicates that this field supports operations on `array_value`s. - * - * The number should be among the values of [ArrayConfig]{@link google.firestore.admin.v1.ArrayConfig} - * - * @typedef IndexField - * @memberof google.firestore.admin.v1 - * @see [google.firestore.admin.v1.Index.IndexField definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/admin/v1/index.proto} - */ - IndexField: { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * The supported array value configurations. - * - * @enum {number} - * @memberof google.firestore.admin.v1 - */ - ArrayConfig: { - /** - * The index does not support additional array queries. - */ - ARRAY_CONFIG_UNSPECIFIED: 0, - - /** - * The index supports array containment queries. - */ - CONTAINS: 1, - }, - - /** - * The supported orderings. - * - * @enum {number} - * @memberof google.firestore.admin.v1 - */ - Order: { - /** - * The ordering is unspecified. Not a valid option. - */ - ORDER_UNSPECIFIED: 0, - - /** - * The field is ordered by ascending field value. - */ - ASCENDING: 1, - - /** - * The field is ordered by descending field value. - */ - DESCENDING: 2, - }, - }, - - /** - * Query Scope defines the scope at which a query is run. This is specified on - * a StructuredQuery's `from` field. - * - * @enum {number} - * @memberof google.firestore.admin.v1 - */ - QueryScope: { - /** - * The query scope is unspecified. Not a valid option. - */ - QUERY_SCOPE_UNSPECIFIED: 0, - - /** - * Indexes with a collection query scope specified allow queries - * against a collection that is the child of a specific document, specified - * at query time, and that has the collection id specified by the index. - */ - COLLECTION: 1, - - /** - * Indexes with a collection group query scope specified allow queries - * against all collections that has the collection id specified by the - * index. - */ - COLLECTION_GROUP: 2, - }, - - /** - * The state of an index. During index creation, an index will be in the - * `CREATING` state. If the index is created successfully, it will transition - * to the `READY` state. If the index creation encounters a problem, the index - * will transition to the `NEEDS_REPAIR` state. - * - * @enum {number} - * @memberof google.firestore.admin.v1 - */ - State: { - /** - * The state is unspecified. - */ - STATE_UNSPECIFIED: 0, - - /** - * The index is being created. - * There is an active long-running operation for the index. - * The index is updated when writing a document. - * Some index data may exist. - */ - CREATING: 1, - - /** - * The index is ready to be used. - * The index is updated when writing a document. - * The index is fully populated from all stored documents it applies to. - */ - READY: 2, - - /** - * The index was being created, but something went wrong. - * There is no active long-running operation for the index, - * and the most recently finished long-running operation failed. - * The index is not updated when writing a document. - * Some index data may exist. - * Use the google.longrunning.Operations API to determine why the operation - * that last attempted to create this index failed, then re-create the - * index. - */ - NEEDS_REPAIR: 3, - }, -}; diff --git a/dev/src/v1/doc/google/firestore/v1/doc_common.js b/dev/src/v1/doc/google/firestore/v1/doc_common.js deleted file mode 100644 index 377763a0b..000000000 --- a/dev/src/v1/doc/google/firestore/v1/doc_common.js +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * A set of field paths on a document. - * Used to restrict a get or update operation on a document to a subset of its - * fields. - * This is different from standard field masks, as this is always scoped to a - * Document, and takes in account the dynamic nature of Value. - * - * @property {string[]} fieldPaths - * The list of field paths in the mask. See Document.fields for a field - * path syntax reference. - * - * @typedef DocumentMask - * @memberof google.firestore.v1 - * @see [google.firestore.v1.DocumentMask definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/common.proto} - */ -const DocumentMask = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A precondition on a document, used for conditional operations. - * - * @property {boolean} exists - * When set to `true`, the target document must exist. - * When set to `false`, the target document must not exist. - * - * @property {Object} updateTime - * When set, the target document must exist and have been last updated at - * that time. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef Precondition - * @memberof google.firestore.v1 - * @see [google.firestore.v1.Precondition definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/common.proto} - */ -const Precondition = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * Options for creating a new transaction. - * - * @property {Object} readOnly - * The transaction can only be used for read operations. - * - * This object should have the same structure as [ReadOnly]{@link google.firestore.v1.ReadOnly} - * - * @property {Object} readWrite - * The transaction can be used for both read and write operations. - * - * This object should have the same structure as [ReadWrite]{@link google.firestore.v1.ReadWrite} - * - * @typedef TransactionOptions - * @memberof google.firestore.v1 - * @see [google.firestore.v1.TransactionOptions definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/common.proto} - */ -const TransactionOptions = { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * Options for a transaction that can be used to read and write documents. - * - * @property {Buffer} retryTransaction - * An optional transaction to retry. - * - * @typedef ReadWrite - * @memberof google.firestore.v1 - * @see [google.firestore.v1.TransactionOptions.ReadWrite definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/common.proto} - */ - ReadWrite: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, - - /** - * Options for a transaction that can only be used to read documents. - * - * @property {Object} readTime - * Reads documents at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef ReadOnly - * @memberof google.firestore.v1 - * @see [google.firestore.v1.TransactionOptions.ReadOnly definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/common.proto} - */ - ReadOnly: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, -}; diff --git a/dev/src/v1/doc/google/firestore/v1/doc_document.js b/dev/src/v1/doc/google/firestore/v1/doc_document.js deleted file mode 100644 index e0a9f8ce6..000000000 --- a/dev/src/v1/doc/google/firestore/v1/doc_document.js +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * A Firestore document. - * - * Must not exceed 1 MiB - 4 bytes. - * - * @property {string} name - * The resource name of the document, for example - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * - * @property {Object.} fields - * The document's fields. - * - * The map keys represent field names. - * - * A simple field name contains only characters `a` to `z`, `A` to `Z`, - * `0` to `9`, or `_`, and must not start with `0` to `9`. For example, - * `foo_bar_17`. - * - * Field names matching the regular expression `__.*__` are reserved. Reserved - * field names are forbidden except in certain documented contexts. The map - * keys, represented as UTF-8, must not exceed 1,500 bytes and cannot be - * empty. - * - * Field paths may be used in other contexts to refer to structured fields - * defined here. For `map_value`, the field path is represented by the simple - * or quoted field names of the containing fields, delimited by `.`. For - * example, the structured field - * `"foo" : { map_value: { "x&y" : { string_value: "hello" }}}` would be - * represented by the field path `foo.x&y`. - * - * Within a field path, a quoted field name starts and ends with `` ` `` and - * may contain any character. Some characters, including `` ` ``, must be - * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and - * `` `bak\`tik` `` represents `` bak`tik ``. - * - * @property {Object} createTime - * Output only. The time at which the document was created. - * - * This value increases monotonically when a document is deleted then - * recreated. It can also be compared to values from other documents and - * the `read_time` of a query. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @property {Object} updateTime - * Output only. The time at which the document was last changed. - * - * This value is initially set to the `create_time` then increases - * monotonically with each change to the document. It can also be - * compared to values from other documents and the `read_time` of a query. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef Document - * @memberof google.firestore.v1 - * @see [google.firestore.v1.Document definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/document.proto} - */ -const Document = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A message that can hold any of the supported value types. - * - * @property {number} nullValue - * A null value. - * - * The number should be among the values of [NullValue]{@link google.protobuf.NullValue} - * - * @property {boolean} booleanValue - * A boolean value. - * - * @property {number} integerValue - * An integer value. - * - * @property {number} doubleValue - * A double value. - * - * @property {Object} timestampValue - * A timestamp value. - * - * Precise only to microseconds. When stored, any additional precision is - * rounded down. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @property {string} stringValue - * A string value. - * - * The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes. - * Only the first 1,500 bytes of the UTF-8 representation are considered by - * queries. - * - * @property {Buffer} bytesValue - * A bytes value. - * - * Must not exceed 1 MiB - 89 bytes. - * Only the first 1,500 bytes are considered by queries. - * - * @property {string} referenceValue - * A reference to a document. For example: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * - * @property {Object} geoPointValue - * A geo point value representing a point on the surface of Earth. - * - * This object should have the same structure as [LatLng]{@link google.type.LatLng} - * - * @property {Object} arrayValue - * An array value. - * - * Cannot directly contain another array value, though can contain an - * map which contains another array. - * - * This object should have the same structure as [ArrayValue]{@link google.firestore.v1.ArrayValue} - * - * @property {Object} mapValue - * A map value. - * - * This object should have the same structure as [MapValue]{@link google.firestore.v1.MapValue} - * - * @typedef Value - * @memberof google.firestore.v1 - * @see [google.firestore.v1.Value definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/document.proto} - */ -const Value = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * An array value. - * - * @property {Object[]} values - * Values in the array. - * - * This object should have the same structure as [Value]{@link google.firestore.v1.Value} - * - * @typedef ArrayValue - * @memberof google.firestore.v1 - * @see [google.firestore.v1.ArrayValue definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/document.proto} - */ -const ArrayValue = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A map value. - * - * @property {Object.} fields - * The map's fields. - * - * The map keys represent field names. Field names matching the regular - * expression `__.*__` are reserved. Reserved field names are forbidden except - * in certain documented contexts. The map keys, represented as UTF-8, must - * not exceed 1,500 bytes and cannot be empty. - * - * @typedef MapValue - * @memberof google.firestore.v1 - * @see [google.firestore.v1.MapValue definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/document.proto} - */ -const MapValue = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1/doc/google/firestore/v1/doc_firestore.js b/dev/src/v1/doc/google/firestore/v1/doc_firestore.js deleted file mode 100644 index 7f9394125..000000000 --- a/dev/src/v1/doc/google/firestore/v1/doc_firestore.js +++ /dev/null @@ -1,859 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * The request for Firestore.GetDocument. - * - * @property {string} name - * The resource name of the Document to get. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * - * @property {Object} mask - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1.DocumentMask} - * - * @property {Buffer} transaction - * Reads the document in a transaction. - * - * @property {Object} readTime - * Reads the version of the document at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef GetDocumentRequest - * @memberof google.firestore.v1 - * @see [google.firestore.v1.GetDocumentRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const GetDocumentRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.ListDocuments. - * - * @property {string} parent - * 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` - * - * @property {string} collectionId - * The collection ID, relative to `parent`, to list. For example: `chatrooms` - * or `messages`. - * - * @property {number} pageSize - * The maximum number of documents to return. - * - * @property {string} pageToken - * The `next_page_token` value returned from a previous List request, if any. - * - * @property {string} orderBy - * The order to sort results by. For example: `priority desc, name`. - * - * @property {Object} 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. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1.DocumentMask} - * - * @property {Buffer} transaction - * Reads documents in a transaction. - * - * @property {Object} readTime - * Reads documents as they were at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @property {boolean} 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, Document.create_time, - * or Document.update_time set. - * - * Requests with `show_missing` may not specify `where` or - * `order_by`. - * - * @typedef ListDocumentsRequest - * @memberof google.firestore.v1 - * @see [google.firestore.v1.ListDocumentsRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const ListDocumentsRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The response for Firestore.ListDocuments. - * - * @property {Object[]} documents - * The Documents found. - * - * This object should have the same structure as [Document]{@link google.firestore.v1.Document} - * - * @property {string} nextPageToken - * The next page token. - * - * @typedef ListDocumentsResponse - * @memberof google.firestore.v1 - * @see [google.firestore.v1.ListDocumentsResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const ListDocumentsResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.CreateDocument. - * - * @property {string} parent - * The parent resource. For example: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` - * - * @property {string} collectionId - * The collection ID, relative to `parent`, to list. For example: `chatrooms`. - * - * @property {string} documentId - * The client-assigned document ID to use for this document. - * - * Optional. If not specified, an ID will be assigned by the service. - * - * @property {Object} document - * The document to create. `name` must not be set. - * - * This object should have the same structure as [Document]{@link google.firestore.v1.Document} - * - * @property {Object} mask - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1.DocumentMask} - * - * @typedef CreateDocumentRequest - * @memberof google.firestore.v1 - * @see [google.firestore.v1.CreateDocumentRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const CreateDocumentRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.UpdateDocument. - * - * @property {Object} document - * The updated document. - * Creates the document if it does not already exist. - * - * This object should have the same structure as [Document]{@link google.firestore.v1.Document} - * - * @property {Object} updateMask - * The fields to update. - * None of the field paths in the mask may contain a reserved name. - * - * If the document exists on the server and has fields not referenced in the - * mask, they are left unchanged. - * Fields referenced in the mask, but not present in the input document, are - * deleted from the document on the server. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1.DocumentMask} - * - * @property {Object} mask - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1.DocumentMask} - * - * @property {Object} currentDocument - * An optional precondition on the document. - * The request will fail if this is set and not met by the target document. - * - * This object should have the same structure as [Precondition]{@link google.firestore.v1.Precondition} - * - * @typedef UpdateDocumentRequest - * @memberof google.firestore.v1 - * @see [google.firestore.v1.UpdateDocumentRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const UpdateDocumentRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.DeleteDocument. - * - * @property {string} name - * The resource name of the Document to delete. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * - * @property {Object} currentDocument - * An optional precondition on the document. - * The request will fail if this is set and not met by the target document. - * - * This object should have the same structure as [Precondition]{@link google.firestore.v1.Precondition} - * - * @typedef DeleteDocumentRequest - * @memberof google.firestore.v1 - * @see [google.firestore.v1.DeleteDocumentRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const DeleteDocumentRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.BatchGetDocuments. - * - * @property {string} database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * - * @property {string[]} documents - * The names of the documents to retrieve. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * The request will fail if any of the document is not a child resource of the - * given `database`. Duplicate names will be elided. - * - * @property {Object} 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. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1.DocumentMask} - * - * @property {Buffer} transaction - * Reads documents in a transaction. - * - * @property {Object} newTransaction - * Starts a new transaction and reads the documents. - * Defaults to a read-only transaction. - * The new transaction ID will be returned as the first response in the - * stream. - * - * This object should have the same structure as [TransactionOptions]{@link google.firestore.v1.TransactionOptions} - * - * @property {Object} readTime - * Reads documents as they were at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef BatchGetDocumentsRequest - * @memberof google.firestore.v1 - * @see [google.firestore.v1.BatchGetDocumentsRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const BatchGetDocumentsRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The streamed response for Firestore.BatchGetDocuments. - * - * @property {Object} found - * A document that was requested. - * - * This object should have the same structure as [Document]{@link google.firestore.v1.Document} - * - * @property {string} missing - * A document name that was requested but does not exist. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * - * @property {Buffer} transaction - * The transaction that was started as part of this request. - * Will only be set in the first response, and only if - * BatchGetDocumentsRequest.new_transaction was set in the request. - * - * @property {Object} readTime - * The time at which the document was read. - * This may be monotically increasing, in this case the previous documents in - * the result stream are guaranteed not to have changed between their - * read_time and this one. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef BatchGetDocumentsResponse - * @memberof google.firestore.v1 - * @see [google.firestore.v1.BatchGetDocumentsResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const BatchGetDocumentsResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.BeginTransaction. - * - * @property {string} database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * - * @property {Object} options - * The options for the transaction. - * Defaults to a read-write transaction. - * - * This object should have the same structure as [TransactionOptions]{@link google.firestore.v1.TransactionOptions} - * - * @typedef BeginTransactionRequest - * @memberof google.firestore.v1 - * @see [google.firestore.v1.BeginTransactionRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const BeginTransactionRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The response for Firestore.BeginTransaction. - * - * @property {Buffer} transaction - * The transaction that was started. - * - * @typedef BeginTransactionResponse - * @memberof google.firestore.v1 - * @see [google.firestore.v1.BeginTransactionResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const BeginTransactionResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.Commit. - * - * @property {string} database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * - * @property {Object[]} writes - * The writes to apply. - * - * Always executed atomically and in order. - * - * This object should have the same structure as [Write]{@link google.firestore.v1.Write} - * - * @property {Buffer} transaction - * If set, applies all writes in this transaction, and commits it. - * - * @typedef CommitRequest - * @memberof google.firestore.v1 - * @see [google.firestore.v1.CommitRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const CommitRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The response for Firestore.Commit. - * - * @property {Object[]} writeResults - * The result of applying the writes. - * - * This i-th write result corresponds to the i-th write in the - * request. - * - * This object should have the same structure as [WriteResult]{@link google.firestore.v1.WriteResult} - * - * @property {Object} commitTime - * The time at which the commit occurred. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef CommitResponse - * @memberof google.firestore.v1 - * @see [google.firestore.v1.CommitResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const CommitResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.Rollback. - * - * @property {string} database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * - * @property {Buffer} transaction - * The transaction to roll back. - * - * @typedef RollbackRequest - * @memberof google.firestore.v1 - * @see [google.firestore.v1.RollbackRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const RollbackRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.RunQuery. - * - * @property {string} parent - * 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` - * - * @property {Object} structuredQuery - * A structured query. - * - * This object should have the same structure as [StructuredQuery]{@link google.firestore.v1.StructuredQuery} - * - * @property {Buffer} transaction - * Reads documents in a transaction. - * - * @property {Object} newTransaction - * Starts a new transaction and reads the documents. - * Defaults to a read-only transaction. - * The new transaction ID will be returned as the first response in the - * stream. - * - * This object should have the same structure as [TransactionOptions]{@link google.firestore.v1.TransactionOptions} - * - * @property {Object} readTime - * Reads documents as they were at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef RunQueryRequest - * @memberof google.firestore.v1 - * @see [google.firestore.v1.RunQueryRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const RunQueryRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The response for Firestore.RunQuery. - * - * @property {Buffer} transaction - * The transaction that was started as part of this request. - * Can only be set in the first response, and only if - * RunQueryRequest.new_transaction was set in the request. - * If set, no other fields will be set in this response. - * - * @property {Object} document - * A query result. - * Not set when reporting partial progress. - * - * This object should have the same structure as [Document]{@link google.firestore.v1.Document} - * - * @property {Object} readTime - * The time at which the document was read. This may be monotonically - * increasing; in this case, the previous documents in the result stream are - * guaranteed not to have changed between their `read_time` and this one. - * - * If the query returns no results, a response with `read_time` and no - * `document` will be sent, and this represents the time at which the query - * was run. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @property {number} skippedResults - * The number of results that have been skipped due to an offset between - * the last response and the current response. - * - * @typedef RunQueryResponse - * @memberof google.firestore.v1 - * @see [google.firestore.v1.RunQueryResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const RunQueryResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.Write. - * - * The first request creates a stream, or resumes an existing one from a token. - * - * When creating a new stream, the server replies with a response containing - * only an ID and a token, to use in the next request. - * - * When resuming a stream, the server first streams any responses later than the - * given token, then a response containing only an up-to-date token, to use in - * the next request. - * - * @property {string} database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * This is only required in the first message. - * - * @property {string} streamId - * The ID of the write stream to resume. - * This may only be set in the first message. When left empty, a new write - * stream will be created. - * - * @property {Object[]} writes - * The writes to apply. - * - * Always executed atomically and in order. - * This must be empty on the first request. - * This may be empty on the last request. - * This must not be empty on all other requests. - * - * This object should have the same structure as [Write]{@link google.firestore.v1.Write} - * - * @property {Buffer} streamToken - * A stream token that was previously sent by the server. - * - * The client should set this field to the token from the most recent - * WriteResponse it has received. This acknowledges that the client has - * received responses up to this token. After sending this token, earlier - * tokens may not be used anymore. - * - * The server may close the stream if there are too many unacknowledged - * responses. - * - * Leave this field unset when creating a new stream. To resume a stream at - * a specific point, set this field and the `stream_id` field. - * - * Leave this field unset when creating a new stream. - * - * @property {Object.} labels - * Labels associated with this write request. - * - * @typedef WriteRequest - * @memberof google.firestore.v1 - * @see [google.firestore.v1.WriteRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const WriteRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The response for Firestore.Write. - * - * @property {string} streamId - * The ID of the stream. - * Only set on the first message, when a new stream was created. - * - * @property {Buffer} streamToken - * A token that represents the position of this response in the stream. - * This can be used by a client to resume the stream at this point. - * - * This field is always set. - * - * @property {Object[]} writeResults - * The result of applying the writes. - * - * This i-th write result corresponds to the i-th write in the - * request. - * - * This object should have the same structure as [WriteResult]{@link google.firestore.v1.WriteResult} - * - * @property {Object} commitTime - * The time at which the commit occurred. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef WriteResponse - * @memberof google.firestore.v1 - * @see [google.firestore.v1.WriteResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const WriteResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A request for Firestore.Listen - * - * @property {string} database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * - * @property {Object} addTarget - * A target to add to this stream. - * - * This object should have the same structure as [Target]{@link google.firestore.v1.Target} - * - * @property {number} removeTarget - * The ID of a target to remove from this stream. - * - * @property {Object.} labels - * Labels associated with this target change. - * - * @typedef ListenRequest - * @memberof google.firestore.v1 - * @see [google.firestore.v1.ListenRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const ListenRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The response for Firestore.Listen. - * - * @property {Object} targetChange - * Targets have changed. - * - * This object should have the same structure as [TargetChange]{@link google.firestore.v1.TargetChange} - * - * @property {Object} documentChange - * A Document has changed. - * - * This object should have the same structure as [DocumentChange]{@link google.firestore.v1.DocumentChange} - * - * @property {Object} documentDelete - * A Document has been deleted. - * - * This object should have the same structure as [DocumentDelete]{@link google.firestore.v1.DocumentDelete} - * - * @property {Object} documentRemove - * A Document has been removed from a target (because it is no longer - * relevant to that target). - * - * This object should have the same structure as [DocumentRemove]{@link google.firestore.v1.DocumentRemove} - * - * @property {Object} filter - * A filter to apply to the set of documents previously returned for the - * given target. - * - * Returned when documents may have been removed from the given target, but - * the exact documents are unknown. - * - * This object should have the same structure as [ExistenceFilter]{@link google.firestore.v1.ExistenceFilter} - * - * @typedef ListenResponse - * @memberof google.firestore.v1 - * @see [google.firestore.v1.ListenResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const ListenResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A specification of a set of documents to listen to. - * - * @property {Object} query - * A target specified by a query. - * - * This object should have the same structure as [QueryTarget]{@link google.firestore.v1.QueryTarget} - * - * @property {Object} documents - * A target specified by a set of document names. - * - * This object should have the same structure as [DocumentsTarget]{@link google.firestore.v1.DocumentsTarget} - * - * @property {Buffer} resumeToken - * A resume token from a prior TargetChange for an identical target. - * - * Using a resume token with a different target is unsupported and may fail. - * - * @property {Object} readTime - * Start listening after a specific `read_time`. - * - * The client must know the state of matching documents at this time. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @property {number} targetId - * The target ID that identifies the target on the stream. Must be a positive - * number and non-zero. - * - * @property {boolean} once - * If the target should be removed once it is current and consistent. - * - * @typedef Target - * @memberof google.firestore.v1 - * @see [google.firestore.v1.Target definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const Target = { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * A target specified by a set of documents names. - * - * @property {string[]} documents - * The names of the documents to retrieve. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * The request will fail if any of the document is not a child resource of - * the given `database`. Duplicate names will be elided. - * - * @typedef DocumentsTarget - * @memberof google.firestore.v1 - * @see [google.firestore.v1.Target.DocumentsTarget definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ - DocumentsTarget: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, - - /** - * A target specified by a query. - * - * @property {string} parent - * 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` - * - * @property {Object} structuredQuery - * A structured query. - * - * This object should have the same structure as [StructuredQuery]{@link google.firestore.v1.StructuredQuery} - * - * @typedef QueryTarget - * @memberof google.firestore.v1 - * @see [google.firestore.v1.Target.QueryTarget definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ - QueryTarget: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, -}; - -/** - * Targets being watched have changed. - * - * @property {number} targetChangeType - * The type of change that occurred. - * - * The number should be among the values of [TargetChangeType]{@link google.firestore.v1.TargetChangeType} - * - * @property {number[]} targetIds - * The target IDs of targets that have changed. - * - * If empty, the change applies to all targets. - * - * The order of the target IDs is not defined. - * - * @property {Object} cause - * The error that resulted in this change, if applicable. - * - * This object should have the same structure as [Status]{@link google.rpc.Status} - * - * @property {Buffer} resumeToken - * A token that can be used to resume the stream for the given `target_ids`, - * or all targets if `target_ids` is empty. - * - * Not set on every target change. - * - * @property {Object} readTime - * The consistent `read_time` for the given `target_ids` (omitted when the - * target_ids are not at a consistent snapshot). - * - * The stream is guaranteed to send a `read_time` with `target_ids` empty - * whenever the entire stream reaches a new consistent snapshot. ADD, - * CURRENT, and RESET messages are guaranteed to (eventually) result in a - * new consistent snapshot (while NO_CHANGE and REMOVE messages are not). - * - * For a given stream, `read_time` is guaranteed to be monotonically - * increasing. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef TargetChange - * @memberof google.firestore.v1 - * @see [google.firestore.v1.TargetChange definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const TargetChange = { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * The type of change. - * - * @enum {number} - * @memberof google.firestore.v1 - */ - TargetChangeType: { - /** - * No change has occurred. Used only to send an updated `resume_token`. - */ - NO_CHANGE: 0, - - /** - * The targets have been added. - */ - ADD: 1, - - /** - * The targets have been removed. - */ - REMOVE: 2, - - /** - * The targets reflect all changes committed before the targets were added - * to the stream. - * - * This will be sent after or with a `read_time` that is greater than or - * equal to the time at which the targets were added. - * - * Listeners can wait for this change if read-after-write semantics - * are desired. - */ - CURRENT: 3, - - /** - * The targets have been reset, and a new initial state for the targets - * will be returned in subsequent changes. - * - * After the initial state is complete, `CURRENT` will be returned even - * if the target was previously indicated to be `CURRENT`. - */ - RESET: 4, - }, -}; - -/** - * The request for Firestore.ListCollectionIds. - * - * @property {string} parent - * 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` - * - * @property {number} pageSize - * The maximum number of results to return. - * - * @property {string} pageToken - * A page token. Must be a value from - * ListCollectionIdsResponse. - * - * @typedef ListCollectionIdsRequest - * @memberof google.firestore.v1 - * @see [google.firestore.v1.ListCollectionIdsRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const ListCollectionIdsRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The response from Firestore.ListCollectionIds. - * - * @property {string[]} collectionIds - * The collection ids. - * - * @property {string} nextPageToken - * A page token that may be used to continue the list. - * - * @typedef ListCollectionIdsResponse - * @memberof google.firestore.v1 - * @see [google.firestore.v1.ListCollectionIdsResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto} - */ -const ListCollectionIdsResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1/doc/google/firestore/v1/doc_query.js b/dev/src/v1/doc/google/firestore/v1/doc_query.js deleted file mode 100644 index ce8114309..000000000 --- a/dev/src/v1/doc/google/firestore/v1/doc_query.js +++ /dev/null @@ -1,399 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * A Firestore query. - * - * @property {Object} select - * The projection to return. - * - * This object should have the same structure as [Projection]{@link google.firestore.v1.Projection} - * - * @property {Object[]} from - * The collections to query. - * - * This object should have the same structure as [CollectionSelector]{@link google.firestore.v1.CollectionSelector} - * - * @property {Object} where - * The filter to apply. - * - * This object should have the same structure as [Filter]{@link google.firestore.v1.Filter} - * - * @property {Object[]} orderBy - * The order to apply to the query results. - * - * Firestore guarantees a stable ordering through the following rules: - * - * * Any field required to appear in `order_by`, that is not already - * specified in `order_by`, is appended to the order in field name order - * by default. - * * If an order on `__name__` is not specified, it is appended by default. - * - * Fields are appended with the same sort direction as the last order - * specified, or 'ASCENDING' if no order was specified. For example: - * - * * `SELECT * FROM Foo ORDER BY A` becomes - * `SELECT * FROM Foo ORDER BY A, __name__` - * * `SELECT * FROM Foo ORDER BY A DESC` becomes - * `SELECT * FROM Foo ORDER BY A DESC, __name__ DESC` - * * `SELECT * FROM Foo WHERE A > 1` becomes - * `SELECT * FROM Foo WHERE A > 1 ORDER BY A, __name__` - * - * This object should have the same structure as [Order]{@link google.firestore.v1.Order} - * - * @property {Object} startAt - * A starting point for the query results. - * - * This object should have the same structure as [Cursor]{@link google.firestore.v1.Cursor} - * - * @property {Object} endAt - * A end point for the query results. - * - * This object should have the same structure as [Cursor]{@link google.firestore.v1.Cursor} - * - * @property {number} offset - * The number of results to skip. - * - * Applies before limit, but after all other constraints. Must be >= 0 if - * specified. - * - * @property {Object} limit - * The maximum number of results to return. - * - * Applies after all other constraints. - * Must be >= 0 if specified. - * - * This object should have the same structure as [Int32Value]{@link google.protobuf.Int32Value} - * - * @typedef StructuredQuery - * @memberof google.firestore.v1 - * @see [google.firestore.v1.StructuredQuery definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/query.proto} - */ -const StructuredQuery = { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * A selection of a collection, such as `messages as m1`. - * - * @property {string} collectionId - * The collection ID. - * When set, selects only collections with this ID. - * - * @property {boolean} allDescendants - * When false, selects only collections that are immediate children of - * the `parent` specified in the containing `RunQueryRequest`. - * When true, selects all descendant collections. - * - * @typedef CollectionSelector - * @memberof google.firestore.v1 - * @see [google.firestore.v1.StructuredQuery.CollectionSelector definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/query.proto} - */ - CollectionSelector: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, - - /** - * A filter. - * - * @property {Object} compositeFilter - * A composite filter. - * - * This object should have the same structure as [CompositeFilter]{@link google.firestore.v1.CompositeFilter} - * - * @property {Object} fieldFilter - * A filter on a document field. - * - * This object should have the same structure as [FieldFilter]{@link google.firestore.v1.FieldFilter} - * - * @property {Object} unaryFilter - * A filter that takes exactly one argument. - * - * This object should have the same structure as [UnaryFilter]{@link google.firestore.v1.UnaryFilter} - * - * @typedef Filter - * @memberof google.firestore.v1 - * @see [google.firestore.v1.StructuredQuery.Filter definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/query.proto} - */ - Filter: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, - - /** - * A filter that merges multiple other filters using the given operator. - * - * @property {number} op - * The operator for combining multiple filters. - * - * The number should be among the values of [Operator]{@link google.firestore.v1.Operator} - * - * @property {Object[]} filters - * The list of filters to combine. - * Must contain at least one filter. - * - * This object should have the same structure as [Filter]{@link google.firestore.v1.Filter} - * - * @typedef CompositeFilter - * @memberof google.firestore.v1 - * @see [google.firestore.v1.StructuredQuery.CompositeFilter definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/query.proto} - */ - CompositeFilter: { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * A composite filter operator. - * - * @enum {number} - * @memberof google.firestore.v1 - */ - Operator: { - /** - * Unspecified. This value must not be used. - */ - OPERATOR_UNSPECIFIED: 0, - - /** - * The results are required to satisfy each of the combined filters. - */ - AND: 1, - }, - }, - - /** - * A filter on a specific field. - * - * @property {Object} field - * The field to filter by. - * - * This object should have the same structure as [FieldReference]{@link google.firestore.v1.FieldReference} - * - * @property {number} op - * The operator to filter by. - * - * The number should be among the values of [Operator]{@link google.firestore.v1.Operator} - * - * @property {Object} value - * The value to compare to. - * - * This object should have the same structure as [Value]{@link google.firestore.v1.Value} - * - * @typedef FieldFilter - * @memberof google.firestore.v1 - * @see [google.firestore.v1.StructuredQuery.FieldFilter definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/query.proto} - */ - FieldFilter: { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * A field filter operator. - * - * @enum {number} - * @memberof google.firestore.v1 - */ - Operator: { - /** - * Unspecified. This value must not be used. - */ - OPERATOR_UNSPECIFIED: 0, - - /** - * Less than. Requires that the field come first in `order_by`. - */ - LESS_THAN: 1, - - /** - * Less than or equal. Requires that the field come first in `order_by`. - */ - LESS_THAN_OR_EQUAL: 2, - - /** - * Greater than. Requires that the field come first in `order_by`. - */ - GREATER_THAN: 3, - - /** - * Greater than or equal. Requires that the field come first in - * `order_by`. - */ - GREATER_THAN_OR_EQUAL: 4, - - /** - * Equal. - */ - EQUAL: 5, - - /** - * Contains. Requires that the field is an array. - */ - ARRAY_CONTAINS: 7, - - /** - * In. Requires that `value` is a non-empty ArrayValue with at most 10 - * values. - */ - IN: 8, - - /** - * Contains any. Requires that the field is an array and - * `value` is a non-empty ArrayValue with at most 10 values. - */ - ARRAY_CONTAINS_ANY: 9, - }, - }, - - /** - * A filter with a single operand. - * - * @property {number} op - * The unary operator to apply. - * - * The number should be among the values of [Operator]{@link google.firestore.v1.Operator} - * - * @property {Object} field - * The field to which to apply the operator. - * - * This object should have the same structure as [FieldReference]{@link google.firestore.v1.FieldReference} - * - * @typedef UnaryFilter - * @memberof google.firestore.v1 - * @see [google.firestore.v1.StructuredQuery.UnaryFilter definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/query.proto} - */ - UnaryFilter: { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * A unary operator. - * - * @enum {number} - * @memberof google.firestore.v1 - */ - Operator: { - /** - * Unspecified. This value must not be used. - */ - OPERATOR_UNSPECIFIED: 0, - - /** - * Test if a field is equal to NaN. - */ - IS_NAN: 2, - - /** - * Test if an expression evaluates to Null. - */ - IS_NULL: 3, - }, - }, - - /** - * The projection of document's fields to return. - * - * @property {Object[]} fields - * The fields to return. - * - * If empty, all fields are returned. To only return the name - * of the document, use `['__name__']`. - * - * This object should have the same structure as [FieldReference]{@link google.firestore.v1.FieldReference} - * - * @typedef Projection - * @memberof google.firestore.v1 - * @see [google.firestore.v1.StructuredQuery.Projection definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/query.proto} - */ - Projection: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, - - /** - * An order on a field. - * - * @property {Object} field - * The field to order by. - * - * This object should have the same structure as [FieldReference]{@link google.firestore.v1.FieldReference} - * - * @property {number} direction - * The direction to order by. Defaults to `ASCENDING`. - * - * The number should be among the values of [Direction]{@link google.firestore.v1.Direction} - * - * @typedef Order - * @memberof google.firestore.v1 - * @see [google.firestore.v1.StructuredQuery.Order definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/query.proto} - */ - Order: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, - - /** - * A reference to a field, such as `max(messages.time) as max_time`. - * - * @property {string} fieldPath - * - * @typedef FieldReference - * @memberof google.firestore.v1 - * @see [google.firestore.v1.StructuredQuery.FieldReference definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/query.proto} - */ - FieldReference: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, - - /** - * A sort direction. - * - * @enum {number} - * @memberof google.firestore.v1 - */ - Direction: { - /** - * Unspecified. - */ - DIRECTION_UNSPECIFIED: 0, - - /** - * Ascending. - */ - ASCENDING: 1, - - /** - * Descending. - */ - DESCENDING: 2, - }, -}; - -/** - * A position in a query result set. - * - * @property {Object[]} values - * The values that represent a position, in the order they appear in - * the order by clause of a query. - * - * Can contain fewer values than specified in the order by clause. - * - * This object should have the same structure as [Value]{@link google.firestore.v1.Value} - * - * @property {boolean} before - * If the position is just before or just after the given values, relative - * to the sort order defined by the query. - * - * @typedef Cursor - * @memberof google.firestore.v1 - * @see [google.firestore.v1.Cursor definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/query.proto} - */ -const Cursor = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1/doc/google/firestore/v1/doc_write.js b/dev/src/v1/doc/google/firestore/v1/doc_write.js deleted file mode 100644 index 6f4ee1bfc..000000000 --- a/dev/src/v1/doc/google/firestore/v1/doc_write.js +++ /dev/null @@ -1,338 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * A write on a document. - * - * @property {Object} update - * A document to write. - * - * This object should have the same structure as [Document]{@link google.firestore.v1.Document} - * - * @property {string} delete - * A document name to delete. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * - * @property {Object} transform - * Applies a transformation to a document. - * At most one `transform` per document is allowed in a given request. - * An `update` cannot follow a `transform` on the same document in a given - * request. - * - * This object should have the same structure as [DocumentTransform]{@link google.firestore.v1.DocumentTransform} - * - * @property {Object} updateMask - * The fields to update in this write. - * - * This field can be set only when the operation is `update`. - * If the mask is not set for an `update` and the document exists, any - * existing data will be overwritten. - * If the mask is set and the document on the server has fields not covered by - * the mask, they are left unchanged. - * Fields referenced in the mask, but not present in the input document, are - * deleted from the document on the server. - * The field paths in this mask must not contain a reserved field name. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1.DocumentMask} - * - * @property {Object} currentDocument - * An optional precondition on the document. - * - * The write will fail if this is set and not met by the target document. - * - * This object should have the same structure as [Precondition]{@link google.firestore.v1.Precondition} - * - * @typedef Write - * @memberof google.firestore.v1 - * @see [google.firestore.v1.Write definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/write.proto} - */ -const Write = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A transformation of a document. - * - * @property {string} document - * The name of the document to transform. - * - * @property {Object[]} fieldTransforms - * The list of transformations to apply to the fields of the document, in - * order. - * This must not be empty. - * - * This object should have the same structure as [FieldTransform]{@link google.firestore.v1.FieldTransform} - * - * @typedef DocumentTransform - * @memberof google.firestore.v1 - * @see [google.firestore.v1.DocumentTransform definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/write.proto} - */ -const DocumentTransform = { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * A transformation of a field of the document. - * - * @property {string} fieldPath - * The path of the field. See Document.fields for the field path syntax - * reference. - * - * @property {number} setToServerValue - * Sets the field to the given server value. - * - * The number should be among the values of [ServerValue]{@link google.firestore.v1.ServerValue} - * - * @property {Object} increment - * Adds the given value to the field's current value. - * - * This must be an integer or a double value. - * If the field is not an integer or double, or if the field does not yet - * exist, the transformation will set the field to the given value. - * If either of the given value or the current field value are doubles, - * both values will be interpreted as doubles. Double arithmetic and - * representation of double values follow IEEE 754 semantics. - * If there is positive/negative integer overflow, the field is resolved - * to the largest magnitude positive/negative integer. - * - * This object should have the same structure as [Value]{@link google.firestore.v1.Value} - * - * @property {Object} maximum - * Sets the field to the maximum of its current value and the given value. - * - * This must be an integer or a double value. - * If the field is not an integer or double, or if the field does not yet - * exist, the transformation will set the field to the given value. - * If a maximum operation is applied where the field and the input value - * are of mixed types (that is - one is an integer and one is a double) - * the field takes on the type of the larger operand. If the operands are - * equivalent (e.g. 3 and 3.0), the field does not change. - * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and - * zero input value is always the stored value. - * The maximum of any numeric value x and NaN is NaN. - * - * This object should have the same structure as [Value]{@link google.firestore.v1.Value} - * - * @property {Object} minimum - * Sets the field to the minimum of its current value and the given value. - * - * This must be an integer or a double value. - * If the field is not an integer or double, or if the field does not yet - * exist, the transformation will set the field to the input value. - * If a minimum operation is applied where the field and the input value - * are of mixed types (that is - one is an integer and one is a double) - * the field takes on the type of the smaller operand. If the operands are - * equivalent (e.g. 3 and 3.0), the field does not change. - * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and - * zero input value is always the stored value. - * The minimum of any numeric value x and NaN is NaN. - * - * This object should have the same structure as [Value]{@link google.firestore.v1.Value} - * - * @property {Object} appendMissingElements - * Append the given elements in order if they are not already present in - * the current field value. - * If the field is not an array, or if the field does not yet exist, it is - * first set to the empty array. - * - * Equivalent numbers of different types (e.g. 3L and 3.0) are - * considered equal when checking if a value is missing. - * NaN is equal to NaN, and Null is equal to Null. - * If the input contains multiple equivalent values, only the first will - * be considered. - * - * The corresponding transform_result will be the null value. - * - * This object should have the same structure as [ArrayValue]{@link google.firestore.v1.ArrayValue} - * - * @property {Object} removeAllFromArray - * Remove all of the given elements from the array in the field. - * If the field is not an array, or if the field does not yet exist, it is - * set to the empty array. - * - * Equivalent numbers of the different types (e.g. 3L and 3.0) are - * considered equal when deciding whether an element should be removed. - * NaN is equal to NaN, and Null is equal to Null. - * This will remove all equivalent values if there are duplicates. - * - * The corresponding transform_result will be the null value. - * - * This object should have the same structure as [ArrayValue]{@link google.firestore.v1.ArrayValue} - * - * @typedef FieldTransform - * @memberof google.firestore.v1 - * @see [google.firestore.v1.DocumentTransform.FieldTransform definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/write.proto} - */ - FieldTransform: { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * A value that is calculated by the server. - * - * @enum {number} - * @memberof google.firestore.v1 - */ - ServerValue: { - /** - * Unspecified. This value must not be used. - */ - SERVER_VALUE_UNSPECIFIED: 0, - - /** - * The time at which the server processed the request, with millisecond - * precision. - */ - REQUEST_TIME: 1, - }, - }, -}; - -/** - * The result of applying a write. - * - * @property {Object} updateTime - * The last update time of the document after applying the write. Not set - * after a `delete`. - * - * If the write did not actually change the document, this will be the - * previous update_time. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @property {Object[]} transformResults - * The results of applying each DocumentTransform.FieldTransform, in the - * same order. - * - * This object should have the same structure as [Value]{@link google.firestore.v1.Value} - * - * @typedef WriteResult - * @memberof google.firestore.v1 - * @see [google.firestore.v1.WriteResult definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/write.proto} - */ -const WriteResult = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A Document has changed. - * - * May be the result of multiple writes, including deletes, that - * ultimately resulted in a new value for the Document. - * - * Multiple DocumentChange messages may be returned for the same logical - * change, if multiple targets are affected. - * - * @property {Object} document - * The new state of the Document. - * - * If `mask` is set, contains only fields that were updated or added. - * - * This object should have the same structure as [Document]{@link google.firestore.v1.Document} - * - * @property {number[]} targetIds - * A set of target IDs of targets that match this document. - * - * @property {number[]} removedTargetIds - * A set of target IDs for targets that no longer match this document. - * - * @typedef DocumentChange - * @memberof google.firestore.v1 - * @see [google.firestore.v1.DocumentChange definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/write.proto} - */ -const DocumentChange = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A Document has been deleted. - * - * May be the result of multiple writes, including updates, the - * last of which deleted the Document. - * - * Multiple DocumentDelete messages may be returned for the same logical - * delete, if multiple targets are affected. - * - * @property {string} document - * The resource name of the Document that was deleted. - * - * @property {number[]} removedTargetIds - * A set of target IDs for targets that previously matched this entity. - * - * @property {Object} readTime - * The read timestamp at which the delete was observed. - * - * Greater or equal to the `commit_time` of the delete. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef DocumentDelete - * @memberof google.firestore.v1 - * @see [google.firestore.v1.DocumentDelete definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/write.proto} - */ -const DocumentDelete = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A Document has been removed from the view of the targets. - * - * Sent if the document is no longer relevant to a target and is out of view. - * Can be sent instead of a DocumentDelete or a DocumentChange if the server - * can not send the new value of the document. - * - * Multiple DocumentRemove messages may be returned for the same logical - * write or delete, if multiple targets are affected. - * - * @property {string} document - * The resource name of the Document that has gone out of view. - * - * @property {number[]} removedTargetIds - * A set of target IDs for targets that previously matched this document. - * - * @property {Object} readTime - * The read timestamp at which the remove was observed. - * - * Greater or equal to the `commit_time` of the change/delete/remove. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef DocumentRemove - * @memberof google.firestore.v1 - * @see [google.firestore.v1.DocumentRemove definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/write.proto} - */ -const DocumentRemove = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A digest of all the documents that match a given target. - * - * @property {number} targetId - * The target ID to which this filter applies. - * - * @property {number} count - * The total count of documents that match target_id. - * - * If different from the count of documents in the client that match, the - * client must manually determine which documents no longer match the target. - * - * @typedef ExistenceFilter - * @memberof google.firestore.v1 - * @see [google.firestore.v1.ExistenceFilter definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/write.proto} - */ -const ExistenceFilter = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1/doc/google/longrunning/doc_operations.js b/dev/src/v1/doc/google/longrunning/doc_operations.js deleted file mode 100644 index c37c0ad13..000000000 --- a/dev/src/v1/doc/google/longrunning/doc_operations.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * This resource represents a long-running operation that is the result of a - * network API call. - * - * @property {string} name - * The server-assigned name, which is only unique within the same service that - * originally returns it. If you use the default HTTP mapping, the - * `name` should have the format of `operations/some/unique/name`. - * - * @property {Object} metadata - * Service-specific metadata associated with the operation. It typically - * contains progress information and common metadata such as create time. - * Some services might not provide such metadata. Any method that returns a - * long-running operation should document the metadata type, if any. - * - * This object should have the same structure as [Any]{@link google.protobuf.Any} - * - * @property {boolean} done - * If the value is `false`, it means the operation is still in progress. - * If `true`, the operation is completed, and either `error` or `response` is - * available. - * - * @property {Object} error - * The error result of the operation in case of failure or cancellation. - * - * This object should have the same structure as [Status]{@link google.rpc.Status} - * - * @property {Object} response - * The normal response of the operation in case of success. If the original - * method returns no data on success, such as `Delete`, the response is - * `google.protobuf.Empty`. If the original method is standard - * `Get`/`Create`/`Update`, the response should be the resource. For other - * methods, the response should have the type `XxxResponse`, where `Xxx` - * is the original method name. For example, if the original method name - * is `TakeSnapshot()`, the inferred response type is - * `TakeSnapshotResponse`. - * - * This object should have the same structure as [Any]{@link google.protobuf.Any} - * - * @typedef Operation - * @memberof google.longrunning - * @see [google.longrunning.Operation definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/longrunning/operations.proto} - */ -const Operation = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1/doc/google/protobuf/doc_any.js b/dev/src/v1/doc/google/protobuf/doc_any.js deleted file mode 100644 index 12a36f58d..000000000 --- a/dev/src/v1/doc/google/protobuf/doc_any.js +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * `Any` contains an arbitrary serialized protocol buffer message along with a - * URL that describes the type of the serialized message. - * - * Protobuf library provides support to pack/unpack Any values in the form - * of utility functions or additional generated methods of the Any type. - * - * Example 1: Pack and unpack a message in C++. - * - * Foo foo = ...; - * Any any; - * any.PackFrom(foo); - * ... - * if (any.UnpackTo(&foo)) { - * ... - * } - * - * Example 2: Pack and unpack a message in Java. - * - * Foo foo = ...; - * Any any = Any.pack(foo); - * ... - * if (any.is(Foo.class)) { - * foo = any.unpack(Foo.class); - * } - * - * Example 3: Pack and unpack a message in Python. - * - * foo = Foo(...) - * any = Any() - * any.Pack(foo) - * ... - * if any.Is(Foo.DESCRIPTOR): - * any.Unpack(foo) - * ... - * - * Example 4: Pack and unpack a message in Go - * - * foo := &pb.Foo{...} - * any, err := ptypes.MarshalAny(foo) - * ... - * foo := &pb.Foo{} - * if err := ptypes.UnmarshalAny(any, foo); err != nil { - * ... - * } - * - * The pack methods provided by protobuf library will by default use - * 'type.googleapis.com/full.type.name' as the type URL and the unpack - * methods only use the fully qualified type name after the last '/' - * in the type URL, for example "foo.bar.com/x/y.z" will yield type - * name "y.z". - * - * - * # JSON - * - * The JSON representation of an `Any` value uses the regular - * representation of the deserialized, embedded message, with an - * additional field `@type` which contains the type URL. Example: - * - * package google.profile; - * message Person { - * string first_name = 1; - * string last_name = 2; - * } - * - * { - * "@type": "type.googleapis.com/google.profile.Person", - * "firstName": , - * "lastName": - * } - * - * If the embedded message type is well-known and has a custom JSON - * representation, that representation will be embedded adding a field - * `value` which holds the custom JSON in addition to the `@type` - * field. Example (for message google.protobuf.Duration): - * - * { - * "@type": "type.googleapis.com/google.protobuf.Duration", - * "value": "1.212s" - * } - * - * @property {string} typeUrl - * A URL/resource name that uniquely identifies the type of the serialized - * protocol buffer message. This string must contain at least - * one "/" character. The last segment of the URL's path must represent - * the fully qualified name of the type (as in - * `path/google.protobuf.Duration`). The name should be in a canonical form - * (e.g., leading "." is not accepted). - * - * In practice, teams usually precompile into the binary all types that they - * expect it to use in the context of Any. However, for URLs which use the - * scheme `http`, `https`, or no scheme, one can optionally set up a type - * server that maps type URLs to message definitions as follows: - * - * * If no scheme is provided, `https` is assumed. - * * An HTTP GET on the URL must yield a google.protobuf.Type - * value in binary format, or produce an error. - * * Applications are allowed to cache lookup results based on the - * URL, or have them precompiled into a binary to avoid any - * lookup. Therefore, binary compatibility needs to be preserved - * on changes to types. (Use versioned type names to manage - * breaking changes.) - * - * Note: this functionality is not currently available in the official - * protobuf release, and it is not used for type URLs beginning with - * type.googleapis.com. - * - * Schemes other than `http`, `https` (or the empty scheme) might be - * used with implementation specific semantics. - * - * @property {Buffer} value - * Must be a valid serialized protocol buffer of the above specified type. - * - * @typedef Any - * @memberof google.protobuf - * @see [google.protobuf.Any definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/any.proto} - */ -const Any = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1/doc/google/protobuf/doc_empty.js b/dev/src/v1/doc/google/protobuf/doc_empty.js deleted file mode 100644 index 78e891398..000000000 --- a/dev/src/v1/doc/google/protobuf/doc_empty.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * A generic empty message that you can re-use to avoid defining duplicated - * empty messages in your APIs. A typical example is to use it as the request - * or the response type of an API method. For instance: - * - * service Foo { - * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); - * } - * - * The JSON representation for `Empty` is empty JSON object `{}`. - * @typedef Empty - * @memberof google.protobuf - * @see [google.protobuf.Empty definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/empty.proto} - */ -const Empty = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1/doc/google/protobuf/doc_field_mask.js b/dev/src/v1/doc/google/protobuf/doc_field_mask.js deleted file mode 100644 index 96717ecba..000000000 --- a/dev/src/v1/doc/google/protobuf/doc_field_mask.js +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * `FieldMask` represents a set of symbolic field paths, for example: - * - * paths: "f.a" - * paths: "f.b.d" - * - * Here `f` represents a field in some root message, `a` and `b` - * fields in the message found in `f`, and `d` a field found in the - * message in `f.b`. - * - * Field masks are used to specify a subset of fields that should be - * returned by a get operation or modified by an update operation. - * Field masks also have a custom JSON encoding (see below). - * - * # Field Masks in Projections - * - * When used in the context of a projection, a response message or - * sub-message is filtered by the API to only contain those fields as - * specified in the mask. For example, if the mask in the previous - * example is applied to a response message as follows: - * - * f { - * a : 22 - * b { - * d : 1 - * x : 2 - * } - * y : 13 - * } - * z: 8 - * - * The result will not contain specific values for fields x,y and z - * (their value will be set to the default, and omitted in proto text - * output): - * - * - * f { - * a : 22 - * b { - * d : 1 - * } - * } - * - * A repeated field is not allowed except at the last position of a - * paths string. - * - * If a FieldMask object is not present in a get operation, the - * operation applies to all fields (as if a FieldMask of all fields - * had been specified). - * - * Note that a field mask does not necessarily apply to the - * top-level response message. In case of a REST get operation, the - * field mask applies directly to the response, but in case of a REST - * list operation, the mask instead applies to each individual message - * in the returned resource list. In case of a REST custom method, - * other definitions may be used. Where the mask applies will be - * clearly documented together with its declaration in the API. In - * any case, the effect on the returned resource/resources is required - * behavior for APIs. - * - * # Field Masks in Update Operations - * - * A field mask in update operations specifies which fields of the - * targeted resource are going to be updated. The API is required - * to only change the values of the fields as specified in the mask - * and leave the others untouched. If a resource is passed in to - * describe the updated values, the API ignores the values of all - * fields not covered by the mask. - * - * If a repeated field is specified for an update operation, new values will - * be appended to the existing repeated field in the target resource. Note that - * a repeated field is only allowed in the last position of a `paths` string. - * - * If a sub-message is specified in the last position of the field mask for an - * update operation, then new value will be merged into the existing sub-message - * in the target resource. - * - * For example, given the target message: - * - * f { - * b { - * d: 1 - * x: 2 - * } - * c: [1] - * } - * - * And an update message: - * - * f { - * b { - * d: 10 - * } - * c: [2] - * } - * - * then if the field mask is: - * - * paths: ["f.b", "f.c"] - * - * then the result will be: - * - * f { - * b { - * d: 10 - * x: 2 - * } - * c: [1, 2] - * } - * - * An implementation may provide options to override this default behavior for - * repeated and message fields. - * - * In order to reset a field's value to the default, the field must - * be in the mask and set to the default value in the provided resource. - * Hence, in order to reset all fields of a resource, provide a default - * instance of the resource and set all fields in the mask, or do - * not provide a mask as described below. - * - * If a field mask is not present on update, the operation applies to - * all fields (as if a field mask of all fields has been specified). - * Note that in the presence of schema evolution, this may mean that - * fields the client does not know and has therefore not filled into - * the request will be reset to their default. If this is unwanted - * behavior, a specific service may require a client to always specify - * a field mask, producing an error if not. - * - * As with get operations, the location of the resource which - * describes the updated values in the request message depends on the - * operation kind. In any case, the effect of the field mask is - * required to be honored by the API. - * - * ## Considerations for HTTP REST - * - * The HTTP kind of an update operation which uses a field mask must - * be set to PATCH instead of PUT in order to satisfy HTTP semantics - * (PUT must only be used for full updates). - * - * # JSON Encoding of Field Masks - * - * In JSON, a field mask is encoded as a single string where paths are - * separated by a comma. Fields name in each path are converted - * to/from lower-camel naming conventions. - * - * As an example, consider the following message declarations: - * - * message Profile { - * User user = 1; - * Photo photo = 2; - * } - * message User { - * string display_name = 1; - * string address = 2; - * } - * - * In proto a field mask for `Profile` may look as such: - * - * mask { - * paths: "user.display_name" - * paths: "photo" - * } - * - * In JSON, the same mask is represented as below: - * - * { - * mask: "user.displayName,photo" - * } - * - * # Field Masks and Oneof Fields - * - * Field masks treat fields in oneofs just as regular fields. Consider the - * following message: - * - * message SampleMessage { - * oneof test_oneof { - * string name = 4; - * SubMessage sub_message = 9; - * } - * } - * - * The field mask can be: - * - * mask { - * paths: "name" - * } - * - * Or: - * - * mask { - * paths: "sub_message" - * } - * - * Note that oneof type names ("test_oneof" in this case) cannot be used in - * paths. - * - * ## Field Mask Verification - * - * The implementation of any API method which has a FieldMask type field in the - * request should verify the included field paths, and return an - * `INVALID_ARGUMENT` error if any path is duplicated or unmappable. - * - * @property {string[]} paths - * The set of field mask paths. - * - * @typedef FieldMask - * @memberof google.protobuf - * @see [google.protobuf.FieldMask definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/field_mask.proto} - */ -const FieldMask = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1/doc/google/protobuf/doc_timestamp.js b/dev/src/v1/doc/google/protobuf/doc_timestamp.js deleted file mode 100644 index e14d06caa..000000000 --- a/dev/src/v1/doc/google/protobuf/doc_timestamp.js +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * A Timestamp represents a point in time independent of any time zone or local - * calendar, encoded as a count of seconds and fractions of seconds at - * nanosecond resolution. The count is relative to an epoch at UTC midnight on - * January 1, 1970, in the proleptic Gregorian calendar which extends the - * Gregorian calendar backwards to year one. - * - * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap - * second table is needed for interpretation, using a [24-hour linear - * smear](https://developers.google.com/time/smear). - * - * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By - * restricting to that range, we ensure that we can convert to and from [RFC - * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. - * - * # Examples - * - * Example 1: Compute Timestamp from POSIX `time()`. - * - * Timestamp timestamp; - * timestamp.set_seconds(time(NULL)); - * timestamp.set_nanos(0); - * - * Example 2: Compute Timestamp from POSIX `gettimeofday()`. - * - * struct timeval tv; - * gettimeofday(&tv, NULL); - * - * Timestamp timestamp; - * timestamp.set_seconds(tv.tv_sec); - * timestamp.set_nanos(tv.tv_usec * 1000); - * - * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. - * - * FILETIME ft; - * GetSystemTimeAsFileTime(&ft); - * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; - * - * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z - * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. - * Timestamp timestamp; - * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); - * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); - * - * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. - * - * long millis = System.currentTimeMillis(); - * - * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) - * .setNanos((int) ((millis % 1000) * 1000000)).build(); - * - * - * Example 5: Compute Timestamp from current time in Python. - * - * timestamp = Timestamp() - * timestamp.GetCurrentTime() - * - * # JSON Mapping - * - * In JSON format, the Timestamp type is encoded as a string in the - * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the - * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" - * where {year} is always expressed using four digits while {month}, {day}, - * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional - * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), - * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone - * is required. A proto3 JSON serializer should always use UTC (as indicated by - * "Z") when printing the Timestamp type and a proto3 JSON parser should be - * able to accept both UTC and other timezones (as indicated by an offset). - * - * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past - * 01:30 UTC on January 15, 2017. - * - * In JavaScript, one can convert a Date object to this format using the - * standard - * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) - * method. In Python, a standard `datetime.datetime` object can be converted - * to this format using - * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with - * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use - * the Joda Time's [`ISODateTimeFormat.dateTime()`](https://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D) to obtain a formatter capable of generating timestamps in this format. - * - * @property {number} seconds - * Represents seconds of UTC time since Unix epoch - * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to - * 9999-12-31T23:59:59Z inclusive. - * - * @property {number} nanos - * Non-negative fractions of a second at nanosecond resolution. Negative - * second values with fractions must still have non-negative nanos values - * that count forward in time. Must be from 0 to 999,999,999 - * inclusive. - * - * @typedef Timestamp - * @memberof google.protobuf - * @see [google.protobuf.Timestamp definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto} - */ -const Timestamp = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1/doc/google/protobuf/doc_wrappers.js b/dev/src/v1/doc/google/protobuf/doc_wrappers.js deleted file mode 100644 index cf790ddc4..000000000 --- a/dev/src/v1/doc/google/protobuf/doc_wrappers.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * Wrapper message for `int32`. - * - * The JSON representation for `Int32Value` is JSON number. - * - * @property {number} value - * The int32 value. - * - * @typedef Int32Value - * @memberof google.protobuf - * @see [google.protobuf.Int32Value definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/wrappers.proto} - */ -const Int32Value = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1/doc/google/rpc/doc_status.js b/dev/src/v1/doc/google/rpc/doc_status.js deleted file mode 100644 index 77a6840e3..000000000 --- a/dev/src/v1/doc/google/rpc/doc_status.js +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * The `Status` type defines a logical error model that is suitable for - * different programming environments, including REST APIs and RPC APIs. It is - * used by [gRPC](https://github.com/grpc). The error model is designed to be: - * - * - Simple to use and understand for most users - * - Flexible enough to meet unexpected needs - * - * # Overview - * - * The `Status` message contains three pieces of data: error code, error - * message, and error details. The error code should be an enum value of - * google.rpc.Code, but it may accept additional error codes - * if needed. The error message should be a developer-facing English message - * that helps developers *understand* and *resolve* the error. If a localized - * user-facing error message is needed, put the localized message in the error - * details or localize it in the client. The optional error details may contain - * arbitrary information about the error. There is a predefined set of error - * detail types in the package `google.rpc` that can be used for common error - * conditions. - * - * # Language mapping - * - * The `Status` message is the logical representation of the error model, but it - * is not necessarily the actual wire format. When the `Status` message is - * exposed in different client libraries and different wire protocols, it can be - * mapped differently. For example, it will likely be mapped to some exceptions - * in Java, but more likely mapped to some error codes in C. - * - * # Other uses - * - * The error model and the `Status` message can be used in a variety of - * environments, either with or without APIs, to provide a - * consistent developer experience across different environments. - * - * Example uses of this error model include: - * - * - Partial errors. If a service needs to return partial errors to the client, - * it may embed the `Status` in the normal response to indicate the partial - * errors. - * - * - Workflow errors. A typical workflow has multiple steps. Each step may - * have a `Status` message for error reporting. - * - * - Batch operations. If a client uses batch request and batch response, the - * `Status` message should be used directly inside batch response, one for - * each error sub-response. - * - * - Asynchronous operations. If an API call embeds asynchronous operation - * results in its response, the status of those operations should be - * represented directly using the `Status` message. - * - * - Logging. If some API errors are stored in logs, the message `Status` could - * be used directly after any stripping needed for security/privacy reasons. - * - * @property {number} code - * The status code, which should be an enum value of - * google.rpc.Code. - * - * @property {string} message - * A developer-facing error message, which should be in English. Any - * user-facing error message should be localized and sent in the - * google.rpc.Status.details field, or localized - * by the client. - * - * @property {Object[]} details - * A list of messages that carry the error details. There is a common set of - * message types for APIs to use. - * - * This object should have the same structure as [Any]{@link google.protobuf.Any} - * - * @typedef Status - * @memberof google.rpc - * @see [google.rpc.Status definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto} - */ -const Status = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1/firestore_admin_client.js b/dev/src/v1/firestore_admin_client.js deleted file mode 100644 index b88029f9d..000000000 --- a/dev/src/v1/firestore_admin_client.js +++ /dev/null @@ -1,1249 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -'use strict'; - -const gapicConfig = require('./firestore_admin_client_config.json'); -const gax = require('google-gax'); -const path = require('path'); - -const VERSION = require('../../../package.json').version; - -/** - * Operations are created by service `FirestoreAdmin`, but are accessed via - * service `google.longrunning.Operations`. - * - * @class - * @memberof v1 - */ -class FirestoreAdminClient { - /** - * Construct an instance of FirestoreAdminClient. - * - * @param {object} [options] - The configuration object. See the subsequent - * parameters for more details. - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {function} [options.promise] - Custom promise module to use instead - * of native Promises. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - */ - constructor(opts) { - opts = opts || {}; - this._descriptors = {}; - - if (global.isBrowser) { - // If we're in browser, we use gRPC fallback. - opts.fallback = true; - } - - // If we are in browser, we are already using fallback because of the - // "browser" field in package.json. - // But if we were explicitly requested to use fallback, let's do it now. - const gaxModule = !global.isBrowser && opts.fallback ? gax.fallback : gax; - - const servicePath = - opts.servicePath || opts.apiEndpoint || this.constructor.servicePath; - - // Ensure that options include the service address and port. - opts = Object.assign( - { - clientConfig: {}, - port: this.constructor.port, - servicePath, - }, - opts - ); - - // Create a `gaxGrpc` object, with any grpc-specific options - // sent to the client. - opts.scopes = this.constructor.scopes; - const gaxGrpc = new gaxModule.GrpcClient(opts); - - // Save the auth object to the client, for use by other methods. - this.auth = gaxGrpc.auth; - - // Determine the client header string. - const clientHeader = []; - - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } - clientHeader.push(`gax/${gaxModule.version}`); - if (opts.fallback) { - clientHeader.push(`gl-web/${gaxModule.version}`); - } else { - clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); - } - clientHeader.push(`gapic/${VERSION}`); - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - - // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join( - __dirname, - '..', - '..', - 'protos', - 'protos.json' - ); - const protos = gaxGrpc.loadProto( - opts.fallback ? 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 = { - databasePathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/databases/{database}' - ), - fieldPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/databases/{database}/collectionGroups/{collection_id}/fields/{field_id}' - ), - indexPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/databases/{database}/collectionGroups/{collection_id}/indexes/{index_id}' - ), - parentPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/databases/{database}/collectionGroups/{collection_id}' - ), - }; - - // 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 = { - listIndexes: new gaxModule.PageDescriptor( - 'pageToken', - 'nextPageToken', - 'indexes' - ), - listFields: new gaxModule.PageDescriptor( - 'pageToken', - 'nextPageToken', - 'fields' - ), - }; - - // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( - 'google.firestore.admin.v1.FirestoreAdmin', - gapicConfig, - opts.clientConfig, - {'x-goog-api-client': clientHeader.join(' ')} - ); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this._innerApiCalls = {}; - - // Put together the "service stub" for - // google.firestore.admin.v1.FirestoreAdmin. - const firestoreAdminStub = gaxGrpc.createStub( - opts.fallback - ? protos.lookupService('google.firestore.admin.v1.FirestoreAdmin') - : protos.google.firestore.admin.v1.FirestoreAdmin, - opts - ); - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const firestoreAdminStubMethods = [ - 'createIndex', - 'listIndexes', - 'getIndex', - 'deleteIndex', - 'importDocuments', - 'exportDocuments', - 'getField', - 'listFields', - 'updateField', - ]; - for (const methodName of firestoreAdminStubMethods) { - const innerCallPromise = firestoreAdminStub.then( - stub => (...args) => { - return stub[methodName].apply(stub, args); - }, - err => () => { - throw err; - } - ); - this._innerApiCalls[methodName] = gaxModule.createApiCall( - innerCallPromise, - defaults[methodName], - this._descriptors.page[methodName] - ); - } - } - - /** - * The DNS address for this API service. - */ - static get servicePath() { - return 'firestore.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - */ - static get apiEndpoint() { - return 'firestore.googleapis.com'; - } - - /** - * The port for this API service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/datastore', - ]; - } - - /** - * Return the project ID used by this class. - * @param {function(Error, string)} callback - the callback to - * be called with the current project Id. - */ - getProjectId(callback) { - return this.auth.getProjectId(callback); - } - - // ------------------- - // -- Service calls -- - // ------------------- - - /** - * Creates a composite index. This returns a google.longrunning.Operation - * which may be used to track the status of the creation. The metadata for - * the operation will be the type IndexOperationMetadata. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * A parent name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - * @param {Object} request.index - * The composite index to create. - * - * This object should have the same structure as [Index]{@link google.firestore.admin.v1.Index} - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [Operation]{@link google.longrunning.Operation}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Operation]{@link google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreAdminClient({ - * // optional auth parameters. - * }); - * - * const formattedParent = client.parentPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]'); - * const index = {}; - * const request = { - * parent: formattedParent, - * index: index, - * }; - * client.createIndex(request) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - createIndex(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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, - }); - - return this._innerApiCalls.createIndex(request, options, callback); - } - - /** - * Lists composite indexes. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * 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 maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Array, ?Object, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is Array of [Index]{@link google.firestore.admin.v1.Index}. - * - * When autoPaginate: false is specified through options, it contains the result - * in a single response. If the response indicates the next page exists, the third - * parameter is set to be used for the next request object. The fourth parameter keeps - * the raw response object of an object representing [ListIndexesResponse]{@link google.firestore.admin.v1.ListIndexesResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Index]{@link google.firestore.admin.v1.Index}. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [Index]{@link google.firestore.admin.v1.Index} in a single response. - * The second element is the next request object if the response - * indicates the next page exists, or null. The third element is - * an object representing [ListIndexesResponse]{@link google.firestore.admin.v1.ListIndexesResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreAdminClient({ - * // optional auth parameters. - * }); - * - * // Iterate over all elements. - * const formattedParent = client.parentPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]'); - * - * client.listIndexes({parent: formattedParent}) - * .then(responses => { - * const resources = responses[0]; - * for (const resource of resources) { - * // doThingsWith(resource) - * } - * }) - * .catch(err => { - * console.error(err); - * }); - * - * // Or obtain the paged response. - * const formattedParent = client.parentPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]'); - * - * - * const options = {autoPaginate: false}; - * const callback = responses => { - * // The actual resources in a response. - * const resources = responses[0]; - * // The next request if the response shows that there are more responses. - * const nextRequest = responses[1]; - * // The actual response object, if necessary. - * // const rawResponse = responses[2]; - * for (const resource of resources) { - * // doThingsWith(resource); - * } - * if (nextRequest) { - * // Fetch the next page. - * return client.listIndexes(nextRequest, options).then(callback); - * } - * } - * client.listIndexes({parent: formattedParent}, options) - * .then(callback) - * .catch(err => { - * console.error(err); - * }); - */ - listIndexes(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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, - }); - - return this._innerApiCalls.listIndexes(request, options, callback); - } - - /** - * Equivalent to {@link listIndexes}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listIndexes} 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 - * 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 maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @returns {Stream} - * An object stream which emits an object representing [Index]{@link google.firestore.admin.v1.Index} on 'data' event. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreAdminClient({ - * // optional auth parameters. - * }); - * - * const formattedParent = client.parentPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]'); - * client.listIndexesStream({parent: formattedParent}) - * .on('data', element => { - * // doThingsWith(element) - * }).on('error', err => { - * console.log(err); - * }); - */ - listIndexesStream(request, options) { - options = options || {}; - - return this._descriptors.page.listIndexes.createStream( - this._innerApiCalls.listIndexes, - request, - options - ); - } - - /** - * Gets a composite index. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * A name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [Index]{@link google.firestore.admin.v1.Index}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Index]{@link google.firestore.admin.v1.Index}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreAdminClient({ - * // optional auth parameters. - * }); - * - * const formattedName = client.indexPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]', '[INDEX_ID]'); - * client.getIndex({name: formattedName}) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - getIndex(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - name: request.name, - }); - - return this._innerApiCalls.getIndex(request, options, callback); - } - - /** - * Deletes a composite index. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * A name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error)} [callback] - * The function which will be called with the result of the API call. - * @returns {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreAdminClient({ - * // optional auth parameters. - * }); - * - * const formattedName = client.indexPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]', '[INDEX_ID]'); - * client.deleteIndex({name: formattedName}).catch(err => { - * console.error(err); - * }); - */ - deleteIndex(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - name: request.name, - }); - - return this._innerApiCalls.deleteIndex(request, options, callback); - } - - /** - * Imports documents into Google Cloud Firestore. Existing documents with the - * same name are overwritten. The import occurs in the background and its - * progress can be monitored and managed via the Operation resource that is - * created. If an ImportDocuments operation is cancelled, it is possible - * that a subset of the data has already been imported to Cloud Firestore. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Database to import into. Should be of the form: - * `projects/{project_id}/databases/{database_id}`. - * @param {string[]} [request.collectionIds] - * Which collection ids to import. Unspecified means all collections included - * in the import. - * @param {string} [request.inputUriPrefix] - * Location of the exported files. - * This must match the output_uri_prefix of an ExportDocumentsResponse from - * an export that has completed successfully. - * See: - * google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [Operation]{@link google.longrunning.Operation}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Operation]{@link google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreAdminClient({ - * // optional auth parameters. - * }); - * - * const formattedName = client.databasePath('[PROJECT]', '[DATABASE]'); - * client.importDocuments({name: formattedName}) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - importDocuments(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - name: request.name, - }); - - return this._innerApiCalls.importDocuments(request, options, callback); - } - - /** - * Exports a copy of all or a subset of documents from Google Cloud Firestore - * to another storage system, such as Google Cloud Storage. Recent updates to - * documents may not be reflected in the export. The export occurs in the - * background and its progress can be monitored and managed via the - * Operation resource that is created. The output of an export may only be - * used once the associated operation is done. If an export operation is - * cancelled before completion it may leave partial data behind in Google - * Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Database to export. Should be of the form: - * `projects/{project_id}/databases/{database_id}`. - * @param {string[]} [request.collectionIds] - * Which collection ids to export. Unspecified means all collections. - * @param {string} [request.outputUriPrefix] - * The output URI. Currently only supports Google Cloud Storage URIs of the - * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name - * of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional - * Google Cloud Storage namespace path. When - * choosing a name, be sure to consider Google Cloud Storage naming - * guidelines: https://cloud.google.com/storage/docs/naming. - * If the URI is a bucket (without a namespace path), a prefix will be - * generated based on the start time. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [Operation]{@link google.longrunning.Operation}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Operation]{@link google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreAdminClient({ - * // optional auth parameters. - * }); - * - * const formattedName = client.databasePath('[PROJECT]', '[DATABASE]'); - * client.exportDocuments({name: formattedName}) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - exportDocuments(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - name: request.name, - }); - - return this._innerApiCalls.exportDocuments(request, options, callback); - } - - /** - * Gets the metadata and configuration for a Field. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * A name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}` - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [Field]{@link google.firestore.admin.v1.Field}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Field]{@link google.firestore.admin.v1.Field}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreAdminClient({ - * // optional auth parameters. - * }); - * - * const formattedName = client.fieldPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]', '[FIELD_ID]'); - * client.getField({name: formattedName}) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - getField(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - name: request.name, - }); - - return this._innerApiCalls.getField(request, options, callback); - } - - /** - * Lists the field configuration and metadata for this database. - * - * Currently, FirestoreAdmin.ListFields only supports listing fields - * that have been explicitly overridden. To issue this query, call - * FirestoreAdmin.ListFields with the filter set to - * `indexConfig.usesAncestorConfig:false`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * 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, - * FirestoreAdmin.ListFields only supports listing fields - * that have been explicitly overridden. To issue this query, call - * FirestoreAdmin.ListFields with the filter set to - * `indexConfig.usesAncestorConfig:false`. - * @param {number} [request.pageSize] - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Array, ?Object, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is Array of [Field]{@link google.firestore.admin.v1.Field}. - * - * When autoPaginate: false is specified through options, it contains the result - * in a single response. If the response indicates the next page exists, the third - * parameter is set to be used for the next request object. The fourth parameter keeps - * the raw response object of an object representing [ListFieldsResponse]{@link google.firestore.admin.v1.ListFieldsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Field]{@link google.firestore.admin.v1.Field}. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [Field]{@link google.firestore.admin.v1.Field} in a single response. - * The second element is the next request object if the response - * indicates the next page exists, or null. The third element is - * an object representing [ListFieldsResponse]{@link google.firestore.admin.v1.ListFieldsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreAdminClient({ - * // optional auth parameters. - * }); - * - * // Iterate over all elements. - * const formattedParent = client.parentPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]'); - * - * client.listFields({parent: formattedParent}) - * .then(responses => { - * const resources = responses[0]; - * for (const resource of resources) { - * // doThingsWith(resource) - * } - * }) - * .catch(err => { - * console.error(err); - * }); - * - * // Or obtain the paged response. - * const formattedParent = client.parentPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]'); - * - * - * const options = {autoPaginate: false}; - * const callback = responses => { - * // The actual resources in a response. - * const resources = responses[0]; - * // The next request if the response shows that there are more responses. - * const nextRequest = responses[1]; - * // The actual response object, if necessary. - * // const rawResponse = responses[2]; - * for (const resource of resources) { - * // doThingsWith(resource); - * } - * if (nextRequest) { - * // Fetch the next page. - * return client.listFields(nextRequest, options).then(callback); - * } - * } - * client.listFields({parent: formattedParent}, options) - * .then(callback) - * .catch(err => { - * console.error(err); - * }); - */ - listFields(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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, - }); - - return this._innerApiCalls.listFields(request, options, callback); - } - - /** - * Equivalent to {@link listFields}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listFields} 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 - * 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, - * FirestoreAdmin.ListFields only supports listing fields - * that have been explicitly overridden. To issue this query, call - * FirestoreAdmin.ListFields with the filter set to - * `indexConfig.usesAncestorConfig:false`. - * @param {number} [request.pageSize] - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @returns {Stream} - * An object stream which emits an object representing [Field]{@link google.firestore.admin.v1.Field} on 'data' event. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreAdminClient({ - * // optional auth parameters. - * }); - * - * const formattedParent = client.parentPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]'); - * client.listFieldsStream({parent: formattedParent}) - * .on('data', element => { - * // doThingsWith(element) - * }).on('error', err => { - * console.log(err); - * }); - */ - listFieldsStream(request, options) { - options = options || {}; - - return this._descriptors.page.listFields.createStream( - this._innerApiCalls.listFields, - request, - options - ); - } - - /** - * Updates a field configuration. Currently, field updates apply only to - * single field index configuration. However, calls to - * FirestoreAdmin.UpdateField should provide a field mask to avoid - * changing any configuration that the caller isn't aware of. The field mask - * should be specified as: `{ paths: "index_config" }`. - * - * This call returns a google.longrunning.Operation which may be used to - * track the status of the field update. The metadata for - * the operation will be the type FieldOperationMetadata. - * - * To configure the default field settings for the database, use - * the special `Field` with resource name: - * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`. - * - * @param {Object} request - * The request object that will be sent. - * @param {Object} request.field - * The field to be updated. - * - * This object should have the same structure as [Field]{@link google.firestore.admin.v1.Field} - * @param {Object} [request.updateMask] - * A mask, relative to the field. If specified, only configuration specified - * by this field_mask will be updated in the field. - * - * This object should have the same structure as [FieldMask]{@link google.protobuf.FieldMask} - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [Operation]{@link google.longrunning.Operation}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Operation]{@link google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreAdminClient({ - * // optional auth parameters. - * }); - * - * const field = {}; - * client.updateField({field: field}) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - updateField(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - 'field.name': request.field.name, - }); - - return this._innerApiCalls.updateField(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified database resource name string. - * - * @param {String} project - * @param {String} database - * @returns {String} - */ - databasePath(project, database) { - return this._pathTemplates.databasePathTemplate.render({ - project: project, - database: database, - }); - } - - /** - * Return a fully-qualified field resource name string. - * - * @param {String} project - * @param {String} database - * @param {String} collectionId - * @param {String} fieldId - * @returns {String} - */ - fieldPath(project, database, collectionId, fieldId) { - return this._pathTemplates.fieldPathTemplate.render({ - project: project, - database: database, - collection_id: collectionId, - field_id: fieldId, - }); - } - - /** - * Return a fully-qualified index resource name string. - * - * @param {String} project - * @param {String} database - * @param {String} collectionId - * @param {String} indexId - * @returns {String} - */ - indexPath(project, database, collectionId, indexId) { - return this._pathTemplates.indexPathTemplate.render({ - project: project, - database: database, - collection_id: collectionId, - index_id: indexId, - }); - } - - /** - * Return a fully-qualified parent resource name string. - * - * @param {String} project - * @param {String} database - * @param {String} collectionId - * @returns {String} - */ - parentPath(project, database, collectionId) { - return this._pathTemplates.parentPathTemplate.render({ - project: project, - database: database, - collection_id: collectionId, - }); - } - - /** - * Parse the databaseName from a database resource. - * - * @param {String} databaseName - * A fully-qualified path representing a database resources. - * @returns {String} - A string representing the project. - */ - matchProjectFromDatabaseName(databaseName) { - return this._pathTemplates.databasePathTemplate.match(databaseName).project; - } - - /** - * Parse the databaseName from a database resource. - * - * @param {String} databaseName - * A fully-qualified path representing a database resources. - * @returns {String} - A string representing the database. - */ - matchDatabaseFromDatabaseName(databaseName) { - return this._pathTemplates.databasePathTemplate.match(databaseName) - .database; - } - - /** - * Parse the fieldName from a field resource. - * - * @param {String} fieldName - * A fully-qualified path representing a field resources. - * @returns {String} - A string representing the project. - */ - matchProjectFromFieldName(fieldName) { - return this._pathTemplates.fieldPathTemplate.match(fieldName).project; - } - - /** - * Parse the fieldName from a field resource. - * - * @param {String} fieldName - * A fully-qualified path representing a field resources. - * @returns {String} - A string representing the database. - */ - matchDatabaseFromFieldName(fieldName) { - return this._pathTemplates.fieldPathTemplate.match(fieldName).database; - } - - /** - * Parse the fieldName from a field resource. - * - * @param {String} fieldName - * A fully-qualified path representing a field resources. - * @returns {String} - A string representing the collection_id. - */ - matchCollectionIdFromFieldName(fieldName) { - return this._pathTemplates.fieldPathTemplate.match(fieldName).collection_id; - } - - /** - * Parse the fieldName from a field resource. - * - * @param {String} fieldName - * A fully-qualified path representing a field resources. - * @returns {String} - A string representing the field_id. - */ - matchFieldIdFromFieldName(fieldName) { - return this._pathTemplates.fieldPathTemplate.match(fieldName).field_id; - } - - /** - * Parse the indexName from a index resource. - * - * @param {String} indexName - * A fully-qualified path representing a index resources. - * @returns {String} - A string representing the project. - */ - matchProjectFromIndexName(indexName) { - return this._pathTemplates.indexPathTemplate.match(indexName).project; - } - - /** - * Parse the indexName from a index resource. - * - * @param {String} indexName - * A fully-qualified path representing a index resources. - * @returns {String} - A string representing the database. - */ - matchDatabaseFromIndexName(indexName) { - return this._pathTemplates.indexPathTemplate.match(indexName).database; - } - - /** - * Parse the indexName from a index resource. - * - * @param {String} indexName - * A fully-qualified path representing a index resources. - * @returns {String} - A string representing the collection_id. - */ - matchCollectionIdFromIndexName(indexName) { - return this._pathTemplates.indexPathTemplate.match(indexName).collection_id; - } - - /** - * Parse the indexName from a index resource. - * - * @param {String} indexName - * A fully-qualified path representing a index resources. - * @returns {String} - A string representing the index_id. - */ - matchIndexIdFromIndexName(indexName) { - return this._pathTemplates.indexPathTemplate.match(indexName).index_id; - } - - /** - * Parse the parentName from a parent resource. - * - * @param {String} parentName - * A fully-qualified path representing a parent resources. - * @returns {String} - A string representing the project. - */ - matchProjectFromParentName(parentName) { - return this._pathTemplates.parentPathTemplate.match(parentName).project; - } - - /** - * Parse the parentName from a parent resource. - * - * @param {String} parentName - * A fully-qualified path representing a parent resources. - * @returns {String} - A string representing the database. - */ - matchDatabaseFromParentName(parentName) { - return this._pathTemplates.parentPathTemplate.match(parentName).database; - } - - /** - * Parse the parentName from a parent resource. - * - * @param {String} parentName - * A fully-qualified path representing a parent resources. - * @returns {String} - A string representing the collection_id. - */ - matchCollectionIdFromParentName(parentName) { - return this._pathTemplates.parentPathTemplate.match(parentName) - .collection_id; - } -} - -module.exports = FirestoreAdminClient; diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts new file mode 100644 index 000000000..ba1680b26 --- /dev/null +++ b/dev/src/v1/firestore_admin_client.ts @@ -0,0 +1,1505 @@ +// Copyright 2019 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as gax from 'google-gax'; +import { + APICallback, + Callback, + CallOptions, + ClientOptions, + Descriptors, + LROperation, + PaginationCallback, + PaginationResponse, +} from 'google-gax'; +import * as path from 'path'; + +import {Transform} from 'stream'; +import * as protosTypes from '../../protos/firestore_admin_v1_proto_api'; +import * as gapicConfig from './firestore_admin_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Operations are created by service `FirestoreAdmin`, but are accessed via + * service `google.longrunning.Operations`. + * @class + * @memberof v1 + */ +export class FirestoreAdminClient { + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _innerApiCalls: {[name: string]: Function}; + private _pathTemplates: {[name: string]: gax.PathTemplate}; + private _terminated = false; + auth: gax.GoogleAuth; + operationsClient: gax.OperationsClient; + firestoreAdminStub: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of FirestoreAdminClient. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof FirestoreAdminClient; + const servicePath = + opts && opts.servicePath + ? opts.servicePath + : opts && opts.apiEndpoint + ? opts.apiEndpoint + : staticMembers.servicePath; + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + 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. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof FirestoreAdminClient).scopes; + const gaxGrpc = new gaxModule.GrpcClient(opts); + + // Save the auth object to the client, for use by other methods. + this.auth = gaxGrpc.auth as gax.GoogleAuth; + + // Determine the client header string. + const clientHeader = [`gax/${gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join( + __dirname, + '..', + '..', + 'protos', + 'protos.json' + ); + const protos = gaxGrpc.loadProto( + opts.fallback ? 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 = { + collectionGroupPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/databases/{database}/collectionGroups/{collection}' + ), + indexPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}' + ), + fieldPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}' + ), + databasePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/databases/{database}' + ), + }; + + // 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 = { + listIndexes: new gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'indexes' + ), + listFields: new gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'fields' + ), + }; + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const protoFilesRoot = opts.fallback + ? gaxModule.protobuf.Root.fromJSON(require('../../protos/protos.json')) + : gaxModule.protobuf.loadSync(nodejsProtoPath); + + this.operationsClient = gaxModule + .lro({ + auth: this.auth, + grpc: 'grpc' in gaxGrpc ? gaxGrpc.grpc : undefined, + }) + .operationsClient(opts); + const createIndexResponse = protoFilesRoot.lookup( + '.google.firestore.admin.v1.Index' + ) as gax.protobuf.Type; + const createIndexMetadata = protoFilesRoot.lookup( + '.google.firestore.admin.v1.IndexOperationMetadata' + ) as gax.protobuf.Type; + const updateFieldResponse = protoFilesRoot.lookup( + '.google.firestore.admin.v1.Field' + ) as gax.protobuf.Type; + const updateFieldMetadata = protoFilesRoot.lookup( + '.google.firestore.admin.v1.FieldOperationMetadata' + ) as gax.protobuf.Type; + const exportDocumentsResponse = protoFilesRoot.lookup( + '.google.firestore.admin.v1.ExportDocumentsResponse' + ) as gax.protobuf.Type; + const exportDocumentsMetadata = protoFilesRoot.lookup( + '.google.firestore.admin.v1.ExportDocumentsMetadata' + ) as gax.protobuf.Type; + const importDocumentsResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty' + ) as gax.protobuf.Type; + const importDocumentsMetadata = protoFilesRoot.lookup( + '.google.firestore.admin.v1.ImportDocumentsMetadata' + ) as gax.protobuf.Type; + + this._descriptors.longrunning = { + createIndex: new gaxModule.LongrunningDescriptor( + this.operationsClient, + createIndexResponse.decode.bind(createIndexResponse), + createIndexMetadata.decode.bind(createIndexMetadata) + ), + updateField: new gaxModule.LongrunningDescriptor( + this.operationsClient, + updateFieldResponse.decode.bind(updateFieldResponse), + updateFieldMetadata.decode.bind(updateFieldMetadata) + ), + exportDocuments: new gaxModule.LongrunningDescriptor( + this.operationsClient, + exportDocumentsResponse.decode.bind(exportDocumentsResponse), + exportDocumentsMetadata.decode.bind(exportDocumentsMetadata) + ), + importDocuments: new gaxModule.LongrunningDescriptor( + this.operationsClient, + importDocumentsResponse.decode.bind(importDocumentsResponse), + importDocumentsMetadata.decode.bind(importDocumentsMetadata) + ), + }; + + // Put together the default options sent with requests. + const defaults = gaxGrpc.constructSettings( + 'google.firestore.admin.v1.FirestoreAdmin', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')} + ); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + + // Put together the "service stub" for + // google.firestore.admin.v1.FirestoreAdmin. + this.firestoreAdminStub = gaxGrpc.createStub( + opts.fallback + ? (protos as protobuf.Root).lookupService( + 'google.firestore.admin.v1.FirestoreAdmin' + ) + : // tslint:disable-next-line no-any + (protos as any).google.firestore.admin.v1.FirestoreAdmin, + opts + ) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const firestoreAdminStubMethods = [ + 'createIndex', + 'listIndexes', + 'getIndex', + 'deleteIndex', + 'getField', + 'updateField', + 'listFields', + 'exportDocuments', + 'importDocuments', + ]; + + for (const methodName of firestoreAdminStubMethods) { + const innerCallPromise = this.firestoreAdminStub.then( + stub => (...args: Array<{}>) => { + return stub[methodName].apply(stub, args); + }, + (err: Error | null | undefined) => () => { + throw err; + } + ); + + const apiCall = gaxModule.createApiCall( + innerCallPromise, + defaults[methodName], + this._descriptors.page[methodName] || + this._descriptors.stream[methodName] || + this._descriptors.longrunning[methodName] + ); + + this._innerApiCalls[methodName] = ( + argument: {}, + callOptions?: CallOptions, + callback?: APICallback + ) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return apiCall(argument, callOptions, callback); + }; + } + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'firestore.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'firestore.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/datastore', + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId( + callback?: Callback + ): Promise | void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + 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; + /** + * Gets a composite index. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` + * @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 [Index]{@link google.firestore.admin.v1.Index}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getIndex( + request: protosTypes.google.firestore.admin.v1.IGetIndexRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.admin.v1.IIndex, + protosTypes.google.firestore.admin.v1.IGetIndexRequest | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.firestore.admin.v1.IIndex, + protosTypes.google.firestore.admin.v1.IGetIndexRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.firestore.admin.v1.IIndex, + protosTypes.google.firestore.admin.v1.IGetIndexRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + return this._innerApiCalls.getIndex(request, options, callback); + } + 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; + /** + * Deletes a composite index. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` + * @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 [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteIndex( + request: protosTypes.google.firestore.admin.v1.IDeleteIndexRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.admin.v1.IDeleteIndexRequest | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.admin.v1.IDeleteIndexRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.admin.v1.IDeleteIndexRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + return this._innerApiCalls.deleteIndex(request, options, callback); + } + 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; + /** + * Gets the metadata and configuration for a Field. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}` + * @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 [Field]{@link google.firestore.admin.v1.Field}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getField( + request: protosTypes.google.firestore.admin.v1.IGetFieldRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.admin.v1.IField, + protosTypes.google.firestore.admin.v1.IGetFieldRequest | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.firestore.admin.v1.IField, + protosTypes.google.firestore.admin.v1.IGetFieldRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.firestore.admin.v1.IField, + protosTypes.google.firestore.admin.v1.IGetFieldRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + return this._innerApiCalls.getField(request, options, callback); + } + + 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; + /** + * Creates a composite index. This returns a [google.longrunning.Operation][google.longrunning.Operation] + * which may be used to track the status of the creation. The metadata for + * the operation will be the type [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata]. + * + * @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 {google.firestore.admin.v1.Index} request.index + * Required. The composite index to create. + * @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 [Operation]{@link google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createIndex( + request: protosTypes.google.firestore.admin.v1.ICreateIndexRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + LROperation< + protosTypes.google.firestore.admin.v1.IIndex, + protosTypes.google.firestore.admin.v1.IIndexOperationMetadata + >, + protosTypes.google.longrunning.IOperation | undefined, + {} | undefined + >, + callback?: Callback< + LROperation< + protosTypes.google.firestore.admin.v1.IIndex, + protosTypes.google.firestore.admin.v1.IIndexOperationMetadata + >, + protosTypes.google.longrunning.IOperation | undefined, + {} | undefined + > + ): Promise< + [ + LROperation< + protosTypes.google.firestore.admin.v1.IIndex, + protosTypes.google.firestore.admin.v1.IIndexOperationMetadata + >, + protosTypes.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.createIndex(request, options, callback); + } + 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; + /** + * Updates a field configuration. Currently, field updates apply only to + * single field index configuration. However, calls to + * [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField] should provide a field mask to avoid + * changing any configuration that the caller isn't aware of. The field mask + * should be specified as: `{ paths: "index_config" }`. + * + * This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may be used to + * track the status of the field update. The metadata for + * the operation will be the type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata]. + * + * To configure the default field settings for the database, use + * the special `Field` with resource name: + * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.firestore.admin.v1.Field} request.field + * Required. The field to be updated. + * @param {google.protobuf.FieldMask} request.updateMask + * A mask, relative to the field. If specified, only configuration specified + * by this field_mask will be updated in the field. + * @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 [Operation]{@link google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateField( + request: protosTypes.google.firestore.admin.v1.IUpdateFieldRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + LROperation< + protosTypes.google.firestore.admin.v1.IField, + protosTypes.google.firestore.admin.v1.IFieldOperationMetadata + >, + protosTypes.google.longrunning.IOperation | undefined, + {} | undefined + >, + callback?: Callback< + LROperation< + protosTypes.google.firestore.admin.v1.IField, + protosTypes.google.firestore.admin.v1.IFieldOperationMetadata + >, + protosTypes.google.longrunning.IOperation | undefined, + {} | undefined + > + ): Promise< + [ + LROperation< + protosTypes.google.firestore.admin.v1.IField, + protosTypes.google.firestore.admin.v1.IFieldOperationMetadata + >, + protosTypes.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + field_name: request.field!.name || '', + }); + return this._innerApiCalls.updateField(request, options, callback); + } + 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; + /** + * Exports a copy of all or a subset of documents from Google Cloud Firestore + * to another storage system, such as Google Cloud Storage. Recent updates to + * documents may not be reflected in the export. The export occurs in the + * background and its progress can be monitored and managed via the + * Operation resource that is created. The output of an export may only be + * used once the associated operation is done. If an export operation is + * cancelled before completion it may leave partial data behind in Google + * Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Database to export. Should be of the form: + * `projects/{project_id}/databases/{database_id}`. + * @param {string[]} request.collectionIds + * Which collection ids to export. Unspecified means all collections. + * @param {string} request.outputUriPrefix + * The output URI. Currently only supports Google Cloud Storage URIs of the + * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name + * of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional + * Google Cloud Storage namespace path. When + * choosing a name, be sure to consider Google Cloud Storage naming + * guidelines: https://cloud.google.com/storage/docs/naming. + * If the URI is a bucket (without a namespace path), a prefix will be + * generated based on the start time. + * @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 [Operation]{@link google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + exportDocuments( + request: protosTypes.google.firestore.admin.v1.IExportDocumentsRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + LROperation< + protosTypes.google.firestore.admin.v1.IExportDocumentsResponse, + protosTypes.google.firestore.admin.v1.IExportDocumentsMetadata + >, + protosTypes.google.longrunning.IOperation | undefined, + {} | undefined + >, + callback?: Callback< + LROperation< + protosTypes.google.firestore.admin.v1.IExportDocumentsResponse, + protosTypes.google.firestore.admin.v1.IExportDocumentsMetadata + >, + protosTypes.google.longrunning.IOperation | undefined, + {} | undefined + > + ): Promise< + [ + LROperation< + protosTypes.google.firestore.admin.v1.IExportDocumentsResponse, + protosTypes.google.firestore.admin.v1.IExportDocumentsMetadata + >, + protosTypes.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + return this._innerApiCalls.exportDocuments(request, options, callback); + } + 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; + /** + * Imports documents into Google Cloud Firestore. Existing documents with the + * same name are overwritten. The import occurs in the background and its + * progress can be monitored and managed via the Operation resource that is + * created. If an ImportDocuments operation is cancelled, it is possible + * that a subset of the data has already been imported to Cloud Firestore. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Database to import into. Should be of the form: + * `projects/{project_id}/databases/{database_id}`. + * @param {string[]} request.collectionIds + * Which collection ids to import. Unspecified means all collections included + * in the import. + * @param {string} request.inputUriPrefix + * Location of the exported files. + * This must match the output_uri_prefix of an ExportDocumentsResponse from + * an export that has completed successfully. + * See: + * [google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix]. + * @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 [Operation]{@link google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + importDocuments( + request: protosTypes.google.firestore.admin.v1.IImportDocumentsRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + LROperation< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.admin.v1.IImportDocumentsMetadata + >, + protosTypes.google.longrunning.IOperation | undefined, + {} | undefined + >, + callback?: Callback< + LROperation< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.admin.v1.IImportDocumentsMetadata + >, + protosTypes.google.longrunning.IOperation | undefined, + {} | undefined + > + ): Promise< + [ + LROperation< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.admin.v1.IImportDocumentsMetadata + >, + protosTypes.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + return this._innerApiCalls.importDocuments(request, options, callback); + } + 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; + /** + * Lists composite indexes. + * + * @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 + * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.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 {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Index]{@link google.firestore.admin.v1.Index}. + * 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 [Index]{@link google.firestore.admin.v1.Index} 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 [ListIndexesRequest]{@link google.firestore.admin.v1.ListIndexesRequest} + * 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 + * [ListIndexesResponse]{@link google.firestore.admin.v1.ListIndexesResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listIndexes( + request: protosTypes.google.firestore.admin.v1.IListIndexesRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.admin.v1.IIndex[], + protosTypes.google.firestore.admin.v1.IListIndexesRequest | null, + protosTypes.google.firestore.admin.v1.IListIndexesResponse + >, + callback?: Callback< + protosTypes.google.firestore.admin.v1.IIndex[], + protosTypes.google.firestore.admin.v1.IListIndexesRequest | null, + protosTypes.google.firestore.admin.v1.IListIndexesResponse + > + ): Promise< + [ + protosTypes.google.firestore.admin.v1.IIndex[], + protosTypes.google.firestore.admin.v1.IListIndexesRequest | null, + protosTypes.google.firestore.admin.v1.IListIndexesResponse + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listIndexes(request, options, callback); + } + + /** + * Equivalent to {@link listIndexes}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listIndexes} 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. 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 + * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.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 {Stream} + * An object stream which emits an object representing [Index]{@link google.firestore.admin.v1.Index} on 'data' event. + */ + listIndexesStream( + request?: protosTypes.google.firestore.admin.v1.IListIndexesRequest, + options?: gax.CallOptions | {} + ): Transform { + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listIndexes.createStream( + this._innerApiCalls.listIndexes as gax.GaxCall, + request, + callSettings + ); + } + 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; + /** + * Lists the field configuration and metadata for this database. + * + * Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields + * that have been explicitly overridden. To issue this query, call + * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the filter set to + * `indexConfig.usesAncestorConfig:false`. + * + * @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, + * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields + * that have been explicitly overridden. To issue this query, call + * [FirestoreAdmin.ListFields][google.firestore.admin.v1.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 + * [FirestoreAdmin.ListFields][google.firestore.admin.v1.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 {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Field]{@link google.firestore.admin.v1.Field}. + * 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 [Field]{@link google.firestore.admin.v1.Field} 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 [ListFieldsRequest]{@link google.firestore.admin.v1.ListFieldsRequest} + * 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 + * [ListFieldsResponse]{@link google.firestore.admin.v1.ListFieldsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listFields( + request: protosTypes.google.firestore.admin.v1.IListFieldsRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.admin.v1.IField[], + protosTypes.google.firestore.admin.v1.IListFieldsRequest | null, + protosTypes.google.firestore.admin.v1.IListFieldsResponse + >, + callback?: Callback< + protosTypes.google.firestore.admin.v1.IField[], + protosTypes.google.firestore.admin.v1.IListFieldsRequest | null, + protosTypes.google.firestore.admin.v1.IListFieldsResponse + > + ): Promise< + [ + protosTypes.google.firestore.admin.v1.IField[], + protosTypes.google.firestore.admin.v1.IListFieldsRequest | null, + protosTypes.google.firestore.admin.v1.IListFieldsResponse + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listFields(request, options, callback); + } + + /** + * Equivalent to {@link listFields}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listFields} 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. 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, + * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields + * that have been explicitly overridden. To issue this query, call + * [FirestoreAdmin.ListFields][google.firestore.admin.v1.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 + * [FirestoreAdmin.ListFields][google.firestore.admin.v1.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 {Stream} + * An object stream which emits an object representing [Field]{@link google.firestore.admin.v1.Field} on 'data' event. + */ + listFieldsStream( + request?: protosTypes.google.firestore.admin.v1.IListFieldsRequest, + options?: gax.CallOptions | {} + ): Transform { + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listFields.createStream( + this._innerApiCalls.listFields as gax.GaxCall, + request, + callSettings + ); + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified collectiongroup resource name string. + * + * @param {string} project + * @param {string} database + * @param {string} collection + * @returns {string} Resource name string. + */ + collectiongroupPath(project: string, database: string, collection: string) { + return this._pathTemplates.collectiongroupPathTemplate.render({ + project, + database, + collection, + }); + } + + /** + * Parse the project from CollectionGroup resource. + * + * @param {string} collectiongroupName + * A fully-qualified path representing CollectionGroup resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCollectionGroupName(collectiongroupName: string) { + return this._pathTemplates.collectiongroupPathTemplate.match( + collectiongroupName + ).project; + } + + /** + * Parse the database from CollectionGroup resource. + * + * @param {string} collectiongroupName + * A fully-qualified path representing CollectionGroup resource. + * @returns {string} A string representing the database. + */ + matchDatabaseFromCollectionGroupName(collectiongroupName: string) { + return this._pathTemplates.collectiongroupPathTemplate.match( + collectiongroupName + ).database; + } + + /** + * Parse the collection from CollectionGroup resource. + * + * @param {string} collectiongroupName + * A fully-qualified path representing CollectionGroup resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromCollectionGroupName(collectiongroupName: string) { + return this._pathTemplates.collectiongroupPathTemplate.match( + collectiongroupName + ).collection; + } + + /** + * Return a fully-qualified index resource name string. + * + * @param {string} project + * @param {string} database + * @param {string} collection + * @param {string} index + * @returns {string} Resource name string. + */ + indexPath( + project: string, + database: string, + collection: string, + index: string + ) { + return this._pathTemplates.indexPathTemplate.render({ + project, + database, + collection, + index, + }); + } + + /** + * Parse the project from Index resource. + * + * @param {string} indexName + * A fully-qualified path representing Index resource. + * @returns {string} A string representing the project. + */ + matchProjectFromIndexName(indexName: string) { + return this._pathTemplates.indexPathTemplate.match(indexName).project; + } + + /** + * Parse the database from Index resource. + * + * @param {string} indexName + * A fully-qualified path representing Index resource. + * @returns {string} A string representing the database. + */ + matchDatabaseFromIndexName(indexName: string) { + return this._pathTemplates.indexPathTemplate.match(indexName).database; + } + + /** + * Parse the collection from Index resource. + * + * @param {string} indexName + * A fully-qualified path representing Index resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromIndexName(indexName: string) { + return this._pathTemplates.indexPathTemplate.match(indexName).collection; + } + + /** + * Parse the index from Index resource. + * + * @param {string} indexName + * A fully-qualified path representing Index resource. + * @returns {string} A string representing the index. + */ + matchIndexFromIndexName(indexName: string) { + return this._pathTemplates.indexPathTemplate.match(indexName).index; + } + + /** + * Return a fully-qualified field resource name string. + * + * @param {string} project + * @param {string} database + * @param {string} collection + * @param {string} field + * @returns {string} Resource name string. + */ + fieldPath( + project: string, + database: string, + collection: string, + field: string + ) { + return this._pathTemplates.fieldPathTemplate.render({ + project, + database, + collection, + field, + }); + } + + /** + * Parse the project from Field resource. + * + * @param {string} fieldName + * A fully-qualified path representing Field resource. + * @returns {string} A string representing the project. + */ + matchProjectFromFieldName(fieldName: string) { + return this._pathTemplates.fieldPathTemplate.match(fieldName).project; + } + + /** + * Parse the database from Field resource. + * + * @param {string} fieldName + * A fully-qualified path representing Field resource. + * @returns {string} A string representing the database. + */ + matchDatabaseFromFieldName(fieldName: string) { + return this._pathTemplates.fieldPathTemplate.match(fieldName).database; + } + + /** + * Parse the collection from Field resource. + * + * @param {string} fieldName + * A fully-qualified path representing Field resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromFieldName(fieldName: string) { + return this._pathTemplates.fieldPathTemplate.match(fieldName).collection; + } + + /** + * Parse the field from Field resource. + * + * @param {string} fieldName + * A fully-qualified path representing Field resource. + * @returns {string} A string representing the field. + */ + matchFieldFromFieldName(fieldName: string) { + return this._pathTemplates.fieldPathTemplate.match(fieldName).field; + } + + /** + * Return a fully-qualified database resource name string. + * + * @param {string} project + * @param {string} database + * @returns {string} Resource name string. + */ + databasePath(project: string, database: string) { + return this._pathTemplates.databasePathTemplate.render({ + project, + database, + }); + } + + /** + * Parse the project from Database resource. + * + * @param {string} databaseName + * A fully-qualified path representing Database resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDatabaseName(databaseName: string) { + return this._pathTemplates.databasePathTemplate.match(databaseName).project; + } + + /** + * Parse the database from Database resource. + * + * @param {string} databaseName + * A fully-qualified path representing Database resource. + * @returns {string} A string representing the database. + */ + matchDatabaseFromDatabaseName(databaseName: string) { + return this._pathTemplates.databasePathTemplate.match(databaseName) + .database; + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + if (!this._terminated) { + return this.firestoreAdminStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/dev/src/v1/firestore_admin_client_config.json b/dev/src/v1/firestore_admin_client_config.json index 638d47867..918ef86d9 100644 --- a/dev/src/v1/firestore_admin_client_config.json +++ b/dev/src/v1/firestore_admin_client_config.json @@ -2,21 +2,25 @@ "interfaces": { "google.firestore.admin.v1.FirestoreAdmin": { "retry_codes": { + "non_idempotent": [], "idempotent": [ "DEADLINE_EXCEEDED", - "INTERNAL", "UNAVAILABLE" ], - "non_idempotent": [] + "deadline_exceeded_internal_unavailable": [ + "DEADLINE_EXCEEDED", + "INTERNAL", + "UNAVAILABLE" + ] }, "retry_params": { "default": { "initial_retry_delay_millis": 100, "retry_delay_multiplier": 1.3, "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 60000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 20000, "total_timeout_millis": 600000 } }, @@ -28,40 +32,40 @@ }, "ListIndexes": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, "GetIndex": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, "DeleteIndex": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, - "ImportDocuments": { + "GetField": { "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, - "ExportDocuments": { + "UpdateField": { "timeout_millis": 60000, "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, - "GetField": { + "ListFields": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, - "ListFields": { + "ExportDocuments": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, - "UpdateField": { + "ImportDocuments": { "timeout_millis": 60000, "retry_codes_name": "non_idempotent", "retry_params_name": "default" diff --git a/dev/src/v1/firestore_admin_proto_list.json b/dev/src/v1/firestore_admin_proto_list.json index 323b6637c..f6060527c 100644 --- a/dev/src/v1/firestore_admin_proto_list.json +++ b/dev/src/v1/firestore_admin_proto_list.json @@ -1,3 +1,7 @@ [ - "../../protos/google/firestore/admin/v1/firestore_admin.proto" + "../../protos/google/firestore/admin/v1/index.proto", + "../../protos/google/firestore/admin/v1/field.proto", + "../../protos/google/firestore/admin/v1/firestore_admin.proto", + "../../protos/google/firestore/admin/v1/operation.proto", + "../../protos/google/firestore/admin/v1/location.proto" ] diff --git a/dev/src/v1/firestore_client.js b/dev/src/v1/firestore_client.js deleted file mode 100644 index e3ee2630c..000000000 --- a/dev/src/v1/firestore_client.js +++ /dev/null @@ -1,1544 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -'use strict'; - -const gapicConfig = require('./firestore_client_config.json'); -const gax = require('google-gax'); -const path = require('path'); - -const VERSION = require('../../../package.json').version; - -/** - * The Cloud Firestore service. - * - * This service exposes several types of comparable timestamps: - * - * * `create_time` - The time at which a document was created. Changes only - * when a document is deleted, then re-created. Increases in a strict - * monotonic fashion. - * * `update_time` - The time at which a document was last updated. Changes - * every time a document is modified. Does not change when a write results - * in no modifications. Increases in a strict monotonic fashion. - * * `read_time` - The time at which a particular state was observed. Used - * to denote a consistent snapshot of the database or the time at which a - * Document was observed to not exist. - * * `commit_time` - The time at which the writes in a transaction were - * committed. Any read with an equal or greater `read_time` is guaranteed - * to see the effects of the transaction. - * - * @class - * @memberof v1 - */ -class FirestoreClient { - /** - * Construct an instance of FirestoreClient. - * - * @param {object} [options] - The configuration object. See the subsequent - * parameters for more details. - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {function} [options.promise] - Custom promise module to use instead - * of native Promises. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - */ - constructor(opts) { - opts = opts || {}; - this._descriptors = {}; - - if (global.isBrowser) { - // If we're in browser, we use gRPC fallback. - opts.fallback = true; - } - - // If we are in browser, we are already using fallback because of the - // "browser" field in package.json. - // But if we were explicitly requested to use fallback, let's do it now. - const gaxModule = !global.isBrowser && opts.fallback ? gax.fallback : gax; - - const servicePath = - opts.servicePath || opts.apiEndpoint || this.constructor.servicePath; - - // Ensure that options include the service address and port. - opts = Object.assign( - { - clientConfig: {}, - port: this.constructor.port, - servicePath, - }, - opts - ); - - // Create a `gaxGrpc` object, with any grpc-specific options - // sent to the client. - opts.scopes = this.constructor.scopes; - const gaxGrpc = new gaxModule.GrpcClient(opts); - - // Save the auth object to the client, for use by other methods. - this.auth = gaxGrpc.auth; - - // Determine the client header string. - const clientHeader = []; - - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } - clientHeader.push(`gax/${gaxModule.version}`); - if (opts.fallback) { - clientHeader.push(`gl-web/${gaxModule.version}`); - } else { - clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); - } - clientHeader.push(`gapic/${VERSION}`); - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - - // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join( - __dirname, - '..', - '..', - 'protos', - 'protos.json' - ); - const protos = gaxGrpc.loadProto( - opts.fallback ? 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 = { - anyPathPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/databases/{database}/documents/{document}/{any_path=**}' - ), - databaseRootPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/databases/{database}' - ), - documentPathPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/databases/{database}/documents/{document_path=**}' - ), - documentRootPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/databases/{database}/documents' - ), - }; - - // 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 = { - listDocuments: new gaxModule.PageDescriptor( - 'pageToken', - 'nextPageToken', - 'documents' - ), - listCollectionIds: new gaxModule.PageDescriptor( - 'pageToken', - 'nextPageToken', - 'collectionIds' - ), - }; - - // Some of the methods on this service provide streaming responses. - // Provide descriptors for these. - this._descriptors.stream = { - batchGetDocuments: new gaxModule.StreamDescriptor( - gax.StreamType.SERVER_STREAMING - ), - runQuery: new gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING), - write: new gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING), - listen: new gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING), - }; - - // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( - 'google.firestore.v1.Firestore', - gapicConfig, - opts.clientConfig, - {'x-goog-api-client': clientHeader.join(' ')} - ); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this._innerApiCalls = {}; - - // Put together the "service stub" for - // google.firestore.v1.Firestore. - const firestoreStub = gaxGrpc.createStub( - opts.fallback - ? protos.lookupService('google.firestore.v1.Firestore') - : protos.google.firestore.v1.Firestore, - opts - ); - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const firestoreStubMethods = [ - 'getDocument', - 'listDocuments', - 'createDocument', - 'updateDocument', - 'deleteDocument', - 'batchGetDocuments', - 'beginTransaction', - 'commit', - 'rollback', - 'runQuery', - 'write', - 'listen', - 'listCollectionIds', - ]; - for (const methodName of firestoreStubMethods) { - const innerCallPromise = firestoreStub.then( - stub => (...args) => { - return stub[methodName].apply(stub, args); - }, - err => () => { - throw err; - } - ); - this._innerApiCalls[methodName] = gaxModule.createApiCall( - innerCallPromise, - defaults[methodName], - this._descriptors.page[methodName] || - this._descriptors.stream[methodName] - ); - } - } - - /** - * The DNS address for this API service. - */ - static get servicePath() { - return 'firestore.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - */ - static get apiEndpoint() { - return 'firestore.googleapis.com'; - } - - /** - * The port for this API service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/datastore', - ]; - } - - /** - * Return the project ID used by this class. - * @param {function(Error, string)} callback - the callback to - * be called with the current project Id. - */ - getProjectId(callback) { - return this.auth.getProjectId(callback); - } - - // ------------------- - // -- Service calls -- - // ------------------- - - /** - * Gets a single document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource name of the Document to get. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * @param {Object} [request.mask] - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1.DocumentMask} - * @param {Buffer} [request.transaction] - * Reads the document in a transaction. - * @param {Object} [request.readTime] - * Reads the version of the document at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [Document]{@link google.firestore.v1.Document}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Document]{@link google.firestore.v1.Document}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedName = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * client.getDocument({name: formattedName}) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - getDocument(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - name: request.name, - }); - - return this._innerApiCalls.getDocument(request, options, callback); - } - - /** - * Lists documents. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * 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 - * The collection ID, relative to `parent`, to list. For example: `chatrooms` - * or `messages`. - * @param {number} [request.pageSize] - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {string} [request.orderBy] - * The order to sort results by. For example: `priority desc, name`. - * @param {Object} [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. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1.DocumentMask} - * @param {Buffer} [request.transaction] - * Reads documents in a transaction. - * @param {Object} [request.readTime] - * Reads documents as they were at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * @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, Document.create_time, - * or Document.update_time set. - * - * Requests with `show_missing` may not specify `where` or - * `order_by`. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Array, ?Object, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is Array of [Document]{@link google.firestore.v1.Document}. - * - * When autoPaginate: false is specified through options, it contains the result - * in a single response. If the response indicates the next page exists, the third - * parameter is set to be used for the next request object. The fourth parameter keeps - * the raw response object of an object representing [ListDocumentsResponse]{@link google.firestore.v1.ListDocumentsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Document]{@link google.firestore.v1.Document}. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [Document]{@link google.firestore.v1.Document} in a single response. - * The second element is the next request object if the response - * indicates the next page exists, or null. The third element is - * an object representing [ListDocumentsResponse]{@link google.firestore.v1.ListDocumentsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * // Iterate over all elements. - * const formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * const collectionId = ''; - * const request = { - * parent: formattedParent, - * collectionId: collectionId, - * }; - * - * client.listDocuments(request) - * .then(responses => { - * const resources = responses[0]; - * for (const resource of resources) { - * // doThingsWith(resource) - * } - * }) - * .catch(err => { - * console.error(err); - * }); - * - * // Or obtain the paged response. - * const formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * const collectionId = ''; - * const request = { - * parent: formattedParent, - * collectionId: collectionId, - * }; - * - * - * const options = {autoPaginate: false}; - * const callback = responses => { - * // The actual resources in a response. - * const resources = responses[0]; - * // The next request if the response shows that there are more responses. - * const nextRequest = responses[1]; - * // The actual response object, if necessary. - * // const rawResponse = responses[2]; - * for (const resource of resources) { - * // doThingsWith(resource); - * } - * if (nextRequest) { - * // Fetch the next page. - * return client.listDocuments(nextRequest, options).then(callback); - * } - * } - * client.listDocuments(request, options) - * .then(callback) - * .catch(err => { - * console.error(err); - * }); - */ - listDocuments(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - options = {}; - } - request = request || {}; - options = options || {}; - - return this._innerApiCalls.listDocuments(request, options, callback); - } - - /** - * Equivalent to {@link listDocuments}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listDocuments} 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 - * 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 - * The collection ID, relative to `parent`, to list. For example: `chatrooms` - * or `messages`. - * @param {number} [request.pageSize] - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {string} [request.orderBy] - * The order to sort results by. For example: `priority desc, name`. - * @param {Object} [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. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1.DocumentMask} - * @param {Buffer} [request.transaction] - * Reads documents in a transaction. - * @param {Object} [request.readTime] - * Reads documents as they were at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * @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, Document.create_time, - * or Document.update_time set. - * - * Requests with `show_missing` may not specify `where` or - * `order_by`. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @returns {Stream} - * An object stream which emits an object representing [Document]{@link google.firestore.v1.Document} on 'data' event. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * const collectionId = ''; - * const request = { - * parent: formattedParent, - * collectionId: collectionId, - * }; - * client.listDocumentsStream(request) - * .on('data', element => { - * // doThingsWith(element) - * }).on('error', err => { - * console.log(err); - * }); - */ - listDocumentsStream(request, options) { - options = options || {}; - - return this._descriptors.page.listDocuments.createStream( - this._innerApiCalls.listDocuments, - request, - options - ); - } - - /** - * Creates a new document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The parent resource. For example: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` - * @param {string} request.collectionId - * The collection ID, relative to `parent`, to list. For example: `chatrooms`. - * @param {string} request.documentId - * The client-assigned document ID to use for this document. - * - * Optional. If not specified, an ID will be assigned by the service. - * @param {Object} request.document - * The document to create. `name` must not be set. - * - * This object should have the same structure as [Document]{@link google.firestore.v1.Document} - * @param {Object} [request.mask] - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1.DocumentMask} - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [Document]{@link google.firestore.v1.Document}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Document]{@link google.firestore.v1.Document}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * const collectionId = ''; - * const documentId = ''; - * const document = {}; - * const request = { - * parent: formattedParent, - * collectionId: collectionId, - * documentId: documentId, - * document: document, - * }; - * client.createDocument(request) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - createDocument(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - options = {}; - } - request = request || {}; - options = options || {}; - - return this._innerApiCalls.createDocument(request, options, callback); - } - - /** - * Updates or inserts a document. - * - * @param {Object} request - * The request object that will be sent. - * @param {Object} request.document - * The updated document. - * Creates the document if it does not already exist. - * - * This object should have the same structure as [Document]{@link google.firestore.v1.Document} - * @param {Object} request.updateMask - * The fields to update. - * None of the field paths in the mask may contain a reserved name. - * - * If the document exists on the server and has fields not referenced in the - * mask, they are left unchanged. - * Fields referenced in the mask, but not present in the input document, are - * deleted from the document on the server. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1.DocumentMask} - * @param {Object} [request.mask] - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1.DocumentMask} - * @param {Object} [request.currentDocument] - * An optional precondition on the document. - * The request will fail if this is set and not met by the target document. - * - * This object should have the same structure as [Precondition]{@link google.firestore.v1.Precondition} - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [Document]{@link google.firestore.v1.Document}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Document]{@link google.firestore.v1.Document}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const document = {}; - * const updateMask = {}; - * const request = { - * document: document, - * updateMask: updateMask, - * }; - * client.updateDocument(request) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - updateDocument(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - 'document.name': request.document.name, - }); - - return this._innerApiCalls.updateDocument(request, options, callback); - } - - /** - * Deletes a document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource name of the Document to delete. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * @param {Object} [request.currentDocument] - * An optional precondition on the document. - * The request will fail if this is set and not met by the target document. - * - * This object should have the same structure as [Precondition]{@link google.firestore.v1.Precondition} - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error)} [callback] - * The function which will be called with the result of the API call. - * @returns {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedName = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * client.deleteDocument({name: formattedName}).catch(err => { - * console.error(err); - * }); - */ - deleteDocument(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - name: request.name, - }); - - return this._innerApiCalls.deleteDocument(request, options, callback); - } - - /** - * Gets multiple documents. - * - * Documents returned by this method are not guaranteed to be returned in the - * same order that they were requested. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {string[]} request.documents - * The names of the documents to retrieve. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * The request will fail if any of the document is not a child resource of the - * given `database`. Duplicate names will be elided. - * @param {Object} [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. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1.DocumentMask} - * @param {Buffer} [request.transaction] - * Reads documents in a transaction. - * @param {Object} [request.newTransaction] - * Starts a new transaction and reads the documents. - * Defaults to a read-only transaction. - * The new transaction ID will be returned as the first response in the - * stream. - * - * This object should have the same structure as [TransactionOptions]{@link google.firestore.v1.TransactionOptions} - * @param {Object} [request.readTime] - * Reads documents as they were at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @returns {Stream} - * An object stream which emits [BatchGetDocumentsResponse]{@link google.firestore.v1.BatchGetDocumentsResponse} on 'data' event. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); - * const documents = []; - * const request = { - * database: formattedDatabase, - * documents: documents, - * }; - * client.batchGetDocuments(request).on('data', response => { - * // doThingsWith(response) - * }); - */ - batchGetDocuments(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({ - database: request.database, - }); - - return this._innerApiCalls.batchGetDocuments(request, options); - } - - /** - * Starts a new transaction. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {Object} [request.options] - * The options for the transaction. - * Defaults to a read-write transaction. - * - * This object should have the same structure as [TransactionOptions]{@link google.firestore.v1.TransactionOptions} - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [BeginTransactionResponse]{@link google.firestore.v1.BeginTransactionResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BeginTransactionResponse]{@link google.firestore.v1.BeginTransactionResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); - * client.beginTransaction({database: formattedDatabase}) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - beginTransaction(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - database: request.database, - }); - - return this._innerApiCalls.beginTransaction(request, options, callback); - } - - /** - * Commits a transaction, while optionally updating documents. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {Object[]} request.writes - * The writes to apply. - * - * Always executed atomically and in order. - * - * This object should have the same structure as [Write]{@link google.firestore.v1.Write} - * @param {Buffer} [request.transaction] - * If set, applies all writes in this transaction, and commits it. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [CommitResponse]{@link google.firestore.v1.CommitResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CommitResponse]{@link google.firestore.v1.CommitResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); - * const writes = []; - * const request = { - * database: formattedDatabase, - * writes: writes, - * }; - * client.commit(request) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - commit(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - database: request.database, - }); - - return this._innerApiCalls.commit(request, options, callback); - } - - /** - * Rolls back a transaction. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {Buffer} request.transaction - * The transaction to roll back. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error)} [callback] - * The function which will be called with the result of the API call. - * @returns {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); - * const transaction = Buffer.from(''); - * const request = { - * database: formattedDatabase, - * transaction: transaction, - * }; - * client.rollback(request).catch(err => { - * console.error(err); - * }); - */ - rollback(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - database: request.database, - }); - - return this._innerApiCalls.rollback(request, options, callback); - } - - /** - * Runs a query. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * 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 {Object} [request.structuredQuery] - * A structured query. - * - * This object should have the same structure as [StructuredQuery]{@link google.firestore.v1.StructuredQuery} - * @param {Buffer} [request.transaction] - * Reads documents in a transaction. - * @param {Object} [request.newTransaction] - * Starts a new transaction and reads the documents. - * Defaults to a read-only transaction. - * The new transaction ID will be returned as the first response in the - * stream. - * - * This object should have the same structure as [TransactionOptions]{@link google.firestore.v1.TransactionOptions} - * @param {Object} [request.readTime] - * Reads documents as they were at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @returns {Stream} - * An object stream which emits [RunQueryResponse]{@link google.firestore.v1.RunQueryResponse} on 'data' event. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * client.runQuery({parent: formattedParent}).on('data', response => { - * // doThingsWith(response) - * }); - */ - runQuery(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, - }); - - return this._innerApiCalls.runQuery(request, options); - } - - /** - * Streams batches of document updates and deletes, in order. - * - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @returns {Stream} - * An object stream which is both readable and writable. It accepts objects - * representing [WriteRequest]{@link google.firestore.v1.WriteRequest} for write() method, and - * will emit objects representing [WriteResponse]{@link google.firestore.v1.WriteResponse} on 'data' event asynchronously. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const stream = client.write().on('data', response => { - * // doThingsWith(response) - * }); - * const formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); - * const request = { - * database: formattedDatabase, - * }; - * // Write request objects. - * stream.write(request); - */ - write(options) { - options = options || {}; - - return this._innerApiCalls.write(options); - } - - /** - * Listens to changes. - * - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @returns {Stream} - * An object stream which is both readable and writable. It accepts objects - * representing [ListenRequest]{@link google.firestore.v1.ListenRequest} for write() method, and - * will emit objects representing [ListenResponse]{@link google.firestore.v1.ListenResponse} on 'data' event asynchronously. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const stream = client.listen().on('data', response => { - * // doThingsWith(response) - * }); - * const formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); - * const request = { - * database: formattedDatabase, - * }; - * // Write request objects. - * stream.write(request); - */ - listen(options) { - options = options || {}; - - return this._innerApiCalls.listen({}, options); - } - - /** - * Lists all the collection IDs underneath a document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * 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 resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Array, ?Object, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is Array of string. - * - * When autoPaginate: false is specified through options, it contains the result - * in a single response. If the response indicates the next page exists, the third - * parameter is set to be used for the next request object. The fourth parameter keeps - * the raw response object of an object representing [ListCollectionIdsResponse]{@link google.firestore.v1.ListCollectionIdsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of string. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of string in a single response. - * The second element is the next request object if the response - * indicates the next page exists, or null. The third element is - * an object representing [ListCollectionIdsResponse]{@link google.firestore.v1.ListCollectionIdsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * // Iterate over all elements. - * const formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * - * client.listCollectionIds({parent: formattedParent}) - * .then(responses => { - * const resources = responses[0]; - * for (const resource of resources) { - * // doThingsWith(resource) - * } - * }) - * .catch(err => { - * console.error(err); - * }); - * - * // Or obtain the paged response. - * const formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * - * - * const options = {autoPaginate: false}; - * const callback = responses => { - * // The actual resources in a response. - * const resources = responses[0]; - * // The next request if the response shows that there are more responses. - * const nextRequest = responses[1]; - * // The actual response object, if necessary. - * // const rawResponse = responses[2]; - * for (const resource of resources) { - * // doThingsWith(resource); - * } - * if (nextRequest) { - * // Fetch the next page. - * return client.listCollectionIds(nextRequest, options).then(callback); - * } - * } - * client.listCollectionIds({parent: formattedParent}, options) - * .then(callback) - * .catch(err => { - * console.error(err); - * }); - */ - listCollectionIds(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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, - }); - - return this._innerApiCalls.listCollectionIds(request, options, callback); - } - - /** - * Equivalent to {@link listCollectionIds}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listCollectionIds} 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 - * 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 resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @returns {Stream} - * An object stream which emits a string on 'data' event. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * client.listCollectionIdsStream({parent: formattedParent}) - * .on('data', element => { - * // doThingsWith(element) - * }).on('error', err => { - * console.log(err); - * }); - */ - listCollectionIdsStream(request, options) { - options = options || {}; - - return this._descriptors.page.listCollectionIds.createStream( - this._innerApiCalls.listCollectionIds, - request, - options - ); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified any_path resource name string. - * - * @param {String} project - * @param {String} database - * @param {String} document - * @param {String} anyPath - * @returns {String} - */ - anyPathPath(project, database, document, anyPath) { - return this._pathTemplates.anyPathPathTemplate.render({ - project: project, - database: database, - document: document, - any_path: anyPath, - }); - } - - /** - * Return a fully-qualified database_root resource name string. - * - * @param {String} project - * @param {String} database - * @returns {String} - */ - databaseRootPath(project, database) { - return this._pathTemplates.databaseRootPathTemplate.render({ - project: project, - database: database, - }); - } - - /** - * Return a fully-qualified document_path resource name string. - * - * @param {String} project - * @param {String} database - * @param {String} documentPath - * @returns {String} - */ - documentPathPath(project, database, documentPath) { - return this._pathTemplates.documentPathPathTemplate.render({ - project: project, - database: database, - document_path: documentPath, - }); - } - - /** - * Return a fully-qualified document_root resource name string. - * - * @param {String} project - * @param {String} database - * @returns {String} - */ - documentRootPath(project, database) { - return this._pathTemplates.documentRootPathTemplate.render({ - project: project, - database: database, - }); - } - - /** - * Parse the anyPathName from a any_path resource. - * - * @param {String} anyPathName - * A fully-qualified path representing a any_path resources. - * @returns {String} - A string representing the project. - */ - matchProjectFromAnyPathName(anyPathName) { - return this._pathTemplates.anyPathPathTemplate.match(anyPathName).project; - } - - /** - * Parse the anyPathName from a any_path resource. - * - * @param {String} anyPathName - * A fully-qualified path representing a any_path resources. - * @returns {String} - A string representing the database. - */ - matchDatabaseFromAnyPathName(anyPathName) { - return this._pathTemplates.anyPathPathTemplate.match(anyPathName).database; - } - - /** - * Parse the anyPathName from a any_path resource. - * - * @param {String} anyPathName - * A fully-qualified path representing a any_path resources. - * @returns {String} - A string representing the document. - */ - matchDocumentFromAnyPathName(anyPathName) { - return this._pathTemplates.anyPathPathTemplate.match(anyPathName).document; - } - - /** - * Parse the anyPathName from a any_path resource. - * - * @param {String} anyPathName - * A fully-qualified path representing a any_path resources. - * @returns {String} - A string representing the any_path. - */ - matchAnyPathFromAnyPathName(anyPathName) { - return this._pathTemplates.anyPathPathTemplate.match(anyPathName).any_path; - } - - /** - * Parse the databaseRootName from a database_root resource. - * - * @param {String} databaseRootName - * A fully-qualified path representing a database_root resources. - * @returns {String} - A string representing the project. - */ - matchProjectFromDatabaseRootName(databaseRootName) { - return this._pathTemplates.databaseRootPathTemplate.match(databaseRootName) - .project; - } - - /** - * Parse the databaseRootName from a database_root resource. - * - * @param {String} databaseRootName - * A fully-qualified path representing a database_root resources. - * @returns {String} - A string representing the database. - */ - matchDatabaseFromDatabaseRootName(databaseRootName) { - return this._pathTemplates.databaseRootPathTemplate.match(databaseRootName) - .database; - } - - /** - * Parse the documentPathName from a document_path resource. - * - * @param {String} documentPathName - * A fully-qualified path representing a document_path resources. - * @returns {String} - A string representing the project. - */ - matchProjectFromDocumentPathName(documentPathName) { - return this._pathTemplates.documentPathPathTemplate.match(documentPathName) - .project; - } - - /** - * Parse the documentPathName from a document_path resource. - * - * @param {String} documentPathName - * A fully-qualified path representing a document_path resources. - * @returns {String} - A string representing the database. - */ - matchDatabaseFromDocumentPathName(documentPathName) { - return this._pathTemplates.documentPathPathTemplate.match(documentPathName) - .database; - } - - /** - * Parse the documentPathName from a document_path resource. - * - * @param {String} documentPathName - * A fully-qualified path representing a document_path resources. - * @returns {String} - A string representing the document_path. - */ - matchDocumentPathFromDocumentPathName(documentPathName) { - return this._pathTemplates.documentPathPathTemplate.match(documentPathName) - .document_path; - } - - /** - * Parse the documentRootName from a document_root resource. - * - * @param {String} documentRootName - * A fully-qualified path representing a document_root resources. - * @returns {String} - A string representing the project. - */ - matchProjectFromDocumentRootName(documentRootName) { - return this._pathTemplates.documentRootPathTemplate.match(documentRootName) - .project; - } - - /** - * Parse the documentRootName from a document_root resource. - * - * @param {String} documentRootName - * A fully-qualified path representing a document_root resources. - * @returns {String} - A string representing the database. - */ - matchDatabaseFromDocumentRootName(documentRootName) { - return this._pathTemplates.documentRootPathTemplate.match(documentRootName) - .database; - } -} - -module.exports = FirestoreClient; diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts new file mode 100644 index 000000000..8bcf8b6ad --- /dev/null +++ b/dev/src/v1/firestore_client.ts @@ -0,0 +1,1312 @@ +// Copyright 2019 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as gax from 'google-gax'; +import { + APICallback, + Callback, + CallOptions, + ClientOptions, + Descriptors, + PaginationCallback, + PaginationResponse, +} from 'google-gax'; +import * as path from 'path'; + +import {Transform} from 'stream'; +import * as protosTypes from '../../protos/firestore_v1_proto_api'; +import * as gapicConfig from './firestore_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * The Cloud Firestore service. + * + * This service exposes several types of comparable timestamps: + * + * * `create_time` - The time at which a document was created. Changes only + * when a document is deleted, then re-created. Increases in a strict + * monotonic fashion. + * * `update_time` - The time at which a document was last updated. Changes + * every time a document is modified. Does not change when a write results + * in no modifications. Increases in a strict monotonic fashion. + * * `read_time` - The time at which a particular state was observed. Used + * to denote a consistent snapshot of the database or the time at which a + * Document was observed to not exist. + * * `commit_time` - The time at which the writes in a transaction were + * committed. Any read with an equal or greater `read_time` is guaranteed + * to see the effects of the transaction. + * @class + * @memberof v1 + */ +export class FirestoreClient { + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _innerApiCalls: {[name: string]: Function}; + private _terminated = false; + auth: gax.GoogleAuth; + firestoreStub: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of FirestoreClient. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof FirestoreClient; + const servicePath = + opts && opts.servicePath + ? opts.servicePath + : opts && opts.apiEndpoint + ? opts.apiEndpoint + : staticMembers.servicePath; + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + 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. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof FirestoreClient).scopes; + const gaxGrpc = new gaxModule.GrpcClient(opts); + + // Save the auth object to the client, for use by other methods. + this.auth = gaxGrpc.auth as gax.GoogleAuth; + + // Determine the client header string. + const clientHeader = [`gax/${gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join( + __dirname, + '..', + '..', + 'protos', + 'protos.json' + ); + const protos = gaxGrpc.loadProto( + opts.fallback ? 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 = { + listDocuments: new gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'documents' + ), + listCollectionIds: new gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'collectionIds' + ), + }; + + // Some of the methods on this service provide streaming responses. + // Provide descriptors for these. + this._descriptors.stream = { + batchGetDocuments: new gaxModule.StreamDescriptor( + gax.StreamType.SERVER_STREAMING + ), + runQuery: new gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING), + write: new gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING), + listen: new gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING), + }; + + // Put together the default options sent with requests. + const defaults = gaxGrpc.constructSettings( + 'google.firestore.v1.Firestore', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')} + ); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + + // Put together the "service stub" for + // google.firestore.v1.Firestore. + this.firestoreStub = gaxGrpc.createStub( + opts.fallback + ? (protos as protobuf.Root).lookupService( + 'google.firestore.v1.Firestore' + ) + : // tslint:disable-next-line no-any + (protos as any).google.firestore.v1.Firestore, + opts + ) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const firestoreStubMethods = [ + 'getDocument', + 'listDocuments', + 'createDocument', + 'updateDocument', + 'deleteDocument', + 'batchGetDocuments', + 'beginTransaction', + 'commit', + 'rollback', + 'runQuery', + 'write', + 'listen', + 'listCollectionIds', + ]; + + for (const methodName of firestoreStubMethods) { + const innerCallPromise = this.firestoreStub.then( + stub => (...args: Array<{}>) => { + return stub[methodName].apply(stub, args); + }, + (err: Error | null | undefined) => () => { + throw err; + } + ); + + const apiCall = gaxModule.createApiCall( + innerCallPromise, + defaults[methodName], + this._descriptors.page[methodName] || + this._descriptors.stream[methodName] || + this._descriptors.longrunning[methodName] + ); + + this._innerApiCalls[methodName] = ( + argument: {}, + callOptions?: CallOptions, + callback?: APICallback + ) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return apiCall(argument, callOptions, callback); + }; + } + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'firestore.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'firestore.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/datastore', + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId( + callback?: Callback + ): Promise | void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + 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; + /** + * Gets a single document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Document to get. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * @param {google.firestore.v1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If the 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 the document in a transaction. + * @param {google.protobuf.Timestamp} request.readTime + * Reads the version of the document at the given time. + * This may not be older than 60 seconds. + * @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 [Document]{@link google.firestore.v1.Document}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getDocument( + request: protosTypes.google.firestore.v1.IGetDocumentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.v1.IDocument, + protosTypes.google.firestore.v1.IGetDocumentRequest | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.firestore.v1.IDocument, + protosTypes.google.firestore.v1.IGetDocumentRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.firestore.v1.IDocument, + protosTypes.google.firestore.v1.IGetDocumentRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + return this._innerApiCalls.getDocument(request, options, callback); + } + 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; + /** + * Creates a new document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. For example: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` + * @param {string} request.collectionId + * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. + * @param {string} request.documentId + * The client-assigned document ID to use for this document. + * + * Optional. If not specified, an ID will be assigned by the service. + * @param {google.firestore.v1.Document} request.document + * Required. The document to create. `name` must not be set. + * @param {google.firestore.v1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + * @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 [Document]{@link google.firestore.v1.Document}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createDocument( + request: protosTypes.google.firestore.v1.ICreateDocumentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.v1.IDocument, + protosTypes.google.firestore.v1.ICreateDocumentRequest | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.firestore.v1.IDocument, + protosTypes.google.firestore.v1.ICreateDocumentRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.firestore.v1.IDocument, + protosTypes.google.firestore.v1.ICreateDocumentRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.createDocument(request, options, callback); + } + 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; + /** + * Updates or inserts a document. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.firestore.v1.Document} request.document + * Required. The updated document. + * Creates the document if it does not already exist. + * @param {google.firestore.v1.DocumentMask} request.updateMask + * The fields to update. + * None of the field paths in the mask may contain a reserved name. + * + * If the document exists on the server and has fields not referenced in the + * mask, they are left unchanged. + * Fields referenced in the mask, but not present in the input document, are + * deleted from the document on the server. + * @param {google.firestore.v1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + * @param {google.firestore.v1.Precondition} request.currentDocument + * An optional precondition on the document. + * The request will fail if this is set and not met by the target document. + * @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 [Document]{@link google.firestore.v1.Document}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateDocument( + request: protosTypes.google.firestore.v1.IUpdateDocumentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.v1.IDocument, + protosTypes.google.firestore.v1.IUpdateDocumentRequest | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.firestore.v1.IDocument, + protosTypes.google.firestore.v1.IUpdateDocumentRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.firestore.v1.IDocument, + protosTypes.google.firestore.v1.IUpdateDocumentRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + document_name: request.document!.name || '', + }); + return this._innerApiCalls.updateDocument(request, options, callback); + } + 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; + /** + * Deletes a document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Document to delete. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * @param {google.firestore.v1.Precondition} request.currentDocument + * An optional precondition on the document. + * The request will fail if this is set and not met by the target document. + * @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 [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteDocument( + request: protosTypes.google.firestore.v1.IDeleteDocumentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.v1.IDeleteDocumentRequest | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.v1.IDeleteDocumentRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.v1.IDeleteDocumentRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + return this._innerApiCalls.deleteDocument(request, options, callback); + } + 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; + /** + * Starts a new transaction. + * + * @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 {google.firestore.v1.TransactionOptions} request.options + * The options for the transaction. + * Defaults to a read-write transaction. + * @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 [BeginTransactionResponse]{@link google.firestore.v1.BeginTransactionResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + beginTransaction( + request: protosTypes.google.firestore.v1.IBeginTransactionRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.v1.IBeginTransactionResponse, + protosTypes.google.firestore.v1.IBeginTransactionRequest | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.firestore.v1.IBeginTransactionResponse, + protosTypes.google.firestore.v1.IBeginTransactionRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.firestore.v1.IBeginTransactionResponse, + protosTypes.google.firestore.v1.IBeginTransactionRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.beginTransaction(request, options, callback); + } + 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; + /** + * Commits a transaction, while optionally updating documents. + * + * @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. + * + * Always executed atomically and in order. + * @param {Buffer} request.transaction + * If set, applies all writes in this transaction, and commits it. + * @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 [CommitResponse]{@link google.firestore.v1.CommitResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + commit( + request: protosTypes.google.firestore.v1.ICommitRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.v1.ICommitResponse, + protosTypes.google.firestore.v1.ICommitRequest | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.firestore.v1.ICommitResponse, + protosTypes.google.firestore.v1.ICommitRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.firestore.v1.ICommitResponse, + protosTypes.google.firestore.v1.ICommitRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.commit(request, options, callback); + } + 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; + /** + * Rolls back a transaction. + * + * @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 {Buffer} request.transaction + * Required. The transaction to roll back. + * @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 [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + rollback( + request: protosTypes.google.firestore.v1.IRollbackRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.v1.IRollbackRequest | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.v1.IRollbackRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.v1.IRollbackRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.rollback(request, options, callback); + } + + /** + * Gets multiple documents. + * + * Documents returned by this method are not guaranteed to be returned in the + * same order that they were requested. + * + * @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 {string[]} request.documents + * The names of the documents to retrieve. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * The request will fail if any of the document is not a child resource of the + * given `database`. Duplicate names will be elided. + * @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.firestore.v1.TransactionOptions} request.newTransaction + * Starts a new transaction and reads the documents. + * Defaults to a read-only transaction. + * The new transaction ID will be returned as the first response in the + * stream. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 60 seconds. + * @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 [BatchGetDocumentsResponse]{@link google.firestore.v1.BatchGetDocumentsResponse} on 'data' event. + */ + batchGetDocuments( + request?: protosTypes.google.firestore.v1.IBatchGetDocumentsRequest, + options?: gax.CallOptions + ): gax.CancellableStream { + request = request || {}; + options = options || {}; + return this._innerApiCalls.batchGetDocuments(request, options); + } + + /** + * Runs a query. + * + * @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 {google.firestore.v1.StructuredQuery} request.structuredQuery + * A structured query. + * @param {Buffer} request.transaction + * Reads documents in a transaction. + * @param {google.firestore.v1.TransactionOptions} request.newTransaction + * Starts a new transaction and reads the documents. + * Defaults to a read-only transaction. + * The new transaction ID will be returned as the first response in the + * stream. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 60 seconds. + * @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 [RunQueryResponse]{@link google.firestore.v1.RunQueryResponse} on 'data' event. + */ + runQuery( + request?: protosTypes.google.firestore.v1.IRunQueryRequest, + options?: gax.CallOptions + ): gax.CancellableStream { + request = request || {}; + options = options || {}; + return this._innerApiCalls.runQuery(request, options); + } + + /** + * Streams batches of document updates and deletes, in order. + * + * @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 is both readable and writable. It accepts objects + * representing [WriteRequest]{@link google.firestore.v1.WriteRequest} for write() method, and + * will emit objects representing [WriteResponse]{@link google.firestore.v1.WriteResponse} on 'data' event asynchronously. + */ + write(options?: gax.CallOptions): gax.CancellableStream { + options = options || {}; + return this._innerApiCalls.write(options); + } + + /** + * Listens to changes. + * + * @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 is both readable and writable. It accepts objects + * representing [ListenRequest]{@link google.firestore.v1.ListenRequest} for write() method, and + * will emit objects representing [ListenResponse]{@link google.firestore.v1.ListenResponse} on 'data' event asynchronously. + */ + listen(options?: gax.CallOptions): gax.CancellableStream { + options = options || {}; + return this._innerApiCalls.listen({}, options); + } + + 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; + /** + * Lists documents. + * + * @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 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, [Document.create_time][google.firestore.v1.Document.create_time], + * or [Document.update_time][google.firestore.v1.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 {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Document]{@link google.firestore.v1.Document}. + * 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 [Document]{@link google.firestore.v1.Document} 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 [ListDocumentsRequest]{@link google.firestore.v1.ListDocumentsRequest} + * 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 + * [ListDocumentsResponse]{@link google.firestore.v1.ListDocumentsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listDocuments( + request: protosTypes.google.firestore.v1.IListDocumentsRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.v1.IDocument[], + protosTypes.google.firestore.v1.IListDocumentsRequest | null, + protosTypes.google.firestore.v1.IListDocumentsResponse + >, + callback?: Callback< + protosTypes.google.firestore.v1.IDocument[], + protosTypes.google.firestore.v1.IListDocumentsRequest | null, + protosTypes.google.firestore.v1.IListDocumentsResponse + > + ): Promise< + [ + protosTypes.google.firestore.v1.IDocument[], + protosTypes.google.firestore.v1.IListDocumentsRequest | null, + protosTypes.google.firestore.v1.IListDocumentsResponse + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listDocuments(request, options, callback); + } + + /** + * Equivalent to {@link listDocuments}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listDocuments} 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` 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 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, [Document.create_time][google.firestore.v1.Document.create_time], + * or [Document.update_time][google.firestore.v1.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 {Stream} + * An object stream which emits an object representing [Document]{@link google.firestore.v1.Document} on 'data' event. + */ + listDocumentsStream( + request?: protosTypes.google.firestore.v1.IListDocumentsRequest, + options?: gax.CallOptions | {} + ): Transform { + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listDocuments.createStream( + this._innerApiCalls.listDocuments as gax.GaxCall, + request, + callSettings + ); + } + 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; + /** + * Lists all the collection IDs underneath a document. + * + * @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 + * [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse]. + * @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 string. + * 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 string 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 [ListCollectionIdsRequest]{@link google.firestore.v1.ListCollectionIdsRequest} + * 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 + * [ListCollectionIdsResponse]{@link google.firestore.v1.ListCollectionIdsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listCollectionIds( + request: protosTypes.google.firestore.v1.IListCollectionIdsRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + string[], + protosTypes.google.firestore.v1.IListCollectionIdsRequest | null, + protosTypes.google.firestore.v1.IListCollectionIdsResponse + >, + callback?: Callback< + string[], + protosTypes.google.firestore.v1.IListCollectionIdsRequest | null, + protosTypes.google.firestore.v1.IListCollectionIdsResponse + > + ): Promise< + [ + string[], + protosTypes.google.firestore.v1.IListCollectionIdsRequest | null, + protosTypes.google.firestore.v1.IListCollectionIdsResponse + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listCollectionIds(request, options, callback); + } + + /** + * Equivalent to {@link listCollectionIds}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listCollectionIds} 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 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 + * [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse]. + * @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 string on 'data' event. + */ + listCollectionIdsStream( + request?: protosTypes.google.firestore.v1.IListCollectionIdsRequest, + options?: gax.CallOptions | {} + ): Transform { + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listCollectionIds.createStream( + this._innerApiCalls.listCollectionIds as gax.GaxCall, + request, + callSettings + ); + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + if (!this._terminated) { + return this.firestoreStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/dev/src/v1/firestore_client_config.json b/dev/src/v1/firestore_client_config.json index 8c44f6186..3930e894a 100644 --- a/dev/src/v1/firestore_client_config.json +++ b/dev/src/v1/firestore_client_config.json @@ -2,42 +2,37 @@ "interfaces": { "google.firestore.v1.Firestore": { "retry_codes": { + "non_idempotent": [], "idempotent": [ "DEADLINE_EXCEEDED", - "INTERNAL", "UNAVAILABLE" ], - "non_idempotent": [] + "deadline_exceeded_internal_unavailable": [ + "DEADLINE_EXCEEDED", + "INTERNAL", + "UNAVAILABLE" + ] }, "retry_params": { "default": { "initial_retry_delay_millis": 100, "retry_delay_multiplier": 1.3, "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "streaming": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 60000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 20000, "total_timeout_millis": 600000 } }, "methods": { "GetDocument": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, "ListDocuments": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, "CreateDocument": { @@ -52,17 +47,17 @@ }, "DeleteDocument": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, "BatchGetDocuments": { "timeout_millis": 300000, - "retry_codes_name": "idempotent", - "retry_params_name": "streaming" + "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_params_name": "default" }, "BeginTransaction": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, "Commit": { @@ -72,27 +67,27 @@ }, "Rollback": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, "RunQuery": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "streaming" + "timeout_millis": 300000, + "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_params_name": "default" }, "Write": { "timeout_millis": 86400000, "retry_codes_name": "non_idempotent", - "retry_params_name": "streaming" + "retry_params_name": "default" }, "Listen": { "timeout_millis": 86400000, - "retry_codes_name": "idempotent", - "retry_params_name": "streaming" + "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_params_name": "default" }, "ListCollectionIds": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" } } diff --git a/dev/src/v1/firestore_proto_list.json b/dev/src/v1/firestore_proto_list.json index eb0560245..5aad32750 100644 --- a/dev/src/v1/firestore_proto_list.json +++ b/dev/src/v1/firestore_proto_list.json @@ -1,3 +1,7 @@ [ + "../../protos/google/firestore/v1/common.proto", + "../../protos/google/firestore/v1/document.proto", + "../../protos/google/firestore/v1/write.proto", + "../../protos/google/firestore/v1/query.proto", "../../protos/google/firestore/v1/firestore.proto" ] diff --git a/dev/src/v1/index.js b/dev/src/v1/index.ts similarity index 63% rename from dev/src/v1/index.js rename to dev/src/v1/index.ts index 3ae193cc0..b6d83aaf9 100644 --- a/dev/src/v1/index.js +++ b/dev/src/v1/index.ts @@ -12,11 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -'use strict'; +import {FirestoreAdminClient} from './firestore_admin_client'; +import {FirestoreClient} from './firestore_client'; -const FirestoreClient = require('./firestore_client'); -const FirestoreAdminClient = require('./firestore_admin_client'); +export {FirestoreClient, FirestoreAdminClient}; -FirestoreClient.FirestoreClient = FirestoreClient; -FirestoreClient.FirestoreAdminClient = FirestoreAdminClient; +// Doing something really horrible for reverse compatibility with original JavaScript exports +const existingExports = module.exports; module.exports = FirestoreClient; +module.exports = Object.assign(module.exports, existingExports); diff --git a/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_common.js b/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_common.js deleted file mode 100644 index 9095ebb89..000000000 --- a/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_common.js +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * A set of field paths on a document. - * Used to restrict a get or update operation on a document to a subset of its - * fields. - * This is different from standard field masks, as this is always scoped to a - * Document, and takes in account the dynamic nature of Value. - * - * @property {string[]} fieldPaths - * The list of field paths in the mask. See Document.fields for a field - * path syntax reference. - * - * @typedef DocumentMask - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.DocumentMask definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/common.proto} - */ -const DocumentMask = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A precondition on a document, used for conditional operations. - * - * @property {boolean} exists - * When set to `true`, the target document must exist. - * When set to `false`, the target document must not exist. - * - * @property {Object} updateTime - * When set, the target document must exist and have been last updated at - * that time. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef Precondition - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.Precondition definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/common.proto} - */ -const Precondition = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * Options for creating a new transaction. - * - * @property {Object} readOnly - * The transaction can only be used for read operations. - * - * This object should have the same structure as [ReadOnly]{@link google.firestore.v1beta1.ReadOnly} - * - * @property {Object} readWrite - * The transaction can be used for both read and write operations. - * - * This object should have the same structure as [ReadWrite]{@link google.firestore.v1beta1.ReadWrite} - * - * @typedef TransactionOptions - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.TransactionOptions definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/common.proto} - */ -const TransactionOptions = { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * Options for a transaction that can be used to read and write documents. - * - * @property {Buffer} retryTransaction - * An optional transaction to retry. - * - * @typedef ReadWrite - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.TransactionOptions.ReadWrite definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/common.proto} - */ - ReadWrite: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, - - /** - * Options for a transaction that can only be used to read documents. - * - * @property {Object} readTime - * Reads documents at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef ReadOnly - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.TransactionOptions.ReadOnly definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/common.proto} - */ - ReadOnly: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, -}; diff --git a/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_document.js b/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_document.js deleted file mode 100644 index eec8a5863..000000000 --- a/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_document.js +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * A Firestore document. - * - * Must not exceed 1 MiB - 4 bytes. - * - * @property {string} name - * The resource name of the document, for example - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * - * @property {Object.} fields - * The document's fields. - * - * The map keys represent field names. - * - * A simple field name contains only characters `a` to `z`, `A` to `Z`, - * `0` to `9`, or `_`, and must not start with `0` to `9`. For example, - * `foo_bar_17`. - * - * Field names matching the regular expression `__.*__` are reserved. Reserved - * field names are forbidden except in certain documented contexts. The map - * keys, represented as UTF-8, must not exceed 1,500 bytes and cannot be - * empty. - * - * Field paths may be used in other contexts to refer to structured fields - * defined here. For `map_value`, the field path is represented by the simple - * or quoted field names of the containing fields, delimited by `.`. For - * example, the structured field - * `"foo" : { map_value: { "x&y" : { string_value: "hello" }}}` would be - * represented by the field path `foo.x&y`. - * - * Within a field path, a quoted field name starts and ends with `` ` `` and - * may contain any character. Some characters, including `` ` ``, must be - * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and - * `` `bak\`tik` `` represents `` bak`tik ``. - * - * @property {Object} createTime - * Output only. The time at which the document was created. - * - * This value increases monotonically when a document is deleted then - * recreated. It can also be compared to values from other documents and - * the `read_time` of a query. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @property {Object} updateTime - * Output only. The time at which the document was last changed. - * - * This value is initially set to the `create_time` then increases - * monotonically with each change to the document. It can also be - * compared to values from other documents and the `read_time` of a query. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef Document - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.Document definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/document.proto} - */ -const Document = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A message that can hold any of the supported value types. - * - * @property {number} nullValue - * A null value. - * - * The number should be among the values of [NullValue]{@link google.protobuf.NullValue} - * - * @property {boolean} booleanValue - * A boolean value. - * - * @property {number} integerValue - * An integer value. - * - * @property {number} doubleValue - * A double value. - * - * @property {Object} timestampValue - * A timestamp value. - * - * Precise only to microseconds. When stored, any additional precision is - * rounded down. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @property {string} stringValue - * A string value. - * - * The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes. - * Only the first 1,500 bytes of the UTF-8 representation are considered by - * queries. - * - * @property {Buffer} bytesValue - * A bytes value. - * - * Must not exceed 1 MiB - 89 bytes. - * Only the first 1,500 bytes are considered by queries. - * - * @property {string} referenceValue - * A reference to a document. For example: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * - * @property {Object} geoPointValue - * A geo point value representing a point on the surface of Earth. - * - * This object should have the same structure as [LatLng]{@link google.type.LatLng} - * - * @property {Object} arrayValue - * An array value. - * - * Cannot directly contain another array value, though can contain an - * map which contains another array. - * - * This object should have the same structure as [ArrayValue]{@link google.firestore.v1beta1.ArrayValue} - * - * @property {Object} mapValue - * A map value. - * - * This object should have the same structure as [MapValue]{@link google.firestore.v1beta1.MapValue} - * - * @typedef Value - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.Value definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/document.proto} - */ -const Value = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * An array value. - * - * @property {Object[]} values - * Values in the array. - * - * This object should have the same structure as [Value]{@link google.firestore.v1beta1.Value} - * - * @typedef ArrayValue - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.ArrayValue definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/document.proto} - */ -const ArrayValue = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A map value. - * - * @property {Object.} fields - * The map's fields. - * - * The map keys represent field names. Field names matching the regular - * expression `__.*__` are reserved. Reserved field names are forbidden except - * in certain documented contexts. The map keys, represented as UTF-8, must - * not exceed 1,500 bytes and cannot be empty. - * - * @typedef MapValue - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.MapValue definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/document.proto} - */ -const MapValue = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_firestore.js b/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_firestore.js deleted file mode 100644 index 83f7c9d3f..000000000 --- a/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_firestore.js +++ /dev/null @@ -1,859 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * The request for Firestore.GetDocument. - * - * @property {string} name - * The resource name of the Document to get. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * - * @property {Object} mask - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1beta1.DocumentMask} - * - * @property {Buffer} transaction - * Reads the document in a transaction. - * - * @property {Object} readTime - * Reads the version of the document at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef GetDocumentRequest - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.GetDocumentRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const GetDocumentRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.ListDocuments. - * - * @property {string} parent - * 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` - * - * @property {string} collectionId - * The collection ID, relative to `parent`, to list. For example: `chatrooms` - * or `messages`. - * - * @property {number} pageSize - * The maximum number of documents to return. - * - * @property {string} pageToken - * The `next_page_token` value returned from a previous List request, if any. - * - * @property {string} orderBy - * The order to sort results by. For example: `priority desc, name`. - * - * @property {Object} 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. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1beta1.DocumentMask} - * - * @property {Buffer} transaction - * Reads documents in a transaction. - * - * @property {Object} readTime - * Reads documents as they were at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @property {boolean} 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, Document.create_time, - * or Document.update_time set. - * - * Requests with `show_missing` may not specify `where` or - * `order_by`. - * - * @typedef ListDocumentsRequest - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.ListDocumentsRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const ListDocumentsRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The response for Firestore.ListDocuments. - * - * @property {Object[]} documents - * The Documents found. - * - * This object should have the same structure as [Document]{@link google.firestore.v1beta1.Document} - * - * @property {string} nextPageToken - * The next page token. - * - * @typedef ListDocumentsResponse - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.ListDocumentsResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const ListDocumentsResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.CreateDocument. - * - * @property {string} parent - * The parent resource. For example: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` - * - * @property {string} collectionId - * The collection ID, relative to `parent`, to list. For example: `chatrooms`. - * - * @property {string} documentId - * The client-assigned document ID to use for this document. - * - * Optional. If not specified, an ID will be assigned by the service. - * - * @property {Object} document - * The document to create. `name` must not be set. - * - * This object should have the same structure as [Document]{@link google.firestore.v1beta1.Document} - * - * @property {Object} mask - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1beta1.DocumentMask} - * - * @typedef CreateDocumentRequest - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.CreateDocumentRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const CreateDocumentRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.UpdateDocument. - * - * @property {Object} document - * The updated document. - * Creates the document if it does not already exist. - * - * This object should have the same structure as [Document]{@link google.firestore.v1beta1.Document} - * - * @property {Object} updateMask - * The fields to update. - * None of the field paths in the mask may contain a reserved name. - * - * If the document exists on the server and has fields not referenced in the - * mask, they are left unchanged. - * Fields referenced in the mask, but not present in the input document, are - * deleted from the document on the server. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1beta1.DocumentMask} - * - * @property {Object} mask - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1beta1.DocumentMask} - * - * @property {Object} currentDocument - * An optional precondition on the document. - * The request will fail if this is set and not met by the target document. - * - * This object should have the same structure as [Precondition]{@link google.firestore.v1beta1.Precondition} - * - * @typedef UpdateDocumentRequest - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.UpdateDocumentRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const UpdateDocumentRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.DeleteDocument. - * - * @property {string} name - * The resource name of the Document to delete. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * - * @property {Object} currentDocument - * An optional precondition on the document. - * The request will fail if this is set and not met by the target document. - * - * This object should have the same structure as [Precondition]{@link google.firestore.v1beta1.Precondition} - * - * @typedef DeleteDocumentRequest - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.DeleteDocumentRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const DeleteDocumentRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.BatchGetDocuments. - * - * @property {string} database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * - * @property {string[]} documents - * The names of the documents to retrieve. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * The request will fail if any of the document is not a child resource of the - * given `database`. Duplicate names will be elided. - * - * @property {Object} 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. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1beta1.DocumentMask} - * - * @property {Buffer} transaction - * Reads documents in a transaction. - * - * @property {Object} newTransaction - * Starts a new transaction and reads the documents. - * Defaults to a read-only transaction. - * The new transaction ID will be returned as the first response in the - * stream. - * - * This object should have the same structure as [TransactionOptions]{@link google.firestore.v1beta1.TransactionOptions} - * - * @property {Object} readTime - * Reads documents as they were at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef BatchGetDocumentsRequest - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.BatchGetDocumentsRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const BatchGetDocumentsRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The streamed response for Firestore.BatchGetDocuments. - * - * @property {Object} found - * A document that was requested. - * - * This object should have the same structure as [Document]{@link google.firestore.v1beta1.Document} - * - * @property {string} missing - * A document name that was requested but does not exist. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * - * @property {Buffer} transaction - * The transaction that was started as part of this request. - * Will only be set in the first response, and only if - * BatchGetDocumentsRequest.new_transaction was set in the request. - * - * @property {Object} readTime - * The time at which the document was read. - * This may be monotically increasing, in this case the previous documents in - * the result stream are guaranteed not to have changed between their - * read_time and this one. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef BatchGetDocumentsResponse - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.BatchGetDocumentsResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const BatchGetDocumentsResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.BeginTransaction. - * - * @property {string} database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * - * @property {Object} options - * The options for the transaction. - * Defaults to a read-write transaction. - * - * This object should have the same structure as [TransactionOptions]{@link google.firestore.v1beta1.TransactionOptions} - * - * @typedef BeginTransactionRequest - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.BeginTransactionRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const BeginTransactionRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The response for Firestore.BeginTransaction. - * - * @property {Buffer} transaction - * The transaction that was started. - * - * @typedef BeginTransactionResponse - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.BeginTransactionResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const BeginTransactionResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.Commit. - * - * @property {string} database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * - * @property {Object[]} writes - * The writes to apply. - * - * Always executed atomically and in order. - * - * This object should have the same structure as [Write]{@link google.firestore.v1beta1.Write} - * - * @property {Buffer} transaction - * If set, applies all writes in this transaction, and commits it. - * - * @typedef CommitRequest - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.CommitRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const CommitRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The response for Firestore.Commit. - * - * @property {Object[]} writeResults - * The result of applying the writes. - * - * This i-th write result corresponds to the i-th write in the - * request. - * - * This object should have the same structure as [WriteResult]{@link google.firestore.v1beta1.WriteResult} - * - * @property {Object} commitTime - * The time at which the commit occurred. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef CommitResponse - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.CommitResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const CommitResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.Rollback. - * - * @property {string} database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * - * @property {Buffer} transaction - * The transaction to roll back. - * - * @typedef RollbackRequest - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.RollbackRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const RollbackRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.RunQuery. - * - * @property {string} parent - * 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` - * - * @property {Object} structuredQuery - * A structured query. - * - * This object should have the same structure as [StructuredQuery]{@link google.firestore.v1beta1.StructuredQuery} - * - * @property {Buffer} transaction - * Reads documents in a transaction. - * - * @property {Object} newTransaction - * Starts a new transaction and reads the documents. - * Defaults to a read-only transaction. - * The new transaction ID will be returned as the first response in the - * stream. - * - * This object should have the same structure as [TransactionOptions]{@link google.firestore.v1beta1.TransactionOptions} - * - * @property {Object} readTime - * Reads documents as they were at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef RunQueryRequest - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.RunQueryRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const RunQueryRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The response for Firestore.RunQuery. - * - * @property {Buffer} transaction - * The transaction that was started as part of this request. - * Can only be set in the first response, and only if - * RunQueryRequest.new_transaction was set in the request. - * If set, no other fields will be set in this response. - * - * @property {Object} document - * A query result. - * Not set when reporting partial progress. - * - * This object should have the same structure as [Document]{@link google.firestore.v1beta1.Document} - * - * @property {Object} readTime - * The time at which the document was read. This may be monotonically - * increasing; in this case, the previous documents in the result stream are - * guaranteed not to have changed between their `read_time` and this one. - * - * If the query returns no results, a response with `read_time` and no - * `document` will be sent, and this represents the time at which the query - * was run. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @property {number} skippedResults - * The number of results that have been skipped due to an offset between - * the last response and the current response. - * - * @typedef RunQueryResponse - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.RunQueryResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const RunQueryResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The request for Firestore.Write. - * - * The first request creates a stream, or resumes an existing one from a token. - * - * When creating a new stream, the server replies with a response containing - * only an ID and a token, to use in the next request. - * - * When resuming a stream, the server first streams any responses later than the - * given token, then a response containing only an up-to-date token, to use in - * the next request. - * - * @property {string} database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * This is only required in the first message. - * - * @property {string} streamId - * The ID of the write stream to resume. - * This may only be set in the first message. When left empty, a new write - * stream will be created. - * - * @property {Object[]} writes - * The writes to apply. - * - * Always executed atomically and in order. - * This must be empty on the first request. - * This may be empty on the last request. - * This must not be empty on all other requests. - * - * This object should have the same structure as [Write]{@link google.firestore.v1beta1.Write} - * - * @property {Buffer} streamToken - * A stream token that was previously sent by the server. - * - * The client should set this field to the token from the most recent - * WriteResponse it has received. This acknowledges that the client has - * received responses up to this token. After sending this token, earlier - * tokens may not be used anymore. - * - * The server may close the stream if there are too many unacknowledged - * responses. - * - * Leave this field unset when creating a new stream. To resume a stream at - * a specific point, set this field and the `stream_id` field. - * - * Leave this field unset when creating a new stream. - * - * @property {Object.} labels - * Labels associated with this write request. - * - * @typedef WriteRequest - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.WriteRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const WriteRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The response for Firestore.Write. - * - * @property {string} streamId - * The ID of the stream. - * Only set on the first message, when a new stream was created. - * - * @property {Buffer} streamToken - * A token that represents the position of this response in the stream. - * This can be used by a client to resume the stream at this point. - * - * This field is always set. - * - * @property {Object[]} writeResults - * The result of applying the writes. - * - * This i-th write result corresponds to the i-th write in the - * request. - * - * This object should have the same structure as [WriteResult]{@link google.firestore.v1beta1.WriteResult} - * - * @property {Object} commitTime - * The time at which the commit occurred. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef WriteResponse - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.WriteResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const WriteResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A request for Firestore.Listen - * - * @property {string} database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * - * @property {Object} addTarget - * A target to add to this stream. - * - * This object should have the same structure as [Target]{@link google.firestore.v1beta1.Target} - * - * @property {number} removeTarget - * The ID of a target to remove from this stream. - * - * @property {Object.} labels - * Labels associated with this target change. - * - * @typedef ListenRequest - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.ListenRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const ListenRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The response for Firestore.Listen. - * - * @property {Object} targetChange - * Targets have changed. - * - * This object should have the same structure as [TargetChange]{@link google.firestore.v1beta1.TargetChange} - * - * @property {Object} documentChange - * A Document has changed. - * - * This object should have the same structure as [DocumentChange]{@link google.firestore.v1beta1.DocumentChange} - * - * @property {Object} documentDelete - * A Document has been deleted. - * - * This object should have the same structure as [DocumentDelete]{@link google.firestore.v1beta1.DocumentDelete} - * - * @property {Object} documentRemove - * A Document has been removed from a target (because it is no longer - * relevant to that target). - * - * This object should have the same structure as [DocumentRemove]{@link google.firestore.v1beta1.DocumentRemove} - * - * @property {Object} filter - * A filter to apply to the set of documents previously returned for the - * given target. - * - * Returned when documents may have been removed from the given target, but - * the exact documents are unknown. - * - * This object should have the same structure as [ExistenceFilter]{@link google.firestore.v1beta1.ExistenceFilter} - * - * @typedef ListenResponse - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.ListenResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const ListenResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A specification of a set of documents to listen to. - * - * @property {Object} query - * A target specified by a query. - * - * This object should have the same structure as [QueryTarget]{@link google.firestore.v1beta1.QueryTarget} - * - * @property {Object} documents - * A target specified by a set of document names. - * - * This object should have the same structure as [DocumentsTarget]{@link google.firestore.v1beta1.DocumentsTarget} - * - * @property {Buffer} resumeToken - * A resume token from a prior TargetChange for an identical target. - * - * Using a resume token with a different target is unsupported and may fail. - * - * @property {Object} readTime - * Start listening after a specific `read_time`. - * - * The client must know the state of matching documents at this time. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @property {number} targetId - * The target ID that identifies the target on the stream. Must be a positive - * number and non-zero. - * - * @property {boolean} once - * If the target should be removed once it is current and consistent. - * - * @typedef Target - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.Target definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const Target = { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * A target specified by a set of documents names. - * - * @property {string[]} documents - * The names of the documents to retrieve. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * The request will fail if any of the document is not a child resource of - * the given `database`. Duplicate names will be elided. - * - * @typedef DocumentsTarget - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.Target.DocumentsTarget definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ - DocumentsTarget: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, - - /** - * A target specified by a query. - * - * @property {string} parent - * 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` - * - * @property {Object} structuredQuery - * A structured query. - * - * This object should have the same structure as [StructuredQuery]{@link google.firestore.v1beta1.StructuredQuery} - * - * @typedef QueryTarget - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.Target.QueryTarget definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ - QueryTarget: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, -}; - -/** - * Targets being watched have changed. - * - * @property {number} targetChangeType - * The type of change that occurred. - * - * The number should be among the values of [TargetChangeType]{@link google.firestore.v1beta1.TargetChangeType} - * - * @property {number[]} targetIds - * The target IDs of targets that have changed. - * - * If empty, the change applies to all targets. - * - * The order of the target IDs is not defined. - * - * @property {Object} cause - * The error that resulted in this change, if applicable. - * - * This object should have the same structure as [Status]{@link google.rpc.Status} - * - * @property {Buffer} resumeToken - * A token that can be used to resume the stream for the given `target_ids`, - * or all targets if `target_ids` is empty. - * - * Not set on every target change. - * - * @property {Object} readTime - * The consistent `read_time` for the given `target_ids` (omitted when the - * target_ids are not at a consistent snapshot). - * - * The stream is guaranteed to send a `read_time` with `target_ids` empty - * whenever the entire stream reaches a new consistent snapshot. ADD, - * CURRENT, and RESET messages are guaranteed to (eventually) result in a - * new consistent snapshot (while NO_CHANGE and REMOVE messages are not). - * - * For a given stream, `read_time` is guaranteed to be monotonically - * increasing. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef TargetChange - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.TargetChange definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const TargetChange = { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * The type of change. - * - * @enum {number} - * @memberof google.firestore.v1beta1 - */ - TargetChangeType: { - /** - * No change has occurred. Used only to send an updated `resume_token`. - */ - NO_CHANGE: 0, - - /** - * The targets have been added. - */ - ADD: 1, - - /** - * The targets have been removed. - */ - REMOVE: 2, - - /** - * The targets reflect all changes committed before the targets were added - * to the stream. - * - * This will be sent after or with a `read_time` that is greater than or - * equal to the time at which the targets were added. - * - * Listeners can wait for this change if read-after-write semantics - * are desired. - */ - CURRENT: 3, - - /** - * The targets have been reset, and a new initial state for the targets - * will be returned in subsequent changes. - * - * After the initial state is complete, `CURRENT` will be returned even - * if the target was previously indicated to be `CURRENT`. - */ - RESET: 4, - }, -}; - -/** - * The request for Firestore.ListCollectionIds. - * - * @property {string} parent - * 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` - * - * @property {number} pageSize - * The maximum number of results to return. - * - * @property {string} pageToken - * A page token. Must be a value from - * ListCollectionIdsResponse. - * - * @typedef ListCollectionIdsRequest - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.ListCollectionIdsRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const ListCollectionIdsRequest = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * The response from Firestore.ListCollectionIds. - * - * @property {string[]} collectionIds - * The collection ids. - * - * @property {string} nextPageToken - * A page token that may be used to continue the list. - * - * @typedef ListCollectionIdsResponse - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.ListCollectionIdsResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto} - */ -const ListCollectionIdsResponse = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_query.js b/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_query.js deleted file mode 100644 index 8f9fc62cc..000000000 --- a/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_query.js +++ /dev/null @@ -1,399 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * A Firestore query. - * - * @property {Object} select - * The projection to return. - * - * This object should have the same structure as [Projection]{@link google.firestore.v1beta1.Projection} - * - * @property {Object[]} from - * The collections to query. - * - * This object should have the same structure as [CollectionSelector]{@link google.firestore.v1beta1.CollectionSelector} - * - * @property {Object} where - * The filter to apply. - * - * This object should have the same structure as [Filter]{@link google.firestore.v1beta1.Filter} - * - * @property {Object[]} orderBy - * The order to apply to the query results. - * - * Firestore guarantees a stable ordering through the following rules: - * - * * Any field required to appear in `order_by`, that is not already - * specified in `order_by`, is appended to the order in field name order - * by default. - * * If an order on `__name__` is not specified, it is appended by default. - * - * Fields are appended with the same sort direction as the last order - * specified, or 'ASCENDING' if no order was specified. For example: - * - * * `SELECT * FROM Foo ORDER BY A` becomes - * `SELECT * FROM Foo ORDER BY A, __name__` - * * `SELECT * FROM Foo ORDER BY A DESC` becomes - * `SELECT * FROM Foo ORDER BY A DESC, __name__ DESC` - * * `SELECT * FROM Foo WHERE A > 1` becomes - * `SELECT * FROM Foo WHERE A > 1 ORDER BY A, __name__` - * - * This object should have the same structure as [Order]{@link google.firestore.v1beta1.Order} - * - * @property {Object} startAt - * A starting point for the query results. - * - * This object should have the same structure as [Cursor]{@link google.firestore.v1beta1.Cursor} - * - * @property {Object} endAt - * A end point for the query results. - * - * This object should have the same structure as [Cursor]{@link google.firestore.v1beta1.Cursor} - * - * @property {number} offset - * The number of results to skip. - * - * Applies before limit, but after all other constraints. Must be >= 0 if - * specified. - * - * @property {Object} limit - * The maximum number of results to return. - * - * Applies after all other constraints. - * Must be >= 0 if specified. - * - * This object should have the same structure as [Int32Value]{@link google.protobuf.Int32Value} - * - * @typedef StructuredQuery - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.StructuredQuery definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/query.proto} - */ -const StructuredQuery = { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * A selection of a collection, such as `messages as m1`. - * - * @property {string} collectionId - * The collection ID. - * When set, selects only collections with this ID. - * - * @property {boolean} allDescendants - * When false, selects only collections that are immediate children of - * the `parent` specified in the containing `RunQueryRequest`. - * When true, selects all descendant collections. - * - * @typedef CollectionSelector - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.StructuredQuery.CollectionSelector definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/query.proto} - */ - CollectionSelector: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, - - /** - * A filter. - * - * @property {Object} compositeFilter - * A composite filter. - * - * This object should have the same structure as [CompositeFilter]{@link google.firestore.v1beta1.CompositeFilter} - * - * @property {Object} fieldFilter - * A filter on a document field. - * - * This object should have the same structure as [FieldFilter]{@link google.firestore.v1beta1.FieldFilter} - * - * @property {Object} unaryFilter - * A filter that takes exactly one argument. - * - * This object should have the same structure as [UnaryFilter]{@link google.firestore.v1beta1.UnaryFilter} - * - * @typedef Filter - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.StructuredQuery.Filter definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/query.proto} - */ - Filter: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, - - /** - * A filter that merges multiple other filters using the given operator. - * - * @property {number} op - * The operator for combining multiple filters. - * - * The number should be among the values of [Operator]{@link google.firestore.v1beta1.Operator} - * - * @property {Object[]} filters - * The list of filters to combine. - * Must contain at least one filter. - * - * This object should have the same structure as [Filter]{@link google.firestore.v1beta1.Filter} - * - * @typedef CompositeFilter - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.StructuredQuery.CompositeFilter definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/query.proto} - */ - CompositeFilter: { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * A composite filter operator. - * - * @enum {number} - * @memberof google.firestore.v1beta1 - */ - Operator: { - /** - * Unspecified. This value must not be used. - */ - OPERATOR_UNSPECIFIED: 0, - - /** - * The results are required to satisfy each of the combined filters. - */ - AND: 1, - }, - }, - - /** - * A filter on a specific field. - * - * @property {Object} field - * The field to filter by. - * - * This object should have the same structure as [FieldReference]{@link google.firestore.v1beta1.FieldReference} - * - * @property {number} op - * The operator to filter by. - * - * The number should be among the values of [Operator]{@link google.firestore.v1beta1.Operator} - * - * @property {Object} value - * The value to compare to. - * - * This object should have the same structure as [Value]{@link google.firestore.v1beta1.Value} - * - * @typedef FieldFilter - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.StructuredQuery.FieldFilter definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/query.proto} - */ - FieldFilter: { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * A field filter operator. - * - * @enum {number} - * @memberof google.firestore.v1beta1 - */ - Operator: { - /** - * Unspecified. This value must not be used. - */ - OPERATOR_UNSPECIFIED: 0, - - /** - * Less than. Requires that the field come first in `order_by`. - */ - LESS_THAN: 1, - - /** - * Less than or equal. Requires that the field come first in `order_by`. - */ - LESS_THAN_OR_EQUAL: 2, - - /** - * Greater than. Requires that the field come first in `order_by`. - */ - GREATER_THAN: 3, - - /** - * Greater than or equal. Requires that the field come first in - * `order_by`. - */ - GREATER_THAN_OR_EQUAL: 4, - - /** - * Equal. - */ - EQUAL: 5, - - /** - * Contains. Requires that the field is an array. - */ - ARRAY_CONTAINS: 7, - - /** - * In. Requires that `value` is a non-empty ArrayValue with at most 10 - * values. - */ - IN: 8, - - /** - * Contains any. Requires that the field is an array and - * `value` is a non-empty ArrayValue with at most 10 values. - */ - ARRAY_CONTAINS_ANY: 9, - }, - }, - - /** - * A filter with a single operand. - * - * @property {number} op - * The unary operator to apply. - * - * The number should be among the values of [Operator]{@link google.firestore.v1beta1.Operator} - * - * @property {Object} field - * The field to which to apply the operator. - * - * This object should have the same structure as [FieldReference]{@link google.firestore.v1beta1.FieldReference} - * - * @typedef UnaryFilter - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.StructuredQuery.UnaryFilter definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/query.proto} - */ - UnaryFilter: { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * A unary operator. - * - * @enum {number} - * @memberof google.firestore.v1beta1 - */ - Operator: { - /** - * Unspecified. This value must not be used. - */ - OPERATOR_UNSPECIFIED: 0, - - /** - * Test if a field is equal to NaN. - */ - IS_NAN: 2, - - /** - * Test if an expression evaluates to Null. - */ - IS_NULL: 3, - }, - }, - - /** - * An order on a field. - * - * @property {Object} field - * The field to order by. - * - * This object should have the same structure as [FieldReference]{@link google.firestore.v1beta1.FieldReference} - * - * @property {number} direction - * The direction to order by. Defaults to `ASCENDING`. - * - * The number should be among the values of [Direction]{@link google.firestore.v1beta1.Direction} - * - * @typedef Order - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.StructuredQuery.Order definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/query.proto} - */ - Order: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, - - /** - * The projection of document's fields to return. - * - * @property {Object[]} fields - * The fields to return. - * - * If empty, all fields are returned. To only return the name - * of the document, use `['__name__']`. - * - * This object should have the same structure as [FieldReference]{@link google.firestore.v1beta1.FieldReference} - * - * @typedef Projection - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.StructuredQuery.Projection definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/query.proto} - */ - Projection: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, - - /** - * A reference to a field, such as `max(messages.time) as max_time`. - * - * @property {string} fieldPath - * - * @typedef FieldReference - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.StructuredQuery.FieldReference definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/query.proto} - */ - FieldReference: { - // This is for documentation. Actual contents will be loaded by gRPC. - }, - - /** - * A sort direction. - * - * @enum {number} - * @memberof google.firestore.v1beta1 - */ - Direction: { - /** - * Unspecified. - */ - DIRECTION_UNSPECIFIED: 0, - - /** - * Ascending. - */ - ASCENDING: 1, - - /** - * Descending. - */ - DESCENDING: 2, - }, -}; - -/** - * A position in a query result set. - * - * @property {Object[]} values - * The values that represent a position, in the order they appear in - * the order by clause of a query. - * - * Can contain fewer values than specified in the order by clause. - * - * This object should have the same structure as [Value]{@link google.firestore.v1beta1.Value} - * - * @property {boolean} before - * If the position is just before or just after the given values, relative - * to the sort order defined by the query. - * - * @typedef Cursor - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.Cursor definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/query.proto} - */ -const Cursor = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_write.js b/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_write.js deleted file mode 100644 index 3ba939fff..000000000 --- a/dev/src/v1beta1/doc/google/firestore/v1beta1/doc_write.js +++ /dev/null @@ -1,338 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * A write on a document. - * - * @property {Object} update - * A document to write. - * - * This object should have the same structure as [Document]{@link google.firestore.v1beta1.Document} - * - * @property {string} delete - * A document name to delete. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * - * @property {Object} transform - * Applies a transformation to a document. - * At most one `transform` per document is allowed in a given request. - * An `update` cannot follow a `transform` on the same document in a given - * request. - * - * This object should have the same structure as [DocumentTransform]{@link google.firestore.v1beta1.DocumentTransform} - * - * @property {Object} updateMask - * The fields to update in this write. - * - * This field can be set only when the operation is `update`. - * If the mask is not set for an `update` and the document exists, any - * existing data will be overwritten. - * If the mask is set and the document on the server has fields not covered by - * the mask, they are left unchanged. - * Fields referenced in the mask, but not present in the input document, are - * deleted from the document on the server. - * The field paths in this mask must not contain a reserved field name. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1beta1.DocumentMask} - * - * @property {Object} currentDocument - * An optional precondition on the document. - * - * The write will fail if this is set and not met by the target document. - * - * This object should have the same structure as [Precondition]{@link google.firestore.v1beta1.Precondition} - * - * @typedef Write - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.Write definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/write.proto} - */ -const Write = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A transformation of a document. - * - * @property {string} document - * The name of the document to transform. - * - * @property {Object[]} fieldTransforms - * The list of transformations to apply to the fields of the document, in - * order. - * This must not be empty. - * - * This object should have the same structure as [FieldTransform]{@link google.firestore.v1beta1.FieldTransform} - * - * @typedef DocumentTransform - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.DocumentTransform definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/write.proto} - */ -const DocumentTransform = { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * A transformation of a field of the document. - * - * @property {string} fieldPath - * The path of the field. See Document.fields for the field path syntax - * reference. - * - * @property {number} setToServerValue - * Sets the field to the given server value. - * - * The number should be among the values of [ServerValue]{@link google.firestore.v1beta1.ServerValue} - * - * @property {Object} increment - * Adds the given value to the field's current value. - * - * This must be an integer or a double value. - * If the field is not an integer or double, or if the field does not yet - * exist, the transformation will set the field to the given value. - * If either of the given value or the current field value are doubles, - * both values will be interpreted as doubles. Double arithmetic and - * representation of double values follow IEEE 754 semantics. - * If there is positive/negative integer overflow, the field is resolved - * to the largest magnitude positive/negative integer. - * - * This object should have the same structure as [Value]{@link google.firestore.v1beta1.Value} - * - * @property {Object} maximum - * Sets the field to the maximum of its current value and the given value. - * - * This must be an integer or a double value. - * If the field is not an integer or double, or if the field does not yet - * exist, the transformation will set the field to the given value. - * If a maximum operation is applied where the field and the input value - * are of mixed types (that is - one is an integer and one is a double) - * the field takes on the type of the larger operand. If the operands are - * equivalent (e.g. 3 and 3.0), the field does not change. - * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and - * zero input value is always the stored value. - * The maximum of any numeric value x and NaN is NaN. - * - * This object should have the same structure as [Value]{@link google.firestore.v1beta1.Value} - * - * @property {Object} minimum - * Sets the field to the minimum of its current value and the given value. - * - * This must be an integer or a double value. - * If the field is not an integer or double, or if the field does not yet - * exist, the transformation will set the field to the input value. - * If a minimum operation is applied where the field and the input value - * are of mixed types (that is - one is an integer and one is a double) - * the field takes on the type of the smaller operand. If the operands are - * equivalent (e.g. 3 and 3.0), the field does not change. - * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and - * zero input value is always the stored value. - * The minimum of any numeric value x and NaN is NaN. - * - * This object should have the same structure as [Value]{@link google.firestore.v1beta1.Value} - * - * @property {Object} appendMissingElements - * Append the given elements in order if they are not already present in - * the current field value. - * If the field is not an array, or if the field does not yet exist, it is - * first set to the empty array. - * - * Equivalent numbers of different types (e.g. 3L and 3.0) are - * considered equal when checking if a value is missing. - * NaN is equal to NaN, and Null is equal to Null. - * If the input contains multiple equivalent values, only the first will - * be considered. - * - * The corresponding transform_result will be the null value. - * - * This object should have the same structure as [ArrayValue]{@link google.firestore.v1beta1.ArrayValue} - * - * @property {Object} removeAllFromArray - * Remove all of the given elements from the array in the field. - * If the field is not an array, or if the field does not yet exist, it is - * set to the empty array. - * - * Equivalent numbers of the different types (e.g. 3L and 3.0) are - * considered equal when deciding whether an element should be removed. - * NaN is equal to NaN, and Null is equal to Null. - * This will remove all equivalent values if there are duplicates. - * - * The corresponding transform_result will be the null value. - * - * This object should have the same structure as [ArrayValue]{@link google.firestore.v1beta1.ArrayValue} - * - * @typedef FieldTransform - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.DocumentTransform.FieldTransform definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/write.proto} - */ - FieldTransform: { - // This is for documentation. Actual contents will be loaded by gRPC. - - /** - * A value that is calculated by the server. - * - * @enum {number} - * @memberof google.firestore.v1beta1 - */ - ServerValue: { - /** - * Unspecified. This value must not be used. - */ - SERVER_VALUE_UNSPECIFIED: 0, - - /** - * The time at which the server processed the request, with millisecond - * precision. - */ - REQUEST_TIME: 1, - }, - }, -}; - -/** - * The result of applying a write. - * - * @property {Object} updateTime - * The last update time of the document after applying the write. Not set - * after a `delete`. - * - * If the write did not actually change the document, this will be the - * previous update_time. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @property {Object[]} transformResults - * The results of applying each DocumentTransform.FieldTransform, in the - * same order. - * - * This object should have the same structure as [Value]{@link google.firestore.v1beta1.Value} - * - * @typedef WriteResult - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.WriteResult definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/write.proto} - */ -const WriteResult = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A Document has changed. - * - * May be the result of multiple writes, including deletes, that - * ultimately resulted in a new value for the Document. - * - * Multiple DocumentChange messages may be returned for the same logical - * change, if multiple targets are affected. - * - * @property {Object} document - * The new state of the Document. - * - * If `mask` is set, contains only fields that were updated or added. - * - * This object should have the same structure as [Document]{@link google.firestore.v1beta1.Document} - * - * @property {number[]} targetIds - * A set of target IDs of targets that match this document. - * - * @property {number[]} removedTargetIds - * A set of target IDs for targets that no longer match this document. - * - * @typedef DocumentChange - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.DocumentChange definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/write.proto} - */ -const DocumentChange = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A Document has been deleted. - * - * May be the result of multiple writes, including updates, the - * last of which deleted the Document. - * - * Multiple DocumentDelete messages may be returned for the same logical - * delete, if multiple targets are affected. - * - * @property {string} document - * The resource name of the Document that was deleted. - * - * @property {number[]} removedTargetIds - * A set of target IDs for targets that previously matched this entity. - * - * @property {Object} readTime - * The read timestamp at which the delete was observed. - * - * Greater or equal to the `commit_time` of the delete. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef DocumentDelete - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.DocumentDelete definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/write.proto} - */ -const DocumentDelete = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A Document has been removed from the view of the targets. - * - * Sent if the document is no longer relevant to a target and is out of view. - * Can be sent instead of a DocumentDelete or a DocumentChange if the server - * can not send the new value of the document. - * - * Multiple DocumentRemove messages may be returned for the same logical - * write or delete, if multiple targets are affected. - * - * @property {string} document - * The resource name of the Document that has gone out of view. - * - * @property {number[]} removedTargetIds - * A set of target IDs for targets that previously matched this document. - * - * @property {Object} readTime - * The read timestamp at which the remove was observed. - * - * Greater or equal to the `commit_time` of the change/delete/remove. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * - * @typedef DocumentRemove - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.DocumentRemove definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/write.proto} - */ -const DocumentRemove = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; - -/** - * A digest of all the documents that match a given target. - * - * @property {number} targetId - * The target ID to which this filter applies. - * - * @property {number} count - * The total count of documents that match target_id. - * - * If different from the count of documents in the client that match, the - * client must manually determine which documents no longer match the target. - * - * @typedef ExistenceFilter - * @memberof google.firestore.v1beta1 - * @see [google.firestore.v1beta1.ExistenceFilter definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/write.proto} - */ -const ExistenceFilter = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1beta1/doc/google/protobuf/doc_any.js b/dev/src/v1beta1/doc/google/protobuf/doc_any.js deleted file mode 100644 index 12a36f58d..000000000 --- a/dev/src/v1beta1/doc/google/protobuf/doc_any.js +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * `Any` contains an arbitrary serialized protocol buffer message along with a - * URL that describes the type of the serialized message. - * - * Protobuf library provides support to pack/unpack Any values in the form - * of utility functions or additional generated methods of the Any type. - * - * Example 1: Pack and unpack a message in C++. - * - * Foo foo = ...; - * Any any; - * any.PackFrom(foo); - * ... - * if (any.UnpackTo(&foo)) { - * ... - * } - * - * Example 2: Pack and unpack a message in Java. - * - * Foo foo = ...; - * Any any = Any.pack(foo); - * ... - * if (any.is(Foo.class)) { - * foo = any.unpack(Foo.class); - * } - * - * Example 3: Pack and unpack a message in Python. - * - * foo = Foo(...) - * any = Any() - * any.Pack(foo) - * ... - * if any.Is(Foo.DESCRIPTOR): - * any.Unpack(foo) - * ... - * - * Example 4: Pack and unpack a message in Go - * - * foo := &pb.Foo{...} - * any, err := ptypes.MarshalAny(foo) - * ... - * foo := &pb.Foo{} - * if err := ptypes.UnmarshalAny(any, foo); err != nil { - * ... - * } - * - * The pack methods provided by protobuf library will by default use - * 'type.googleapis.com/full.type.name' as the type URL and the unpack - * methods only use the fully qualified type name after the last '/' - * in the type URL, for example "foo.bar.com/x/y.z" will yield type - * name "y.z". - * - * - * # JSON - * - * The JSON representation of an `Any` value uses the regular - * representation of the deserialized, embedded message, with an - * additional field `@type` which contains the type URL. Example: - * - * package google.profile; - * message Person { - * string first_name = 1; - * string last_name = 2; - * } - * - * { - * "@type": "type.googleapis.com/google.profile.Person", - * "firstName": , - * "lastName": - * } - * - * If the embedded message type is well-known and has a custom JSON - * representation, that representation will be embedded adding a field - * `value` which holds the custom JSON in addition to the `@type` - * field. Example (for message google.protobuf.Duration): - * - * { - * "@type": "type.googleapis.com/google.protobuf.Duration", - * "value": "1.212s" - * } - * - * @property {string} typeUrl - * A URL/resource name that uniquely identifies the type of the serialized - * protocol buffer message. This string must contain at least - * one "/" character. The last segment of the URL's path must represent - * the fully qualified name of the type (as in - * `path/google.protobuf.Duration`). The name should be in a canonical form - * (e.g., leading "." is not accepted). - * - * In practice, teams usually precompile into the binary all types that they - * expect it to use in the context of Any. However, for URLs which use the - * scheme `http`, `https`, or no scheme, one can optionally set up a type - * server that maps type URLs to message definitions as follows: - * - * * If no scheme is provided, `https` is assumed. - * * An HTTP GET on the URL must yield a google.protobuf.Type - * value in binary format, or produce an error. - * * Applications are allowed to cache lookup results based on the - * URL, or have them precompiled into a binary to avoid any - * lookup. Therefore, binary compatibility needs to be preserved - * on changes to types. (Use versioned type names to manage - * breaking changes.) - * - * Note: this functionality is not currently available in the official - * protobuf release, and it is not used for type URLs beginning with - * type.googleapis.com. - * - * Schemes other than `http`, `https` (or the empty scheme) might be - * used with implementation specific semantics. - * - * @property {Buffer} value - * Must be a valid serialized protocol buffer of the above specified type. - * - * @typedef Any - * @memberof google.protobuf - * @see [google.protobuf.Any definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/any.proto} - */ -const Any = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1beta1/doc/google/protobuf/doc_empty.js b/dev/src/v1beta1/doc/google/protobuf/doc_empty.js deleted file mode 100644 index 78e891398..000000000 --- a/dev/src/v1beta1/doc/google/protobuf/doc_empty.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * A generic empty message that you can re-use to avoid defining duplicated - * empty messages in your APIs. A typical example is to use it as the request - * or the response type of an API method. For instance: - * - * service Foo { - * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); - * } - * - * The JSON representation for `Empty` is empty JSON object `{}`. - * @typedef Empty - * @memberof google.protobuf - * @see [google.protobuf.Empty definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/empty.proto} - */ -const Empty = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1beta1/doc/google/protobuf/doc_timestamp.js b/dev/src/v1beta1/doc/google/protobuf/doc_timestamp.js deleted file mode 100644 index e14d06caa..000000000 --- a/dev/src/v1beta1/doc/google/protobuf/doc_timestamp.js +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * A Timestamp represents a point in time independent of any time zone or local - * calendar, encoded as a count of seconds and fractions of seconds at - * nanosecond resolution. The count is relative to an epoch at UTC midnight on - * January 1, 1970, in the proleptic Gregorian calendar which extends the - * Gregorian calendar backwards to year one. - * - * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap - * second table is needed for interpretation, using a [24-hour linear - * smear](https://developers.google.com/time/smear). - * - * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By - * restricting to that range, we ensure that we can convert to and from [RFC - * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. - * - * # Examples - * - * Example 1: Compute Timestamp from POSIX `time()`. - * - * Timestamp timestamp; - * timestamp.set_seconds(time(NULL)); - * timestamp.set_nanos(0); - * - * Example 2: Compute Timestamp from POSIX `gettimeofday()`. - * - * struct timeval tv; - * gettimeofday(&tv, NULL); - * - * Timestamp timestamp; - * timestamp.set_seconds(tv.tv_sec); - * timestamp.set_nanos(tv.tv_usec * 1000); - * - * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. - * - * FILETIME ft; - * GetSystemTimeAsFileTime(&ft); - * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; - * - * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z - * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. - * Timestamp timestamp; - * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); - * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); - * - * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. - * - * long millis = System.currentTimeMillis(); - * - * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) - * .setNanos((int) ((millis % 1000) * 1000000)).build(); - * - * - * Example 5: Compute Timestamp from current time in Python. - * - * timestamp = Timestamp() - * timestamp.GetCurrentTime() - * - * # JSON Mapping - * - * In JSON format, the Timestamp type is encoded as a string in the - * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the - * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" - * where {year} is always expressed using four digits while {month}, {day}, - * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional - * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), - * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone - * is required. A proto3 JSON serializer should always use UTC (as indicated by - * "Z") when printing the Timestamp type and a proto3 JSON parser should be - * able to accept both UTC and other timezones (as indicated by an offset). - * - * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past - * 01:30 UTC on January 15, 2017. - * - * In JavaScript, one can convert a Date object to this format using the - * standard - * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) - * method. In Python, a standard `datetime.datetime` object can be converted - * to this format using - * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with - * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use - * the Joda Time's [`ISODateTimeFormat.dateTime()`](https://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D) to obtain a formatter capable of generating timestamps in this format. - * - * @property {number} seconds - * Represents seconds of UTC time since Unix epoch - * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to - * 9999-12-31T23:59:59Z inclusive. - * - * @property {number} nanos - * Non-negative fractions of a second at nanosecond resolution. Negative - * second values with fractions must still have non-negative nanos values - * that count forward in time. Must be from 0 to 999,999,999 - * inclusive. - * - * @typedef Timestamp - * @memberof google.protobuf - * @see [google.protobuf.Timestamp definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto} - */ -const Timestamp = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1beta1/doc/google/protobuf/doc_wrappers.js b/dev/src/v1beta1/doc/google/protobuf/doc_wrappers.js deleted file mode 100644 index cf790ddc4..000000000 --- a/dev/src/v1beta1/doc/google/protobuf/doc_wrappers.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * Wrapper message for `int32`. - * - * The JSON representation for `Int32Value` is JSON number. - * - * @property {number} value - * The int32 value. - * - * @typedef Int32Value - * @memberof google.protobuf - * @see [google.protobuf.Int32Value definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/wrappers.proto} - */ -const Int32Value = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1beta1/doc/google/rpc/doc_status.js b/dev/src/v1beta1/doc/google/rpc/doc_status.js deleted file mode 100644 index 77a6840e3..000000000 --- a/dev/src/v1beta1/doc/google/rpc/doc_status.js +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -// Note: this file is purely for documentation. Any contents are not expected -// to be loaded as the JS file. - -/** - * The `Status` type defines a logical error model that is suitable for - * different programming environments, including REST APIs and RPC APIs. It is - * used by [gRPC](https://github.com/grpc). The error model is designed to be: - * - * - Simple to use and understand for most users - * - Flexible enough to meet unexpected needs - * - * # Overview - * - * The `Status` message contains three pieces of data: error code, error - * message, and error details. The error code should be an enum value of - * google.rpc.Code, but it may accept additional error codes - * if needed. The error message should be a developer-facing English message - * that helps developers *understand* and *resolve* the error. If a localized - * user-facing error message is needed, put the localized message in the error - * details or localize it in the client. The optional error details may contain - * arbitrary information about the error. There is a predefined set of error - * detail types in the package `google.rpc` that can be used for common error - * conditions. - * - * # Language mapping - * - * The `Status` message is the logical representation of the error model, but it - * is not necessarily the actual wire format. When the `Status` message is - * exposed in different client libraries and different wire protocols, it can be - * mapped differently. For example, it will likely be mapped to some exceptions - * in Java, but more likely mapped to some error codes in C. - * - * # Other uses - * - * The error model and the `Status` message can be used in a variety of - * environments, either with or without APIs, to provide a - * consistent developer experience across different environments. - * - * Example uses of this error model include: - * - * - Partial errors. If a service needs to return partial errors to the client, - * it may embed the `Status` in the normal response to indicate the partial - * errors. - * - * - Workflow errors. A typical workflow has multiple steps. Each step may - * have a `Status` message for error reporting. - * - * - Batch operations. If a client uses batch request and batch response, the - * `Status` message should be used directly inside batch response, one for - * each error sub-response. - * - * - Asynchronous operations. If an API call embeds asynchronous operation - * results in its response, the status of those operations should be - * represented directly using the `Status` message. - * - * - Logging. If some API errors are stored in logs, the message `Status` could - * be used directly after any stripping needed for security/privacy reasons. - * - * @property {number} code - * The status code, which should be an enum value of - * google.rpc.Code. - * - * @property {string} message - * A developer-facing error message, which should be in English. Any - * user-facing error message should be localized and sent in the - * google.rpc.Status.details field, or localized - * by the client. - * - * @property {Object[]} details - * A list of messages that carry the error details. There is a common set of - * message types for APIs to use. - * - * This object should have the same structure as [Any]{@link google.protobuf.Any} - * - * @typedef Status - * @memberof google.rpc - * @see [google.rpc.Status definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto} - */ -const Status = { - // This is for documentation. Actual contents will be loaded by gRPC. -}; diff --git a/dev/src/v1beta1/firestore_client.js b/dev/src/v1beta1/firestore_client.js deleted file mode 100644 index bd91d6f7f..000000000 --- a/dev/src/v1beta1/firestore_client.js +++ /dev/null @@ -1,1544 +0,0 @@ -// Copyright 2019 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 -// -// https://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. - -'use strict'; - -const gapicConfig = require('./firestore_client_config.json'); -const gax = require('google-gax'); -const path = require('path'); - -const VERSION = require('../../../package.json').version; - -/** - * The Cloud Firestore service. - * - * This service exposes several types of comparable timestamps: - * - * * `create_time` - The time at which a document was created. Changes only - * when a document is deleted, then re-created. Increases in a strict - * monotonic fashion. - * * `update_time` - The time at which a document was last updated. Changes - * every time a document is modified. Does not change when a write results - * in no modifications. Increases in a strict monotonic fashion. - * * `read_time` - The time at which a particular state was observed. Used - * to denote a consistent snapshot of the database or the time at which a - * Document was observed to not exist. - * * `commit_time` - The time at which the writes in a transaction were - * committed. Any read with an equal or greater `read_time` is guaranteed - * to see the effects of the transaction. - * - * @class - * @memberof v1beta1 - */ -class FirestoreClient { - /** - * Construct an instance of FirestoreClient. - * - * @param {object} [options] - The configuration object. See the subsequent - * parameters for more details. - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {function} [options.promise] - Custom promise module to use instead - * of native Promises. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - */ - constructor(opts) { - opts = opts || {}; - this._descriptors = {}; - - if (global.isBrowser) { - // If we're in browser, we use gRPC fallback. - opts.fallback = true; - } - - // If we are in browser, we are already using fallback because of the - // "browser" field in package.json. - // But if we were explicitly requested to use fallback, let's do it now. - const gaxModule = !global.isBrowser && opts.fallback ? gax.fallback : gax; - - const servicePath = - opts.servicePath || opts.apiEndpoint || this.constructor.servicePath; - - // Ensure that options include the service address and port. - opts = Object.assign( - { - clientConfig: {}, - port: this.constructor.port, - servicePath, - }, - opts - ); - - // Create a `gaxGrpc` object, with any grpc-specific options - // sent to the client. - opts.scopes = this.constructor.scopes; - const gaxGrpc = new gaxModule.GrpcClient(opts); - - // Save the auth object to the client, for use by other methods. - this.auth = gaxGrpc.auth; - - // Determine the client header string. - const clientHeader = []; - - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } - clientHeader.push(`gax/${gaxModule.version}`); - if (opts.fallback) { - clientHeader.push(`gl-web/${gaxModule.version}`); - } else { - clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); - } - clientHeader.push(`gapic/${VERSION}`); - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - - // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join( - __dirname, - '..', - '..', - 'protos', - 'protos.json' - ); - const protos = gaxGrpc.loadProto( - opts.fallback ? 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 = { - anyPathPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/databases/{database}/documents/{document}/{any_path=**}' - ), - databaseRootPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/databases/{database}' - ), - documentPathPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/databases/{database}/documents/{document_path=**}' - ), - documentRootPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/databases/{database}/documents' - ), - }; - - // 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 = { - listDocuments: new gaxModule.PageDescriptor( - 'pageToken', - 'nextPageToken', - 'documents' - ), - listCollectionIds: new gaxModule.PageDescriptor( - 'pageToken', - 'nextPageToken', - 'collectionIds' - ), - }; - - // Some of the methods on this service provide streaming responses. - // Provide descriptors for these. - this._descriptors.stream = { - batchGetDocuments: new gaxModule.StreamDescriptor( - gax.StreamType.SERVER_STREAMING - ), - runQuery: new gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING), - write: new gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING), - listen: new gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING), - }; - - // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( - 'google.firestore.v1beta1.Firestore', - gapicConfig, - opts.clientConfig, - {'x-goog-api-client': clientHeader.join(' ')} - ); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this._innerApiCalls = {}; - - // Put together the "service stub" for - // google.firestore.v1beta1.Firestore. - const firestoreStub = gaxGrpc.createStub( - opts.fallback - ? protos.lookupService('google.firestore.v1beta1.Firestore') - : protos.google.firestore.v1beta1.Firestore, - opts - ); - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const firestoreStubMethods = [ - 'getDocument', - 'listDocuments', - 'createDocument', - 'updateDocument', - 'deleteDocument', - 'batchGetDocuments', - 'beginTransaction', - 'commit', - 'rollback', - 'runQuery', - 'write', - 'listen', - 'listCollectionIds', - ]; - for (const methodName of firestoreStubMethods) { - const innerCallPromise = firestoreStub.then( - stub => (...args) => { - return stub[methodName].apply(stub, args); - }, - err => () => { - throw err; - } - ); - this._innerApiCalls[methodName] = gaxModule.createApiCall( - innerCallPromise, - defaults[methodName], - this._descriptors.page[methodName] || - this._descriptors.stream[methodName] - ); - } - } - - /** - * The DNS address for this API service. - */ - static get servicePath() { - return 'firestore.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - */ - static get apiEndpoint() { - return 'firestore.googleapis.com'; - } - - /** - * The port for this API service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/datastore', - ]; - } - - /** - * Return the project ID used by this class. - * @param {function(Error, string)} callback - the callback to - * be called with the current project Id. - */ - getProjectId(callback) { - return this.auth.getProjectId(callback); - } - - // ------------------- - // -- Service calls -- - // ------------------- - - /** - * Gets a single document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource name of the Document to get. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * @param {Object} [request.mask] - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1beta1.DocumentMask} - * @param {Buffer} [request.transaction] - * Reads the document in a transaction. - * @param {Object} [request.readTime] - * Reads the version of the document at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [Document]{@link google.firestore.v1beta1.Document}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Document]{@link google.firestore.v1beta1.Document}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1beta1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedName = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * client.getDocument({name: formattedName}) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - getDocument(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - name: request.name, - }); - - return this._innerApiCalls.getDocument(request, options, callback); - } - - /** - * Lists documents. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * 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 - * The collection ID, relative to `parent`, to list. For example: `chatrooms` - * or `messages`. - * @param {number} [request.pageSize] - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {string} [request.orderBy] - * The order to sort results by. For example: `priority desc, name`. - * @param {Object} [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. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1beta1.DocumentMask} - * @param {Buffer} [request.transaction] - * Reads documents in a transaction. - * @param {Object} [request.readTime] - * Reads documents as they were at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * @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, Document.create_time, - * or Document.update_time set. - * - * Requests with `show_missing` may not specify `where` or - * `order_by`. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Array, ?Object, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is Array of [Document]{@link google.firestore.v1beta1.Document}. - * - * When autoPaginate: false is specified through options, it contains the result - * in a single response. If the response indicates the next page exists, the third - * parameter is set to be used for the next request object. The fourth parameter keeps - * the raw response object of an object representing [ListDocumentsResponse]{@link google.firestore.v1beta1.ListDocumentsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Document]{@link google.firestore.v1beta1.Document}. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [Document]{@link google.firestore.v1beta1.Document} in a single response. - * The second element is the next request object if the response - * indicates the next page exists, or null. The third element is - * an object representing [ListDocumentsResponse]{@link google.firestore.v1beta1.ListDocumentsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1beta1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * // Iterate over all elements. - * const formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * const collectionId = ''; - * const request = { - * parent: formattedParent, - * collectionId: collectionId, - * }; - * - * client.listDocuments(request) - * .then(responses => { - * const resources = responses[0]; - * for (const resource of resources) { - * // doThingsWith(resource) - * } - * }) - * .catch(err => { - * console.error(err); - * }); - * - * // Or obtain the paged response. - * const formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * const collectionId = ''; - * const request = { - * parent: formattedParent, - * collectionId: collectionId, - * }; - * - * - * const options = {autoPaginate: false}; - * const callback = responses => { - * // The actual resources in a response. - * const resources = responses[0]; - * // The next request if the response shows that there are more responses. - * const nextRequest = responses[1]; - * // The actual response object, if necessary. - * // const rawResponse = responses[2]; - * for (const resource of resources) { - * // doThingsWith(resource); - * } - * if (nextRequest) { - * // Fetch the next page. - * return client.listDocuments(nextRequest, options).then(callback); - * } - * } - * client.listDocuments(request, options) - * .then(callback) - * .catch(err => { - * console.error(err); - * }); - */ - listDocuments(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - options = {}; - } - request = request || {}; - options = options || {}; - - return this._innerApiCalls.listDocuments(request, options, callback); - } - - /** - * Equivalent to {@link listDocuments}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listDocuments} 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 - * 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 - * The collection ID, relative to `parent`, to list. For example: `chatrooms` - * or `messages`. - * @param {number} [request.pageSize] - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {string} [request.orderBy] - * The order to sort results by. For example: `priority desc, name`. - * @param {Object} [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. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1beta1.DocumentMask} - * @param {Buffer} [request.transaction] - * Reads documents in a transaction. - * @param {Object} [request.readTime] - * Reads documents as they were at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * @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, Document.create_time, - * or Document.update_time set. - * - * Requests with `show_missing` may not specify `where` or - * `order_by`. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @returns {Stream} - * An object stream which emits an object representing [Document]{@link google.firestore.v1beta1.Document} on 'data' event. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1beta1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * const collectionId = ''; - * const request = { - * parent: formattedParent, - * collectionId: collectionId, - * }; - * client.listDocumentsStream(request) - * .on('data', element => { - * // doThingsWith(element) - * }).on('error', err => { - * console.log(err); - * }); - */ - listDocumentsStream(request, options) { - options = options || {}; - - return this._descriptors.page.listDocuments.createStream( - this._innerApiCalls.listDocuments, - request, - options - ); - } - - /** - * Creates a new document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The parent resource. For example: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` - * @param {string} request.collectionId - * The collection ID, relative to `parent`, to list. For example: `chatrooms`. - * @param {string} request.documentId - * The client-assigned document ID to use for this document. - * - * Optional. If not specified, an ID will be assigned by the service. - * @param {Object} request.document - * The document to create. `name` must not be set. - * - * This object should have the same structure as [Document]{@link google.firestore.v1beta1.Document} - * @param {Object} [request.mask] - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1beta1.DocumentMask} - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [Document]{@link google.firestore.v1beta1.Document}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Document]{@link google.firestore.v1beta1.Document}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1beta1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * const collectionId = ''; - * const documentId = ''; - * const document = {}; - * const request = { - * parent: formattedParent, - * collectionId: collectionId, - * documentId: documentId, - * document: document, - * }; - * client.createDocument(request) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - createDocument(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - options = {}; - } - request = request || {}; - options = options || {}; - - return this._innerApiCalls.createDocument(request, options, callback); - } - - /** - * Updates or inserts a document. - * - * @param {Object} request - * The request object that will be sent. - * @param {Object} request.document - * The updated document. - * Creates the document if it does not already exist. - * - * This object should have the same structure as [Document]{@link google.firestore.v1beta1.Document} - * @param {Object} request.updateMask - * The fields to update. - * None of the field paths in the mask may contain a reserved name. - * - * If the document exists on the server and has fields not referenced in the - * mask, they are left unchanged. - * Fields referenced in the mask, but not present in the input document, are - * deleted from the document on the server. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1beta1.DocumentMask} - * @param {Object} [request.mask] - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1beta1.DocumentMask} - * @param {Object} [request.currentDocument] - * An optional precondition on the document. - * The request will fail if this is set and not met by the target document. - * - * This object should have the same structure as [Precondition]{@link google.firestore.v1beta1.Precondition} - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [Document]{@link google.firestore.v1beta1.Document}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Document]{@link google.firestore.v1beta1.Document}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1beta1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const document = {}; - * const updateMask = {}; - * const request = { - * document: document, - * updateMask: updateMask, - * }; - * client.updateDocument(request) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - updateDocument(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - 'document.name': request.document.name, - }); - - return this._innerApiCalls.updateDocument(request, options, callback); - } - - /** - * Deletes a document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource name of the Document to delete. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * @param {Object} [request.currentDocument] - * An optional precondition on the document. - * The request will fail if this is set and not met by the target document. - * - * This object should have the same structure as [Precondition]{@link google.firestore.v1beta1.Precondition} - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error)} [callback] - * The function which will be called with the result of the API call. - * @returns {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1beta1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedName = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * client.deleteDocument({name: formattedName}).catch(err => { - * console.error(err); - * }); - */ - deleteDocument(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - name: request.name, - }); - - return this._innerApiCalls.deleteDocument(request, options, callback); - } - - /** - * Gets multiple documents. - * - * Documents returned by this method are not guaranteed to be returned in the - * same order that they were requested. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {string[]} request.documents - * The names of the documents to retrieve. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * The request will fail if any of the document is not a child resource of the - * given `database`. Duplicate names will be elided. - * @param {Object} [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. - * - * This object should have the same structure as [DocumentMask]{@link google.firestore.v1beta1.DocumentMask} - * @param {Buffer} [request.transaction] - * Reads documents in a transaction. - * @param {Object} [request.newTransaction] - * Starts a new transaction and reads the documents. - * Defaults to a read-only transaction. - * The new transaction ID will be returned as the first response in the - * stream. - * - * This object should have the same structure as [TransactionOptions]{@link google.firestore.v1beta1.TransactionOptions} - * @param {Object} [request.readTime] - * Reads documents as they were at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @returns {Stream} - * An object stream which emits [BatchGetDocumentsResponse]{@link google.firestore.v1beta1.BatchGetDocumentsResponse} on 'data' event. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1beta1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); - * const documents = []; - * const request = { - * database: formattedDatabase, - * documents: documents, - * }; - * client.batchGetDocuments(request).on('data', response => { - * // doThingsWith(response) - * }); - */ - batchGetDocuments(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({ - database: request.database, - }); - - return this._innerApiCalls.batchGetDocuments(request, options); - } - - /** - * Starts a new transaction. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {Object} [request.options] - * The options for the transaction. - * Defaults to a read-write transaction. - * - * This object should have the same structure as [TransactionOptions]{@link google.firestore.v1beta1.TransactionOptions} - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [BeginTransactionResponse]{@link google.firestore.v1beta1.BeginTransactionResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BeginTransactionResponse]{@link google.firestore.v1beta1.BeginTransactionResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1beta1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); - * client.beginTransaction({database: formattedDatabase}) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - beginTransaction(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - database: request.database, - }); - - return this._innerApiCalls.beginTransaction(request, options, callback); - } - - /** - * Commits a transaction, while optionally updating documents. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {Object[]} request.writes - * The writes to apply. - * - * Always executed atomically and in order. - * - * This object should have the same structure as [Write]{@link google.firestore.v1beta1.Write} - * @param {Buffer} [request.transaction] - * If set, applies all writes in this transaction, and commits it. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing [CommitResponse]{@link google.firestore.v1beta1.CommitResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CommitResponse]{@link google.firestore.v1beta1.CommitResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1beta1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); - * const writes = []; - * const request = { - * database: formattedDatabase, - * writes: writes, - * }; - * client.commit(request) - * .then(responses => { - * const response = responses[0]; - * // doThingsWith(response) - * }) - * .catch(err => { - * console.error(err); - * }); - */ - commit(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - database: request.database, - }); - - return this._innerApiCalls.commit(request, options, callback); - } - - /** - * Rolls back a transaction. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {Buffer} request.transaction - * The transaction to roll back. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error)} [callback] - * The function which will be called with the result of the API call. - * @returns {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1beta1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); - * const transaction = Buffer.from(''); - * const request = { - * database: formattedDatabase, - * transaction: transaction, - * }; - * client.rollback(request).catch(err => { - * console.error(err); - * }); - */ - rollback(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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({ - database: request.database, - }); - - return this._innerApiCalls.rollback(request, options, callback); - } - - /** - * Runs a query. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * 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 {Object} [request.structuredQuery] - * A structured query. - * - * This object should have the same structure as [StructuredQuery]{@link google.firestore.v1beta1.StructuredQuery} - * @param {Buffer} [request.transaction] - * Reads documents in a transaction. - * @param {Object} [request.newTransaction] - * Starts a new transaction and reads the documents. - * Defaults to a read-only transaction. - * The new transaction ID will be returned as the first response in the - * stream. - * - * This object should have the same structure as [TransactionOptions]{@link google.firestore.v1beta1.TransactionOptions} - * @param {Object} [request.readTime] - * Reads documents as they were at the given time. - * This may not be older than 60 seconds. - * - * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @returns {Stream} - * An object stream which emits [RunQueryResponse]{@link google.firestore.v1beta1.RunQueryResponse} on 'data' event. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1beta1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * client.runQuery({parent: formattedParent}).on('data', response => { - * // doThingsWith(response) - * }); - */ - runQuery(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, - }); - - return this._innerApiCalls.runQuery(request, options); - } - - /** - * Streams batches of document updates and deletes, in order. - * - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @returns {Stream} - * An object stream which is both readable and writable. It accepts objects - * representing [WriteRequest]{@link google.firestore.v1beta1.WriteRequest} for write() method, and - * will emit objects representing [WriteResponse]{@link google.firestore.v1beta1.WriteResponse} on 'data' event asynchronously. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1beta1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const stream = client.write().on('data', response => { - * // doThingsWith(response) - * }); - * const formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); - * const request = { - * database: formattedDatabase, - * }; - * // Write request objects. - * stream.write(request); - */ - write(options) { - options = options || {}; - - return this._innerApiCalls.write(options); - } - - /** - * Listens to changes. - * - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @returns {Stream} - * An object stream which is both readable and writable. It accepts objects - * representing [ListenRequest]{@link google.firestore.v1beta1.ListenRequest} for write() method, and - * will emit objects representing [ListenResponse]{@link google.firestore.v1beta1.ListenResponse} on 'data' event asynchronously. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1beta1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const stream = client.listen().on('data', response => { - * // doThingsWith(response) - * }); - * const formattedDatabase = client.databaseRootPath('[PROJECT]', '[DATABASE]'); - * const request = { - * database: formattedDatabase, - * }; - * // Write request objects. - * stream.write(request); - */ - listen(options) { - options = options || {}; - - return this._innerApiCalls.listen({}, options); - } - - /** - * Lists all the collection IDs underneath a document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * 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 resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @param {function(?Error, ?Array, ?Object, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is Array of string. - * - * When autoPaginate: false is specified through options, it contains the result - * in a single response. If the response indicates the next page exists, the third - * parameter is set to be used for the next request object. The fourth parameter keeps - * the raw response object of an object representing [ListCollectionIdsResponse]{@link google.firestore.v1beta1.ListCollectionIdsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of string. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of string in a single response. - * The second element is the next request object if the response - * indicates the next page exists, or null. The third element is - * an object representing [ListCollectionIdsResponse]{@link google.firestore.v1beta1.ListCollectionIdsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1beta1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * // Iterate over all elements. - * const formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * - * client.listCollectionIds({parent: formattedParent}) - * .then(responses => { - * const resources = responses[0]; - * for (const resource of resources) { - * // doThingsWith(resource) - * } - * }) - * .catch(err => { - * console.error(err); - * }); - * - * // Or obtain the paged response. - * const formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * - * - * const options = {autoPaginate: false}; - * const callback = responses => { - * // The actual resources in a response. - * const resources = responses[0]; - * // The next request if the response shows that there are more responses. - * const nextRequest = responses[1]; - * // The actual response object, if necessary. - * // const rawResponse = responses[2]; - * for (const resource of resources) { - * // doThingsWith(resource); - * } - * if (nextRequest) { - * // Fetch the next page. - * return client.listCollectionIds(nextRequest, options).then(callback); - * } - * } - * client.listCollectionIds({parent: formattedParent}, options) - * .then(callback) - * .catch(err => { - * console.error(err); - * }); - */ - listCollectionIds(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - 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, - }); - - return this._innerApiCalls.listCollectionIds(request, options, callback); - } - - /** - * Equivalent to {@link listCollectionIds}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listCollectionIds} 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 - * 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 resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details. - * @returns {Stream} - * An object stream which emits a string on 'data' event. - * - * @example - * - * const firestore = require('@google-cloud/firestore'); - * - * const client = new firestore.v1beta1.FirestoreClient({ - * // optional auth parameters. - * }); - * - * const formattedParent = client.anyPathPath('[PROJECT]', '[DATABASE]', '[DOCUMENT]', '[ANY_PATH]'); - * client.listCollectionIdsStream({parent: formattedParent}) - * .on('data', element => { - * // doThingsWith(element) - * }).on('error', err => { - * console.log(err); - * }); - */ - listCollectionIdsStream(request, options) { - options = options || {}; - - return this._descriptors.page.listCollectionIds.createStream( - this._innerApiCalls.listCollectionIds, - request, - options - ); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified any_path resource name string. - * - * @param {String} project - * @param {String} database - * @param {String} document - * @param {String} anyPath - * @returns {String} - */ - anyPathPath(project, database, document, anyPath) { - return this._pathTemplates.anyPathPathTemplate.render({ - project: project, - database: database, - document: document, - any_path: anyPath, - }); - } - - /** - * Return a fully-qualified database_root resource name string. - * - * @param {String} project - * @param {String} database - * @returns {String} - */ - databaseRootPath(project, database) { - return this._pathTemplates.databaseRootPathTemplate.render({ - project: project, - database: database, - }); - } - - /** - * Return a fully-qualified document_path resource name string. - * - * @param {String} project - * @param {String} database - * @param {String} documentPath - * @returns {String} - */ - documentPathPath(project, database, documentPath) { - return this._pathTemplates.documentPathPathTemplate.render({ - project: project, - database: database, - document_path: documentPath, - }); - } - - /** - * Return a fully-qualified document_root resource name string. - * - * @param {String} project - * @param {String} database - * @returns {String} - */ - documentRootPath(project, database) { - return this._pathTemplates.documentRootPathTemplate.render({ - project: project, - database: database, - }); - } - - /** - * Parse the anyPathName from a any_path resource. - * - * @param {String} anyPathName - * A fully-qualified path representing a any_path resources. - * @returns {String} - A string representing the project. - */ - matchProjectFromAnyPathName(anyPathName) { - return this._pathTemplates.anyPathPathTemplate.match(anyPathName).project; - } - - /** - * Parse the anyPathName from a any_path resource. - * - * @param {String} anyPathName - * A fully-qualified path representing a any_path resources. - * @returns {String} - A string representing the database. - */ - matchDatabaseFromAnyPathName(anyPathName) { - return this._pathTemplates.anyPathPathTemplate.match(anyPathName).database; - } - - /** - * Parse the anyPathName from a any_path resource. - * - * @param {String} anyPathName - * A fully-qualified path representing a any_path resources. - * @returns {String} - A string representing the document. - */ - matchDocumentFromAnyPathName(anyPathName) { - return this._pathTemplates.anyPathPathTemplate.match(anyPathName).document; - } - - /** - * Parse the anyPathName from a any_path resource. - * - * @param {String} anyPathName - * A fully-qualified path representing a any_path resources. - * @returns {String} - A string representing the any_path. - */ - matchAnyPathFromAnyPathName(anyPathName) { - return this._pathTemplates.anyPathPathTemplate.match(anyPathName).any_path; - } - - /** - * Parse the databaseRootName from a database_root resource. - * - * @param {String} databaseRootName - * A fully-qualified path representing a database_root resources. - * @returns {String} - A string representing the project. - */ - matchProjectFromDatabaseRootName(databaseRootName) { - return this._pathTemplates.databaseRootPathTemplate.match(databaseRootName) - .project; - } - - /** - * Parse the databaseRootName from a database_root resource. - * - * @param {String} databaseRootName - * A fully-qualified path representing a database_root resources. - * @returns {String} - A string representing the database. - */ - matchDatabaseFromDatabaseRootName(databaseRootName) { - return this._pathTemplates.databaseRootPathTemplate.match(databaseRootName) - .database; - } - - /** - * Parse the documentPathName from a document_path resource. - * - * @param {String} documentPathName - * A fully-qualified path representing a document_path resources. - * @returns {String} - A string representing the project. - */ - matchProjectFromDocumentPathName(documentPathName) { - return this._pathTemplates.documentPathPathTemplate.match(documentPathName) - .project; - } - - /** - * Parse the documentPathName from a document_path resource. - * - * @param {String} documentPathName - * A fully-qualified path representing a document_path resources. - * @returns {String} - A string representing the database. - */ - matchDatabaseFromDocumentPathName(documentPathName) { - return this._pathTemplates.documentPathPathTemplate.match(documentPathName) - .database; - } - - /** - * Parse the documentPathName from a document_path resource. - * - * @param {String} documentPathName - * A fully-qualified path representing a document_path resources. - * @returns {String} - A string representing the document_path. - */ - matchDocumentPathFromDocumentPathName(documentPathName) { - return this._pathTemplates.documentPathPathTemplate.match(documentPathName) - .document_path; - } - - /** - * Parse the documentRootName from a document_root resource. - * - * @param {String} documentRootName - * A fully-qualified path representing a document_root resources. - * @returns {String} - A string representing the project. - */ - matchProjectFromDocumentRootName(documentRootName) { - return this._pathTemplates.documentRootPathTemplate.match(documentRootName) - .project; - } - - /** - * Parse the documentRootName from a document_root resource. - * - * @param {String} documentRootName - * A fully-qualified path representing a document_root resources. - * @returns {String} - A string representing the database. - */ - matchDatabaseFromDocumentRootName(documentRootName) { - return this._pathTemplates.documentRootPathTemplate.match(documentRootName) - .database; - } -} - -module.exports = FirestoreClient; diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts new file mode 100644 index 000000000..bc2766bfe --- /dev/null +++ b/dev/src/v1beta1/firestore_client.ts @@ -0,0 +1,1316 @@ +// Copyright 2019 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as gax from 'google-gax'; +import { + APICallback, + Callback, + CallOptions, + ClientOptions, + Descriptors, + PaginationCallback, + PaginationResponse, +} from 'google-gax'; +import * as path from 'path'; + +import {Transform} from 'stream'; +import * as protosTypes from '../../protos/firestore_v1beta1_proto_api'; +import * as gapicConfig from './firestore_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * The Cloud Firestore service. + * + * This service exposes several types of comparable timestamps: + * + * * `create_time` - The time at which a document was created. Changes only + * when a document is deleted, then re-created. Increases in a strict + * monotonic fashion. + * * `update_time` - The time at which a document was last updated. Changes + * every time a document is modified. Does not change when a write results + * in no modifications. Increases in a strict monotonic fashion. + * * `read_time` - The time at which a particular state was observed. Used + * to denote a consistent snapshot of the database or the time at which a + * Document was observed to not exist. + * * `commit_time` - The time at which the writes in a transaction were + * committed. Any read with an equal or greater `read_time` is guaranteed + * to see the effects of the transaction. + * @class + * @memberof v1beta1 + */ +export class FirestoreClient { + private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _innerApiCalls: {[name: string]: Function}; + private _terminated = false; + auth: gax.GoogleAuth; + firestoreStub: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of FirestoreClient. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + */ + + constructor(opts?: ClientOptions) { + // Ensure that options include the service address and port. + const staticMembers = this.constructor as typeof FirestoreClient; + const servicePath = + opts && opts.servicePath + ? opts.servicePath + : opts && opts.apiEndpoint + ? opts.apiEndpoint + : staticMembers.servicePath; + const port = opts && opts.port ? opts.port : staticMembers.port; + + if (!opts) { + opts = {servicePath, port}; + } + opts.servicePath = opts.servicePath || servicePath; + opts.port = opts.port || port; + 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. + const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = (this.constructor as typeof FirestoreClient).scopes; + const gaxGrpc = new gaxModule.GrpcClient(opts); + + // Save the auth object to the client, for use by other methods. + this.auth = gaxGrpc.auth as gax.GoogleAuth; + + // Determine the client header string. + const clientHeader = [`gax/${gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join( + __dirname, + '..', + '..', + 'protos', + 'protos.json' + ); + const protos = gaxGrpc.loadProto( + opts.fallback ? 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 = { + listDocuments: new gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'documents' + ), + listCollectionIds: new gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'collectionIds' + ), + }; + + // Some of the methods on this service provide streaming responses. + // Provide descriptors for these. + this._descriptors.stream = { + batchGetDocuments: new gaxModule.StreamDescriptor( + gax.StreamType.SERVER_STREAMING + ), + runQuery: new gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING), + write: new gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING), + listen: new gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING), + }; + + // Put together the default options sent with requests. + const defaults = gaxGrpc.constructSettings( + 'google.firestore.v1beta1.Firestore', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')} + ); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; + + // Put together the "service stub" for + // google.firestore.v1beta1.Firestore. + this.firestoreStub = gaxGrpc.createStub( + opts.fallback + ? (protos as protobuf.Root).lookupService( + 'google.firestore.v1beta1.Firestore' + ) + : // tslint:disable-next-line no-any + (protos as any).google.firestore.v1beta1.Firestore, + opts + ) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const firestoreStubMethods = [ + 'getDocument', + 'listDocuments', + 'createDocument', + 'updateDocument', + 'deleteDocument', + 'batchGetDocuments', + 'beginTransaction', + 'commit', + 'rollback', + 'runQuery', + 'write', + 'listen', + 'listCollectionIds', + ]; + + for (const methodName of firestoreStubMethods) { + const innerCallPromise = this.firestoreStub.then( + stub => (...args: Array<{}>) => { + return stub[methodName].apply(stub, args); + }, + (err: Error | null | undefined) => () => { + throw err; + } + ); + + const apiCall = gaxModule.createApiCall( + innerCallPromise, + defaults[methodName], + this._descriptors.page[methodName] || + this._descriptors.stream[methodName] || + this._descriptors.longrunning[methodName] + ); + + this._innerApiCalls[methodName] = ( + argument: {}, + callOptions?: CallOptions, + callback?: APICallback + ) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + return apiCall(argument, callOptions, callback); + }; + } + } + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'firestore.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'firestore.googleapis.com'; + } + + /** + * The port for this API service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/datastore', + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId( + callback?: Callback + ): Promise | void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + 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; + /** + * Gets a single document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Document to get. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * @param {google.firestore.v1beta1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If the 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 the document in a transaction. + * @param {google.protobuf.Timestamp} request.readTime + * Reads the version of the document at the given time. + * This may not be older than 60 seconds. + * @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 [Document]{@link google.firestore.v1beta1.Document}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + getDocument( + request: protosTypes.google.firestore.v1beta1.IGetDocumentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.v1beta1.IDocument, + protosTypes.google.firestore.v1beta1.IGetDocumentRequest | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.firestore.v1beta1.IDocument, + protosTypes.google.firestore.v1beta1.IGetDocumentRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.firestore.v1beta1.IDocument, + protosTypes.google.firestore.v1beta1.IGetDocumentRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + return this._innerApiCalls.getDocument(request, options, callback); + } + 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; + /** + * Creates a new document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. For example: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` + * @param {string} request.collectionId + * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. + * @param {string} request.documentId + * The client-assigned document ID to use for this document. + * + * Optional. If not specified, an ID will be assigned by the service. + * @param {google.firestore.v1beta1.Document} request.document + * Required. The document to create. `name` must not be set. + * @param {google.firestore.v1beta1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + * @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 [Document]{@link google.firestore.v1beta1.Document}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createDocument( + request: protosTypes.google.firestore.v1beta1.ICreateDocumentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.v1beta1.IDocument, + | protosTypes.google.firestore.v1beta1.ICreateDocumentRequest + | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.firestore.v1beta1.IDocument, + protosTypes.google.firestore.v1beta1.ICreateDocumentRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.firestore.v1beta1.IDocument, + protosTypes.google.firestore.v1beta1.ICreateDocumentRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.createDocument(request, options, callback); + } + 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; + /** + * Updates or inserts a document. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.firestore.v1beta1.Document} request.document + * Required. The updated document. + * Creates the document if it does not already exist. + * @param {google.firestore.v1beta1.DocumentMask} request.updateMask + * The fields to update. + * None of the field paths in the mask may contain a reserved name. + * + * If the document exists on the server and has fields not referenced in the + * mask, they are left unchanged. + * Fields referenced in the mask, but not present in the input document, are + * deleted from the document on the server. + * @param {google.firestore.v1beta1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + * @param {google.firestore.v1beta1.Precondition} request.currentDocument + * An optional precondition on the document. + * The request will fail if this is set and not met by the target document. + * @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 [Document]{@link google.firestore.v1beta1.Document}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + updateDocument( + request: protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.v1beta1.IDocument, + | protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest + | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.firestore.v1beta1.IDocument, + protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.firestore.v1beta1.IDocument, + protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + document_name: request.document!.name || '', + }); + return this._innerApiCalls.updateDocument(request, options, callback); + } + 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; + /** + * Deletes a document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Document to delete. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * @param {google.firestore.v1beta1.Precondition} request.currentDocument + * An optional precondition on the document. + * The request will fail if this is set and not met by the target document. + * @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 [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + deleteDocument( + request: protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.protobuf.IEmpty, + | protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest + | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + return this._innerApiCalls.deleteDocument(request, options, callback); + } + 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; + /** + * Starts a new transaction. + * + * @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 {google.firestore.v1beta1.TransactionOptions} request.options + * The options for the transaction. + * Defaults to a read-write transaction. + * @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 [BeginTransactionResponse]{@link google.firestore.v1beta1.BeginTransactionResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + beginTransaction( + request: protosTypes.google.firestore.v1beta1.IBeginTransactionRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.v1beta1.IBeginTransactionResponse, + | protosTypes.google.firestore.v1beta1.IBeginTransactionRequest + | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.firestore.v1beta1.IBeginTransactionResponse, + protosTypes.google.firestore.v1beta1.IBeginTransactionRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.firestore.v1beta1.IBeginTransactionResponse, + protosTypes.google.firestore.v1beta1.IBeginTransactionRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.beginTransaction(request, options, callback); + } + 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; + /** + * Commits a transaction, while optionally updating documents. + * + * @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. + * + * Always executed atomically and in order. + * @param {Buffer} request.transaction + * If set, applies all writes in this transaction, and commits it. + * @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 [CommitResponse]{@link google.firestore.v1beta1.CommitResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + commit( + request: protosTypes.google.firestore.v1beta1.ICommitRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.v1beta1.ICommitResponse, + protosTypes.google.firestore.v1beta1.ICommitRequest | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.firestore.v1beta1.ICommitResponse, + protosTypes.google.firestore.v1beta1.ICommitRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.firestore.v1beta1.ICommitResponse, + protosTypes.google.firestore.v1beta1.ICommitRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.commit(request, options, callback); + } + 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; + /** + * Rolls back a transaction. + * + * @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 {Buffer} request.transaction + * Required. The transaction to roll back. + * @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 [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + rollback( + request: protosTypes.google.firestore.v1beta1.IRollbackRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.v1beta1.IRollbackRequest | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.v1beta1.IRollbackRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.protobuf.IEmpty, + protosTypes.google.firestore.v1beta1.IRollbackRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.rollback(request, options, callback); + } + + /** + * Gets multiple documents. + * + * Documents returned by this method are not guaranteed to be returned in the + * same order that they were requested. + * + * @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 {string[]} request.documents + * The names of the documents to retrieve. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * The request will fail if any of the document is not a child resource of the + * given `database`. Duplicate names will be elided. + * @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.firestore.v1beta1.TransactionOptions} request.newTransaction + * Starts a new transaction and reads the documents. + * Defaults to a read-only transaction. + * The new transaction ID will be returned as the first response in the + * stream. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 60 seconds. + * @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 [BatchGetDocumentsResponse]{@link google.firestore.v1beta1.BatchGetDocumentsResponse} on 'data' event. + */ + batchGetDocuments( + request?: protosTypes.google.firestore.v1beta1.IBatchGetDocumentsRequest, + options?: gax.CallOptions + ): gax.CancellableStream { + request = request || {}; + options = options || {}; + return this._innerApiCalls.batchGetDocuments(request, options); + } + + /** + * Runs a query. + * + * @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 {google.firestore.v1beta1.StructuredQuery} request.structuredQuery + * A structured query. + * @param {Buffer} request.transaction + * Reads documents in a transaction. + * @param {google.firestore.v1beta1.TransactionOptions} request.newTransaction + * Starts a new transaction and reads the documents. + * Defaults to a read-only transaction. + * The new transaction ID will be returned as the first response in the + * stream. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 60 seconds. + * @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 [RunQueryResponse]{@link google.firestore.v1beta1.RunQueryResponse} on 'data' event. + */ + runQuery( + request?: protosTypes.google.firestore.v1beta1.IRunQueryRequest, + options?: gax.CallOptions + ): gax.CancellableStream { + request = request || {}; + options = options || {}; + return this._innerApiCalls.runQuery(request, options); + } + + /** + * Streams batches of document updates and deletes, in order. + * + * @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 is both readable and writable. It accepts objects + * representing [WriteRequest]{@link google.firestore.v1beta1.WriteRequest} for write() method, and + * will emit objects representing [WriteResponse]{@link google.firestore.v1beta1.WriteResponse} on 'data' event asynchronously. + */ + write(options?: gax.CallOptions): gax.CancellableStream { + options = options || {}; + return this._innerApiCalls.write(options); + } + + /** + * Listens to changes. + * + * @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 is both readable and writable. It accepts objects + * representing [ListenRequest]{@link google.firestore.v1beta1.ListenRequest} for write() method, and + * will emit objects representing [ListenResponse]{@link google.firestore.v1beta1.ListenResponse} on 'data' event asynchronously. + */ + listen(options?: gax.CallOptions): gax.CancellableStream { + options = options || {}; + return this._innerApiCalls.listen({}, options); + } + + 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; + /** + * Lists documents. + * + * @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, [Document.create_time][google.firestore.v1beta1.Document.create_time], + * or [Document.update_time][google.firestore.v1beta1.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 {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Document]{@link google.firestore.v1beta1.Document}. + * 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 [Document]{@link google.firestore.v1beta1.Document} 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 [ListDocumentsRequest]{@link google.firestore.v1beta1.ListDocumentsRequest} + * 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 + * [ListDocumentsResponse]{@link google.firestore.v1beta1.ListDocumentsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listDocuments( + request: protosTypes.google.firestore.v1beta1.IListDocumentsRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.v1beta1.IDocument[], + protosTypes.google.firestore.v1beta1.IListDocumentsRequest | null, + protosTypes.google.firestore.v1beta1.IListDocumentsResponse + >, + callback?: Callback< + protosTypes.google.firestore.v1beta1.IDocument[], + protosTypes.google.firestore.v1beta1.IListDocumentsRequest | null, + protosTypes.google.firestore.v1beta1.IListDocumentsResponse + > + ): Promise< + [ + protosTypes.google.firestore.v1beta1.IDocument[], + protosTypes.google.firestore.v1beta1.IListDocumentsRequest | null, + protosTypes.google.firestore.v1beta1.IListDocumentsResponse + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listDocuments(request, options, callback); + } + + /** + * Equivalent to {@link listDocuments}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listDocuments} 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` 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, [Document.create_time][google.firestore.v1beta1.Document.create_time], + * or [Document.update_time][google.firestore.v1beta1.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 {Stream} + * An object stream which emits an object representing [Document]{@link google.firestore.v1beta1.Document} on 'data' event. + */ + listDocumentsStream( + request?: protosTypes.google.firestore.v1beta1.IListDocumentsRequest, + options?: gax.CallOptions | {} + ): Transform { + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listDocuments.createStream( + this._innerApiCalls.listDocuments as gax.GaxCall, + request, + callSettings + ); + } + 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; + /** + * Lists all the collection IDs underneath a document. + * + * @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 + * [ListCollectionIdsResponse][google.firestore.v1beta1.ListCollectionIdsResponse]. + * @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 string. + * 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 string 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 [ListCollectionIdsRequest]{@link google.firestore.v1beta1.ListCollectionIdsRequest} + * 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 + * [ListCollectionIdsResponse]{@link google.firestore.v1beta1.ListCollectionIdsResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + listCollectionIds( + request: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + string[], + protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest | null, + protosTypes.google.firestore.v1beta1.IListCollectionIdsResponse + >, + callback?: Callback< + string[], + protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest | null, + protosTypes.google.firestore.v1beta1.IListCollectionIdsResponse + > + ): Promise< + [ + string[], + protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest | null, + protosTypes.google.firestore.v1beta1.IListCollectionIdsResponse + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.listCollectionIds(request, options, callback); + } + + /** + * Equivalent to {@link listCollectionIds}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listCollectionIds} 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 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 + * [ListCollectionIdsResponse][google.firestore.v1beta1.ListCollectionIdsResponse]. + * @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 string on 'data' event. + */ + listCollectionIdsStream( + request?: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest, + options?: gax.CallOptions | {} + ): Transform { + request = request || {}; + const callSettings = new gax.CallSettings(options); + return this._descriptors.page.listCollectionIds.createStream( + this._innerApiCalls.listCollectionIds as gax.GaxCall, + request, + callSettings + ); + } + + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close(): Promise { + if (!this._terminated) { + return this.firestoreStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/dev/src/v1beta1/firestore_client_config.json b/dev/src/v1beta1/firestore_client_config.json index 8c407c338..1166bff74 100644 --- a/dev/src/v1beta1/firestore_client_config.json +++ b/dev/src/v1beta1/firestore_client_config.json @@ -2,11 +2,11 @@ "interfaces": { "google.firestore.v1beta1.Firestore": { "retry_codes": { + "non_idempotent": [], "idempotent": [ "DEADLINE_EXCEEDED", "UNAVAILABLE" - ], - "non_idempotent": [] + ] }, "retry_params": { "default": { @@ -14,18 +14,9 @@ "retry_delay_multiplier": 1.3, "max_retry_delay_millis": 60000, "initial_rpc_timeout_millis": 20000, - "rpc_timeout_multiplier": 1.0, + "rpc_timeout_multiplier": 1, "max_rpc_timeout_millis": 20000, "total_timeout_millis": 600000 - }, - "streaming": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 300000, - "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 300000, - "total_timeout_millis": 600000 } }, "methods": { @@ -57,7 +48,7 @@ "BatchGetDocuments": { "timeout_millis": 300000, "retry_codes_name": "idempotent", - "retry_params_name": "streaming" + "retry_params_name": "default" }, "BeginTransaction": { "timeout_millis": 60000, @@ -75,19 +66,19 @@ "retry_params_name": "default" }, "RunQuery": { - "timeout_millis": 60000, + "timeout_millis": 300000, "retry_codes_name": "idempotent", - "retry_params_name": "streaming" + "retry_params_name": "default" }, "Write": { "timeout_millis": 86400000, "retry_codes_name": "non_idempotent", - "retry_params_name": "streaming" + "retry_params_name": "default" }, "Listen": { "timeout_millis": 86400000, "retry_codes_name": "idempotent", - "retry_params_name": "streaming" + "retry_params_name": "default" }, "ListCollectionIds": { "timeout_millis": 60000, diff --git a/dev/src/v1beta1/firestore_proto_list.json b/dev/src/v1beta1/firestore_proto_list.json index 1ddacc0df..f1254d305 100644 --- a/dev/src/v1beta1/firestore_proto_list.json +++ b/dev/src/v1beta1/firestore_proto_list.json @@ -1,3 +1,7 @@ [ + "../../protos/google/firestore/v1beta1/common.proto", + "../../protos/google/firestore/v1beta1/document.proto", + "../../protos/google/firestore/v1beta1/write.proto", + "../../protos/google/firestore/v1beta1/query.proto", "../../protos/google/firestore/v1beta1/firestore.proto" ] diff --git a/dev/src/v1beta1/index.js b/dev/src/v1beta1/index.ts similarity index 56% rename from dev/src/v1beta1/index.js rename to dev/src/v1beta1/index.ts index ff5b61255..9a03699e8 100644 --- a/dev/src/v1beta1/index.js +++ b/dev/src/v1beta1/index.ts @@ -11,12 +11,15 @@ // 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** -'use strict'; - -const FirestoreClient = require('./firestore_client'); +import {FirestoreClient} from './firestore_client'; +export {FirestoreClient}; -// For backwards compatibility, we continue to support the default -// export. +// Doing something really horrible for reverse compatibility with original JavaScript exports +const existingExports = module.exports; module.exports = FirestoreClient; -module.exports.FirestoreClient = FirestoreClient; +module.exports = Object.assign(module.exports, existingExports); diff --git a/dev/src/watch.ts b/dev/src/watch.ts index c646f8243..24caca2dc 100644 --- a/dev/src/watch.ts +++ b/dev/src/watch.ts @@ -17,7 +17,7 @@ import * as assert from 'assert'; import * as rbtree from 'functional-red-black-tree'; -import {google} from '../protos/firestore_proto_api'; +import {google} from '../protos/firestore_v1_proto_api'; import {ExponentialBackoff} from './backoff'; import {DocumentSnapshotBuilder, QueryDocumentSnapshot} from './document'; import {DocumentChange, DocumentChangeType} from './document-change'; diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 61bf6bf75..884c0e373 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -16,7 +16,7 @@ import * as assert from 'assert'; -import {google} from '../protos/firestore_proto_api'; +import {google} from '../protos/firestore_v1_proto_api'; import { DocumentMask, DocumentSnapshot, diff --git a/dev/synth.metadata b/dev/synth.metadata index 267577afb..f9f21d2d4 100644 --- a/dev/synth.metadata +++ b/dev/synth.metadata @@ -1,19 +1,12 @@ { - "updateTime": "2019-11-09T12:16:07.654763Z", + "updateTime": "2019-12-15T06:29:34.857861Z", "sources": [ - { - "generator": { - "name": "artman", - "version": "0.41.1", - "dockerImage": "googleapis/artman@sha256:545c758c76c3f779037aa259023ec3d1ef2d57d2c8cd00a222cb187d63ceac5e" - } - }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "34e661f58d58fa57da8ed113a3d8bb3de26b307d", - "internalRef": "279417429" + "sha": "2085a0d3c76180ee843cf2ecef2b94ca5266be31", + "internalRef": "285233245" } }, { @@ -30,9 +23,8 @@ "source": "googleapis", "apiName": "firestore-admin", "apiVersion": "v1", - "language": "nodejs", - "generator": "gapic", - "config": "google/firestore/admin/artman_firestore_v1.yaml" + "language": "typescript", + "generator": "gapic-generator-typescript" } }, { @@ -40,9 +32,8 @@ "source": "googleapis", "apiName": "firestore", "apiVersion": "v1beta1", - "language": "nodejs", - "generator": "gapic", - "config": "google/firestore/artman_firestore.yaml" + "language": "typescript", + "generator": "gapic-generator-typescript" } }, { @@ -50,9 +41,8 @@ "source": "googleapis", "apiName": "firestore", "apiVersion": "v1", - "language": "nodejs", - "generator": "gapic", - "config": "google/firestore/artman_firestore_v1.yaml" + "language": "typescript", + "generator": "gapic-generator-typescript" } } ] diff --git a/dev/system-test/.eslintrc.yml b/dev/system-test/.eslintrc.yml new file mode 100644 index 000000000..dc5d9b017 --- /dev/null +++ b/dev/system-test/.eslintrc.yml @@ -0,0 +1,4 @@ +--- +env: + mocha: true + diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 3954e750b..5fa028b31 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -27,6 +27,7 @@ import { QuerySnapshot, setLogFunction, Timestamp, + WriteResult, } from '../src'; import {autoId, Deferred} from '../src/util'; import {verifyInstance} from '../test/util/helpers'; diff --git a/dev/test/document.ts b/dev/test/document.ts index 9bf885f8c..4a6f62c27 100644 --- a/dev/test/document.ts +++ b/dev/test/document.ts @@ -14,7 +14,7 @@ import {expect} from 'chai'; -import * as proto from '../protos/firestore_proto_api'; +import * as proto from '../protos/firestore_v1_proto_api'; import { DocumentReference, FieldPath, diff --git a/dev/test/gapic-v1.js b/dev/test/gapic-firestore-v1.ts similarity index 56% rename from dev/test/gapic-v1.js rename to dev/test/gapic-firestore-v1.ts index f197fddff..d598e2fbb 100644 --- a/dev/test/gapic-v1.js +++ b/dev/test/gapic-firestore-v1.ts @@ -11,76 +11,134 @@ // 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** -'use strict'; - -const assert = require('assert'); -const {PassThrough} = require('stream'); - +import * as assert from 'assert'; +import * as protosTypes from '../protos/firestore_v1_proto_api'; const firestoreModule = require('../src'); +import {PassThrough} from 'stream'; + const FAKE_STATUS_CODE = 1; -const error = new Error(); -error.code = FAKE_STATUS_CODE; +class FakeError { + name: string; + message: string; + code: number; + constructor(n: number) { + this.name = 'fakeName'; + this.message = 'fake message'; + this.code = n; + } +} +const error = new FakeError(FAKE_STATUS_CODE); +export interface Callback { + (err: FakeError | null, response?: {} | null): void; +} -describe('FirestoreClient', () => { +export class Operation { + constructor() {} + promise() {} +} +function mockSimpleGrpcMethod( + expectedRequest: {}, + response: {} | null, + error: FakeError | null +) { + return (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, expectedRequest); + if (error) { + callback(error); + } else if (response) { + callback(null, response); + } else { + callback(null); + } + }; +} +function mockServerStreamingGrpcMethod( + expectedRequest: {}, + response: {} | null, + error: FakeError | null +) { + return (actualRequest: {}) => { + assert.deepStrictEqual(actualRequest, expectedRequest); + const mockStream = new PassThrough({ + objectMode: true, + transform: (chunk: {}, enc: {}, callback: Callback) => { + if (error) { + callback(error); + } else { + callback(null, response); + } + }, + }); + return mockStream; + }; +} +function mockBidiStreamingGrpcMethod( + expectedRequest: {}, + response: {} | null, + error: FakeError | null +) { + return () => { + const mockStream = new PassThrough({ + objectMode: true, + transform: (chunk: {}, enc: {}, callback: Callback) => { + assert.deepStrictEqual(chunk, expectedRequest); + if (error) { + callback(error); + } else { + callback(null, response); + } + }, + }); + return mockStream; + }; +} +describe('v1.FirestoreClient', () => { it('has servicePath', () => { const servicePath = firestoreModule.v1.FirestoreClient.servicePath; assert(servicePath); }); - it('has apiEndpoint', () => { const apiEndpoint = firestoreModule.v1.FirestoreClient.apiEndpoint; assert(apiEndpoint); }); - it('has port', () => { const port = firestoreModule.v1.FirestoreClient.port; assert(port); assert(typeof port === 'number'); }); - - it('should create a client with no options', () => { + it('should create a client with no option', () => { const client = new firestoreModule.v1.FirestoreClient(); assert(client); }); - it('should create a client with gRPC fallback', () => { - const client = new firestoreModule.v1.FirestoreClient({fallback: true}); + const client = new firestoreModule.v1.FirestoreClient({ + fallback: true, + }); assert(client); }); - describe('getDocument', () => { it('invokes getDocument without error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedName = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const request = { - name: formattedName, - }; - + const request: protosTypes.google.firestore.v1.IGetDocumentRequest = {}; // Mock response - const name2 = 'name2-1052831874'; - const expectedResponse = { - name: name2, - }; - - // Mock Grpc layer + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.getDocument = mockSimpleGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - - client.getDocument(request, (err, response) => { + client.getDocument(request, (err: {}, response: {}) => { assert.ifError(err); assert.deepStrictEqual(response, expectedResponse); done(); @@ -92,152 +150,41 @@ describe('FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - - // Mock request - const formattedName = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const request = { - name: formattedName, - }; - - // Mock Grpc layer - client._innerApiCalls.getDocument = mockSimpleGrpcMethod( - request, - null, - error - ); - - client.getDocument(request, (err, response) => { - assert(err instanceof Error); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - - describe('listDocuments', () => { - it('invokes listDocuments without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const formattedParent = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const collectionId = 'collectionId-821242276'; - const request = { - parent: formattedParent, - collectionId: collectionId, - }; - + const request: protosTypes.google.firestore.v1.IGetDocumentRequest = {}; // Mock response - const nextPageToken = ''; - const documentsElement = {}; - const documents = [documentsElement]; - const expectedResponse = { - nextPageToken: nextPageToken, - documents: documents, - }; - - // Mock Grpc layer - client._innerApiCalls.listDocuments = ( - actualRequest, - options, - callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse.documents); - }; - - client.listDocuments(request, (err, response) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse.documents); - done(); - }); - }); - - it('invokes listDocuments with error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - - // Mock request - const formattedParent = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const collectionId = 'collectionId-821242276'; - const request = { - parent: formattedParent, - collectionId: collectionId, - }; - - // Mock Grpc layer - client._innerApiCalls.listDocuments = mockSimpleGrpcMethod( + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getDocument = mockSimpleGrpcMethod( request, null, error ); - - client.listDocuments(request, (err, response) => { - assert(err instanceof Error); + client.getDocument(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); }); }); - describe('createDocument', () => { it('invokes createDocument without error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedParent = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const collectionId = 'collectionId-821242276'; - const documentId = 'documentId506676927'; - const document = {}; - const request = { - parent: formattedParent, - collectionId: collectionId, - documentId: documentId, - document: document, - }; - + const request: protosTypes.google.firestore.v1.ICreateDocumentRequest = {}; // Mock response - const name = 'name3373707'; - const expectedResponse = { - name: name, - }; - - // Mock Grpc layer + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.createDocument = mockSimpleGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - - client.createDocument(request, (err, response) => { + client.createDocument(request, (err: {}, response: {}) => { assert.ifError(err); assert.deepStrictEqual(response, expectedResponse); done(); @@ -249,68 +196,43 @@ describe('FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedParent = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const collectionId = 'collectionId-821242276'; - const documentId = 'documentId506676927'; - const document = {}; - const request = { - parent: formattedParent, - collectionId: collectionId, - documentId: documentId, - document: document, - }; - - // Mock Grpc layer + const request: protosTypes.google.firestore.v1.ICreateDocumentRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.createDocument = mockSimpleGrpcMethod( request, null, error ); - - client.createDocument(request, (err, response) => { - assert(err instanceof Error); + client.createDocument(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); }); }); - describe('updateDocument', () => { it('invokes updateDocument without error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const document = {}; - const updateMask = {}; - const request = { - document: document, - updateMask: updateMask, - }; - + const request: protosTypes.google.firestore.v1.IUpdateDocumentRequest = {}; + request.document = {}; + request.document.name = ''; // Mock response - const name = 'name3373707'; - const expectedResponse = { - name: name, - }; - - // Mock Grpc layer + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.updateDocument = mockSimpleGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - - client.updateDocument(request, (err, response) => { + client.updateDocument(request, (err: {}, response: {}) => { assert.ifError(err); assert.deepStrictEqual(response, expectedResponse); done(); @@ -322,54 +244,45 @@ describe('FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const document = {}; - const updateMask = {}; - const request = { - document: document, - updateMask: updateMask, - }; - - // Mock Grpc layer + const request: protosTypes.google.firestore.v1.IUpdateDocumentRequest = {}; + request.document = {}; + request.document.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.updateDocument = mockSimpleGrpcMethod( request, null, error ); - - client.updateDocument(request, (err, response) => { - assert(err instanceof Error); + client.updateDocument(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); }); }); - describe('deleteDocument', () => { it('invokes deleteDocument without error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedName = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' + const request: protosTypes.google.firestore.v1.IDeleteDocumentRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteDocument = mockSimpleGrpcMethod( + request, + expectedResponse, + null ); - const request = { - name: formattedName, - }; - - // Mock Grpc layer - client._innerApiCalls.deleteDocument = mockSimpleGrpcMethod(request); - - client.deleteDocument(request, err => { + client.deleteDocument(request, (err: {}, response: {}) => { assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); done(); }); }); @@ -379,661 +292,486 @@ describe('FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedName = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const request = { - name: formattedName, - }; - - // Mock Grpc layer + const request: protosTypes.google.firestore.v1.IDeleteDocumentRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.deleteDocument = mockSimpleGrpcMethod( request, null, error ); - - client.deleteDocument(request, err => { - assert(err instanceof Error); + client.deleteDocument(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); done(); }); }); }); - - describe('batchGetDocuments', () => { - it('invokes batchGetDocuments without error', done => { + describe('beginTransaction', () => { + it('invokes beginTransaction without error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const documents = []; - const request = { - database: formattedDatabase, - documents: documents, - }; - + const request: protosTypes.google.firestore.v1.IBeginTransactionRequest = {}; // Mock response - const missing = 'missing1069449574'; - const transaction = '-34'; - const expectedResponse = { - missing: missing, - transaction: transaction, - }; - - // Mock Grpc layer - client._innerApiCalls.batchGetDocuments = mockServerStreamingGrpcMethod( + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.beginTransaction = mockSimpleGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - - const stream = client.batchGetDocuments(request); - stream.on('data', response => { + client.beginTransaction(request, (err: {}, response: {}) => { + assert.ifError(err); assert.deepStrictEqual(response, expectedResponse); done(); }); - stream.on('error', err => { - done(err); - }); - - stream.write(); }); - it('invokes batchGetDocuments with error', done => { + it('invokes beginTransaction with error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const documents = []; - const request = { - database: formattedDatabase, - documents: documents, - }; - - // Mock Grpc layer - client._innerApiCalls.batchGetDocuments = mockServerStreamingGrpcMethod( + const request: protosTypes.google.firestore.v1.IBeginTransactionRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.beginTransaction = mockSimpleGrpcMethod( request, null, error ); - - const stream = client.batchGetDocuments(request); - stream.on('data', () => { - assert.fail(); - }); - stream.on('error', err => { - assert(err instanceof Error); + client.beginTransaction(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); done(); }); - - stream.write(); }); }); - - describe('beginTransaction', () => { - it('invokes beginTransaction without error', done => { + describe('commit', () => { + it('invokes commit without error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const request = { - database: formattedDatabase, - }; - + const request: protosTypes.google.firestore.v1.ICommitRequest = {}; // Mock response - const transaction = '-34'; - const expectedResponse = { - transaction: transaction, - }; - - // Mock Grpc layer - client._innerApiCalls.beginTransaction = mockSimpleGrpcMethod( + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.commit = mockSimpleGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - - client.beginTransaction(request, (err, response) => { + client.commit(request, (err: {}, response: {}) => { assert.ifError(err); assert.deepStrictEqual(response, expectedResponse); done(); }); }); - it('invokes beginTransaction with error', done => { + it('invokes commit with error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const request = { - database: formattedDatabase, - }; - - // Mock Grpc layer - client._innerApiCalls.beginTransaction = mockSimpleGrpcMethod( - request, - null, - error - ); - - client.beginTransaction(request, (err, response) => { - assert(err instanceof Error); + const request: protosTypes.google.firestore.v1.ICommitRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.commit = mockSimpleGrpcMethod(request, null, error); + client.commit(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); }); }); - - describe('commit', () => { - it('invokes commit without error', done => { + describe('rollback', () => { + it('invokes rollback without error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const writes = []; - const request = { - database: formattedDatabase, - writes: writes, - }; - + const request: protosTypes.google.firestore.v1.IRollbackRequest = {}; // Mock response const expectedResponse = {}; - - // Mock Grpc layer - client._innerApiCalls.commit = mockSimpleGrpcMethod( + // Mock gRPC layer + client._innerApiCalls.rollback = mockSimpleGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - - client.commit(request, (err, response) => { + client.rollback(request, (err: {}, response: {}) => { assert.ifError(err); assert.deepStrictEqual(response, expectedResponse); done(); }); }); - it('invokes commit with error', done => { + it('invokes rollback with error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' + const request: protosTypes.google.firestore.v1.IRollbackRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.rollback = mockSimpleGrpcMethod( + request, + null, + error ); - const writes = []; - const request = { - database: formattedDatabase, - writes: writes, - }; - - // Mock Grpc layer - client._innerApiCalls.commit = mockSimpleGrpcMethod(request, null, error); - - client.commit(request, (err, response) => { - assert(err instanceof Error); + client.rollback(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); }); }); - - describe('rollback', () => { - it('invokes rollback without error', done => { + describe('batchGetDocuments', () => { + it('invokes batchGetDocuments without error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.batchGetDocuments = mockServerStreamingGrpcMethod( + request, + expectedResponse, + null ); - const transaction = '-34'; - const request = { - database: formattedDatabase, - transaction: transaction, - }; - - // Mock Grpc layer - client._innerApiCalls.rollback = mockSimpleGrpcMethod(request); - - client.rollback(request, err => { - assert.ifError(err); + const stream = client.batchGetDocuments(request); + stream.on('data', (response: {}) => { + assert.deepStrictEqual(response, expectedResponse); done(); }); + stream.on('error', (err: FakeError) => { + done(err); + }); + stream.write(); }); - - it('invokes rollback with error', done => { + it('invokes batchGetDocuments with error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const transaction = '-34'; - const request = { - database: formattedDatabase, - transaction: transaction, - }; - - // Mock Grpc layer - client._innerApiCalls.rollback = mockSimpleGrpcMethod( + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.batchGetDocuments = mockServerStreamingGrpcMethod( request, null, error ); - - client.rollback(request, err => { - assert(err instanceof Error); + const stream = client.batchGetDocuments(request); + stream.on('data', () => { + assert.fail(); + }); + stream.on('error', (err: FakeError) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); done(); }); + stream.write(); }); }); - describe('runQuery', () => { it('invokes runQuery without error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedParent = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const request = { - parent: formattedParent, - }; - + const request = {}; // Mock response - const transaction = '-34'; - const skippedResults = 880286183; - const expectedResponse = { - transaction: transaction, - skippedResults: skippedResults, - }; - - // Mock Grpc layer + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.runQuery = mockServerStreamingGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - const stream = client.runQuery(request); - stream.on('data', response => { + stream.on('data', (response: {}) => { assert.deepStrictEqual(response, expectedResponse); done(); }); - stream.on('error', err => { + stream.on('error', (err: FakeError) => { done(err); }); - stream.write(); }); - it('invokes runQuery with error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedParent = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const request = { - parent: formattedParent, - }; - - // Mock Grpc layer + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.runQuery = mockServerStreamingGrpcMethod( request, null, error ); - const stream = client.runQuery(request); stream.on('data', () => { assert.fail(); }); - stream.on('error', err => { - assert(err instanceof Error); + stream.on('error', (err: FakeError) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); done(); }); - stream.write(); }); }); - describe('write', () => { it('invokes write without error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const request = { - database: formattedDatabase, - }; - + const request = {}; // Mock response - const streamId = 'streamId-315624902'; - const streamToken = '122'; - const expectedResponse = { - streamId: streamId, - streamToken: streamToken, - }; - - // Mock Grpc layer + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.write = mockBidiStreamingGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - const stream = client .write() - .on('data', response => { + .on('data', (response: {}) => { assert.deepStrictEqual(response, expectedResponse); done(); }) - .on('error', err => { + .on('error', (err: FakeError) => { done(err); }); - stream.write(request); }); - it('invokes write with error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const request = { - database: formattedDatabase, - }; - - // Mock Grpc layer + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.write = mockBidiStreamingGrpcMethod( request, null, error ); - const stream = client .write() .on('data', () => { assert.fail(); }) - .on('error', err => { - assert(err instanceof Error); + .on('error', (err: FakeError) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); done(); }); - stream.write(request); }); }); - describe('listen', () => { it('invokes listen without error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const request = { - database: formattedDatabase, - }; - + const request = {}; // Mock response const expectedResponse = {}; - - // Mock Grpc layer + // Mock gRPC layer client._innerApiCalls.listen = mockBidiStreamingGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - const stream = client .listen() - .on('data', response => { + .on('data', (response: {}) => { assert.deepStrictEqual(response, expectedResponse); done(); }) - .on('error', err => { + .on('error', (err: FakeError) => { done(err); }); - stream.write(request); }); - it('invokes listen with error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const request = { - database: formattedDatabase, - }; - - // Mock Grpc layer + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.listen = mockBidiStreamingGrpcMethod( request, null, error ); - const stream = client .listen() .on('data', () => { assert.fail(); }) - .on('error', err => { - assert(err instanceof Error); + .on('error', (err: FakeError) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); done(); }); - stream.write(request); }); }); - - describe('listCollectionIds', () => { - it('invokes listCollectionIds without error', done => { + describe('listDocuments', () => { + it('invokes listDocuments without error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedParent = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const request = { - parent: formattedParent, - }; - + const request: protosTypes.google.firestore.v1.IListDocumentsRequest = {}; // Mock response - const nextPageToken = ''; - const collectionIdsElement = 'collectionIdsElement1368994900'; - const collectionIds = [collectionIdsElement]; - const expectedResponse = { - nextPageToken: nextPageToken, - collectionIds: collectionIds, - }; - + const expectedResponse = {}; // Mock Grpc layer - client._innerApiCalls.listCollectionIds = ( - actualRequest, - options, - callback + client._innerApiCalls.listDocuments = ( + actualRequest: {}, + options: {}, + callback: Callback ) => { assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse.collectionIds); + callback(null, expectedResponse); }; - - client.listCollectionIds(request, (err, response) => { + client.listDocuments(request, (err: FakeError, response: {}) => { assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse.collectionIds); + assert.deepStrictEqual(response, expectedResponse); done(); }); }); - - it('invokes listCollectionIds with error', done => { + }); + describe('listDocumentsStream', () => { + it('invokes listDocumentsStream without error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedParent = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const request = { - parent: formattedParent, + const request: protosTypes.google.firestore.v1.IListDocumentsRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listDocuments = ( + actualRequest: {}, + options: {}, + callback: Callback + ) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); }; - + const stream = client + .listDocumentsStream(request, {}) + .on('data', (response: {}) => { + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + .on('error', (err: FakeError) => { + done(err); + }); + stream.write(request); + }); + }); + describe('listCollectionIds', () => { + it('invokes listCollectionIds without error', done => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.v1.IListCollectionIdsRequest = {}; + // Mock response + const expectedResponse = {}; // Mock Grpc layer - client._innerApiCalls.listCollectionIds = mockSimpleGrpcMethod( - request, - null, - error - ); - - client.listCollectionIds(request, (err, response) => { - assert(err instanceof Error); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); + client._innerApiCalls.listCollectionIds = ( + actualRequest: {}, + options: {}, + callback: Callback + ) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listCollectionIds(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); done(); }); }); }); -}); - -function mockSimpleGrpcMethod(expectedRequest, response, error) { - return function(actualRequest, options, callback) { - assert.deepStrictEqual(actualRequest, expectedRequest); - if (error) { - callback(error); - } else if (response) { - callback(null, response); - } else { - callback(null); - } - }; -} - -function mockServerStreamingGrpcMethod(expectedRequest, response, error) { - return actualRequest => { - assert.deepStrictEqual(actualRequest, expectedRequest); - const mockStream = new PassThrough({ - objectMode: true, - transform: (chunk, enc, callback) => { - if (error) { - callback(error); - } else { - callback(null, response); - } - }, - }); - return mockStream; - }; -} - -function mockBidiStreamingGrpcMethod(expectedRequest, response, error) { - return () => { - const mockStream = new PassThrough({ - objectMode: true, - transform: (chunk, enc, callback) => { - assert.deepStrictEqual(chunk, expectedRequest); - if (error) { - callback(error); - } else { - callback(null, response); - } - }, + describe('listCollectionIdsStream', () => { + it('invokes listCollectionIdsStream without error', done => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.v1.IListCollectionIdsRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listCollectionIds = ( + actualRequest: {}, + options: {}, + callback: Callback + ) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client + .listCollectionIdsStream(request, {}) + .on('data', (response: {}) => { + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + .on('error', (err: FakeError) => { + done(err); + }); + stream.write(request); }); - return mockStream; - }; -} + }); +}); diff --git a/dev/test/gapic-v1beta1.js b/dev/test/gapic-firestore-v1beta1.ts similarity index 57% rename from dev/test/gapic-v1beta1.js rename to dev/test/gapic-firestore-v1beta1.ts index b2f6e333d..f45876f46 100644 --- a/dev/test/gapic-v1beta1.js +++ b/dev/test/gapic-firestore-v1beta1.ts @@ -11,78 +11,134 @@ // 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** -'use strict'; - -const assert = require('assert'); -const {PassThrough} = require('stream'); - +import * as assert from 'assert'; +import * as protosTypes from '../protos/firestore_v1beta1_proto_api'; const firestoreModule = require('../src'); +import {PassThrough} from 'stream'; + const FAKE_STATUS_CODE = 1; -const error = new Error(); -error.code = FAKE_STATUS_CODE; +class FakeError { + name: string; + message: string; + code: number; + constructor(n: number) { + this.name = 'fakeName'; + this.message = 'fake message'; + this.code = n; + } +} +const error = new FakeError(FAKE_STATUS_CODE); +export interface Callback { + (err: FakeError | null, response?: {} | null): void; +} -describe('FirestoreClient', () => { +export class Operation { + constructor() {} + promise() {} +} +function mockSimpleGrpcMethod( + expectedRequest: {}, + response: {} | null, + error: FakeError | null +) { + return (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, expectedRequest); + if (error) { + callback(error); + } else if (response) { + callback(null, response); + } else { + callback(null); + } + }; +} +function mockServerStreamingGrpcMethod( + expectedRequest: {}, + response: {} | null, + error: FakeError | null +) { + return (actualRequest: {}) => { + assert.deepStrictEqual(actualRequest, expectedRequest); + const mockStream = new PassThrough({ + objectMode: true, + transform: (chunk: {}, enc: {}, callback: Callback) => { + if (error) { + callback(error); + } else { + callback(null, response); + } + }, + }); + return mockStream; + }; +} +function mockBidiStreamingGrpcMethod( + expectedRequest: {}, + response: {} | null, + error: FakeError | null +) { + return () => { + const mockStream = new PassThrough({ + objectMode: true, + transform: (chunk: {}, enc: {}, callback: Callback) => { + assert.deepStrictEqual(chunk, expectedRequest); + if (error) { + callback(error); + } else { + callback(null, response); + } + }, + }); + return mockStream; + }; +} +describe('v1beta1.FirestoreClient', () => { it('has servicePath', () => { const servicePath = firestoreModule.v1beta1.FirestoreClient.servicePath; assert(servicePath); }); - it('has apiEndpoint', () => { const apiEndpoint = firestoreModule.v1beta1.FirestoreClient.apiEndpoint; assert(apiEndpoint); }); - it('has port', () => { const port = firestoreModule.v1beta1.FirestoreClient.port; assert(port); assert(typeof port === 'number'); }); - - it('should create a client with no options', () => { + it('should create a client with no option', () => { const client = new firestoreModule.v1beta1.FirestoreClient(); assert(client); }); - it('should create a client with gRPC fallback', () => { const client = new firestoreModule.v1beta1.FirestoreClient({ fallback: true, }); assert(client); }); - describe('getDocument', () => { it('invokes getDocument without error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedName = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const request = { - name: formattedName, - }; - + const request: protosTypes.google.firestore.v1beta1.IGetDocumentRequest = {}; // Mock response - const name2 = 'name2-1052831874'; - const expectedResponse = { - name: name2, - }; - - // Mock Grpc layer + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.getDocument = mockSimpleGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - - client.getDocument(request, (err, response) => { + client.getDocument(request, (err: {}, response: {}) => { assert.ifError(err); assert.deepStrictEqual(response, expectedResponse); done(); @@ -94,152 +150,41 @@ describe('FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - - // Mock request - const formattedName = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const request = { - name: formattedName, - }; - - // Mock Grpc layer - client._innerApiCalls.getDocument = mockSimpleGrpcMethod( - request, - null, - error - ); - - client.getDocument(request, (err, response) => { - assert(err instanceof Error); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - - describe('listDocuments', () => { - it('invokes listDocuments without error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const formattedParent = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const collectionId = 'collectionId-821242276'; - const request = { - parent: formattedParent, - collectionId: collectionId, - }; - + const request: protosTypes.google.firestore.v1beta1.IGetDocumentRequest = {}; // Mock response - const nextPageToken = ''; - const documentsElement = {}; - const documents = [documentsElement]; - const expectedResponse = { - nextPageToken: nextPageToken, - documents: documents, - }; - - // Mock Grpc layer - client._innerApiCalls.listDocuments = ( - actualRequest, - options, - callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse.documents); - }; - - client.listDocuments(request, (err, response) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse.documents); - done(); - }); - }); - - it('invokes listDocuments with error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - - // Mock request - const formattedParent = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const collectionId = 'collectionId-821242276'; - const request = { - parent: formattedParent, - collectionId: collectionId, - }; - - // Mock Grpc layer - client._innerApiCalls.listDocuments = mockSimpleGrpcMethod( + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getDocument = mockSimpleGrpcMethod( request, null, error ); - - client.listDocuments(request, (err, response) => { - assert(err instanceof Error); + client.getDocument(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); }); }); - describe('createDocument', () => { it('invokes createDocument without error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedParent = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const collectionId = 'collectionId-821242276'; - const documentId = 'documentId506676927'; - const document = {}; - const request = { - parent: formattedParent, - collectionId: collectionId, - documentId: documentId, - document: document, - }; - + const request: protosTypes.google.firestore.v1beta1.ICreateDocumentRequest = {}; // Mock response - const name = 'name3373707'; - const expectedResponse = { - name: name, - }; - - // Mock Grpc layer + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.createDocument = mockSimpleGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - - client.createDocument(request, (err, response) => { + client.createDocument(request, (err: {}, response: {}) => { assert.ifError(err); assert.deepStrictEqual(response, expectedResponse); done(); @@ -251,68 +196,43 @@ describe('FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedParent = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const collectionId = 'collectionId-821242276'; - const documentId = 'documentId506676927'; - const document = {}; - const request = { - parent: formattedParent, - collectionId: collectionId, - documentId: documentId, - document: document, - }; - - // Mock Grpc layer + const request: protosTypes.google.firestore.v1beta1.ICreateDocumentRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.createDocument = mockSimpleGrpcMethod( request, null, error ); - - client.createDocument(request, (err, response) => { - assert(err instanceof Error); + client.createDocument(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); }); }); - describe('updateDocument', () => { it('invokes updateDocument without error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const document = {}; - const updateMask = {}; - const request = { - document: document, - updateMask: updateMask, - }; - + const request: protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest = {}; + request.document = {}; + request.document.name = ''; // Mock response - const name = 'name3373707'; - const expectedResponse = { - name: name, - }; - - // Mock Grpc layer + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.updateDocument = mockSimpleGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - - client.updateDocument(request, (err, response) => { + client.updateDocument(request, (err: {}, response: {}) => { assert.ifError(err); assert.deepStrictEqual(response, expectedResponse); done(); @@ -324,54 +244,45 @@ describe('FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const document = {}; - const updateMask = {}; - const request = { - document: document, - updateMask: updateMask, - }; - - // Mock Grpc layer + const request: protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest = {}; + request.document = {}; + request.document.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.updateDocument = mockSimpleGrpcMethod( request, null, error ); - - client.updateDocument(request, (err, response) => { - assert(err instanceof Error); + client.updateDocument(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); }); }); - describe('deleteDocument', () => { it('invokes deleteDocument without error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedName = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' + const request: protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteDocument = mockSimpleGrpcMethod( + request, + expectedResponse, + null ); - const request = { - name: formattedName, - }; - - // Mock Grpc layer - client._innerApiCalls.deleteDocument = mockSimpleGrpcMethod(request); - - client.deleteDocument(request, err => { + client.deleteDocument(request, (err: {}, response: {}) => { assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); done(); }); }); @@ -381,661 +292,486 @@ describe('FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedName = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const request = { - name: formattedName, - }; - - // Mock Grpc layer + const request: protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.deleteDocument = mockSimpleGrpcMethod( request, null, error ); - - client.deleteDocument(request, err => { - assert(err instanceof Error); + client.deleteDocument(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); done(); }); }); }); - - describe('batchGetDocuments', () => { - it('invokes batchGetDocuments without error', done => { + describe('beginTransaction', () => { + it('invokes beginTransaction without error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const documents = []; - const request = { - database: formattedDatabase, - documents: documents, - }; - + const request: protosTypes.google.firestore.v1beta1.IBeginTransactionRequest = {}; // Mock response - const missing = 'missing1069449574'; - const transaction = '-34'; - const expectedResponse = { - missing: missing, - transaction: transaction, - }; - - // Mock Grpc layer - client._innerApiCalls.batchGetDocuments = mockServerStreamingGrpcMethod( + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.beginTransaction = mockSimpleGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - - const stream = client.batchGetDocuments(request); - stream.on('data', response => { + client.beginTransaction(request, (err: {}, response: {}) => { + assert.ifError(err); assert.deepStrictEqual(response, expectedResponse); done(); }); - stream.on('error', err => { - done(err); - }); - - stream.write(); }); - it('invokes batchGetDocuments with error', done => { + it('invokes beginTransaction with error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const documents = []; - const request = { - database: formattedDatabase, - documents: documents, - }; - - // Mock Grpc layer - client._innerApiCalls.batchGetDocuments = mockServerStreamingGrpcMethod( + const request: protosTypes.google.firestore.v1beta1.IBeginTransactionRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.beginTransaction = mockSimpleGrpcMethod( request, null, error ); - - const stream = client.batchGetDocuments(request); - stream.on('data', () => { - assert.fail(); - }); - stream.on('error', err => { - assert(err instanceof Error); + client.beginTransaction(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); done(); }); - - stream.write(); }); }); - - describe('beginTransaction', () => { - it('invokes beginTransaction without error', done => { + describe('commit', () => { + it('invokes commit without error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const request = { - database: formattedDatabase, - }; - + const request: protosTypes.google.firestore.v1beta1.ICommitRequest = {}; // Mock response - const transaction = '-34'; - const expectedResponse = { - transaction: transaction, - }; - - // Mock Grpc layer - client._innerApiCalls.beginTransaction = mockSimpleGrpcMethod( + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.commit = mockSimpleGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - - client.beginTransaction(request, (err, response) => { + client.commit(request, (err: {}, response: {}) => { assert.ifError(err); assert.deepStrictEqual(response, expectedResponse); done(); }); }); - it('invokes beginTransaction with error', done => { + it('invokes commit with error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const request = { - database: formattedDatabase, - }; - - // Mock Grpc layer - client._innerApiCalls.beginTransaction = mockSimpleGrpcMethod( - request, - null, - error - ); - - client.beginTransaction(request, (err, response) => { - assert(err instanceof Error); + const request: protosTypes.google.firestore.v1beta1.ICommitRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.commit = mockSimpleGrpcMethod(request, null, error); + client.commit(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); }); }); - - describe('commit', () => { - it('invokes commit without error', done => { + describe('rollback', () => { + it('invokes rollback without error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const writes = []; - const request = { - database: formattedDatabase, - writes: writes, - }; - + const request: protosTypes.google.firestore.v1beta1.IRollbackRequest = {}; // Mock response const expectedResponse = {}; - - // Mock Grpc layer - client._innerApiCalls.commit = mockSimpleGrpcMethod( + // Mock gRPC layer + client._innerApiCalls.rollback = mockSimpleGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - - client.commit(request, (err, response) => { + client.rollback(request, (err: {}, response: {}) => { assert.ifError(err); assert.deepStrictEqual(response, expectedResponse); done(); }); }); - it('invokes commit with error', done => { + it('invokes rollback with error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' + const request: protosTypes.google.firestore.v1beta1.IRollbackRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.rollback = mockSimpleGrpcMethod( + request, + null, + error ); - const writes = []; - const request = { - database: formattedDatabase, - writes: writes, - }; - - // Mock Grpc layer - client._innerApiCalls.commit = mockSimpleGrpcMethod(request, null, error); - - client.commit(request, (err, response) => { - assert(err instanceof Error); + client.rollback(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); assert(typeof response === 'undefined'); done(); }); }); }); - - describe('rollback', () => { - it('invokes rollback without error', done => { + describe('batchGetDocuments', () => { + it('invokes batchGetDocuments without error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.batchGetDocuments = mockServerStreamingGrpcMethod( + request, + expectedResponse, + null ); - const transaction = '-34'; - const request = { - database: formattedDatabase, - transaction: transaction, - }; - - // Mock Grpc layer - client._innerApiCalls.rollback = mockSimpleGrpcMethod(request); - - client.rollback(request, err => { - assert.ifError(err); + const stream = client.batchGetDocuments(request); + stream.on('data', (response: {}) => { + assert.deepStrictEqual(response, expectedResponse); done(); }); + stream.on('error', (err: FakeError) => { + done(err); + }); + stream.write(); }); - - it('invokes rollback with error', done => { + it('invokes batchGetDocuments with error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const transaction = '-34'; - const request = { - database: formattedDatabase, - transaction: transaction, - }; - - // Mock Grpc layer - client._innerApiCalls.rollback = mockSimpleGrpcMethod( + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.batchGetDocuments = mockServerStreamingGrpcMethod( request, null, error ); - - client.rollback(request, err => { - assert(err instanceof Error); + const stream = client.batchGetDocuments(request); + stream.on('data', () => { + assert.fail(); + }); + stream.on('error', (err: FakeError) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); done(); }); + stream.write(); }); }); - describe('runQuery', () => { it('invokes runQuery without error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedParent = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const request = { - parent: formattedParent, - }; - + const request = {}; // Mock response - const transaction = '-34'; - const skippedResults = 880286183; - const expectedResponse = { - transaction: transaction, - skippedResults: skippedResults, - }; - - // Mock Grpc layer + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.runQuery = mockServerStreamingGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - const stream = client.runQuery(request); - stream.on('data', response => { + stream.on('data', (response: {}) => { assert.deepStrictEqual(response, expectedResponse); done(); }); - stream.on('error', err => { + stream.on('error', (err: FakeError) => { done(err); }); - stream.write(); }); - it('invokes runQuery with error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedParent = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const request = { - parent: formattedParent, - }; - - // Mock Grpc layer + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.runQuery = mockServerStreamingGrpcMethod( request, null, error ); - const stream = client.runQuery(request); stream.on('data', () => { assert.fail(); }); - stream.on('error', err => { - assert(err instanceof Error); + stream.on('error', (err: FakeError) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); done(); }); - stream.write(); }); }); - describe('write', () => { it('invokes write without error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const request = { - database: formattedDatabase, - }; - + const request = {}; // Mock response - const streamId = 'streamId-315624902'; - const streamToken = '122'; - const expectedResponse = { - streamId: streamId, - streamToken: streamToken, - }; - - // Mock Grpc layer + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.write = mockBidiStreamingGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - const stream = client .write() - .on('data', response => { + .on('data', (response: {}) => { assert.deepStrictEqual(response, expectedResponse); done(); }) - .on('error', err => { + .on('error', (err: FakeError) => { done(err); }); - stream.write(request); }); - it('invokes write with error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const request = { - database: formattedDatabase, - }; - - // Mock Grpc layer + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.write = mockBidiStreamingGrpcMethod( request, null, error ); - const stream = client .write() .on('data', () => { assert.fail(); }) - .on('error', err => { - assert(err instanceof Error); + .on('error', (err: FakeError) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); done(); }); - stream.write(request); }); }); - describe('listen', () => { it('invokes listen without error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const request = { - database: formattedDatabase, - }; - + const request = {}; // Mock response const expectedResponse = {}; - - // Mock Grpc layer + // Mock gRPC layer client._innerApiCalls.listen = mockBidiStreamingGrpcMethod( request, - expectedResponse + expectedResponse, + null ); - const stream = client .listen() - .on('data', response => { + .on('data', (response: {}) => { assert.deepStrictEqual(response, expectedResponse); done(); }) - .on('error', err => { + .on('error', (err: FakeError) => { done(err); }); - stream.write(request); }); - it('invokes listen with error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedDatabase = client.databaseRootPath( - '[PROJECT]', - '[DATABASE]' - ); - const request = { - database: formattedDatabase, - }; - - // Mock Grpc layer + const request = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer client._innerApiCalls.listen = mockBidiStreamingGrpcMethod( request, null, error ); - const stream = client .listen() .on('data', () => { assert.fail(); }) - .on('error', err => { - assert(err instanceof Error); + .on('error', (err: FakeError) => { + assert(err instanceof FakeError); assert.strictEqual(err.code, FAKE_STATUS_CODE); done(); }); - stream.write(request); }); }); - - describe('listCollectionIds', () => { - it('invokes listCollectionIds without error', done => { + describe('listDocuments', () => { + it('invokes listDocuments without error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedParent = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const request = { - parent: formattedParent, - }; - + const request: protosTypes.google.firestore.v1beta1.IListDocumentsRequest = {}; // Mock response - const nextPageToken = ''; - const collectionIdsElement = 'collectionIdsElement1368994900'; - const collectionIds = [collectionIdsElement]; - const expectedResponse = { - nextPageToken: nextPageToken, - collectionIds: collectionIds, - }; - + const expectedResponse = {}; // Mock Grpc layer - client._innerApiCalls.listCollectionIds = ( - actualRequest, - options, - callback + client._innerApiCalls.listDocuments = ( + actualRequest: {}, + options: {}, + callback: Callback ) => { assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse.collectionIds); + callback(null, expectedResponse); }; - - client.listCollectionIds(request, (err, response) => { + client.listDocuments(request, (err: FakeError, response: {}) => { assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse.collectionIds); + assert.deepStrictEqual(response, expectedResponse); done(); }); }); - - it('invokes listCollectionIds with error', done => { + }); + describe('listDocumentsStream', () => { + it('invokes listDocumentsStream without error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - // Mock request - const formattedParent = client.anyPathPath( - '[PROJECT]', - '[DATABASE]', - '[DOCUMENT]', - '[ANY_PATH]' - ); - const request = { - parent: formattedParent, + const request: protosTypes.google.firestore.v1beta1.IListDocumentsRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listDocuments = ( + actualRequest: {}, + options: {}, + callback: Callback + ) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); }; - + const stream = client + .listDocumentsStream(request, {}) + .on('data', (response: {}) => { + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + .on('error', (err: FakeError) => { + done(err); + }); + stream.write(request); + }); + }); + describe('listCollectionIds', () => { + it('invokes listCollectionIds without error', done => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest = {}; + // Mock response + const expectedResponse = {}; // Mock Grpc layer - client._innerApiCalls.listCollectionIds = mockSimpleGrpcMethod( - request, - null, - error - ); - - client.listCollectionIds(request, (err, response) => { - assert(err instanceof Error); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); + client._innerApiCalls.listCollectionIds = ( + actualRequest: {}, + options: {}, + callback: Callback + ) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listCollectionIds(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); done(); }); }); }); -}); - -function mockSimpleGrpcMethod(expectedRequest, response, error) { - return function(actualRequest, options, callback) { - assert.deepStrictEqual(actualRequest, expectedRequest); - if (error) { - callback(error); - } else if (response) { - callback(null, response); - } else { - callback(null); - } - }; -} - -function mockServerStreamingGrpcMethod(expectedRequest, response, error) { - return actualRequest => { - assert.deepStrictEqual(actualRequest, expectedRequest); - const mockStream = new PassThrough({ - objectMode: true, - transform: (chunk, enc, callback) => { - if (error) { - callback(error); - } else { - callback(null, response); - } - }, - }); - return mockStream; - }; -} - -function mockBidiStreamingGrpcMethod(expectedRequest, response, error) { - return () => { - const mockStream = new PassThrough({ - objectMode: true, - transform: (chunk, enc, callback) => { - assert.deepStrictEqual(chunk, expectedRequest); - if (error) { - callback(error); - } else { - callback(null, response); - } - }, + describe('listCollectionIdsStream', () => { + it('invokes listCollectionIdsStream without error', done => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listCollectionIds = ( + actualRequest: {}, + options: {}, + callback: Callback + ) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client + .listCollectionIdsStream(request, {}) + .on('data', (response: {}) => { + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + .on('error', (err: FakeError) => { + done(err); + }); + stream.write(request); }); - return mockStream; - }; -} + }); +}); diff --git a/dev/test/gapic-firestore_admin-v1.ts b/dev/test/gapic-firestore_admin-v1.ts new file mode 100644 index 000000000..c6aa9a187 --- /dev/null +++ b/dev/test/gapic-firestore_admin-v1.ts @@ -0,0 +1,606 @@ +// Copyright 2019 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as assert from 'assert'; +import * as protosTypes from '../protos/firestore_admin_v1_proto_api'; +const firestoreadminModule = require('../src'); + +const FAKE_STATUS_CODE = 1; +class FakeError { + name: string; + message: string; + code: number; + constructor(n: number) { + this.name = 'fakeName'; + this.message = 'fake message'; + this.code = n; + } +} +const error = new FakeError(FAKE_STATUS_CODE); +export interface Callback { + (err: FakeError | null, response?: {} | null): void; +} + +export class Operation { + constructor() {} + promise() {} +} +function mockSimpleGrpcMethod( + expectedRequest: {}, + response: {} | null, + error: FakeError | null +) { + return (actualRequest: {}, options: {}, callback: Callback) => { + assert.deepStrictEqual(actualRequest, expectedRequest); + if (error) { + callback(error); + } else if (response) { + callback(null, response); + } else { + callback(null); + } + }; +} +function mockLongRunningGrpcMethod( + expectedRequest: {}, + response: {} | null, + error?: {} | null +) { + return (request: {}) => { + assert.deepStrictEqual(request, expectedRequest); + const mockOperation = { + promise() { + return new Promise((resolve, reject) => { + if (error) { + reject(error); + } else { + resolve([response]); + } + }); + }, + }; + return Promise.resolve([mockOperation]); + }; +} +describe('v1.FirestoreAdminClient', () => { + it('has servicePath', () => { + const servicePath = + firestoreadminModule.v1.FirestoreAdminClient.servicePath; + assert(servicePath); + }); + it('has apiEndpoint', () => { + const apiEndpoint = + firestoreadminModule.v1.FirestoreAdminClient.apiEndpoint; + assert(apiEndpoint); + }); + it('has port', () => { + const port = firestoreadminModule.v1.FirestoreAdminClient.port; + assert(port); + assert(typeof port === 'number'); + }); + it('should create a client with no option', () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient(); + assert(client); + }); + it('should create a client with gRPC fallback', () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + fallback: true, + }); + assert(client); + }); + describe('getIndex', () => { + it('invokes getIndex without error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.IGetIndexRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getIndex = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getIndex(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes getIndex with error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.IGetIndexRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getIndex = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getIndex(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); + }); + }); + describe('deleteIndex', () => { + it('invokes deleteIndex without error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.IDeleteIndexRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteIndex = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.deleteIndex(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes deleteIndex with error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.IDeleteIndexRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.deleteIndex = mockSimpleGrpcMethod( + request, + null, + error + ); + client.deleteIndex(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); + }); + }); + describe('getField', () => { + it('invokes getField without error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.IGetFieldRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getField = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.getField(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes getField with error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.IGetFieldRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.getField = mockSimpleGrpcMethod( + request, + null, + error + ); + client.getField(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); + }); + }); + describe('createIndex', () => { + it('invokes createIndex without error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.ICreateIndexRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createIndex = mockLongRunningGrpcMethod( + request, + expectedResponse + ); + client + .createIndex(request) + .then((responses: [Operation]) => { + const operation = responses[0]; + return operation ? operation.promise() : {}; + }) + .then((responses: [Operation]) => { + assert.deepStrictEqual(responses[0], expectedResponse); + done(); + }) + .catch((err: {}) => { + done(err); + }); + }); + + it('invokes createIndex with error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.ICreateIndexRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createIndex = mockLongRunningGrpcMethod( + request, + null, + error + ); + client + .createIndex(request) + .then((responses: [Operation]) => { + const operation = responses[0]; + return operation ? operation.promise() : {}; + }) + .then(() => { + assert.fail(); + }) + .catch((err: FakeError) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + describe('updateField', () => { + it('invokes updateField without error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.IUpdateFieldRequest = {}; + request.field = {}; + request.field.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateField = mockLongRunningGrpcMethod( + request, + expectedResponse + ); + client + .updateField(request) + .then((responses: [Operation]) => { + const operation = responses[0]; + return operation ? operation.promise() : {}; + }) + .then((responses: [Operation]) => { + assert.deepStrictEqual(responses[0], expectedResponse); + done(); + }) + .catch((err: {}) => { + done(err); + }); + }); + + it('invokes updateField with error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.IUpdateFieldRequest = {}; + request.field = {}; + request.field.name = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.updateField = mockLongRunningGrpcMethod( + request, + null, + error + ); + client + .updateField(request) + .then((responses: [Operation]) => { + const operation = responses[0]; + return operation ? operation.promise() : {}; + }) + .then(() => { + assert.fail(); + }) + .catch((err: FakeError) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + describe('exportDocuments', () => { + it('invokes exportDocuments without error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.IExportDocumentsRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.exportDocuments = mockLongRunningGrpcMethod( + request, + expectedResponse + ); + client + .exportDocuments(request) + .then((responses: [Operation]) => { + const operation = responses[0]; + return operation ? operation.promise() : {}; + }) + .then((responses: [Operation]) => { + assert.deepStrictEqual(responses[0], expectedResponse); + done(); + }) + .catch((err: {}) => { + done(err); + }); + }); + + it('invokes exportDocuments with error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.IExportDocumentsRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.exportDocuments = mockLongRunningGrpcMethod( + request, + null, + error + ); + client + .exportDocuments(request) + .then((responses: [Operation]) => { + const operation = responses[0]; + return operation ? operation.promise() : {}; + }) + .then(() => { + assert.fail(); + }) + .catch((err: FakeError) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + describe('importDocuments', () => { + it('invokes importDocuments without error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.IImportDocumentsRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.importDocuments = mockLongRunningGrpcMethod( + request, + expectedResponse + ); + client + .importDocuments(request) + .then((responses: [Operation]) => { + const operation = responses[0]; + return operation ? operation.promise() : {}; + }) + .then((responses: [Operation]) => { + assert.deepStrictEqual(responses[0], expectedResponse); + done(); + }) + .catch((err: {}) => { + done(err); + }); + }); + + it('invokes importDocuments with error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.IImportDocumentsRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.importDocuments = mockLongRunningGrpcMethod( + request, + null, + error + ); + client + .importDocuments(request) + .then((responses: [Operation]) => { + const operation = responses[0]; + return operation ? operation.promise() : {}; + }) + .then(() => { + assert.fail(); + }) + .catch((err: FakeError) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + done(); + }); + }); + }); + describe('listIndexes', () => { + it('invokes listIndexes without error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.IListIndexesRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listIndexes = ( + actualRequest: {}, + options: {}, + callback: Callback + ) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listIndexes(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listIndexesStream', () => { + it('invokes listIndexesStream without error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.IListIndexesRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listIndexes = ( + actualRequest: {}, + options: {}, + callback: Callback + ) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client + .listIndexesStream(request, {}) + .on('data', (response: {}) => { + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + .on('error', (err: FakeError) => { + done(err); + }); + stream.write(request); + }); + }); + describe('listFields', () => { + it('invokes listFields without error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.IListFieldsRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listFields = ( + actualRequest: {}, + options: {}, + callback: Callback + ) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + client.listFields(request, (err: FakeError, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + }); + describe('listFieldsStream', () => { + it('invokes listFieldsStream without error', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.admin.v1.IListFieldsRequest = {}; + // Mock response + const expectedResponse = {}; + // Mock Grpc layer + client._innerApiCalls.listFields = ( + actualRequest: {}, + options: {}, + callback: Callback + ) => { + assert.deepStrictEqual(actualRequest, request); + callback(null, expectedResponse); + }; + const stream = client + .listFieldsStream(request, {}) + .on('data', (response: {}) => { + assert.deepStrictEqual(response, expectedResponse); + done(); + }) + .on('error', (err: FakeError) => { + done(err); + }); + stream.write(request); + }); + }); +}); diff --git a/dev/test/index.ts b/dev/test/index.ts index 30218d045..84201cd28 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -17,7 +17,7 @@ import * as chaiAsPromised from 'chai-as-promised'; import * as extend from 'extend'; import * as gax from 'google-gax'; -import {google} from '../protos/firestore_proto_api'; +import {google} from '../protos/firestore_v1_proto_api'; import * as Firestore from '../src'; import {DocumentSnapshot, FieldPath} from '../src'; diff --git a/dev/test/order.ts b/dev/test/order.ts index 73ba58b9f..58a5316b6 100644 --- a/dev/test/order.ts +++ b/dev/test/order.ts @@ -14,7 +14,7 @@ import {expect} from 'chai'; -import {google} from '../protos/firestore_proto_api'; +import {google} from '../protos/firestore_v1_proto_api'; import { Firestore, diff --git a/dev/test/query.ts b/dev/test/query.ts index 7b5a3ef42..03ff08cb1 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -15,7 +15,7 @@ import {expect} from 'chai'; import * as extend from 'extend'; -import {google} from '../protos/firestore_proto_api'; +import {google} from '../protos/firestore_v1_proto_api'; import {FieldPath, FieldValue, Firestore, setLogFunction} from '../src'; import {DocumentData, DocumentReference, Query, Timestamp} from '../src'; import {DocumentSnapshot, DocumentSnapshotBuilder} from '../src/document'; diff --git a/dev/test/timestamp.ts b/dev/test/timestamp.ts index 0f638f6c9..7a3995702 100644 --- a/dev/test/timestamp.ts +++ b/dev/test/timestamp.ts @@ -15,7 +15,7 @@ import {expect} from 'chai'; import * as through2 from 'through2'; -import {google} from '../protos/firestore_proto_api'; +import {google} from '../protos/firestore_v1_proto_api'; import * as Firestore from '../src/index'; import { diff --git a/dev/test/transaction.ts b/dev/test/transaction.ts index 490b51874..570b38437 100644 --- a/dev/test/transaction.ts +++ b/dev/test/transaction.ts @@ -17,7 +17,7 @@ import * as chaiAsPromised from 'chai-as-promised'; import * as extend from 'extend'; import * as through2 from 'through2'; -import * as proto from '../protos/firestore_proto_api'; +import * as proto from '../protos/firestore_v1_proto_api'; import * as Firestore from '../src'; import {DocumentReference, FieldPath, Transaction} from '../src'; import {ApiOverride, createInstance, InvalidApiUsage} from './util/helpers'; diff --git a/dev/test/util/helpers.ts b/dev/test/util/helpers.ts index ce1b5f3d1..d47a8ff67 100644 --- a/dev/test/util/helpers.ts +++ b/dev/test/util/helpers.ts @@ -17,7 +17,7 @@ import * as extend from 'extend'; import {CallOptions, GrpcClient} from 'google-gax'; import * as through2 from 'through2'; -import * as proto from '../../protos/firestore_proto_api'; +import * as proto from '../../protos/firestore_v1_proto_api'; import {Firestore} from '../../src'; import {ClientPool} from '../../src/pool'; import {GapicClient, GrpcError} from '../../src/types'; diff --git a/dev/test/watch.ts b/dev/test/watch.ts index 4c36974fd..99b9d37e1 100644 --- a/dev/test/watch.ts +++ b/dev/test/watch.ts @@ -19,7 +19,7 @@ import * as extend from 'extend'; import {Transform} from 'stream'; import * as through2 from 'through2'; -import {google} from '../protos/firestore_proto_api'; +import {google} from '../protos/firestore_v1_proto_api'; import { CollectionReference, @@ -588,7 +588,7 @@ describe('Query watch', () => { let lastSnapshot: { docs: QueryDocumentSnapshot[]; - docChanges: DocumentChange[]; + docChanges: TestChange[]; } = EMPTY; // The proto JSON that should be sent for the query. diff --git a/package.json b/package.json index e3d893cdb..8d7323c61 100644 --- a/package.json +++ b/package.json @@ -49,39 +49,39 @@ }, "dependencies": { "bun": "^0.0.12", - "deep-equal": "^1.0.1", + "deep-equal": "^1.1.1", "functional-red-black-tree": "^1.0.1", - "google-gax": "^1.7.5", + "google-gax": "^1.12.0", "through2": "^3.0.0" }, "devDependencies": { "@types/assert": "^1.4.0", - "@types/chai": "^4.1.7", - "@types/chai-as-promised": "^7.1.0", + "@types/chai": "^4.2.7", + "@types/chai-as-promised": "^7.1.2", "@types/duplexify": "^3.5.0", "@types/extend": "^3.0.0", "@types/mocha": "^5.2.3", - "@types/node": "^10.3.5", + "@types/node": "^12.12.17", "@types/through2": "^2.0.34", "chai": "^4.1.2", "chai-as-promised": "^7.1.1", - "codecov": "^3.0.2", + "codecov": "^3.6.1", "duplexify": "^4.0.0", "extend": "^3.0.2", - "gts": "^1.0.0", + "gts": "^1.1.2", "hard-rejection": "^2.0.0", "intelli-espower-loader": "^1.0.1", "jsdoc": "^3.6.2", - "jsdoc-fresh": "^1.0.1", + "jsdoc-fresh": "^1.0.2", "jsdoc-region-tag": "^1.0.2", - "linkinator": "^1.5.0", - "mocha": "^6.0.0", + "linkinator": "^1.8.0", + "mocha": "^6.2.2", "nyc": "^14.0.0", "power-assert": "^1.6.1", "protobufjs": "^6.8.6", - "proxyquire": "^2.0.1", - "source-map-support": "^0.5.6", - "ts-node": "^8.0.0", + "proxyquire": "^2.1.3", + "source-map-support": "^0.5.16", + "ts-node": "^8.5.4", "typescript": "3.6.4" } } diff --git a/samples/README.md b/samples/README.md index 88e5b8835..85a69e9f3 100644 --- a/samples/README.md +++ b/samples/README.md @@ -21,6 +21,7 @@ Applications that use Google's Server SDKs should not be used in end-user e * [Before you begin](#before-you-begin) * [Samples](#samples) * [Quickstart](#quickstart) + * [Solution-counters](#solution-counters) ## Before you begin @@ -43,6 +44,23 @@ __Usage:__ `node quickstart.js` +----- + + + + +### Solution-counters + +View the [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) + +__Usage:__ + + +`node solution-counters.js` + + diff --git a/synth.metadata b/synth.metadata index 41110293a..a3b819c98 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,42 +1,3 @@ { - "updateTime": "2019-09-30T21:28:17.572574Z", - "sources": [ - { - "generator": { - "name": "artman", - "version": "0.37.1", - "dockerImage": "googleapis/artman@sha256:6068f67900a3f0bdece596b97bda8fc70406ca0e137a941f4c81d3217c994a80" - } - }, - { - "git": { - "name": "googleapis", - "remote": "https://github.com/googleapis/googleapis.git", - "sha": "588bdb668cd362c2c18a4bc87cf478c64c88dabb", - "internalRef": "272063168" - } - } - ], - "destinations": [ - { - "client": { - "source": "googleapis", - "apiName": "firestore-admin", - "apiVersion": "v1", - "language": "nodejs", - "generator": "gapic", - "config": "google/firestore/admin/artman_firestore_v1.yaml" - } - }, - { - "client": { - "source": "googleapis", - "apiName": "firestore", - "apiVersion": "v1beta1", - "language": "nodejs", - "generator": "gapic", - "config": "google/firestore/artman_firestore.yaml" - } - } - ] + "updateTime": "2019-12-15T01:34:32.499415Z" } \ No newline at end of file diff --git a/synth.py b/synth.py index c3444fa0a..262b0ce32 100644 --- a/synth.py +++ b/synth.py @@ -6,44 +6,38 @@ logging.basicConfig(level=logging.DEBUG) -gapic = gcp.GAPICGenerator() +gapic_micro = gcp.GAPICMicrogenerator() -# tasks has two product names, and a poorly named artman yaml -v1_admin_library = gapic.node_library( - "firestore-admin", "v1", config_path="/google/firestore/admin/artman_firestore_v1.yaml" +v1_admin_library = gapic_micro.typescript_library( + "firestore-admin", "v1", proto_path="/google/firestore/admin/v1", + generator_args={'grpc-service-config': 'google/firestore/admin/v1/firestore_admin_grpc_service_config.json'} ) -v1beta1_library = gapic.node_library( - "firestore", "v1beta1", config_path="/google/firestore/artman_firestore.yaml" +v1beta1_library = gapic_micro.typescript_library( + "firestore", "v1beta1", proto_path="/google/firestore/v1beta1", + generator_args={'grpc-service-config': 'google/firestore/v1beta1/firestore_grpc_service_config.json'} ) -v1_library = gapic.node_library( - "firestore", "v1", config_path="/google/firestore/artman_firestore_v1.yaml" +v1_library = gapic_micro.typescript_library( + "firestore", "v1", proto_path="/google/firestore/v1", + generator_args={'grpc-service-config': 'google/firestore/v1/firestore_grpc_service_config.json'} ) # skip index, protos, package.json, and README.md -s.copy(v1_admin_library, "dev", excludes=["package.json", "README.md", "src/index.js", "src/v1/index.js"]) -s.copy(v1beta1_library, "dev", excludes=["package.json", "README.md", "src/index.js", "src/v1beta1/index.js"]) -s.copy(v1_library, "dev", excludes=["package.json", "README.md", "src/index.js", "src/v1/index.js"]) - -# package.json is one level deeper since firestore's src/ is under dev/ -s.replace( - "dev/src/v1/firestore_admin_client.js", "../../package.json", "../../../package.json" -) -s.replace( - "dev/src/v1beta1/firestore_client.js", "../../package.json", "../../../package.json" -) -s.replace( - "dev/src/v1/firestore_client.js", "../../package.json", "../../../package.json" -) +s.copy(v1_admin_library, "dev", excludes=["package.json", "README.md", "src/index.ts", "src/v1/index.ts", + "tsconfig.json", "tslint.json", "linkinator.config.json", "webpack.config.js"]) +s.copy(v1beta1_library, "dev", excludes=["package.json", "README.md", "src/index.ts", "src/v1beta1/index.ts", + "tsconfig.json", "tslint.json", "linkinator.config.json", "webpack.config.js"]) +s.copy(v1_library, "dev", excludes=["package.json", "README.md", "src/index.ts", "src/v1/index.ts", + "tsconfig.json", "tslint.json", "linkinator.config.json", "webpack.config.js"]) # Fix dropping of google-cloud-resource-header # See: https://github.com/googleapis/nodejs-firestore/pull/375 s.replace( - "dev/src/v1beta1/firestore_client.js", + "dev/src/v1beta1/firestore_client.ts", "return this\._innerApiCalls\.listen\(options\);", "return this._innerApiCalls.listen({}, options);", ) s.replace( - "dev/src/v1/firestore_client.js", + "dev/src/v1/firestore_client.ts", "return this\._innerApiCalls\.listen\(options\);", "return this._innerApiCalls.listen({}, options);", ) @@ -56,19 +50,40 @@ s.copy(templates) -# [START fix-dead-link] -s.replace('**/doc/google/protobuf/doc_timestamp.js', - 'https:\/\/cloud\.google\.com[\s\*]*http:\/\/(.*)[\s\*]*\)', - r"https://\1)") - -s.replace('**/doc/google/protobuf/doc_timestamp.js', - 'toISOString\]', - 'toISOString)') -# [END fix-dead-link] +# use the existing proto .js / .d.ts files +s.replace( + "dev/src/v1/firestore_client.ts", + "/protos/protos'", + "/protos/firestore_v1_proto_api'" + ) +s.replace( + "dev/test/gapic-firestore-v1.ts", + "/protos/protos'", + "/protos/firestore_v1_proto_api'" +) +s.replace( + "dev/src/v1/firestore_admin_client.ts", + "/protos/protos'", + "/protos/firestore_admin_v1_proto_api'" + ) +s.replace( + "dev/test/gapic-firestore_admin-v1.ts", + "/protos/protos'", + "/protos/firestore_admin_v1_proto_api'" +) +s.replace( + "dev/src/v1beta1/firestore_client.ts", + "/protos/protos'", + "/protos/firestore_v1beta1_proto_api'" + ) +s.replace( + "dev/test/gapic-firestore-v1beta1.ts", + "/protos/protos'", + "/protos/firestore_v1beta1_proto_api'" +) -# remove browser.js, it does not work with TypeScript yet -os.unlink('dev/src/browser.js') -os.unlink('dev/webpack.config.js') +# Remove auto-generated packaging tests +os.system('rm -rf dev/system-test/fixtures dev/system-test/install.ts') # Node.js specific cleanup subprocess.run(["npm", "install"]) @@ -77,3 +92,4 @@ subprocess.run(["npx", "compileProtos", "src"]) os.unlink('protos/protos.js') os.unlink('protos/protos.d.ts') +os.unlink('.jsdoc.js') diff --git a/tsconfig.json b/tsconfig.json index e3643435e..e70989a99 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,15 +1,17 @@ { "extends": "./node_modules/gts/tsconfig-google.json", "compilerOptions": { - "allowJs": true, - "declaration": false, // TODO: Remove when all source are migrated to TS - "outDir": "build" + "resolveJsonModule": true, + "outDir": "build", + "lib": [ + "es2016", + "dom" + ] }, "include": [ "dev/src/*.d.ts", "dev/src/*.ts", - "dev/src/**/*.js", - "dev/test/*.js", + "dev/src/**/*.ts", "dev/test/*.ts", "dev/test/**/*.ts", "dev/system-test/*.ts", From 22ef0d0229569f0d97ff908b5866264a8de2ca78 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 16 Dec 2019 05:41:17 +0800 Subject: [PATCH 004/337] fix: close GRPC channel when we dispose of clients (#779) --- dev/src/index.ts | 5 ++-- dev/src/pool.ts | 27 ++++++++++++------- dev/src/v1/firestore_admin_client_config.json | 4 +-- dev/src/v1/firestore_client_config.json | 4 +-- dev/src/v1beta1/firestore_client_config.json | 4 +-- dev/test/pool.ts | 22 +++++++++++++++ 6 files changed, 48 insertions(+), 18 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index 001c58fd7..af3498ed0 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -374,7 +374,7 @@ export class Firestore { this._clientPool = new ClientPool( MAX_CONCURRENT_REQUESTS_PER_CLIENT, - () => { + /* clientFactory= */ () => { let client: GapicClient; if (this._settings.ssl === false) { @@ -387,7 +387,8 @@ export class Firestore { logger('Firestore', null, 'Initialized Firestore GAPIC Client'); return client; - } + }, + /* clientDestructor= */ (client: GapicClient) => client.close() ); logger('Firestore', null, 'Initialized Firestore'); diff --git a/dev/src/pool.ts b/dev/src/pool.ts index fc229dac2..b7c861b67 100644 --- a/dev/src/pool.ts +++ b/dev/src/pool.ts @@ -40,10 +40,14 @@ export class ClientPool { * can handle. * @param clientFactory A factory function called as needed when new clients * are required. + * @param clientDestructor A cleanup function that is called when a client is + * disposed of. */ constructor( private readonly concurrentOperationLimit: number, - private readonly clientFactory: () => T + private readonly clientFactory: () => T, + private readonly clientDestructor: (client: T) => Promise = () => + Promise.resolve() ) {} /** @@ -88,7 +92,7 @@ export class ClientPool { * removing it from the pool of active clients. * @private */ - private release(requestTag: string, client: T): void { + private async release(requestTag: string, client: T): Promise { let requestCount = this.activeClients.get(client) || 0; assert(requestCount > 0, 'No active request'); @@ -96,7 +100,7 @@ export class ClientPool { this.activeClients.set(client, requestCount); if (requestCount === 0) { - const deletedCount = this.garbageCollect(); + const deletedCount = await this.garbageCollect(); if (deletedCount) { logger( 'ClientPool.release', @@ -147,12 +151,12 @@ export class ClientPool { const client = this.acquire(requestTag); return op(client) - .catch(err => { - this.release(requestTag, client); + .catch(async err => { + await this.release(requestTag, client); return Promise.reject(err); }) - .then(res => { - this.release(requestTag, client); + .then(async res => { + await this.release(requestTag, client); return res; }); } @@ -164,17 +168,20 @@ export class ClientPool { * @return Number of clients deleted. * @private */ - private garbageCollect(): number { + private async garbageCollect(): Promise { let idleClients = 0; - this.activeClients.forEach((requestCount, client) => { + const cleanUpTasks: Array> = []; + for (const [client, requestCount] of this.activeClients) { if (requestCount === 0) { ++idleClients; if (idleClients > 1) { this.activeClients.delete(client); + cleanUpTasks.push(this.clientDestructor(client)); } } - }); + } + await Promise.all(cleanUpTasks); return idleClients - 1; } } diff --git a/dev/src/v1/firestore_admin_client_config.json b/dev/src/v1/firestore_admin_client_config.json index 918ef86d9..b73e97016 100644 --- a/dev/src/v1/firestore_admin_client_config.json +++ b/dev/src/v1/firestore_admin_client_config.json @@ -18,9 +18,9 @@ "initial_retry_delay_millis": 100, "retry_delay_multiplier": 1.3, "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 20000, + "initial_rpc_timeout_millis": 60000, "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 20000, + "max_rpc_timeout_millis": 60000, "total_timeout_millis": 600000 } }, diff --git a/dev/src/v1/firestore_client_config.json b/dev/src/v1/firestore_client_config.json index 3930e894a..b1e32f327 100644 --- a/dev/src/v1/firestore_client_config.json +++ b/dev/src/v1/firestore_client_config.json @@ -18,9 +18,9 @@ "initial_retry_delay_millis": 100, "retry_delay_multiplier": 1.3, "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 20000, + "initial_rpc_timeout_millis": 60000, "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 20000, + "max_rpc_timeout_millis": 60000, "total_timeout_millis": 600000 } }, diff --git a/dev/src/v1beta1/firestore_client_config.json b/dev/src/v1beta1/firestore_client_config.json index 1166bff74..85e682aff 100644 --- a/dev/src/v1beta1/firestore_client_config.json +++ b/dev/src/v1beta1/firestore_client_config.json @@ -13,9 +13,9 @@ "initial_retry_delay_millis": 100, "retry_delay_multiplier": 1.3, "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 20000, + "initial_rpc_timeout_millis": 60000, "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 20000, + "max_rpc_timeout_millis": 60000, "total_timeout_millis": 600000 } }, diff --git a/dev/test/pool.ts b/dev/test/pool.ts index 9a00c5c72..b9b2afecf 100644 --- a/dev/test/pool.ts +++ b/dev/test/pool.ts @@ -150,6 +150,28 @@ describe('Client pool', () => { ); }); + it('garbage collection calls destructor', () => { + const garbageCollect = new Deferred(); + + const clientPool = new ClientPool<{}>( + 1, + () => { + return {}; + }, + () => Promise.resolve(garbageCollect.resolve()) + ); + + const operationPromises = deferredPromises(2); + + // Create two pending operations that each spawn their own client + clientPool.run(REQUEST_TAG, () => operationPromises[0].promise); + clientPool.run(REQUEST_TAG, () => operationPromises[1].promise); + + operationPromises.forEach(deferred => deferred.resolve()); + + return garbageCollect.promise; + }); + it('forwards success', () => { const clientPool = new ClientPool<{}>(1, () => { return {}; From 280f748ec995cb86f71b5f80b60f5da0fb4c8044 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2019 05:48:51 +0800 Subject: [PATCH 005/337] chore: release 3.0.0 (#815) --- CHANGELOG.md | 18 ++++++++++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8aa5bb825..ff667515d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,24 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [3.0.0](https://www.github.com/googleapis/nodejs-firestore/compare/v2.6.1...v3.0.0) (2019-12-15) + + +### ⚠ BREAKING CHANGES + +* convert Gapic client to TypeScript (#805) +* remove deprecated timestampInSnapshots setting (#808) + +### Features + +* convert Gapic client to TypeScript ([#805](https://www.github.com/googleapis/nodejs-firestore/issues/805)) ([5000b2d](https://www.github.com/googleapis/nodejs-firestore/commit/5000b2d4b5c528b66c5a71db343c0e4163d5d8f7)) +* remove deprecated timestampInSnapshots setting ([#808](https://www.github.com/googleapis/nodejs-firestore/issues/808)) ([f37fffc](https://www.github.com/googleapis/nodejs-firestore/commit/f37fffc44fb1ddc8177bd24dfb44d830221e2479)) + + +### Bug Fixes + +* close GRPC channel when we dispose of clients ([#779](https://www.github.com/googleapis/nodejs-firestore/issues/779)) ([22ef0d0](https://www.github.com/googleapis/nodejs-firestore/commit/22ef0d0229569f0d97ff908b5866264a8de2ca78)) + ### [2.6.1](https://www.github.com/googleapis/nodejs-firestore/compare/v2.6.0...v2.6.1) (2019-12-05) diff --git a/package.json b/package.json index 8d7323c61..90df32079 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "2.6.1", + "version": "3.0.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index a8a20a11e..0332be4eb 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^2.6.1" + "@google-cloud/firestore": "^3.0.0" }, "devDependencies": { "chai": "^4.2.0", From 25472e11a0e1a4a5e1931b1652d125f9c8cabf11 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 17 Dec 2019 13:41:48 +0200 Subject: [PATCH 006/337] fix(deps): update dependency deep-equal to v2 (#821) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 90df32079..4008e5909 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ }, "dependencies": { "bun": "^0.0.12", - "deep-equal": "^1.1.1", + "deep-equal": "^2.0.0", "functional-red-black-tree": "^1.0.1", "google-gax": "^1.12.0", "through2": "^3.0.0" From 9ef582aa0508a3d02fb036f741c8c51e5ff4307c Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Thu, 19 Dec 2019 15:45:35 -0800 Subject: [PATCH 007/337] feat: add ability to close channels (#824) --- dev/src/index.ts | 9 +++++++++ dev/src/pool.ts | 17 +++++++++++++++++ dev/system-test/firestore.ts | 18 ++++++++++++++++++ dev/test/pool.ts | 17 +++++++++++++++++ types/firestore.d.ts | 7 +++++++ 5 files changed, 68 insertions(+) diff --git a/dev/src/index.ts b/dev/src/index.ts index af3498ed0..f5c064137 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -1007,6 +1007,15 @@ export class Firestore { }); } + /** + * Terminates the Firestore client and closes all open streams. + * + * @return A Promise that resolves when the client is terminated. + */ + terminate(): Promise { + return this._clientPool.terminate(); + } + /** * Initializes the client if it is not already initialized. All methods in the * SDK can be used after this method completes. diff --git a/dev/src/pool.ts b/dev/src/pool.ts index b7c861b67..4010817fa 100644 --- a/dev/src/pool.ts +++ b/dev/src/pool.ts @@ -35,6 +35,12 @@ export class ClientPool { */ private activeClients: Map = new Map(); + /** + * Whether the Firestore instance has been terminated. Once terminated, the + * ClientPool can longer schedule new operations. + */ + private terminated = false; + /** * @param concurrentOperationLimit The number of operations that each client * can handle. @@ -148,6 +154,9 @@ export class ClientPool { * @private */ run(requestTag: string, op: (client: T) => Promise): Promise { + if (this.terminated) { + throw new Error('The client has already been terminated'); + } const client = this.acquire(requestTag); return op(client) @@ -161,6 +170,14 @@ export class ClientPool { }); } + async terminate(): Promise { + this.terminated = true; + for (const [client, _requestCount] of this.activeClients) { + this.activeClients.delete(client); + await this.clientDestructor(client); + } + } + /** * Deletes clients that are no longer executing operations. Keeps up to one * idle client to reduce future initialization costs. diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 5fa028b31..e5b45af62 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -127,6 +127,24 @@ describe('Firestore class', () => { expect(docs[1].data()).to.deep.equal({f: 'a'}); }); }); + + it('cannot make calls after the client has been terminated', () => { + const ref1 = randomCol.doc('doc1'); + ref1.onSnapshot(snapshot => { + return Promise.reject('onSnapshot() should be called'); + }); + return firestore + .terminate() + .then(() => { + return ref1.set({foo: 100}); + }) + .then(() => { + Promise.reject('set() should have failed'); + }) + .catch(err => { + expect(err.message).to.equal('The client has already been terminated'); + }); + }); }); describe('CollectionReference class', () => { diff --git a/dev/test/pool.ts b/dev/test/pool.ts index b9b2afecf..cd50ff73b 100644 --- a/dev/test/pool.ts +++ b/dev/test/pool.ts @@ -191,4 +191,21 @@ describe('Client pool', () => { ); return expect(op).to.eventually.be.rejectedWith('Generated error'); }); + + it('rejects subsequent operations after being terminated', () => { + const clientPool = new ClientPool<{}>(1, () => { + return {}; + }); + + return clientPool + .terminate() + .then(() => { + clientPool.run(REQUEST_TAG, () => + Promise.reject('Call to run() should have failed') + ); + }) + .catch((err: Error) => { + expect(err.message).to.equal('The client has already been terminated'); + }); + }); }); diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 2cc5796b3..3a7122922 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -154,6 +154,13 @@ declare namespace FirebaseFirestore { getAll(...documentRefsOrReadOptions: Array): Promise; + /** + * Terminates the Firestore client and closes all open streams. + * + * @return A Promise that resolves when the client is terminated. + */ + terminate(): Promise; + /** * Fetches the root collections that are associated with this Firestore * database. From a93c77d80900eeff0a320bb4e518802756e629df Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2019 11:42:01 +0800 Subject: [PATCH 008/337] chore: release 3.1.0 (#830) * updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json [ci skip] --- CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff667515d..74e1804b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [3.1.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.0.0...v3.1.0) (2019-12-19) + + +### Features + +* add ability to close channels ([#824](https://www.github.com/googleapis/nodejs-firestore/issues/824)) ([9ef582a](https://www.github.com/googleapis/nodejs-firestore/commit/9ef582aa0508a3d02fb036f741c8c51e5ff4307c)) + + +### Bug Fixes + +* **deps:** update dependency deep-equal to v2 ([#821](https://www.github.com/googleapis/nodejs-firestore/issues/821)) ([25472e1](https://www.github.com/googleapis/nodejs-firestore/commit/25472e11a0e1a4a5e1931b1652d125f9c8cabf11)) + ## [3.0.0](https://www.github.com/googleapis/nodejs-firestore/compare/v2.6.1...v3.0.0) (2019-12-15) diff --git a/package.json b/package.json index 4008e5909..44b1d45dc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.0.0", + "version": "3.1.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 0332be4eb..630cae1eb 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.0.0" + "@google-cloud/firestore": "^3.1.0" }, "devDependencies": { "chai": "^4.2.0", From a4e92520b48d9e6d42dfe58a224d8bd5916994fa Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Wed, 25 Dec 2019 22:22:54 -0500 Subject: [PATCH 009/337] docs: update jsdoc license/samples-README (#834) --- .jsdoc.js | 29 ++++++++++++++--------------- samples/README.md | 12 +++++++++--- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.jsdoc.js b/.jsdoc.js index a23d18173..d52e77079 100644 --- a/.jsdoc.js +++ b/.jsdoc.js @@ -1,18 +1,17 @@ -/*! - * Copyright 2018 Google LLC. All Rights Reserved. - * - * 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. - */ +// Copyright 2019 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 +// +// https://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. +// 'use strict'; diff --git a/samples/README.md b/samples/README.md index 85a69e9f3..b34c2473e 100644 --- a/samples/README.md +++ b/samples/README.md @@ -28,6 +28,12 @@ Applications that use Google's Server SDKs should not be used in end-user e Before running the samples, make sure you've followed the steps outlined in [Using the client library](https://github.com/googleapis/nodejs-firestore#using-the-client-library). +`cd samples` + +`npm install` + +`cd ..` + ## Samples @@ -41,7 +47,7 @@ View the [source code](https://github.com/googleapis/nodejs-firestore/blob/maste __Usage:__ -`node quickstart.js` +`node samples/quickstart.js` ----- @@ -58,7 +64,7 @@ View the [source code](https://github.com/googleapis/nodejs-firestore/blob/maste __Usage:__ -`node solution-counters.js` +`node samples/solution-counters.js` @@ -67,4 +73,4 @@ __Usage:__ [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-firestore&page=editor&open_in_editor=samples/README.md -[product-docs]: https://cloud.google.com/firestore \ No newline at end of file +[product-docs]: https://cloud.google.com/firestore From 3cd93c87467c1a685f61e250aedbcdfce0bedc45 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Thu, 26 Dec 2019 01:14:47 -0800 Subject: [PATCH 010/337] build: use c8 for coverage (#836) --- package.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 44b1d45dc..fc08730d4 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,6 @@ "firestore" ], "scripts": { - "codecov": "nyc report --reporter=json && codecov -f .coverage/*.json", "predocs": "npm run compile", "docs": "jsdoc -c .jsdoc.js", "system-test": "mocha build/system-test --timeout 600000", @@ -36,7 +35,7 @@ "samples-test": "npm link && cd samples/ && npm link ../ && npm test && cd ../", "conformance": "mocha build/conformance", "preconformance": "npm run compile", - "test-only": "nyc mocha build/test", + "test-only": "c8 mocha build/test", "pretest-only": "npm run compile", "test": "npm run test-only && npm run conformance", "lint": "gts check", @@ -76,7 +75,7 @@ "jsdoc-region-tag": "^1.0.2", "linkinator": "^1.8.0", "mocha": "^6.2.2", - "nyc": "^14.0.0", + "c8": "^7.0.0", "power-assert": "^1.6.1", "protobufjs": "^6.8.6", "proxyquire": "^2.1.3", From 5c870e615e4774d3d50fc33c17b5da45dcacea4f Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Fri, 27 Dec 2019 09:00:05 +0800 Subject: [PATCH 011/337] fix: reduce overhead for listDocuments()/listCollections() (#838) --- dev/src/reference.ts | 11 ++++++++++- dev/test/collection.ts | 1 + dev/test/document.ts | 1 + dev/test/index.ts | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 25dbed75a..913b9505f 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -286,7 +286,13 @@ export class DocumentReference implements Serializable { listCollections(): Promise { const tag = requestTag(); return this.firestore.initializeIfNeeded(tag).then(() => { - const request = {parent: this.formattedName}; + const request: api.IListCollectionIdsRequest = { + parent: this.formattedName, + // Setting `pageSize` to an arbitrarily large value lets the backend cap + // the page size (currently to 300). Note that the backend rejects + // MAX_INT32 (b/146883794). + pageSize: Math.pow(2, 16) - 1, + }; return this._firestore .request( 'listCollectionIds', @@ -2051,6 +2057,9 @@ export class CollectionReference extends Query { parent: parentPath.formattedName, collectionId: this.id, showMissing: true, + // Setting `pageSize` to the maximum allowed value lets the backend cap + // the page size (currently to 300). + pageSize: Math.pow(2, 32) - 1, mask: {fieldPaths: []}, }; diff --git a/dev/test/collection.ts b/dev/test/collection.ts index e25272535..96e2a3f64 100644 --- a/dev/test/collection.ts +++ b/dev/test/collection.ts @@ -142,6 +142,7 @@ describe('Collection interface', () => { parent: `${DATABASE_ROOT}/documents/a/b`, collectionId: 'c', showMissing: true, + pageSize: 4294967295, mask: {fieldPaths: []}, }); diff --git a/dev/test/document.ts b/dev/test/document.ts index 4a6f62c27..773fa0f6a 100644 --- a/dev/test/document.ts +++ b/dev/test/document.ts @@ -2003,6 +2003,7 @@ describe('listCollections() method', () => { listCollectionIds: (request, options, callback) => { expect(request).to.deep.eq({ parent: `projects/${PROJECT_ID}/databases/(default)/documents/coll/doc`, + pageSize: 65535, }); callback(null, ['second', 'first']); diff --git a/dev/test/index.ts b/dev/test/index.ts index 84201cd28..e43332129 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -871,6 +871,7 @@ describe('listCollections() method', () => { listCollectionIds: (request, options, callback) => { expect(request).to.deep.eq({ parent: `projects/${PROJECT_ID}/databases/(default)/documents`, + pageSize: 65535, }); callback(null, ['first', 'second']); From 37e93da689f985b6b0f30645435b12179513eb64 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Fri, 27 Dec 2019 10:16:50 +0800 Subject: [PATCH 012/337] feat: allow specifying how many idle GRPC channels to keep (#837) --- dev/src/index.ts | 21 +++++++ dev/src/pool.ts | 91 ++++++++++++++++--------------- dev/src/types.ts | 8 +++ dev/test/index.ts | 13 +++++ dev/test/pool.ts | 115 +++++++++++++++++++++++++++++++++++---- dev/test/typescript.ts | 1 + dev/test/util/helpers.ts | 32 ++++++----- dev/test/watch.ts | 2 +- types/firestore.d.ts | 8 +++ 9 files changed, 221 insertions(+), 70 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index f5c064137..2f0d7e430 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -130,6 +130,11 @@ const CLOUD_RESOURCE_HEADER = 'google-cloud-resource-prefix'; */ const MAX_REQUEST_RETRIES = 5; +/*! + * The default number of idle GRPC channel to keep. + */ +const DEFAULT_MAX_IDLE_CHANNELS = 1; + /*! * The maximum number of concurrent requests supported by a single GRPC channel, * as enforced by Google's Frontend. If the SDK issues more than 100 concurrent @@ -317,6 +322,11 @@ export class Firestore { * can specify a `keyFilename` instead. * @param {string=} settings.host The host to connect to. * @param {boolean=} settings.ssl Whether to use SSL when connecting. + * @param {number=} settings.maxIdleChannels 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. */ constructor(settings?: Settings) { const libraryHeader = { @@ -372,8 +382,13 @@ export class Firestore { logger('Firestore', null, 'Detected GCF environment'); } + const maxIdleChannels = + this._settings.maxIdleChannels === undefined + ? DEFAULT_MAX_IDLE_CHANNELS + : this._settings.maxIdleChannels; this._clientPool = new ClientPool( MAX_CONCURRENT_REQUESTS_PER_CLIENT, + maxIdleChannels, /* clientFactory= */ () => { let client: GapicClient; @@ -455,6 +470,12 @@ export class Firestore { validateBoolean('settings.ssl', settings.ssl); } + if (settings.maxIdleChannels !== undefined) { + validateInteger('settings.maxIdleChannels', settings.maxIdleChannels, { + minValue: 0, + }); + } + this._settings = settings; this._serializer = new Serializer(this); } diff --git a/dev/src/pool.ts b/dev/src/pool.ts index 4010817fa..0c82a435e 100644 --- a/dev/src/pool.ts +++ b/dev/src/pool.ts @@ -44,6 +44,8 @@ export class ClientPool { /** * @param concurrentOperationLimit The number of operations that each client * can handle. + * @param maxIdleClients The maximum number of idle clients to keep before + * garbage collecting. * @param clientFactory A factory function called as needed when new clients * are required. * @param clientDestructor A cleanup function that is called when a client is @@ -51,6 +53,7 @@ export class ClientPool { */ constructor( private readonly concurrentOperationLimit: number, + private readonly maxIdleClients: number, private readonly clientFactory: () => T, private readonly clientDestructor: (client: T) => Promise = () => Promise.resolve() @@ -64,10 +67,16 @@ export class ClientPool { */ private acquire(requestTag: string): T { let selectedClient: T | null = null; - let selectedRequestCount = 0; + let selectedClientRequestCount = 0; - this.activeClients.forEach((requestCount, client) => { - if (!selectedClient && requestCount < this.concurrentOperationLimit) { + for (const [client, requestCount] of this.activeClients) { + // Use the "most-full" client that can still accommodate the request + // in order to maximize the number of idle clients as operations start to + // complete. + if ( + requestCount > selectedClientRequestCount && + requestCount < this.concurrentOperationLimit + ) { logger( 'ClientPool.acquire', requestTag, @@ -75,11 +84,18 @@ export class ClientPool { this.concurrentOperationLimit - requestCount ); selectedClient = client; - selectedRequestCount = requestCount; + selectedClientRequestCount = requestCount; } - }); + } - if (!selectedClient) { + if (selectedClient) { + logger( + 'ClientPool.acquire', + requestTag, + 'Re-using existing client with %s remaining operations', + this.concurrentOperationLimit - selectedClientRequestCount + ); + } else { logger('ClientPool.acquire', requestTag, 'Creating a new client'); selectedClient = this.clientFactory(); assert( @@ -88,7 +104,7 @@ export class ClientPool { ); } - this.activeClients.set(selectedClient, selectedRequestCount + 1); + this.activeClients.set(selectedClient, selectedClientRequestCount + 1); return selectedClient!; } @@ -99,23 +115,34 @@ export class ClientPool { * @private */ private async release(requestTag: string, client: T): Promise { - let requestCount = this.activeClients.get(client) || 0; + const requestCount = this.activeClients.get(client) || 0; assert(requestCount > 0, 'No active request'); + this.activeClients.set(client, requestCount - 1); - requestCount = requestCount! - 1; - this.activeClients.set(client, requestCount); + if (this.shouldGarbageCollectClient(client)) { + this.activeClients.delete(client); + await this.clientDestructor(client); + logger('ClientPool.release', requestTag, 'Garbage collected 1 client'); + } + } - if (requestCount === 0) { - const deletedCount = await this.garbageCollect(); - if (deletedCount) { - logger( - 'ClientPool.release', - requestTag, - 'Garbage collected %s clients', - deletedCount - ); - } + /** + * Given the current operation counts, determines if the given client should + * be garbage collected. + * @private + */ + private shouldGarbageCollectClient(client: T): boolean { + if (this.activeClients.get(client) !== 0) { + return false; + } + + let idleCapacityCount = 0; + for (const [_, count] of this.activeClients) { + idleCapacityCount += this.concurrentOperationLimit - count; } + return ( + idleCapacityCount > this.maxIdleClients * this.concurrentOperationLimit + ); } /** @@ -177,28 +204,4 @@ export class ClientPool { await this.clientDestructor(client); } } - - /** - * Deletes clients that are no longer executing operations. Keeps up to one - * idle client to reduce future initialization costs. - * - * @return Number of clients deleted. - * @private - */ - private async garbageCollect(): Promise { - let idleClients = 0; - const cleanUpTasks: Array> = []; - for (const [client, requestCount] of this.activeClients) { - if (requestCount === 0) { - ++idleClients; - - if (idleClients > 1) { - this.activeClients.delete(client); - cleanUpTasks.push(this.clientDestructor(client)); - } - } - } - await Promise.all(cleanUpTasks); - return idleClients - 1; - } } diff --git a/dev/src/types.ts b/dev/src/types.ts index 7085284c4..a70517a2d 100644 --- a/dev/src/types.ts +++ b/dev/src/types.ts @@ -72,6 +72,14 @@ export interface Settings { /** 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; + // tslint:disable-next-line:no-any [key: string]: any; // Accept other properties, such as GRPC settings. } diff --git a/dev/test/index.ts b/dev/test/index.ts index e43332129..bffc04e7a 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -491,6 +491,19 @@ describe('instantiation', () => { } }); + it('validates maxIdleChannels', () => { + const invalidValues = [-1, 'foo', 1.3]; + + for (const value of invalidValues) { + expect(() => { + const settings = {...DEFAULT_SETTINGS, maxIdleChannels: value}; + new Firestore.Firestore(settings as InvalidApiUsage); + }).to.throw(); + } + + new Firestore.Firestore({maxIdleChannels: 1}); + }); + it('uses project id from constructor', () => { const firestore = new Firestore.Firestore({projectId: 'foo'}); diff --git a/dev/test/pool.ts b/dev/test/pool.ts index cd50ff73b..0ff986a4f 100644 --- a/dev/test/pool.ts +++ b/dev/test/pool.ts @@ -32,7 +32,7 @@ function deferredPromises(count: number): Array> { describe('Client pool', () => { it('creates new instances as needed', () => { - const clientPool = new ClientPool<{}>(3, () => { + const clientPool = new ClientPool<{}>(3, 0, () => { return {}; }); @@ -52,7 +52,7 @@ describe('Client pool', () => { }); it('re-uses idle instances', () => { - const clientPool = new ClientPool<{}>(2, () => { + const clientPool = new ClientPool<{}>(2, 0, () => { return {}; }); @@ -80,8 +80,51 @@ describe('Client pool', () => { }); }); + it('bin packs operations', async () => { + let clientCount = 0; + const clientPool = new ClientPool(2, 0, () => { + return ++clientCount; + }); + + expect(clientPool.size).to.equal(0); + + // Create 5 operations, which should schedule 2 operations on the first + // client, 2 on the second and 1 on the third. + const operationPromises = deferredPromises(7); + clientPool.run(REQUEST_TAG, client => { + expect(client).to.be.equal(1); + return operationPromises[0].promise; + }); + clientPool.run(REQUEST_TAG, client => { + expect(client).to.be.equal(1); + return operationPromises[1].promise; + }); + const thirdOperation = clientPool.run(REQUEST_TAG, client => { + expect(client).to.be.equal(2); + return operationPromises[2].promise; + }); + clientPool.run(REQUEST_TAG, client => { + expect(client).to.be.equal(2); + return operationPromises[3].promise; + }); + clientPool.run(REQUEST_TAG, client => { + expect(client).to.be.equal(3); + return operationPromises[4].promise; + }); + + // Free one slot on the second client. + operationPromises[2].resolve(); + await thirdOperation; + + // A newly scheduled operation should use the first client that has a free + // slot. + clientPool.run(REQUEST_TAG, async client => { + expect(client).to.be.equal(2); + }); + }); + it('garbage collects after success', () => { - const clientPool = new ClientPool<{}>(2, () => { + const clientPool = new ClientPool<{}>(2, 0, () => { return {}; }); @@ -110,12 +153,12 @@ describe('Client pool', () => { operationPromises.forEach(deferred => deferred.resolve()); return Promise.all(completionPromises).then(() => { - expect(clientPool.size).to.equal(1); + expect(clientPool.size).to.equal(0); }); }); it('garbage collects after error', () => { - const clientPool = new ClientPool<{}>(2, () => { + const clientPool = new ClientPool<{}>(2, 0, () => { return {}; }); @@ -145,7 +188,7 @@ describe('Client pool', () => { return Promise.all(completionPromises.map(p => p.catch(() => {}))).then( () => { - expect(clientPool.size).to.equal(1); + expect(clientPool.size).to.equal(0); } ); }); @@ -155,9 +198,8 @@ describe('Client pool', () => { const clientPool = new ClientPool<{}>( 1, - () => { - return {}; - }, + 0, + () => ({}), () => Promise.resolve(garbageCollect.resolve()) ); @@ -173,7 +215,7 @@ describe('Client pool', () => { }); it('forwards success', () => { - const clientPool = new ClientPool<{}>(1, () => { + const clientPool = new ClientPool<{}>(1, 0, () => { return {}; }); @@ -182,7 +224,7 @@ describe('Client pool', () => { }); it('forwards failure', () => { - const clientPool = new ClientPool<{}>(1, () => { + const clientPool = new ClientPool<{}>(1, 0, () => { return {}; }); @@ -192,8 +234,57 @@ describe('Client pool', () => { return expect(op).to.eventually.be.rejectedWith('Generated error'); }); + it('keeps pool of idle clients', async () => { + const clientPool = new ClientPool<{}>( + /* concurrentOperationLimit= */ 1, + /* maxIdleClients= */ 3, + () => { + return {}; + } + ); + + const operationPromises = deferredPromises(4); + clientPool.run(REQUEST_TAG, () => operationPromises[0].promise); + clientPool.run(REQUEST_TAG, () => operationPromises[1].promise); + clientPool.run(REQUEST_TAG, () => operationPromises[2].promise); + const lastOp = clientPool.run( + REQUEST_TAG, + () => operationPromises[3].promise + ); + expect(clientPool.size).to.equal(4); + + // Resolve all pending operations. Note that one client is removed, while + // 3 are kept for further usage. + operationPromises.forEach(deferred => deferred.resolve()); + await lastOp; + expect(clientPool.size).to.equal(3); + }); + + it('default setting keeps at least one idle client', async () => { + const clientPool = new ClientPool<{}>( + 1, + /* maxIdleClients= git c*/ 1, + () => { + return {}; + } + ); + + const operationPromises = deferredPromises(2); + clientPool.run(REQUEST_TAG, () => operationPromises[0].promise); + const completionPromise = clientPool.run( + REQUEST_TAG, + () => operationPromises[1].promise + ); + expect(clientPool.size).to.equal(2); + + operationPromises[0].resolve(); + operationPromises[1].resolve(); + await completionPromise; + expect(clientPool.size).to.equal(1); + }); + it('rejects subsequent operations after being terminated', () => { - const clientPool = new ClientPool<{}>(1, () => { + const clientPool = new ClientPool<{}>(1, 0, () => { return {}; }); diff --git a/dev/test/typescript.ts b/dev/test/typescript.ts index 7cdd3452b..80993ddf2 100644 --- a/dev/test/typescript.ts +++ b/dev/test/typescript.ts @@ -58,6 +58,7 @@ xdescribe('firestore.d.ts', () => { firestore.settings({ keyFilename: 'foo', projectId: 'foo', + maxIdleChannels: 42, otherOption: 'foo', }); const collRef: CollectionReference = firestore.collection('coll'); diff --git a/dev/test/util/helpers.ts b/dev/test/util/helpers.ts index d47a8ff67..9877f6faa 100644 --- a/dev/test/util/helpers.ts +++ b/dev/test/util/helpers.ts @@ -105,20 +105,26 @@ export function createInstance( const firestore = new Firestore(); firestore.settings(initializationOptions); - const clientPool = new ClientPool(/* concurrentRequestLimit= */ 1, () => { - const gapicClient: GapicClient = new v1(initializationOptions); - if (apiOverrides) { - Object.keys(apiOverrides).forEach(override => { - const apiOverride = (apiOverrides as {[k: string]: unknown})[override]; - if (override !== 'getProjectId') { - gapicClient._innerApiCalls[override] = apiOverride; - } else { - gapicClient[override] = apiOverride; - } - }); + const clientPool = new ClientPool( + /* concurrentRequestLimit= */ 1, + /* maxIdleClients= */ 0, + () => { + const gapicClient: GapicClient = new v1(initializationOptions); + if (apiOverrides) { + Object.keys(apiOverrides).forEach(override => { + const apiOverride = (apiOverrides as {[k: string]: unknown})[ + override + ]; + if (override !== 'getProjectId') { + gapicClient._innerApiCalls[override] = apiOverride; + } else { + gapicClient[override] = apiOverride; + } + }); + } + return gapicClient; } - return gapicClient; - }); + ); firestore['_clientPool'] = clientPool; diff --git a/dev/test/watch.ts b/dev/test/watch.ts index 99b9d37e1..bc2c0792e 100644 --- a/dev/test/watch.ts +++ b/dev/test/watch.ts @@ -926,7 +926,7 @@ describe('Query watch', () => { } return result; - }); + }).timeout(5000); it('retries with unknown code', () => { return watchHelper.runTest(collQueryJSON(), () => { diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 3a7122922..c6f5f1533 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -80,6 +80,14 @@ declare namespace FirebaseFirestore { /** 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; + [key: string]: any; // Accept other properties, such as GRPC settings. } From 069043e9bec726e064b46c859b026ff90d6409a1 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Mon, 30 Dec 2019 08:54:55 -0800 Subject: [PATCH 013/337] refactor: use explicit mocha imports (#841) --- dev/conformance/.eslintrc.yml | 2 -- dev/src/document.ts | 1 + dev/src/pool.ts | 1 + dev/src/watch.ts | 1 + dev/src/write-batch.ts | 1 + dev/system-test/.eslintrc.yml | 2 -- dev/test/gapic-firestore-v1.ts | 1 + dev/test/gapic-firestore-v1beta1.ts | 1 + dev/test/gapic-firestore_admin-v1.ts | 1 + samples/test/.eslintrc.yml | 3 --- samples/test/quickstart.test.js | 1 + 11 files changed, 8 insertions(+), 7 deletions(-) delete mode 100644 samples/test/.eslintrc.yml diff --git a/dev/conformance/.eslintrc.yml b/dev/conformance/.eslintrc.yml index 73f7bbc94..cd088a978 100644 --- a/dev/conformance/.eslintrc.yml +++ b/dev/conformance/.eslintrc.yml @@ -1,5 +1,3 @@ --- -env: - mocha: true rules: node/no-unpublished-require: off diff --git a/dev/src/document.ts b/dev/src/document.ts index 434f78656..6cb6f1480 100644 --- a/dev/src/document.ts +++ b/dev/src/document.ts @@ -17,6 +17,7 @@ const deepEqual = require('deep-equal'); import * as assert from 'assert'; +import {describe, it} from 'mocha'; import {google} from '../protos/firestore_v1_proto_api'; import {FieldTransform} from './field-value'; diff --git a/dev/src/pool.ts b/dev/src/pool.ts index 0c82a435e..1e2d51123 100644 --- a/dev/src/pool.ts +++ b/dev/src/pool.ts @@ -15,6 +15,7 @@ */ import * as assert from 'assert'; +import {describe, it} from 'mocha'; import {logger} from './logger'; diff --git a/dev/src/watch.ts b/dev/src/watch.ts index 24caca2dc..d6434a23e 100644 --- a/dev/src/watch.ts +++ b/dev/src/watch.ts @@ -16,6 +16,7 @@ import * as assert from 'assert'; import * as rbtree from 'functional-red-black-tree'; +import {describe, it} from 'mocha'; import {google} from '../protos/firestore_v1_proto_api'; import {ExponentialBackoff} from './backoff'; diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 884c0e373..1f6cc7cd4 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -15,6 +15,7 @@ */ import * as assert from 'assert'; +import {describe, it} from 'mocha'; import {google} from '../protos/firestore_v1_proto_api'; import { diff --git a/dev/system-test/.eslintrc.yml b/dev/system-test/.eslintrc.yml index dc5d9b017..cd21505a4 100644 --- a/dev/system-test/.eslintrc.yml +++ b/dev/system-test/.eslintrc.yml @@ -1,4 +1,2 @@ --- -env: - mocha: true diff --git a/dev/test/gapic-firestore-v1.ts b/dev/test/gapic-firestore-v1.ts index d598e2fbb..defb39701 100644 --- a/dev/test/gapic-firestore-v1.ts +++ b/dev/test/gapic-firestore-v1.ts @@ -17,6 +17,7 @@ // ** All changes to this file may be overwritten. ** import * as assert from 'assert'; +import {describe, it} from 'mocha'; import * as protosTypes from '../protos/firestore_v1_proto_api'; const firestoreModule = require('../src'); diff --git a/dev/test/gapic-firestore-v1beta1.ts b/dev/test/gapic-firestore-v1beta1.ts index f45876f46..f28bedefd 100644 --- a/dev/test/gapic-firestore-v1beta1.ts +++ b/dev/test/gapic-firestore-v1beta1.ts @@ -17,6 +17,7 @@ // ** All changes to this file may be overwritten. ** import * as assert from 'assert'; +import {describe, it} from 'mocha'; import * as protosTypes from '../protos/firestore_v1beta1_proto_api'; const firestoreModule = require('../src'); diff --git a/dev/test/gapic-firestore_admin-v1.ts b/dev/test/gapic-firestore_admin-v1.ts index c6aa9a187..2515aeadc 100644 --- a/dev/test/gapic-firestore_admin-v1.ts +++ b/dev/test/gapic-firestore_admin-v1.ts @@ -17,6 +17,7 @@ // ** All changes to this file may be overwritten. ** import * as assert from 'assert'; +import {describe, it} from 'mocha'; import * as protosTypes from '../protos/firestore_admin_v1_proto_api'; const firestoreadminModule = require('../src'); diff --git a/samples/test/.eslintrc.yml b/samples/test/.eslintrc.yml deleted file mode 100644 index 6db2a46c5..000000000 --- a/samples/test/.eslintrc.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -env: - mocha: true diff --git a/samples/test/quickstart.test.js b/samples/test/quickstart.test.js index 47f404845..d574bcc6c 100644 --- a/samples/test/quickstart.test.js +++ b/samples/test/quickstart.test.js @@ -16,6 +16,7 @@ const {execSync} = require('child_process'); const {assert} = require('chai'); +const {describe, it} = require('mocha'); const exec = cmd => execSync(cmd, { encoding: 'utf8' }); describe('should make some API calls', () => { From 144528692e828d41f051515918be31a2b27c0a39 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2019 09:08:35 -0800 Subject: [PATCH 014/337] chore: release 3.2.0 (#840) --- CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74e1804b5..ba8de1e5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [3.2.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.1.0...v3.2.0) (2019-12-30) + + +### Features + +* allow specifying how many idle GRPC channels to keep ([#837](https://www.github.com/googleapis/nodejs-firestore/issues/837)) ([37e93da](https://www.github.com/googleapis/nodejs-firestore/commit/37e93da689f985b6b0f30645435b12179513eb64)) + + +### Bug Fixes + +* reduce overhead for listDocuments()/listCollections() ([#838](https://www.github.com/googleapis/nodejs-firestore/issues/838)) ([5c870e6](https://www.github.com/googleapis/nodejs-firestore/commit/5c870e615e4774d3d50fc33c17b5da45dcacea4f)) + ## [3.1.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.0.0...v3.1.0) (2019-12-19) diff --git a/package.json b/package.json index fc08730d4..7f49dc447 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.1.0", + "version": "3.2.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 630cae1eb..e34c91768 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.1.0" + "@google-cloud/firestore": "^3.2.0" }, "devDependencies": { "chai": "^4.2.0", From b94c367e9655f8a6a3553610ebc655877be502ec Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 31 Dec 2019 07:47:34 +0800 Subject: [PATCH 015/337] fix: increase test timeout (#846) --- dev/test/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/test/index.ts b/dev/test/index.ts index bffc04e7a..7cd355631 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -1073,7 +1073,7 @@ describe('getAll() method', () => { expect(actualErrorAttempts).to.deep.eq(expectedErrorAttempts); }); }); - }); + }).timeout(5000); it('requires at least one argument', () => { return createInstance().then(firestore => { From 68795c43ae9ef6b286650228746c7c16f59347f7 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 30 Dec 2019 19:58:17 -0800 Subject: [PATCH 016/337] feat: add Symbol.asyncInterator to Query.stream() (#843) --- dev/src/external-modules.d.ts | 20 ++- dev/src/index.ts | 260 ++++++++++------------------------ dev/src/reference.ts | 7 +- dev/src/watch.ts | 9 +- dev/system-test/firestore.ts | 16 ++- dev/test/watch.ts | 2 + package.json | 2 +- 7 files changed, 122 insertions(+), 194 deletions(-) diff --git a/dev/src/external-modules.d.ts b/dev/src/external-modules.d.ts index 40761eba0..2747e5615 100644 --- a/dev/src/external-modules.d.ts +++ b/dev/src/external-modules.d.ts @@ -1,4 +1,18 @@ -// TODO(mrschmidt): Come up with actual definitions for these modules. +/*! + * Copyright 2019 Google Inc. All Rights Reserved. + * + * 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. + */ -declare module 'bun'; -declare module 'functional-red-black-tree' \ No newline at end of file +// TODO(mrschmidt): Come up with actual definitions for these modules. +declare module 'functional-red-black-tree' diff --git a/dev/src/index.ts b/dev/src/index.ts index 2f0d7e430..5211ae25f 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import * as bun from 'bun'; import {CallOptions} from 'google-gax'; +import {Duplex, PassThrough} from 'stream'; import * as through2 from 'through2'; import {URL} from 'url'; @@ -950,7 +950,7 @@ export class Firestore { const self = this; return self - .readStream('batchGetDocuments', request, requestTag, true) + .requestStream('batchGetDocuments', 'unidirectional', request, requestTag) .then(stream => { return new Promise((resolve, reject) => { stream @@ -1166,33 +1166,25 @@ export class Firestore { } /** - * Opens the provided stream and waits for it to become healthy. If an error - * occurs before the first byte is read, the method rejects the returned - * Promise. + * Waits for the provided stream to become active and returns a paused but + * healthy stream. If an error occurs before the first byte is read, the + * method rejects the returned Promise. * * @private - * @param resultStream The Node stream to monitor. + * @param backendStream The Node stream to monitor. * @param requestTag A unique client-assigned identifier for this request. * @param request If specified, the request that should be written to the - * stream after it opened. - * @returns The given Stream once it is considered healthy. + * stream after opening. + * @returns A guaranteed healthy stream that should be used instead of + * `backendStream`. */ private _initializeStream( - resultStream: NodeJS.ReadableStream, - requestTag: string - ): Promise; - private _initializeStream( - resultStream: NodeJS.ReadWriteStream, - requestTag: string, - request: {} - ): Promise; - private _initializeStream( - resultStream: NodeJS.ReadableStream | NodeJS.ReadWriteStream, + backendStream: Duplex, requestTag: string, request?: {} - ): Promise { - /** The last error we received and have not forwarded yet. */ - let errorReceived: Error | null = null; + ): Promise { + const resultStream = new PassThrough({objectMode: true}); + resultStream.pause(); /** * Whether we have resolved the Promise and returned the stream to the @@ -1200,91 +1192,59 @@ export class Firestore { */ let streamInitialized = false; - /** - * Whether the stream end has been reached. This has to be forwarded to the - * caller.. - */ - let endCalled = false; - - return new Promise((resolve, reject) => { - const streamReady = () => { - if (errorReceived) { - logger( - 'Firestore._initializeStream', - requestTag, - 'Emit error:', - errorReceived - ); - resultStream.emit('error', errorReceived); - errorReceived = null; - } else if (!streamInitialized) { - logger('Firestore._initializeStream', requestTag, 'Releasing stream'); + return new Promise((resolve, reject) => { + function streamReady() { + if (!streamInitialized) { streamInitialized = true; - resultStream.pause(); - - // Calling 'stream.pause()' only holds up 'data' events and not the - // 'end' event we intend to forward here. We therefore need to wait - // until the API consumer registers their listeners (in the .then() - // call) before emitting any further events. - resolve(); - - // We execute the forwarding of the 'end' event via setTimeout() as - // V8 guarantees that the above the Promise chain is resolved before - // any calls invoked via setTimeout(). - setTimeout(() => { - if (endCalled) { - logger( - 'Firestore._initializeStream', - requestTag, - 'Forwarding stream close' - ); - resultStream.emit('end'); - } - }, 0); + logger('Firestore._initializeStream', requestTag, 'Releasing stream'); + resolve(resultStream); } - }; - - // We capture any errors received and buffer them until the caller has - // registered a listener. We register our event handler as early as - // possible to avoid the default stream behavior (which is just to log and - // continue). - resultStream.on('readable', () => { - streamReady(); - }); + } - resultStream.on('end', () => { + function streamEnded() { logger( 'Firestore._initializeStream', requestTag, 'Received stream end' ); - endCalled = true; streamReady(); - }); + resultStream.unpipe(backendStream); + } - resultStream.on('error', err => { - logger( - 'Firestore._initializeStream', - requestTag, - 'Received stream error:', - err - ); - // If we receive an error before we were able to receive any data, - // reject this stream. + backendStream.on('data', () => streamReady()); + backendStream.on('end', () => streamEnded()); + backendStream.on('close', () => streamEnded()); + + backendStream.on('error', err => { if (!streamInitialized) { + // If we receive an error before we were able to receive any data, + // reject this stream. logger( 'Firestore._initializeStream', requestTag, 'Received initial error:', err ); - streamInitialized = true; reject(err); } else { - errorReceived = err; + logger( + 'Firestore._initializeStream', + requestTag, + 'Received stream error:', + err + ); + // We execute the forwarding of the 'error' event via setImmediate() as + // V8 guarantees that the Promise chain returned from this method + // is resolved before any code executed via setImmediate(). This + // allows the caller to attach an error handler. + setImmediate(() => { + resultStream.emit('error', err); + }, 0); } }); + backendStream.pipe(resultStream); + if (request) { logger( 'Firestore._initializeStream', @@ -1292,18 +1252,14 @@ export class Firestore { 'Sending request: %j', request ); - (resultStream as NodeJS.WritableStream) - // The stream returned by the Gapic library accepts Protobuf - // messages, but the type information does not expose this. - // tslint:disable-next-line no-any - .write(request as any, 'utf-8', () => { - logger( - 'Firestore._initializeStream', - requestTag, - 'Marking stream as healthy' - ); - streamReady(); - }); + backendStream.write(request, 'utf-8', () => { + logger( + 'Firestore._initializeStream', + requestTag, + 'Marking stream as healthy' + ); + streamReady(); + }); } }); } @@ -1363,8 +1319,8 @@ export class Firestore { } /** - * A funnel for read-only streaming API requests, assigning a project ID where - * necessary within the request options. + * A funnel for streaming API requests, assigning a project ID where necessary + * within the request options. * * The stream is returned in paused state and needs to be resumed once all * listeners are attached. @@ -1372,22 +1328,20 @@ export class Firestore { * @private * @param methodName Name of the streaming Veneer API endpoint that * takes a request and GAX options. + * @param mode Whether this a unidirectional or bidirectional call. * @param request The Protobuf request to send. * @param requestTag A unique client-assigned identifier for this request. - * @param allowRetries Whether this is an idempotent request that can be - * retried. * @returns A Promise with the resulting read-only stream. */ - readStream( + requestStream( methodName: string, + mode: 'unidirectional' | 'bidirectional', request: {}, - requestTag: string, - allowRetries: boolean - ): Promise { - const attempts = allowRetries ? MAX_REQUEST_RETRIES : 1; + requestTag: string + ): Promise { const callOptions = this.createCallOptions(); - const result = new Deferred(); + const result = new Deferred(); this._clientPool.run(requestTag, gapicClient => { // While we return the stream to the callee early, we don't want to @@ -1395,98 +1349,40 @@ export class Firestore { // stream. const lifetime = new Deferred(); - this._retry(attempts, requestTag, async () => { + this._retry(MAX_REQUEST_RETRIES, requestTag, async () => { logger( - 'Firestore.readStream', + 'Firestore.requestStream', requestTag, 'Sending request: %j', request ); - const stream = gapicClient[methodName](request, callOptions); + const stream: Duplex = + mode === 'unidirectional' + ? gapicClient[methodName](request, callOptions) + : gapicClient[methodName](callOptions); const logStream = through2.obj(function(this, chunk, enc, callback) { logger( - 'Firestore.readStream', + 'Firestore.requestStream', requestTag, 'Received response: %j', chunk ); - this.push(chunk); callback(); }); - const resultStream = bun([stream, logStream]); - resultStream.on('close', lifetime.resolve); - resultStream.on('end', lifetime.resolve); - resultStream.on('error', lifetime.resolve); - - await this._initializeStream(resultStream, requestTag); - result.resolve(resultStream); - }).catch(err => { - lifetime.resolve(); - result.reject(err); - }); - - return lifetime.promise; - }); - - return result.promise; - } + stream.pipe(logStream); + stream.on('close', lifetime.resolve); + stream.on('end', lifetime.resolve); + stream.on('finish', lifetime.resolve); + stream.on('error', lifetime.resolve); - /** - * A funnel for read-write streaming API requests, assigning a project ID - * where necessary for all writes. - * - * The stream is returned in paused state and needs to be resumed once all - * listeners are attached. - * - * @private - * @param methodName Name of the streaming Veneer API endpoint that takes - * GAX options. - * @param request The Protobuf request to send as the first stream message. - * @param requestTag A unique client-assigned identifier for this request. - * @param allowRetries Whether this is an idempotent request that can be - * retried. - * @returns A Promise with the resulting read/write stream. - */ - readWriteStream( - methodName: string, - request: {}, - requestTag: string, - allowRetries: boolean - ): Promise { - const attempts = allowRetries ? MAX_REQUEST_RETRIES : 1; - const callOptions = this.createCallOptions(); - - const result = new Deferred(); - - this._clientPool.run(requestTag, gapicClient => { - // While we return the stream to the callee early, we don't want to - // release the GAPIC client until the callee has finished processing the - // stream. - const lifetime = new Deferred(); - - this._retry(attempts, requestTag, async () => { - logger('Firestore.readWriteStream', requestTag, 'Opening stream'); - const requestStream = gapicClient[methodName](callOptions); - - const logStream = through2.obj(function(this, chunk, enc, callback) { - logger( - 'Firestore.readWriteStream', - requestTag, - 'Received response: %j', - chunk - ); - this.push(chunk); - callback(); - }); - - const resultStream = bun([requestStream, logStream]); - resultStream.on('close', lifetime.resolve); - resultStream.on('finish', lifetime.resolve); - resultStream.on('end', lifetime.resolve); - resultStream.on('error', lifetime.resolve); + const resultStream = await this._initializeStream( + stream, + requestTag, + mode === 'bidirectional' ? request : undefined + ); - await this._initializeStream(resultStream, requestTag, request); + resultStream.on('end', () => stream.end()); result.resolve(resultStream); }).catch(err => { lifetime.resolve(); diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 913b9505f..ae98085e3 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -16,7 +16,6 @@ const deepEqual = require('deep-equal'); -import * as bun from 'bun'; import * as through2 from 'through2'; import * as proto from '../protos/firestore_v1_proto_api'; @@ -1719,7 +1718,9 @@ export class Query { callback(); }); - return bun([responseStream, transform]); + responseStream.pipe(transform); + responseStream.on('error', transform.destroy); + return transform; } /** @@ -1833,7 +1834,7 @@ export class Query { this.firestore.initializeIfNeeded(tag).then(() => { const request = this.toProto(transactionId); this._firestore - .readStream('runQuery', request, tag, true) + .requestStream('runQuery', 'unidirectional', request, tag) .then(backendStream => { backendStream.on('error', err => { logger( diff --git a/dev/src/watch.ts b/dev/src/watch.ts index d6434a23e..9f4692852 100644 --- a/dev/src/watch.ts +++ b/dev/src/watch.ts @@ -17,6 +17,7 @@ import * as assert from 'assert'; import * as rbtree from 'functional-red-black-tree'; import {describe, it} from 'mocha'; +import {Duplex} from 'stream'; import {google} from '../protos/firestore_v1_proto_api'; import {ExponentialBackoff} from './backoff'; @@ -245,7 +246,7 @@ abstract class Watch { * The current stream to the backend. * @private */ - private currentStream: NodeJS.ReadWriteStream | null = null; + private currentStream: Duplex | null = null; /** * The server assigns and updates the resume token. @@ -359,7 +360,7 @@ abstract class Watch { this.initStream(); return () => { - logger('Watch.onSnapshot', this.requestTag, 'Ending stream'); + logger('Watch.onSnapshot', this.requestTag, 'Unsubscribe called'); // Prevent further callbacks. this.isActive = false; this.onNext = () => {}; @@ -505,7 +506,7 @@ abstract class Watch { // Note that we need to call the internal _listen API to pass additional // header values in readWriteStream. return this.firestore - .readWriteStream('listen', request, this.requestTag, true) + .requestStream('listen', 'bidirectional', request, this.requestTag) .then(backendStream => { if (!this.isActive) { logger( @@ -513,7 +514,7 @@ abstract class Watch { this.requestTag, 'Closing inactive stream' ); - backendStream.end(); + backendStream.emit('end'); return; } logger('Watch.initStream', this.requestTag, 'Opened new stream'); diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index e5b45af62..9d2fe9d2d 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -1345,7 +1345,8 @@ describe('Query class', () => { Promise.all([ref1.set({foo: 'a'}), ref2.set({foo: 'b'})]).then(() => { return randomCol .stream() - .on('data', () => { + .on('data', d => { + expect(d).to.be.an.instanceOf(DocumentSnapshot); ++received; }) .on('end', () => { @@ -1355,6 +1356,19 @@ describe('Query class', () => { }); }); + it('stream() supports readable[Symbol.asyncIterator]()', async () => { + let received = 0; + await randomCol.doc().set({foo: 'bar'}); + await randomCol.doc().set({foo: 'bar'}); + + const stream = randomCol.stream(); + for await (const chunk of stream) { + ++received; + } + + expect(received).to.equal(2); + }); + it('can query collection groups', async () => { // Use `randomCol` to get a random collection group name to use but ensure // it starts with 'b' for predictable ordering. diff --git a/dev/test/watch.ts b/dev/test/watch.ts index bc2c0792e..5a5dbbc6e 100644 --- a/dev/test/watch.ts +++ b/dev/test/watch.ts @@ -807,9 +807,11 @@ describe('Query watch', () => { watchHelper.sendSnapshot(1, Buffer.from([0xabcd])); return watchHelper.await('snapshot').then(async () => { streamHelper.close(); + await streamHelper.await('end'); await streamHelper.awaitOpen(); streamHelper.close(); + await streamHelper.await('end'); await streamHelper.awaitOpen(); expect(streamHelper.streamCount).to.equal(3); diff --git a/package.json b/package.json index 7f49dc447..05e7fef74 100644 --- a/package.json +++ b/package.json @@ -47,10 +47,10 @@ "predocs-test": "npm run docs" }, "dependencies": { - "bun": "^0.0.12", "deep-equal": "^2.0.0", "functional-red-black-tree": "^1.0.1", "google-gax": "^1.12.0", + "readable-stream": "^3.4.0", "through2": "^3.0.0" }, "devDependencies": { From 2ad8acc6101f7b20c6881b66ed6eb66f99a699b3 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 31 Dec 2019 23:59:55 +0200 Subject: [PATCH 017/337] fix(deps): roll back dependency @google-cloud/firestore to ^3.1.0 (#848) --- samples/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/package.json b/samples/package.json index e34c91768..630cae1eb 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.2.0" + "@google-cloud/firestore": "^3.1.0" }, "devDependencies": { "chai": "^4.2.0", From 218a4c65afcc55158aac45b98a4ccb28b88c00a1 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 2 Jan 2020 13:17:50 -0800 Subject: [PATCH 018/337] feat: use GAX retry config for streams (#847) --- README.md | 4 +- dev/src/backoff.ts | 4 +- dev/src/index.ts | 169 ++++++++++++++++++--------------------- dev/src/reference.ts | 14 +--- dev/src/transaction.ts | 15 +--- dev/src/types.ts | 4 - dev/src/util.ts | 25 ++++++ dev/src/watch.ts | 156 +++++------------------------------- dev/src/write-batch.ts | 10 +-- dev/test/document.ts | 30 +------ dev/test/index.ts | 105 +++++++++++++++--------- dev/test/query.ts | 7 +- dev/test/transaction.ts | 19 +---- dev/test/util/helpers.ts | 4 +- dev/test/watch.ts | 138 +++++++++++++++----------------- package.json | 2 +- 16 files changed, 275 insertions(+), 431 deletions(-) diff --git a/README.md b/README.md index d1cd97732..536072cc8 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,7 @@ This is the Node.js Server SDK for [Google Cloud Firestore](https://firebase.goo This Cloud Firestore Server SDK uses Google’s Cloud Identity and Access Management for authentication and should only be used in trusted environments. Your Cloud Identity credentials allow you bypass all access restrictions and provide read and write access to all data in your Cloud Firestore project. -The Cloud Firestore Server SDKs are designed to manage the full set of data in your Cloud Firestore project and work best with reliable network connectivity. Data operations performed via these SDKs directly access the Cloud Firestore backend and all document reads and writes are optimized for high throughput. - -Applications that use Google's Server SDKs should not be used in end-user environments, such as on phones or on publicly hosted websites. If you are developing a Web or Node.js application that accesses Cloud Firestore on behalf of end users, use the firebase Client SDK. +Applications that use Google's Server SDKs should not be used in end-user environments, such as on phones or on publicly hosted websites. If you are developing a Web or Node.js application that accesses Cloud Firestore on behalf of end users, use the Firebase Client SDK. **Note:** This Cloud Firestore Server SDK does not support Firestore databases created in [Datastore mode](https://cloud.google.com/datastore/docs/firestore-or-datastore#in_datastore_mode). To access these databases, use the [Datastore SDK](https://www.npmjs.com/package/@google-cloud/datastore). diff --git a/dev/src/backoff.ts b/dev/src/backoff.ts index 6529ecebd..f0bc32017 100644 --- a/dev/src/backoff.ts +++ b/dev/src/backoff.ts @@ -80,7 +80,7 @@ export function setTimeoutHandler( * * @private */ -export interface ExponentialBackoffOptions { +export interface ExponentialBackoffSetting { /** Optional override for the initial retry delay. */ initialDelayMs?: number; /** Optional override for the exponential backoff factor. */ @@ -162,7 +162,7 @@ export class ExponentialBackoff { */ private awaitingBackoffCompletion = false; - constructor(options: ExponentialBackoffOptions = {}) { + constructor(options: ExponentialBackoffSetting = {}) { this.initialDelayMs = options.initialDelayMs !== undefined ? options.initialDelayMs diff --git a/dev/src/index.ts b/dev/src/index.ts index 5211ae25f..c765b30b5 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -14,12 +14,13 @@ * limitations under the License. */ -import {CallOptions} from 'google-gax'; +import {CallOptions, GoogleError} from 'google-gax'; import {Duplex, PassThrough} from 'stream'; import * as through2 from 'through2'; import {URL} from 'url'; import {google} from '../protos/firestore_v1_proto_api'; +import {ExponentialBackoff, ExponentialBackoffSetting} from './backoff'; import {fieldsFromJson, timestampFromJson} from './convert'; import { DocumentSnapshot, @@ -40,14 +41,8 @@ import {DocumentReference} from './reference'; import {Serializer} from './serializer'; import {Timestamp} from './timestamp'; import {parseGetAllArguments, Transaction} from './transaction'; -import { - ApiMapValue, - GapicClient, - GrpcError, - ReadOptions, - Settings, -} from './types'; -import {Deferred, requestTag} from './util'; +import {ApiMapValue, GapicClient, ReadOptions, Settings} from './types'; +import {Deferred, isPermanentRpcError, requestTag} from './util'; import { validateBoolean, validateFunction, @@ -59,6 +54,9 @@ import { } from './validate'; import {WriteBatch} from './write-batch'; +import {interfaces} from './v1/firestore_client_config.json'; +const serviceConfig = interfaces['google.firestore.v1.Firestore']; + import api = google.firestore.v1; export { @@ -143,11 +141,6 @@ const DEFAULT_MAX_IDLE_CHANNELS = 1; */ const MAX_CONCURRENT_REQUESTS_PER_CLIENT = 100; -/*! - * GRPC Error code for 'UNAVAILABLE'. - */ -const GRPC_UNAVAILABLE = 14; - /** * Document data (e.g. for use with * [set()]{@link DocumentReference#set}) consisting of fields mapped @@ -265,6 +258,12 @@ export class Firestore { */ private _settings: Settings = {}; + /** + * Settings for the exponential backoff used by the streaming endpoints. + * @private + */ + private _backoffSettings: ExponentialBackoffSetting; + /** * Whether the initialization settings can still be changed by invoking * `settings()`. @@ -368,6 +367,13 @@ export class Firestore { this.validateAndApplySettings({...settings, ...libraryHeader}); } + const retryConfig = serviceConfig.retry_params.default; + this._backoffSettings = { + initialDelayMs: retryConfig.initial_retry_delay_millis, + maxDelayMs: retryConfig.max_retry_delay_millis, + backoffFactor: retryConfig.retry_delay_multiplier, + }; + // 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 @@ -1107,62 +1113,53 @@ export class Firestore { * for further attempts. * * @private - * @param attemptsRemaining The number of available attempts. + * @param methodName Name of the Veneer API endpoint that takes a request + * and GAX options. * @param requestTag A unique client-assigned identifier for this request. * @param func Method returning a Promise than can be retried. - * @param delayMs How long to wait before issuing a this retry. Defaults to - * zero. * @returns - A Promise with the function's result if successful within * `attemptsRemaining`. Otherwise, returns the last rejected Promise. */ - private _retry( - attemptsRemaining: number, + private async _retry( + methodName: string, requestTag: string, - func: () => Promise, - delayMs = 0 + func: () => Promise ): Promise { - const self = this; + const backoff = new ExponentialBackoff(); - const currentDelay = delayMs; - const nextDelay = delayMs || 100; + let lastError: Error | undefined = undefined; - --attemptsRemaining; - - return new Promise(resolve => { - setTimeout(resolve, currentDelay); - }) - .then(func) - .then(result => { - self._lastSuccessfulRequest = new Date().getTime(); - return result; - }) - .catch(err => { - if (err.code !== undefined && err.code !== GRPC_UNAVAILABLE) { - logger( - 'Firestore._retry', - requestTag, - 'Request failed with unrecoverable error:', - err - ); - return Promise.reject(err); - } - if (attemptsRemaining === 0) { - logger( - 'Firestore._retry', - requestTag, - 'Request failed with error:', - err - ); - return Promise.reject(err); - } + for (let attempt = 0; attempt < MAX_REQUEST_RETRIES; ++attempt) { + if (lastError) { logger( 'Firestore._retry', requestTag, 'Retrying request that failed with error:', - err + lastError ); - return self._retry(attemptsRemaining, requestTag, func, nextDelay); - }); + } + + try { + await backoff.backoffAndWait(); + const result = await func(); + this._lastSuccessfulRequest = new Date().getTime(); + return result; + } catch (err) { + lastError = err; + + if (isPermanentRpcError(err, methodName, serviceConfig)) { + break; + } + } + } + + logger( + 'Firestore._retry', + requestTag, + 'Request failed with error:', + lastError + ); + return Promise.reject(lastError); } /** @@ -1269,51 +1266,37 @@ export class Firestore { * necessary within the request options. * * @private - * @param methodName Name of the veneer API endpoint that takes a request + * @param methodName Name of the Veneer API endpoint that takes a request * and GAX options. * @param request The Protobuf request to send. * @param requestTag A unique client-assigned identifier for this request. - * @param allowRetries Whether this is an idempotent request that can be - * retried. * @returns A Promise with the request result. */ - request( - methodName: string, - request: {}, - requestTag: string, - allowRetries: boolean - ): Promise { - const attempts = allowRetries ? MAX_REQUEST_RETRIES : 1; + request(methodName: string, request: {}, requestTag: string): Promise { const callOptions = this.createCallOptions(); return this._clientPool.run(requestTag, gapicClient => { - return this._retry(attempts, requestTag, () => { - return new Promise((resolve, reject) => { - logger( - 'Firestore.request', - requestTag, - 'Sending request: %j', - request - ); - gapicClient[methodName]( - request, - callOptions, - (err: GrpcError, result: T) => { - if (err) { - logger('Firestore.request', requestTag, 'Received error:', err); - reject(err); - } else { - logger( - 'Firestore.request', - requestTag, - 'Received response: %j', - result - ); - resolve(result); - } + return new Promise((resolve, reject) => { + logger('Firestore.request', requestTag, 'Sending request: %j', request); + gapicClient[methodName]( + request, + callOptions, + (err: GoogleError, result: T) => { + if (err) { + logger('Firestore.request', requestTag, 'Received error:', err); + reject(err); + } else { + logger( + 'Firestore.request', + requestTag, + 'Received response: %j', + result + ); + this._lastSuccessfulRequest = new Date().getTime(); + resolve(result); } - ); - }); + } + ); }); }); } @@ -1349,7 +1332,7 @@ export class Firestore { // stream. const lifetime = new Deferred(); - this._retry(MAX_REQUEST_RETRIES, requestTag, async () => { + this._retry(methodName, requestTag, async () => { logger( 'Firestore.requestStream', requestTag, diff --git a/dev/src/reference.ts b/dev/src/reference.ts index ae98085e3..048622b0e 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -293,12 +293,7 @@ export class DocumentReference implements Serializable { pageSize: Math.pow(2, 16) - 1, }; return this._firestore - .request( - 'listCollectionIds', - request, - tag, - /* allowRetries= */ true - ) + .request('listCollectionIds', request, tag) .then(collectionIds => { const collections: CollectionReference[] = []; @@ -2065,12 +2060,7 @@ export class CollectionReference extends Query { }; return this.firestore - .request( - 'listDocuments', - request, - tag, - /*allowRetries=*/ true - ) + .request('listDocuments', request, tag) .then(documents => { // Note that the backend already orders these documents by name, // so we do not need to manually sort them. diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index 5d260a1c8..25b7cea24 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -50,11 +50,6 @@ import api = proto.google.firestore.v1; const READ_AFTER_WRITE_ERROR_MSG = 'Firestore transactions require all reads to be executed before all writes.'; -/*! - * Transactions can be retried if the initial stream opening errors out. - */ -const ALLOW_RETRIES = true; - /** * A reference to a transaction. * @@ -372,8 +367,7 @@ export class Transaction { .request( 'beginTransaction', request, - this._requestTag, - ALLOW_RETRIES + this._requestTag ) .then(resp => { this._transactionId = resp.transaction!; @@ -405,12 +399,7 @@ export class Transaction { transaction: this._transactionId, }; - return this._firestore.request( - 'rollback', - request, - this._requestTag, - /* allowRetries= */ false - ); + return this._firestore.request('rollback', request, this._requestTag); } /** diff --git a/dev/src/types.ts b/dev/src/types.ts index a70517a2d..cca4fdc0d 100644 --- a/dev/src/types.ts +++ b/dev/src/types.ts @@ -36,10 +36,6 @@ export type GapicClient = any; // tslint:disable-next-line:no-any export type RBTree = any; -export class GrpcError extends Error { - code?: number; -} - /** * Settings used to directly configure a `Firestore` instance. */ diff --git a/dev/src/util.ts b/dev/src/util.ts index b3915e97b..95252e5a4 100644 --- a/dev/src/util.ts +++ b/dev/src/util.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import {GoogleError, ServiceConfig, Status} from 'google-gax'; + /** * A Promise implementation that supports deferred resolution. * @private @@ -92,3 +94,26 @@ export function isEmpty(value: {}): boolean { export function isFunction(value: unknown): boolean { return typeof value === 'function'; } + +/** + * Determines whether the provided error is considered permanent for the given + * RPC. + * + * @private + */ +export function isPermanentRpcError( + err: GoogleError, + methodName: string, + config: ServiceConfig +): boolean { + if (err.code !== undefined) { + const serviceConfigName = methodName[0].toUpperCase() + methodName.slice(1); + const retryCodeNames = config.methods[serviceConfigName]!.retry_codes_name!; + const retryCodes = config.retry_codes![retryCodeNames].map( + errorName => Status[errorName as keyof typeof Status] + ); + return retryCodes.indexOf(err.code) === -1; + } else { + return false; + } +} diff --git a/dev/src/watch.ts b/dev/src/watch.ts index 9f4692852..6771399fa 100644 --- a/dev/src/watch.ts +++ b/dev/src/watch.ts @@ -16,6 +16,7 @@ import * as assert from 'assert'; import * as rbtree from 'functional-red-black-tree'; +import {GoogleError, Status} from 'google-gax'; import {describe, it} from 'mocha'; import {Duplex} from 'stream'; @@ -27,7 +28,7 @@ import {DocumentReference, Firestore, Query} from './index'; import {logger} from './logger'; import {QualifiedResourcePath} from './path'; import {Timestamp} from './timestamp'; -import {GrpcError, RBTree} from './types'; +import {RBTree} from './types'; import {requestTag} from './util'; import api = google.firestore.v1; @@ -54,123 +55,6 @@ const ChangeType: {[k: string]: DocumentChangeType} = { removed: 'removed', }; -/*! - * List of GRPC Error Codes. - * - * This corresponds to - * {@link https://github.com/grpc/grpc/blob/master/doc/statuscodes.md}. - */ -const GRPC_STATUS_CODE: {[k: string]: number} = { - // Not an error; returned on success. - OK: 0, - - // The operation was cancelled (typically by the caller). - CANCELLED: 1, - - // Unknown error. An example of where this error may be returned is if a - // Status value received from another address space belongs to an error-space - // that is not known in this address space. Also errors raised by APIs that - // do not return enough error information may be converted to this error. - UNKNOWN: 2, - - // Client specified an invalid argument. Note that this differs from - // FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments that are - // problematic regardless of the state of the system (e.g., a malformed file - // name). - INVALID_ARGUMENT: 3, - - // Deadline expired before operation could complete. For operations that - // change the state of the system, this error may be returned even if the - // operation has completed successfully. For example, a successful response - // from a server could have been delayed long enough for the deadline to - // expire. - DEADLINE_EXCEEDED: 4, - - // Some requested entity (e.g., file or directory) was not found. - NOT_FOUND: 5, - - // Some entity that we attempted to create (e.g., file or directory) already - // exists. - ALREADY_EXISTS: 6, - - // The caller does not have permission to execute the specified operation. - // PERMISSION_DENIED must not be used for rejections caused by exhausting - // some resource (use RESOURCE_EXHAUSTED instead for those errors). - // PERMISSION_DENIED must not be used if the caller can not be identified - // (use UNAUTHENTICATED instead for those errors). - PERMISSION_DENIED: 7, - - // The request does not have valid authentication credentials for the - // operation. - UNAUTHENTICATED: 16, - - // Some resource has been exhausted, perhaps a per-user quota, or perhaps the - // entire file system is out of space. - RESOURCE_EXHAUSTED: 8, - - // Operation was rejected because the system is not in a state required for - // the operation's execution. For example, directory to be deleted may be - // non-empty, an rmdir operation is applied to a non-directory, etc. - // - // A litmus test that may help a service implementor in deciding - // between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE: - // (a) Use UNAVAILABLE if the client can retry just the failing call. - // (b) Use ABORTED if the client should retry at a higher-level - // (e.g., restarting a read-modify-write sequence). - // (c) Use FAILED_PRECONDITION if the client should not retry until - // the system state has been explicitly fixed. E.g., if an "rmdir" - // fails because the directory is non-empty, FAILED_PRECONDITION - // should be returned since the client should not retry unless - // they have first fixed up the directory by deleting files from it. - // (d) Use FAILED_PRECONDITION if the client performs conditional - // REST Get/Update/Delete on a resource and the resource on the - // server does not match the condition. E.g., conflicting - // read-modify-write on the same resource. - FAILED_PRECONDITION: 9, - - // The operation was aborted, typically due to a concurrency issue like - // sequencer check failures, transaction aborts, etc. - // - // See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, - // and UNAVAILABLE. - ABORTED: 10, - - // Operation was attempted past the valid range. E.g., seeking or reading - // past end of file. - // - // Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed - // if the system state changes. For example, a 32-bit file system will - // generate INVALID_ARGUMENT if asked to read at an offset that is not in the - // range [0,2^32-1], but it will generate OUT_OF_RANGE if asked to read from - // an offset past the current file size. - // - // There is a fair bit of overlap between FAILED_PRECONDITION and - // OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific error) - // when it applies so that callers who are iterating through a space can - // easily look for an OUT_OF_RANGE error to detect when they are done. - OUT_OF_RANGE: 11, - - // Operation is not implemented or not supported/enabled in this service. - UNIMPLEMENTED: 12, - - // Internal errors. Means some invariants expected by underlying System has - // been broken. If you see one of these errors, Something is very broken. - INTERNAL: 13, - - // The service is currently unavailable. This is a most likely a transient - // condition and may be corrected by retrying with a backoff. - // - // See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, - // and UNAVAILABLE. - UNAVAILABLE: 14, - - // Unrecoverable data loss or corruption. - DATA_LOSS: 15, - - // Force users to include a default branch: - DO_NOT_USE: -1, -}; - /*! * The comparator used for document watches (which should always get called with * the same document). @@ -429,7 +313,7 @@ abstract class Watch { * Closes the stream and calls onError() if the stream is still active. * @private */ - private closeStream(err: GrpcError): void { + private closeStream(err: GoogleError): void { if (this.currentStream) { this.currentStream.end(); this.currentStream = null; @@ -447,8 +331,8 @@ abstract class Watch { * Clears the change map. * @private */ - private maybeReopenStream(err: GrpcError): void { - if (this.isActive && !this.isPermanentError(err)) { + private maybeReopenStream(err: GoogleError): void { + if (this.isActive && !this.isPermanentWatchError(err)) { logger( 'Watch.maybeReopenStream', this.requestTag, @@ -532,8 +416,8 @@ abstract class Watch { if (this.currentStream === backendStream) { this.currentStream = null; - const err = new GrpcError('Stream ended unexpectedly'); - err.code = GRPC_STATUS_CODE.UNKNOWN; + const err = new GoogleError('Stream ended unexpectedly'); + err.code = Status.UNKNOWN; this.maybeReopenStream(err); } }); @@ -569,7 +453,7 @@ abstract class Watch { this.closeStream(Error('Unexpected target ID sent by server')); } } else if (change.targetChangeType === 'REMOVE') { - let code = 13; + let code = Status.INTERNAL; let message = 'internal error'; if (change.cause) { code = change.cause.code!; @@ -808,7 +692,7 @@ abstract class Watch { } /** - * Determines whether an error is considered permanent and should not be + * Determines whether a watch error is considered permanent and should not be * retried. Errors that don't provide a GRPC error code are always considered * transient in this context. * @@ -816,7 +700,7 @@ abstract class Watch { * @param error An error object. * @return Whether the error is permanent. */ - private isPermanentError(error: GrpcError): boolean { + private isPermanentWatchError(error: GoogleError): boolean { if (error.code === undefined) { logger( 'Watch.isPermanentError', @@ -828,14 +712,14 @@ abstract class Watch { } switch (error.code) { - case GRPC_STATUS_CODE.ABORTED: - case GRPC_STATUS_CODE.CANCELLED: - case GRPC_STATUS_CODE.UNKNOWN: - case GRPC_STATUS_CODE.DEADLINE_EXCEEDED: - case GRPC_STATUS_CODE.RESOURCE_EXHAUSTED: - case GRPC_STATUS_CODE.INTERNAL: - case GRPC_STATUS_CODE.UNAVAILABLE: - case GRPC_STATUS_CODE.UNAUTHENTICATED: + case Status.ABORTED: + case Status.CANCELLED: + case Status.UNKNOWN: + case Status.DEADLINE_EXCEEDED: + case Status.RESOURCE_EXHAUSTED: + case Status.INTERNAL: + case Status.UNAVAILABLE: + case Status.UNAUTHENTICATED: return false; default: return true; @@ -850,8 +734,8 @@ abstract class Watch { * @param error A GRPC Error object that exposes an error code. * @return Whether we need to back off our retries. */ - private isResourceExhaustedError(error: GrpcError): boolean { - return error.code === GRPC_STATUS_CODE.RESOURCE_EXHAUSTED; + private isResourceExhaustedError(error: GoogleError): boolean { + return error.code === Status.RESOURCE_EXHAUSTED; } } diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 1f6cc7cd4..9779c0ea3 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -545,8 +545,7 @@ export class WriteBatch { .request( 'beginTransaction', request, - tag, - true + tag ) .then(resp => { return this.commit_({transactionId: resp.transaction!}); @@ -587,12 +586,7 @@ export class WriteBatch { } return this._firestore - .request( - 'commit', - request, - tag, - /* allowRetries= */ false - ) + .request('commit', request, tag) .then(resp => { const writeResults: WriteResult[] = []; diff --git a/dev/test/document.ts b/dev/test/document.ts index 773fa0f6a..37bc425db 100644 --- a/dev/test/document.ts +++ b/dev/test/document.ts @@ -44,7 +44,7 @@ import { writeResult, } from './util/helpers'; -import api = proto.google.firestore.v1; +import {GoogleError, Status} from 'google-gax'; const PROJECT_ID = 'test-project'; @@ -410,30 +410,6 @@ describe('deserialize document', () => { }); }); - it('ignores intermittent stream failures', () => { - let attempts = 1; - - const overrides: ApiOverride = { - batchGetDocuments: () => { - if (attempts < 3) { - ++attempts; - throw new Error('Expected error'); - } else { - return stream(found(document('documentId'))); - } - }, - }; - - return createInstance(overrides).then(firestore => { - return firestore - .doc('collectionId/documentId') - .get() - .then(() => { - expect(attempts).to.equal(3); - }); - }); - }); - it('deserializes date before 1970', () => { const overrides: ApiOverride = { batchGetDocuments: () => { @@ -674,7 +650,9 @@ describe('get document', () => { it('throws error', done => { const overrides: ApiOverride = { batchGetDocuments: () => { - return stream(new Error('RPC Error')); + const error = new GoogleError('RPC Error'); + error.code = Status.PERMISSION_DENIED; + return stream(error); }, }; diff --git a/dev/test/index.ts b/dev/test/index.ts index 7cd355631..59060dd22 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -21,8 +21,8 @@ import {google} from '../protos/firestore_v1_proto_api'; import * as Firestore from '../src'; import {DocumentSnapshot, FieldPath} from '../src'; +import {setTimeoutHandler} from '../src/backoff'; import {QualifiedResourcePath} from '../src/path'; -import {GrpcError} from '../src/types'; import { ApiOverride, createInstance, @@ -36,6 +36,7 @@ import { } from './util/helpers'; import api = google.firestore.v1; +import {Status} from 'google-gax'; use(chaiAsPromised); @@ -901,6 +902,14 @@ describe('listCollections() method', () => { }); describe('getAll() method', () => { + before(() => { + setTimeoutHandler(setImmediate); + }); + + after(() => { + setTimeoutHandler(setTimeout); + }); + function resultEquals( result: DocumentSnapshot[], ...docs: api.IBatchGetDocumentsResponse[] @@ -995,6 +1004,30 @@ describe('getAll() method', () => { }); }); + it('handles intermittent stream exception', () => { + let attempts = 1; + + const overrides: ApiOverride = { + batchGetDocuments: () => { + if (attempts < 3) { + ++attempts; + throw new Error('Expected error'); + } else { + return stream(found(document('documentId'))); + } + }, + }; + + return createInstance(overrides).then(firestore => { + return firestore + .doc('collectionId/documentId') + .get() + .then(() => { + expect(attempts).to.equal(3); + }); + }); + }); + it('handles serialization error', () => { const overrides: ApiOverride = { batchGetDocuments: () => { @@ -1018,60 +1051,54 @@ describe('getAll() method', () => { }); }); - it('only retries on GRPC unavailable', () => { - const expectedErrorAttempts = { - /* Cancelled */ 1: 1, - /* Unknown */ 2: 1, - /* InvalidArgument */ 3: 1, - /* DeadlineExceeded */ 4: 1, - /* NotFound */ 5: 1, - /* AlreadyExists */ 6: 1, - /* PermissionDenied */ 7: 1, - /* ResourceExhausted */ 8: 1, - /* FailedPrecondition */ 9: 1, - /* Aborted */ 10: 1, - /* OutOfRange */ 11: 1, - /* Unimplemented */ 12: 1, - /* Internal */ 13: 1, - /* Unavailable */ 14: 5, - /* DataLoss */ 15: 1, - /* Unauthenticated */ 16: 1, + it('retries based on error code', () => { + const expectedErrorAttempts: {[key: number]: number} = { + [Status.CANCELLED]: 1, + [Status.UNKNOWN]: 1, + [Status.INVALID_ARGUMENT]: 1, + [Status.DEADLINE_EXCEEDED]: 5, + [Status.NOT_FOUND]: 1, + [Status.ALREADY_EXISTS]: 1, + [Status.PERMISSION_DENIED]: 1, + [Status.RESOURCE_EXHAUSTED]: 1, + [Status.FAILED_PRECONDITION]: 1, + [Status.ABORTED]: 1, + [Status.OUT_OF_RANGE]: 1, + [Status.UNIMPLEMENTED]: 1, + [Status.INTERNAL]: 5, + [Status.UNAVAILABLE]: 5, + [Status.DATA_LOSS]: 1, + [Status.UNAUTHENTICATED]: 1, }; - const actualErrorAttempts: {[k: number]: number} = {}; + const actualErrorAttempts: {[key: number]: number} = {}; const overrides: ApiOverride = { batchGetDocuments: request => { const errorCode = Number(request.documents![0].split('/').pop()); actualErrorAttempts[errorCode] = (actualErrorAttempts[errorCode] || 0) + 1; - const error = new GrpcError('Expected exception'); + const error = new gax.GoogleError('Expected exception'); error.code = errorCode; return stream(error); }, }; - return createInstance(overrides).then(firestore => { + return createInstance(overrides).then(async firestore => { const coll = firestore.collection('collectionId'); - const promises: Array> = []; - - Object.keys(expectedErrorAttempts).forEach(errorCode => { - promises.push( - firestore - .getAll(coll.doc(`${errorCode}`)) - .then(() => { - throw new Error('Unexpected success in Promise'); - }) - .catch(err => { - expect(err.code).to.equal(Number(errorCode)); - }) - ); - }); + for (const errorCode of Object.keys(expectedErrorAttempts)) { + await firestore + .getAll(coll.doc(`${errorCode}`)) + .then(() => { + throw new Error('Unexpected success in Promise'); + }) + .catch(err => { + expect(err.code).to.equal(Number(errorCode)); + }); + } - return Promise.all(promises).then(() => { - expect(actualErrorAttempts).to.deep.eq(expectedErrorAttempts); - }); + expect(actualErrorAttempts).to.deep.eq(expectedErrorAttempts); }); }).timeout(5000); diff --git a/dev/test/query.ts b/dev/test/query.ts index 03ff08cb1..6aa4fda80 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -18,6 +18,7 @@ import * as extend from 'extend'; import {google} from '../protos/firestore_v1_proto_api'; import {FieldPath, FieldValue, Firestore, setLogFunction} from '../src'; import {DocumentData, DocumentReference, Query, Timestamp} from '../src'; +import {setTimeoutHandler} from '../src/backoff'; import {DocumentSnapshot, DocumentSnapshotBuilder} from '../src/document'; import {QualifiedResourcePath} from '../src/path'; import { @@ -286,12 +287,16 @@ describe('query interface', () => { let firestore: Firestore; beforeEach(() => { + setTimeoutHandler(setImmediate); return createInstance().then(firestoreInstance => { firestore = firestoreInstance; }); }); - afterEach(() => verifyInstance(firestore)); + afterEach(() => { + verifyInstance(firestore); + setTimeoutHandler(setTimeout); + }); it('has isEqual() method', () => { const query = firestore.collection('collectionId'); diff --git a/dev/test/transaction.ts b/dev/test/transaction.ts index 570b38437..0e202261c 100644 --- a/dev/test/transaction.ts +++ b/dev/test/transaction.ts @@ -15,6 +15,7 @@ import {expect, use} from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; import * as extend from 'extend'; +import {GoogleError, Status} from 'google-gax'; import * as through2 from 'through2'; import * as proto from '../protos/firestore_v1_proto_api'; @@ -436,7 +437,8 @@ describe('failed transactions', () => { }); it('limits the retry attempts', () => { - const err = new Error('Retryable error'); + const err = new GoogleError('Server disconnect'); + err.code = Status.UNAVAILABLE; return expect( runTransaction( @@ -457,21 +459,6 @@ describe('failed transactions', () => { ).to.eventually.be.rejectedWith('Final exception'); }); - it('fails on beginTransaction', () => { - return expect( - runTransaction( - () => { - return Promise.resolve('success'); - }, - begin('foo', undefined, new Error('Fails (1) on beginTransaction')), - begin('foo', undefined, new Error('Fails (2) on beginTransaction')), - begin('foo', undefined, new Error('Fails (3) on beginTransaction')), - begin('foo', undefined, new Error('Fails (4) on beginTransaction')), - begin('foo', undefined, new Error('Fails (5) on beginTransaction')) - ) - ).to.eventually.be.rejectedWith('Fails (5) on beginTransaction'); - }); - it('fails on rollback', () => { return expect( runTransaction( diff --git a/dev/test/util/helpers.ts b/dev/test/util/helpers.ts index 9877f6faa..df050d683 100644 --- a/dev/test/util/helpers.ts +++ b/dev/test/util/helpers.ts @@ -20,7 +20,7 @@ import * as through2 from 'through2'; import * as proto from '../../protos/firestore_v1_proto_api'; import {Firestore} from '../../src'; import {ClientPool} from '../../src/pool'; -import {GapicClient, GrpcError} from '../../src/types'; +import {GapicClient} from '../../src/types'; import api = proto.google.firestore.v1; @@ -67,7 +67,7 @@ export interface ApiOverride { listDocuments?: ( request: api.IListDocumentsRequest, options: CallOptions, - callback: (err?: GrpcError | null, resp?: api.IDocument[]) => void + callback: (err?: Error | null, resp?: api.IDocument[]) => void ) => void; batchGetDocuments?: ( request: api.IBatchGetDocumentsRequest diff --git a/dev/test/watch.ts b/dev/test/watch.ts index 5a5dbbc6e..5975ee666 100644 --- a/dev/test/watch.ts +++ b/dev/test/watch.ts @@ -16,6 +16,7 @@ const duplexify = require('duplexify'); import {expect} from 'chai'; import * as extend from 'extend'; +import {GoogleError, Status} from 'google-gax'; import {Transform} from 'stream'; import * as through2 from 'through2'; @@ -23,27 +24,23 @@ import {google} from '../protos/firestore_v1_proto_api'; import { CollectionReference, - FieldPath, - Firestore, - GeoPoint, - setLogFunction, - Timestamp, -} from '../src'; -import { DocumentData, DocumentReference, DocumentSnapshot, + FieldPath, + Firestore, + GeoPoint, Query, QueryDocumentSnapshot, QuerySnapshot, + setLogFunction, + Timestamp, } from '../src'; import {MAX_RETRY_ATTEMPTS, setTimeoutHandler} from '../src/backoff'; import {DocumentSnapshotBuilder} from '../src/document'; import {DocumentChangeType} from '../src/document-change'; import {Serializer} from '../src/serializer'; -import {GrpcError} from '../src/types'; import {createInstance, InvalidApiUsage, verifyInstance} from './util/helpers'; - import api = google.firestore.v1; // Change the argument to 'console.log' to enable debug output. @@ -323,10 +320,10 @@ class StreamHelper { * Destroys the currently active stream with the optionally provided error. * If omitted, the stream is closed with a GRPC Status of UNAVAILABLE. */ - destroyStream(err?: GrpcError): void { + destroyStream(err?: GoogleError): void { if (!err) { - err = new GrpcError('Server disconnect'); - err.code = 14; // Unavailable + err = new GoogleError('Server disconnect'); + err.code = Status.UNAVAILABLE; } this.readStream!.destroy(err); } @@ -820,8 +817,8 @@ describe('Query watch', () => { }); it('stops attempts after maximum retry attempts', () => { - const err = new GrpcError('GRPC Error'); - err.code = Number(10 /* ABORTED */); + const err = new GoogleError('GRPC Error'); + err.code = Status.ABORTED; return watchHelper.runFailedTest( collQueryJSON(), async () => { @@ -863,71 +860,62 @@ describe('Query watch', () => { }); }); - it('retries based on error code', () => { - const expectRetry: {[k: number]: boolean} = { - /* Cancelled */ 1: true, - /* Unknown */ 2: true, - /* InvalidArgument */ 3: false, - /* DeadlineExceeded */ 4: true, - /* NotFound */ 5: false, - /* AlreadyExists */ 6: false, - /* PermissionDenied */ 7: false, - /* ResourceExhausted */ 8: true, - /* FailedPrecondition */ 9: false, - /* Aborted */ 10: true, - /* OutOfRange */ 11: false, - /* Unimplemented */ 12: false, - /* Internal */ 13: true, - /* Unavailable */ 14: true, - /* DataLoss */ 15: false, - /* Unauthenticated */ 16: true, - }; - - let result = Promise.resolve(); - - for (const statusCode in expectRetry) { - if (expectRetry.hasOwnProperty(statusCode)) { - result = result.then(() => { - const err = new GrpcError('GRPC Error'); - err.code = Number(statusCode); - - if (expectRetry[statusCode]) { - return watchHelper.runTest(collQueryJSON(), () => { - watchHelper.sendAddTarget(); - watchHelper.sendCurrent(); - watchHelper.sendSnapshot(1, Buffer.from([0xabcd])); - return watchHelper.await('snapshot').then(() => { + it('retries based on error code', async () => { + const testCases = new Map(); + testCases.set(Status.CANCELLED, true); + testCases.set(Status.UNKNOWN, true); + testCases.set(Status.INVALID_ARGUMENT, false); + testCases.set(Status.DEADLINE_EXCEEDED, true); + testCases.set(Status.NOT_FOUND, false); + testCases.set(Status.ALREADY_EXISTS, false); + testCases.set(Status.PERMISSION_DENIED, false); + testCases.set(Status.RESOURCE_EXHAUSTED, true); + testCases.set(Status.FAILED_PRECONDITION, false); + testCases.set(Status.ABORTED, true); + testCases.set(Status.OUT_OF_RANGE, false); + testCases.set(Status.UNIMPLEMENTED, false); + testCases.set(Status.INTERNAL, true); + testCases.set(Status.UNAVAILABLE, true); + testCases.set(Status.DATA_LOSS, false); + testCases.set(Status.UNAUTHENTICATED, true); + + for (const [statusCode, expectRetry] of testCases) { + const err = new GoogleError('GRPC Error'); + err.code = statusCode; + + if (expectRetry) { + await watchHelper.runTest(collQueryJSON(), () => { + watchHelper.sendAddTarget(); + watchHelper.sendCurrent(); + watchHelper.sendSnapshot(1, Buffer.from([0xabcd])); + return watchHelper.await('snapshot').then(() => { + streamHelper.destroyStream(err); + return streamHelper.awaitReopen(); + }); + }); + } else { + await watchHelper.runFailedTest( + collQueryJSON(), + () => { + watchHelper.sendAddTarget(); + watchHelper.sendCurrent(); + watchHelper.sendSnapshot(1, Buffer.from([0xabcd])); + return watchHelper + .await('snapshot') + .then(() => { streamHelper.destroyStream(err); - return streamHelper.awaitReopen(); + }) + .then(() => { + return streamHelper.await('error'); + }) + .then(() => { + return streamHelper.await('close'); }); - }); - } else { - return watchHelper.runFailedTest( - collQueryJSON(), - () => { - watchHelper.sendAddTarget(); - watchHelper.sendCurrent(); - watchHelper.sendSnapshot(1, Buffer.from([0xabcd])); - return watchHelper - .await('snapshot') - .then(() => { - streamHelper.destroyStream(err); - }) - .then(() => { - return streamHelper.await('error'); - }) - .then(() => { - return streamHelper.await('close'); - }); - }, - 'GRPC Error' - ); - } - }); + }, + 'GRPC Error' + ); } } - - return result; }).timeout(5000); it('retries with unknown code', () => { diff --git a/package.json b/package.json index 05e7fef74..886654964 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "dependencies": { "deep-equal": "^2.0.0", "functional-red-black-tree": "^1.0.1", - "google-gax": "^1.12.0", + "google-gax": "^1.13.0", "readable-stream": "^3.4.0", "through2": "^3.0.0" }, From b49698a88d15443a04a424ec5fea1c85afcbaa09 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 2 Jan 2020 13:28:42 -0800 Subject: [PATCH 019/337] build: adds list of files to synth.metadata --- dev/protos/protos.json | 8 +- dev/src/v1/firestore_admin_proto_list.json | 4 +- dev/synth.metadata | 302 ++++++++++++++++++++- 3 files changed, 305 insertions(+), 9 deletions(-) diff --git a/dev/protos/protos.json b/dev/protos/protos.json index 59f318626..e0eff68d2 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -11,7 +11,7 @@ "csharp_namespace": "Google.Cloud.Firestore.Admin.V1", "go_package": "google.golang.org/genproto/googleapis/firestore/admin/v1;admin", "java_multiple_files": true, - "java_outer_classname": "LocationProto", + "java_outer_classname": "OperationProto", "java_package": "com.google.firestore.admin.v1", "objc_class_prefix": "GCFS", "php_namespace": "Google\\Cloud\\Firestore\\Admin\\V1", @@ -417,6 +417,9 @@ } } }, + "LocationMetadata": { + "fields": {} + }, "IndexOperationMetadata": { "fields": { "startTime": { @@ -598,9 +601,6 @@ "FAILED": 6, "CANCELLED": 7 } - }, - "LocationMetadata": { - "fields": {} } } } diff --git a/dev/src/v1/firestore_admin_proto_list.json b/dev/src/v1/firestore_admin_proto_list.json index f6060527c..0484301c3 100644 --- a/dev/src/v1/firestore_admin_proto_list.json +++ b/dev/src/v1/firestore_admin_proto_list.json @@ -2,6 +2,6 @@ "../../protos/google/firestore/admin/v1/index.proto", "../../protos/google/firestore/admin/v1/field.proto", "../../protos/google/firestore/admin/v1/firestore_admin.proto", - "../../protos/google/firestore/admin/v1/operation.proto", - "../../protos/google/firestore/admin/v1/location.proto" + "../../protos/google/firestore/admin/v1/location.proto", + "../../protos/google/firestore/admin/v1/operation.proto" ] diff --git a/dev/synth.metadata b/dev/synth.metadata index f9f21d2d4..30e4f5221 100644 --- a/dev/synth.metadata +++ b/dev/synth.metadata @@ -1,12 +1,12 @@ { - "updateTime": "2019-12-15T06:29:34.857861Z", + "updateTime": "2019-12-18T12:16:40.490708Z", "sources": [ { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "2085a0d3c76180ee843cf2ecef2b94ca5266be31", - "internalRef": "285233245" + "sha": "3352100a15ede383f5ab3c34599f7a10a3d066fe", + "internalRef": "286065440" } }, { @@ -45,5 +45,301 @@ "generator": "gapic-generator-typescript" } } + ], + "newFiles": [ + { + "path": "synth.metadata" + }, + { + "path": "protos/protos.json" + }, + { + "path": "protos/firestore_admin_v1_proto_api.d.ts" + }, + { + "path": "protos/update.sh" + }, + { + "path": "protos/insert-license.sh" + }, + { + "path": "protos/firestore_v1_proto_api.js" + }, + { + "path": "protos/firestore_v1beta1_proto_api.d.ts" + }, + { + "path": "protos/firestore_admin_v1_proto_api.js" + }, + { + "path": "protos/firestore_v1beta1_proto_api.js" + }, + { + "path": "protos/firestore_v1_proto_api.d.ts" + }, + { + "path": "protos/google/rpc/status.proto" + }, + { + "path": "protos/google/firestore/v1beta1/document.proto" + }, + { + "path": "protos/google/firestore/v1beta1/query.proto" + }, + { + "path": "protos/google/firestore/v1beta1/common.proto" + }, + { + "path": "protos/google/firestore/v1beta1/firestore.proto" + }, + { + "path": "protos/google/firestore/v1beta1/write.proto" + }, + { + "path": "protos/google/firestore/admin/v1/field.proto" + }, + { + "path": "protos/google/firestore/admin/v1/location.proto" + }, + { + "path": "protos/google/firestore/admin/v1/firestore_admin.proto" + }, + { + "path": "protos/google/firestore/admin/v1/operation.proto" + }, + { + "path": "protos/google/firestore/admin/v1/index.proto" + }, + { + "path": "protos/google/firestore/v1/document.proto" + }, + { + "path": "protos/google/firestore/v1/query.proto" + }, + { + "path": "protos/google/firestore/v1/common.proto" + }, + { + "path": "protos/google/firestore/v1/firestore.proto" + }, + { + "path": "protos/google/firestore/v1/write.proto" + }, + { + "path": "protos/google/protobuf/struct.proto" + }, + { + "path": "protos/google/protobuf/wrappers.proto" + }, + { + "path": "protos/google/protobuf/empty.proto" + }, + { + "path": "protos/google/protobuf/timestamp.proto" + }, + { + "path": "protos/google/protobuf/any.proto" + }, + { + "path": "protos/google/protobuf/field_mask.proto" + }, + { + "path": "protos/google/longrunning/operations.proto" + }, + { + "path": "protos/google/type/latlng.proto" + }, + { + "path": "protos/google/api/resource.proto" + }, + { + "path": "protos/google/api/client.proto" + }, + { + "path": "protos/google/api/http.proto" + }, + { + "path": "protos/google/api/field_behavior.proto" + }, + { + "path": "protos/google/api/annotations.proto" + }, + { + "path": "test/gapic-firestore-v1beta1.ts" + }, + { + "path": "test/transaction.ts" + }, + { + "path": "test/watch.ts" + }, + { + "path": "test/field-value.ts" + }, + { + "path": "test/query.ts" + }, + { + "path": "test/typescript.ts" + }, + { + "path": "test/document.ts" + }, + { + "path": "test/fake-certificate.json" + }, + { + "path": "test/path.ts" + }, + { + "path": "test/collection.ts" + }, + { + "path": "test/gapic-firestore_admin-v1.ts" + }, + { + "path": "test/timestamp.ts" + }, + { + "path": "test/backoff.ts" + }, + { + "path": "test/pool.ts" + }, + { + "path": "test/index.ts" + }, + { + "path": "test/write-batch.ts" + }, + { + "path": "test/mocha.opts" + }, + { + "path": "test/order.ts" + }, + { + "path": "test/gapic-firestore-v1.ts" + }, + { + "path": "test/util/helpers.ts" + }, + { + "path": "system-test/.eslintrc.yml" + }, + { + "path": "system-test/.gitignore" + }, + { + "path": "system-test/firestore.ts" + }, + { + "path": "src/transaction.ts" + }, + { + "path": "src/watch.ts" + }, + { + "path": "src/field-value.ts" + }, + { + "path": "src/convert.ts" + }, + { + "path": "src/util.ts" + }, + { + "path": "src/geo-point.ts" + }, + { + "path": "src/reference.ts" + }, + { + "path": "src/document.ts" + }, + { + "path": "src/logger.ts" + }, + { + "path": "src/path.ts" + }, + { + "path": "src/document-change.ts" + }, + { + "path": "src/timestamp.ts" + }, + { + "path": "src/backoff.ts" + }, + { + "path": "src/pool.ts" + }, + { + "path": "src/types.ts" + }, + { + "path": "src/index.ts" + }, + { + "path": "src/write-batch.ts" + }, + { + "path": "src/external-modules.d.ts" + }, + { + "path": "src/serializer.ts" + }, + { + "path": "src/order.ts" + }, + { + "path": "src/validate.ts" + }, + { + "path": "src/v1beta1/firestore_client.ts" + }, + { + "path": "src/v1beta1/firestore_proto_list.json" + }, + { + "path": "src/v1beta1/firestore_client_config.json" + }, + { + "path": "src/v1beta1/index.ts" + }, + { + "path": "src/v1/firestore_client.ts" + }, + { + "path": "src/v1/firestore_admin_proto_list.json" + }, + { + "path": "src/v1/firestore_proto_list.json" + }, + { + "path": "src/v1/firestore_client_config.json" + }, + { + "path": "src/v1/firestore_admin_client.ts" + }, + { + "path": "src/v1/index.ts" + }, + { + "path": "src/v1/firestore_admin_client_config.json" + }, + { + "path": "conformance/test-suite.binproto" + }, + { + "path": "conformance/.eslintrc.yml" + }, + { + "path": "conformance/runner.ts" + }, + { + "path": "conformance/test-definition.proto" + } ] } \ No newline at end of file From 191d3b83b5a012d8b82953aa73d265d3e7314ca2 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 2 Jan 2020 14:08:42 -0800 Subject: [PATCH 020/337] build: make update-license script work on Windows (#851) --- dev/protos/firestore_admin_v1_proto_api.d.ts | 2 +- dev/protos/firestore_admin_v1_proto_api.js | 2 +- dev/protos/firestore_v1_proto_api.d.ts | 10 ++--- dev/protos/firestore_v1_proto_api.js | 34 ++++++++-------- dev/protos/firestore_v1beta1_proto_api.d.ts | 2 +- dev/protos/firestore_v1beta1_proto_api.js | 2 +- .../google/firestore/v1/firestore.proto | 26 +++++-------- dev/protos/google/firestore/v1/query.proto | 24 ++++++------ dev/protos/insert-license.sh | 38 ------------------ dev/protos/update.sh | 2 +- scripts/license.js | 39 +++++++++++++++++++ 11 files changed, 88 insertions(+), 93 deletions(-) delete mode 100755 dev/protos/insert-license.sh create mode 100755 scripts/license.js diff --git a/dev/protos/firestore_admin_v1_proto_api.d.ts b/dev/protos/firestore_admin_v1_proto_api.d.ts index d66a9fbdc..a2b8fc7bf 100644 --- a/dev/protos/firestore_admin_v1_proto_api.d.ts +++ b/dev/protos/firestore_admin_v1_proto_api.d.ts @@ -1,5 +1,5 @@ /*! - * Copyright 2019 Google LLC + * 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. diff --git a/dev/protos/firestore_admin_v1_proto_api.js b/dev/protos/firestore_admin_v1_proto_api.js index 18baf526c..2b96c841e 100644 --- a/dev/protos/firestore_admin_v1_proto_api.js +++ b/dev/protos/firestore_admin_v1_proto_api.js @@ -1,5 +1,5 @@ /*! - * Copyright 2019 Google LLC + * 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. diff --git a/dev/protos/firestore_v1_proto_api.d.ts b/dev/protos/firestore_v1_proto_api.d.ts index 9edef25cd..5e5584154 100644 --- a/dev/protos/firestore_v1_proto_api.d.ts +++ b/dev/protos/firestore_v1_proto_api.d.ts @@ -1,5 +1,5 @@ /*! - * Copyright 2019 Google LLC + * 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. @@ -3278,10 +3278,6 @@ export namespace google { public direction: google.firestore.v1.StructuredQuery.Direction; } - /** Direction enum. */ - type Direction = - "DIRECTION_UNSPECIFIED"| "ASCENDING"| "DESCENDING"; - /** Properties of a FieldReference. */ interface IFieldReference { @@ -3321,6 +3317,10 @@ export namespace google { /** Projection fields. */ public fields: google.firestore.v1.StructuredQuery.IFieldReference[]; } + + /** Direction enum. */ + type Direction = + "DIRECTION_UNSPECIFIED"| "ASCENDING"| "DESCENDING"; } /** Properties of a Cursor. */ diff --git a/dev/protos/firestore_v1_proto_api.js b/dev/protos/firestore_v1_proto_api.js index 2bc89ea07..9a0f3ea32 100644 --- a/dev/protos/firestore_v1_proto_api.js +++ b/dev/protos/firestore_v1_proto_api.js @@ -1,5 +1,5 @@ /*! - * Copyright 2019 Google LLC + * 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. @@ -5705,22 +5705,6 @@ $root.google = (function() { return Order; })(); - /** - * Direction enum. - * @name google.firestore.v1.StructuredQuery.Direction - * @enum {number} - * @property {string} DIRECTION_UNSPECIFIED=DIRECTION_UNSPECIFIED DIRECTION_UNSPECIFIED value - * @property {string} ASCENDING=ASCENDING ASCENDING value - * @property {string} DESCENDING=DESCENDING DESCENDING value - */ - StructuredQuery.Direction = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "DIRECTION_UNSPECIFIED"] = "DIRECTION_UNSPECIFIED"; - values[valuesById[1] = "ASCENDING"] = "ASCENDING"; - values[valuesById[2] = "DESCENDING"] = "DESCENDING"; - return values; - })(); - StructuredQuery.FieldReference = (function() { /** @@ -5792,6 +5776,22 @@ $root.google = (function() { return Projection; })(); + /** + * Direction enum. + * @name google.firestore.v1.StructuredQuery.Direction + * @enum {number} + * @property {string} DIRECTION_UNSPECIFIED=DIRECTION_UNSPECIFIED DIRECTION_UNSPECIFIED value + * @property {string} ASCENDING=ASCENDING ASCENDING value + * @property {string} DESCENDING=DESCENDING DESCENDING value + */ + StructuredQuery.Direction = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DIRECTION_UNSPECIFIED"] = "DIRECTION_UNSPECIFIED"; + values[valuesById[1] = "ASCENDING"] = "ASCENDING"; + values[valuesById[2] = "DESCENDING"] = "DESCENDING"; + return values; + })(); + return StructuredQuery; })(); diff --git a/dev/protos/firestore_v1beta1_proto_api.d.ts b/dev/protos/firestore_v1beta1_proto_api.d.ts index 68e3882f7..e748df35a 100644 --- a/dev/protos/firestore_v1beta1_proto_api.d.ts +++ b/dev/protos/firestore_v1beta1_proto_api.d.ts @@ -1,5 +1,5 @@ /*! - * Copyright 2019 Google LLC + * 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. diff --git a/dev/protos/firestore_v1beta1_proto_api.js b/dev/protos/firestore_v1beta1_proto_api.js index 1c34a763c..02dcd65a2 100644 --- a/dev/protos/firestore_v1beta1_proto_api.js +++ b/dev/protos/firestore_v1beta1_proto_api.js @@ -1,5 +1,5 @@ /*! - * Copyright 2019 Google LLC + * 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. diff --git a/dev/protos/google/firestore/v1/firestore.proto b/dev/protos/google/firestore/v1/firestore.proto index a07b267d7..9af30b7a4 100644 --- a/dev/protos/google/firestore/v1/firestore.proto +++ b/dev/protos/google/firestore/v1/firestore.proto @@ -40,20 +40,12 @@ option php_namespace = "Google\\Cloud\\Firestore\\V1"; // The Cloud Firestore service. // -// This service exposes several types of comparable timestamps: -// -// * `create_time` - The time at which a document was created. Changes only -// when a document is deleted, then re-created. Increases in a strict -// monotonic fashion. -// * `update_time` - The time at which a document was last updated. Changes -// every time a document is modified. Does not change when a write results -// in no modifications. Increases in a strict monotonic fashion. -// * `read_time` - The time at which a particular state was observed. Used -// to denote a consistent snapshot of the database or the time at which a -// Document was observed to not exist. -// * `commit_time` - The time at which the writes in a transaction were -// committed. Any read with an equal or greater `read_time` is guaranteed -// to see the effects of the transaction. +// Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL +// document database that simplifies storing, syncing, and querying data for +// your mobile, web, and IoT apps at global scale. Its client libraries provide +// live synchronization and offline support, while its security features and +// integrations with Firebase and Google Cloud Platform (GCP) accelerate +// building truly serverless apps. service Firestore { option (google.api.default_host) = "firestore.googleapis.com"; option (google.api.oauth_scopes) = @@ -425,7 +417,8 @@ message CommitResponse { // request. repeated WriteResult write_results = 1; - // The time at which the commit occurred. + // The time at which the commit occurred. Any read with an equal or greater + // `read_time` is guaranteed to see the effects of the commit. google.protobuf.Timestamp commit_time = 2; } @@ -566,7 +559,8 @@ message WriteResponse { // request. repeated WriteResult write_results = 3; - // The time at which the commit occurred. + // The time at which the commit occurred. Any read with an equal or greater + // `read_time` is guaranteed to see the effects of the write. google.protobuf.Timestamp commit_time = 4; } diff --git a/dev/protos/google/firestore/v1/query.proto b/dev/protos/google/firestore/v1/query.proto index 12d80b255..fa34daf7a 100644 --- a/dev/protos/google/firestore/v1/query.proto +++ b/dev/protos/google/firestore/v1/query.proto @@ -155,18 +155,6 @@ message StructuredQuery { Direction direction = 2; } - // A sort direction. - enum Direction { - // Unspecified. - DIRECTION_UNSPECIFIED = 0; - - // Ascending. - ASCENDING = 1; - - // Descending. - DESCENDING = 2; - } - // A reference to a field, such as `max(messages.time) as max_time`. message FieldReference { string field_path = 2; @@ -181,6 +169,18 @@ message StructuredQuery { repeated FieldReference fields = 2; } + // A sort direction. + enum Direction { + // Unspecified. + DIRECTION_UNSPECIFIED = 0; + + // Ascending. + ASCENDING = 1; + + // Descending. + DESCENDING = 2; + } + // The projection to return. Projection select = 1; diff --git a/dev/protos/insert-license.sh b/dev/protos/insert-license.sh deleted file mode 100755 index c6d932f69..000000000 --- a/dev/protos/insert-license.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -# Copyright 2019 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. - -read -r -d '' LICENSE_HEADER << LICENSE -/*! - * Copyright 2019 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. - */ -LICENSE - -for n in "$@" -do - printf "%s\n\n%s\n" "$LICENSE_HEADER" "`cat $n`" > $n -done diff --git a/dev/protos/update.sh b/dev/protos/update.sh index cccf6b86d..9b8e7f687 100755 --- a/dev/protos/update.sh +++ b/dev/protos/update.sh @@ -108,7 +108,7 @@ PBJS_ARGS=( --proto_path=. \ "${PROTOS_DIR}/google/longrunning/*.proto" "${PBTS}" -o firestore_v1beta1_proto_api.d.ts firestore_v1beta1_proto_api.js -"${PROTOS_DIR}"/insert-license.sh *.d.ts *.js +node "${PROTOS_DIR}"/../../scripts/license.js *.d.ts *.js # Copy typings into source repo cp {firestore_v1_proto_api.d.ts,firestore_v1_proto_api.js} ${PROTOS_DIR} diff --git a/scripts/license.js b/scripts/license.js new file mode 100755 index 000000000..8eef77c12 --- /dev/null +++ b/scripts/license.js @@ -0,0 +1,39 @@ +/*! + * 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 fs = require('fs'); + +const LICENSE_HEADER = `/*! + * 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. + */ +`; + +for (const file of process.argv.slice(2)) { + const content = fs.readFileSync(file, 'utf-8'); + fs.writeFileSync(file, `${LICENSE_HEADER}\n${content.trim()}\n`); +} From 96f085f3df7c8e6e20dbffb14ebf6ebb533fc036 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 3 Jan 2020 09:08:54 -0800 Subject: [PATCH 021/337] fix: retry writes that fail with status code ABORTED (#854) --- .nycrc | 1 + README.md | 4 +- dev/protos/protos.json | 14 +- dev/src/v1/firestore_admin_client.ts | 8 +- dev/src/v1/firestore_client.ts | 26 ++-- dev/src/v1/firestore_client_config.json | 21 +-- dev/src/v1beta1/firestore_client.ts | 6 +- dev/synth.metadata | 193 ++++++++++++------------ dev/test/index.ts | 2 +- 9 files changed, 134 insertions(+), 141 deletions(-) diff --git a/.nycrc b/.nycrc index 367688844..b18d5472b 100644 --- a/.nycrc +++ b/.nycrc @@ -12,6 +12,7 @@ "**/scripts", "**/protos", "**/test", + "**/*.d.ts", ".jsdoc.js", "**/.jsdoc.js", "karma.conf.js", diff --git a/README.md b/README.md index 536072cc8..d1cd97732 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,9 @@ This is the Node.js Server SDK for [Google Cloud Firestore](https://firebase.goo This Cloud Firestore Server SDK uses Google’s Cloud Identity and Access Management for authentication and should only be used in trusted environments. Your Cloud Identity credentials allow you bypass all access restrictions and provide read and write access to all data in your Cloud Firestore project. -Applications that use Google's Server SDKs should not be used in end-user environments, such as on phones or on publicly hosted websites. If you are developing a Web or Node.js application that accesses Cloud Firestore on behalf of end users, use the Firebase Client SDK. +The Cloud Firestore Server SDKs are designed to manage the full set of data in your Cloud Firestore project and work best with reliable network connectivity. Data operations performed via these SDKs directly access the Cloud Firestore backend and all document reads and writes are optimized for high throughput. + +Applications that use Google's Server SDKs should not be used in end-user environments, such as on phones or on publicly hosted websites. If you are developing a Web or Node.js application that accesses Cloud Firestore on behalf of end users, use the firebase Client SDK. **Note:** This Cloud Firestore Server SDK does not support Firestore databases created in [Datastore mode](https://cloud.google.com/datastore/docs/firestore-or-datastore#in_datastore_mode). To access these databases, use the [Datastore SDK](https://www.npmjs.com/package/@google-cloud/datastore). diff --git a/dev/protos/protos.json b/dev/protos/protos.json index e0eff68d2..43a9cfaad 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -1139,13 +1139,6 @@ } } }, - "Direction": { - "values": { - "DIRECTION_UNSPECIFIED": 0, - "ASCENDING": 1, - "DESCENDING": 2 - } - }, "FieldReference": { "fields": { "fieldPath": { @@ -1162,6 +1155,13 @@ "id": 2 } } + }, + "Direction": { + "values": { + "DIRECTION_UNSPECIFIED": 0, + "ASCENDING": 1, + "DESCENDING": 2 + } } } }, diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index ba1680b26..57e3ec599 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -278,6 +278,9 @@ export class FirestoreAdminClient { for (const methodName of firestoreAdminStubMethods) { const innerCallPromise = this.firestoreAdminStub.then( stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } return stub[methodName].apply(stub, args); }, (err: Error | null | undefined) => () => { @@ -298,9 +301,6 @@ export class FirestoreAdminClient { callOptions?: CallOptions, callback?: APICallback ) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } return apiCall(argument, callOptions, callback); }; } @@ -1270,7 +1270,7 @@ export class FirestoreAdminClient { * @param {string} collection * @returns {string} Resource name string. */ - collectiongroupPath(project: string, database: string, collection: string) { + collectionGroupPath(project: string, database: string, collection: string) { return this._pathTemplates.collectiongroupPathTemplate.render({ project, database, diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 8bcf8b6ad..86cd60bd0 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -37,20 +37,12 @@ const version = require('../../../package.json').version; /** * The Cloud Firestore service. * - * This service exposes several types of comparable timestamps: - * - * * `create_time` - The time at which a document was created. Changes only - * when a document is deleted, then re-created. Increases in a strict - * monotonic fashion. - * * `update_time` - The time at which a document was last updated. Changes - * every time a document is modified. Does not change when a write results - * in no modifications. Increases in a strict monotonic fashion. - * * `read_time` - The time at which a particular state was observed. Used - * to denote a consistent snapshot of the database or the time at which a - * Document was observed to not exist. - * * `commit_time` - The time at which the writes in a transaction were - * committed. Any read with an equal or greater `read_time` is guaranteed - * to see the effects of the transaction. + * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL + * document database that simplifies storing, syncing, and querying data for + * your mobile, web, and IoT apps at global scale. Its client libraries provide + * live synchronization and offline support, while its security features and + * integrations with Firebase and Google Cloud Platform (GCP) accelerate + * building truly serverless apps. * @class * @memberof v1 */ @@ -225,6 +217,9 @@ export class FirestoreClient { for (const methodName of firestoreStubMethods) { const innerCallPromise = this.firestoreStub.then( stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } return stub[methodName].apply(stub, args); }, (err: Error | null | undefined) => () => { @@ -245,9 +240,6 @@ export class FirestoreClient { callOptions?: CallOptions, callback?: APICallback ) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } return apiCall(argument, callOptions, callback); }; } diff --git a/dev/src/v1/firestore_client_config.json b/dev/src/v1/firestore_client_config.json index b1e32f327..60230c0d7 100644 --- a/dev/src/v1/firestore_client_config.json +++ b/dev/src/v1/firestore_client_config.json @@ -7,8 +7,9 @@ "DEADLINE_EXCEEDED", "UNAVAILABLE" ], - "deadline_exceeded_internal_unavailable": [ + "deadline_exceeded_aborted_internal_unavailable": [ "DEADLINE_EXCEEDED", + "ABORTED", "INTERNAL", "UNAVAILABLE" ] @@ -27,12 +28,12 @@ "methods": { "GetDocument": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", "retry_params_name": "default" }, "ListDocuments": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", "retry_params_name": "default" }, "CreateDocument": { @@ -47,17 +48,17 @@ }, "DeleteDocument": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", "retry_params_name": "default" }, "BatchGetDocuments": { "timeout_millis": 300000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", "retry_params_name": "default" }, "BeginTransaction": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", "retry_params_name": "default" }, "Commit": { @@ -67,12 +68,12 @@ }, "Rollback": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", "retry_params_name": "default" }, "RunQuery": { "timeout_millis": 300000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", "retry_params_name": "default" }, "Write": { @@ -82,12 +83,12 @@ }, "Listen": { "timeout_millis": 86400000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", "retry_params_name": "default" }, "ListCollectionIds": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", "retry_params_name": "default" } } diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index bc2766bfe..738d5dd56 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -225,6 +225,9 @@ export class FirestoreClient { for (const methodName of firestoreStubMethods) { const innerCallPromise = this.firestoreStub.then( stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } return stub[methodName].apply(stub, args); }, (err: Error | null | undefined) => () => { @@ -245,9 +248,6 @@ export class FirestoreClient { callOptions?: CallOptions, callback?: APICallback ) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } return apiCall(argument, callOptions, callback); }; } diff --git a/dev/synth.metadata b/dev/synth.metadata index 30e4f5221..49226d35c 100644 --- a/dev/synth.metadata +++ b/dev/synth.metadata @@ -1,12 +1,12 @@ { - "updateTime": "2019-12-18T12:16:40.490708Z", + "updateTime": "2020-01-03T12:14:28.989140Z", "sources": [ { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "3352100a15ede383f5ab3c34599f7a10a3d066fe", - "internalRef": "286065440" + "sha": "4d45a6399e9444fbddaeb1c86aabfde210723714", + "internalRef": "287908369" } }, { @@ -51,295 +51,292 @@ "path": "synth.metadata" }, { - "path": "protos/protos.json" + "path": "test/path.ts" }, { - "path": "protos/firestore_admin_v1_proto_api.d.ts" + "path": "test/gapic-firestore-v1beta1.ts" }, { - "path": "protos/update.sh" + "path": "test/fake-certificate.json" }, { - "path": "protos/insert-license.sh" + "path": "test/gapic-firestore-v1.ts" }, { - "path": "protos/firestore_v1_proto_api.js" + "path": "test/pool.ts" }, { - "path": "protos/firestore_v1beta1_proto_api.d.ts" + "path": "test/mocha.opts" }, { - "path": "protos/firestore_admin_v1_proto_api.js" + "path": "test/timestamp.ts" }, { - "path": "protos/firestore_v1beta1_proto_api.js" + "path": "test/document.ts" }, { - "path": "protos/firestore_v1_proto_api.d.ts" + "path": "test/index.ts" }, { - "path": "protos/google/rpc/status.proto" + "path": "test/query.ts" }, { - "path": "protos/google/firestore/v1beta1/document.proto" + "path": "test/watch.ts" }, { - "path": "protos/google/firestore/v1beta1/query.proto" + "path": "test/backoff.ts" }, { - "path": "protos/google/firestore/v1beta1/common.proto" + "path": "test/gapic-firestore_admin-v1.ts" }, { - "path": "protos/google/firestore/v1beta1/firestore.proto" + "path": "test/collection.ts" }, { - "path": "protos/google/firestore/v1beta1/write.proto" + "path": "test/field-value.ts" }, { - "path": "protos/google/firestore/admin/v1/field.proto" + "path": "test/order.ts" }, { - "path": "protos/google/firestore/admin/v1/location.proto" + "path": "test/typescript.ts" }, { - "path": "protos/google/firestore/admin/v1/firestore_admin.proto" + "path": "test/transaction.ts" }, { - "path": "protos/google/firestore/admin/v1/operation.proto" + "path": "test/write-batch.ts" }, { - "path": "protos/google/firestore/admin/v1/index.proto" + "path": "test/util/helpers.ts" }, { - "path": "protos/google/firestore/v1/document.proto" + "path": "system-test/.gitignore" }, { - "path": "protos/google/firestore/v1/query.proto" + "path": "system-test/firestore.ts" }, { - "path": "protos/google/firestore/v1/common.proto" + "path": "system-test/.eslintrc.yml" }, { - "path": "protos/google/firestore/v1/firestore.proto" + "path": "protos/firestore_admin_v1_proto_api.d.ts" }, { - "path": "protos/google/firestore/v1/write.proto" + "path": "protos/update.sh" }, { - "path": "protos/google/protobuf/struct.proto" + "path": "protos/firestore_v1beta1_proto_api.js" }, { - "path": "protos/google/protobuf/wrappers.proto" + "path": "protos/firestore_v1_proto_api.d.ts" }, { - "path": "protos/google/protobuf/empty.proto" + "path": "protos/firestore_v1_proto_api.js" }, { - "path": "protos/google/protobuf/timestamp.proto" + "path": "protos/protos.json" }, { - "path": "protos/google/protobuf/any.proto" + "path": "protos/firestore_v1beta1_proto_api.d.ts" }, { - "path": "protos/google/protobuf/field_mask.proto" + "path": "protos/firestore_admin_v1_proto_api.js" }, { - "path": "protos/google/longrunning/operations.proto" + "path": "protos/google/api/http.proto" }, { - "path": "protos/google/type/latlng.proto" + "path": "protos/google/api/annotations.proto" }, { - "path": "protos/google/api/resource.proto" + "path": "protos/google/api/field_behavior.proto" }, { - "path": "protos/google/api/client.proto" + "path": "protos/google/api/resource.proto" }, { - "path": "protos/google/api/http.proto" + "path": "protos/google/api/client.proto" }, { - "path": "protos/google/api/field_behavior.proto" + "path": "protos/google/type/latlng.proto" }, { - "path": "protos/google/api/annotations.proto" + "path": "protos/google/protobuf/field_mask.proto" }, { - "path": "test/gapic-firestore-v1beta1.ts" + "path": "protos/google/protobuf/struct.proto" }, { - "path": "test/transaction.ts" + "path": "protos/google/protobuf/empty.proto" }, { - "path": "test/watch.ts" + "path": "protos/google/protobuf/any.proto" }, { - "path": "test/field-value.ts" + "path": "protos/google/protobuf/wrappers.proto" }, { - "path": "test/query.ts" + "path": "protos/google/protobuf/timestamp.proto" }, { - "path": "test/typescript.ts" + "path": "protos/google/longrunning/operations.proto" }, { - "path": "test/document.ts" + "path": "protos/google/rpc/status.proto" }, { - "path": "test/fake-certificate.json" + "path": "protos/google/firestore/v1beta1/firestore.proto" }, { - "path": "test/path.ts" + "path": "protos/google/firestore/v1beta1/common.proto" }, { - "path": "test/collection.ts" + "path": "protos/google/firestore/v1beta1/query.proto" }, { - "path": "test/gapic-firestore_admin-v1.ts" + "path": "protos/google/firestore/v1beta1/write.proto" }, { - "path": "test/timestamp.ts" + "path": "protos/google/firestore/v1beta1/document.proto" }, { - "path": "test/backoff.ts" + "path": "protos/google/firestore/admin/v1/location.proto" }, { - "path": "test/pool.ts" + "path": "protos/google/firestore/admin/v1/index.proto" }, { - "path": "test/index.ts" + "path": "protos/google/firestore/admin/v1/firestore_admin.proto" }, { - "path": "test/write-batch.ts" + "path": "protos/google/firestore/admin/v1/operation.proto" }, { - "path": "test/mocha.opts" + "path": "protos/google/firestore/admin/v1/field.proto" }, { - "path": "test/order.ts" + "path": "protos/google/firestore/v1/firestore.proto" }, { - "path": "test/gapic-firestore-v1.ts" + "path": "protos/google/firestore/v1/common.proto" }, { - "path": "test/util/helpers.ts" + "path": "protos/google/firestore/v1/query.proto" }, { - "path": "system-test/.eslintrc.yml" + "path": "protos/google/firestore/v1/write.proto" }, { - "path": "system-test/.gitignore" + "path": "protos/google/firestore/v1/document.proto" }, { - "path": "system-test/firestore.ts" + "path": "src/path.ts" }, { - "path": "src/transaction.ts" + "path": "src/util.ts" }, { - "path": "src/watch.ts" + "path": "src/reference.ts" }, { - "path": "src/field-value.ts" + "path": "src/logger.ts" }, { - "path": "src/convert.ts" + "path": "src/types.ts" }, { - "path": "src/util.ts" + "path": "src/geo-point.ts" }, { - "path": "src/geo-point.ts" + "path": "src/pool.ts" }, { - "path": "src/reference.ts" + "path": "src/timestamp.ts" }, { "path": "src/document.ts" }, { - "path": "src/logger.ts" + "path": "src/convert.ts" }, { - "path": "src/path.ts" + "path": "src/index.ts" }, { - "path": "src/document-change.ts" + "path": "src/validate.ts" }, { - "path": "src/timestamp.ts" + "path": "src/serializer.ts" }, { - "path": "src/backoff.ts" + "path": "src/watch.ts" }, { - "path": "src/pool.ts" + "path": "src/backoff.ts" }, { - "path": "src/types.ts" + "path": "src/external-modules.d.ts" }, { - "path": "src/index.ts" + "path": "src/field-value.ts" }, { - "path": "src/write-batch.ts" + "path": "src/order.ts" }, { - "path": "src/external-modules.d.ts" + "path": "src/document-change.ts" }, { - "path": "src/serializer.ts" + "path": "src/transaction.ts" }, { - "path": "src/order.ts" + "path": "src/write-batch.ts" }, { - "path": "src/validate.ts" + "path": "src/v1beta1/index.ts" }, { "path": "src/v1beta1/firestore_client.ts" }, - { - "path": "src/v1beta1/firestore_proto_list.json" - }, { "path": "src/v1beta1/firestore_client_config.json" }, { - "path": "src/v1beta1/index.ts" + "path": "src/v1beta1/firestore_proto_list.json" }, { - "path": "src/v1/firestore_client.ts" + "path": "src/v1/index.ts" }, { - "path": "src/v1/firestore_admin_proto_list.json" + "path": "src/v1/firestore_client.ts" }, { - "path": "src/v1/firestore_proto_list.json" + "path": "src/v1/firestore_client_config.json" }, { - "path": "src/v1/firestore_client_config.json" + "path": "src/v1/firestore_admin_client_config.json" }, { "path": "src/v1/firestore_admin_client.ts" }, { - "path": "src/v1/index.ts" + "path": "src/v1/firestore_admin_proto_list.json" }, { - "path": "src/v1/firestore_admin_client_config.json" + "path": "src/v1/firestore_proto_list.json" }, { - "path": "conformance/test-suite.binproto" + "path": "conformance/test-definition.proto" }, { - "path": "conformance/.eslintrc.yml" + "path": "conformance/runner.ts" }, { - "path": "conformance/runner.ts" + "path": "conformance/test-suite.binproto" }, { - "path": "conformance/test-definition.proto" + "path": "conformance/.eslintrc.yml" } ] } \ No newline at end of file diff --git a/dev/test/index.ts b/dev/test/index.ts index 59060dd22..0ab27c308 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -1062,7 +1062,7 @@ describe('getAll() method', () => { [Status.PERMISSION_DENIED]: 1, [Status.RESOURCE_EXHAUSTED]: 1, [Status.FAILED_PRECONDITION]: 1, - [Status.ABORTED]: 1, + [Status.ABORTED]: 5, [Status.OUT_OF_RANGE]: 1, [Status.UNIMPLEMENTED]: 1, [Status.INTERNAL]: 5, From 186cdba26c7f56ddb85f79cd9223a79b91354aca Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2020 09:22:22 -0800 Subject: [PATCH 022/337] chore: release 3.3.0 (#850) --- CHANGELOG.md | 14 ++++++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba8de1e5e..4d2ed156a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [3.3.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.2.0...v3.3.0) (2020-01-03) + + +### Features + +* add Symbol.asyncInterator to Query.stream() ([#843](https://www.github.com/googleapis/nodejs-firestore/issues/843)) ([68795c4](https://www.github.com/googleapis/nodejs-firestore/commit/68795c43ae9ef6b286650228746c7c16f59347f7)) +* use GAX retry config for streams ([#847](https://www.github.com/googleapis/nodejs-firestore/issues/847)) ([218a4c6](https://www.github.com/googleapis/nodejs-firestore/commit/218a4c65afcc55158aac45b98a4ccb28b88c00a1)) + + +### Bug Fixes + +* increase test timeout ([#846](https://www.github.com/googleapis/nodejs-firestore/issues/846)) ([b94c367](https://www.github.com/googleapis/nodejs-firestore/commit/b94c367e9655f8a6a3553610ebc655877be502ec)) +* retry writes that fail with status code ABORTED ([#854](https://www.github.com/googleapis/nodejs-firestore/issues/854)) ([96f085f](https://www.github.com/googleapis/nodejs-firestore/commit/96f085f3df7c8e6e20dbffb14ebf6ebb533fc036)) + ## [3.2.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.1.0...v3.2.0) (2019-12-30) diff --git a/package.json b/package.json index 886654964..d245cc07d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.2.0", + "version": "3.3.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 630cae1eb..aa8a64ea1 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.1.0" + "@google-cloud/firestore": "^3.3.0" }, "devDependencies": { "chai": "^4.2.0", From 0aa2a8b8d0c76e0cfc6d29c37d143cc9c0b45fec Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 6 Jan 2020 10:27:11 -0800 Subject: [PATCH 023/337] fix: don't recreate instances when client is idle --- dev/src/pool.ts | 3 ++- dev/test/pool.ts | 30 +++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/dev/src/pool.ts b/dev/src/pool.ts index 1e2d51123..3d417d8db 100644 --- a/dev/src/pool.ts +++ b/dev/src/pool.ts @@ -68,7 +68,7 @@ export class ClientPool { */ private acquire(requestTag: string): T { let selectedClient: T | null = null; - let selectedClientRequestCount = 0; + let selectedClientRequestCount = -1; for (const [client, requestCount] of this.activeClients) { // Use the "most-full" client that can still accommodate the request @@ -99,6 +99,7 @@ export class ClientPool { } else { logger('ClientPool.acquire', requestTag, 'Creating a new client'); selectedClient = this.clientFactory(); + selectedClientRequestCount = 0; assert( !this.activeClients.has(selectedClient), 'The provided client factory returned an existing instance' diff --git a/dev/test/pool.ts b/dev/test/pool.ts index 0ff986a4f..dfa658e6f 100644 --- a/dev/test/pool.ts +++ b/dev/test/pool.ts @@ -51,7 +51,7 @@ describe('Client pool', () => { expect(clientPool.size).to.equal(2); }); - it('re-uses idle instances', () => { + it('re-uses instances with remaining capacity', () => { const clientPool = new ClientPool<{}>(2, 0, () => { return {}; }); @@ -80,6 +80,34 @@ describe('Client pool', () => { }); }); + it('re-uses idle instances', async () => { + let instanceCount = 0; + const clientPool = new ClientPool<{}>(1, 1, () => { + ++instanceCount; + return {}; + }); + + const operationPromises = deferredPromises(2); + + let completionPromise = clientPool.run( + REQUEST_TAG, + () => operationPromises[0].promise + ); + expect(clientPool.size).to.equal(1); + operationPromises[0].resolve(); + await completionPromise; + + completionPromise = clientPool.run( + REQUEST_TAG, + () => operationPromises[1].promise + ); + expect(clientPool.size).to.equal(1); + operationPromises[1].resolve(); + await completionPromise; + + expect(instanceCount).to.equal(1); + }); + it('bin packs operations', async () => { let clientCount = 0; const clientPool = new ClientPool(2, 0, () => { From aba4f36071a96831cf4344ee0c764708c982c7a3 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 6 Jan 2020 20:35:16 +0200 Subject: [PATCH 024/337] chore(deps): update dependency mocha to v7 (#855) --- package.json | 2 +- samples/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d245cc07d..84163e24b 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "jsdoc-fresh": "^1.0.2", "jsdoc-region-tag": "^1.0.2", "linkinator": "^1.8.0", - "mocha": "^6.2.2", + "mocha": "^7.0.0", "c8": "^7.0.0", "power-assert": "^1.6.1", "protobufjs": "^6.8.6", diff --git a/samples/package.json b/samples/package.json index aa8a64ea1..7ae94e602 100644 --- a/samples/package.json +++ b/samples/package.json @@ -15,6 +15,6 @@ }, "devDependencies": { "chai": "^4.2.0", - "mocha": "^6.0.0" + "mocha": "^7.0.0" } } From 87543e2040651034004ab52c264bb95bb39eeef7 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2020 10:46:57 -0800 Subject: [PATCH 025/337] chore: release 3.3.1 * updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json [ci skip] Co-authored-by: Sebastian Schmidt --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d2ed156a..a74272bc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.3.1](https://www.github.com/googleapis/nodejs-firestore/compare/v3.3.0...v3.3.1) (2020-01-06) + + +### Bug Fixes + +* don't recreate instances when client is idle ([0aa2a8b](https://www.github.com/googleapis/nodejs-firestore/commit/0aa2a8b8d0c76e0cfc6d29c37d143cc9c0b45fec)) + ## [3.3.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.2.0...v3.3.0) (2020-01-03) diff --git a/package.json b/package.json index 84163e24b..92f761214 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.3.0", + "version": "3.3.1", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 7ae94e602..acac828fb 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.3.0" + "@google-cloud/firestore": "^3.3.1" }, "devDependencies": { "chai": "^4.2.0", From 8caee71f6105e82faf3f6334e69ed5890f977a3a Mon Sep 17 00:00:00 2001 From: Jake Oliver Date: Mon, 6 Jan 2020 21:25:30 +0000 Subject: [PATCH 026/337] fix: add quotes to field name to avoid ambiguity (#860) --- dev/src/serializer.ts | 2 +- dev/src/validate.ts | 2 +- dev/test/document.ts | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dev/src/serializer.ts b/dev/src/serializer.ts index 55f0231fe..346161044 100644 --- a/dev/src/serializer.ts +++ b/dev/src/serializer.ts @@ -308,7 +308,7 @@ export function validateUserInput( level = level || 0; inArray = inArray || false; - const fieldPathMessage = path ? ` (found in field ${path})` : ''; + const fieldPathMessage = path ? ` (found in field "${path}")` : ''; if (Array.isArray(value)) { for (let i = 0; i < value.length; ++i) { diff --git a/dev/src/validate.ts b/dev/src/validate.ts index c7378cacd..b749e08f3 100644 --- a/dev/src/validate.ts +++ b/dev/src/validate.ts @@ -67,7 +67,7 @@ export function customObjectMessage( value: unknown, path?: FieldPath ): string { - const fieldPathMessage = path ? ` (found in field ${path})` : ''; + const fieldPathMessage = path ? ` (found in field "${path}")` : ''; if (isObject(value)) { // We use the base class name as the type name as the sentinel classes diff --git a/dev/test/document.ts b/dev/test/document.ts index 37bc425db..dab80e153 100644 --- a/dev/test/document.ts +++ b/dev/test/document.ts @@ -140,7 +140,7 @@ describe('serialize document', () => { expect(() => { firestore.doc('collectionId/documentId').set({foo: undefined}); }).to.throw( - 'Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field foo).' + 'Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field "foo").' ); expect(() => { @@ -148,14 +148,14 @@ describe('serialize document', () => { foo: FieldPath.documentId(), }); }).to.throw( - 'Value for argument "data" is not a valid Firestore document. Cannot use object of type "FieldPath" as a Firestore value (found in field foo).' + 'Value for argument "data" is not a valid Firestore document. Cannot use object of type "FieldPath" as a Firestore value (found in field "foo").' ); expect(() => { class Foo {} firestore.doc('collectionId/documentId').set({foo: new Foo()}); }).to.throw( - 'Value for argument "data" is not a valid Firestore document. Couldn\'t serialize object of type "Foo" (found in field foo). Firestore doesn\'t support JavaScript objects with custom prototypes (i.e. objects that were created via the "new" operator).' + 'Value for argument "data" is not a valid Firestore document. Couldn\'t serialize object of type "Foo" (found in field "foo"). Firestore doesn\'t support JavaScript objects with custom prototypes (i.e. objects that were created via the "new" operator).' ); expect(() => { @@ -1238,7 +1238,7 @@ describe('set document', () => { expect(() => { firestore.doc('collectionId/documentId').set({foo: FieldValue.delete()}); }).to.throw( - 'Value for argument "data" is not a valid Firestore document. FieldValue.delete() must appear at the top-level and can only be used in update() or set() with {merge:true} (found in field foo).' + 'Value for argument "data" is not a valid Firestore document. FieldValue.delete() must appear at the top-level and can only be used in update() or set() with {merge:true} (found in field "foo").' ); }); @@ -1587,7 +1587,7 @@ describe('update document', () => { a: {b: FieldValue.delete()}, }); }).to.throw( - 'Update() requires either a single JavaScript object or an alternating list of field/value pairs that can be followed by an optional precondition. Value for argument "dataOrField" is not a valid Firestore value. FieldValue.delete() must appear at the top-level and can only be used in update() or set() with {merge:true} (found in field a.b).' + 'Update() requires either a single JavaScript object or an alternating list of field/value pairs that can be followed by an optional precondition. Value for argument "dataOrField" is not a valid Firestore value. FieldValue.delete() must appear at the top-level and can only be used in update() or set() with {merge:true} (found in field "a.b").' ); expect(() => { @@ -1595,7 +1595,7 @@ describe('update document', () => { b: FieldValue.delete(), }); }).to.throw( - 'Update() requires either a single JavaScript object or an alternating list of field/value pairs that can be followed by an optional precondition. Element at index 1 is not a valid Firestore value. FieldValue.delete() must appear at the top-level and can only be used in update() or set() with {merge:true} (found in field a.b).' + 'Update() requires either a single JavaScript object or an alternating list of field/value pairs that can be followed by an optional precondition. Element at index 1 is not a valid Firestore value. FieldValue.delete() must appear at the top-level and can only be used in update() or set() with {merge:true} (found in field "a.b").' ); expect(() => { From 006ebcb55b33eaf5a097fcf2981a4e1638c0d053 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2020 14:33:53 -0800 Subject: [PATCH 027/337] chore: release 3.3.2 (#862) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a74272bc5..9ee021dd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.3.2](https://www.github.com/googleapis/nodejs-firestore/compare/v3.3.1...v3.3.2) (2020-01-06) + + +### Bug Fixes + +* add quotes to field name to avoid ambiguity ([#860](https://www.github.com/googleapis/nodejs-firestore/issues/860)) ([8caee71](https://www.github.com/googleapis/nodejs-firestore/commit/8caee71f6105e82faf3f6334e69ed5890f977a3a)) + ### [3.3.1](https://www.github.com/googleapis/nodejs-firestore/compare/v3.3.0...v3.3.1) (2020-01-06) diff --git a/package.json b/package.json index 92f761214..3e30265e8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.3.1", + "version": "3.3.2", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index acac828fb..29c4cebeb 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.3.1" + "@google-cloud/firestore": "^3.3.2" }, "devDependencies": { "chai": "^4.2.0", From f2c4d911077c8e5b7713263fc8b2c21bbd50ca11 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 8 Jan 2020 08:43:56 -0800 Subject: [PATCH 028/337] fix: use rejected Promise for terminate() (#845) --- dev/src/pool.ts | 2 +- dev/system-test/firestore.ts | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/dev/src/pool.ts b/dev/src/pool.ts index 3d417d8db..6d0e2b36a 100644 --- a/dev/src/pool.ts +++ b/dev/src/pool.ts @@ -184,7 +184,7 @@ export class ClientPool { */ run(requestTag: string, op: (client: T) => Promise): Promise { if (this.terminated) { - throw new Error('The client has already been terminated'); + return Promise.reject('The client has already been terminated'); } const client = this.acquire(requestTag); diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 9d2fe9d2d..7491e4891 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -130,19 +130,14 @@ describe('Firestore class', () => { it('cannot make calls after the client has been terminated', () => { const ref1 = randomCol.doc('doc1'); - ref1.onSnapshot(snapshot => { - return Promise.reject('onSnapshot() should be called'); - }); return firestore .terminate() .then(() => { return ref1.set({foo: 100}); }) - .then(() => { - Promise.reject('set() should have failed'); - }) + .then(() => Promise.reject('set() should have failed')) .catch(err => { - expect(err.message).to.equal('The client has already been terminated'); + expect(err).to.equal('The client has already been terminated'); }); }); }); From a85f0c32eca5d8cf677d621a8ff326623ad5266e Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 8 Jan 2020 12:01:52 -0800 Subject: [PATCH 029/337] fix: support Objects created with Object.create({}) (#842) --- dev/src/document.ts | 4 ++-- dev/src/serializer.ts | 18 +----------------- dev/src/transaction.ts | 3 +-- dev/src/util.ts | 19 +++++++++++++++++++ dev/src/validate.ts | 18 +----------------- dev/src/write-batch.ts | 4 ++-- dev/test/document.ts | 22 ++++++++++++++-------- dev/test/util.ts | 35 +++++++++++++++++++++++++++++++++++ 8 files changed, 75 insertions(+), 48 deletions(-) create mode 100644 dev/test/util.ts diff --git a/dev/src/document.ts b/dev/src/document.ts index 6cb6f1480..a13674f5f 100644 --- a/dev/src/document.ts +++ b/dev/src/document.ts @@ -23,10 +23,10 @@ import {google} from '../protos/firestore_v1_proto_api'; import {FieldTransform} from './field-value'; import {FieldPath, validateFieldPath} from './path'; import {DocumentReference} from './reference'; -import {isPlainObject, Serializer} from './serializer'; +import {Serializer} from './serializer'; import {Timestamp} from './timestamp'; import {ApiMapValue, DocumentData, UpdateMap} from './types'; -import {isEmpty, isObject} from './util'; +import {isEmpty, isObject, isPlainObject} from './util'; import api = google.firestore.v1; diff --git a/dev/src/serializer.ts b/dev/src/serializer.ts index 346161044..1b25b12bd 100644 --- a/dev/src/serializer.ts +++ b/dev/src/serializer.ts @@ -24,7 +24,7 @@ import {DocumentReference, Firestore} from './index'; import {FieldPath, QualifiedResourcePath} from './path'; import {Timestamp} from './timestamp'; import {ApiMapValue, DocumentData, ValidationOptions} from './types'; -import {isEmpty, isObject} from './util'; +import {isEmpty, isObject, isPlainObject} from './util'; import {customObjectMessage, invalidArgumentMessage} from './validate'; import api = proto.google.firestore.v1; @@ -256,22 +256,6 @@ export class Serializer { } } -/** - * Verifies that 'obj' is a plain JavaScript object that can be encoded as a - * 'Map' in Firestore. - * - * @private - * @param input The argument to verify. - * @returns 'true' if the input can be a treated as a plain object. - */ -export function isPlainObject(input: unknown): input is DocumentData { - return ( - isObject(input) && - (Object.getPrototypeOf(input) === Object.prototype || - Object.getPrototypeOf(input) === null) - ); -} - /** * Validates a JavaScript value for usage as a Firestore value. * diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index 25b7cea24..7f20ec910 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -25,7 +25,6 @@ import { QuerySnapshot, validateDocumentReference, } from './reference'; -import {isPlainObject} from './serializer'; import { DocumentData, Precondition as PublicPrecondition, @@ -33,7 +32,7 @@ import { SetOptions, UpdateData, } from './types'; -import {isObject, requestTag} from './util'; +import {isObject, isPlainObject} from './util'; import { invalidArgumentMessage, RequiredArgumentOptions, diff --git a/dev/src/util.ts b/dev/src/util.ts index 95252e5a4..d7a690ce7 100644 --- a/dev/src/util.ts +++ b/dev/src/util.ts @@ -16,6 +16,8 @@ import {GoogleError, ServiceConfig, Status} from 'google-gax'; +import {DocumentData} from './types'; + /** * A Promise implementation that supports deferred resolution. * @private @@ -77,6 +79,23 @@ export function isObject(value: unknown): value is {[k: string]: unknown} { return Object.prototype.toString.call(value) === '[object Object]'; } +/** + * Verifies that 'obj' is a plain JavaScript object that can be encoded as a + * 'Map' in Firestore. + * + * @private + * @param input The argument to verify. + * @returns 'true' if the input can be a treated as a plain object. + */ +export function isPlainObject(input: unknown): input is DocumentData { + return ( + isObject(input) && + (Object.getPrototypeOf(input) === Object.prototype || + Object.getPrototypeOf(input) === null || + input.constructor.name === 'Object') + ); +} + /** * Returns whether `value` has no custom properties. * diff --git a/dev/src/validate.ts b/dev/src/validate.ts index b749e08f3..b820cca0f 100644 --- a/dev/src/validate.ts +++ b/dev/src/validate.ts @@ -37,22 +37,6 @@ export interface NumericRangeOptions { maxValue?: number; } -/** - * Returns the name of the base class (ignoring Object). - * - * @private - * @param value The object whose base class name to extract. - * @returns The name of the base class constructor or "Object" if value does not - * extend a custom class. - */ -function extractBaseClassName(value: object): string { - let constructorName = 'Object'; - while (Object.getPrototypeOf(value) !== Object.prototype) { - value = Object.getPrototypeOf(value); - constructorName = value.constructor.name; - } - return constructorName; -} /** * Generates an error message to use with custom objects that cannot be * serialized. @@ -73,7 +57,7 @@ export function customObjectMessage( // We use the base class name as the type name as the sentinel classes // returned by the public FieldValue API are subclasses of FieldValue. By // using the base name, we reduce the number of special cases below. - const typeName = extractBaseClassName(value); + const typeName = value.constructor.name; switch (typeName) { case 'DocumentReference': case 'FieldPath': diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 9779c0ea3..19028f55c 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -28,7 +28,7 @@ import {Firestore} from './index'; import {logger} from './logger'; import {FieldPath, validateFieldPath} from './path'; import {DocumentReference, validateDocumentReference} from './reference'; -import {isPlainObject, Serializer, validateUserInput} from './serializer'; +import {Serializer, validateUserInput} from './serializer'; import {Timestamp} from './timestamp'; import { Precondition as PublicPrecondition, @@ -37,7 +37,7 @@ import { UpdateMap, } from './types'; import {DocumentData} from './types'; -import {isObject, requestTag} from './util'; +import {isObject, isPlainObject, requestTag} from './util'; import { customObjectMessage, invalidArgumentMessage, diff --git a/dev/test/document.ts b/dev/test/document.ts index dab80e153..6facb2029 100644 --- a/dev/test/document.ts +++ b/dev/test/document.ts @@ -166,18 +166,24 @@ describe('serialize document', () => { }).to.throw( 'Value for argument "data" is not a valid Firestore document. Couldn\'t serialize object of type "Foo". Firestore doesn\'t support JavaScript objects with custom prototypes (i.e. objects that were created via the "new" operator).' ); + + expect(() => { + class Foo {} + class Bar extends Foo {} + firestore + .doc('collectionId/documentId') + .set(new Bar() as InvalidApiUsage); + }).to.throw( + 'Value for argument "data" is not a valid Firestore document. Couldn\'t serialize object of type "Bar". Firestore doesn\'t support JavaScript objects with custom prototypes (i.e. objects that were created via the "new" operator).' + ); }); it('provides custom error for objects from different Firestore instance', () => { class FieldPath {} - class CustomFieldPath extends FieldPath {} - class VeryCustomFieldPath extends CustomFieldPath {} + class GeoPoint {} + class Timestamp {} - const customClasses = [ - new FieldPath(), - new CustomFieldPath(), - new VeryCustomFieldPath(), - ]; + const customClasses = [new FieldPath(), new GeoPoint(), new Timestamp()]; for (const customClass of customClasses) { expect(() => { @@ -186,7 +192,7 @@ describe('serialize document', () => { .set(customClass as InvalidApiUsage); }).to.throw( 'Value for argument "data" is not a valid Firestore document. ' + - 'Detected an object of type "FieldPath" that doesn\'t match the expected instance.' + `Detected an object of type "${customClass.constructor.name}" that doesn't match the expected instance.` ); } }); diff --git a/dev/test/util.ts b/dev/test/util.ts new file mode 100644 index 000000000..805d2bd8b --- /dev/null +++ b/dev/test/util.ts @@ -0,0 +1,35 @@ +// 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 {expect} from 'chai'; +import {isPlainObject} from '../src/util'; + +describe('isPlainObject()', () => { + it('allows Object.create()', () => { + expect(isPlainObject(Object.create({}))).to.be.true; + expect(isPlainObject(Object.create(Object.prototype))).to.be.true; + expect(isPlainObject(Object.create(null))).to.be.true; + }); + + it(' allows plain types', () => { + expect(isPlainObject({foo: 'bar'})).to.be.true; + expect(isPlainObject({})).to.be.true; + }); + + it('rejects custom types', () => { + class Foo {} + expect(isPlainObject(new Foo())).to.be.false; + expect(isPlainObject(Object.create(new Foo()))).to.be.false; + }); +}); From f17d90e7d58431d02c349976391a5e4799a6b6f1 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 8 Jan 2020 12:11:18 -0800 Subject: [PATCH 030/337] chore: release 3.3.3 (#863) --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ee021dd4..e1ca56e54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.3.3](https://www.github.com/googleapis/nodejs-firestore/compare/v3.3.2...v3.3.3) (2020-01-08) + + +### Bug Fixes + +* support Objects created with Object.create({}) ([#842](https://www.github.com/googleapis/nodejs-firestore/issues/842)) ([a85f0c3](https://www.github.com/googleapis/nodejs-firestore/commit/a85f0c32eca5d8cf677d621a8ff326623ad5266e)) +* use rejected Promise for terminate() ([#845](https://www.github.com/googleapis/nodejs-firestore/issues/845)) ([f2c4d91](https://www.github.com/googleapis/nodejs-firestore/commit/f2c4d911077c8e5b7713263fc8b2c21bbd50ca11)) + ### [3.3.2](https://www.github.com/googleapis/nodejs-firestore/compare/v3.3.1...v3.3.2) (2020-01-06) diff --git a/package.json b/package.json index 3e30265e8..efc96eead 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.3.2", + "version": "3.3.3", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 29c4cebeb..c027c4115 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.3.2" + "@google-cloud/firestore": "^3.3.3" }, "devDependencies": { "chai": "^4.2.0", From 43472f6bd51a22a5ee27d7fc0f88a9dd97c22336 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 9 Jan 2020 09:02:17 -0800 Subject: [PATCH 031/337] fix: proper routing headers --- dev/src/v1/firestore_client.ts | 2 +- dev/src/v1beta1/firestore_client.ts | 2 +- dev/synth.metadata | 299 +--------------------------- 3 files changed, 5 insertions(+), 298 deletions(-) diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 86cd60bd0..02fda1d34 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -550,7 +550,7 @@ export class FirestoreClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - document_name: request.document!.name || '', + 'document.name': request.document!.name || '', }); return this._innerApiCalls.updateDocument(request, options, callback); } diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index 738d5dd56..e8ae66602 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -560,7 +560,7 @@ export class FirestoreClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - document_name: request.document!.name || '', + 'document.name': request.document!.name || '', }); return this._innerApiCalls.updateDocument(request, options, callback); } diff --git a/dev/synth.metadata b/dev/synth.metadata index 49226d35c..d20d3fb4f 100644 --- a/dev/synth.metadata +++ b/dev/synth.metadata @@ -1,12 +1,12 @@ { - "updateTime": "2020-01-03T12:14:28.989140Z", + "updateTime": "2020-01-09T12:16:06.483557Z", "sources": [ { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "4d45a6399e9444fbddaeb1c86aabfde210723714", - "internalRef": "287908369" + "sha": "6ace586805c08896fef43e28a261337fcf3f022b", + "internalRef": "288783603" } }, { @@ -45,298 +45,5 @@ "generator": "gapic-generator-typescript" } } - ], - "newFiles": [ - { - "path": "synth.metadata" - }, - { - "path": "test/path.ts" - }, - { - "path": "test/gapic-firestore-v1beta1.ts" - }, - { - "path": "test/fake-certificate.json" - }, - { - "path": "test/gapic-firestore-v1.ts" - }, - { - "path": "test/pool.ts" - }, - { - "path": "test/mocha.opts" - }, - { - "path": "test/timestamp.ts" - }, - { - "path": "test/document.ts" - }, - { - "path": "test/index.ts" - }, - { - "path": "test/query.ts" - }, - { - "path": "test/watch.ts" - }, - { - "path": "test/backoff.ts" - }, - { - "path": "test/gapic-firestore_admin-v1.ts" - }, - { - "path": "test/collection.ts" - }, - { - "path": "test/field-value.ts" - }, - { - "path": "test/order.ts" - }, - { - "path": "test/typescript.ts" - }, - { - "path": "test/transaction.ts" - }, - { - "path": "test/write-batch.ts" - }, - { - "path": "test/util/helpers.ts" - }, - { - "path": "system-test/.gitignore" - }, - { - "path": "system-test/firestore.ts" - }, - { - "path": "system-test/.eslintrc.yml" - }, - { - "path": "protos/firestore_admin_v1_proto_api.d.ts" - }, - { - "path": "protos/update.sh" - }, - { - "path": "protos/firestore_v1beta1_proto_api.js" - }, - { - "path": "protos/firestore_v1_proto_api.d.ts" - }, - { - "path": "protos/firestore_v1_proto_api.js" - }, - { - "path": "protos/protos.json" - }, - { - "path": "protos/firestore_v1beta1_proto_api.d.ts" - }, - { - "path": "protos/firestore_admin_v1_proto_api.js" - }, - { - "path": "protos/google/api/http.proto" - }, - { - "path": "protos/google/api/annotations.proto" - }, - { - "path": "protos/google/api/field_behavior.proto" - }, - { - "path": "protos/google/api/resource.proto" - }, - { - "path": "protos/google/api/client.proto" - }, - { - "path": "protos/google/type/latlng.proto" - }, - { - "path": "protos/google/protobuf/field_mask.proto" - }, - { - "path": "protos/google/protobuf/struct.proto" - }, - { - "path": "protos/google/protobuf/empty.proto" - }, - { - "path": "protos/google/protobuf/any.proto" - }, - { - "path": "protos/google/protobuf/wrappers.proto" - }, - { - "path": "protos/google/protobuf/timestamp.proto" - }, - { - "path": "protos/google/longrunning/operations.proto" - }, - { - "path": "protos/google/rpc/status.proto" - }, - { - "path": "protos/google/firestore/v1beta1/firestore.proto" - }, - { - "path": "protos/google/firestore/v1beta1/common.proto" - }, - { - "path": "protos/google/firestore/v1beta1/query.proto" - }, - { - "path": "protos/google/firestore/v1beta1/write.proto" - }, - { - "path": "protos/google/firestore/v1beta1/document.proto" - }, - { - "path": "protos/google/firestore/admin/v1/location.proto" - }, - { - "path": "protos/google/firestore/admin/v1/index.proto" - }, - { - "path": "protos/google/firestore/admin/v1/firestore_admin.proto" - }, - { - "path": "protos/google/firestore/admin/v1/operation.proto" - }, - { - "path": "protos/google/firestore/admin/v1/field.proto" - }, - { - "path": "protos/google/firestore/v1/firestore.proto" - }, - { - "path": "protos/google/firestore/v1/common.proto" - }, - { - "path": "protos/google/firestore/v1/query.proto" - }, - { - "path": "protos/google/firestore/v1/write.proto" - }, - { - "path": "protos/google/firestore/v1/document.proto" - }, - { - "path": "src/path.ts" - }, - { - "path": "src/util.ts" - }, - { - "path": "src/reference.ts" - }, - { - "path": "src/logger.ts" - }, - { - "path": "src/types.ts" - }, - { - "path": "src/geo-point.ts" - }, - { - "path": "src/pool.ts" - }, - { - "path": "src/timestamp.ts" - }, - { - "path": "src/document.ts" - }, - { - "path": "src/convert.ts" - }, - { - "path": "src/index.ts" - }, - { - "path": "src/validate.ts" - }, - { - "path": "src/serializer.ts" - }, - { - "path": "src/watch.ts" - }, - { - "path": "src/backoff.ts" - }, - { - "path": "src/external-modules.d.ts" - }, - { - "path": "src/field-value.ts" - }, - { - "path": "src/order.ts" - }, - { - "path": "src/document-change.ts" - }, - { - "path": "src/transaction.ts" - }, - { - "path": "src/write-batch.ts" - }, - { - "path": "src/v1beta1/index.ts" - }, - { - "path": "src/v1beta1/firestore_client.ts" - }, - { - "path": "src/v1beta1/firestore_client_config.json" - }, - { - "path": "src/v1beta1/firestore_proto_list.json" - }, - { - "path": "src/v1/index.ts" - }, - { - "path": "src/v1/firestore_client.ts" - }, - { - "path": "src/v1/firestore_client_config.json" - }, - { - "path": "src/v1/firestore_admin_client_config.json" - }, - { - "path": "src/v1/firestore_admin_client.ts" - }, - { - "path": "src/v1/firestore_admin_proto_list.json" - }, - { - "path": "src/v1/firestore_proto_list.json" - }, - { - "path": "conformance/test-definition.proto" - }, - { - "path": "conformance/runner.ts" - }, - { - "path": "conformance/test-suite.binproto" - }, - { - "path": "conformance/.eslintrc.yml" - } ] } \ No newline at end of file From af3196fe8da2018e0a9842f4f62588ce2c740597 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 9 Jan 2020 10:37:42 -0800 Subject: [PATCH 032/337] fix: remove redundant log line (#868) --- dev/src/pool.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/dev/src/pool.ts b/dev/src/pool.ts index 6d0e2b36a..31080fcab 100644 --- a/dev/src/pool.ts +++ b/dev/src/pool.ts @@ -78,12 +78,6 @@ export class ClientPool { requestCount > selectedClientRequestCount && requestCount < this.concurrentOperationLimit ) { - logger( - 'ClientPool.acquire', - requestTag, - 'Re-using existing client with %s remaining operations', - this.concurrentOperationLimit - requestCount - ); selectedClient = client; selectedClientRequestCount = requestCount; } From 69bd69a3bc3d49e82a56c7cf14e0e4885d9af9cb Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 9 Jan 2020 10:45:36 -0800 Subject: [PATCH 033/337] refactor: use typed GAPIC methods (#849) --- dev/conformance/runner.ts | 44 ++++----- dev/src/index.ts | 118 +++++++++++------------ dev/src/reference.ts | 14 ++- dev/src/transaction.ts | 2 +- dev/src/types.ts | 62 ++++++++++++- dev/src/watch.ts | 2 +- dev/src/write-batch.ts | 8 +- dev/test/collection.ts | 9 +- dev/test/document.ts | 165 ++++++++++++++++----------------- dev/test/fake-certificate.json | 8 -- dev/test/field-value.ts | 17 ++-- dev/test/index.ts | 33 +++---- dev/test/query.ts | 4 +- dev/test/transaction.ts | 45 +++++---- dev/test/util/helpers.ts | 100 +++++--------------- dev/test/watch.ts | 8 +- dev/test/write-batch.ts | 17 ++-- package.json | 3 +- 18 files changed, 334 insertions(+), 325 deletions(-) delete mode 100644 dev/test/fake-certificate.json diff --git a/dev/conformance/runner.ts b/dev/conformance/runner.ts index 41811ee47..0c8f6019e 100644 --- a/dev/conformance/runner.ts +++ b/dev/conformance/runner.ts @@ -15,7 +15,6 @@ const duplexify = require('duplexify'); import {expect} from 'chai'; -import {CallOptions} from 'google-gax'; import * as path from 'path'; import * as protobufjs from 'protobufjs'; import * as through2 from 'through2'; @@ -36,10 +35,12 @@ import { import {fieldsFromJson} from '../src/convert'; import {DocumentChangeType} from '../src/document-change'; import {QualifiedResourcePath} from '../src/path'; +import {UnaryMethod} from '../src/types'; import {isObject} from '../src/util'; import { ApiOverride, createInstance as createInstanceHelper, + response, } from '../test/util/helpers'; import api = proto.google.firestore.v1; @@ -248,32 +249,23 @@ const convertProto = { }; /** Request handler for _commit. */ -function commitHandler(spec: ConformanceProto) { - return ( - request: api.ICommitRequest, - options: CallOptions, - callback: ( - err: Error | null | undefined, - resp?: api.ICommitResponse - ) => void - ) => { - try { - const actualCommit = COMMIT_REQUEST_TYPE.fromObject(request); - const expectedCommit = COMMIT_REQUEST_TYPE.fromObject(spec.request); - expect(actualCommit).to.deep.equal(expectedCommit); - const res: api.IWriteResponse = { - commitTime: {}, - writeResults: [], - }; - for (let i = 1; i <= request.writes!.length; ++i) { - res.writeResults!.push({ - updateTime: {}, - }); - } - callback(null, res); - } catch (err) { - callback(err); +function commitHandler( + spec: ConformanceProto +): UnaryMethod { + return request => { + const actualCommit = COMMIT_REQUEST_TYPE.fromObject(request); + const expectedCommit = COMMIT_REQUEST_TYPE.fromObject(spec.request); + expect(actualCommit).to.deep.equal(expectedCommit); + const res: api.ICommitResponse = { + commitTime: {}, + writeResults: [], + }; + for (let i = 1; i <= request.writes!.length; ++i) { + res.writeResults!.push({ + updateTime: {}, + }); } + return response(res); }; } diff --git a/dev/src/index.ts b/dev/src/index.ts index c765b30b5..2d5f92fe8 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -41,7 +41,15 @@ import {DocumentReference} from './reference'; import {Serializer} from './serializer'; import {Timestamp} from './timestamp'; import {parseGetAllArguments, Transaction} from './transaction'; -import {ApiMapValue, GapicClient, ReadOptions, Settings} from './types'; +import { + ApiMapValue, + FirestoreStreamingMethod, + FirestoreUnaryMethod, + GapicClient, + ReadOptions, + Settings, + UnaryMethod, +} from './types'; import {Deferred, isPermanentRpcError, requestTag} from './util'; import { validateBoolean, @@ -392,7 +400,7 @@ export class Firestore { this._settings.maxIdleChannels === undefined ? DEFAULT_MAX_IDLE_CHANNELS : this._settings.maxIdleChannels; - this._clientPool = new ClientPool( + this._clientPool = new ClientPool( MAX_CONCURRENT_REQUESTS_PER_CLIENT, maxIdleChannels, /* clientFactory= */ () => { @@ -409,7 +417,7 @@ export class Firestore { logger('Firestore', null, 'Initialized Firestore GAPIC Client'); return client; }, - /* clientDestructor= */ (client: GapicClient) => client.close() + /* clientDestructor= */ client => client.close() ); logger('Firestore', null, 'Initialized Firestore'); @@ -956,7 +964,7 @@ export class Firestore { const self = this; return self - .requestStream('batchGetDocuments', 'unidirectional', request, requestTag) + .requestStream('batchGetDocuments', request, requestTag) .then(stream => { return new Promise((resolve, reject) => { stream @@ -1056,29 +1064,25 @@ export class Firestore { this._settingsFrozen = true; if (this._projectId === undefined) { - this._projectId = await this._clientPool.run(requestTag, gapicClient => { - return new Promise((resolve, reject) => { - gapicClient.getProjectId((err: Error, projectId: string) => { - if (err) { - logger( - 'Firestore._detectProjectId', - null, - 'Failed to detect project ID: %s', - err - ); - reject(err); - } else { - logger( - 'Firestore._detectProjectId', - null, - 'Detected project ID: %s', - projectId - ); - resolve(projectId); - } - }); - }); - }); + try { + this._projectId = await this._clientPool.run(requestTag, gapicClient => + gapicClient.getProjectId() + ); + logger( + 'Firestore.initializeIfNeeded', + null, + 'Detected project ID: %s', + this._projectId + ); + } catch (err) { + logger( + 'Firestore.initializeIfNeeded', + null, + 'Failed to detect project ID: %s', + err + ); + return Promise.reject(err); + } } } @@ -1263,7 +1267,7 @@ export class Firestore { /** * A funnel for all non-streaming API requests, assigning a project ID where - * necessary within the request options. + * necessary within the request options. * * @private * @param methodName Name of the Veneer API endpoint that takes a request @@ -1272,32 +1276,32 @@ export class Firestore { * @param requestTag A unique client-assigned identifier for this request. * @returns A Promise with the request result. */ - request(methodName: string, request: {}, requestTag: string): Promise { + request( + methodName: FirestoreUnaryMethod, + request: Req, + requestTag: string + ): Promise { const callOptions = this.createCallOptions(); - return this._clientPool.run(requestTag, gapicClient => { - return new Promise((resolve, reject) => { + return this._clientPool.run(requestTag, async gapicClient => { + try { logger('Firestore.request', requestTag, 'Sending request: %j', request); - gapicClient[methodName]( - request, - callOptions, - (err: GoogleError, result: T) => { - if (err) { - logger('Firestore.request', requestTag, 'Received error:', err); - reject(err); - } else { - logger( - 'Firestore.request', - requestTag, - 'Received response: %j', - result - ); - this._lastSuccessfulRequest = new Date().getTime(); - resolve(result); - } - } + const [result] = await (gapicClient[methodName] as UnaryMethod< + Req, + Resp + >)(request, callOptions); + logger( + 'Firestore.request', + requestTag, + 'Received response: %j', + result ); - }); + this._lastSuccessfulRequest = new Date().getTime(); + return result; + } catch (err) { + logger('Firestore.request', requestTag, 'Received error:', err); + return Promise.reject(err); + } }); } @@ -1311,19 +1315,18 @@ export class Firestore { * @private * @param methodName Name of the streaming Veneer API endpoint that * takes a request and GAX options. - * @param mode Whether this a unidirectional or bidirectional call. * @param request The Protobuf request to send. * @param requestTag A unique client-assigned identifier for this request. * @returns A Promise with the resulting read-only stream. */ requestStream( - methodName: string, - mode: 'unidirectional' | 'bidirectional', + methodName: FirestoreStreamingMethod, request: {}, requestTag: string ): Promise { const callOptions = this.createCallOptions(); + const bidrectional = methodName === 'listen'; const result = new Deferred(); this._clientPool.run(requestTag, gapicClient => { @@ -1339,10 +1342,9 @@ export class Firestore { 'Sending request: %j', request ); - const stream: Duplex = - mode === 'unidirectional' - ? gapicClient[methodName](request, callOptions) - : gapicClient[methodName](callOptions); + const stream = bidrectional + ? gapicClient[methodName](callOptions) + : gapicClient[methodName](request, callOptions); const logStream = through2.obj(function(this, chunk, enc, callback) { logger( 'Firestore.requestStream', @@ -1362,7 +1364,7 @@ export class Firestore { const resultStream = await this._initializeStream( stream, requestTag, - mode === 'bidirectional' ? request : undefined + bidrectional ? request : undefined ); resultStream.on('end', () => stream.end()); diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 048622b0e..442db77db 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -293,7 +293,11 @@ export class DocumentReference implements Serializable { pageSize: Math.pow(2, 16) - 1, }; return this._firestore - .request('listCollectionIds', request, tag) + .request( + 'listCollectionIds', + request, + tag + ) .then(collectionIds => { const collections: CollectionReference[] = []; @@ -1829,7 +1833,7 @@ export class Query { this.firestore.initializeIfNeeded(tag).then(() => { const request = this.toProto(transactionId); this._firestore - .requestStream('runQuery', 'unidirectional', request, tag) + .requestStream('runQuery', request, tag) .then(backendStream => { backendStream.on('error', err => { logger( @@ -2060,7 +2064,11 @@ export class CollectionReference extends Query { }; return this.firestore - .request('listDocuments', request, tag) + .request( + 'listDocuments', + request, + tag + ) .then(documents => { // Note that the backend already orders these documents by name, // so we do not need to manually sort them. diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index 7f20ec910..ebefaeb86 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -363,7 +363,7 @@ export class Transaction { } return this._firestore - .request( + .request( 'beginTransaction', request, this._requestTag diff --git a/dev/src/types.ts b/dev/src/types.ts index cca4fdc0d..a82b68349 100644 --- a/dev/src/types.ts +++ b/dev/src/types.ts @@ -14,6 +14,9 @@ * limitations under the License. */ +import {CallOptions} from 'google-gax'; +import {Duplex} from 'stream'; + import {google} from '../protos/firestore_v1_proto_api'; import {FieldPath} from './path'; import {Timestamp} from './timestamp'; @@ -27,9 +30,62 @@ export interface ApiMapValue { [k: string]: google.firestore.v1.IValue; } -// We don't have type information for the JavaScript GapicClient. -// tslint:disable-next-line:no-any -export type GapicClient = any; +/** + * The subset of methods we use from FirestoreClient. + * + * We don't depend on the actual Gapic client to avoid loading the GAX stack at + * module initialization time. + */ +export interface GapicClient { + getProjectId(): Promise; + beginTransaction( + request: api.IBeginTransactionRequest, + options?: CallOptions + ): Promise<[api.IBeginTransactionResponse, unknown, unknown]>; + commit( + request: api.ICommitRequest, + options?: CallOptions + ): Promise<[api.ICommitResponse, unknown, unknown]>; + rollback( + request: api.IRollbackRequest, + options?: CallOptions + ): Promise<[google.protobuf.IEmpty, unknown, unknown]>; + batchGetDocuments( + request?: api.IBatchGetDocumentsRequest, + options?: CallOptions + ): Duplex; + runQuery(request?: api.IRunQueryRequest, options?: CallOptions): Duplex; + listDocuments( + request: api.IListDocumentsRequest, + options?: CallOptions + ): Promise<[api.IDocument[], unknown, unknown]>; + listCollectionIds( + request: api.IListCollectionIdsRequest, + options?: CallOptions + ): Promise<[string[], unknown, unknown]>; + listen(options?: CallOptions): Duplex; + close(): Promise; +} + +/** Request/response methods used in the Firestore SDK. */ +export type FirestoreUnaryMethod = + | 'listDocuments' + | 'listCollectionIds' + | 'rollback' + | 'beginTransaction' + | 'commit'; + +/** Streaming methods used in the Firestore SDK. */ +export type FirestoreStreamingMethod = + | 'listen' + | 'runQuery' + | 'batchGetDocuments'; + +/** Type signature for the unary methods in the GAPIC layer. */ +export type UnaryMethod = ( + request: Req, + callOptions: CallOptions +) => Promise<[Resp, unknown, unknown]>; // We don't have type information for the npm package // `functional-red-black-tree`. diff --git a/dev/src/watch.ts b/dev/src/watch.ts index 6771399fa..4a6ef2a16 100644 --- a/dev/src/watch.ts +++ b/dev/src/watch.ts @@ -390,7 +390,7 @@ abstract class Watch { // Note that we need to call the internal _listen API to pass additional // header values in readWriteStream. return this.firestore - .requestStream('listen', 'bidirectional', request, this.requestTag) + .requestStream('listen', request, this.requestTag) .then(backendStream => { if (!this.isActive) { logger( diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 19028f55c..1f3bf5103 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -534,7 +534,6 @@ export class WriteBatch { await this._firestore.initializeIfNeeded(tag); const database = this._firestore.formattedName; - const request: api.ICommitRequest = {database}; // On GCF, we periodically force transactional commits to allow for // request retries in case GCF closes our backend connection. @@ -542,9 +541,9 @@ export class WriteBatch { if (!explicitTransaction && this._shouldCreateTransaction()) { logger('WriteBatch.commit', tag, 'Using transaction for commit'); return this._firestore - .request( + .request( 'beginTransaction', - request, + {database}, tag ) .then(resp => { @@ -552,6 +551,7 @@ export class WriteBatch { }); } + const request: api.ICommitRequest = {database}; const writes = this._ops.map(op => op()); request.writes = []; @@ -586,7 +586,7 @@ export class WriteBatch { } return this._firestore - .request('commit', request, tag) + .request('commit', request, tag) .then(resp => { const writeResults: WriteResult[] = []; diff --git a/dev/test/collection.ts b/dev/test/collection.ts index 96e2a3f64..6bf8b00b2 100644 --- a/dev/test/collection.ts +++ b/dev/test/collection.ts @@ -21,6 +21,7 @@ import { DATABASE_ROOT, document, InvalidApiUsage, + response, verifyInstance, } from './util/helpers'; @@ -84,7 +85,7 @@ describe('Collection interface', () => { it('has add() method', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { // Verify that the document name uses an auto-generated id. const docIdRe = /^projects\/test-project\/databases\/\(default\)\/documents\/collectionId\/[a-zA-Z0-9]{20}$/; expect(request.writes![0].update!.name).to.match(docIdRe); @@ -105,7 +106,7 @@ describe('Collection interface', () => { ], }); - callback(null, { + return response({ commitTime: { nanos: 0, seconds: 0, @@ -137,7 +138,7 @@ describe('Collection interface', () => { it('has list() method', () => { const overrides: ApiOverride = { - listDocuments: (request, options, callback) => { + listDocuments: (request, options) => { expect(request).to.deep.eq({ parent: `${DATABASE_ROOT}/documents/a/b`, collectionId: 'c', @@ -146,7 +147,7 @@ describe('Collection interface', () => { mask: {fieldPaths: []}, }); - callback(null, [document('first'), document('second')]); + return response([document('first'), document('second')]); }, }; diff --git a/dev/test/document.ts b/dev/test/document.ts index 6facb2029..43c764a4d 100644 --- a/dev/test/document.ts +++ b/dev/test/document.ts @@ -13,8 +13,8 @@ // limitations under the License. import {expect} from 'chai'; +import {GoogleError, Status} from 'google-gax'; -import * as proto from '../protos/firestore_v1_proto_api'; import { DocumentReference, FieldPath, @@ -34,6 +34,7 @@ import { missing, remove, requestEquals, + response, retrieve, serverTimestamp, set, @@ -44,8 +45,6 @@ import { writeResult, } from './util/helpers'; -import {GoogleError, Status} from 'google-gax'; - const PROJECT_ID = 'test-project'; const INVALID_ARGUMENTS_TO_UPDATE = new RegExp( @@ -116,7 +115,7 @@ describe('serialize document', () => { it('serializes to Protobuf JS', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ @@ -125,7 +124,7 @@ describe('serialize document', () => { }), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -199,7 +198,7 @@ describe('serialize document', () => { it('serializes large numbers into doubles', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ @@ -208,7 +207,7 @@ describe('serialize document', () => { }), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -222,7 +221,7 @@ describe('serialize document', () => { it('serializes date before 1970', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ @@ -234,7 +233,7 @@ describe('serialize document', () => { }), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -247,14 +246,14 @@ describe('serialize document', () => { it('serializes unicode keys', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ document: document('documentId', '😀', '😜'), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -267,7 +266,7 @@ describe('serialize document', () => { it('accepts both blob formats', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ @@ -282,7 +281,7 @@ describe('serialize document', () => { ), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -296,14 +295,14 @@ describe('serialize document', () => { it('supports NaN and Infinity', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { const fields = request.writes![0].update!.fields!; expect(fields.nanValue.doubleValue).to.be.a('number'); expect(fields.nanValue.doubleValue).to.be.NaN; expect(fields.posInfinity.doubleValue).to.equal(Infinity); expect(fields.negInfinity.doubleValue).to.equal(-Infinity); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -365,7 +364,7 @@ describe('serialize document', () => { it('is able to write a document reference with cycles', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ @@ -374,7 +373,7 @@ describe('serialize document', () => { }), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -718,10 +717,10 @@ describe('delete document', () => { it('generates proto', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals(request, remove('documentId')); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -732,10 +731,10 @@ describe('delete document', () => { it('returns update time', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals(request, remove('documentId')); - callback(null, { + return response({ commitTime: { nanos: 123000000, seconds: 479978400, @@ -758,7 +757,7 @@ describe('delete document', () => { it('with last update time precondition', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, remove('documentId', { @@ -769,7 +768,7 @@ describe('delete document', () => { }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -837,14 +836,14 @@ describe('set document', () => { it('supports empty map', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ document: document('documentId'), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -855,7 +854,7 @@ describe('set document', () => { it('supports nested empty map', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ @@ -864,7 +863,7 @@ describe('set document', () => { }), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -875,14 +874,14 @@ describe('set document', () => { it('skips merges with just field transform', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ transforms: [serverTimestamp('a'), serverTimestamp('b.c')], }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -899,7 +898,7 @@ describe('set document', () => { it('sends empty non-merge write even with just field transform', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ @@ -907,7 +906,7 @@ describe('set document', () => { transforms: [serverTimestamp('a'), serverTimestamp('b.c')], }) ); - callback(null, writeResult(2)); + return response(writeResult(2)); }, }; @@ -921,7 +920,7 @@ describe('set document', () => { it('supports document merges', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ @@ -937,7 +936,7 @@ describe('set document', () => { mask: updateMask('a', 'c.d', 'f'), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -950,7 +949,7 @@ describe('set document', () => { it('supports document merges with field mask', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ @@ -982,7 +981,7 @@ describe('set document', () => { mask: updateMask('a', 'b', 'd.e', 'f'), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1003,7 +1002,7 @@ describe('set document', () => { it('supports document merges with empty field mask', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ @@ -1011,7 +1010,7 @@ describe('set document', () => { mask: updateMask(), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1027,7 +1026,7 @@ describe('set document', () => { it('supports document merges with field mask and empty maps', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ @@ -1057,7 +1056,7 @@ describe('set document', () => { mask: updateMask('a', 'c.d'), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1074,7 +1073,7 @@ describe('set document', () => { it('supports document merges with field mask and field transform', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ @@ -1087,7 +1086,7 @@ describe('set document', () => { ], }) ); - callback(null, writeResult(2)); + return response(writeResult(2)); }, }; @@ -1111,7 +1110,7 @@ describe('set document', () => { it('supports empty merge', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ @@ -1119,7 +1118,7 @@ describe('set document', () => { mask: updateMask(), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1130,7 +1129,7 @@ describe('set document', () => { it('supports nested empty merge', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ @@ -1140,7 +1139,7 @@ describe('set document', () => { mask: updateMask('a'), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1156,14 +1155,14 @@ describe('set document', () => { it("doesn't split on dots", () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, set({ document: document('documentId', 'a.b', 'c'), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1270,9 +1269,9 @@ describe('create document', () => { it('creates document', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals(request, create({document: document('documentId')})); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1283,10 +1282,10 @@ describe('create document', () => { it('returns update time', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals(request, create({document: document('documentId')})); - callback(null, { + return response({ commitTime: { nanos: 0, seconds: 0, @@ -1316,7 +1315,7 @@ describe('create document', () => { it('supports field transform', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, create({ @@ -1326,7 +1325,7 @@ describe('create document', () => { ], }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1340,7 +1339,7 @@ describe('create document', () => { it('supports nested empty map', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, create({ @@ -1355,7 +1354,7 @@ describe('create document', () => { }), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1394,7 +1393,7 @@ describe('update document', () => { it('generates proto', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, update({ @@ -1402,7 +1401,7 @@ describe('update document', () => { mask: updateMask('foo'), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1413,7 +1412,7 @@ describe('update document', () => { it('supports nested field transform', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, update({ @@ -1424,7 +1423,7 @@ describe('update document', () => { mask: updateMask('a', 'foo'), }) ); - callback(null, writeResult(2)); + return response(writeResult(2)); }, }; @@ -1439,9 +1438,9 @@ describe('update document', () => { it('skips write for single field transform', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals(request, update({transforms: [serverTimestamp('a')]})); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1454,7 +1453,7 @@ describe('update document', () => { it('supports nested empty map', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, update({ @@ -1464,7 +1463,7 @@ describe('update document', () => { mask: updateMask('a'), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1475,12 +1474,12 @@ describe('update document', () => { it('supports nested delete', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, update({document: document('documentId'), mask: updateMask('a.b')}) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1493,7 +1492,7 @@ describe('update document', () => { it('returns update time', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, update({ @@ -1501,7 +1500,7 @@ describe('update document', () => { mask: updateMask('foo'), }) ); - callback(null, { + return response({ commitTime: { nanos: 0, seconds: 0, @@ -1531,7 +1530,7 @@ describe('update document', () => { it('with last update time precondition', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, update({ @@ -1545,7 +1544,7 @@ describe('update document', () => { }, }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1615,7 +1614,7 @@ describe('update document', () => { it('with top-level document', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, update({ @@ -1623,7 +1622,7 @@ describe('update document', () => { mask: updateMask('foo'), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1636,7 +1635,7 @@ describe('update document', () => { it('with nested document', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, update({ @@ -1672,7 +1671,7 @@ describe('update document', () => { mask: updateMask('a.b.c', 'foo.bar'), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1691,7 +1690,7 @@ describe('update document', () => { it('with two nested fields ', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, update({ @@ -1719,7 +1718,7 @@ describe('update document', () => { ), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1749,7 +1748,7 @@ describe('update document', () => { it('with nested field and document transform ', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, update({ @@ -1785,7 +1784,7 @@ describe('update document', () => { ), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1801,7 +1800,7 @@ describe('update document', () => { it('with field with dot ', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, update({ @@ -1809,7 +1808,7 @@ describe('update document', () => { mask: updateMask('`a.b`'), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; return createInstance(overrides).then(firestore => { @@ -1960,7 +1959,7 @@ describe('update document', () => { it('with field delete', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { requestEquals( request, update({ @@ -1968,7 +1967,7 @@ describe('update document', () => { mask: updateMask('bar', 'foo'), }) ); - callback(null, writeResult(1)); + return response(writeResult(1)); }, }; @@ -1984,13 +1983,13 @@ describe('update document', () => { describe('listCollections() method', () => { it('sorts results', () => { const overrides: ApiOverride = { - listCollectionIds: (request, options, callback) => { + listCollectionIds: request => { expect(request).to.deep.eq({ parent: `projects/${PROJECT_ID}/databases/(default)/documents/coll/doc`, pageSize: 65535, }); - callback(null, ['second', 'first']); + return response(['second', 'first']); }, }; diff --git a/dev/test/fake-certificate.json b/dev/test/fake-certificate.json deleted file mode 100644 index c72de1984..000000000 --- a/dev/test/fake-certificate.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type": "service_account", - "project_id": "...", - "private_key_id": "...", - "private_key": "...", - "client_email": "...", - "client_id": "..." -} diff --git a/dev/test/field-value.ts b/dev/test/field-value.ts index 973e3309f..2228a1138 100644 --- a/dev/test/field-value.ts +++ b/dev/test/field-value.ts @@ -23,6 +23,7 @@ import { incrementTransform, InvalidApiUsage, requestEquals, + response, serverTimestamp, set, writeResult, @@ -96,7 +97,7 @@ describe('FieldValue.arrayUnion()', () => { it('can be used with set()', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { const expectedRequest = set({ document: document('documentId', 'foo', 'bar'), transforms: [ @@ -107,7 +108,7 @@ describe('FieldValue.arrayUnion()', () => { requestEquals(request, expectedRequest); - callback(null, writeResult(2)); + return response(writeResult(2)); }, }; @@ -152,7 +153,7 @@ describe('FieldValue.increment()', () => { it('can be used with set()', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { const expectedRequest = set({ document: document('documentId', 'foo', 'bar'), transforms: [ @@ -161,7 +162,7 @@ describe('FieldValue.increment()', () => { ], }); requestEquals(request, expectedRequest); - callback(null, writeResult(2)); + return response(writeResult(2)); }, }; @@ -194,7 +195,7 @@ describe('FieldValue.arrayRemove()', () => { it('can be used with set()', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { const expectedRequest = set({ document: document('documentId', 'foo', 'bar'), transforms: [ @@ -204,7 +205,7 @@ describe('FieldValue.arrayRemove()', () => { }); requestEquals(request, expectedRequest); - callback(null, writeResult(2)); + return response(writeResult(2)); }, }; @@ -232,14 +233,14 @@ describe('FieldValue.serverTimestamp()', () => { it('can be used with set()', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { const expectedRequest = set({ document: document('documentId', 'foo', 'bar'), transforms: [serverTimestamp('field'), serverTimestamp('map.field')], }); requestEquals(request, expectedRequest); - callback(null, writeResult(2)); + return response(writeResult(2)); }, }; diff --git a/dev/test/index.ts b/dev/test/index.ts index 0ab27c308..73e1bb2af 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -15,7 +15,7 @@ import {expect, use} from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; import * as extend from 'extend'; -import * as gax from 'google-gax'; +import {GoogleError, GrpcClient, Status} from 'google-gax'; import {google} from '../protos/firestore_v1_proto_api'; @@ -31,23 +31,22 @@ import { found, InvalidApiUsage, missing, + response, stream, verifyInstance, } from './util/helpers'; import api = google.firestore.v1; -import {Status} from 'google-gax'; use(chaiAsPromised); -const {grpc} = new gax.GrpcClient({}); +const {grpc} = new GrpcClient({}); const PROJECT_ID = 'test-project'; const DATABASE_ROOT = `projects/${PROJECT_ID}/databases/(default)`; const DEFAULT_SETTINGS = { projectId: PROJECT_ID, sslCreds: grpc.credentials.createInsecure(), - keyFilename: __dirname + '/fake-certificate.json', }; // Change the argument to 'console.log' to enable debug output. @@ -516,9 +515,7 @@ describe('instantiation', () => { it('uses project id from gapic client', async () => { return createInstance( { - getProjectId: callback => { - callback(null, 'foo'); - }, + getProjectId: () => Promise.resolve('foo'), }, {projectId: undefined} ).then(async firestore => { @@ -533,7 +530,6 @@ describe('instantiation', () => { it('uses project ID from settings()', () => { const firestore = new Firestore.Firestore({ sslCreds: grpc.credentials.createInsecure(), - keyFilename: './test/fake-certificate.json', }); firestore.settings({projectId: PROJECT_ID}); @@ -546,9 +542,7 @@ describe('instantiation', () => { it('handles error from project ID detection', () => { return createInstance( { - getProjectId: callback => { - callback(new Error('Injected Error'), null); - }, + getProjectId: () => Promise.reject(new Error('Injected Error')), }, {projectId: undefined} ).then(firestore => { @@ -609,11 +603,11 @@ describe('instantiation', () => { describe('serializer', () => { it('supports all types', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { expect(allSupportedTypesProtobufJs.fields).to.deep.eq( request.writes![0].update!.fields ); - callback(null, { + return response({ commitTime: {}, writeResults: [ { @@ -662,7 +656,6 @@ describe('snapshot_() method', () => { firestore = new Firestore.Firestore({ projectId: PROJECT_ID, sslCreds: grpc.credentials.createInsecure(), - keyFilename: './test/fake-certificate.json', }); }); @@ -882,13 +875,13 @@ describe('collection() method', () => { describe('listCollections() method', () => { it('returns collections', () => { const overrides: ApiOverride = { - listCollectionIds: (request, options, callback) => { + listCollectionIds: request => { expect(request).to.deep.eq({ parent: `projects/${PROJECT_ID}/databases/(default)/documents`, pageSize: 65535, }); - callback(null, ['first', 'second']); + return response(['first', 'second']); }, }; @@ -1075,10 +1068,10 @@ describe('getAll() method', () => { const overrides: ApiOverride = { batchGetDocuments: request => { - const errorCode = Number(request.documents![0].split('/').pop()); + const errorCode = Number(request!.documents![0].split('/').pop()); actualErrorAttempts[errorCode] = (actualErrorAttempts[errorCode] || 0) + 1; - const error = new gax.GoogleError('Expected exception'); + const error = new GoogleError('Expected exception'); error.code = errorCode; return stream(error); }, @@ -1171,7 +1164,7 @@ describe('getAll() method', () => { it('accepts same document multiple times', () => { const overrides: ApiOverride = { batchGetDocuments: request => { - expect(request.documents!.length).to.equal(2); + expect(request!.documents!.length).to.equal(2); return stream(found('a'), found('b')); }, }; @@ -1193,7 +1186,7 @@ describe('getAll() method', () => { it('applies field mask', () => { const overrides: ApiOverride = { batchGetDocuments: request => { - expect(request.mask!.fieldPaths).to.have.members([ + expect(request!.mask!.fieldPaths).to.have.members([ 'foo.bar', '`foo.bar`', ]); diff --git a/dev/test/query.ts b/dev/test/query.ts index 6aa4fda80..f2c546c78 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -254,9 +254,11 @@ function endAt( } function queryEquals( - actual: api.IRunQueryRequest, + actual: api.IRunQueryRequest | undefined, ...protoComponents: api.IStructuredQuery[] ) { + expect(actual).to.not.be.undefined; + const query: api.IRunQueryRequest = { parent: DATABASE_ROOT + '/documents', structuredQuery: { diff --git a/dev/test/transaction.ts b/dev/test/transaction.ts index 0e202261c..b4dba86a8 100644 --- a/dev/test/transaction.ts +++ b/dev/test/transaction.ts @@ -16,12 +16,18 @@ import {expect, use} from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; import * as extend from 'extend'; import {GoogleError, Status} from 'google-gax'; +import {Duplex} from 'stream'; import * as through2 from 'through2'; import * as proto from '../protos/firestore_v1_proto_api'; import * as Firestore from '../src'; import {DocumentReference, FieldPath, Transaction} from '../src'; -import {ApiOverride, createInstance, InvalidApiUsage} from './util/helpers'; +import { + ApiOverride, + createInstance, + InvalidApiUsage, + response, +} from './util/helpers'; import api = proto.google.firestore.v1; @@ -58,7 +64,7 @@ interface TransactionStep { | api.IRunQueryRequest; error?: Error; response?: api.ICommitResponse | api.IBeginTransactionResponse; - stream?: NodeJS.ReadableStream; + stream?: Duplex; } function commit( @@ -267,26 +273,35 @@ function runTransaction( ...expectedRequests: TransactionStep[] ) { const overrides: ApiOverride = { - beginTransaction: (actual, _, callback) => { + beginTransaction: actual => { const request = expectedRequests.shift()!; expect(request.type).to.equal('begin'); expect(actual).to.deep.eq(request.request); - callback( - request.error, - request.response as api.IBeginTransactionResponse - ); + if (request.error) { + return Promise.reject(request.error); + } else { + return response(request.response as api.IBeginTransactionResponse); + } }, - commit: (actual, _, callback) => { + commit: actual => { const request = expectedRequests.shift()!; expect(request.type).to.equal('commit'); expect(actual).to.deep.eq(request.request); - callback(request.error, request.response as api.ICommitResponse); + if (request.error) { + return Promise.reject(request.error); + } else { + return response(request.response as api.ICommitResponse); + } }, - rollback: (actual, _, callback) => { + rollback: actual => { const request = expectedRequests.shift()!; expect(request.type).to.equal('rollback'); expect(actual).to.deep.eq(request.request); - callback(request.error); + if (request.error) { + return Promise.reject(request.error); + } else { + return response({}); + } }, batchGetDocuments: actual => { const request = expectedRequests.shift()!; @@ -347,9 +362,7 @@ describe('successful transactions', () => { describe('failed transactions', () => { it('requires update function', () => { const overrides: ApiOverride = { - beginTransaction: () => { - expect.fail(); - }, + beginTransaction: () => Promise.reject(), }; return createInstance(overrides).then(firestore => { @@ -361,9 +374,7 @@ describe('failed transactions', () => { it('requires valid retry number', () => { const overrides: ApiOverride = { - beginTransaction: () => { - expect.fail(); - }, + beginTransaction: () => Promise.reject(), }; return createInstance(overrides).then(firestore => { diff --git a/dev/test/util/helpers.ts b/dev/test/util/helpers.ts index df050d683..614e30db2 100644 --- a/dev/test/util/helpers.ts +++ b/dev/test/util/helpers.ts @@ -14,7 +14,8 @@ import {expect} from 'chai'; import * as extend from 'extend'; -import {CallOptions, GrpcClient} from 'google-gax'; +import {GrpcClient} from 'google-gax'; +import {Duplex} from 'stream'; import * as through2 from 'through2'; import * as proto from '../../protos/firestore_v1_proto_api'; @@ -40,94 +41,35 @@ export const DOCUMENT_NAME = `${COLLECTION_ROOT}/documentId`; // tslint:disable-next-line:no-any export type InvalidApiUsage = any; -/** - * Interface that defines the request handlers used by Firestore. - */ -export interface ApiOverride { - beginTransaction?: ( - request: api.IBeginTransactionRequest, - options: CallOptions, - callback: (err?: Error | null, resp?: api.IBeginTransactionResponse) => void - ) => void; - commit?: ( - request: api.ICommitRequest, - options: CallOptions, - callback: (err?: Error | null, resp?: api.ICommitResponse) => void - ) => void; - rollback?: ( - request: api.IRollbackRequest, - options: CallOptions, - callback: (err?: Error | null, resp?: void) => void - ) => void; - listCollectionIds?: ( - request: api.IListCollectionIdsRequest, - options: CallOptions, - callback: (err?: Error | null, resp?: string[]) => void - ) => void; - listDocuments?: ( - request: api.IListDocumentsRequest, - options: CallOptions, - callback: (err?: Error | null, resp?: api.IDocument[]) => void - ) => void; - batchGetDocuments?: ( - request: api.IBatchGetDocumentsRequest - ) => NodeJS.ReadableStream; - runQuery?: (request: api.IRunQueryRequest) => NodeJS.ReadableStream; - listen?: () => NodeJS.ReadWriteStream; - getProjectId?: ( - callback: (err?: Error | null, projectId?: string | null) => void - ) => void; -} +/** Defines the request handlers used by Firestore. */ +export type ApiOverride = Partial; /** * Creates a new Firestore instance for testing. Request handlers can be * overridden by providing `apiOverrides`. * - * @param {ApiOverride} apiOverrides An object with the request handlers to - * override. - * @param {Object} firestoreSettings Firestore Settings to configure the client. - * @return {Promise} A Promise that resolves with the new Firestore - * client. + * @param apiOverrides An object with request handlers to override. + * @param firestoreSettings Firestore Settings to configure the client. + * @return A Promise that resolves with the new Firestore client. */ export function createInstance( apiOverrides?: ApiOverride, firestoreSettings?: {} ): Promise { - const initializationOptions = Object.assign( - { - projectId: PROJECT_ID, - sslCreds: SSL_CREDENTIALS, - keyFilename: __dirname + '/../fake-certificate.json', - }, - firestoreSettings - ); + const initializationOptions = { + ...{projectId: PROJECT_ID, sslCreds: SSL_CREDENTIALS}, + ...firestoreSettings, + }; const firestore = new Firestore(); firestore.settings(initializationOptions); - const clientPool = new ClientPool( + firestore['_clientPool'] = new ClientPool( /* concurrentRequestLimit= */ 1, /* maxIdleClients= */ 0, - () => { - const gapicClient: GapicClient = new v1(initializationOptions); - if (apiOverrides) { - Object.keys(apiOverrides).forEach(override => { - const apiOverride = (apiOverrides as {[k: string]: unknown})[ - override - ]; - if (override !== 'getProjectId') { - gapicClient._innerApiCalls[override] = apiOverride; - } else { - gapicClient[override] = apiOverride; - } - }); - } - return gapicClient; - } + () => ({...new v1(initializationOptions), ...apiOverrides}) ); - firestore['_clientPool'] = clientPool; - return Promise.resolve(firestore); } @@ -357,7 +299,12 @@ export function writeResult(count: number): api.IWriteResponse { return response; } -export function requestEquals(actual: object, expected: object): void { +export function requestEquals( + actual: object | undefined, + expected: object +): void { + expect(actual).to.not.be.undefined; + // 'extend' removes undefined fields in the request object. The backend // ignores these fields, but we need to manually strip them before we compare // the expected and the actual request. @@ -366,9 +313,7 @@ export function requestEquals(actual: object, expected: object): void { expect(actual).to.deep.eq(proto); } -export function stream( - ...elements: Array -): NodeJS.ReadableStream { +export function stream(...elements: Array): Duplex { const stream = through2.obj(); setImmediate(() => { @@ -384,3 +329,8 @@ export function stream( return stream; } + +/** Creates a response as formatted by the GAPIC request methods. */ +export function response(result: T): Promise<[T, unknown, unknown]> { + return Promise.resolve([result, undefined, undefined]); +} diff --git a/dev/test/watch.ts b/dev/test/watch.ts index 5975ee666..efdd3f6c9 100644 --- a/dev/test/watch.ts +++ b/dev/test/watch.ts @@ -17,7 +17,7 @@ const duplexify = require('duplexify'); import {expect} from 'chai'; import * as extend from 'extend'; import {GoogleError, Status} from 'google-gax'; -import {Transform} from 'stream'; +import {Duplex, Transform} from 'stream'; import * as through2 from 'through2'; import {google} from '../protos/firestore_v1_proto_api'; @@ -244,14 +244,14 @@ class StreamHelper { private readonly deferredListener = new DeferredListener< api.IListenRequest >(); - private backendStream: NodeJS.ReadWriteStream | null = null; + private backendStream: Duplex | null = null; streamCount = 0; // The number of streams that the client has requested readStream: Transform | null = null; writeStream: Transform | null = null; /** Returns the GAPIC callback to use with this stream helper. */ - getListenCallback(): () => NodeJS.ReadWriteStream { + getListenCallback(): () => Duplex { return () => { // Create a mock backend whose stream we can return. ++this.streamCount; @@ -676,7 +676,7 @@ describe('Query watch', () => { }; /** The GAPIC callback that executes the listen. */ - let listenCallback: () => NodeJS.ReadWriteStream; + let listenCallback: () => Duplex; beforeEach(() => { // We are intentionally skipping the delays to ensure fast test execution. diff --git a/dev/test/write-batch.ts b/dev/test/write-batch.ts index ef71e68f3..1b125347f 100644 --- a/dev/test/write-batch.ts +++ b/dev/test/write-batch.ts @@ -26,6 +26,7 @@ import { ApiOverride, createInstance, InvalidApiUsage, + response, verifyInstance, } from './util/helpers'; @@ -187,7 +188,7 @@ describe('batch support', () => { beforeEach(() => { const overrides: ApiOverride = { - commit: (request, options, callback) => { + commit: request => { expect(request).to.deep.eq({ database: `projects/${PROJECT_ID}/databases/(default)`, writes: [ @@ -238,7 +239,7 @@ describe('batch support', () => { }, ], }); - callback(null, { + return response({ commitTime: { nanos: 0, seconds: 0, @@ -368,8 +369,8 @@ describe('batch support', () => { it('can return same write result', () => { const overrides: ApiOverride = { - commit: (request, options, callback) => { - callback(null, { + commit: request => { + return response({ commitTime: { nanos: 0, seconds: 0, @@ -411,13 +412,13 @@ describe('batch support', () => { let commitCalled = 0; const overrides: ApiOverride = { - beginTransaction: (actual, options, callback) => { + beginTransaction: () => { ++beginCalled; - callback(null, {transaction: Buffer.from('foo')}); + return response({transaction: Buffer.from('foo')}); }, - commit: (request, options, callback) => { + commit: () => { ++commitCalled; - callback(null, { + return response({ commitTime: { nanos: 0, seconds: 0, diff --git a/package.json b/package.json index efc96eead..4825af8a8 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "test": "npm run test-only && npm run conformance", "lint": "gts check", "clean": "gts clean", - "compile": "tsc -p . && cp -r dev/protos build && cp -r dev/test/fake-certificate.json build/test/fake-certificate.json && cp dev/src/v1beta1/*.json build/src/v1beta1/ && cp dev/src/v1/*.json build/src/v1/ && cp dev/conformance/test-definition.proto build/conformance && cp dev/conformance/test-suite.binproto build/conformance", + "compile": "tsc -p .", + "postcompile": "cp -r dev/protos build && cp dev/src/v1beta1/*.json build/src/v1beta1/ && cp dev/src/v1/*.json build/src/v1/ && cp dev/conformance/test-definition.proto build/conformance && cp dev/conformance/test-suite.binproto build/conformance", "fix": "gts fix", "prepare": "npm run compile", "docs-test": "linkinator docs", From 47f7ab52f9133064785754ee924d9f8736853eba Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Sun, 12 Jan 2020 09:40:31 -0800 Subject: [PATCH 034/337] fix: do not release client before retry (#870) --- dev/src/index.ts | 86 ++++++++++++++++++++++++----------------------- dev/test/index.ts | 12 ++++++- dev/test/pool.ts | 4 +-- 3 files changed, 57 insertions(+), 45 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index 2d5f92fe8..131014cd9 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -1173,6 +1173,8 @@ export class Firestore { * * @private * @param backendStream The Node stream to monitor. + * @param lifetime A Promise that resolves when the stream receives an 'end', + * 'close' or 'finish' message. * @param requestTag A unique client-assigned identifier for this request. * @param request If specified, the request that should be written to the * stream after opening. @@ -1181,6 +1183,7 @@ export class Firestore { */ private _initializeStream( backendStream: Duplex, + lifetime: Deferred, requestTag: string, request?: {} ): Promise { @@ -1202,19 +1205,22 @@ export class Firestore { } } + backendStream.on('data', () => streamReady()); + function streamEnded() { logger( 'Firestore._initializeStream', requestTag, 'Received stream end' ); - streamReady(); resultStream.unpipe(backendStream); + resolve(resultStream); + lifetime.resolve(); } - backendStream.on('data', () => streamReady()); backendStream.on('end', () => streamEnded()); backendStream.on('close', () => streamEnded()); + backendStream.on('finish', () => streamEnded()); backendStream.on('error', err => { if (!streamInitialized) { @@ -1240,7 +1246,7 @@ export class Firestore { // allows the caller to attach an error handler. setImmediate(() => { resultStream.emit('error', err); - }, 0); + }); } }); @@ -1326,58 +1332,54 @@ export class Firestore { ): Promise { const callOptions = this.createCallOptions(); - const bidrectional = methodName === 'listen'; - const result = new Deferred(); + const bidirectional = methodName === 'listen'; - this._clientPool.run(requestTag, gapicClient => { - // While we return the stream to the callee early, we don't want to - // release the GAPIC client until the callee has finished processing the - // stream. - const lifetime = new Deferred(); + return this._retry(methodName, requestTag, () => { + const result = new Deferred(); - this._retry(methodName, requestTag, async () => { + this._clientPool.run(requestTag, async gapicClient => { logger( 'Firestore.requestStream', requestTag, 'Sending request: %j', request ); - const stream = bidrectional - ? gapicClient[methodName](callOptions) - : gapicClient[methodName](request, callOptions); - const logStream = through2.obj(function(this, chunk, enc, callback) { - logger( - 'Firestore.requestStream', + try { + const stream = bidirectional + ? gapicClient[methodName](callOptions) + : gapicClient[methodName](request, callOptions); + const logStream = through2.obj(function(this, chunk, enc, callback) { + logger( + 'Firestore.requestStream', + requestTag, + 'Received response: %j', + chunk + ); + callback(); + }); + stream.pipe(logStream); + + const lifetime = new Deferred(); + const resultStream = await this._initializeStream( + stream, + lifetime, requestTag, - 'Received response: %j', - chunk + bidirectional ? request : undefined ); - callback(); - }); - - stream.pipe(logStream); - stream.on('close', lifetime.resolve); - stream.on('end', lifetime.resolve); - stream.on('finish', lifetime.resolve); - stream.on('error', lifetime.resolve); - - const resultStream = await this._initializeStream( - stream, - requestTag, - bidrectional ? request : undefined - ); - - resultStream.on('end', () => stream.end()); - result.resolve(resultStream); - }).catch(err => { - lifetime.resolve(); - result.reject(err); + resultStream.on('end', () => stream.end()); + result.resolve(resultStream); + + // While we return the stream to the callee early, we don't want to + // release the GAPIC client until the callee has finished processing the + // stream. + return lifetime.promise; + } catch (e) { + result.reject(e); + } }); - return lifetime.promise; + return result.promise; }); - - return result.promise; } } diff --git a/dev/test/index.ts b/dev/test/index.ts index 73e1bb2af..2e7343f17 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -960,8 +960,11 @@ describe('getAll() method', () => { }); it('handles stream exception during initialization', () => { + let attempts = 0; + const overrides: ApiOverride = { batchGetDocuments: () => { + ++attempts; return stream(new Error('Expected exception')); }, }; @@ -973,14 +976,18 @@ describe('getAll() method', () => { throw new Error('Unexpected success in Promise'); }) .catch(err => { + expect(attempts).to.equal(5); expect(err.message).to.equal('Expected exception'); }); }); }); it('handles stream exception after initialization', () => { + let attempts = 0; + const overrides: ApiOverride = { batchGetDocuments: () => { + ++attempts; return stream(found('documentId'), new Error('Expected exception')); }, }; @@ -992,13 +999,16 @@ describe('getAll() method', () => { throw new Error('Unexpected success in Promise'); }) .catch(err => { + // We don't retry since the stream might have already been released + // to the end user. + expect(attempts).to.equal(1); expect(err.message).to.equal('Expected exception'); }); }); }); it('handles intermittent stream exception', () => { - let attempts = 1; + let attempts = 0; const overrides: ApiOverride = { batchGetDocuments: () => { diff --git a/dev/test/pool.ts b/dev/test/pool.ts index dfa658e6f..623af579d 100644 --- a/dev/test/pool.ts +++ b/dev/test/pool.ts @@ -319,12 +319,12 @@ describe('Client pool', () => { return clientPool .terminate() .then(() => { - clientPool.run(REQUEST_TAG, () => + return clientPool.run(REQUEST_TAG, () => Promise.reject('Call to run() should have failed') ); }) .catch((err: Error) => { - expect(err.message).to.equal('The client has already been terminated'); + expect(err).to.equal('The client has already been terminated'); }); }); }); From 87c2819defc3cdbe94b469b6d44ba2dcfcb5d7f3 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2020 11:47:17 -0800 Subject: [PATCH 035/337] chore: release 3.3.4 (#867) --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1ca56e54..6f6d77339 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.3.4](https://www.github.com/googleapis/nodejs-firestore/compare/v3.3.3...v3.3.4) (2020-01-12) + + +### Bug Fixes + +* do not release client before retry ([#870](https://www.github.com/googleapis/nodejs-firestore/issues/870)) ([47f7ab5](https://www.github.com/googleapis/nodejs-firestore/commit/47f7ab52f9133064785754ee924d9f8736853eba)) +* proper routing headers ([43472f6](https://www.github.com/googleapis/nodejs-firestore/commit/43472f6bd51a22a5ee27d7fc0f88a9dd97c22336)) +* remove redundant log line ([#868](https://www.github.com/googleapis/nodejs-firestore/issues/868)) ([af3196f](https://www.github.com/googleapis/nodejs-firestore/commit/af3196fe8da2018e0a9842f4f62588ce2c740597)) + ### [3.3.3](https://www.github.com/googleapis/nodejs-firestore/compare/v3.3.2...v3.3.3) (2020-01-08) diff --git a/package.json b/package.json index 4825af8a8..6e0c8d7a2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.3.3", + "version": "3.3.4", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index c027c4115..4e3431bcd 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.3.3" + "@google-cloud/firestore": "^3.3.4" }, "devDependencies": { "chai": "^4.2.0", From b7b5fc993d4cece92833c95487efe63320537058 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 13 Jan 2020 14:57:24 -0800 Subject: [PATCH 036/337] fix: don't format log message if logging is disable (#874) --- dev/src/logger.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/dev/src/logger.ts b/dev/src/logger.ts index 7bc542e8c..28296f3f1 100644 --- a/dev/src/logger.ts +++ b/dev/src/logger.ts @@ -22,7 +22,7 @@ import {validateFunction} from './validate'; let libVersion: string; /*! The external function used to emit logs. */ -let logFunction = (msg: string) => {}; +let logFunction: ((msg: string) => void) | undefined = undefined; /** * Log function to use for debug output. By default, we don't perform any @@ -38,12 +38,14 @@ export function logger( ): void { requestTag = requestTag || '#####'; - const formattedMessage = util.format(logMessage, ...additionalArgs); - const time = new Date().toISOString(); - logFunction( - `Firestore (${libVersion}) ${time} ${requestTag} [${methodName}]: ` + - formattedMessage - ); + if (logFunction) { + const formattedMessage = util.format(logMessage, ...additionalArgs); + const time = new Date().toISOString(); + logFunction( + `Firestore (${libVersion}) ${time} ${requestTag} [${methodName}]: ` + + formattedMessage + ); + } } /** From 9169fae692d219b5fb42004a4eb82e5a5919f087 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 14 Jan 2020 09:36:54 -0800 Subject: [PATCH 037/337] feat: support serialization of Moment.js (#879) --- dev/src/serializer.ts | 29 ++++++++++++++++++++++++++++- dev/test/document.ts | 31 +++++++++++++++++++++++++++++++ package.json | 3 ++- 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/dev/src/serializer.ts b/dev/src/serializer.ts index 1b25b12bd..db6b3de30 100644 --- a/dev/src/serializer.ts +++ b/dev/src/serializer.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import {Moment} from 'moment'; + import * as proto from '../protos/firestore_v1_proto_api'; import {detectValueType} from './convert'; @@ -119,7 +121,17 @@ export class Serializer { } if (val instanceof Date) { - const timestamp = Timestamp.fromDate(val as Date); + const timestamp = Timestamp.fromDate(val); + return { + timestampValue: { + seconds: timestamp.seconds, + nanos: timestamp.nanoseconds, + }, + }; + } + + if (isMomentJsType(val)) { + const timestamp = Timestamp.fromDate(val.toDate()); return { timestampValue: { seconds: timestamp.seconds, @@ -369,6 +381,8 @@ export function validateUserInput( // Ok. } else if (value instanceof Timestamp || value instanceof Date) { // Ok. + } else if (isMomentJsType(value)) { + // Ok. } else if (value instanceof Buffer || value instanceof Uint8Array) { // Ok. } else if (value === null) { @@ -377,3 +391,16 @@ export function validateUserInput( throw new Error(customObjectMessage(arg, value, path)); } } + +/** + * Returns true if value is a MomentJs date object. + * @private + */ +function isMomentJsType(value: unknown): value is Moment { + return ( + typeof value === 'object' && + value !== null && + value.constructor.name === 'Moment' && + typeof (value as Moment).toDate === 'function' + ); +} diff --git a/dev/test/document.ts b/dev/test/document.ts index 43c764a4d..8d9a8594b 100644 --- a/dev/test/document.ts +++ b/dev/test/document.ts @@ -244,6 +244,37 @@ describe('serialize document', () => { }); }); + it('supports Moment.js', () => { + class Moment { + toDate(): Date { + return new Date('Jul 20 1969 20:18:00.123 UTC'); + } + } + + const overrides: ApiOverride = { + commit: request => { + requestEquals( + request, + set({ + document: document('documentId', 'moonLanding', { + timestampValue: { + nanos: 123000000, + seconds: -14182920, + }, + }), + }) + ); + return response(writeResult(1)); + }, + }; + + return createInstance(overrides).then(firestore => { + return firestore.doc('collectionId/documentId').set({ + moonLanding: new Moment(), + }); + }); + }); + it('serializes unicode keys', () => { const overrides: ApiOverride = { commit: request => { diff --git a/package.json b/package.json index 6e0c8d7a2..d74da7697 100644 --- a/package.json +++ b/package.json @@ -61,8 +61,10 @@ "@types/duplexify": "^3.5.0", "@types/extend": "^3.0.0", "@types/mocha": "^5.2.3", + "@types/moment": "^2.13.0", "@types/node": "^12.12.17", "@types/through2": "^2.0.34", + "c8": "^7.0.0", "chai": "^4.1.2", "chai-as-promised": "^7.1.1", "codecov": "^3.6.1", @@ -76,7 +78,6 @@ "jsdoc-region-tag": "^1.0.2", "linkinator": "^1.8.0", "mocha": "^7.0.0", - "c8": "^7.0.0", "power-assert": "^1.6.1", "protobufjs": "^6.8.6", "proxyquire": "^2.1.3", From 36d75f6b75d7ede4656636f1d8bf770eb1cb3a80 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 14 Jan 2020 10:25:49 -0800 Subject: [PATCH 038/337] feat: allow logging to be disabled (#880) --- dev/src/logger.ts | 11 +++++++---- types/firestore.d.ts | 7 +++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/dev/src/logger.ts b/dev/src/logger.ts index 28296f3f1..c0b3cb07f 100644 --- a/dev/src/logger.ts +++ b/dev/src/logger.ts @@ -22,7 +22,7 @@ import {validateFunction} from './validate'; let libVersion: string; /*! The external function used to emit logs. */ -let logFunction: ((msg: string) => void) | undefined = undefined; +let logFunction: ((msg: string) => void) | null = null; /** * Log function to use for debug output. By default, we don't perform any @@ -49,15 +49,18 @@ export function logger( } /** - * Sets the log function for all active Firestore instances. + * 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. */ -export function setLogFunction(logger: (msg: string) => void): void { +export function setLogFunction(logger: ((msg: string) => void) | null): void { validateFunction('logger', logger); logFunction = logger; } /** - * Sets the log function for all active Firestore instances. + * Sets the library version to be used in log messages. * * @private */ diff --git a/types/firestore.d.ts b/types/firestore.d.ts index c6f5f1533..038c90018 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -35,9 +35,12 @@ declare namespace FirebaseFirestore { export type UpdateData = {[fieldPath: string]: any}; /** - * Sets the log function for all active Firestore instances. + * 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): void; + function setLogFunction(logger: ((msg:string) => void) | null) : void; /** * Settings used to directly configure a `Firestore` instance. From 94ddc897400cafe5a1ee16f3ad0d285411bdd0b2 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 14 Jan 2020 10:44:21 -0800 Subject: [PATCH 039/337] feat: add support for Typescript Custom Mapping (#828) --- dev/src/document-change.ts | 9 +- dev/src/document.ts | 77 ++++--- dev/src/index.ts | 41 ++-- dev/src/reference.ts | 381 +++++++++++++++++++++++++++-------- dev/src/transaction.ts | 52 +++-- dev/src/types.ts | 75 ++++++- dev/src/watch.ts | 104 ++++++---- dev/src/write-batch.ts | 37 ++-- dev/system-test/firestore.ts | 86 +++++++- dev/test/collection.ts | 52 +++++ dev/test/document.ts | 52 +++++ dev/test/query.ts | 41 +++- dev/test/typescript.ts | 13 ++ dev/test/util/helpers.ts | 20 +- dev/test/watch.ts | 3 +- types/firestore.d.ts | 223 ++++++++++++++------ 16 files changed, 967 insertions(+), 299 deletions(-) diff --git a/dev/src/document-change.ts b/dev/src/document-change.ts index b0e40eafd..0b8c16ecf 100644 --- a/dev/src/document-change.ts +++ b/dev/src/document-change.ts @@ -15,6 +15,7 @@ */ import {QueryDocumentSnapshot} from './document'; +import {DocumentData} from './types'; export type DocumentChangeType = 'added' | 'removed' | 'modified'; @@ -24,9 +25,9 @@ export type DocumentChangeType = 'added' | 'removed' | 'modified'; * * @class */ -export class DocumentChange { +export class DocumentChange { private readonly _type: DocumentChangeType; - private readonly _document: QueryDocumentSnapshot; + private readonly _document: QueryDocumentSnapshot; private readonly _oldIndex: number; private readonly _newIndex: number; @@ -42,7 +43,7 @@ export class DocumentChange { */ constructor( type: DocumentChangeType, - document: QueryDocumentSnapshot, + document: QueryDocumentSnapshot, oldIndex: number, newIndex: number ) { @@ -169,7 +170,7 @@ export class DocumentChange { * @param {*} other The value to compare against. * @return true if this `DocumentChange` is equal to the provided value. */ - isEqual(other: DocumentChange): boolean { + isEqual(other: DocumentChange): boolean { if (this === other) { return true; } diff --git a/dev/src/document.ts b/dev/src/document.ts index a13674f5f..e0bc273c5 100644 --- a/dev/src/document.ts +++ b/dev/src/document.ts @@ -36,10 +36,7 @@ import api = google.firestore.v1; * * @private */ -export class DocumentSnapshotBuilder { - /** The reference to the document. */ - ref?: DocumentReference; - +export class DocumentSnapshotBuilder { /** The fields of the Firestore `Document` Protobuf backing this document. */ fieldsProto?: ApiMapValue; @@ -52,6 +49,10 @@ export class DocumentSnapshotBuilder { /** The time when this document was last updated. */ updateTime?: Timestamp; + // We include the DocumentReference in the constructor in order to allow the + // DocumentSnapshotBuilder to be typed with when it is constructed. + constructor(readonly ref: DocumentReference) {} + /** * Builds the DocumentSnapshot. * @@ -59,7 +60,7 @@ export class DocumentSnapshotBuilder { * @returns Returns either a QueryDocumentSnapshot (if `fieldsProto` was * provided) or a DocumentSnapshot. */ - build(): QueryDocumentSnapshot | DocumentSnapshot { + build(): QueryDocumentSnapshot | DocumentSnapshot { assert( (this.fieldsProto !== undefined) === (this.createTime !== undefined), 'Create time should be set iff document exists.' @@ -94,9 +95,8 @@ export class DocumentSnapshotBuilder { * * @class */ -export class DocumentSnapshot { - private _ref: DocumentReference; - private _fieldsProto: ApiMapValue | undefined; +export class DocumentSnapshot { + private _ref: DocumentReference; private _serializer: Serializer; private _readTime: Timestamp | undefined; private _createTime: Timestamp | undefined; @@ -106,7 +106,7 @@ export class DocumentSnapshot { * @hideconstructor * * @param ref The reference to the document. - * @param fieldsProto The fields of the Firestore `Document` Protobuf backing + * @param _fieldsProto The fields of the Firestore `Document` Protobuf backing * this document (or undefined if the document does not exist). * @param readTime The time when this snapshot was read (or undefined if * the document exists only locally). @@ -116,14 +116,13 @@ export class DocumentSnapshot { * if the document does not exist). */ constructor( - ref: DocumentReference, - fieldsProto?: ApiMapValue, + ref: DocumentReference, + readonly _fieldsProto?: ApiMapValue, readTime?: Timestamp, createTime?: Timestamp, updateTime?: Timestamp ) { this._ref = ref; - this._fieldsProto = fieldsProto; this._serializer = ref.firestore._serializer!; this._readTime = readTime; this._createTime = createTime; @@ -138,10 +137,10 @@ export class DocumentSnapshot { * @param obj The object to store in the DocumentSnapshot. * @return The created DocumentSnapshot. */ - static fromObject( - ref: DocumentReference, + static fromObject( + ref: DocumentReference, obj: DocumentData - ): DocumentSnapshot { + ): DocumentSnapshot { const serializer = ref.firestore._serializer!; return new DocumentSnapshot(ref, serializer.encodeFields(obj)); } @@ -156,10 +155,10 @@ export class DocumentSnapshot { * @param data The field/value map to expand. * @return The created DocumentSnapshot. */ - static fromUpdateMap( - ref: DocumentReference, + static fromUpdateMap( + ref: DocumentReference, data: UpdateMap - ): DocumentSnapshot { + ): DocumentSnapshot { const serializer = ref.firestore._serializer!; /** @@ -270,7 +269,7 @@ export class DocumentSnapshot { * } * }); */ - get ref(): DocumentReference { + get ref(): DocumentReference { return this._ref; } @@ -364,8 +363,8 @@ export class DocumentSnapshot { * Retrieves all fields in the document as an object. Returns 'undefined' if * the document doesn't exist. * - * @returns {DocumentData|undefined} An object containing all fields in the - * document or 'undefined' if the document doesn't exist. + * @returns {T|undefined} An object containing all fields in the document or + * 'undefined' if the document doesn't exist. * * @example * let documentRef = firestore.doc('col/doc'); @@ -375,11 +374,7 @@ export class DocumentSnapshot { * console.log(`Retrieved data: ${JSON.stringify(data)}`); * }); */ - // We deliberately use `any` in the external API to not impose type-checking - // on end users. - // tslint:disable-next-line no-any - data(): {[field: string]: any} | undefined { - // tslint:disable-line no-any + data(): T | undefined { const fields = this._fieldsProto; if (fields === undefined) { @@ -390,7 +385,7 @@ export class DocumentSnapshot { for (const prop of Object.keys(fields)) { obj[prop] = this._serializer.decodeValue(fields[prop]); } - return obj; + return this.ref._converter.fromFirestore(obj); } /** @@ -490,7 +485,7 @@ export class DocumentSnapshot { * @return {boolean} true if this `DocumentSnapshot` is equal to the provided * value. */ - isEqual(other: DocumentSnapshot): boolean { + isEqual(other: DocumentSnapshot): boolean { // Since the read time is different on every document read, we explicitly // ignore all document metadata in this comparison. return ( @@ -517,7 +512,9 @@ export class DocumentSnapshot { * @class * @extends DocumentSnapshot */ -export class QueryDocumentSnapshot extends DocumentSnapshot { +export class QueryDocumentSnapshot extends DocumentSnapshot< + T +> { /** * @hideconstructor * @@ -529,7 +526,7 @@ export class QueryDocumentSnapshot extends DocumentSnapshot { * @param updateTime The time when the document was last updated. */ constructor( - ref: DocumentReference, + ref: DocumentReference, fieldsProto: ApiMapValue, readTime: Timestamp, createTime: Timestamp, @@ -582,7 +579,7 @@ export class QueryDocumentSnapshot extends DocumentSnapshot { * * @override * - * @returns {DocumentData} An object containing all fields in the document. + * @returns {T} An object containing all fields in the document. * * @example * let query = firestore.collection('col'); @@ -592,7 +589,7 @@ export class QueryDocumentSnapshot extends DocumentSnapshot { * console.log(`Retrieved data: ${JSON.stringify(data)}`); * }); */ - data(): DocumentData { + data(): T { const data = super.data(); if (!data) { throw new Error( @@ -871,7 +868,7 @@ export class DocumentMask { * @private * @class */ -export class DocumentTransform { +export class DocumentTransform { /** * @private * @hideconstructor @@ -880,7 +877,7 @@ export class DocumentTransform { * @param transforms A Map of FieldPaths to FieldTransforms. */ constructor( - private readonly ref: DocumentReference, + private readonly ref: DocumentReference, private readonly transforms: Map ) {} @@ -892,10 +889,10 @@ export class DocumentTransform { * @param obj The object to extract the transformations from. * @returns The Document Transform. */ - static fromObject( - ref: DocumentReference, + static fromObject( + ref: DocumentReference, obj: DocumentData - ): DocumentTransform { + ): DocumentTransform { const updateMap = new Map(); for (const prop of Object.keys(obj)) { @@ -913,10 +910,10 @@ export class DocumentTransform { * @param data The update data to extract the transformations from. * @returns The Document Transform. */ - static fromUpdateMap( - ref: DocumentReference, + static fromUpdateMap( + ref: DocumentReference, data: UpdateMap - ): DocumentTransform { + ): DocumentTransform { const transforms = new Map(); function encode_(val: unknown, path: FieldPath, allowTransforms: boolean) { diff --git a/dev/src/index.ts b/dev/src/index.ts index 131014cd9..8f83c12da 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -43,6 +43,7 @@ import {Timestamp} from './timestamp'; import {parseGetAllArguments, Transaction} from './transaction'; import { ApiMapValue, + DocumentData, FirestoreStreamingMethod, FirestoreUnaryMethod, GapicClient, @@ -83,6 +84,7 @@ export {FieldPath} from './path'; export {GeoPoint} from './geo-point'; export {setLogFunction} from './logger'; export { + FirestoreDataConverter, UpdateData, DocumentData, Settings, @@ -695,20 +697,22 @@ export class Firestore { ); } - const document = new DocumentSnapshotBuilder(); - + let ref: DocumentReference; + let document: DocumentSnapshotBuilder; if (typeof documentOrName === 'string') { - document.ref = new DocumentReference( + ref = new DocumentReference( this, QualifiedResourcePath.fromSlashSeparatedString(documentOrName) ); + document = new DocumentSnapshotBuilder(ref); } else { - document.ref = new DocumentReference( + ref = new DocumentReference( this, QualifiedResourcePath.fromSlashSeparatedString( documentOrName.name as string ) ); + document = new DocumentSnapshotBuilder(ref); document.fieldsProto = documentOrName.fields ? convertFields(documentOrName.fields as ApiMapValue) : {}; @@ -886,7 +890,7 @@ export class Firestore { * } * }); */ - listCollections() { + listCollections(): Promise { const rootDocument = new DocumentReference(this, ResourcePath.EMPTY); return rootDocument.listCollections(); } @@ -912,9 +916,9 @@ export class Firestore { * console.log(`Second document: ${JSON.stringify(docs[1])}`); * }); */ - getAll( - ...documentRefsOrReadOptions: Array - ): Promise { + getAll( + ...documentRefsOrReadOptions: Array | ReadOptions> + ): Promise>> { validateMinNumberOfArguments('Firestore.getAll', arguments, 1); const {documents, fieldMask} = parseGetAllArguments( @@ -937,12 +941,12 @@ export class Firestore { * @param transactionId The transaction ID to use for this read. * @returns A Promise that contains an array with the resulting documents. */ - getAll_( - docRefs: DocumentReference[], + getAll_( + docRefs: Array>, fieldMask: FieldPath[] | null, requestTag: string, transactionId?: Uint8Array - ): Promise { + ): Promise>> { const requestedDocuments = new Set(); const retrievedDocuments = new Map(); @@ -962,11 +966,10 @@ export class Firestore { } const self = this; - return self .requestStream('batchGetDocuments', request, requestTag) .then(stream => { - return new Promise((resolve, reject) => { + return new Promise>>((resolve, reject) => { stream .on('error', err => { logger( @@ -1024,11 +1027,19 @@ export class Firestore { // BatchGetDocuments doesn't preserve document order. We use // the request order to sort the resulting documents. - const orderedDocuments: DocumentSnapshot[] = []; + const orderedDocuments: Array> = []; + for (const docRef of docRefs) { const document = retrievedDocuments.get(docRef.path); if (document !== undefined) { - orderedDocuments.push(document); + // Recreate the DocumentSnapshot with the DocumentReference + // containing the original converter. + const finalDoc = new DocumentSnapshotBuilder(docRef); + finalDoc.fieldsProto = document._fieldsProto; + finalDoc.readTime = document.readTime; + finalDoc.createTime = document.createTime; + finalDoc.updateTime = document.updateTime; + orderedDocuments.push(finalDoc.build()); } else { reject( new Error(`Did not receive document for "${docRef.path}".`) diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 442db77db..df580d81e 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -39,7 +39,9 @@ import { import {Serializable, Serializer, validateUserInput} from './serializer'; import {Timestamp} from './timestamp'; import { + defaultConverter, DocumentData, + FirestoreDataConverter, OrderByDirection, Precondition, SetOptions, @@ -121,7 +123,7 @@ const comparisonOperators: { * * @class */ -export class DocumentReference implements Serializable { +export class DocumentReference implements Serializable { /** * @hideconstructor * @@ -130,7 +132,8 @@ export class DocumentReference implements Serializable { */ constructor( private readonly _firestore: Firestore, - readonly _path: ResourcePath + readonly _path: ResourcePath, + readonly _converter = defaultConverter as FirestoreDataConverter ) {} /** @@ -216,8 +219,12 @@ export class DocumentReference implements Serializable { * console.log(`Found ${results.size} matches in parent collection`); * }): */ - get parent(): CollectionReference { - return new CollectionReference(this._firestore, this._path.parent()!); + get parent(): CollectionReference { + return new CollectionReference( + this._firestore, + this._path.parent()!, + this._converter + ); } /** @@ -237,7 +244,7 @@ export class DocumentReference implements Serializable { * } * }); */ - get(): Promise { + get(): Promise> { return this._firestore.getAll(this).then(([result]) => result); } @@ -282,7 +289,7 @@ export class DocumentReference implements Serializable { * } * }); */ - listCollections(): Promise { + listCollections(): Promise>> { const tag = requestTag(); return this.firestore.initializeIfNeeded(tag).then(() => { const request: api.IListCollectionIdsRequest = { @@ -299,7 +306,7 @@ export class DocumentReference implements Serializable { tag ) .then(collectionIds => { - const collections: CollectionReference[] = []; + const collections: Array> = []; // We can just sort this list using the default comparator since it // will only contain collection ids. @@ -332,7 +339,7 @@ export class DocumentReference implements Serializable { * console.log(`Failed to create document: ${err}`); * }); */ - create(data: DocumentData): Promise { + create(data: T): Promise { const writeBatch = new WriteBatch(this._firestore); return writeBatch .create(this, data) @@ -375,7 +382,7 @@ export class DocumentReference implements Serializable { * [SetOptions]{@link SetOptions}, the provided data can be merged into an * existing document. * - * @param {DocumentData} data A map of the fields and values for the 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. @@ -392,7 +399,7 @@ export class DocumentReference implements Serializable { * console.log(`Document written at ${res.updateTime}`); * }); */ - set(data: DocumentData, options?: SetOptions): Promise { + set(data: T, options?: SetOptions): Promise { const writeBatch = new WriteBatch(this._firestore); return writeBatch .set(this, data, options) @@ -436,8 +443,12 @@ export class DocumentReference implements Serializable { validateMinNumberOfArguments('DocumentReference.update', arguments, 1); const writeBatch = new WriteBatch(this._firestore); - return writeBatch.update - .apply(writeBatch, [this, dataOrField, ...preconditionOrValues]) + return writeBatch + .update( + this as DocumentReference, + dataOrField, + ...preconditionOrValues + ) .commit() .then(([writeResult]) => writeResult); } @@ -469,7 +480,7 @@ export class DocumentReference implements Serializable { * unsubscribe(); */ onSnapshot( - onNext: (snapshot: DocumentSnapshot) => void, + onNext: (snapshot: DocumentSnapshot) => void, onError?: (error: Error) => void ): () => void { validateFunction('onNext', onNext); @@ -486,8 +497,12 @@ export class DocumentReference implements Serializable { } // The document is missing. - const document = new DocumentSnapshotBuilder(); - document.ref = new DocumentReference(this._firestore, this._path); + const ref = new DocumentReference( + this._firestore, + this._path, + this._converter + ); + const document = new DocumentSnapshotBuilder(ref); document.readTime = readTime; onNext(document.build()); }, onError || console.error); @@ -500,12 +515,13 @@ export class DocumentReference implements Serializable { * @return {boolean} true if this `DocumentReference` is equal to the provided * value. */ - isEqual(other: DocumentReference): boolean { + isEqual(other: DocumentReference): boolean { return ( this === other || (other instanceof DocumentReference && this._firestore === other._firestore && - this._path.isEqual(other._path)) + this._path.isEqual(other._path) && + this._converter === other._converter) ); } @@ -517,6 +533,54 @@ export class DocumentReference implements Serializable { toProto(): api.IValue { return {referenceValue: this.formattedName}; } + + /** + * 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. + * + * 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 + * } + * + * @param converter Converts objects to and from Firestore. + * @return A DocumentReference that uses the provided converter. + */ + withConverter(converter: FirestoreDataConverter): DocumentReference { + return new DocumentReference(this.firestore, this._path, converter); + } } /** @@ -641,11 +705,11 @@ class FieldFilter { * * @class QuerySnapshot */ -export class QuerySnapshot { - private _materializedDocs: QueryDocumentSnapshot[] | null = null; - private _materializedChanges: DocumentChange[] | null = null; - private _docs: (() => QueryDocumentSnapshot[]) | null = null; - private _changes: (() => DocumentChange[]) | null = null; +export class QuerySnapshot { + private _materializedDocs: Array> | null = null; + private _materializedChanges: Array> | null = null; + private _docs: (() => Array>) | null = null; + private _changes: (() => Array>) | null = null; /** * @hideconstructor @@ -659,11 +723,11 @@ export class QuerySnapshot { * events for this snapshot. */ constructor( - private readonly _query: Query, + private readonly _query: Query, private readonly _readTime: Timestamp, private readonly _size: number, - docs: () => QueryDocumentSnapshot[], - changes: () => DocumentChange[] + docs: () => Array>, + changes: () => Array> ) { this._docs = docs; this._changes = changes; @@ -688,7 +752,7 @@ export class QuerySnapshot { * console.log(`Returned second batch of results`); * }); */ - get query(): Query { + get query(): Query { return this._query; } @@ -709,7 +773,7 @@ export class QuerySnapshot { * } * }); */ - get docs(): QueryDocumentSnapshot[] { + get docs(): Array> { if (this._materializedDocs) { return this._materializedDocs!; } @@ -791,7 +855,7 @@ export class QuerySnapshot { * } * }); */ - docChanges(): DocumentChange[] { + docChanges(): Array> { if (this._materializedChanges) { return this._materializedChanges!; } @@ -820,7 +884,7 @@ export class QuerySnapshot { * }); */ forEach( - callback: (result: QueryDocumentSnapshot) => void, + callback: (result: QueryDocumentSnapshot) => void, thisArg?: unknown ): void { validateFunction('callback', callback); @@ -838,7 +902,7 @@ export class QuerySnapshot { * @return {boolean} true if this `QuerySnapshot` is equal to the provided * value. */ - isEqual(other: QuerySnapshot): boolean { + isEqual(other: QuerySnapshot): boolean { // Since the read time is different on every query read, we explicitly // ignore all metadata in this comparison. @@ -911,10 +975,11 @@ interface QueryCursor { * These options are immutable. Modified options can be created using `with()`. * @private */ -export class QueryOptions { +export class QueryOptions { constructor( readonly parentPath: ResourcePath, readonly collectionId: string, + readonly converter: FirestoreDataConverter, readonly allDescendants: boolean, readonly fieldFilters: FieldFilter[], readonly fieldOrders: FieldOrder[], @@ -929,10 +994,14 @@ export class QueryOptions { * Returns query options for a collection group query. * @private */ - static forCollectionGroupQuery(collectionId: string): QueryOptions { - return new QueryOptions( + static forCollectionGroupQuery( + collectionId: string, + converter = defaultConverter as FirestoreDataConverter + ): QueryOptions { + return new QueryOptions( /*parentPath=*/ ResourcePath.EMPTY, collectionId, + converter, /*allDescendants=*/ true, /*fieldFilters=*/ [], /*fieldOrders=*/ [] @@ -943,10 +1012,14 @@ export class QueryOptions { * Returns query options for a single-collection query. * @private */ - static forCollectionQuery(collectionRef: ResourcePath): QueryOptions { - return new QueryOptions( + static forCollectionQuery( + collectionRef: ResourcePath, + converter = defaultConverter as FirestoreDataConverter + ): QueryOptions { + return new QueryOptions( collectionRef.parent()!, collectionRef.id!, + converter, /*allDescendants=*/ false, /*fieldFilters=*/ [], /*fieldOrders=*/ [] @@ -957,10 +1030,14 @@ export class QueryOptions { * Returns the union of the current and the provided options. * @private */ - with(settings: Partial): QueryOptions { + with( + settings: Partial, 'converter'>>, + converter = defaultConverter as FirestoreDataConverter + ): QueryOptions { return new QueryOptions( coalesce(settings.parentPath, this.parentPath)!, coalesce(settings.collectionId, this.collectionId)!, + converter, coalesce(settings.allDescendants, this.allDescendants)!, coalesce(settings.fieldFilters, this.fieldFilters)!, coalesce(settings.fieldOrders, this.fieldOrders)!, @@ -972,7 +1049,23 @@ export class QueryOptions { ); } - isEqual(other: QueryOptions) { + withConverter(converter: FirestoreDataConverter): QueryOptions { + return new QueryOptions( + this.parentPath, + this.collectionId, + converter, + this.allDescendants, + this.fieldFilters, + this.fieldOrders, + this.startAt, + this.endAt, + this.limit, + this.offset, + this.projection + ); + } + + isEqual(other: QueryOptions) { if (this === other) { return true; } @@ -981,6 +1074,7 @@ export class QueryOptions { other instanceof QueryOptions && this.parentPath.isEqual(other.parentPath) && this.collectionId === other.collectionId && + this.converter === other.converter && this.allDescendants === other.allDescendants && this.limit === other.limit && this.offset === other.offset && @@ -999,7 +1093,7 @@ export class QueryOptions { * * @class Query */ -export class Query { +export class Query { private readonly _serializer: Serializer; /** @@ -1010,7 +1104,7 @@ export class Query { */ constructor( private readonly _firestore: Firestore, - protected readonly _queryOptions: QueryOptions + protected readonly _queryOptions: QueryOptions ) { this._serializer = new Serializer(_firestore); } @@ -1024,7 +1118,7 @@ export class Query { * @returns 'true' if the input is a single DocumentSnapshot.. */ static _isDocumentSnapshot( - fieldValuesOrDocumentSnapshot: Array + fieldValuesOrDocumentSnapshot: Array | unknown> ): boolean { return ( fieldValuesOrDocumentSnapshot.length === 1 && @@ -1118,7 +1212,7 @@ export class Query { fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown - ): Query { + ): Query { validateFieldPath('fieldPath', fieldPath); opStr = validateQueryOperator('opStr', opStr, value); validateQueryValue('value', value); @@ -1171,7 +1265,7 @@ export class Query { * console.log(`y is ${res.docs[0].get('y')}.`); * }); */ - select(...fieldPaths: Array): Query { + select(...fieldPaths: Array): Query { const fields: api.StructuredQuery.IFieldReference[] = []; if (fieldPaths.length === 0) { @@ -1214,7 +1308,7 @@ export class Query { orderBy( fieldPath: string | FieldPath, directionStr?: OrderByDirection - ): Query { + ): Query { validateFieldPath('fieldPath', fieldPath); directionStr = validateQueryOrder('directionStr', directionStr); @@ -1255,7 +1349,7 @@ export class Query { * }); * }); */ - limit(limit: number): Query { + limit(limit: number): Query { validateInteger('limit', limit); const options = this._queryOptions.with({limit}); @@ -1281,7 +1375,7 @@ export class Query { * }); * }); */ - offset(offset: number): Query { + offset(offset: number): Query { validateInteger('offset', offset); const options = this._queryOptions.with({offset}); @@ -1294,7 +1388,7 @@ export class Query { * @param {*} other The value to compare against. * @return {boolean} true if this `Query` is equal to the provided value. */ - isEqual(other: Query): boolean { + isEqual(other: Query): boolean { if (this === other) { return true; } @@ -1313,7 +1407,7 @@ export class Query { * @returns The implicit ordering semantics. */ private createImplicitOrderBy( - cursorValuesOrDocumentSnapshot: Array + cursorValuesOrDocumentSnapshot: Array | unknown> ): FieldOrder[] { if (!Query._isDocumentSnapshot(cursorValuesOrDocumentSnapshot)) { return this._queryOptions.fieldOrders; @@ -1419,11 +1513,11 @@ export class Query { * query. * @private */ - private validateReference(val: unknown): DocumentReference { + private validateReference(val: unknown): DocumentReference { const basePath = this._queryOptions.allDescendants ? this._queryOptions.parentPath : this._queryOptions.parentPath.append(this._queryOptions.collectionId); - let reference: DocumentReference; + let reference: DocumentReference; if (typeof val === 'string') { const path = basePath.append(val); @@ -1445,7 +1539,11 @@ export class Query { ); } - reference = new DocumentReference(this._firestore, basePath.append(val)); + reference = new DocumentReference( + this._firestore, + basePath.append(val), + this._queryOptions.converter + ); } else if (val instanceof DocumentReference) { reference = val; if (!basePath.isPrefixOf(reference._path)) { @@ -1493,8 +1591,8 @@ export class Query { * }); */ startAt( - ...fieldValuesOrDocumentSnapshot: Array - ): Query { + ...fieldValuesOrDocumentSnapshot: Array | unknown> + ): Query { validateMinNumberOfArguments('Query.startAt', arguments, 1); const fieldOrders = this.createImplicitOrderBy( @@ -1531,8 +1629,8 @@ export class Query { * }); */ startAfter( - ...fieldValuesOrDocumentSnapshot: Array - ): Query { + ...fieldValuesOrDocumentSnapshot: Array | unknown> + ): Query { validateMinNumberOfArguments('Query.startAfter', arguments, 1); const fieldOrders = this.createImplicitOrderBy( @@ -1568,8 +1666,8 @@ export class Query { * }); */ endBefore( - ...fieldValuesOrDocumentSnapshot: Array - ): Query { + ...fieldValuesOrDocumentSnapshot: Array | unknown> + ): Query { validateMinNumberOfArguments('Query.endBefore', arguments, 1); const fieldOrders = this.createImplicitOrderBy( @@ -1605,8 +1703,8 @@ export class Query { * }); */ endAt( - ...fieldValuesOrDocumentSnapshot: Array - ): Query { + ...fieldValuesOrDocumentSnapshot: Array | unknown> + ): Query { validateMinNumberOfArguments('Query.endAt', arguments, 1); const fieldOrders = this.createImplicitOrderBy( @@ -1638,7 +1736,7 @@ export class Query { * }); * }); */ - get(): Promise { + get(): Promise> { return this._get(); } @@ -1648,9 +1746,9 @@ export class Query { * @private * @param {bytes=} transactionId A transaction ID. */ - _get(transactionId?: Uint8Array): Promise { + _get(transactionId?: Uint8Array): Promise> { const self = this; - const docs: QueryDocumentSnapshot[] = []; + const docs: Array> = []; return new Promise((resolve, reject) => { let readTime: Timestamp; @@ -1663,8 +1761,7 @@ export class Query { .on('data', result => { readTime = result.readTime; if (result.document) { - const document = result.document; - docs.push(document); + docs.push(result.document); } }) .on('end', () => { @@ -1675,7 +1772,7 @@ export class Query { docs.length, () => docs, () => { - const changes: DocumentChange[] = []; + const changes: Array> = []; for (let i = 0; i < docs.length; ++i) { changes.push(new DocumentChange('added', docs[i], -1, i)); } @@ -1823,7 +1920,16 @@ export class Query { proto.document, proto.readTime ); - this.push({document, readTime}); + const finalDoc = new DocumentSnapshotBuilder( + document.ref.withConverter(self._queryOptions.converter) + ); + // Recreate the QueryDocumentSnapshot with the DocumentReference + // containing the original converter. + finalDoc.fieldsProto = document._fieldsProto; + finalDoc.readTime = document.readTime; + finalDoc.createTime = document.createTime; + finalDoc.updateTime = document.updateTime; + this.push({document: finalDoc.build(), readTime}); } else { this.push({readTime}); } @@ -1879,13 +1985,17 @@ export class Query { * unsubscribe(); */ onSnapshot( - onNext: (snapshot: QuerySnapshot) => void, + onNext: (snapshot: QuerySnapshot) => void, onError?: (error: Error) => void ): () => void { validateFunction('onNext', onNext); validateFunction('onError', onError, {optional: true}); - const watch = new QueryWatch(this.firestore, this); + const watch = new QueryWatch( + this.firestore, + this, + this._queryOptions.converter + ); return watch.onSnapshot((readTime, size, docs, changes) => { onNext(new QuerySnapshot(this, readTime, size, docs, changes)); @@ -1899,8 +2009,8 @@ export class Query { * @private */ comparator(): ( - s1: QueryDocumentSnapshot, - s2: QueryDocumentSnapshot + s1: QueryDocumentSnapshot, + s2: QueryDocumentSnapshot ) => number { return (doc1, doc2) => { // Add implicit sorting by name, using the last specified direction. @@ -1940,6 +2050,56 @@ export class Query { return 0; }; } + + /** + * Applies a custom data converter to this Query, allowing you to use your + * own custom model objects with Firestore. When you call get() on the + * returned Query, the provided converter will convert between Firestore + * data and your custom type U. + * + * 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 + * } + * + * @param converter Converts objects to and from Firestore. + * @return A Query that uses the provided converter. + */ + withConverter(converter: FirestoreDataConverter): Query { + return new Query( + this.firestore, + this._queryOptions.withConverter(converter) + ); + } } /** @@ -1950,15 +2110,19 @@ export class Query { * @class * @extends Query */ -export class CollectionReference extends Query { +export class CollectionReference extends Query { /** * @hideconstructor * * @param firestore The Firestore Database client. * @param path The Path of this collection. */ - constructor(firestore: Firestore, path: ResourcePath) { - super(firestore, QueryOptions.forCollectionQuery(path)); + constructor( + firestore: Firestore, + path: ResourcePath, + converter?: FirestoreDataConverter + ) { + super(firestore, QueryOptions.forCollectionQuery(path, converter)); } /** @@ -1999,7 +2163,7 @@ export class CollectionReference extends Query { * let documentRef = collectionRef.parent; * console.log(`Parent name: ${documentRef.path}`); */ - get parent(): DocumentReference { + get parent(): DocumentReference { return new DocumentReference(this.firestore, this._queryOptions.parentPath); } @@ -2046,7 +2210,7 @@ export class CollectionReference extends Query { * } * }); */ - listDocuments(): Promise { + listDocuments(): Promise>> { const tag = requestTag(); return this.firestore.initializeIfNeeded(tag).then(() => { const parentPath = this._queryOptions.parentPath.toQualifiedResourcePath( @@ -2082,8 +2246,8 @@ export class CollectionReference extends Query { }); } - doc(): DocumentReference; - doc(documentPath: string): DocumentReference; + doc(): DocumentReference; + doc(documentPath: string): DocumentReference; /** * Gets a [DocumentReference]{@link DocumentReference} instance that * refers to the document at the specified path. If no path is specified, an @@ -2101,7 +2265,7 @@ export class CollectionReference extends Query { * console.log(`Reference with name: ${documentRefWithName.path}`); * console.log(`Reference with auto-id: ${documentRefWithAutoId.path}`); */ - doc(documentPath?: string): DocumentReference { + doc(documentPath?: string): DocumentReference { if (arguments.length === 0) { documentPath = autoId(); } else { @@ -2115,7 +2279,11 @@ export class CollectionReference extends Query { ); } - return new DocumentReference(this.firestore, path); + return new DocumentReference( + this.firestore, + path, + this._queryOptions.converter + ); } /** @@ -2134,7 +2302,7 @@ export class CollectionReference extends Query { * console.log(`Added document with name: ${documentReference.id}`); * }); */ - add(data: DocumentData): Promise { + add(data: T): Promise> { validateDocumentData('data', data, /*allowDeletes=*/ false); const documentRef = this.doc(); @@ -2148,12 +2316,65 @@ export class CollectionReference extends Query { * @return {boolean} true if this `CollectionReference` is equal to the * provided value. */ - isEqual(other: CollectionReference): boolean { + isEqual(other: CollectionReference): boolean { return ( this === other || (other instanceof CollectionReference && super.isEqual(other)) ); } + + /** + * 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 + * convert between Firestore data and your custom type U. + * + * 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 + * } + * + * @param converter Converts objects to and from Firestore. + * @return A CollectionReference that uses the provided converter. + */ + withConverter( + converter: FirestoreDataConverter + ): CollectionReference { + return new CollectionReference( + this.firestore, + this.resourcePath, + converter + ); + } } /** diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index ebefaeb86..2030ef123 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -92,7 +92,7 @@ export class Transaction { * @param {Query} query A query to execute. * @return {Promise} A QuerySnapshot for the retrieved data. */ - get(query: Query): Promise; + get(query: Query): Promise>; /** * Reads the document referenced by the provided `DocumentReference.` @@ -101,7 +101,7 @@ export class Transaction { * @param {DocumentReference} documentRef A reference to the document to be read. * @return {Promise} A DocumentSnapshot for the read data. */ - get(documentRef: DocumentReference): Promise; + get(documentRef: DocumentReference): Promise>; /** * Retrieve a document or a query result from the database. Holds a @@ -124,9 +124,9 @@ export class Transaction { * }); * }); */ - get( - refOrQuery: DocumentReference | Query - ): Promise { + get( + refOrQuery: DocumentReference | Query + ): Promise | QuerySnapshot> { if (!this._writeBatch.isEmpty) { throw new Error(READ_AFTER_WRITE_ERROR_MSG); } @@ -179,9 +179,9 @@ export class Transaction { * }); * }); */ - getAll( - ...documentRefsOrReadOptions: Array - ): Promise { + getAll( + ...documentRefsOrReadOptions: Array | ReadOptions> + ): Promise>> { if (!this._writeBatch.isEmpty) { throw new Error(READ_AFTER_WRITE_ERROR_MSG); } @@ -221,7 +221,7 @@ export class Transaction { * }); * }); */ - create(documentRef: DocumentReference, data: DocumentData): Transaction { + create(documentRef: DocumentReference, data: T): Transaction { this._writeBatch.create(documentRef, data); return this; } @@ -235,7 +235,7 @@ export class Transaction { * * @param {DocumentReference} documentRef A reference to the document to be * set. - * @param {DocumentData} data The object to serialize as the document. + * @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 @@ -253,9 +253,9 @@ export class Transaction { * return Promise.resolve(); * }); */ - set( - documentRef: DocumentReference, - data: DocumentData, + set( + documentRef: DocumentReference, + data: T, options?: SetOptions ): Transaction { this._writeBatch.set(documentRef, data, options); @@ -300,18 +300,14 @@ export class Transaction { * }); * }); */ - update( - documentRef: DocumentReference, + update( + documentRef: DocumentReference, dataOrField: UpdateData | string | FieldPath, ...preconditionOrValues: Array ): Transaction { validateMinNumberOfArguments('Transaction.update', arguments, 2); - this._writeBatch.update.apply(this._writeBatch, [ - documentRef, - dataOrField, - ...preconditionOrValues, - ]); + this._writeBatch.update(documentRef, dataOrField, ...preconditionOrValues); return this; } @@ -336,8 +332,8 @@ export class Transaction { * return Promise.resolve(); * }); */ - delete( - documentRef: DocumentReference, + delete( + documentRef: DocumentReference, precondition?: PublicPrecondition ): this { this._writeBatch.delete(documentRef, precondition); @@ -419,10 +415,10 @@ export class Transaction { * @param documentRefsOrReadOptions An array of document references followed by * an optional ReadOptions object. */ -export function parseGetAllArguments( - documentRefsOrReadOptions: Array -): {documents: DocumentReference[]; fieldMask: FieldPath[] | null} { - let documents: DocumentReference[]; +export function parseGetAllArguments( + documentRefsOrReadOptions: Array | ReadOptions> +): {documents: Array>; fieldMask: FieldPath[] | null} { + let documents: Array>; let readOptions: ReadOptions | undefined = undefined; if (Array.isArray(documentRefsOrReadOptions[0])) { @@ -439,9 +435,9 @@ export function parseGetAllArguments( ) ) { readOptions = documentRefsOrReadOptions.pop() as ReadOptions; - documents = documentRefsOrReadOptions as DocumentReference[]; + documents = documentRefsOrReadOptions as Array>; } else { - documents = documentRefsOrReadOptions as DocumentReference[]; + documents = documentRefsOrReadOptions as Array>; } for (let i = 0; i < documents.length; ++i) { diff --git a/dev/src/types.ts b/dev/src/types.ts index a82b68349..851b11f54 100644 --- a/dev/src/types.ts +++ b/dev/src/types.ts @@ -92,6 +92,78 @@ export type UnaryMethod = ( // tslint:disable-next-line:no-any export type RBTree = any; +/** + * 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 + * ```typescript + * 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 { + /** + * 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 const defaultConverter: FirestoreDataConverter = { + toFirestore( + modelObject: FirebaseFirestore.DocumentData + ): FirebaseFirestore.DocumentData { + return modelObject; + }, + fromFirestore( + data: FirebaseFirestore.DocumentData + ): FirebaseFirestore.DocumentData { + return data; + }, +}; + /** * Settings used to directly configure a `Firestore` instance. */ @@ -141,7 +213,8 @@ export interface Settings { * mapped to values. */ export interface DocumentData { - [field: string]: unknown; + // tslint:disable-next-line:no-any + [field: string]: any; } /** diff --git a/dev/src/watch.ts b/dev/src/watch.ts index 4a6ef2a16..21a97d0eb 100644 --- a/dev/src/watch.ts +++ b/dev/src/watch.ts @@ -28,7 +28,12 @@ import {DocumentReference, Firestore, Query} from './index'; import {logger} from './logger'; import {QualifiedResourcePath} from './path'; import {Timestamp} from './timestamp'; -import {RBTree} from './types'; +import { + defaultConverter, + DocumentData, + FirestoreDataConverter, + RBTree, +} from './types'; import {requestTag} from './util'; import api = google.firestore.v1; @@ -43,7 +48,8 @@ const WATCH_TARGET_ID = 0x1; /*! * Sentinel value for a document remove. */ -const REMOVED = {} as DocumentSnapshotBuilder; +// tslint:disable-next-line:no-any +const REMOVED = {} as DocumentSnapshotBuilder; /*! * The change type for document change events. @@ -59,9 +65,9 @@ const ChangeType: {[k: string]: DocumentChangeType} = { * The comparator used for document watches (which should always get called with * the same document). */ -const DOCUMENT_WATCH_COMPARATOR = ( - doc1: QueryDocumentSnapshot, - doc2: QueryDocumentSnapshot +const DOCUMENT_WATCH_COMPARATOR = ( + doc1: QueryDocumentSnapshot, + doc2: QueryDocumentSnapshot ) => { assert(doc1 === doc2, 'Document watches only support one document.'); return 0; @@ -96,15 +102,15 @@ const EMPTY_FUNCTION = () => {}; * changed documents since the last snapshot delivered for this watch. */ -type DocumentComparator = ( - l: QueryDocumentSnapshot, - r: QueryDocumentSnapshot +type DocumentComparator = ( + l: QueryDocumentSnapshot, + r: QueryDocumentSnapshot ) => number; -interface DocumentChangeSet { +interface DocumentChangeSet { deletes: string[]; - adds: QueryDocumentSnapshot[]; - updates: QueryDocumentSnapshot[]; + adds: Array>; + updates: Array>; } /** @@ -114,7 +120,7 @@ interface DocumentChangeSet { * @class * @private */ -abstract class Watch { +abstract class Watch { protected readonly firestore: Firestore; private readonly backoff: ExponentialBackoff; private readonly requestTag: string; @@ -142,14 +148,14 @@ abstract class Watch { * A map of document names to QueryDocumentSnapshots for the last sent snapshot. * @private */ - private docMap = new Map(); + private docMap = new Map>(); /** * The accumulated map of document changes (keyed by document name) for the * current snapshot. * @private */ - private changeMap = new Map(); + private changeMap = new Map>(); /** * The current state of the query results. * @@ -175,8 +181,8 @@ abstract class Watch { private onNext: ( readTime: Timestamp, size: number, - docs: () => QueryDocumentSnapshot[], - changes: () => DocumentChange[] + docs: () => Array>, + changes: () => Array> ) => void; private onError: (error: Error) => void; @@ -187,7 +193,10 @@ abstract class Watch { * * @param firestore The Firestore Database client. */ - constructor(firestore: Firestore) { + constructor( + firestore: Firestore, + readonly _converter = defaultConverter as FirestoreDataConverter + ) { this.firestore = firestore; this.backoff = new ExponentialBackoff(); this.requestTag = requestTag(); @@ -202,7 +211,7 @@ abstract class Watch { * Returns a comparator for QueryDocumentSnapshots that is used to order the * document snapshots returned by this watch. */ - protected abstract getComparator(): DocumentComparator; + protected abstract getComparator(): DocumentComparator; /** * Starts a watch and attaches a listener for document change events. @@ -220,8 +229,8 @@ abstract class Watch { onNext: ( readTime: Timestamp, size: number, - docs: () => QueryDocumentSnapshot[], - changes: () => DocumentChange[] + docs: () => Array>, + changes: () => Array> ) => void, onError: (error: Error) => void ): () => void { @@ -269,10 +278,10 @@ abstract class Watch { * Splits up document changes into removals, additions, and updates. * @private */ - private extractCurrentChanges(readTime: Timestamp): DocumentChangeSet { + private extractCurrentChanges(readTime: Timestamp): DocumentChangeSet { const deletes: string[] = []; - const adds: QueryDocumentSnapshot[] = []; - const updates: QueryDocumentSnapshot[] = []; + const adds: Array> = []; + const updates: Array> = []; this.changeMap.forEach((value, name) => { if (value === REMOVED) { @@ -281,10 +290,10 @@ abstract class Watch { } } else if (this.docMap.has(name)) { value.readTime = readTime; - updates.push(value.build() as QueryDocumentSnapshot); + updates.push(value.build() as QueryDocumentSnapshot); } else { value.readTime = readTime; - adds.push(value.build() as QueryDocumentSnapshot); + adds.push(value.build() as QueryDocumentSnapshot); } }); @@ -505,8 +514,10 @@ abstract class Watch { if (changed) { logger('Watch.onData', this.requestTag, 'Received document change'); - const snapshot = new DocumentSnapshotBuilder(); - snapshot.ref = this.firestore.doc(relativeName); + const ref = this.firestore.doc(relativeName); + const snapshot = new DocumentSnapshotBuilder( + ref.withConverter(this._converter) + ); snapshot.fieldsProto = document.fields || {}; snapshot.createTime = Timestamp.fromProto(document.createTime!); snapshot.updateTime = Timestamp.fromProto(document.updateTime!); @@ -597,7 +608,7 @@ abstract class Watch { * Returns the corresponding DocumentChange event. * @private */ - private deleteDoc(name: string): DocumentChange { + private deleteDoc(name: string): DocumentChange { assert(this.docMap.has(name), 'Document to delete does not exist'); const oldDocument = this.docMap.get(name)!; const existing = this.docTree.find(oldDocument); @@ -612,7 +623,7 @@ abstract class Watch { * the corresponding DocumentChange event. * @private */ - private addDoc(newDocument: QueryDocumentSnapshot): DocumentChange { + private addDoc(newDocument: QueryDocumentSnapshot): DocumentChange { const name = newDocument.ref.path; assert(!this.docMap.has(name), 'Document to add already exists'); this.docTree = this.docTree.insert(newDocument, null); @@ -626,7 +637,9 @@ abstract class Watch { * Returns the DocumentChange event for successful modifications. * @private */ - private modifyDoc(newDocument: QueryDocumentSnapshot): DocumentChange | null { + private modifyDoc( + newDocument: QueryDocumentSnapshot + ): DocumentChange | null { const name = newDocument.ref.path; assert(this.docMap.has(name), 'Document to modify does not exist'); const oldDocument = this.docMap.get(name)!; @@ -649,9 +662,9 @@ abstract class Watch { * state. * @private */ - private computeSnapshot(readTime: Timestamp): DocumentChange[] { + private computeSnapshot(readTime: Timestamp): Array> { const changeSet = this.extractCurrentChanges(readTime); - const appliedChanges: DocumentChange[] = []; + const appliedChanges: Array> = []; // Process the sorted changes in the order that is expected by our clients // (removals, additions, and then modifications). We also need to sort the @@ -744,12 +757,15 @@ abstract class Watch { * * @private */ -export class DocumentWatch extends Watch { - constructor(firestore: Firestore, private readonly ref: DocumentReference) { - super(firestore); +export class DocumentWatch extends Watch { + constructor( + firestore: Firestore, + private readonly ref: DocumentReference + ) { + super(firestore, ref._converter); } - getComparator(): DocumentComparator { + getComparator(): DocumentComparator { return DOCUMENT_WATCH_COMPARATOR; } @@ -770,15 +786,19 @@ export class DocumentWatch extends Watch { * * @private */ -export class QueryWatch extends Watch { - private comparator: DocumentComparator; - - constructor(firestore: Firestore, private readonly query: Query) { - super(firestore); +export class QueryWatch extends Watch { + private comparator: DocumentComparator; + + constructor( + firestore: Firestore, + private readonly query: Query, + converter?: FirestoreDataConverter + ) { + super(firestore, converter); this.comparator = query.comparator(); } - getComparator(): DocumentComparator { + getComparator(): DocumentComparator { return this.query.comparator(); } diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 1f3bf5103..6b2e161ee 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -166,7 +166,7 @@ export class WriteBatch { * * @param {DocumentReference} documentRef A reference to the document to be * created. - * @param {DocumentData} data The object to serialize as the document. + * @param {T} data The object to serialize as the document. * @returns {WriteBatch} This WriteBatch instance. Used for chaining * method calls. * @@ -180,19 +180,20 @@ export class WriteBatch { * console.log('Successfully executed batch.'); * }); */ - create(documentRef: DocumentReference, data: DocumentData): WriteBatch { + create(documentRef: DocumentReference, data: T): WriteBatch { validateDocumentReference('documentRef', documentRef); validateDocumentData('data', data, /* allowDeletes= */ false); this.verifyNotCommitted(); - const transform = DocumentTransform.fromObject(documentRef, data); + const firestoreData = documentRef._converter.toFirestore(data); + const transform = DocumentTransform.fromObject(documentRef, firestoreData); transform.validate(); const precondition = new Precondition({exists: false}); const op = () => { - const document = DocumentSnapshot.fromObject(documentRef, data); + const document = DocumentSnapshot.fromObject(documentRef, firestoreData); const write = !document.isEmpty || transform.isEmpty ? document.toProto() : null; @@ -231,8 +232,8 @@ export class WriteBatch { * console.log('Successfully executed batch.'); * }); */ - delete( - documentRef: DocumentReference, + delete( + documentRef: DocumentReference, precondition?: PublicPrecondition ): WriteBatch { validateDocumentReference('documentRef', documentRef); @@ -265,7 +266,7 @@ export class WriteBatch { * * @param {DocumentReference} documentRef A reference to the document to be * set. - * @param {DocumentData} data The object to serialize as the document. + * @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 @@ -286,19 +287,19 @@ export class WriteBatch { * console.log('Successfully executed batch.'); * }); */ - set( - documentRef: DocumentReference, - data: DocumentData, + set( + documentRef: DocumentReference, + data: T, options?: SetOptions ): WriteBatch { validateSetOptions('options', options, {optional: true}); const mergeLeaves = options && options.merge === true; const mergePaths = options && options.mergeFields; - validateDocumentReference('documentRef', documentRef); + let firestoreData = documentRef._converter.toFirestore(data); validateDocumentData( 'data', - data, + firestoreData, /* allowDeletes= */ !!(mergePaths || mergeLeaves) ); @@ -308,19 +309,19 @@ export class WriteBatch { if (mergePaths) { documentMask = DocumentMask.fromFieldMask(options!.mergeFields!); - data = documentMask.applyTo(data); + firestoreData = documentMask.applyTo(firestoreData); } - const transform = DocumentTransform.fromObject(documentRef, data); + const transform = DocumentTransform.fromObject(documentRef, firestoreData); transform.validate(); const op = () => { - const document = DocumentSnapshot.fromObject(documentRef, data); + const document = DocumentSnapshot.fromObject(documentRef, firestoreData); if (mergePaths) { documentMask!.removeFields(transform.fields); } else { - documentMask = DocumentMask.fromObject(data); + documentMask = DocumentMask.fromObject(firestoreData); } const hasDocumentData = !document.isEmpty || !documentMask!.isEmpty; @@ -381,8 +382,8 @@ export class WriteBatch { * console.log('Successfully executed batch.'); * }); */ - update( - documentRef: DocumentReference, + update( + documentRef: DocumentReference, dataOrField: UpdateData | string | FieldPath, ...preconditionOrValues: Array< {lastUpdateTime?: Timestamp} | unknown | string | FieldPath diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 7491e4891..81ecd158a 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -17,6 +17,7 @@ import {expect} from 'chai'; import { CollectionReference, DocumentData, + DocumentReference, DocumentSnapshot, FieldPath, FieldValue, @@ -30,7 +31,7 @@ import { WriteResult, } from '../src'; import {autoId, Deferred} from '../src/util'; -import {verifyInstance} from '../test/util/helpers'; +import {Post, postConverter, verifyInstance} from '../test/util/helpers'; const version = require('../../package.json').version; @@ -128,6 +129,17 @@ describe('Firestore class', () => { }); }); + it('getAll() supports generics', async () => { + const ref1 = randomCol.doc('doc1').withConverter(postConverter); + const ref2 = randomCol.doc('doc2').withConverter(postConverter); + await ref1.set(new Post('post1', 'author1')); + await ref2.set(new Post('post2', 'author2')); + + const docs = await firestore.getAll(ref1, ref2); + expect(docs[0].data()!.toString()).to.deep.equal('post1, by author1'); + expect(docs[1].data()!.toString()).to.deep.equal('post2, by author2'); + }); + it('cannot make calls after the client has been terminated', () => { const ref1 = randomCol.doc('doc1'); return firestore @@ -208,6 +220,18 @@ describe('CollectionReference class', () => { expect(existingDocs.map(doc => doc.id)).to.have.members(['a', 'c']); expect(missingDocs.map(doc => doc.id)).to.have.members(['b']); }); + + it('supports withConverter()', async () => { + const ref = firestore + .collection('col') + .withConverter(postConverter) + .doc('doc'); + await ref.set(new Post('post', 'author')); + const postData = await ref.get(); + const post = postData.data(); + expect(post).to.not.be.undefined; + expect(post!.toString()).to.equal('post, by author'); + }); }); describe('DocumentReference class', () => { @@ -967,6 +991,41 @@ describe('DocumentReference class', () => { await Promise.all(documentResults.map(d => d.promise)); unsubscribeCallbacks.forEach(c => c()); }); + + it('handles query snapshots with converters', async () => { + const setupDeferred = new Deferred(); + const resultsDeferred = new Deferred>(); + const ref = randomCol.doc('doc').withConverter(postConverter); + const unsubscribe = randomCol + .where('title', '==', 'post') + .withConverter(postConverter) + .onSnapshot(snapshot => { + if (snapshot.size === 0) { + setupDeferred.resolve(); + } + if (snapshot.size === 1) { + resultsDeferred.resolve(snapshot); + } + }); + + await setupDeferred.promise; + await ref.set(new Post('post', 'author')); + const snapshot = await resultsDeferred.promise; + expect(snapshot.docs[0].data().toString()).to.equal('post, by author'); + unsubscribe(); + }); + }); + + it('supports withConverter()', async () => { + const ref = firestore + .collection('col') + .doc('doc') + .withConverter(postConverter); + await ref.set(new Post('post', 'author')); + const postData = await ref.get(); + const post = postData.data(); + expect(post).to.not.be.undefined; + expect(post!.toString()).to.equal('post, by author'); }); }); @@ -1840,6 +1899,31 @@ describe('Transaction class', () => { }); }); + it('getAll() supports withConverter()', async () => { + const ref1 = randomCol.doc('doc1').withConverter(postConverter); + const ref2 = randomCol.doc('doc2').withConverter(postConverter); + await ref1.set(new Post('post1', 'author1')); + await ref2.set(new Post('post2', 'author2')); + + const docs = await firestore.runTransaction(updateFunction => { + return updateFunction.getAll(ref1, ref2); + }); + + expect(docs[0].data()!.toString()).to.equal('post1, by author1'); + expect(docs[1].data()!.toString()).to.equal('post2, by author2'); + }); + + it('set() and get() support withConverter()', async () => { + const ref = randomCol.doc('doc1').withConverter(postConverter); + await ref.set(new Post('post', 'author')); + await firestore.runTransaction(async txn => { + await txn.get(ref); + await txn.set(ref, new Post('new post', 'author')); + }); + const doc = await ref.get(); + expect(doc.data()!.toString()).to.equal('new post, by author'); + }); + it('has get() with query', () => { const ref = randomCol.doc('doc'); const query = randomCol.where('foo', '==', 'bar'); diff --git a/dev/test/collection.ts b/dev/test/collection.ts index 6bf8b00b2..7f6a65d44 100644 --- a/dev/test/collection.ts +++ b/dev/test/collection.ts @@ -13,6 +13,7 @@ // limitations under the License. import {expect} from 'chai'; +import * as through2 from 'through2'; import {DocumentReference, Firestore, setLogFunction} from '../src'; import { @@ -21,8 +22,13 @@ import { DATABASE_ROOT, document, InvalidApiUsage, + Post, + postConverter, + requestEquals, response, + set, verifyInstance, + writeResult, } from './util/helpers'; // Change the argument to 'console.log' to enable debug output. @@ -169,4 +175,50 @@ describe('Collection interface', () => { expect(coll1.isEqual(coll1Equals)).to.be.ok; expect(coll1.isEqual(coll2)).to.not.be.ok; }); + + it('for CollectionReference.withConverter().doc()', async () => { + const doc = document('documentId', 'author', 'author', 'title', 'post'); + const overrides: ApiOverride = { + commit: request => { + const expectedRequest = set({ + document: doc, + }); + requestEquals(request, expectedRequest); + + return response(writeResult(1)); + }, + batchGetDocuments: () => { + const stream = through2.obj(); + setImmediate(() => { + stream.push({found: doc, readTime: {seconds: 5, nanos: 6}}); + stream.push(null); + }); + + return stream; + }, + }; + + return createInstance(overrides).then(async firestore => { + const docRef = firestore + .collection('collectionId') + .withConverter(postConverter) + .doc('documentId'); + await docRef.set(new Post('post', 'author')); + const postData = await docRef.get(); + const post = postData.data(); + expect(post).to.not.be.undefined; + expect(post!.toString()).to.equal('post, by author'); + }); + }); + + it('drops the converter when calling CollectionReference.parent()', () => { + return createInstance().then(async firestore => { + const postsCollection = firestore + .collection('users/user1/posts') + .withConverter(postConverter); + + const usersCollection = postsCollection.parent; + expect(usersCollection!.isEqual(firestore.doc('users/user1'))).to.be.true; + }); + }); }); diff --git a/dev/test/document.ts b/dev/test/document.ts index 8d9a8594b..19a655815 100644 --- a/dev/test/document.ts +++ b/dev/test/document.ts @@ -14,9 +14,11 @@ import {expect} from 'chai'; import {GoogleError, Status} from 'google-gax'; +import * as through2 from 'through2'; import { DocumentReference, + DocumentSnapshot, FieldPath, FieldValue, Firestore, @@ -32,6 +34,8 @@ import { found, InvalidApiUsage, missing, + Post, + postConverter, remove, requestEquals, response, @@ -2035,3 +2039,51 @@ describe('listCollections() method', () => { }); }); }); + +describe('withConverter() support', () => { + let firestore: Firestore; + + beforeEach(() => { + return createInstance().then(firestoreInstance => { + firestore = firestoreInstance; + }); + }); + + afterEach(() => verifyInstance(firestore)); + + it('for DocumentReference.get()', async () => { + const doc = document('documentId', 'author', 'author', 'title', 'post'); + const overrides: ApiOverride = { + commit: request => { + const expectedRequest = set({ + document: doc, + }); + requestEquals(request, expectedRequest); + + return response(writeResult(1)); + }, + batchGetDocuments: () => { + const stream = through2.obj(); + setImmediate(() => { + stream.push({found: doc, readTime: {seconds: 5, nanos: 6}}); + stream.push(null); + }); + + return stream; + }, + }; + + return createInstance(overrides).then(async firestore => { + const docRef = firestore + .collection('collectionId') + .doc('documentId') + .withConverter(postConverter); + + await docRef.set(new Post('post', 'author')); + const postData = await docRef.get(); + const post = postData.data(); + expect(post).to.not.be.undefined; + expect(post!.toString()).to.equal('post, by author'); + }); + }); +}); diff --git a/dev/test/query.ts b/dev/test/query.ts index f2c546c78..38f4b552b 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -26,8 +26,14 @@ import { createInstance, document, InvalidApiUsage, + Post, + postConverter, + requestEquals, + response, + set, stream, verifyInstance, + writeResult, } from './util/helpers'; import api = google.firestore.v1; @@ -43,11 +49,11 @@ function snapshot( data: DocumentData ): Promise { return createInstance().then(firestore => { - const snapshot = new DocumentSnapshotBuilder(); const path = QualifiedResourcePath.fromSlashSeparatedString( `${DATABASE_ROOT}/documents/${relativePath}` ); - snapshot.ref = new DocumentReference(firestore, path); + const ref = new DocumentReference(firestore, path); + const snapshot = new DocumentSnapshotBuilder(ref); snapshot.fieldsProto = firestore['_serializer']!.encodeFields(data); snapshot.readTime = Timestamp.fromMillis(0); snapshot.createTime = Timestamp.fromMillis(0); @@ -621,6 +627,37 @@ describe('query interface', () => { }); }); }); + + it('for Query.withConverter()', async () => { + const doc = document('documentId', 'author', 'author', 'title', 'post'); + const overrides: ApiOverride = { + commit: request => { + const expectedRequest = set({ + document: doc, + }); + requestEquals(request, expectedRequest); + return response(writeResult(1)); + }, + runQuery: request => { + queryEquals(request, fieldFilters('title', 'EQUAL', 'post')); + return stream({document: doc, readTime: {seconds: 5, nanos: 6}}); + }, + }; + + return createInstance(overrides).then(async firestore => { + await firestore + .collection('collectionId') + .doc('documentId') + .set({title: 'post', author: 'author'}); + const posts = await firestore + .collection('collectionId') + .where('title', '==', 'post') + .withConverter(postConverter) + .get(); + expect(posts.size).to.equal(1); + expect(posts.docs[0].data().toString()).to.equal('post, by author'); + }); + }); }); describe('where() interface', () => { diff --git a/dev/test/typescript.ts b/dev/test/typescript.ts index 80993ddf2..33c59db98 100644 --- a/dev/test/typescript.ts +++ b/dev/test/typescript.ts @@ -31,6 +31,7 @@ import DocumentData = FirebaseFirestore.DocumentData; import GeoPoint = FirebaseFirestore.GeoPoint; import Precondition = FirebaseFirestore.Precondition; import SetOptions = FirebaseFirestore.SetOptions; +import FirestoreDataConverter = FirebaseFirestore.FirestoreDataConverter; import Timestamp = FirebaseFirestore.Timestamp; import Settings = FirebaseFirestore.Settings; @@ -52,6 +53,15 @@ xdescribe('firestore.d.ts', () => { const updateData: UpdateData = {}; const documentData: DocumentData = {}; + const defaultConverter: FirestoreDataConverter = { + toFirestore(modelObject: DocumentData): DocumentData { + return modelObject; + }, + fromFirestore(data: DocumentData): DocumentData { + return data; + }, + }; + FirebaseFirestore.setLogFunction(console.log); it('has typings for Firestore', () => { @@ -153,6 +163,7 @@ xdescribe('firestore.d.ts', () => { const subcollection: CollectionReference = docRef.collection('coll'); docRef.listCollections().then((collections: CollectionReference[]) => {}); docRef.get().then((snapshot: DocumentSnapshot) => {}); + docRef.withConverter(defaultConverter); docRef .create(documentData) .then((writeResult: FirebaseFirestore.WriteResult) => {}); @@ -260,6 +271,7 @@ xdescribe('firestore.d.ts', () => { query = query.endBefore(snapshot); query = query.endBefore('foo'); query = query.endBefore('foo', 'bar'); + query = query.withConverter(defaultConverter); query.get().then((results: QuerySnapshot) => {}); query.stream().on('data', () => {}); let unsubscribe: () => void = query.onSnapshot( @@ -305,6 +317,7 @@ xdescribe('firestore.d.ts', () => { const docRef1: DocumentReference = collRef.doc(); const docRef2: DocumentReference = collRef.doc('doc'); collRef.add(documentData).then((docRef: DocumentReference) => {}); + collRef.withConverter(defaultConverter); const list: Promise = collRef.listDocuments(); const equals: boolean = collRef.isEqual(collRef); }); diff --git a/dev/test/util/helpers.ts b/dev/test/util/helpers.ts index 614e30db2..655b73d87 100644 --- a/dev/test/util/helpers.ts +++ b/dev/test/util/helpers.ts @@ -21,7 +21,7 @@ import * as through2 from 'through2'; import * as proto from '../../protos/firestore_v1_proto_api'; import {Firestore} from '../../src'; import {ClientPool} from '../../src/pool'; -import {GapicClient} from '../../src/types'; +import {DocumentData, GapicClient} from '../../src/types'; import api = proto.google.firestore.v1; @@ -334,3 +334,21 @@ export function stream(...elements: Array): Duplex { export function response(result: T): Promise<[T, unknown, unknown]> { return Promise.resolve([result, undefined, undefined]); } + +/** Sample user object class used in tests. */ +export class Post { + constructor(readonly title: string, readonly author: string) {} + toString(): string { + return this.title + ', by ' + this.author; + } +} + +/** Converts Post objects to and from Firestore in tests. */ +export const postConverter = { + toFirestore(post: Post): DocumentData { + return {title: post.title, author: post.author}; + }, + fromFirestore(data: DocumentData): Post { + return new Post(data.title, data.author); + }, +}; diff --git a/dev/test/watch.ts b/dev/test/watch.ts index efdd3f6c9..bf82d2713 100644 --- a/dev/test/watch.ts +++ b/dev/test/watch.ts @@ -141,8 +141,7 @@ function snapshot( ref: DocumentReference, data: DocumentData ): QueryDocumentSnapshot { - const snapshot = new DocumentSnapshotBuilder(); - snapshot.ref = ref; + const snapshot = new DocumentSnapshotBuilder(ref); snapshot.fieldsProto = ref.firestore._serializer!.encodeFields(data); snapshot.readTime = new Timestamp(0, 0); snapshot.createTime = new Timestamp(0, 0); diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 038c90018..74eadbea9 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -40,7 +40,62 @@ declare namespace FirebaseFirestore { * @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; + + /** + * 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 + * ```typescript + * 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 { + /** + * 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; + } /** * Settings used to directly configure a `Firestore` instance. @@ -126,7 +181,7 @@ declare namespace FirebaseFirestore { * @param collectionPath A slash-separated path to a collection. * @return The `CollectionReference` instance. */ - collection(collectionPath: string): CollectionReference; + collection(collectionPath: string): CollectionReference; /** * Gets a `DocumentReference` instance that refers to the document at the @@ -135,7 +190,7 @@ declare namespace FirebaseFirestore { * @param documentPath A slash-separated path to a document. * @return The `DocumentReference` instance. */ - doc(documentPath: string): DocumentReference; + doc(documentPath: string): DocumentReference; /** * Creates and returns a new Query that includes all documents in the @@ -147,7 +202,7 @@ declare namespace FirebaseFirestore { * will be included. Cannot contain a slash. * @return The created Query. */ - collectionGroup(collectionId: string): Query; + collectionGroup(collectionId: string): Query; /** * Retrieves multiple documents from Firestore. @@ -162,8 +217,8 @@ declare namespace FirebaseFirestore { * @return A Promise that resolves with an array of resulting document * snapshots. */ - getAll(...documentRefsOrReadOptions: Array): - Promise; + getAll(...documentRefsOrReadOptions: Array | ReadOptions>): + Promise>>; /** * Terminates the Firestore client and closes all open streams. @@ -178,7 +233,7 @@ declare namespace FirebaseFirestore { * * @returns A Promise that resolves with an array of CollectionReferences. */ - listCollections() : Promise; + listCollections() : Promise>>; /** * Executes the given updateFunction and commits the changes applied within @@ -256,7 +311,7 @@ declare namespace FirebaseFirestore { * @param query A query to execute. * @return A QuerySnapshot for the retrieved data. */ - get(query: Query): Promise; + get(query: Query): Promise>; /** * Reads the document referenced by the provided `DocumentReference.` @@ -265,7 +320,7 @@ declare namespace FirebaseFirestore { * @param documentRef A reference to the document to be read. * @return A DocumentSnapshot for the read data. */ - get(documentRef: DocumentReference): Promise; + get(documentRef: DocumentReference): Promise>; /** * Retrieves multiple documents from Firestore. Holds a pessimistic lock on @@ -281,8 +336,8 @@ declare namespace FirebaseFirestore { * @return A Promise that resolves with an array of resulting document * snapshots. */ - getAll(...documentRefsOrReadOptions: Array): - Promise; + getAll(...documentRefsOrReadOptions: Array): + Promise>>; /** * Create the document referred to by the provided `DocumentReference`. @@ -293,7 +348,7 @@ declare namespace FirebaseFirestore { * @param data The object data to serialize as the document. * @return This `Transaction` instance. Used for chaining method calls. */ - create(documentRef: DocumentReference, data: DocumentData): Transaction; + create(documentRef: DocumentReference, data: T): Transaction; /** * Writes to the document referred to by the provided `DocumentReference`. @@ -305,7 +360,7 @@ declare namespace FirebaseFirestore { * @param options An object to configure the set behavior. * @return This `Transaction` instance. Used for chaining method calls. */ - set(documentRef: DocumentReference, data: DocumentData, + set(documentRef: DocumentReference, data: T, options?: SetOptions): Transaction; /** @@ -322,7 +377,7 @@ declare namespace FirebaseFirestore { * @param precondition A Precondition to enforce on this update. * @return This `Transaction` instance. Used for chaining method calls. */ - update(documentRef: DocumentReference, data: UpdateData, + update(documentRef: DocumentReference, data: UpdateData, precondition?: Precondition): Transaction; /** @@ -344,7 +399,7 @@ declare namespace FirebaseFirestore { * update. * @return This `Transaction` instance. Used for chaining method calls. */ - update(documentRef: DocumentReference, field: string|FieldPath, value:any, + update(documentRef: DocumentReference, field: string|FieldPath, value:any, ...fieldsOrPrecondition: any[]): Transaction; /** @@ -354,7 +409,7 @@ declare namespace FirebaseFirestore { * @param precondition A Precondition to enforce for this delete. * @return This `Transaction` instance. Used for chaining method calls. */ - delete(documentRef: DocumentReference, + delete(documentRef: DocumentReference, precondition?: Precondition): Transaction; } @@ -381,7 +436,7 @@ declare namespace FirebaseFirestore { * @param data The object data to serialize as the document. * @return This `WriteBatch` instance. Used for chaining method calls. */ - create(documentRef: DocumentReference, data: DocumentData): WriteBatch; + create(documentRef: DocumentReference, data: T): WriteBatch; /** * Write to the document referred to by the provided `DocumentReference`. @@ -393,7 +448,7 @@ declare namespace FirebaseFirestore { * @param options An object to configure the set behavior. * @return This `WriteBatch` instance. Used for chaining method calls. */ - set(documentRef: DocumentReference, data: DocumentData, + set(documentRef: DocumentReference, data: T, options?: SetOptions): WriteBatch; /** @@ -410,7 +465,7 @@ declare namespace FirebaseFirestore { * @param precondition A Precondition to enforce on this update. * @return This `WriteBatch` instance. Used for chaining method calls. */ - update(documentRef: DocumentReference, data: UpdateData, + update(documentRef: DocumentReference, data: UpdateData, precondition?: Precondition): WriteBatch; /** @@ -431,7 +486,7 @@ declare namespace FirebaseFirestore { * to update, optionally followed a `Precondition` to enforce on this update. * @return This `WriteBatch` instance. Used for chaining method calls. */ - update(documentRef: DocumentReference, field: string|FieldPath, value:any, + update(documentRef: DocumentReference, field: string|FieldPath, value:any, ...fieldsOrPrecondition: any[]): WriteBatch; /** @@ -441,7 +496,7 @@ declare namespace FirebaseFirestore { * @param precondition A Precondition to enforce for this delete. * @return This `WriteBatch` instance. Used for chaining method calls. */ - delete(documentRef: DocumentReference, + delete(documentRef: DocumentReference, precondition?: Precondition): WriteBatch; /** @@ -535,7 +590,7 @@ declare namespace FirebaseFirestore { * the referenced location may or may not exist. A `DocumentReference` can * also be used to create a `CollectionReference` to a subcollection. */ - export class DocumentReference { + export class DocumentReference { private constructor(); /** The identifier of the document within its collection. */ @@ -550,7 +605,7 @@ declare namespace FirebaseFirestore { /** * A reference to the Collection to which this DocumentReference belongs. */ - readonly parent: CollectionReference; + readonly parent: CollectionReference; /** * A string representing the path of the referenced document (relative @@ -565,14 +620,14 @@ declare namespace FirebaseFirestore { * @param collectionPath A slash-separated path to a collection. * @return The `CollectionReference` instance. */ - collection(collectionPath: string): CollectionReference; + collection(collectionPath: string): CollectionReference; /** * Fetches the subcollections that are direct children of this document. * * @returns A Promise that resolves with an array of CollectionReferences. */ - listCollections() : Promise; + listCollections() : Promise>>; /** * Creates a document referred to by this `DocumentReference` with the @@ -581,7 +636,7 @@ declare namespace FirebaseFirestore { * @param data The object data to serialize as the document. * @return A Promise resolved with the write time of this create. */ - create(data: DocumentData): Promise; + create(data: T): Promise; /** * Writes to the document referred to by this `DocumentReference`. If the @@ -592,7 +647,7 @@ declare namespace FirebaseFirestore { * @param options An object to configure the set behavior. * @return A Promise resolved with the write time of this set. */ - set(data: DocumentData, options?: SetOptions): Promise; + set(data: T, options?: SetOptions): Promise; /** * Updates fields in the document referred to by this `DocumentReference`. @@ -642,7 +697,7 @@ declare namespace FirebaseFirestore { * @return A Promise resolved with a DocumentSnapshot containing the * current document contents. */ - get(): Promise; + get(): Promise>; /** * Attaches a listener for DocumentSnapshot events. @@ -654,7 +709,7 @@ declare namespace FirebaseFirestore { * @return An unsubscribe function that can be called to cancel * the snapshot listener. */ - onSnapshot(onNext: (snapshot: DocumentSnapshot) => void, + onSnapshot(onNext: (snapshot: DocumentSnapshot) => void, onError?: (error: Error) => void): () => void; /** @@ -663,7 +718,21 @@ declare namespace FirebaseFirestore { * @param other The `DocumentReference` to compare against. * @return true if this `DocumentReference` is equal to the provided one. */ - isEqual(other: DocumentReference): boolean; + isEqual(other: DocumentReference): boolean; + + /** + * 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. + * + * @param converter Converts objects to and from Firestore. + * @return A DocumentReference that uses the provided converter. + */ + withConverter( + converter: FirestoreDataConverter + ): DocumentReference; } /** @@ -675,14 +744,14 @@ declare namespace FirebaseFirestore { * access will return 'undefined'. You can use the `exists` property to * explicitly verify a document's existence. */ - export class DocumentSnapshot { + export class DocumentSnapshot { protected constructor(); /** True if the document exists. */ readonly exists: boolean; /** A `DocumentReference` to the document location. */ - readonly ref: DocumentReference; + readonly ref: DocumentReference; /** * The ID of the document for which this `DocumentSnapshot` contains data. @@ -712,7 +781,7 @@ declare namespace FirebaseFirestore { * * @return An Object containing all fields in the document. */ - data(): DocumentData | undefined; + data(): T | undefined; /** * Retrieves the field specified by `fieldPath`. @@ -730,7 +799,7 @@ declare namespace FirebaseFirestore { * @param other The `DocumentSnapshot` to compare against. * @return true if this `DocumentSnapshot` is equal to the provided one. */ - isEqual(other: DocumentSnapshot): boolean; + isEqual(other: DocumentSnapshot): boolean; } /** @@ -744,7 +813,7 @@ declare namespace FirebaseFirestore { * `exists` property will always be true and `data()` will never return * 'undefined'. */ - export class QueryDocumentSnapshot extends DocumentSnapshot { + export class QueryDocumentSnapshot extends DocumentSnapshot { private constructor(); /** @@ -764,7 +833,7 @@ declare namespace FirebaseFirestore { * @override * @return An Object containing all fields in the document. */ - data(): DocumentData; + data(): T; } /** @@ -785,7 +854,7 @@ declare namespace FirebaseFirestore { * A `Query` refers to a Query which you can read or listen to. You can also * construct refined `Query` objects by adding filters and ordering. */ - export class Query { + export class Query { protected constructor(); /** @@ -807,7 +876,7 @@ declare namespace FirebaseFirestore { * @param value The value for comparison * @return The created Query. */ - where(fieldPath: string|FieldPath, opStr: WhereFilterOp, value: any): Query; + where(fieldPath: string|FieldPath, opStr: WhereFilterOp, value: any): Query; /** * Creates and returns a new Query that's additionally sorted by the @@ -823,7 +892,7 @@ declare namespace FirebaseFirestore { */ orderBy( fieldPath: string|FieldPath, directionStr?: OrderByDirection - ): Query; + ): Query; /** * Creates and returns a new Query that's additionally limited to only @@ -835,7 +904,7 @@ declare namespace FirebaseFirestore { * @param limit The maximum number of items to return. * @return The created Query. */ - limit(limit: number): Query; + limit(limit: number): Query; /** * Specifies the offset of the returned results. @@ -846,7 +915,7 @@ declare namespace FirebaseFirestore { * @param offset The offset to apply to the Query results. * @return The created Query. */ - offset(offset: number): Query; + offset(offset: number): Query; /** * Creates and returns a new Query instance that applies a field mask to @@ -860,7 +929,7 @@ declare namespace FirebaseFirestore { * @param field The field paths to return. * @return The created Query. */ - select(...field: (string | FieldPath)[]): Query; + select(...field: (string | FieldPath)[]): Query; /** * Creates and returns a new Query that starts at the provided document @@ -871,7 +940,7 @@ declare namespace FirebaseFirestore { * @param snapshot The snapshot of the document to start after. * @return The created Query. */ - startAt(snapshot: DocumentSnapshot): Query; + startAt(snapshot: DocumentSnapshot): Query; /** * Creates and returns a new Query that starts at the provided fields @@ -882,7 +951,7 @@ declare namespace FirebaseFirestore { * of the query's order by. * @return The created Query. */ - startAt(...fieldValues: any[]): Query; + startAt(...fieldValues: any[]): Query; /** * Creates and returns a new Query that starts after the provided document @@ -893,7 +962,7 @@ declare namespace FirebaseFirestore { * @param snapshot The snapshot of the document to start after. * @return The created Query. */ - startAfter(snapshot: DocumentSnapshot): Query; + startAfter(snapshot: DocumentSnapshot): Query; /** * Creates and returns a new Query that starts after the provided fields @@ -904,7 +973,7 @@ declare namespace FirebaseFirestore { * of the query's order by. * @return The created Query. */ - startAfter(...fieldValues: any[]): Query; + startAfter(...fieldValues: any[]): Query; /** * Creates and returns a new Query that ends before the provided document @@ -915,7 +984,7 @@ declare namespace FirebaseFirestore { * @param snapshot The snapshot of the document to end before. * @return The created Query. */ - endBefore(snapshot: DocumentSnapshot): Query; + endBefore(snapshot: DocumentSnapshot): Query; /** * Creates and returns a new Query that ends before the provided fields @@ -926,7 +995,7 @@ declare namespace FirebaseFirestore { * of the query's order by. * @return The created Query. */ - endBefore(...fieldValues: any[]): Query; + endBefore(...fieldValues: any[]): Query; /** * Creates and returns a new Query that ends at the provided document @@ -937,7 +1006,7 @@ declare namespace FirebaseFirestore { * @param snapshot The snapshot of the document to end at. * @return The created Query. */ - endAt(snapshot: DocumentSnapshot): Query; + endAt(snapshot: DocumentSnapshot): Query; /** * Creates and returns a new Query that ends at the provided fields @@ -948,7 +1017,7 @@ declare namespace FirebaseFirestore { * of the query's order by. * @return The created Query. */ - endAt(...fieldValues: any[]): Query; + endAt(...fieldValues: any[]): Query; /** * Executes the query and returns the results as a `QuerySnapshot`. @@ -984,6 +1053,17 @@ declare namespace FirebaseFirestore { * @return true if this `Query` is equal to the provided one. */ isEqual(other: Query): boolean; + + /** + * Applies a custom data converter to this Query, allowing you to use your + * own custom model objects with Firestore. When you call get() on the + * returned Query, the provided converter will convert between Firestore + * data and your custom type U. + * + * @param converter Converts objects to and from Firestore. + * @return A Query that uses the provided converter. + */ + withConverter(converter: FirestoreDataConverter): Query; } /** @@ -993,17 +1073,17 @@ declare namespace FirebaseFirestore { * number of documents can be determined via the `empty` and `size` * properties. */ - export class QuerySnapshot { + export class QuerySnapshot { private constructor(); /** * The query on which you called `get` or `onSnapshot` in order to get this * `QuerySnapshot`. */ - readonly query: Query; + readonly query: Query; /** An array of all the documents in the QuerySnapshot. */ - readonly docs: QueryDocumentSnapshot[]; + readonly docs: Array>; /** The number of documents in the QuerySnapshot. */ readonly size: number; @@ -1029,7 +1109,7 @@ declare namespace FirebaseFirestore { * @param thisArg The `this` binding for the callback. */ forEach( - callback: (result: QueryDocumentSnapshot) => void, thisArg?: any + callback: (result: QueryDocumentSnapshot) => void, thisArg?: any ): void; /** @@ -1039,7 +1119,7 @@ declare namespace FirebaseFirestore { * @param other The `QuerySnapshot` to compare against. * @return true if this `QuerySnapshot` is equal to the provided one. */ - isEqual(other: QuerySnapshot): boolean; + isEqual(other: QuerySnapshot): boolean; } /** @@ -1051,12 +1131,12 @@ declare namespace FirebaseFirestore { * A `DocumentChange` represents a change to the documents matching a query. * It contains the document affected and the type of change that occurred. */ - export interface DocumentChange { + export interface DocumentChange { /** The type of change ('added', 'modified', or 'removed'). */ readonly type: DocumentChangeType; /** The document affected by this change. */ - readonly doc: QueryDocumentSnapshot; + readonly doc: QueryDocumentSnapshot; /** * The index of the changed document in the result set immediately prior to @@ -1080,7 +1160,7 @@ declare namespace FirebaseFirestore { * @param other The `DocumentChange` to compare against. * @return true if this `DocumentChange` is equal to the provided one. */ - isEqual(other: DocumentChange): boolean; + isEqual(other: DocumentChange): boolean; } /** @@ -1088,7 +1168,7 @@ declare namespace FirebaseFirestore { * document references, and querying for documents (using the methods * inherited from `Query`). */ - export class CollectionReference extends Query { + export class CollectionReference extends Query { private constructor(); /** The identifier of the collection. */ @@ -1098,7 +1178,7 @@ declare namespace FirebaseFirestore { * A reference to the containing Document if this is a subcollection, else * null. */ - readonly parent: DocumentReference|null; + readonly parent: DocumentReference | null; /** * A string representing the path of the referenced collection (relative @@ -1118,7 +1198,7 @@ declare namespace FirebaseFirestore { * @return {Promise} The list of documents in this * collection. */ - listDocuments(): Promise; + listDocuments(): Promise>>; /** * Get a `DocumentReference` for a randomly-named document within this @@ -1127,7 +1207,7 @@ declare namespace FirebaseFirestore { * * @return The `DocumentReference` instance. */ - doc(): DocumentReference; + doc(): DocumentReference; /** * Get a `DocumentReference` for the document within the collection at the @@ -1136,7 +1216,7 @@ declare namespace FirebaseFirestore { * @param documentPath A slash-separated path to a document. * @return The `DocumentReference` instance. */ - doc(documentPath: string): DocumentReference; + doc(documentPath: string): DocumentReference; /** * Add a new document to this collection with the specified data, assigning @@ -1146,7 +1226,7 @@ declare namespace FirebaseFirestore { * @return A Promise resolved with a `DocumentReference` pointing to the * newly created document after it has been written to the backend. */ - add(data: DocumentData): Promise; + add(data: T): Promise>; /** * Returns true if this `CollectionReference` is equal to the provided one. @@ -1154,7 +1234,20 @@ declare namespace FirebaseFirestore { * @param other The `CollectionReference` to compare against. * @return true if this `CollectionReference` is equal to the provided one. */ - isEqual(other: CollectionReference): boolean; + isEqual(other: CollectionReference): 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 + * convert between Firestore data and your custom type U. + * + * @param converter Converts objects to and from Firestore. + * @return A CollectionReference that uses the provided converter. + */ + withConverter( + converter: FirestoreDataConverter + ): CollectionReference; } /** From 8f41b37fd766b18113401c7324e319b52b38cc96 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 14 Jan 2020 13:19:02 -0800 Subject: [PATCH 040/337] refactor: use loop for transactions (#875) --- dev/src/index.ts | 77 +++-------------------------------------- dev/src/transaction.ts | 76 +++++++++++++++++++++++++++++++++------- dev/src/write-batch.ts | 9 +++++ dev/test/transaction.ts | 24 ++++++++----- dev/test/write-batch.ts | 19 ++++++++++ 5 files changed, 112 insertions(+), 93 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index 8f83c12da..949cb87bc 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -789,7 +789,7 @@ export class Firestore { const defaultAttempts = 5; const tag = requestTag(); - let attemptsRemaining: number; + let maxAttempts: number; if (transactionOptions) { validateObject('transactionOptions', transactionOptions); @@ -798,84 +798,17 @@ export class Firestore { transactionOptions.maxAttempts, {optional: true, minValue: 1} ); - attemptsRemaining = transactionOptions.maxAttempts || defaultAttempts; + maxAttempts = transactionOptions.maxAttempts || defaultAttempts; } else { - attemptsRemaining = defaultAttempts; + maxAttempts = defaultAttempts; } + const transaction = new Transaction(this, tag); return this.initializeIfNeeded(tag).then(() => - this._runTransaction(updateFunction, {requestTag: tag, attemptsRemaining}) + transaction.runTransaction(updateFunction, maxAttempts) ); } - _runTransaction( - updateFunction: (transaction: Transaction) => Promise, - transactionOptions: { - requestTag: string; - attemptsRemaining: number; - previousTransaction?: Transaction; - } - ): Promise { - const requestTag = transactionOptions.requestTag; - const attemptsRemaining = transactionOptions.attemptsRemaining; - const previousTransaction = transactionOptions.previousTransaction; - - const transaction = new Transaction(this, requestTag, previousTransaction); - let result: Promise; - - return transaction - .begin() - .then(() => { - const promise = updateFunction(transaction); - result = - promise instanceof Promise - ? promise - : Promise.reject( - new Error( - 'You must return a Promise in your transaction()-callback.' - ) - ); - return result.catch(err => { - logger( - 'Firestore.runTransaction', - requestTag, - 'Rolling back transaction after callback error:', - err - ); - // Rollback the transaction and return the failed result. - return transaction.rollback().then(() => { - return result; - }); - }); - }) - .then(() => { - return transaction - .commit() - .then(() => result) - .catch(err => { - if (attemptsRemaining > 1) { - logger( - 'Firestore.runTransaction', - requestTag, - `Retrying transaction after error: ${JSON.stringify(err)}.` - ); - return this._runTransaction(updateFunction, { - previousTransaction: transaction, - requestTag, - attemptsRemaining: attemptsRemaining - 1, - }); - } - logger( - 'Firestore.runTransaction', - requestTag, - 'Exhausted transaction retries, returning error: %s', - err - ); - return Promise.reject(err); - }); - }); - } - /** * Fetches the root collections that are associated with this Firestore * database. diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index 2030ef123..482ba71cb 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -18,6 +18,7 @@ import * as proto from '../protos/firestore_v1_proto_api'; import {DocumentSnapshot, Precondition} from './document'; import {Firestore, WriteBatch} from './index'; +import {logger} from './logger'; import {FieldPath, validateFieldPath} from './path'; import { DocumentReference, @@ -70,17 +71,9 @@ export class Transaction { * @param firestore The Firestore Database client. * @param requestTag A unique client-assigned identifier for the scope of * this transaction. - * @param previousTransaction If available, the failed transaction that is - * being retried. */ - constructor( - firestore: Firestore, - requestTag: string, - previousTransaction?: Transaction - ) { + constructor(firestore: Firestore, requestTag: string) { this._firestore = firestore; - this._transactionId = - previousTransaction && previousTransaction._transactionId; this._writeBatch = firestore.batch(); this._requestTag = requestTag; } @@ -398,12 +391,69 @@ export class Transaction { } /** - * Returns the tag to use with with all request for this Transaction. + * Executes `updateFunction()` and commits the transaction with retry. + * * @private - * @return A unique client-generated identifier for this transaction. + * @param updateFunction The user function to execute within the transaction + * context. + * @param requestTag A unique client-assigned identifier for the scope of + * this transaction. + * @param maxAttempts The maximum number of attempts for this transaction. */ - get requestTag(): string { - return this._requestTag; + async runTransaction( + updateFunction: (transaction: Transaction) => Promise, + maxAttempts: number + ): Promise { + let result: T; + let lastError: Error | undefined = undefined; + + for (let attempt = 0; attempt < maxAttempts; ++attempt) { + if (lastError) { + logger( + 'Firestore.runTransaction', + this._requestTag, + `Retrying transaction after error:`, + lastError + ); + } + + await this.begin(); + + try { + const promise = updateFunction(this); + if (!(promise instanceof Promise)) { + throw new Error( + 'You must return a Promise in your transaction()-callback.' + ); + } + result = await promise; + } catch (err) { + logger( + 'Firestore.runTransaction', + this._requestTag, + 'Rolling back transaction after callback error:', + err + ); + await this.rollback(); + return Promise.reject(err); // User callback failed + } + + try { + await this.commit(); + return result; // Success + } catch (err) { + lastError = err; + this._writeBatch._reset(); + } + } + + logger( + 'Firestore.runTransaction', + this._requestTag, + 'Exhausted transaction retries, returning error: %s', + lastError + ); + return Promise.reject(lastError); } } diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 6b2e161ee..4191a7471 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -652,6 +652,15 @@ export class WriteBatch { return true; } + + /** + * Resets the WriteBatch and dequeues all pending operations. + * @private + */ + _reset() { + this._ops.splice(0); + this._committed = false; + } } /** diff --git a/dev/test/transaction.ts b/dev/test/transaction.ts index b4dba86a8..453440595 100644 --- a/dev/test/transaction.ts +++ b/dev/test/transaction.ts @@ -517,10 +517,14 @@ describe('transaction operations', () => { it('enforce that gets come before writes', () => { return expect( - runTransaction((transaction, docRef) => { - transaction.set(docRef, {foo: 'bar'}); - return transaction.get(docRef); - }, begin()) + runTransaction( + (transaction, docRef) => { + transaction.set(docRef, {foo: 'bar'}); + return transaction.get(docRef); + }, + begin(), + rollback() + ) ).to.eventually.be.rejectedWith( 'Firestore transactions require all reads to be executed before all writes.' ); @@ -575,10 +579,14 @@ describe('transaction operations', () => { it('enforce that getAll come before writes', () => { return expect( - runTransaction((transaction, docRef) => { - transaction.set(docRef, {foo: 'bar'}); - return transaction.getAll(docRef); - }, begin()) + runTransaction( + (transaction, docRef) => { + transaction.set(docRef, {foo: 'bar'}); + return transaction.getAll(docRef); + }, + begin(), + rollback() + ) ).to.eventually.be.rejectedWith( 'Firestore transactions require all reads to be executed before all writes.' ); diff --git a/dev/test/write-batch.ts b/dev/test/write-batch.ts index 1b125347f..692d40abb 100644 --- a/dev/test/write-batch.ts +++ b/dev/test/write-batch.ts @@ -356,6 +356,25 @@ describe('batch support', () => { return promise; }); + it('can reset a committed batch', async () => { + const documentName = firestore.doc('col/doc'); + + const batch = firestore.batch(); + batch.set(documentName, {foo: FieldValue.serverTimestamp()}); + batch.update(documentName, {foo: 'bar'}); + batch.create(documentName, {}); + batch.delete(documentName); + await batch.commit(); + + batch._reset(); + + batch.set(documentName, {foo: FieldValue.serverTimestamp()}); + batch.update(documentName, {foo: 'bar'}); + batch.create(documentName, {}); + batch.delete(documentName); + await batch.commit(); + }); + it('can commit an unmodified batch multiple times', () => { const documentName = firestore.doc('col/doc'); From 82273ec0035b2ddae94d8f12791f8a5c55b6560d Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 14 Jan 2020 14:15:41 -0800 Subject: [PATCH 041/337] fix: don't retry reads with Code ABORTED (#881) --- dev/protos/protos.json | 8 ++++---- dev/src/v1/firestore_admin_proto_list.json | 4 ++-- dev/src/v1/firestore_client_config.json | 21 ++++++++++----------- dev/synth.metadata | 6 +++--- dev/test/index.ts | 2 +- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/dev/protos/protos.json b/dev/protos/protos.json index 43a9cfaad..ea758f26b 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -11,7 +11,7 @@ "csharp_namespace": "Google.Cloud.Firestore.Admin.V1", "go_package": "google.golang.org/genproto/googleapis/firestore/admin/v1;admin", "java_multiple_files": true, - "java_outer_classname": "OperationProto", + "java_outer_classname": "LocationProto", "java_package": "com.google.firestore.admin.v1", "objc_class_prefix": "GCFS", "php_namespace": "Google\\Cloud\\Firestore\\Admin\\V1", @@ -417,9 +417,6 @@ } } }, - "LocationMetadata": { - "fields": {} - }, "IndexOperationMetadata": { "fields": { "startTime": { @@ -601,6 +598,9 @@ "FAILED": 6, "CANCELLED": 7 } + }, + "LocationMetadata": { + "fields": {} } } } diff --git a/dev/src/v1/firestore_admin_proto_list.json b/dev/src/v1/firestore_admin_proto_list.json index 0484301c3..f6060527c 100644 --- a/dev/src/v1/firestore_admin_proto_list.json +++ b/dev/src/v1/firestore_admin_proto_list.json @@ -2,6 +2,6 @@ "../../protos/google/firestore/admin/v1/index.proto", "../../protos/google/firestore/admin/v1/field.proto", "../../protos/google/firestore/admin/v1/firestore_admin.proto", - "../../protos/google/firestore/admin/v1/location.proto", - "../../protos/google/firestore/admin/v1/operation.proto" + "../../protos/google/firestore/admin/v1/operation.proto", + "../../protos/google/firestore/admin/v1/location.proto" ] diff --git a/dev/src/v1/firestore_client_config.json b/dev/src/v1/firestore_client_config.json index 60230c0d7..b1e32f327 100644 --- a/dev/src/v1/firestore_client_config.json +++ b/dev/src/v1/firestore_client_config.json @@ -7,9 +7,8 @@ "DEADLINE_EXCEEDED", "UNAVAILABLE" ], - "deadline_exceeded_aborted_internal_unavailable": [ + "deadline_exceeded_internal_unavailable": [ "DEADLINE_EXCEEDED", - "ABORTED", "INTERNAL", "UNAVAILABLE" ] @@ -28,12 +27,12 @@ "methods": { "GetDocument": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, "ListDocuments": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, "CreateDocument": { @@ -48,17 +47,17 @@ }, "DeleteDocument": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, "BatchGetDocuments": { "timeout_millis": 300000, - "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, "BeginTransaction": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, "Commit": { @@ -68,12 +67,12 @@ }, "Rollback": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, "RunQuery": { "timeout_millis": 300000, - "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, "Write": { @@ -83,12 +82,12 @@ }, "Listen": { "timeout_millis": 86400000, - "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, "ListCollectionIds": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_aborted_internal_unavailable", + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" } } diff --git a/dev/synth.metadata b/dev/synth.metadata index d20d3fb4f..6494e13f0 100644 --- a/dev/synth.metadata +++ b/dev/synth.metadata @@ -1,12 +1,12 @@ { - "updateTime": "2020-01-09T12:16:06.483557Z", + "updateTime": "2020-01-14T17:21:47.294128Z", "sources": [ { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "6ace586805c08896fef43e28a261337fcf3f022b", - "internalRef": "288783603" + "sha": "2fa8d48165cc48e35b0c62e6f7bdade12229326c", + "internalRef": "289619243" } }, { diff --git a/dev/test/index.ts b/dev/test/index.ts index 2e7343f17..26f6c0b37 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -1065,7 +1065,7 @@ describe('getAll() method', () => { [Status.PERMISSION_DENIED]: 1, [Status.RESOURCE_EXHAUSTED]: 1, [Status.FAILED_PRECONDITION]: 1, - [Status.ABORTED]: 5, + [Status.ABORTED]: 1, [Status.OUT_OF_RANGE]: 1, [Status.UNIMPLEMENTED]: 1, [Status.INTERNAL]: 5, From b2740ed4fb0e7c34fd407e3de4f47f03067171cb Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 14 Jan 2020 16:30:36 -0800 Subject: [PATCH 042/337] fix: remove ticks from code comments (#885) --- dev/src/types.ts | 2 -- types/firestore.d.ts | 2 -- 2 files changed, 4 deletions(-) diff --git a/dev/src/types.ts b/dev/src/types.ts index 851b11f54..d318074b4 100644 --- a/dev/src/types.ts +++ b/dev/src/types.ts @@ -100,7 +100,6 @@ export type RBTree = any; * storing and retrieving objects from Firestore. * * @example - * ```typescript * class Post { * constructor(readonly title: string, readonly author: string) {} * @@ -130,7 +129,6 @@ export type RBTree = any; * post.toString(); // Should be defined * post.someNonExistentProperty; // TS error * } - * ``` */ export interface FirestoreDataConverter { /** diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 74eadbea9..e8b4ee060 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -50,7 +50,6 @@ declare namespace FirebaseFirestore { * storing and retrieving objects from Firestore. * * @example - * ```typescript * class Post { * constructor(readonly title: string, readonly author: string) {} * @@ -80,7 +79,6 @@ declare namespace FirebaseFirestore { * post.toString(); // Should be defined * post.someNonExistentProperty; // TS error * } - * ``` */ export interface FirestoreDataConverter { /** From cd0d7588f914e260693f375a78fcb90ccf931be4 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 14 Jan 2020 16:42:57 -0800 Subject: [PATCH 043/337] refactor: remove usage of 'self' (#884) --- dev/src/index.ts | 13 ++++++------- dev/src/reference.ts | 4 +--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index 949cb87bc..b2c052087 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -898,10 +898,8 @@ export class Firestore { request.mask = {fieldPaths}; } - const self = this; - return self - .requestStream('batchGetDocuments', request, requestTag) - .then(stream => { + return this.requestStream('batchGetDocuments', request, requestTag).then( + stream => { return new Promise>>((resolve, reject) => { stream .on('error', err => { @@ -924,7 +922,7 @@ export class Firestore { 'Received document: %s', response.found.name! ); - document = self.snapshot_(response.found, response.readTime!); + document = this.snapshot_(response.found, response.readTime!); } else { logger( 'Firestore.getAll_', @@ -932,7 +930,7 @@ export class Firestore { 'Document missing: %s', response.missing! ); - document = self.snapshot_( + document = this.snapshot_( response.missing!, response.readTime! ); @@ -983,7 +981,8 @@ export class Firestore { }); stream.resume(); }); - }); + } + ); } /** diff --git a/dev/src/reference.ts b/dev/src/reference.ts index df580d81e..5cd240fa7 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -1747,14 +1747,12 @@ export class Query { * @param {bytes=} transactionId A transaction ID. */ _get(transactionId?: Uint8Array): Promise> { - const self = this; const docs: Array> = []; return new Promise((resolve, reject) => { let readTime: Timestamp; - self - ._stream(transactionId) + this._stream(transactionId) .on('error', err => { reject(err); }) From 7562033876dc006e77d00b576b2541a7dfd30c66 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 14 Jan 2020 20:44:47 -0800 Subject: [PATCH 044/337] fix: manually retry ABORTED reads in transactions (#883) --- dev/src/transaction.ts | 24 ++++++++++++-- dev/test/transaction.ts | 71 +++++++++++++++++++++++++++++++++-------- 2 files changed, 80 insertions(+), 15 deletions(-) diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index 482ba71cb..925ec73e5 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import {GoogleError, Status} from 'google-gax'; + import * as proto from '../protos/firestore_v1_proto_api'; import {DocumentSnapshot, Precondition} from './document'; @@ -434,8 +436,15 @@ export class Transaction { 'Rolling back transaction after callback error:', err ); + await this.rollback(); - return Promise.reject(err); // User callback failed + + if (isRetryableTransactionError(err)) { + lastError = err; + continue; // Retry full transaction + } else { + return Promise.reject(err); // Callback failed w/ non-retryable error + } } try { @@ -450,7 +459,7 @@ export class Transaction { logger( 'Firestore.runTransaction', this._requestTag, - 'Exhausted transaction retries, returning error: %s', + 'Transaction not eligible for retry, returning error: %s', lastError ); return Promise.reject(lastError); @@ -552,3 +561,14 @@ function validateReadOptions( } } } + +function isRetryableTransactionError(error: Error): boolean { + if (error instanceof GoogleError || 'code' in error) { + // In transactions, the backend returns code ABORTED for reads that fail + // with contention. These errors should be retried for both GoogleError + // and GoogleError-alike errors (in case the prototype hierarchy gets + // stripped somewhere). + return error.code === Status.ABORTED; + } + return false; +} diff --git a/dev/test/transaction.ts b/dev/test/transaction.ts index 453440595..e25f400f9 100644 --- a/dev/test/transaction.ts +++ b/dev/test/transaction.ts @@ -70,7 +70,7 @@ interface TransactionStep { function commit( transaction?: Uint8Array | string, writes?: api.IWrite[], - err?: Error + error?: Error ): TransactionStep { const proto: api.ICommitRequest = { database: DATABASE_ROOT, @@ -99,14 +99,14 @@ function commit( return { type: 'commit', request: proto, - error: err, + error, response, }; } function rollback( transaction?: Uint8Array | string, - err?: Error + error?: Error ): TransactionStep { const proto = { database: DATABASE_ROOT, @@ -116,7 +116,7 @@ function rollback( return { type: 'rollback', request: proto, - error: err, + error, response: {}, }; } @@ -124,7 +124,7 @@ function rollback( function begin( transaction?: Uint8Array | string, prevTransaction?: Uint8Array | string, - err?: Error + error?: Error ): TransactionStep { const proto: api.IBeginTransactionRequest = {database: DATABASE_ROOT}; @@ -143,12 +143,15 @@ function begin( return { type: 'begin', request: proto, - error: err, + error, response, }; } -function getDocument(transaction?: Uint8Array | string): TransactionStep { +function getDocument( + transaction?: Uint8Array | string, + error?: Error +): TransactionStep { const request = { database: DATABASE_ROOT, documents: [DOCUMENT_NAME], @@ -172,6 +175,7 @@ function getDocument(transaction?: Uint8Array | string): TransactionStep { return { type: 'getDocument', request, + error, stream, }; } @@ -307,7 +311,11 @@ function runTransaction( const request = expectedRequests.shift()!; expect(request.type).to.equal('getDocument'); expect(actual).to.deep.eq(request.request); - return request.stream!; + if (request.error) { + throw request.error; + } else { + return request.stream!; + } }, runQuery: actual => { const request = expectedRequests.shift()!; @@ -396,7 +404,7 @@ describe('failed transactions', () => { it('requires a promise', () => { return expect( - runTransaction((() => {}) as InvalidApiUsage, begin(), rollback('foo')) + runTransaction((() => {}) as InvalidApiUsage, begin(), rollback()) ).to.eventually.be.rejectedWith( 'You must return a Promise in your transaction()-callback.' ); @@ -416,14 +424,51 @@ describe('failed transactions', () => { }); }); - it("doesn't retry on callback failure", () => { + it('retries GRPC exceptions with code ABORTED in callback', () => { + const retryableError = new GoogleError('Aborted'); + retryableError.code = Status.ABORTED; + + return runTransaction( + async (transaction, docRef) => { + await transaction.get(docRef); + return 'success'; + }, + begin('foo1'), + getDocument('foo1', retryableError), + rollback('foo1'), + begin('foo2', 'foo1'), + getDocument('foo2'), + commit('foo2') + ).then(res => { + expect(res).to.equal('success'); + }); + }); + + it("doesn't retry GRPC exceptions with code FAILED_PRECONDITION in callback", () => { + const nonRetryableError = new GoogleError('Failed Precondition'); + nonRetryableError.code = Status.FAILED_PRECONDITION; + + return expect( + runTransaction( + async (transaction, docRef) => { + await transaction.get(docRef); + return 'failure'; + }, + begin('foo'), + getDocument('foo', nonRetryableError), + rollback('foo') + ) + ).to.eventually.be.rejectedWith('Failed Precondition'); + }); + + it("doesn't retry custom user exceptions in callback", () => { return expect( runTransaction( () => { return Promise.reject('request exception'); }, begin(), - rollback('foo') + rollback() ) ).to.eventually.be.rejectedWith('request exception'); }); @@ -442,8 +487,8 @@ describe('failed transactions', () => { commit('foo2', [], serverError), begin('foo3', 'foo2'), commit('foo3') - ).then(red => { - expect(red).to.equal('success'); + ).then(res => { + expect(res).to.equal('success'); }); }); From 92ea215583e5d327f2255914e0454cb201820a4f Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2020 20:56:42 -0800 Subject: [PATCH 045/337] chore: release 3.4.0 (#882) --- CHANGELOG.md | 17 +++++++++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f6d77339..98741092b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [3.4.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.3.4...v3.4.0) (2020-01-15) + + +### Features + +* support serialization of custom objects ([#828](https://www.github.com/googleapis/nodejs-firestore/issues/828)) ([94ddc89](https://www.github.com/googleapis/nodejs-firestore/commit/94ddc897400cafe5a1ee16f3ad0d285411bdd0b2)) +* support serialization of Moment.js types ([#879](https://www.github.com/googleapis/nodejs-firestore/issues/879)) ([9169fae](https://www.github.com/googleapis/nodejs-firestore/commit/9169fae692d219b5fb42004a4eb82e5a5919f087)) +* allow logging to be disabled ([#880](https://www.github.com/googleapis/nodejs-firestore/issues/880)) ([36d75f6](https://www.github.com/googleapis/nodejs-firestore/commit/36d75f6b75d7ede4656636f1d8bf770eb1cb3a80)) + + +### Bug Fixes + +* don't format log message if logging is disabled ([#874](https://www.github.com/googleapis/nodejs-firestore/issues/874)) ([b7b5fc9](https://www.github.com/googleapis/nodejs-firestore/commit/b7b5fc993d4cece92833c95487efe63320537058)) +* disable non-transactional retries for Code ABORTED ([#881](https://www.github.com/googleapis/nodejs-firestore/issues/881)) ([82273ec](https://www.github.com/googleapis/nodejs-firestore/commit/82273ec0035b2ddae94d8f12791f8a5c55b6560d)) +* manually retry ABORTED reads in transactions ([#883](https://www.github.com/googleapis/nodejs-firestore/issues/883)) ([7562033](https://www.github.com/googleapis/nodejs-firestore/commit/7562033876dc006e77d00b576b2541a7dfd30c66)) +* remove ticks from code comments ([#885](https://www.github.com/googleapis/nodejs-firestore/issues/885)) ([b2740ed](https://www.github.com/googleapis/nodejs-firestore/commit/b2740ed4fb0e7c34fd407e3de4f47f03067171cb)) + ### [3.3.4](https://www.github.com/googleapis/nodejs-firestore/compare/v3.3.3...v3.3.4) (2020-01-12) diff --git a/package.json b/package.json index d74da7697..7f40b4fac 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.3.4", + "version": "3.4.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 4e3431bcd..c052eeb2d 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.3.4" + "@google-cloud/firestore": "^3.4.0" }, "devDependencies": { "chai": "^4.2.0", From c478dfc4e597bb2e43860d2b265d6457a139cd84 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 15 Jan 2020 09:19:39 -0800 Subject: [PATCH 046/337] chore: re-order JSON imports --- dev/protos/protos.json | 8 ++++---- dev/src/v1/firestore_admin_proto_list.json | 4 ++-- dev/synth.metadata | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dev/protos/protos.json b/dev/protos/protos.json index ea758f26b..43a9cfaad 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -11,7 +11,7 @@ "csharp_namespace": "Google.Cloud.Firestore.Admin.V1", "go_package": "google.golang.org/genproto/googleapis/firestore/admin/v1;admin", "java_multiple_files": true, - "java_outer_classname": "LocationProto", + "java_outer_classname": "OperationProto", "java_package": "com.google.firestore.admin.v1", "objc_class_prefix": "GCFS", "php_namespace": "Google\\Cloud\\Firestore\\Admin\\V1", @@ -417,6 +417,9 @@ } } }, + "LocationMetadata": { + "fields": {} + }, "IndexOperationMetadata": { "fields": { "startTime": { @@ -598,9 +601,6 @@ "FAILED": 6, "CANCELLED": 7 } - }, - "LocationMetadata": { - "fields": {} } } } diff --git a/dev/src/v1/firestore_admin_proto_list.json b/dev/src/v1/firestore_admin_proto_list.json index f6060527c..0484301c3 100644 --- a/dev/src/v1/firestore_admin_proto_list.json +++ b/dev/src/v1/firestore_admin_proto_list.json @@ -2,6 +2,6 @@ "../../protos/google/firestore/admin/v1/index.proto", "../../protos/google/firestore/admin/v1/field.proto", "../../protos/google/firestore/admin/v1/firestore_admin.proto", - "../../protos/google/firestore/admin/v1/operation.proto", - "../../protos/google/firestore/admin/v1/location.proto" + "../../protos/google/firestore/admin/v1/location.proto", + "../../protos/google/firestore/admin/v1/operation.proto" ] diff --git a/dev/synth.metadata b/dev/synth.metadata index 6494e13f0..b684fbe81 100644 --- a/dev/synth.metadata +++ b/dev/synth.metadata @@ -1,12 +1,12 @@ { - "updateTime": "2020-01-14T17:21:47.294128Z", + "updateTime": "2020-01-15T12:19:38.399076Z", "sources": [ { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "2fa8d48165cc48e35b0c62e6f7bdade12229326c", - "internalRef": "289619243" + "sha": "d99df0d67057a233c711187e0689baa4f8e6333d", + "internalRef": "289709813" } }, { From e099de631793e62c4360d035609850abd7b02df9 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Tue, 21 Jan 2020 15:40:12 -0800 Subject: [PATCH 047/337] build: update windows configuration to match new vm --- .kokoro/test.bat | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.kokoro/test.bat b/.kokoro/test.bat index fddff7570..ae59e59be 100644 --- a/.kokoro/test.bat +++ b/.kokoro/test.bat @@ -17,14 +17,12 @@ cd /d %~dp0 cd .. -@rem The image we're currently running has a broken version of Node.js enabled -@rem by nvm (v10.15.3), which has no npm bin. This hack uses the functional -@rem Node v8.9.1 to install npm@latest, it then uses this version of npm to -@rem install npm for v10.15.3. -call nvm use v8.9.1 || goto :error -call node C:\Users\kbuilder\AppData\Roaming\nvm-ps\versions\v8.9.1\node_modules\npm-bootstrap\bin\npm-cli.js i npm -g || goto :error -call nvm use v10.15.3 || goto :error -call node C:\Users\kbuilder\AppData\Roaming\nvm-ps\versions\v8.9.1\node_modules\npm\bin\npm-cli.js i npm -g || goto :error +@rem npm path is not currently set in our image, we should fix this next time +@rem we upgrade Node.js in the image: +SET PATH=%PATH%;/cygdrive/c/Program Files/nodejs/npm + +call nvm use v12.14.1 +call which node call npm install || goto :error call npm run test || goto :error From f668e8e4880256223c41c2c3183434e81c7f7945 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 22 Jan 2020 10:06:12 -0800 Subject: [PATCH 048/337] fix: do not assume all custom objects have constructors (#893) fixes https://github.com/googleapis/nodejs-firestore/issues/892 --- dev/src/serializer.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/src/serializer.ts b/dev/src/serializer.ts index db6b3de30..3dc61b970 100644 --- a/dev/src/serializer.ts +++ b/dev/src/serializer.ts @@ -400,6 +400,7 @@ function isMomentJsType(value: unknown): value is Moment { return ( typeof value === 'object' && value !== null && + value.constructor && value.constructor.name === 'Moment' && typeof (value as Moment).toDate === 'function' ); From 6fd042f5f920aa4896199e99dee82b8908f44dbf Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 22 Jan 2020 10:12:44 -0800 Subject: [PATCH 049/337] chore: release 3.4.1 (#894) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98741092b..37346b88e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.4.1](https://www.github.com/googleapis/nodejs-firestore/compare/v3.4.0...v3.4.1) (2020-01-22) + + +### Bug Fixes + +* do not assume all custom objects have constructors ([#893](https://www.github.com/googleapis/nodejs-firestore/issues/893)) ([f668e8e](https://www.github.com/googleapis/nodejs-firestore/commit/f668e8e4880256223c41c2c3183434e81c7f7945)) + ## [3.4.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.3.4...v3.4.0) (2020-01-15) diff --git a/package.json b/package.json index 7f40b4fac..2ddebeb22 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.4.0", + "version": "3.4.1", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index c052eeb2d..39bc06ae6 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.4.0" + "@google-cloud/firestore": "^3.4.1" }, "devDependencies": { "chai": "^4.2.0", From 703cef961c48843fe9672615b1346a6245acfb65 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Thu, 23 Jan 2020 16:25:13 -0800 Subject: [PATCH 050/337] chore: clear synth.metadata --- synth.metadata | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 synth.metadata diff --git a/synth.metadata b/synth.metadata deleted file mode 100644 index a3b819c98..000000000 --- a/synth.metadata +++ /dev/null @@ -1,3 +0,0 @@ -{ - "updateTime": "2019-12-15T01:34:32.499415Z" -} \ No newline at end of file From 2ec0489127faea88dca95e6dc169efe6e55d330d Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Fri, 24 Jan 2020 13:39:32 -0800 Subject: [PATCH 051/337] fix: retry streaming methods if initial write errored (#897) According to https://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback, the write() callback may be called with an Error before on('error') is invoked. In this case, we should reject our Stream. In the current implementation, we would accept the Stream as healthy and then forward the error to the user, which prevents retries. I noticed while looking at this code as we are porting it to Python --- dev/src/index.ts | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index b2c052087..8b3749632 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -1148,8 +1148,6 @@ export class Firestore { } } - backendStream.on('data', () => streamReady()); - function streamEnded() { logger( 'Firestore._initializeStream', @@ -1161,11 +1159,7 @@ export class Firestore { lifetime.resolve(); } - backendStream.on('end', () => streamEnded()); - backendStream.on('close', () => streamEnded()); - backendStream.on('finish', () => streamEnded()); - - backendStream.on('error', err => { + function streamFailed(err: Error) { if (!streamInitialized) { // If we receive an error before we were able to receive any data, // reject this stream. @@ -1191,7 +1185,13 @@ export class Firestore { resultStream.emit('error', err); }); } - }); + } + + backendStream.on('data', () => streamReady()); + backendStream.on('error', err => streamFailed(err)); + backendStream.on('end', () => streamEnded()); + backendStream.on('close', () => streamEnded()); + backendStream.on('finish', () => streamEnded()); backendStream.pipe(resultStream); @@ -1202,13 +1202,17 @@ export class Firestore { 'Sending request: %j', request ); - backendStream.write(request, 'utf-8', () => { - logger( - 'Firestore._initializeStream', - requestTag, - 'Marking stream as healthy' - ); - streamReady(); + backendStream.write(request, 'utf-8', err => { + if (err) { + streamFailed(err); + } else { + logger( + 'Firestore._initializeStream', + requestTag, + 'Marking stream as healthy' + ); + streamReady(); + } }); } }); From aac02f463ba13c385a6dc5a4d96e281e0801cc93 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 29 Jan 2020 11:46:47 -0800 Subject: [PATCH 052/337] fix: better parameter naming in path template helpers --- dev/src/v1/firestore_admin_client.ts | 28 +-- dev/synth.metadata | 299 ++++++++++++++++++++++++++- 2 files changed, 310 insertions(+), 17 deletions(-) diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index 57e3ec599..cca2b24f1 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -1263,7 +1263,7 @@ export class FirestoreAdminClient { // -------------------- /** - * Return a fully-qualified collectiongroup resource name string. + * Return a fully-qualified collectionGroup resource name string. * * @param {string} project * @param {string} database @@ -1271,7 +1271,7 @@ export class FirestoreAdminClient { * @returns {string} Resource name string. */ collectionGroupPath(project: string, database: string, collection: string) { - return this._pathTemplates.collectiongroupPathTemplate.render({ + return this._pathTemplates.collectionGroupPathTemplate.render({ project, database, collection, @@ -1281,39 +1281,39 @@ export class FirestoreAdminClient { /** * Parse the project from CollectionGroup resource. * - * @param {string} collectiongroupName + * @param {string} collectionGroupName * A fully-qualified path representing CollectionGroup resource. * @returns {string} A string representing the project. */ - matchProjectFromCollectionGroupName(collectiongroupName: string) { - return this._pathTemplates.collectiongroupPathTemplate.match( - collectiongroupName + matchProjectFromCollectionGroupName(collectionGroupName: string) { + return this._pathTemplates.collectionGroupPathTemplate.match( + collectionGroupName ).project; } /** * Parse the database from CollectionGroup resource. * - * @param {string} collectiongroupName + * @param {string} collectionGroupName * A fully-qualified path representing CollectionGroup resource. * @returns {string} A string representing the database. */ - matchDatabaseFromCollectionGroupName(collectiongroupName: string) { - return this._pathTemplates.collectiongroupPathTemplate.match( - collectiongroupName + matchDatabaseFromCollectionGroupName(collectionGroupName: string) { + return this._pathTemplates.collectionGroupPathTemplate.match( + collectionGroupName ).database; } /** * Parse the collection from CollectionGroup resource. * - * @param {string} collectiongroupName + * @param {string} collectionGroupName * A fully-qualified path representing CollectionGroup resource. * @returns {string} A string representing the collection. */ - matchCollectionFromCollectionGroupName(collectiongroupName: string) { - return this._pathTemplates.collectiongroupPathTemplate.match( - collectiongroupName + matchCollectionFromCollectionGroupName(collectionGroupName: string) { + return this._pathTemplates.collectionGroupPathTemplate.match( + collectionGroupName ).collection; } diff --git a/dev/synth.metadata b/dev/synth.metadata index b684fbe81..f755bb76d 100644 --- a/dev/synth.metadata +++ b/dev/synth.metadata @@ -1,12 +1,12 @@ { - "updateTime": "2020-01-15T12:19:38.399076Z", + "updateTime": "2020-01-29T12:21:39.064044Z", "sources": [ { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "d99df0d67057a233c711187e0689baa4f8e6333d", - "internalRef": "289709813" + "sha": "cf3b61102ed5f36b827bc82ec39be09525f018c8", + "internalRef": "292034635" } }, { @@ -45,5 +45,298 @@ "generator": "gapic-generator-typescript" } } + ], + "newFiles": [ + { + "path": "conformance/.eslintrc.yml" + }, + { + "path": "conformance/runner.ts" + }, + { + "path": "conformance/test-definition.proto" + }, + { + "path": "conformance/test-suite.binproto" + }, + { + "path": "protos/firestore_admin_v1_proto_api.d.ts" + }, + { + "path": "protos/firestore_admin_v1_proto_api.js" + }, + { + "path": "protos/firestore_v1_proto_api.d.ts" + }, + { + "path": "protos/firestore_v1_proto_api.js" + }, + { + "path": "protos/firestore_v1beta1_proto_api.d.ts" + }, + { + "path": "protos/firestore_v1beta1_proto_api.js" + }, + { + "path": "protos/google/api/annotations.proto" + }, + { + "path": "protos/google/api/client.proto" + }, + { + "path": "protos/google/api/field_behavior.proto" + }, + { + "path": "protos/google/api/http.proto" + }, + { + "path": "protos/google/api/resource.proto" + }, + { + "path": "protos/google/firestore/admin/v1/field.proto" + }, + { + "path": "protos/google/firestore/admin/v1/firestore_admin.proto" + }, + { + "path": "protos/google/firestore/admin/v1/index.proto" + }, + { + "path": "protos/google/firestore/admin/v1/location.proto" + }, + { + "path": "protos/google/firestore/admin/v1/operation.proto" + }, + { + "path": "protos/google/firestore/v1/common.proto" + }, + { + "path": "protos/google/firestore/v1/document.proto" + }, + { + "path": "protos/google/firestore/v1/firestore.proto" + }, + { + "path": "protos/google/firestore/v1/query.proto" + }, + { + "path": "protos/google/firestore/v1/write.proto" + }, + { + "path": "protos/google/firestore/v1beta1/common.proto" + }, + { + "path": "protos/google/firestore/v1beta1/document.proto" + }, + { + "path": "protos/google/firestore/v1beta1/firestore.proto" + }, + { + "path": "protos/google/firestore/v1beta1/query.proto" + }, + { + "path": "protos/google/firestore/v1beta1/write.proto" + }, + { + "path": "protos/google/longrunning/operations.proto" + }, + { + "path": "protos/google/protobuf/any.proto" + }, + { + "path": "protos/google/protobuf/empty.proto" + }, + { + "path": "protos/google/protobuf/field_mask.proto" + }, + { + "path": "protos/google/protobuf/struct.proto" + }, + { + "path": "protos/google/protobuf/timestamp.proto" + }, + { + "path": "protos/google/protobuf/wrappers.proto" + }, + { + "path": "protos/google/rpc/status.proto" + }, + { + "path": "protos/google/type/latlng.proto" + }, + { + "path": "protos/protos.json" + }, + { + "path": "protos/update.sh" + }, + { + "path": "src/backoff.ts" + }, + { + "path": "src/convert.ts" + }, + { + "path": "src/document-change.ts" + }, + { + "path": "src/document.ts" + }, + { + "path": "src/external-modules.d.ts" + }, + { + "path": "src/field-value.ts" + }, + { + "path": "src/geo-point.ts" + }, + { + "path": "src/index.ts" + }, + { + "path": "src/logger.ts" + }, + { + "path": "src/order.ts" + }, + { + "path": "src/path.ts" + }, + { + "path": "src/pool.ts" + }, + { + "path": "src/reference.ts" + }, + { + "path": "src/serializer.ts" + }, + { + "path": "src/timestamp.ts" + }, + { + "path": "src/transaction.ts" + }, + { + "path": "src/types.ts" + }, + { + "path": "src/util.ts" + }, + { + "path": "src/v1/firestore_admin_client.ts" + }, + { + "path": "src/v1/firestore_admin_client_config.json" + }, + { + "path": "src/v1/firestore_admin_proto_list.json" + }, + { + "path": "src/v1/firestore_client.ts" + }, + { + "path": "src/v1/firestore_client_config.json" + }, + { + "path": "src/v1/firestore_proto_list.json" + }, + { + "path": "src/v1/index.ts" + }, + { + "path": "src/v1beta1/firestore_client.ts" + }, + { + "path": "src/v1beta1/firestore_client_config.json" + }, + { + "path": "src/v1beta1/firestore_proto_list.json" + }, + { + "path": "src/v1beta1/index.ts" + }, + { + "path": "src/validate.ts" + }, + { + "path": "src/watch.ts" + }, + { + "path": "src/write-batch.ts" + }, + { + "path": "synth.metadata" + }, + { + "path": "system-test/.eslintrc.yml" + }, + { + "path": "system-test/.gitignore" + }, + { + "path": "system-test/firestore.ts" + }, + { + "path": "test/backoff.ts" + }, + { + "path": "test/collection.ts" + }, + { + "path": "test/document.ts" + }, + { + "path": "test/field-value.ts" + }, + { + "path": "test/gapic-firestore-v1.ts" + }, + { + "path": "test/gapic-firestore-v1beta1.ts" + }, + { + "path": "test/gapic-firestore_admin-v1.ts" + }, + { + "path": "test/index.ts" + }, + { + "path": "test/mocha.opts" + }, + { + "path": "test/order.ts" + }, + { + "path": "test/path.ts" + }, + { + "path": "test/pool.ts" + }, + { + "path": "test/query.ts" + }, + { + "path": "test/timestamp.ts" + }, + { + "path": "test/transaction.ts" + }, + { + "path": "test/typescript.ts" + }, + { + "path": "test/util.ts" + }, + { + "path": "test/util/helpers.ts" + }, + { + "path": "test/watch.ts" + }, + { + "path": "test/write-batch.ts" + } ] } \ No newline at end of file From eb14aa99e1bcc5ad1e44d74f496e0df3624ad75d Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 30 Jan 2020 16:34:16 +0100 Subject: [PATCH 053/337] chore(deps): update dependency @types/mocha to v7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2ddebeb22..cc0a117b0 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@types/chai-as-promised": "^7.1.2", "@types/duplexify": "^3.5.0", "@types/extend": "^3.0.0", - "@types/mocha": "^5.2.3", + "@types/mocha": "^7.0.0", "@types/moment": "^2.13.0", "@types/node": "^12.12.17", "@types/through2": "^2.0.34", From 4254edb04480033c7dc3b455b9c644cc6dccab6b Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Fri, 31 Jan 2020 12:00:31 -0800 Subject: [PATCH 054/337] docs: update documentation for preconditions (#904) --- dev/src/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index 8b3749632..ef660dc8b 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -187,8 +187,9 @@ const MAX_CONCURRENT_REQUESTS_PER_CLIENT = 100; * return documentRef.delete({ lastUpdateTime: updateTime }); * }); * - * @property {string} lastUpdateTime The update time to enforce (specified as - * an ISO 8601 string). + * @property {Timestamp} lastUpdateTime The update time to enforce. If set, + * enforces that the document was last updated at lastUpdateTime. Fails the + * operation if the document was last updated at a different time. * @typedef {Object} Precondition */ From 68e60437c3f75ddce5b1bfaa5a880e2614730919 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Fri, 31 Jan 2020 17:22:45 -0800 Subject: [PATCH 055/337] chore: skip img.shields.io in docs test --- linkinator.config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linkinator.config.json b/linkinator.config.json index d780d6bff..b555215ca 100644 --- a/linkinator.config.json +++ b/linkinator.config.json @@ -2,6 +2,7 @@ "recurse": true, "skip": [ "https://codecov.io/gh/googleapis/", - "www.googleapis.com" + "www.googleapis.com", + "img.shields.io" ] } From ad1c4593277c32af0bb38272b600a07b6c5086aa Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Fri, 31 Jan 2020 19:01:47 -0800 Subject: [PATCH 056/337] test: modernize mocha config (#905) --- .mocharc.json | 5 +++++ dev/test/mocha.opts | 4 +--- package.json | 4 ---- 3 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 .mocharc.json diff --git a/.mocharc.json b/.mocharc.json new file mode 100644 index 000000000..670c5e2c2 --- /dev/null +++ b/.mocharc.json @@ -0,0 +1,5 @@ +{ + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} diff --git a/dev/test/mocha.opts b/dev/test/mocha.opts index f2202f83e..086387a23 100644 --- a/dev/test/mocha.opts +++ b/dev/test/mocha.opts @@ -1,5 +1,3 @@ ---require hard-rejection/register ---require source-map-support/register ---require intelli-espower-loader +--enable-source-maps --timeout 2000 --throw-deprecation diff --git a/package.json b/package.json index cc0a117b0..656281fc6 100644 --- a/package.json +++ b/package.json @@ -71,17 +71,13 @@ "duplexify": "^4.0.0", "extend": "^3.0.2", "gts": "^1.1.2", - "hard-rejection": "^2.0.0", - "intelli-espower-loader": "^1.0.1", "jsdoc": "^3.6.2", "jsdoc-fresh": "^1.0.2", "jsdoc-region-tag": "^1.0.2", "linkinator": "^1.8.0", "mocha": "^7.0.0", - "power-assert": "^1.6.1", "protobufjs": "^6.8.6", "proxyquire": "^2.1.3", - "source-map-support": "^0.5.16", "ts-node": "^8.5.4", "typescript": "3.6.4" } From c5b9442e6620e59e5563ffaf210ad493ec5ed9b2 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Thu, 6 Feb 2020 15:05:44 -0800 Subject: [PATCH 057/337] fix: add missing generics on query (#917) --- types/firestore.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/firestore.d.ts b/types/firestore.d.ts index e8b4ee060..e50671e69 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -1022,7 +1022,7 @@ declare namespace FirebaseFirestore { * * @return A Promise that will be resolved with the results of the Query. */ - get(): Promise; + get(): Promise>; /* * Executes the query and returns the results as Node Stream. @@ -1041,7 +1041,7 @@ declare namespace FirebaseFirestore { * @return An unsubscribe function that can be called to cancel * the snapshot listener. */ - onSnapshot(onNext: (snapshot: QuerySnapshot) => void, + onSnapshot(onNext: (snapshot: QuerySnapshot) => void, onError?: (error: Error) => void) : () => void; /** @@ -1050,7 +1050,7 @@ declare namespace FirebaseFirestore { * @param other The `Query` to compare against. * @return true if this `Query` is equal to the provided one. */ - isEqual(other: Query): boolean; + isEqual(other: Query): boolean; /** * Applies a custom data converter to this Query, allowing you to use your From 7d9738456525b99507b8819d86a8634b0a1d04c3 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Thu, 6 Feb 2020 17:10:34 -0800 Subject: [PATCH 058/337] feat: add google-gax status to exports (#912) --- dev/src/index.ts | 1 + dev/test/typescript.ts | 5 +++++ types/firestore.d.ts | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/dev/src/index.ts b/dev/src/index.ts index ef660dc8b..35f06fd09 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -91,6 +91,7 @@ export { Precondition, SetOptions, } from './types'; +export {Status as GrpcStatus} from 'google-gax'; const libVersion = require('../../package.json').version; setLibVersion(libVersion); diff --git a/dev/test/typescript.ts b/dev/test/typescript.ts index 33c59db98..ee3845c9b 100644 --- a/dev/test/typescript.ts +++ b/dev/test/typescript.ts @@ -34,6 +34,7 @@ import SetOptions = FirebaseFirestore.SetOptions; import FirestoreDataConverter = FirebaseFirestore.FirestoreDataConverter; import Timestamp = FirebaseFirestore.Timestamp; import Settings = FirebaseFirestore.Settings; +import GrpcStatus = FirebaseFirestore.GrpcStatus; // This test verifies the Typescript typings and is not meant for execution. xdescribe('firestore.d.ts', () => { @@ -352,4 +353,8 @@ xdescribe('firestore.d.ts', () => { const seconds: number = timestamp.seconds; const nanoseconds: number = timestamp.nanoseconds; }); + + it('has typings for GrpcStatus', () => { + const status = GrpcStatus.ABORTED; + }); }); diff --git a/types/firestore.d.ts b/types/firestore.d.ts index e50671e69..e338106d7 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -1452,6 +1452,29 @@ declare namespace FirebaseFirestore { * API and the underlying Firestore v1 RPCs. */ export const v1: {FirestoreClient: any, FirestoreAdminClient: any}; + + /** + * Status codes returned by Firestore's gRPC calls. + */ + export enum GrpcStatus { + OK = 0, + CANCELLED = 1, + UNKNOWN = 2, + INVALID_ARGUMENT = 3, + DEADLINE_EXCEEDED = 4, + NOT_FOUND = 5, + ALREADY_EXISTS = 6, + PERMISSION_DENIED = 7, + RESOURCE_EXHAUSTED = 8, + FAILED_PRECONDITION = 9, + ABORTED = 10, + OUT_OF_RANGE = 11, + UNIMPLEMENTED = 12, + INTERNAL = 13, + UNAVAILABLE = 14, + DATA_LOSS = 15, + UNAUTHENTICATED = 16 + } } declare module '@google-cloud/firestore' { From 864d77b9db3bade8c6d77c09974ae88da9450c35 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 6 Feb 2020 21:16:07 -0800 Subject: [PATCH 059/337] chore: release 3.5.0 (#918) --- CHANGELOG.md | 14 ++++++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37346b88e..34a217b1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [3.5.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.4.1...v3.5.0) (2020-02-07) + + +### Features + +* add google-gax status to exports ([#912](https://www.github.com/googleapis/nodejs-firestore/issues/912)) ([7d97384](https://www.github.com/googleapis/nodejs-firestore/commit/7d9738456525b99507b8819d86a8634b0a1d04c3)) + + +### Bug Fixes + +* add missing generics on query ([#917](https://www.github.com/googleapis/nodejs-firestore/issues/917)) ([c5b9442](https://www.github.com/googleapis/nodejs-firestore/commit/c5b9442e6620e59e5563ffaf210ad493ec5ed9b2)) +* better parameter naming in path template helpers ([aac02f4](https://www.github.com/googleapis/nodejs-firestore/commit/aac02f463ba13c385a6dc5a4d96e281e0801cc93)) +* retry streaming methods if initial write errored ([#897](https://www.github.com/googleapis/nodejs-firestore/issues/897)) ([2ec0489](https://www.github.com/googleapis/nodejs-firestore/commit/2ec0489127faea88dca95e6dc169efe6e55d330d)) + ### [3.4.1](https://www.github.com/googleapis/nodejs-firestore/compare/v3.4.0...v3.4.1) (2020-01-22) diff --git a/package.json b/package.json index 656281fc6..c58ae8879 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.4.1", + "version": "3.5.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 39bc06ae6..0b69351c0 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.4.1" + "@google-cloud/firestore": "^3.5.0" }, "devDependencies": { "chai": "^4.2.0", From cfbe19ed4c3cc6bb9ffc7b352de901150b8b9dea Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 7 Feb 2020 11:46:15 -0800 Subject: [PATCH 060/337] fix: pass x-goog-request-params header for streaming calls (#920) * [CHANGE ME] Re-generated to pick up changes in the API or client library generator. * fix: make bidi streaming work Co-authored-by: Alexander Fenster --- dev/.gitignore | 14 + dev/.mocharc.json | 5 + dev/protos/protos.json | 2488 ++++++++++---------- dev/src/v1/firestore_admin_client.ts | 146 +- dev/src/v1/firestore_admin_proto_list.json | 2 +- dev/src/v1/firestore_client.ts | 36 +- dev/src/v1/firestore_proto_list.json | 4 +- dev/src/v1beta1/firestore_client.ts | 36 +- dev/src/v1beta1/firestore_proto_list.json | 4 +- dev/synth.metadata | 211 +- dev/test/gapic-firestore-v1.ts | 24 +- dev/test/gapic-firestore-v1beta1.ts | 24 +- dev/test/gapic-firestore_admin-v1.ts | 24 +- 13 files changed, 1478 insertions(+), 1540 deletions(-) create mode 100644 dev/.gitignore create mode 100644 dev/.mocharc.json diff --git a/dev/.gitignore b/dev/.gitignore new file mode 100644 index 000000000..5d32b2378 --- /dev/null +++ b/dev/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/dev/.mocharc.json b/dev/.mocharc.json new file mode 100644 index 000000000..670c5e2c2 --- /dev/null +++ b/dev/.mocharc.json @@ -0,0 +1,5 @@ +{ + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} diff --git a/dev/protos/protos.json b/dev/protos/protos.json index 43a9cfaad..6e4359b9d 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -19,6 +19,45 @@ "(google.api.resource_definition).pattern": "projects/{project}/databases/{database}/collectionGroups/{collection}" }, "nested": { + "Field": { + "options": { + "(google.api.resource).type": "firestore.googleapis.com/Field", + "(google.api.resource).pattern": "projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}" + }, + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "indexConfig": { + "type": "IndexConfig", + "id": 2 + } + }, + "nested": { + "IndexConfig": { + "fields": { + "indexes": { + "rule": "repeated", + "type": "Index", + "id": 1 + }, + "usesAncestorConfig": { + "type": "bool", + "id": 2 + }, + "ancestorField": { + "type": "string", + "id": 3 + }, + "reverting": { + "type": "bool", + "id": 4 + } + } + } + } + }, "Index": { "options": { "(google.api.resource).type": "firestore.googleapis.com/Index", @@ -100,45 +139,6 @@ } } }, - "Field": { - "options": { - "(google.api.resource).type": "firestore.googleapis.com/Field", - "(google.api.resource).pattern": "projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}" - }, - "fields": { - "name": { - "type": "string", - "id": 1 - }, - "indexConfig": { - "type": "IndexConfig", - "id": 2 - } - }, - "nested": { - "IndexConfig": { - "fields": { - "indexes": { - "rule": "repeated", - "type": "Index", - "id": 1 - }, - "usesAncestorConfig": { - "type": "bool", - "id": 2 - }, - "ancestorField": { - "type": "string", - "id": 3 - }, - "reverting": { - "type": "bool", - "id": 4 - } - } - } - } - }, "FirestoreAdmin": { "options": { "(google.api.default_host)": "firestore.googleapis.com", @@ -611,7 +611,7 @@ "csharp_namespace": "Google.Cloud.Firestore.V1", "go_package": "google.golang.org/genproto/googleapis/firestore/v1;firestore", "java_multiple_files": true, - "java_outer_classname": "FirestoreProto", + "java_outer_classname": "WriteProto", "java_package": "com.google.firestore.v1", "objc_class_prefix": "GCFS", "php_namespace": "Google\\Cloud\\Firestore\\V1" @@ -795,771 +795,388 @@ } } }, - "Write": { + "Firestore": { + "options": { + "(google.api.default_host)": "firestore.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/datastore" + }, + "methods": { + "GetDocument": { + "requestType": "GetDocumentRequest", + "responseType": "Document", + "options": { + "(google.api.http).get": "/v1/{name=projects/*/databases/*/documents/*/**}" + } + }, + "ListDocuments": { + "requestType": "ListDocumentsRequest", + "responseType": "ListDocumentsResponse", + "options": { + "(google.api.http).get": "/v1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" + } + }, + "CreateDocument": { + "requestType": "CreateDocumentRequest", + "responseType": "Document", + "options": { + "(google.api.http).post": "/v1/{parent=projects/*/databases/*/documents/**}/{collection_id}", + "(google.api.http).body": "document" + } + }, + "UpdateDocument": { + "requestType": "UpdateDocumentRequest", + "responseType": "Document", + "options": { + "(google.api.http).patch": "/v1/{document.name=projects/*/databases/*/documents/*/**}", + "(google.api.http).body": "document", + "(google.api.method_signature)": "document,update_mask" + } + }, + "DeleteDocument": { + "requestType": "DeleteDocumentRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v1/{name=projects/*/databases/*/documents/*/**}", + "(google.api.method_signature)": "name" + } + }, + "BatchGetDocuments": { + "requestType": "BatchGetDocumentsRequest", + "responseType": "BatchGetDocumentsResponse", + "responseStream": true, + "options": { + "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:batchGet", + "(google.api.http).body": "*" + } + }, + "BeginTransaction": { + "requestType": "BeginTransactionRequest", + "responseType": "BeginTransactionResponse", + "options": { + "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:beginTransaction", + "(google.api.http).body": "*", + "(google.api.method_signature)": "database" + } + }, + "Commit": { + "requestType": "CommitRequest", + "responseType": "CommitResponse", + "options": { + "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:commit", + "(google.api.http).body": "*", + "(google.api.method_signature)": "database,writes" + } + }, + "Rollback": { + "requestType": "RollbackRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:rollback", + "(google.api.http).body": "*", + "(google.api.method_signature)": "database,transaction" + } + }, + "RunQuery": { + "requestType": "RunQueryRequest", + "responseType": "RunQueryResponse", + "responseStream": true, + "options": { + "(google.api.http).post": "/v1/{parent=projects/*/databases/*/documents}:runQuery", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v1/{parent=projects/*/databases/*/documents/*/**}:runQuery", + "(google.api.http).additional_bindings.body": "*" + } + }, + "Write": { + "requestType": "WriteRequest", + "requestStream": true, + "responseType": "WriteResponse", + "responseStream": true, + "options": { + "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:write", + "(google.api.http).body": "*" + } + }, + "Listen": { + "requestType": "ListenRequest", + "requestStream": true, + "responseType": "ListenResponse", + "responseStream": true, + "options": { + "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:listen", + "(google.api.http).body": "*" + } + }, + "ListCollectionIds": { + "requestType": "ListCollectionIdsRequest", + "responseType": "ListCollectionIdsResponse", + "options": { + "(google.api.http).post": "/v1/{parent=projects/*/databases/*/documents}:listCollectionIds", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds", + "(google.api.http).additional_bindings.body": "*", + "(google.api.method_signature)": "parent" + } + } + } + }, + "GetDocumentRequest": { "oneofs": { - "operation": { + "consistencySelector": { "oneof": [ - "update", - "delete", - "transform" + "transaction", + "readTime" ] } }, "fields": { - "update": { - "type": "Document", - "id": 1 - }, - "delete": { + "name": { "type": "string", - "id": 2 - }, - "transform": { - "type": "DocumentTransform", - "id": 6 + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "updateMask": { + "mask": { "type": "DocumentMask", + "id": 2 + }, + "transaction": { + "type": "bytes", "id": 3 }, - "currentDocument": { - "type": "Precondition", - "id": 4 + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 5 } } }, - "DocumentTransform": { + "ListDocumentsRequest": { + "oneofs": { + "consistencySelector": { + "oneof": [ + "transaction", + "readTime" + ] + } + }, "fields": { - "document": { + "parent": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "fieldTransforms": { - "rule": "repeated", - "type": "FieldTransform", - "id": 2 - } - }, - "nested": { - "FieldTransform": { - "oneofs": { - "transformType": { - "oneof": [ - "setToServerValue", - "increment", - "maximum", - "minimum", - "appendMissingElements", - "removeAllFromArray" - ] - } - }, - "fields": { - "fieldPath": { - "type": "string", - "id": 1 - }, - "setToServerValue": { - "type": "ServerValue", - "id": 2 - }, - "increment": { - "type": "Value", - "id": 3 - }, - "maximum": { - "type": "Value", - "id": 4 - }, - "minimum": { - "type": "Value", - "id": 5 - }, - "appendMissingElements": { - "type": "ArrayValue", - "id": 6 - }, - "removeAllFromArray": { - "type": "ArrayValue", - "id": 7 - } - }, - "nested": { - "ServerValue": { - "values": { - "SERVER_VALUE_UNSPECIFIED": 0, - "REQUEST_TIME": 1 - } - } + "collectionId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" } + }, + "pageSize": { + "type": "int32", + "id": 3 + }, + "pageToken": { + "type": "string", + "id": 4 + }, + "orderBy": { + "type": "string", + "id": 6 + }, + "mask": { + "type": "DocumentMask", + "id": 7 + }, + "transaction": { + "type": "bytes", + "id": 8 + }, + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 10 + }, + "showMissing": { + "type": "bool", + "id": 12 } } }, - "WriteResult": { + "ListDocumentsResponse": { "fields": { - "updateTime": { - "type": "google.protobuf.Timestamp", + "documents": { + "rule": "repeated", + "type": "Document", "id": 1 }, - "transformResults": { - "rule": "repeated", - "type": "Value", + "nextPageToken": { + "type": "string", "id": 2 } } }, - "DocumentChange": { + "CreateDocumentRequest": { "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "collectionId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "documentId": { + "type": "string", + "id": 3 + }, "document": { "type": "Document", - "id": 1 + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "targetIds": { - "rule": "repeated", - "type": "int32", + "mask": { + "type": "DocumentMask", "id": 5 - }, - "removedTargetIds": { - "rule": "repeated", - "type": "int32", - "id": 6 } } }, - "DocumentDelete": { + "UpdateDocumentRequest": { "fields": { "document": { + "type": "Document", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "DocumentMask", + "id": 2 + }, + "mask": { + "type": "DocumentMask", + "id": 3 + }, + "currentDocument": { + "type": "Precondition", + "id": 4 + } + } + }, + "DeleteDocumentRequest": { + "fields": { + "name": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "removedTargetIds": { + "currentDocument": { + "type": "Precondition", + "id": 2 + } + } + }, + "BatchGetDocumentsRequest": { + "oneofs": { + "consistencySelector": { + "oneof": [ + "transaction", + "newTransaction", + "readTime" + ] + } + }, + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "documents": { "rule": "repeated", - "type": "int32", - "id": 6 + "type": "string", + "id": 2 + }, + "mask": { + "type": "DocumentMask", + "id": 3 + }, + "transaction": { + "type": "bytes", + "id": 4 + }, + "newTransaction": { + "type": "TransactionOptions", + "id": 5 }, "readTime": { "type": "google.protobuf.Timestamp", - "id": 4 + "id": 7 } } }, - "DocumentRemove": { + "BatchGetDocumentsResponse": { + "oneofs": { + "result": { + "oneof": [ + "found", + "missing" + ] + } + }, "fields": { - "document": { - "type": "string", + "found": { + "type": "Document", "id": 1 }, - "removedTargetIds": { - "rule": "repeated", - "type": "int32", + "missing": { + "type": "string", "id": 2 }, + "transaction": { + "type": "bytes", + "id": 3 + }, "readTime": { "type": "google.protobuf.Timestamp", "id": 4 } } }, - "ExistenceFilter": { + "BeginTransactionRequest": { "fields": { - "targetId": { - "type": "int32", - "id": 1 + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } }, - "count": { - "type": "int32", + "options": { + "type": "TransactionOptions", "id": 2 } } }, - "StructuredQuery": { + "BeginTransactionResponse": { "fields": { - "select": { - "type": "Projection", - "id": 1 - }, - "from": { - "rule": "repeated", - "type": "CollectionSelector", - "id": 2 - }, - "where": { - "type": "Filter", - "id": 3 - }, - "orderBy": { - "rule": "repeated", - "type": "Order", - "id": 4 - }, - "startAt": { - "type": "Cursor", - "id": 7 - }, - "endAt": { - "type": "Cursor", - "id": 8 - }, - "offset": { - "type": "int32", - "id": 6 - }, - "limit": { - "type": "google.protobuf.Int32Value", - "id": 5 - } - }, - "nested": { - "CollectionSelector": { - "fields": { - "collectionId": { - "type": "string", - "id": 2 - }, - "allDescendants": { - "type": "bool", - "id": 3 - } - } - }, - "Filter": { - "oneofs": { - "filterType": { - "oneof": [ - "compositeFilter", - "fieldFilter", - "unaryFilter" - ] - } - }, - "fields": { - "compositeFilter": { - "type": "CompositeFilter", - "id": 1 - }, - "fieldFilter": { - "type": "FieldFilter", - "id": 2 - }, - "unaryFilter": { - "type": "UnaryFilter", - "id": 3 - } - } - }, - "CompositeFilter": { - "fields": { - "op": { - "type": "Operator", - "id": 1 - }, - "filters": { - "rule": "repeated", - "type": "Filter", - "id": 2 - } - }, - "nested": { - "Operator": { - "values": { - "OPERATOR_UNSPECIFIED": 0, - "AND": 1 - } - } - } - }, - "FieldFilter": { - "fields": { - "field": { - "type": "FieldReference", - "id": 1 - }, - "op": { - "type": "Operator", - "id": 2 - }, - "value": { - "type": "Value", - "id": 3 - } - }, - "nested": { - "Operator": { - "values": { - "OPERATOR_UNSPECIFIED": 0, - "LESS_THAN": 1, - "LESS_THAN_OR_EQUAL": 2, - "GREATER_THAN": 3, - "GREATER_THAN_OR_EQUAL": 4, - "EQUAL": 5, - "ARRAY_CONTAINS": 7, - "IN": 8, - "ARRAY_CONTAINS_ANY": 9 - } - } - } - }, - "UnaryFilter": { - "oneofs": { - "operandType": { - "oneof": [ - "field" - ] - } - }, - "fields": { - "op": { - "type": "Operator", - "id": 1 - }, - "field": { - "type": "FieldReference", - "id": 2 - } - }, - "nested": { - "Operator": { - "values": { - "OPERATOR_UNSPECIFIED": 0, - "IS_NAN": 2, - "IS_NULL": 3 - } - } - } - }, - "Order": { - "fields": { - "field": { - "type": "FieldReference", - "id": 1 - }, - "direction": { - "type": "Direction", - "id": 2 - } - } - }, - "FieldReference": { - "fields": { - "fieldPath": { - "type": "string", - "id": 2 - } - } - }, - "Projection": { - "fields": { - "fields": { - "rule": "repeated", - "type": "FieldReference", - "id": 2 - } - } - }, - "Direction": { - "values": { - "DIRECTION_UNSPECIFIED": 0, - "ASCENDING": 1, - "DESCENDING": 2 - } - } - } - }, - "Cursor": { - "fields": { - "values": { - "rule": "repeated", - "type": "Value", - "id": 1 - }, - "before": { - "type": "bool", - "id": 2 - } - } - }, - "Firestore": { - "options": { - "(google.api.default_host)": "firestore.googleapis.com", - "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/datastore" - }, - "methods": { - "GetDocument": { - "requestType": "GetDocumentRequest", - "responseType": "Document", - "options": { - "(google.api.http).get": "/v1/{name=projects/*/databases/*/documents/*/**}" - } - }, - "ListDocuments": { - "requestType": "ListDocumentsRequest", - "responseType": "ListDocumentsResponse", - "options": { - "(google.api.http).get": "/v1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" - } - }, - "CreateDocument": { - "requestType": "CreateDocumentRequest", - "responseType": "Document", - "options": { - "(google.api.http).post": "/v1/{parent=projects/*/databases/*/documents/**}/{collection_id}", - "(google.api.http).body": "document" - } - }, - "UpdateDocument": { - "requestType": "UpdateDocumentRequest", - "responseType": "Document", - "options": { - "(google.api.http).patch": "/v1/{document.name=projects/*/databases/*/documents/*/**}", - "(google.api.http).body": "document", - "(google.api.method_signature)": "document,update_mask" - } - }, - "DeleteDocument": { - "requestType": "DeleteDocumentRequest", - "responseType": "google.protobuf.Empty", - "options": { - "(google.api.http).delete": "/v1/{name=projects/*/databases/*/documents/*/**}", - "(google.api.method_signature)": "name" - } - }, - "BatchGetDocuments": { - "requestType": "BatchGetDocumentsRequest", - "responseType": "BatchGetDocumentsResponse", - "responseStream": true, - "options": { - "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:batchGet", - "(google.api.http).body": "*" - } - }, - "BeginTransaction": { - "requestType": "BeginTransactionRequest", - "responseType": "BeginTransactionResponse", - "options": { - "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:beginTransaction", - "(google.api.http).body": "*", - "(google.api.method_signature)": "database" - } - }, - "Commit": { - "requestType": "CommitRequest", - "responseType": "CommitResponse", - "options": { - "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:commit", - "(google.api.http).body": "*", - "(google.api.method_signature)": "database,writes" - } - }, - "Rollback": { - "requestType": "RollbackRequest", - "responseType": "google.protobuf.Empty", - "options": { - "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:rollback", - "(google.api.http).body": "*", - "(google.api.method_signature)": "database,transaction" - } - }, - "RunQuery": { - "requestType": "RunQueryRequest", - "responseType": "RunQueryResponse", - "responseStream": true, - "options": { - "(google.api.http).post": "/v1/{parent=projects/*/databases/*/documents}:runQuery", - "(google.api.http).body": "*", - "(google.api.http).additional_bindings.post": "/v1/{parent=projects/*/databases/*/documents/*/**}:runQuery", - "(google.api.http).additional_bindings.body": "*" - } - }, - "Write": { - "requestType": "WriteRequest", - "requestStream": true, - "responseType": "WriteResponse", - "responseStream": true, - "options": { - "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:write", - "(google.api.http).body": "*" - } - }, - "Listen": { - "requestType": "ListenRequest", - "requestStream": true, - "responseType": "ListenResponse", - "responseStream": true, - "options": { - "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:listen", - "(google.api.http).body": "*" - } - }, - "ListCollectionIds": { - "requestType": "ListCollectionIdsRequest", - "responseType": "ListCollectionIdsResponse", - "options": { - "(google.api.http).post": "/v1/{parent=projects/*/databases/*/documents}:listCollectionIds", - "(google.api.http).body": "*", - "(google.api.http).additional_bindings.post": "/v1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds", - "(google.api.http).additional_bindings.body": "*", - "(google.api.method_signature)": "parent" - } - } - } - }, - "GetDocumentRequest": { - "oneofs": { - "consistencySelector": { - "oneof": [ - "transaction", - "readTime" - ] - } - }, - "fields": { - "name": { - "type": "string", - "id": 1, - "options": { - "(google.api.field_behavior)": "REQUIRED" - } - }, - "mask": { - "type": "DocumentMask", - "id": 2 - }, - "transaction": { - "type": "bytes", - "id": 3 - }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 5 - } - } - }, - "ListDocumentsRequest": { - "oneofs": { - "consistencySelector": { - "oneof": [ - "transaction", - "readTime" - ] - } - }, - "fields": { - "parent": { - "type": "string", - "id": 1, - "options": { - "(google.api.field_behavior)": "REQUIRED" - } - }, - "collectionId": { - "type": "string", - "id": 2, - "options": { - "(google.api.field_behavior)": "REQUIRED" - } - }, - "pageSize": { - "type": "int32", - "id": 3 - }, - "pageToken": { - "type": "string", - "id": 4 - }, - "orderBy": { - "type": "string", - "id": 6 - }, - "mask": { - "type": "DocumentMask", - "id": 7 - }, - "transaction": { - "type": "bytes", - "id": 8 - }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 10 - }, - "showMissing": { - "type": "bool", - "id": 12 - } - } - }, - "ListDocumentsResponse": { - "fields": { - "documents": { - "rule": "repeated", - "type": "Document", - "id": 1 - }, - "nextPageToken": { - "type": "string", - "id": 2 - } - } - }, - "CreateDocumentRequest": { - "fields": { - "parent": { - "type": "string", - "id": 1, - "options": { - "(google.api.field_behavior)": "REQUIRED" - } - }, - "collectionId": { - "type": "string", - "id": 2, - "options": { - "(google.api.field_behavior)": "REQUIRED" - } - }, - "documentId": { - "type": "string", - "id": 3 - }, - "document": { - "type": "Document", - "id": 4, - "options": { - "(google.api.field_behavior)": "REQUIRED" - } - }, - "mask": { - "type": "DocumentMask", - "id": 5 - } - } - }, - "UpdateDocumentRequest": { - "fields": { - "document": { - "type": "Document", - "id": 1, - "options": { - "(google.api.field_behavior)": "REQUIRED" - } - }, - "updateMask": { - "type": "DocumentMask", - "id": 2 - }, - "mask": { - "type": "DocumentMask", - "id": 3 - }, - "currentDocument": { - "type": "Precondition", - "id": 4 - } - } - }, - "DeleteDocumentRequest": { - "fields": { - "name": { - "type": "string", - "id": 1, - "options": { - "(google.api.field_behavior)": "REQUIRED" - } - }, - "currentDocument": { - "type": "Precondition", - "id": 2 - } - } - }, - "BatchGetDocumentsRequest": { - "oneofs": { - "consistencySelector": { - "oneof": [ - "transaction", - "newTransaction", - "readTime" - ] - } - }, - "fields": { - "database": { - "type": "string", - "id": 1, - "options": { - "(google.api.field_behavior)": "REQUIRED" - } - }, - "documents": { - "rule": "repeated", - "type": "string", - "id": 2 - }, - "mask": { - "type": "DocumentMask", - "id": 3 - }, - "transaction": { - "type": "bytes", - "id": 4 - }, - "newTransaction": { - "type": "TransactionOptions", - "id": 5 - }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 7 - } - } - }, - "BatchGetDocumentsResponse": { - "oneofs": { - "result": { - "oneof": [ - "found", - "missing" - ] - } - }, - "fields": { - "found": { - "type": "Document", - "id": 1 - }, - "missing": { - "type": "string", - "id": 2 - }, - "transaction": { - "type": "bytes", - "id": 3 - }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 4 - } - } - }, - "BeginTransactionRequest": { - "fields": { - "database": { - "type": "string", - "id": 1, - "options": { - "(google.api.field_behavior)": "REQUIRED" - } - }, - "options": { - "type": "TransactionOptions", - "id": 2 - } - } - }, - "BeginTransactionResponse": { - "fields": { - "transaction": { - "type": "bytes", + "transaction": { + "type": "bytes", "id": 1 } } @@ -1932,195 +1549,210 @@ "id": 2 } } - } - } - }, - "v1beta1": { - "options": { - "csharp_namespace": "Google.Cloud.Firestore.V1Beta1", - "go_package": "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore", - "java_multiple_files": true, - "java_outer_classname": "FirestoreProto", - "java_package": "com.google.firestore.v1beta1", - "objc_class_prefix": "GCFS", - "php_namespace": "Google\\Cloud\\Firestore\\V1beta1" - }, - "nested": { - "DocumentMask": { - "fields": { - "fieldPaths": { - "rule": "repeated", - "type": "string", - "id": 1 - } - } }, - "Precondition": { - "oneofs": { - "conditionType": { - "oneof": [ - "exists", - "updateTime" - ] - } - }, + "StructuredQuery": { "fields": { - "exists": { - "type": "bool", + "select": { + "type": "Projection", "id": 1 }, - "updateTime": { - "type": "google.protobuf.Timestamp", + "from": { + "rule": "repeated", + "type": "CollectionSelector", "id": 2 - } - } - }, - "TransactionOptions": { - "oneofs": { - "mode": { - "oneof": [ - "readOnly", - "readWrite" - ] + }, + "where": { + "type": "Filter", + "id": 3 + }, + "orderBy": { + "rule": "repeated", + "type": "Order", + "id": 4 + }, + "startAt": { + "type": "Cursor", + "id": 7 + }, + "endAt": { + "type": "Cursor", + "id": 8 + }, + "offset": { + "type": "int32", + "id": 6 + }, + "limit": { + "type": "google.protobuf.Int32Value", + "id": 5 } }, - "fields": { - "readOnly": { - "type": "ReadOnly", - "id": 2 + "nested": { + "CollectionSelector": { + "fields": { + "collectionId": { + "type": "string", + "id": 2 + }, + "allDescendants": { + "type": "bool", + "id": 3 + } + } + }, + "Filter": { + "oneofs": { + "filterType": { + "oneof": [ + "compositeFilter", + "fieldFilter", + "unaryFilter" + ] + } + }, + "fields": { + "compositeFilter": { + "type": "CompositeFilter", + "id": 1 + }, + "fieldFilter": { + "type": "FieldFilter", + "id": 2 + }, + "unaryFilter": { + "type": "UnaryFilter", + "id": 3 + } + } }, - "readWrite": { - "type": "ReadWrite", - "id": 3 - } - }, - "nested": { - "ReadWrite": { + "CompositeFilter": { "fields": { - "retryTransaction": { - "type": "bytes", + "op": { + "type": "Operator", + "id": 1 + }, + "filters": { + "rule": "repeated", + "type": "Filter", + "id": 2 + } + }, + "nested": { + "Operator": { + "values": { + "OPERATOR_UNSPECIFIED": 0, + "AND": 1 + } + } + } + }, + "FieldFilter": { + "fields": { + "field": { + "type": "FieldReference", "id": 1 + }, + "op": { + "type": "Operator", + "id": 2 + }, + "value": { + "type": "Value", + "id": 3 + } + }, + "nested": { + "Operator": { + "values": { + "OPERATOR_UNSPECIFIED": 0, + "LESS_THAN": 1, + "LESS_THAN_OR_EQUAL": 2, + "GREATER_THAN": 3, + "GREATER_THAN_OR_EQUAL": 4, + "EQUAL": 5, + "ARRAY_CONTAINS": 7, + "IN": 8, + "ARRAY_CONTAINS_ANY": 9 + } } } }, - "ReadOnly": { + "UnaryFilter": { "oneofs": { - "consistencySelector": { + "operandType": { "oneof": [ - "readTime" + "field" ] } }, "fields": { - "readTime": { - "type": "google.protobuf.Timestamp", + "op": { + "type": "Operator", + "id": 1 + }, + "field": { + "type": "FieldReference", "id": 2 } + }, + "nested": { + "Operator": { + "values": { + "OPERATOR_UNSPECIFIED": 0, + "IS_NAN": 2, + "IS_NULL": 3 + } + } } - } - } - }, - "Document": { - "fields": { - "name": { - "type": "string", - "id": 1 - }, - "fields": { - "keyType": "string", - "type": "Value", - "id": 2 - }, - "createTime": { - "type": "google.protobuf.Timestamp", - "id": 3 - }, - "updateTime": { - "type": "google.protobuf.Timestamp", - "id": 4 - } - } - }, - "Value": { - "oneofs": { - "valueType": { - "oneof": [ - "nullValue", - "booleanValue", - "integerValue", - "doubleValue", - "timestampValue", - "stringValue", - "bytesValue", - "referenceValue", - "geoPointValue", - "arrayValue", - "mapValue" - ] - } - }, - "fields": { - "nullValue": { - "type": "google.protobuf.NullValue", - "id": 11 - }, - "booleanValue": { - "type": "bool", - "id": 1 - }, - "integerValue": { - "type": "int64", - "id": 2 - }, - "doubleValue": { - "type": "double", - "id": 3 }, - "timestampValue": { - "type": "google.protobuf.Timestamp", - "id": 10 - }, - "stringValue": { - "type": "string", - "id": 17 - }, - "bytesValue": { - "type": "bytes", - "id": 18 - }, - "referenceValue": { - "type": "string", - "id": 5 + "Order": { + "fields": { + "field": { + "type": "FieldReference", + "id": 1 + }, + "direction": { + "type": "Direction", + "id": 2 + } + } }, - "geoPointValue": { - "type": "google.type.LatLng", - "id": 8 + "FieldReference": { + "fields": { + "fieldPath": { + "type": "string", + "id": 2 + } + } }, - "arrayValue": { - "type": "ArrayValue", - "id": 9 + "Projection": { + "fields": { + "fields": { + "rule": "repeated", + "type": "FieldReference", + "id": 2 + } + } }, - "mapValue": { - "type": "MapValue", - "id": 6 + "Direction": { + "values": { + "DIRECTION_UNSPECIFIED": 0, + "ASCENDING": 1, + "DESCENDING": 2 + } } } }, - "ArrayValue": { + "Cursor": { "fields": { "values": { "rule": "repeated", "type": "Value", "id": 1 - } - } - }, - "MapValue": { - "fields": { - "fields": { - "keyType": "string", - "type": "Value", - "id": 1 + }, + "before": { + "type": "bool", + "id": 2 } } }, @@ -2274,236 +1906,221 @@ }, "DocumentRemove": { "fields": { - "document": { + "document": { + "type": "string", + "id": 1 + }, + "removedTargetIds": { + "rule": "repeated", + "type": "int32", + "id": 2 + }, + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 4 + } + } + }, + "ExistenceFilter": { + "fields": { + "targetId": { + "type": "int32", + "id": 1 + }, + "count": { + "type": "int32", + "id": 2 + } + } + } + } + }, + "v1beta1": { + "options": { + "csharp_namespace": "Google.Cloud.Firestore.V1Beta1", + "go_package": "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore", + "java_multiple_files": true, + "java_outer_classname": "WriteProto", + "java_package": "com.google.firestore.v1beta1", + "objc_class_prefix": "GCFS", + "php_namespace": "Google\\Cloud\\Firestore\\V1beta1" + }, + "nested": { + "DocumentMask": { + "fields": { + "fieldPaths": { + "rule": "repeated", "type": "string", "id": 1 - }, - "removedTargetIds": { - "rule": "repeated", - "type": "int32", - "id": 2 - }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 4 } } }, - "ExistenceFilter": { + "Precondition": { + "oneofs": { + "conditionType": { + "oneof": [ + "exists", + "updateTime" + ] + } + }, "fields": { - "targetId": { - "type": "int32", + "exists": { + "type": "bool", "id": 1 }, - "count": { - "type": "int32", + "updateTime": { + "type": "google.protobuf.Timestamp", "id": 2 } } }, - "StructuredQuery": { + "TransactionOptions": { + "oneofs": { + "mode": { + "oneof": [ + "readOnly", + "readWrite" + ] + } + }, "fields": { - "select": { - "type": "Projection", - "id": 1 - }, - "from": { - "rule": "repeated", - "type": "CollectionSelector", + "readOnly": { + "type": "ReadOnly", "id": 2 }, - "where": { - "type": "Filter", + "readWrite": { + "type": "ReadWrite", "id": 3 - }, - "orderBy": { - "rule": "repeated", - "type": "Order", - "id": 4 - }, - "startAt": { - "type": "Cursor", - "id": 7 - }, - "endAt": { - "type": "Cursor", - "id": 8 - }, - "offset": { - "type": "int32", - "id": 6 - }, - "limit": { - "type": "google.protobuf.Int32Value", - "id": 5 } }, "nested": { - "CollectionSelector": { + "ReadWrite": { "fields": { - "collectionId": { - "type": "string", - "id": 2 - }, - "allDescendants": { - "type": "bool", - "id": 3 + "retryTransaction": { + "type": "bytes", + "id": 1 } } }, - "Filter": { + "ReadOnly": { "oneofs": { - "filterType": { + "consistencySelector": { "oneof": [ - "compositeFilter", - "fieldFilter", - "unaryFilter" + "readTime" ] } }, "fields": { - "compositeFilter": { - "type": "CompositeFilter", - "id": 1 - }, - "fieldFilter": { - "type": "FieldFilter", + "readTime": { + "type": "google.protobuf.Timestamp", "id": 2 - }, - "unaryFilter": { - "type": "UnaryFilter", - "id": 3 } } + } + } + }, + "Document": { + "fields": { + "name": { + "type": "string", + "id": 1 }, - "CompositeFilter": { - "fields": { - "op": { - "type": "Operator", - "id": 1 - }, - "filters": { - "rule": "repeated", - "type": "Filter", - "id": 2 - } - }, - "nested": { - "Operator": { - "values": { - "OPERATOR_UNSPECIFIED": 0, - "AND": 1 - } - } - } + "fields": { + "keyType": "string", + "type": "Value", + "id": 2 }, - "FieldFilter": { - "fields": { - "field": { - "type": "FieldReference", - "id": 1 - }, - "op": { - "type": "Operator", - "id": 2 - }, - "value": { - "type": "Value", - "id": 3 - } - }, - "nested": { - "Operator": { - "values": { - "OPERATOR_UNSPECIFIED": 0, - "LESS_THAN": 1, - "LESS_THAN_OR_EQUAL": 2, - "GREATER_THAN": 3, - "GREATER_THAN_OR_EQUAL": 4, - "EQUAL": 5, - "ARRAY_CONTAINS": 7, - "IN": 8, - "ARRAY_CONTAINS_ANY": 9 - } - } - } + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 3 }, - "UnaryFilter": { - "oneofs": { - "operandType": { - "oneof": [ - "field" - ] - } - }, - "fields": { - "op": { - "type": "Operator", - "id": 1 - }, - "field": { - "type": "FieldReference", - "id": 2 - } - }, - "nested": { - "Operator": { - "values": { - "OPERATOR_UNSPECIFIED": 0, - "IS_NAN": 2, - "IS_NULL": 3 - } - } - } + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 4 + } + } + }, + "Value": { + "oneofs": { + "valueType": { + "oneof": [ + "nullValue", + "booleanValue", + "integerValue", + "doubleValue", + "timestampValue", + "stringValue", + "bytesValue", + "referenceValue", + "geoPointValue", + "arrayValue", + "mapValue" + ] + } + }, + "fields": { + "nullValue": { + "type": "google.protobuf.NullValue", + "id": 11 }, - "Order": { - "fields": { - "field": { - "type": "FieldReference", - "id": 1 - }, - "direction": { - "type": "Direction", - "id": 2 - } - } + "booleanValue": { + "type": "bool", + "id": 1 + }, + "integerValue": { + "type": "int64", + "id": 2 + }, + "doubleValue": { + "type": "double", + "id": 3 + }, + "timestampValue": { + "type": "google.protobuf.Timestamp", + "id": 10 + }, + "stringValue": { + "type": "string", + "id": 17 }, - "FieldReference": { - "fields": { - "fieldPath": { - "type": "string", - "id": 2 - } - } + "bytesValue": { + "type": "bytes", + "id": 18 }, - "Projection": { - "fields": { - "fields": { - "rule": "repeated", - "type": "FieldReference", - "id": 2 - } - } + "referenceValue": { + "type": "string", + "id": 5 }, - "Direction": { - "values": { - "DIRECTION_UNSPECIFIED": 0, - "ASCENDING": 1, - "DESCENDING": 2 - } + "geoPointValue": { + "type": "google.type.LatLng", + "id": 8 + }, + "arrayValue": { + "type": "ArrayValue", + "id": 9 + }, + "mapValue": { + "type": "MapValue", + "id": 6 } } }, - "Cursor": { + "ArrayValue": { "fields": { "values": { "rule": "repeated", "type": "Value", "id": 1 - }, - "before": { - "type": "bool", - "id": 2 + } + } + }, + "MapValue": { + "fields": { + "fields": { + "keyType": "string", + "type": "Value", + "id": 1 } } }, @@ -2995,269 +2612,652 @@ "type": "Document", "id": 1 }, - "readTime": { - "type": "google.protobuf.Timestamp", + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + }, + "skippedResults": { + "type": "int32", + "id": 4 + } + } + }, + "WriteRequest": { + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "streamId": { + "type": "string", + "id": 2 + }, + "writes": { + "rule": "repeated", + "type": "Write", + "id": 3 + }, + "streamToken": { + "type": "bytes", + "id": 4 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 5 + } + } + }, + "WriteResponse": { + "fields": { + "streamId": { + "type": "string", + "id": 1 + }, + "streamToken": { + "type": "bytes", + "id": 2 + }, + "writeResults": { + "rule": "repeated", + "type": "WriteResult", + "id": 3 + }, + "commitTime": { + "type": "google.protobuf.Timestamp", + "id": 4 + } + } + }, + "ListenRequest": { + "oneofs": { + "targetChange": { + "oneof": [ + "addTarget", + "removeTarget" + ] + } + }, + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "addTarget": { + "type": "Target", + "id": 2 + }, + "removeTarget": { + "type": "int32", + "id": 3 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 4 + } + } + }, + "ListenResponse": { + "oneofs": { + "responseType": { + "oneof": [ + "targetChange", + "documentChange", + "documentDelete", + "documentRemove", + "filter" + ] + } + }, + "fields": { + "targetChange": { + "type": "TargetChange", + "id": 2 + }, + "documentChange": { + "type": "DocumentChange", + "id": 3 + }, + "documentDelete": { + "type": "DocumentDelete", + "id": 4 + }, + "documentRemove": { + "type": "DocumentRemove", + "id": 6 + }, + "filter": { + "type": "ExistenceFilter", + "id": 5 + } + } + }, + "Target": { + "oneofs": { + "targetType": { + "oneof": [ + "query", + "documents" + ] + }, + "resumeType": { + "oneof": [ + "resumeToken", + "readTime" + ] + } + }, + "fields": { + "query": { + "type": "QueryTarget", + "id": 2 + }, + "documents": { + "type": "DocumentsTarget", + "id": 3 + }, + "resumeToken": { + "type": "bytes", + "id": 4 + }, + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 11 + }, + "targetId": { + "type": "int32", + "id": 5 + }, + "once": { + "type": "bool", + "id": 6 + } + }, + "nested": { + "DocumentsTarget": { + "fields": { + "documents": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } + }, + "QueryTarget": { + "oneofs": { + "queryType": { + "oneof": [ + "structuredQuery" + ] + } + }, + "fields": { + "parent": { + "type": "string", + "id": 1 + }, + "structuredQuery": { + "type": "StructuredQuery", + "id": 2 + } + } + } + } + }, + "TargetChange": { + "fields": { + "targetChangeType": { + "type": "TargetChangeType", + "id": 1 + }, + "targetIds": { + "rule": "repeated", + "type": "int32", + "id": 2 + }, + "cause": { + "type": "google.rpc.Status", "id": 3 }, - "skippedResults": { - "type": "int32", + "resumeToken": { + "type": "bytes", "id": 4 + }, + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 6 + } + }, + "nested": { + "TargetChangeType": { + "values": { + "NO_CHANGE": 0, + "ADD": 1, + "REMOVE": 2, + "CURRENT": 3, + "RESET": 4 + } } } }, - "WriteRequest": { + "ListCollectionIdsRequest": { "fields": { - "database": { + "parent": { "type": "string", "id": 1, "options": { "(google.api.field_behavior)": "REQUIRED" } }, - "streamId": { - "type": "string", + "pageSize": { + "type": "int32", "id": 2 }, - "writes": { - "rule": "repeated", - "type": "Write", - "id": 3 - }, - "streamToken": { - "type": "bytes", - "id": 4 - }, - "labels": { - "keyType": "string", + "pageToken": { "type": "string", - "id": 5 + "id": 3 } } }, - "WriteResponse": { + "ListCollectionIdsResponse": { "fields": { - "streamId": { + "collectionIds": { + "rule": "repeated", "type": "string", "id": 1 }, - "streamToken": { - "type": "bytes", + "nextPageToken": { + "type": "string", "id": 2 + } + } + }, + "StructuredQuery": { + "fields": { + "select": { + "type": "Projection", + "id": 1 }, - "writeResults": { + "from": { "rule": "repeated", - "type": "WriteResult", + "type": "CollectionSelector", + "id": 2 + }, + "where": { + "type": "Filter", "id": 3 }, - "commitTime": { - "type": "google.protobuf.Timestamp", + "orderBy": { + "rule": "repeated", + "type": "Order", "id": 4 + }, + "startAt": { + "type": "Cursor", + "id": 7 + }, + "endAt": { + "type": "Cursor", + "id": 8 + }, + "offset": { + "type": "int32", + "id": 6 + }, + "limit": { + "type": "google.protobuf.Int32Value", + "id": 5 } - } - }, - "ListenRequest": { - "oneofs": { - "targetChange": { - "oneof": [ - "addTarget", - "removeTarget" - ] + }, + "nested": { + "CollectionSelector": { + "fields": { + "collectionId": { + "type": "string", + "id": 2 + }, + "allDescendants": { + "type": "bool", + "id": 3 + } + } + }, + "Filter": { + "oneofs": { + "filterType": { + "oneof": [ + "compositeFilter", + "fieldFilter", + "unaryFilter" + ] + } + }, + "fields": { + "compositeFilter": { + "type": "CompositeFilter", + "id": 1 + }, + "fieldFilter": { + "type": "FieldFilter", + "id": 2 + }, + "unaryFilter": { + "type": "UnaryFilter", + "id": 3 + } + } + }, + "CompositeFilter": { + "fields": { + "op": { + "type": "Operator", + "id": 1 + }, + "filters": { + "rule": "repeated", + "type": "Filter", + "id": 2 + } + }, + "nested": { + "Operator": { + "values": { + "OPERATOR_UNSPECIFIED": 0, + "AND": 1 + } + } + } + }, + "FieldFilter": { + "fields": { + "field": { + "type": "FieldReference", + "id": 1 + }, + "op": { + "type": "Operator", + "id": 2 + }, + "value": { + "type": "Value", + "id": 3 + } + }, + "nested": { + "Operator": { + "values": { + "OPERATOR_UNSPECIFIED": 0, + "LESS_THAN": 1, + "LESS_THAN_OR_EQUAL": 2, + "GREATER_THAN": 3, + "GREATER_THAN_OR_EQUAL": 4, + "EQUAL": 5, + "ARRAY_CONTAINS": 7, + "IN": 8, + "ARRAY_CONTAINS_ANY": 9 + } + } + } + }, + "UnaryFilter": { + "oneofs": { + "operandType": { + "oneof": [ + "field" + ] + } + }, + "fields": { + "op": { + "type": "Operator", + "id": 1 + }, + "field": { + "type": "FieldReference", + "id": 2 + } + }, + "nested": { + "Operator": { + "values": { + "OPERATOR_UNSPECIFIED": 0, + "IS_NAN": 2, + "IS_NULL": 3 + } + } + } + }, + "Order": { + "fields": { + "field": { + "type": "FieldReference", + "id": 1 + }, + "direction": { + "type": "Direction", + "id": 2 + } + } + }, + "FieldReference": { + "fields": { + "fieldPath": { + "type": "string", + "id": 2 + } + } + }, + "Projection": { + "fields": { + "fields": { + "rule": "repeated", + "type": "FieldReference", + "id": 2 + } + } + }, + "Direction": { + "values": { + "DIRECTION_UNSPECIFIED": 0, + "ASCENDING": 1, + "DESCENDING": 2 + } } - }, + } + }, + "Cursor": { "fields": { - "database": { - "type": "string", - "id": 1, - "options": { - "(google.api.field_behavior)": "REQUIRED" - } + "values": { + "rule": "repeated", + "type": "Value", + "id": 1 }, - "addTarget": { - "type": "Target", + "before": { + "type": "bool", "id": 2 - }, - "removeTarget": { - "type": "int32", - "id": 3 - }, - "labels": { - "keyType": "string", - "type": "string", - "id": 4 } } }, - "ListenResponse": { + "Write": { "oneofs": { - "responseType": { + "operation": { "oneof": [ - "targetChange", - "documentChange", - "documentDelete", - "documentRemove", - "filter" + "update", + "delete", + "transform" ] } }, "fields": { - "targetChange": { - "type": "TargetChange", + "update": { + "type": "Document", + "id": 1 + }, + "delete": { + "type": "string", "id": 2 }, - "documentChange": { - "type": "DocumentChange", + "transform": { + "type": "DocumentTransform", + "id": 6 + }, + "updateMask": { + "type": "DocumentMask", "id": 3 }, - "documentDelete": { - "type": "DocumentDelete", + "currentDocument": { + "type": "Precondition", "id": 4 - }, - "documentRemove": { - "type": "DocumentRemove", - "id": 6 - }, - "filter": { - "type": "ExistenceFilter", - "id": 5 } } }, - "Target": { - "oneofs": { - "targetType": { - "oneof": [ - "query", - "documents" - ] - }, - "resumeType": { - "oneof": [ - "resumeToken", - "readTime" - ] - } - }, + "DocumentTransform": { "fields": { - "query": { - "type": "QueryTarget", - "id": 2 - }, - "documents": { - "type": "DocumentsTarget", - "id": 3 - }, - "resumeToken": { - "type": "bytes", - "id": 4 - }, - "readTime": { - "type": "google.protobuf.Timestamp", - "id": 11 - }, - "targetId": { - "type": "int32", - "id": 5 + "document": { + "type": "string", + "id": 1 }, - "once": { - "type": "bool", - "id": 6 + "fieldTransforms": { + "rule": "repeated", + "type": "FieldTransform", + "id": 2 } }, "nested": { - "DocumentsTarget": { - "fields": { - "documents": { - "rule": "repeated", - "type": "string", - "id": 2 - } - } - }, - "QueryTarget": { + "FieldTransform": { "oneofs": { - "queryType": { + "transformType": { "oneof": [ - "structuredQuery" + "setToServerValue", + "increment", + "maximum", + "minimum", + "appendMissingElements", + "removeAllFromArray" ] } }, "fields": { - "parent": { + "fieldPath": { "type": "string", "id": 1 }, - "structuredQuery": { - "type": "StructuredQuery", + "setToServerValue": { + "type": "ServerValue", "id": 2 + }, + "increment": { + "type": "Value", + "id": 3 + }, + "maximum": { + "type": "Value", + "id": 4 + }, + "minimum": { + "type": "Value", + "id": 5 + }, + "appendMissingElements": { + "type": "ArrayValue", + "id": 6 + }, + "removeAllFromArray": { + "type": "ArrayValue", + "id": 7 + } + }, + "nested": { + "ServerValue": { + "values": { + "SERVER_VALUE_UNSPECIFIED": 0, + "REQUEST_TIME": 1 + } } } } } }, - "TargetChange": { + "WriteResult": { "fields": { - "targetChangeType": { - "type": "TargetChangeType", + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 1 + }, + "transformResults": { + "rule": "repeated", + "type": "Value", + "id": 2 + } + } + }, + "DocumentChange": { + "fields": { + "document": { + "type": "Document", "id": 1 }, "targetIds": { "rule": "repeated", "type": "int32", - "id": 2 + "id": 5 }, - "cause": { - "type": "google.rpc.Status", - "id": 3 + "removedTargetIds": { + "rule": "repeated", + "type": "int32", + "id": 6 + } + } + }, + "DocumentDelete": { + "fields": { + "document": { + "type": "string", + "id": 1 }, - "resumeToken": { - "type": "bytes", - "id": 4 + "removedTargetIds": { + "rule": "repeated", + "type": "int32", + "id": 6 }, "readTime": { "type": "google.protobuf.Timestamp", - "id": 6 - } - }, - "nested": { - "TargetChangeType": { - "values": { - "NO_CHANGE": 0, - "ADD": 1, - "REMOVE": 2, - "CURRENT": 3, - "RESET": 4 - } + "id": 4 } } }, - "ListCollectionIdsRequest": { + "DocumentRemove": { "fields": { - "parent": { + "document": { "type": "string", - "id": 1, - "options": { - "(google.api.field_behavior)": "REQUIRED" - } + "id": 1 }, - "pageSize": { + "removedTargetIds": { + "rule": "repeated", "type": "int32", "id": 2 }, - "pageToken": { - "type": "string", - "id": 3 + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 4 } } }, - "ListCollectionIdsResponse": { + "ExistenceFilter": { "fields": { - "collectionIds": { - "rule": "repeated", - "type": "string", + "targetId": { + "type": "int32", "id": 1 }, - "nextPageToken": { - "type": "string", + "count": { + "type": "int32", "id": 2 } } diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index cca2b24f1..db21f1652 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -148,14 +148,14 @@ export class FirestoreAdminClient { collectionGroupPathTemplate: new gaxModule.PathTemplate( 'projects/{project}/databases/{database}/collectionGroups/{collection}' ), - indexPathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}' + databasePathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/databases/{database}' ), fieldPathTemplate: new gaxModule.PathTemplate( 'projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}' ), - databasePathTemplate: new gaxModule.PathTemplate( - 'projects/{project}/databases/{database}' + indexPathTemplate: new gaxModule.PathTemplate( + 'projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}' ), }; @@ -764,7 +764,7 @@ export class FirestoreAdminClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - field_name: request.field!.name || '', + 'field.name': request.field!.name || '', }); return this._innerApiCalls.updateField(request, options, callback); } @@ -1099,9 +1099,17 @@ export class FirestoreAdminClient { */ listIndexesStream( request?: protosTypes.google.firestore.admin.v1.IListIndexesRequest, - options?: gax.CallOptions | {} + options?: gax.CallOptions ): Transform { 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); return this._descriptors.page.listIndexes.createStream( this._innerApiCalls.listIndexes as gax.GaxCall, @@ -1248,9 +1256,17 @@ export class FirestoreAdminClient { */ listFieldsStream( request?: protosTypes.google.firestore.admin.v1.IListFieldsRequest, - options?: gax.CallOptions | {} + options?: gax.CallOptions ): Transform { 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); return this._descriptors.page.listFields.createStream( this._innerApiCalls.listFields as gax.GaxCall, @@ -1318,70 +1334,40 @@ export class FirestoreAdminClient { } /** - * Return a fully-qualified index resource name string. + * Return a fully-qualified database resource name string. * * @param {string} project * @param {string} database - * @param {string} collection - * @param {string} index * @returns {string} Resource name string. */ - indexPath( - project: string, - database: string, - collection: string, - index: string - ) { - return this._pathTemplates.indexPathTemplate.render({ + databasePath(project: string, database: string) { + return this._pathTemplates.databasePathTemplate.render({ project, database, - collection, - index, }); } /** - * Parse the project from Index resource. + * Parse the project from Database resource. * - * @param {string} indexName - * A fully-qualified path representing Index resource. + * @param {string} databaseName + * A fully-qualified path representing Database resource. * @returns {string} A string representing the project. */ - matchProjectFromIndexName(indexName: string) { - return this._pathTemplates.indexPathTemplate.match(indexName).project; + matchProjectFromDatabaseName(databaseName: string) { + return this._pathTemplates.databasePathTemplate.match(databaseName).project; } /** - * Parse the database from Index resource. + * Parse the database from Database resource. * - * @param {string} indexName - * A fully-qualified path representing Index resource. + * @param {string} databaseName + * A fully-qualified path representing Database resource. * @returns {string} A string representing the database. */ - matchDatabaseFromIndexName(indexName: string) { - return this._pathTemplates.indexPathTemplate.match(indexName).database; - } - - /** - * Parse the collection from Index resource. - * - * @param {string} indexName - * A fully-qualified path representing Index resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromIndexName(indexName: string) { - return this._pathTemplates.indexPathTemplate.match(indexName).collection; - } - - /** - * Parse the index from Index resource. - * - * @param {string} indexName - * A fully-qualified path representing Index resource. - * @returns {string} A string representing the index. - */ - matchIndexFromIndexName(indexName: string) { - return this._pathTemplates.indexPathTemplate.match(indexName).index; + matchDatabaseFromDatabaseName(databaseName: string) { + return this._pathTemplates.databasePathTemplate.match(databaseName) + .database; } /** @@ -1452,40 +1438,70 @@ export class FirestoreAdminClient { } /** - * Return a fully-qualified database resource name string. + * Return a fully-qualified index resource name string. * * @param {string} project * @param {string} database + * @param {string} collection + * @param {string} index * @returns {string} Resource name string. */ - databasePath(project: string, database: string) { - return this._pathTemplates.databasePathTemplate.render({ + indexPath( + project: string, + database: string, + collection: string, + index: string + ) { + return this._pathTemplates.indexPathTemplate.render({ project, database, + collection, + index, }); } /** - * Parse the project from Database resource. + * Parse the project from Index resource. * - * @param {string} databaseName - * A fully-qualified path representing Database resource. + * @param {string} indexName + * A fully-qualified path representing Index resource. * @returns {string} A string representing the project. */ - matchProjectFromDatabaseName(databaseName: string) { - return this._pathTemplates.databasePathTemplate.match(databaseName).project; + matchProjectFromIndexName(indexName: string) { + return this._pathTemplates.indexPathTemplate.match(indexName).project; } /** - * Parse the database from Database resource. + * Parse the database from Index resource. * - * @param {string} databaseName - * A fully-qualified path representing Database resource. + * @param {string} indexName + * A fully-qualified path representing Index resource. * @returns {string} A string representing the database. */ - matchDatabaseFromDatabaseName(databaseName: string) { - return this._pathTemplates.databasePathTemplate.match(databaseName) - .database; + matchDatabaseFromIndexName(indexName: string) { + return this._pathTemplates.indexPathTemplate.match(indexName).database; + } + + /** + * Parse the collection from Index resource. + * + * @param {string} indexName + * A fully-qualified path representing Index resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromIndexName(indexName: string) { + return this._pathTemplates.indexPathTemplate.match(indexName).collection; + } + + /** + * Parse the index from Index resource. + * + * @param {string} indexName + * A fully-qualified path representing Index resource. + * @returns {string} A string representing the index. + */ + matchIndexFromIndexName(indexName: string) { + return this._pathTemplates.indexPathTemplate.match(indexName).index; } /** diff --git a/dev/src/v1/firestore_admin_proto_list.json b/dev/src/v1/firestore_admin_proto_list.json index 0484301c3..e50187de7 100644 --- a/dev/src/v1/firestore_admin_proto_list.json +++ b/dev/src/v1/firestore_admin_proto_list.json @@ -1,7 +1,7 @@ [ - "../../protos/google/firestore/admin/v1/index.proto", "../../protos/google/firestore/admin/v1/field.proto", "../../protos/google/firestore/admin/v1/firestore_admin.proto", + "../../protos/google/firestore/admin/v1/index.proto", "../../protos/google/firestore/admin/v1/location.proto", "../../protos/google/firestore/admin/v1/operation.proto" ] diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 02fda1d34..6eaf680e0 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -899,6 +899,13 @@ export class FirestoreClient { ): gax.CancellableStream { request = request || {}; 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 || '', + }); return this._innerApiCalls.batchGetDocuments(request, options); } @@ -937,6 +944,13 @@ export class FirestoreClient { ): gax.CancellableStream { 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 || '', + }); return this._innerApiCalls.runQuery(request, options); } @@ -951,7 +965,6 @@ export class FirestoreClient { * will emit objects representing [WriteResponse]{@link google.firestore.v1.WriteResponse} on 'data' event asynchronously. */ write(options?: gax.CallOptions): gax.CancellableStream { - options = options || {}; return this._innerApiCalls.write(options); } @@ -966,7 +979,6 @@ export class FirestoreClient { * will emit objects representing [ListenResponse]{@link google.firestore.v1.ListenResponse} on 'data' event asynchronously. */ listen(options?: gax.CallOptions): gax.CancellableStream { - options = options || {}; return this._innerApiCalls.listen({}, options); } @@ -1142,9 +1154,17 @@ export class FirestoreClient { */ listDocumentsStream( request?: protosTypes.google.firestore.v1.IListDocumentsRequest, - options?: gax.CallOptions | {} + options?: gax.CallOptions ): Transform { 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); return this._descriptors.page.listDocuments.createStream( this._innerApiCalls.listDocuments as gax.GaxCall, @@ -1276,9 +1296,17 @@ export class FirestoreClient { */ listCollectionIdsStream( request?: protosTypes.google.firestore.v1.IListCollectionIdsRequest, - options?: gax.CallOptions | {} + options?: gax.CallOptions ): Transform { 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); return this._descriptors.page.listCollectionIds.createStream( this._innerApiCalls.listCollectionIds as gax.GaxCall, diff --git a/dev/src/v1/firestore_proto_list.json b/dev/src/v1/firestore_proto_list.json index 5aad32750..dcd35e64b 100644 --- a/dev/src/v1/firestore_proto_list.json +++ b/dev/src/v1/firestore_proto_list.json @@ -1,7 +1,7 @@ [ "../../protos/google/firestore/v1/common.proto", "../../protos/google/firestore/v1/document.proto", - "../../protos/google/firestore/v1/write.proto", + "../../protos/google/firestore/v1/firestore.proto", "../../protos/google/firestore/v1/query.proto", - "../../protos/google/firestore/v1/firestore.proto" + "../../protos/google/firestore/v1/write.proto" ] diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index e8ae66602..bf29dc995 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -911,6 +911,13 @@ export class FirestoreClient { ): gax.CancellableStream { request = request || {}; 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 || '', + }); return this._innerApiCalls.batchGetDocuments(request, options); } @@ -949,6 +956,13 @@ export class FirestoreClient { ): gax.CancellableStream { 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 || '', + }); return this._innerApiCalls.runQuery(request, options); } @@ -963,7 +977,6 @@ export class FirestoreClient { * will emit objects representing [WriteResponse]{@link google.firestore.v1beta1.WriteResponse} on 'data' event asynchronously. */ write(options?: gax.CallOptions): gax.CancellableStream { - options = options || {}; return this._innerApiCalls.write(options); } @@ -978,7 +991,6 @@ export class FirestoreClient { * will emit objects representing [ListenResponse]{@link google.firestore.v1beta1.ListenResponse} on 'data' event asynchronously. */ listen(options?: gax.CallOptions): gax.CancellableStream { - options = options || {}; return this._innerApiCalls.listen({}, options); } @@ -1154,9 +1166,17 @@ export class FirestoreClient { */ listDocumentsStream( request?: protosTypes.google.firestore.v1beta1.IListDocumentsRequest, - options?: gax.CallOptions | {} + options?: gax.CallOptions ): Transform { 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); return this._descriptors.page.listDocuments.createStream( this._innerApiCalls.listDocuments as gax.GaxCall, @@ -1288,9 +1308,17 @@ export class FirestoreClient { */ listCollectionIdsStream( request?: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest, - options?: gax.CallOptions | {} + options?: gax.CallOptions ): Transform { 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); return this._descriptors.page.listCollectionIds.createStream( this._innerApiCalls.listCollectionIds as gax.GaxCall, diff --git a/dev/src/v1beta1/firestore_proto_list.json b/dev/src/v1beta1/firestore_proto_list.json index f1254d305..fbbd4aecc 100644 --- a/dev/src/v1beta1/firestore_proto_list.json +++ b/dev/src/v1beta1/firestore_proto_list.json @@ -1,7 +1,7 @@ [ "../../protos/google/firestore/v1beta1/common.proto", "../../protos/google/firestore/v1beta1/document.proto", - "../../protos/google/firestore/v1beta1/write.proto", + "../../protos/google/firestore/v1beta1/firestore.proto", "../../protos/google/firestore/v1beta1/query.proto", - "../../protos/google/firestore/v1beta1/firestore.proto" + "../../protos/google/firestore/v1beta1/write.proto" ] diff --git a/dev/synth.metadata b/dev/synth.metadata index f755bb76d..fc8647cbf 100644 --- a/dev/synth.metadata +++ b/dev/synth.metadata @@ -1,12 +1,12 @@ { - "updateTime": "2020-01-29T12:21:39.064044Z", + "updateTime": "2020-02-07T18:50:00.377881Z", "sources": [ { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "cf3b61102ed5f36b827bc82ec39be09525f018c8", - "internalRef": "292034635" + "sha": "e46f761cd6ec15a9e3d5ed4ff321a4bcba8e8585", + "internalRef": "293710856" } }, { @@ -48,49 +48,10 @@ ], "newFiles": [ { - "path": "conformance/.eslintrc.yml" + "path": ".gitignore" }, { - "path": "conformance/runner.ts" - }, - { - "path": "conformance/test-definition.proto" - }, - { - "path": "conformance/test-suite.binproto" - }, - { - "path": "protos/firestore_admin_v1_proto_api.d.ts" - }, - { - "path": "protos/firestore_admin_v1_proto_api.js" - }, - { - "path": "protos/firestore_v1_proto_api.d.ts" - }, - { - "path": "protos/firestore_v1_proto_api.js" - }, - { - "path": "protos/firestore_v1beta1_proto_api.d.ts" - }, - { - "path": "protos/firestore_v1beta1_proto_api.js" - }, - { - "path": "protos/google/api/annotations.proto" - }, - { - "path": "protos/google/api/client.proto" - }, - { - "path": "protos/google/api/field_behavior.proto" - }, - { - "path": "protos/google/api/http.proto" - }, - { - "path": "protos/google/api/resource.proto" + "path": ".mocharc.json" }, { "path": "protos/google/firestore/admin/v1/field.proto" @@ -137,93 +98,9 @@ { "path": "protos/google/firestore/v1beta1/write.proto" }, - { - "path": "protos/google/longrunning/operations.proto" - }, - { - "path": "protos/google/protobuf/any.proto" - }, - { - "path": "protos/google/protobuf/empty.proto" - }, - { - "path": "protos/google/protobuf/field_mask.proto" - }, - { - "path": "protos/google/protobuf/struct.proto" - }, - { - "path": "protos/google/protobuf/timestamp.proto" - }, - { - "path": "protos/google/protobuf/wrappers.proto" - }, - { - "path": "protos/google/rpc/status.proto" - }, - { - "path": "protos/google/type/latlng.proto" - }, { "path": "protos/protos.json" }, - { - "path": "protos/update.sh" - }, - { - "path": "src/backoff.ts" - }, - { - "path": "src/convert.ts" - }, - { - "path": "src/document-change.ts" - }, - { - "path": "src/document.ts" - }, - { - "path": "src/external-modules.d.ts" - }, - { - "path": "src/field-value.ts" - }, - { - "path": "src/geo-point.ts" - }, - { - "path": "src/index.ts" - }, - { - "path": "src/logger.ts" - }, - { - "path": "src/order.ts" - }, - { - "path": "src/path.ts" - }, - { - "path": "src/pool.ts" - }, - { - "path": "src/reference.ts" - }, - { - "path": "src/serializer.ts" - }, - { - "path": "src/timestamp.ts" - }, - { - "path": "src/transaction.ts" - }, - { - "path": "src/types.ts" - }, - { - "path": "src/util.ts" - }, { "path": "src/v1/firestore_admin_client.ts" }, @@ -242,9 +119,6 @@ { "path": "src/v1/firestore_proto_list.json" }, - { - "path": "src/v1/index.ts" - }, { "path": "src/v1beta1/firestore_client.ts" }, @@ -254,42 +128,6 @@ { "path": "src/v1beta1/firestore_proto_list.json" }, - { - "path": "src/v1beta1/index.ts" - }, - { - "path": "src/validate.ts" - }, - { - "path": "src/watch.ts" - }, - { - "path": "src/write-batch.ts" - }, - { - "path": "synth.metadata" - }, - { - "path": "system-test/.eslintrc.yml" - }, - { - "path": "system-test/.gitignore" - }, - { - "path": "system-test/firestore.ts" - }, - { - "path": "test/backoff.ts" - }, - { - "path": "test/collection.ts" - }, - { - "path": "test/document.ts" - }, - { - "path": "test/field-value.ts" - }, { "path": "test/gapic-firestore-v1.ts" }, @@ -298,45 +136,6 @@ }, { "path": "test/gapic-firestore_admin-v1.ts" - }, - { - "path": "test/index.ts" - }, - { - "path": "test/mocha.opts" - }, - { - "path": "test/order.ts" - }, - { - "path": "test/path.ts" - }, - { - "path": "test/pool.ts" - }, - { - "path": "test/query.ts" - }, - { - "path": "test/timestamp.ts" - }, - { - "path": "test/transaction.ts" - }, - { - "path": "test/typescript.ts" - }, - { - "path": "test/util.ts" - }, - { - "path": "test/util/helpers.ts" - }, - { - "path": "test/watch.ts" - }, - { - "path": "test/write-batch.ts" } ] } \ No newline at end of file diff --git a/dev/test/gapic-firestore-v1.ts b/dev/test/gapic-firestore-v1.ts index defb39701..8f9d73780 100644 --- a/dev/test/gapic-firestore-v1.ts +++ b/dev/test/gapic-firestore-v1.ts @@ -131,6 +131,7 @@ describe('v1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1.IGetDocumentRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -153,6 +154,7 @@ describe('v1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1.IGetDocumentRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -177,6 +179,7 @@ describe('v1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1.ICreateDocumentRequest = {}; + request.parent = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -199,6 +202,7 @@ describe('v1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1.ICreateDocumentRequest = {}; + request.parent = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -273,6 +277,7 @@ describe('v1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1.IDeleteDocumentRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -295,6 +300,7 @@ describe('v1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1.IDeleteDocumentRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -319,6 +325,7 @@ describe('v1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1.IBeginTransactionRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -341,6 +348,7 @@ describe('v1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1.IBeginTransactionRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -365,6 +373,7 @@ describe('v1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1.ICommitRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -387,6 +396,7 @@ describe('v1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1.ICommitRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -407,6 +417,7 @@ describe('v1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1.IRollbackRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -429,6 +440,7 @@ describe('v1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1.IRollbackRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -669,6 +681,7 @@ describe('v1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1.IListDocumentsRequest = {}; + request.parent = ''; // Mock response const expectedResponse = {}; // Mock Grpc layer @@ -695,8 +708,9 @@ describe('v1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1.IListDocumentsRequest = {}; + request.parent = ''; // Mock response - const expectedResponse = {}; + const expectedResponse = {response: 'data'}; // Mock Grpc layer client._innerApiCalls.listDocuments = ( actualRequest: {}, @@ -715,7 +729,7 @@ describe('v1.FirestoreClient', () => { .on('error', (err: FakeError) => { done(err); }); - stream.write(request); + stream.write(expectedResponse); }); }); describe('listCollectionIds', () => { @@ -726,6 +740,7 @@ describe('v1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1.IListCollectionIdsRequest = {}; + request.parent = ''; // Mock response const expectedResponse = {}; // Mock Grpc layer @@ -752,8 +767,9 @@ describe('v1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1.IListCollectionIdsRequest = {}; + request.parent = ''; // Mock response - const expectedResponse = {}; + const expectedResponse = {response: 'data'}; // Mock Grpc layer client._innerApiCalls.listCollectionIds = ( actualRequest: {}, @@ -772,7 +788,7 @@ describe('v1.FirestoreClient', () => { .on('error', (err: FakeError) => { done(err); }); - stream.write(request); + stream.write(expectedResponse); }); }); }); diff --git a/dev/test/gapic-firestore-v1beta1.ts b/dev/test/gapic-firestore-v1beta1.ts index f28bedefd..4c4a5d3ec 100644 --- a/dev/test/gapic-firestore-v1beta1.ts +++ b/dev/test/gapic-firestore-v1beta1.ts @@ -131,6 +131,7 @@ describe('v1beta1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1beta1.IGetDocumentRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -153,6 +154,7 @@ describe('v1beta1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1beta1.IGetDocumentRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -177,6 +179,7 @@ describe('v1beta1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1beta1.ICreateDocumentRequest = {}; + request.parent = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -199,6 +202,7 @@ describe('v1beta1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1beta1.ICreateDocumentRequest = {}; + request.parent = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -273,6 +277,7 @@ describe('v1beta1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -295,6 +300,7 @@ describe('v1beta1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -319,6 +325,7 @@ describe('v1beta1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1beta1.IBeginTransactionRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -341,6 +348,7 @@ describe('v1beta1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1beta1.IBeginTransactionRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -365,6 +373,7 @@ describe('v1beta1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1beta1.ICommitRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -387,6 +396,7 @@ describe('v1beta1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1beta1.ICommitRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -407,6 +417,7 @@ describe('v1beta1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1beta1.IRollbackRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -429,6 +440,7 @@ describe('v1beta1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1beta1.IRollbackRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -669,6 +681,7 @@ describe('v1beta1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1beta1.IListDocumentsRequest = {}; + request.parent = ''; // Mock response const expectedResponse = {}; // Mock Grpc layer @@ -695,8 +708,9 @@ describe('v1beta1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1beta1.IListDocumentsRequest = {}; + request.parent = ''; // Mock response - const expectedResponse = {}; + const expectedResponse = {response: 'data'}; // Mock Grpc layer client._innerApiCalls.listDocuments = ( actualRequest: {}, @@ -715,7 +729,7 @@ describe('v1beta1.FirestoreClient', () => { .on('error', (err: FakeError) => { done(err); }); - stream.write(request); + stream.write(expectedResponse); }); }); describe('listCollectionIds', () => { @@ -726,6 +740,7 @@ describe('v1beta1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest = {}; + request.parent = ''; // Mock response const expectedResponse = {}; // Mock Grpc layer @@ -752,8 +767,9 @@ describe('v1beta1.FirestoreClient', () => { }); // Mock request const request: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest = {}; + request.parent = ''; // Mock response - const expectedResponse = {}; + const expectedResponse = {response: 'data'}; // Mock Grpc layer client._innerApiCalls.listCollectionIds = ( actualRequest: {}, @@ -772,7 +788,7 @@ describe('v1beta1.FirestoreClient', () => { .on('error', (err: FakeError) => { done(err); }); - stream.write(request); + stream.write(expectedResponse); }); }); }); diff --git a/dev/test/gapic-firestore_admin-v1.ts b/dev/test/gapic-firestore_admin-v1.ts index 2515aeadc..b06cad3fc 100644 --- a/dev/test/gapic-firestore_admin-v1.ts +++ b/dev/test/gapic-firestore_admin-v1.ts @@ -112,6 +112,7 @@ describe('v1.FirestoreAdminClient', () => { }); // Mock request const request: protosTypes.google.firestore.admin.v1.IGetIndexRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -134,6 +135,7 @@ describe('v1.FirestoreAdminClient', () => { }); // Mock request const request: protosTypes.google.firestore.admin.v1.IGetIndexRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -158,6 +160,7 @@ describe('v1.FirestoreAdminClient', () => { }); // Mock request const request: protosTypes.google.firestore.admin.v1.IDeleteIndexRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -180,6 +183,7 @@ describe('v1.FirestoreAdminClient', () => { }); // Mock request const request: protosTypes.google.firestore.admin.v1.IDeleteIndexRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -204,6 +208,7 @@ describe('v1.FirestoreAdminClient', () => { }); // Mock request const request: protosTypes.google.firestore.admin.v1.IGetFieldRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -226,6 +231,7 @@ describe('v1.FirestoreAdminClient', () => { }); // Mock request const request: protosTypes.google.firestore.admin.v1.IGetFieldRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -250,6 +256,7 @@ describe('v1.FirestoreAdminClient', () => { }); // Mock request const request: protosTypes.google.firestore.admin.v1.ICreateIndexRequest = {}; + request.parent = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -279,6 +286,7 @@ describe('v1.FirestoreAdminClient', () => { }); // Mock request const request: protosTypes.google.firestore.admin.v1.ICreateIndexRequest = {}; + request.parent = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -376,6 +384,7 @@ describe('v1.FirestoreAdminClient', () => { }); // Mock request const request: protosTypes.google.firestore.admin.v1.IExportDocumentsRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -405,6 +414,7 @@ describe('v1.FirestoreAdminClient', () => { }); // Mock request const request: protosTypes.google.firestore.admin.v1.IExportDocumentsRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -437,6 +447,7 @@ describe('v1.FirestoreAdminClient', () => { }); // Mock request const request: protosTypes.google.firestore.admin.v1.IImportDocumentsRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -466,6 +477,7 @@ describe('v1.FirestoreAdminClient', () => { }); // Mock request const request: protosTypes.google.firestore.admin.v1.IImportDocumentsRequest = {}; + request.name = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -498,6 +510,7 @@ describe('v1.FirestoreAdminClient', () => { }); // Mock request const request: protosTypes.google.firestore.admin.v1.IListIndexesRequest = {}; + request.parent = ''; // Mock response const expectedResponse = {}; // Mock Grpc layer @@ -524,8 +537,9 @@ describe('v1.FirestoreAdminClient', () => { }); // Mock request const request: protosTypes.google.firestore.admin.v1.IListIndexesRequest = {}; + request.parent = ''; // Mock response - const expectedResponse = {}; + const expectedResponse = {response: 'data'}; // Mock Grpc layer client._innerApiCalls.listIndexes = ( actualRequest: {}, @@ -544,7 +558,7 @@ describe('v1.FirestoreAdminClient', () => { .on('error', (err: FakeError) => { done(err); }); - stream.write(request); + stream.write(expectedResponse); }); }); describe('listFields', () => { @@ -555,6 +569,7 @@ describe('v1.FirestoreAdminClient', () => { }); // Mock request const request: protosTypes.google.firestore.admin.v1.IListFieldsRequest = {}; + request.parent = ''; // Mock response const expectedResponse = {}; // Mock Grpc layer @@ -581,8 +596,9 @@ describe('v1.FirestoreAdminClient', () => { }); // Mock request const request: protosTypes.google.firestore.admin.v1.IListFieldsRequest = {}; + request.parent = ''; // Mock response - const expectedResponse = {}; + const expectedResponse = {response: 'data'}; // Mock Grpc layer client._innerApiCalls.listFields = ( actualRequest: {}, @@ -601,7 +617,7 @@ describe('v1.FirestoreAdminClient', () => { .on('error', (err: FakeError) => { done(err); }); - stream.write(request); + stream.write(expectedResponse); }); }); }); From 1d80928615862991acc6c81033e7d3d33cb72a59 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 10 Feb 2020 18:04:57 +0100 Subject: [PATCH 061/337] chore(deps): update dependency linkinator to v2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c58ae8879..801e9d26a 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "jsdoc": "^3.6.2", "jsdoc-fresh": "^1.0.2", "jsdoc-region-tag": "^1.0.2", - "linkinator": "^1.8.0", + "linkinator": "^2.0.0", "mocha": "^7.0.0", "protobufjs": "^6.8.6", "proxyquire": "^2.1.3", From d36f5092fcdee0fb779b6fa51d7da6534ca76e36 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Tue, 11 Feb 2020 22:34:16 -0800 Subject: [PATCH 062/337] build: add GitHub actions config for unit tests * build: add GitHub actions config for unit tests * chore: link root directory before linting * chore: also need to npm i --- .github/workflows/ci.yaml | 57 +++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..4d36c57b1 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,57 @@ +on: + push: + branches: + - master + pull_request: +name: ci +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + node: [8, 10, 12, 13] + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + - run: node --version + - run: npm install + - run: npm test + windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 12 + - run: npm install + - run: npm test + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: 12 + - run: npm install + - run: npm run lint + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: 12 + - run: npm install + - run: npm run docs-test + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: 12 + - run: npm install + - run: npm test + - run: ./node_modules/.bin/c8 report --reporter=text-lcov | npx codecov@3 -t ${{ secrets.CODECOV_TOKEN }} --pipe diff --git a/package.json b/package.json index 801e9d26a..c46aa993f 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,8 @@ "fix": "gts fix", "prepare": "npm run compile", "docs-test": "linkinator docs", - "predocs-test": "npm run docs" + "predocs-test": "npm run docs", + "prelint": "cd samples; npm link ../; npm i" }, "dependencies": { "deep-equal": "^2.0.0", From 19c2c75d86c3aab967d21da16598016185ae360b Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 18 Feb 2020 14:34:45 -0800 Subject: [PATCH 063/337] fix: collectionReference.add() validation (#925) --- dev/src/reference.ts | 3 +- dev/src/write-batch.ts | 4 +-- dev/system-test/firestore.ts | 5 ++- dev/test/collection.ts | 60 ++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 6 deletions(-) diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 5cd240fa7..5b68c4b38 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -2301,7 +2301,8 @@ export class CollectionReference extends Query { * }); */ add(data: T): Promise> { - validateDocumentData('data', data, /*allowDeletes=*/ false); + const firestoreData = this._queryOptions.converter.toFirestore(data); + validateDocumentData('data', firestoreData, /*allowDeletes=*/ false); const documentRef = this.doc(); return documentRef.create(data).then(() => documentRef); diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 4191a7471..9c296e78a 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -182,11 +182,11 @@ export class WriteBatch { */ create(documentRef: DocumentReference, data: T): WriteBatch { validateDocumentReference('documentRef', documentRef); - validateDocumentData('data', data, /* allowDeletes= */ false); + const firestoreData = documentRef._converter.toFirestore(data); + validateDocumentData('data', firestoreData, /* allowDeletes= */ false); this.verifyNotCommitted(); - const firestoreData = documentRef._converter.toFirestore(data); const transform = DocumentTransform.fromObject(documentRef, firestoreData); transform.validate(); diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 81ecd158a..afb5275bc 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -222,11 +222,10 @@ describe('CollectionReference class', () => { }); it('supports withConverter()', async () => { - const ref = firestore + const ref = await firestore .collection('col') .withConverter(postConverter) - .doc('doc'); - await ref.set(new Post('post', 'author')); + .add(new Post('post', 'author')); const postData = await ref.get(); const post = postData.data(); expect(post).to.not.be.undefined; diff --git a/dev/test/collection.ts b/dev/test/collection.ts index 7f6a65d44..5539b7e06 100644 --- a/dev/test/collection.ts +++ b/dev/test/collection.ts @@ -211,6 +211,66 @@ describe('Collection interface', () => { }); }); + it('for CollectionReference.withConverter().add()', async () => { + let doc = document('dummy'); + const overrides: ApiOverride = { + commit: request => { + // Extract the auto-generated document ID. + const docId = request.writes![0].update!.name!; + const docIdSplit = docId.split('/'); + doc = document( + docIdSplit[docIdSplit.length - 1], + 'author', + 'author', + 'title', + 'post' + ); + expect(request).to.deep.equal({ + database: DATABASE_ROOT, + writes: [ + { + update: { + fields: { + author: { + stringValue: 'author', + }, + title: { + stringValue: 'post', + }, + }, + name: docId, + }, + currentDocument: { + exists: false, + }, + }, + ], + }); + + return response(writeResult(1)); + }, + batchGetDocuments: () => { + const stream = through2.obj(); + setImmediate(() => { + stream.push({found: doc, readTime: {seconds: 5, nanos: 6}}); + stream.push(null); + }); + return stream; + }, + }; + + return createInstance(overrides).then(async firestore => { + const docRef = await firestore + .collection('collectionId') + .withConverter(postConverter) + .add(new Post('post', 'author')); + const postData = await docRef.get(); + const post = postData.data(); + expect(post).to.not.be.undefined; + expect(post!.toString()).to.equal('post, by author'); + }); + }); + it('drops the converter when calling CollectionReference.parent()', () => { return createInstance().then(async firestore => { const postsCollection = firestore From e35a098621b872b85a3ab70c6592eba75a929de8 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 18 Feb 2020 14:42:48 -0800 Subject: [PATCH 064/337] fix: propagate converter in QueryOptions.with() (#931) --- dev/src/reference.ts | 7 ++----- dev/test/query.ts | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 5b68c4b38..c75a71e00 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -1030,14 +1030,11 @@ export class QueryOptions { * Returns the union of the current and the provided options. * @private */ - with( - settings: Partial, 'converter'>>, - converter = defaultConverter as FirestoreDataConverter - ): QueryOptions { + with(settings: Partial, 'converter'>>): QueryOptions { return new QueryOptions( coalesce(settings.parentPath, this.parentPath)!, coalesce(settings.collectionId, this.collectionId)!, - converter, + this.converter, coalesce(settings.allDescendants, this.allDescendants)!, coalesce(settings.fieldFilters, this.fieldFilters)!, coalesce(settings.fieldOrders, this.fieldOrders)!, diff --git a/dev/test/query.ts b/dev/test/query.ts index 38f4b552b..b1577709a 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -658,6 +658,27 @@ describe('query interface', () => { expect(posts.docs[0].data().toString()).to.equal('post, by author'); }); }); + + it('propagates withConverter() through QueryOptions', async () => { + const doc = document('documentId', 'author', 'author', 'title', 'post'); + const overrides: ApiOverride = { + runQuery: request => { + queryEquals(request, fieldFilters('title', 'EQUAL', 'post')); + return stream({document: doc, readTime: {seconds: 5, nanos: 6}}); + }, + }; + + return createInstance(overrides).then(async firestore => { + const coll = await firestore + .collection('collectionId') + .withConverter(postConverter); + + // Verify that the converter is carried through. + const posts = await coll.where('title', '==', 'post').get(); + expect(posts.size).to.equal(1); + expect(posts.docs[0].data().toString()).to.equal('post, by author'); + }); + }); }); describe('where() interface', () => { From 1e5d63fbc39d9c3e6883e79a55e8a26634cd30c5 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 18 Feb 2020 17:54:12 -0800 Subject: [PATCH 065/337] fix: wait for operations to complete before deleting clients (#915) --- dev/src/index.ts | 35 +++++++++++++++++++++++++++++++++++ dev/src/pool.ts | 24 ++++++++++++++++++++++-- dev/src/watch.ts | 11 +++++++++-- dev/system-test/firestore.ts | 17 +++++++++++++++++ dev/test/pool.ts | 24 ++++++++++++++++++++++++ 5 files changed, 107 insertions(+), 4 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index 35f06fd09..8c54cb115 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -298,6 +298,14 @@ export class Firestore { */ private _projectId: string | undefined = undefined; + /** + * Count of listeners that have been registered on the client. + * + * The client can only be terminated when there are no registered listeners. + * @private + */ + private registeredListenersCount = 0; + // 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 @@ -987,12 +995,39 @@ export class Firestore { ); } + /** + * Registers a listener on this client, incrementing the listener count. This + * is used to verify that all listeners are unsubscribed when terminate() is + * called. + * + * @private + */ + registerListener(): void { + this.registeredListenersCount += 1; + } + + /** + * Unregisters a listener on this client, decrementing the listener count. + * This is used to verify that all listeners are unsubscribed when terminate() + * is called. + * + * @private + */ + unregisterListener(): void { + this.registeredListenersCount -= 1; + } + /** * Terminates the Firestore client and closes all open streams. * * @return A Promise that resolves when the client is terminated. */ terminate(): Promise { + if (this.registeredListenersCount > 0) { + return Promise.reject( + 'All onSnapshot() listeners must be unsubscribed before terminating the client.' + ); + } return this._clientPool.terminate(); } diff --git a/dev/src/pool.ts b/dev/src/pool.ts index 31080fcab..eb55c9f90 100644 --- a/dev/src/pool.ts +++ b/dev/src/pool.ts @@ -15,9 +15,9 @@ */ import * as assert from 'assert'; -import {describe, it} from 'mocha'; import {logger} from './logger'; +import {Deferred} from './util'; /** * An auto-resizing pool that distributes concurrent operations over multiple @@ -42,6 +42,12 @@ export class ClientPool { */ private terminated = false; + /** + * Deferred promise that is resolved when there are no active operations on + * the client pool after terminate() has been called. + */ + private terminateDeferred = new Deferred(); + /** * @param concurrentOperationLimit The number of operations that each client * can handle. @@ -112,8 +118,11 @@ export class ClientPool { */ private async release(requestTag: string, client: T): Promise { const requestCount = this.activeClients.get(client) || 0; - assert(requestCount > 0, 'No active request'); + assert(requestCount > 0, 'No active requests'); this.activeClients.set(client, requestCount - 1); + if (this.terminated && this.opCount === 0) { + this.terminateDeferred.resolve(); + } if (this.shouldGarbageCollectClient(client)) { this.activeClients.delete(client); @@ -195,6 +204,17 @@ export class ClientPool { async terminate(): Promise { this.terminated = true; + + // Wait for all pending operations to complete before terminating. + if (this.opCount > 0) { + logger( + 'ClientPool.terminate', + /* requestTag= */ null, + 'Waiting for %s pending operations to complete before terminating', + this.opCount + ); + await this.terminateDeferred.promise; + } for (const [client, _requestCount] of this.activeClients) { this.activeClients.delete(client); await this.clientDestructor(client); diff --git a/dev/src/watch.ts b/dev/src/watch.ts index 21a97d0eb..5983ea89e 100644 --- a/dev/src/watch.ts +++ b/dev/src/watch.ts @@ -252,16 +252,22 @@ abstract class Watch { this.initStream(); - return () => { + const unsubscribe = () => { logger('Watch.onSnapshot', this.requestTag, 'Unsubscribe called'); // Prevent further callbacks. - this.isActive = false; + if (this.isActive) { + // Unregister the listener iff it has not already been unregistered. + this.firestore.unregisterListener(); + this.isActive = false; + } this.onNext = () => {}; this.onError = () => {}; if (this.currentStream) { this.currentStream.end(); } }; + this.firestore.registerListener(); + return unsubscribe; } /** @@ -329,6 +335,7 @@ abstract class Watch { } if (this.isActive) { + this.firestore.unregisterListener(); this.isActive = false; logger('Watch.closeStream', this.requestTag, 'Invoking onError: ', err); this.onError(err); diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index afb5275bc..be23e3ad4 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -152,6 +152,23 @@ describe('Firestore class', () => { expect(err).to.equal('The client has already been terminated'); }); }); + + it('throws an error if terminate() is called with active listeners', async () => { + const ref = randomCol.doc('doc-1'); + const unsubscribe = ref.onSnapshot(() => { + // No-op + }); + + try { + await firestore.terminate(); + throw new Error('terminate() should have failed'); + } catch (err) { + expect(err).to.equal( + 'All onSnapshot() listeners must be unsubscribed before terminating the client.' + ); + unsubscribe(); + } + }); }); describe('CollectionReference class', () => { diff --git a/dev/test/pool.ts b/dev/test/pool.ts index 623af579d..3489ac54b 100644 --- a/dev/test/pool.ts +++ b/dev/test/pool.ts @@ -327,4 +327,28 @@ describe('Client pool', () => { expect(err).to.equal('The client has already been terminated'); }); }); + + it('waits for existing operations to complete before releasing clients', done => { + const clientPool = new ClientPool<{}>(1, 0, () => { + return {}; + }); + const deferred = new Deferred(); + let terminated = false; + + // Run operation that completes after terminate() is called. + clientPool.run(REQUEST_TAG, () => { + return deferred.promise; + }); + const terminateOp = clientPool.terminate().then(() => { + terminated = true; + }); + + expect(terminated).to.be.false; + // Mark the mock operation as "complete". + deferred.resolve(); + terminateOp.then(() => { + expect(terminated).to.be.true; + done(); + }); + }); }); From 1b142bc0abbc3b41149f8d8d7fdc1bdd107dc25c Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 18 Feb 2020 19:05:04 -0800 Subject: [PATCH 066/337] chore: release 3.5.1 (#932) --- CHANGELOG.md | 10 ++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34a217b1f..70dd9e6f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.5.1](https://www.github.com/googleapis/nodejs-firestore/compare/v3.5.0...v3.5.1) (2020-02-19) + + +### Bug Fixes + +* collectionReference.add() validation ([#925](https://www.github.com/googleapis/nodejs-firestore/issues/925)) ([19c2c75](https://www.github.com/googleapis/nodejs-firestore/commit/19c2c75d86c3aab967d21da16598016185ae360b)) +* pass x-goog-request-params header for streaming calls ([#920](https://www.github.com/googleapis/nodejs-firestore/issues/920)) ([cfbe19e](https://www.github.com/googleapis/nodejs-firestore/commit/cfbe19ed4c3cc6bb9ffc7b352de901150b8b9dea)) +* propagate converter in QueryOptions.with() ([#931](https://www.github.com/googleapis/nodejs-firestore/issues/931)) ([e35a098](https://www.github.com/googleapis/nodejs-firestore/commit/e35a098621b872b85a3ab70c6592eba75a929de8)) +* wait for operations to complete before deleting clients ([#915](https://www.github.com/googleapis/nodejs-firestore/issues/915)) ([1e5d63f](https://www.github.com/googleapis/nodejs-firestore/commit/1e5d63fbc39d9c3e6883e79a55e8a26634cd30c5)) + ## [3.5.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.4.1...v3.5.0) (2020-02-07) diff --git a/package.json b/package.json index c46aa993f..a1adc7dcf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.5.0", + "version": "3.5.1", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 0b69351c0..f1fce0180 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.5.0" + "@google-cloud/firestore": "^3.5.1" }, "devDependencies": { "chai": "^4.2.0", From 6c7a497aa1e42ee1e6876b6c8732f6f7d9c0062b Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 19 Feb 2020 11:53:30 -0800 Subject: [PATCH 067/337] chore: update protos (#935) --- .../google/longrunning/operations.proto | 10 ++- dev/protos/google/rpc/status.proto | 64 +++---------------- 2 files changed, 17 insertions(+), 57 deletions(-) diff --git a/dev/protos/google/longrunning/operations.proto b/dev/protos/google/longrunning/operations.proto index 90778e03e..299eefb2e 100644 --- a/dev/protos/google/longrunning/operations.proto +++ b/dev/protos/google/longrunning/operations.proto @@ -11,13 +11,13 @@ // 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. -// syntax = "proto3"; package google.longrunning; import "google/api/annotations.proto"; +import "google/api/client.proto"; import "google/protobuf/any.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/empty.proto"; @@ -52,6 +52,8 @@ extend google.protobuf.MethodOptions { // returns long-running operations should implement the `Operations` interface // so developers can have a consistent client experience. service Operations { + option (google.api.default_host) = "longrunning.googleapis.com"; + // Lists operations that match the specified filter in the request. If the // server doesn't support this method, it returns `UNIMPLEMENTED`. // @@ -66,6 +68,7 @@ service Operations { option (google.api.http) = { get: "/v1/{name=operations}" }; + option (google.api.method_signature) = "name,filter"; } // Gets the latest state of a long-running operation. Clients can use this @@ -75,6 +78,7 @@ service Operations { option (google.api.http) = { get: "/v1/{name=operations/**}" }; + option (google.api.method_signature) = "name"; } // Deletes a long-running operation. This method indicates that the client is @@ -85,6 +89,7 @@ service Operations { option (google.api.http) = { delete: "/v1/{name=operations/**}" }; + option (google.api.method_signature) = "name"; } // Starts asynchronous cancellation on a long-running operation. The server @@ -102,6 +107,7 @@ service Operations { post: "/v1/{name=operations/**}:cancel" body: "*" }; + option (google.api.method_signature) = "name"; } // Waits for the specified long-running operation until it is done or reaches @@ -122,7 +128,7 @@ service Operations { message Operation { // The server-assigned name, which is only unique within the same service that // originally returns it. If you use the default HTTP mapping, the - // `name` should have the format of `operations/some/unique/name`. + // `name` should be a resource name ending with `operations/{unique_id}`. string name = 1; // Service-specific metadata associated with the operation. It typically diff --git a/dev/protos/google/rpc/status.proto b/dev/protos/google/rpc/status.proto index b0daa3695..652c534c8 100644 --- a/dev/protos/google/rpc/status.proto +++ b/dev/protos/google/rpc/status.proto @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. +// Copyright 2019 Google LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,6 +11,7 @@ // 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. +// syntax = "proto3"; @@ -18,6 +19,7 @@ package google.rpc; import "google/protobuf/any.proto"; +option cc_enable_arenas = true; option go_package = "google.golang.org/genproto/googleapis/rpc/status;status"; option java_multiple_files = true; option java_outer_classname = "StatusProto"; @@ -26,66 +28,18 @@ option objc_class_prefix = "RPC"; // The `Status` type defines a logical error model that is suitable for // different programming environments, including REST APIs and RPC APIs. It is -// used by [gRPC](https://github.com/grpc). The error model is designed to be: -// -// - Simple to use and understand for most users -// - Flexible enough to meet unexpected needs -// -// # Overview -// -// The `Status` message contains three pieces of data: error code, error -// message, and error details. The error code should be an enum value of -// [google.rpc.Code][google.rpc.Code], but it may accept additional error codes -// if needed. The error message should be a developer-facing English message -// that helps developers *understand* and *resolve* the error. If a localized -// user-facing error message is needed, put the localized message in the error -// details or localize it in the client. The optional error details may contain -// arbitrary information about the error. There is a predefined set of error -// detail types in the package `google.rpc` that can be used for common error -// conditions. -// -// # Language mapping -// -// The `Status` message is the logical representation of the error model, but it -// is not necessarily the actual wire format. When the `Status` message is -// exposed in different client libraries and different wire protocols, it can be -// mapped differently. For example, it will likely be mapped to some exceptions -// in Java, but more likely mapped to some error codes in C. -// -// # Other uses -// -// The error model and the `Status` message can be used in a variety of -// environments, either with or without APIs, to provide a -// consistent developer experience across different environments. -// -// Example uses of this error model include: -// -// - Partial errors. If a service needs to return partial errors to the client, -// it may embed the `Status` in the normal response to indicate the partial -// errors. -// -// - Workflow errors. A typical workflow has multiple steps. Each step may -// have a `Status` message for error reporting. -// -// - Batch operations. If a client uses batch request and batch response, the -// `Status` message should be used directly inside batch response, one for -// each error sub-response. -// -// - Asynchronous operations. If an API call embeds asynchronous operation -// results in its response, the status of those operations should be -// represented directly using the `Status` message. +// used by [gRPC](https://github.com/grpc). Each `Status` message contains +// three pieces of data: error code, error message, and error details. // -// - Logging. If some API errors are stored in logs, the message `Status` could -// be used directly after any stripping needed for security/privacy reasons. +// You can find out more about this error model and how to work with it in the +// [API Design Guide](https://cloud.google.com/apis/design/errors). message Status { - // The status code, which should be an enum value of - // [google.rpc.Code][google.rpc.Code]. + // The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. int32 code = 1; // A developer-facing error message, which should be in English. Any // user-facing error message should be localized and sent in the - // [google.rpc.Status.details][google.rpc.Status.details] field, or localized - // by the client. + // [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. string message = 2; // A list of messages that carry the error details. There is a common set of From f78563b76458cd585fd9e0363ae72ce4ed02981b Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 26 Feb 2020 15:13:43 -0800 Subject: [PATCH 068/337] chore: add update_transform (#940) --- dev/protos/google/firestore/v1/common.proto | 3 +- dev/protos/google/firestore/v1/document.proto | 3 +- .../google/firestore/v1/firestore.proto | 19 +- dev/protos/google/firestore/v1/query.proto | 31 ++-- dev/protos/google/firestore/v1/write.proto | 13 +- dev/protos/protos.json | 51 ++--- dev/src/v1/firestore_client.ts | 174 +++++++++--------- dev/src/v1/firestore_client_config.json | 10 +- dev/synth.metadata | 107 ++--------- dev/test/gapic-firestore-v1.ts | 96 +++++----- 10 files changed, 213 insertions(+), 294 deletions(-) diff --git a/dev/protos/google/firestore/v1/common.proto b/dev/protos/google/firestore/v1/common.proto index 8e2ef27ff..b6de070a5 100644 --- a/dev/protos/google/firestore/v1/common.proto +++ b/dev/protos/google/firestore/v1/common.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// 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. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; diff --git a/dev/protos/google/firestore/v1/document.proto b/dev/protos/google/firestore/v1/document.proto index 9110b4ff6..43f69478e 100644 --- a/dev/protos/google/firestore/v1/document.proto +++ b/dev/protos/google/firestore/v1/document.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// 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. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; diff --git a/dev/protos/google/firestore/v1/firestore.proto b/dev/protos/google/firestore/v1/firestore.proto index 9af30b7a4..5f9b6d732 100644 --- a/dev/protos/google/firestore/v1/firestore.proto +++ b/dev/protos/google/firestore/v1/firestore.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// 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. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; @@ -66,14 +65,6 @@ service Firestore { }; } - // Creates a new document. - rpc CreateDocument(CreateDocumentRequest) returns (Document) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/databases/*/documents/**}/{collection_id}" - body: "document" - }; - } - // Updates or inserts a document. rpc UpdateDocument(UpdateDocumentRequest) returns (Document) { option (google.api.http) = { @@ -169,6 +160,14 @@ service Firestore { }; option (google.api.method_signature) = "parent"; } + + // Creates a new document. + rpc CreateDocument(CreateDocumentRequest) returns (Document) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*/documents/**}/{collection_id}" + body: "document" + }; + } } // The request for [Firestore.GetDocument][google.firestore.v1.Firestore.GetDocument]. diff --git a/dev/protos/google/firestore/v1/query.proto b/dev/protos/google/firestore/v1/query.proto index fa34daf7a..226d32418 100644 --- a/dev/protos/google/firestore/v1/query.proto +++ b/dev/protos/google/firestore/v1/query.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// 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. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; @@ -122,6 +121,15 @@ message StructuredQuery { Value value = 3; } + // The projection of document's fields to return. + message Projection { + // The fields to return. + // + // If empty, all fields are returned. To only return the name + // of the document, use `['__name__']`. + repeated FieldReference fields = 2; + } + // A filter with a single operand. message UnaryFilter { // A unary operator. @@ -146,6 +154,11 @@ message StructuredQuery { } } + // A reference to a field, such as `max(messages.time) as max_time`. + message FieldReference { + string field_path = 2; + } + // An order on a field. message Order { // The field to order by. @@ -155,20 +168,6 @@ message StructuredQuery { Direction direction = 2; } - // A reference to a field, such as `max(messages.time) as max_time`. - message FieldReference { - string field_path = 2; - } - - // The projection of document's fields to return. - message Projection { - // The fields to return. - // - // If empty, all fields are returned. To only return the name - // of the document, use `['__name__']`. - repeated FieldReference fields = 2; - } - // A sort direction. enum Direction { // Unspecified. diff --git a/dev/protos/google/firestore/v1/write.proto b/dev/protos/google/firestore/v1/write.proto index 51d923918..403c80f81 100644 --- a/dev/protos/google/firestore/v1/write.proto +++ b/dev/protos/google/firestore/v1/write.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// 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. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; @@ -42,9 +41,6 @@ message Write { string delete = 2; // Applies a transformation to a document. - // At most one `transform` per document is allowed in a given request. - // An `update` cannot follow a `transform` on the same document in a given - // request. DocumentTransform transform = 6; } @@ -60,6 +56,13 @@ message Write { // The field paths in this mask must not contain a reserved field name. DocumentMask update_mask = 3; + // The transforms to perform after update. + // + // This field can be set only when the operation is `update`. If present, this + // write is equivalent to performing `update` and `transform` to the same + // document atomically and in order. + repeated DocumentTransform.FieldTransform update_transforms = 7; + // An optional precondition on the document. // // The write will fail if this is set and not met by the target document. diff --git a/dev/protos/protos.json b/dev/protos/protos.json index 6e4359b9d..8d231d120 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -815,14 +815,6 @@ "(google.api.http).get": "/v1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" } }, - "CreateDocument": { - "requestType": "CreateDocumentRequest", - "responseType": "Document", - "options": { - "(google.api.http).post": "/v1/{parent=projects/*/databases/*/documents/**}/{collection_id}", - "(google.api.http).body": "document" - } - }, "UpdateDocument": { "requestType": "UpdateDocumentRequest", "responseType": "Document", @@ -917,6 +909,14 @@ "(google.api.http).additional_bindings.body": "*", "(google.api.method_signature)": "parent" } + }, + "CreateDocument": { + "requestType": "CreateDocumentRequest", + "responseType": "Document", + "options": { + "(google.api.http).post": "/v1/{parent=projects/*/databases/*/documents/**}/{collection_id}", + "(google.api.http).body": "document" + } } } }, @@ -1677,6 +1677,15 @@ } } }, + "Projection": { + "fields": { + "fields": { + "rule": "repeated", + "type": "FieldReference", + "id": 2 + } + } + }, "UnaryFilter": { "oneofs": { "operandType": { @@ -1705,18 +1714,6 @@ } } }, - "Order": { - "fields": { - "field": { - "type": "FieldReference", - "id": 1 - }, - "direction": { - "type": "Direction", - "id": 2 - } - } - }, "FieldReference": { "fields": { "fieldPath": { @@ -1725,11 +1722,14 @@ } } }, - "Projection": { + "Order": { "fields": { - "fields": { - "rule": "repeated", + "field": { "type": "FieldReference", + "id": 1 + }, + "direction": { + "type": "Direction", "id": 2 } } @@ -1783,6 +1783,11 @@ "type": "DocumentMask", "id": 3 }, + "updateTransforms": { + "rule": "repeated", + "type": "DocumentTransform.FieldTransform", + "id": 7 + }, "currentDocument": { "type": "Precondition", "id": 4 diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 6eaf680e0..40008b2e5 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -201,7 +201,6 @@ export class FirestoreClient { const firestoreStubMethods = [ 'getDocument', 'listDocuments', - 'createDocument', 'updateDocument', 'deleteDocument', 'batchGetDocuments', @@ -212,6 +211,7 @@ export class FirestoreClient { 'write', 'listen', 'listCollectionIds', + 'createDocument', ]; for (const methodName of firestoreStubMethods) { @@ -380,92 +380,6 @@ export class FirestoreClient { }); return this._innerApiCalls.getDocument(request, options, callback); } - 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; - /** - * Creates a new document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource. For example: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` - * @param {string} request.collectionId - * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. - * @param {string} request.documentId - * The client-assigned document ID to use for this document. - * - * Optional. If not specified, an ID will be assigned by the service. - * @param {google.firestore.v1.Document} request.document - * Required. The document to create. `name` must not be set. - * @param {google.firestore.v1.DocumentMask} request.mask - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * @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 [Document]{@link google.firestore.v1.Document}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ - createDocument( - request: protosTypes.google.firestore.v1.ICreateDocumentRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.ICreateDocumentRequest | undefined, - {} | undefined - >, - callback?: Callback< - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.ICreateDocumentRequest | undefined, - {} | undefined - > - ): Promise< - [ - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.ICreateDocumentRequest | undefined, - {} | undefined - ] - > | void { - request = request || {}; - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - 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 || '', - }); - return this._innerApiCalls.createDocument(request, options, callback); - } updateDocument( request: protosTypes.google.firestore.v1.IUpdateDocumentRequest, options?: gax.CallOptions @@ -856,6 +770,92 @@ export class FirestoreClient { }); return this._innerApiCalls.rollback(request, options, callback); } + 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; + /** + * Creates a new document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. For example: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` + * @param {string} request.collectionId + * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. + * @param {string} request.documentId + * The client-assigned document ID to use for this document. + * + * Optional. If not specified, an ID will be assigned by the service. + * @param {google.firestore.v1.Document} request.document + * Required. The document to create. `name` must not be set. + * @param {google.firestore.v1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + * @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 [Document]{@link google.firestore.v1.Document}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ + createDocument( + request: protosTypes.google.firestore.v1.ICreateDocumentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protosTypes.google.firestore.v1.IDocument, + protosTypes.google.firestore.v1.ICreateDocumentRequest | undefined, + {} | undefined + >, + callback?: Callback< + protosTypes.google.firestore.v1.IDocument, + protosTypes.google.firestore.v1.ICreateDocumentRequest | undefined, + {} | undefined + > + ): Promise< + [ + protosTypes.google.firestore.v1.IDocument, + protosTypes.google.firestore.v1.ICreateDocumentRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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 || '', + }); + return this._innerApiCalls.createDocument(request, options, callback); + } /** * Gets multiple documents. diff --git a/dev/src/v1/firestore_client_config.json b/dev/src/v1/firestore_client_config.json index b1e32f327..b832f2b4b 100644 --- a/dev/src/v1/firestore_client_config.json +++ b/dev/src/v1/firestore_client_config.json @@ -35,11 +35,6 @@ "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, - "CreateDocument": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, "UpdateDocument": { "timeout_millis": 60000, "retry_codes_name": "non_idempotent", @@ -89,6 +84,11 @@ "timeout_millis": 60000, "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" + }, + "CreateDocument": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" } } } diff --git a/dev/synth.metadata b/dev/synth.metadata index fc8647cbf..7270827d8 100644 --- a/dev/synth.metadata +++ b/dev/synth.metadata @@ -1,19 +1,26 @@ { - "updateTime": "2020-02-07T18:50:00.377881Z", + "updateTime": "2020-02-26T23:06:26.717008Z", "sources": [ + { + "git": { + "name": ".", + "remote": "git@github.com:googleapis/nodejs-firestore.git", + "sha": "6c7a497aa1e42ee1e6876b6c8732f6f7d9c0062b" + } + }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "e46f761cd6ec15a9e3d5ed4ff321a4bcba8e8585", - "internalRef": "293710856" + "sha": "f077632ba7fee588922d9e8717ee272039be126d", + "internalRef": "297405063" } }, { "template": { "name": "node_library", "origin": "synthtool.gcp", - "version": "2019.10.17" + "version": "2020.2.4" } } ], @@ -45,97 +52,5 @@ "generator": "gapic-generator-typescript" } } - ], - "newFiles": [ - { - "path": ".gitignore" - }, - { - "path": ".mocharc.json" - }, - { - "path": "protos/google/firestore/admin/v1/field.proto" - }, - { - "path": "protos/google/firestore/admin/v1/firestore_admin.proto" - }, - { - "path": "protos/google/firestore/admin/v1/index.proto" - }, - { - "path": "protos/google/firestore/admin/v1/location.proto" - }, - { - "path": "protos/google/firestore/admin/v1/operation.proto" - }, - { - "path": "protos/google/firestore/v1/common.proto" - }, - { - "path": "protos/google/firestore/v1/document.proto" - }, - { - "path": "protos/google/firestore/v1/firestore.proto" - }, - { - "path": "protos/google/firestore/v1/query.proto" - }, - { - "path": "protos/google/firestore/v1/write.proto" - }, - { - "path": "protos/google/firestore/v1beta1/common.proto" - }, - { - "path": "protos/google/firestore/v1beta1/document.proto" - }, - { - "path": "protos/google/firestore/v1beta1/firestore.proto" - }, - { - "path": "protos/google/firestore/v1beta1/query.proto" - }, - { - "path": "protos/google/firestore/v1beta1/write.proto" - }, - { - "path": "protos/protos.json" - }, - { - "path": "src/v1/firestore_admin_client.ts" - }, - { - "path": "src/v1/firestore_admin_client_config.json" - }, - { - "path": "src/v1/firestore_admin_proto_list.json" - }, - { - "path": "src/v1/firestore_client.ts" - }, - { - "path": "src/v1/firestore_client_config.json" - }, - { - "path": "src/v1/firestore_proto_list.json" - }, - { - "path": "src/v1beta1/firestore_client.ts" - }, - { - "path": "src/v1beta1/firestore_client_config.json" - }, - { - "path": "src/v1beta1/firestore_proto_list.json" - }, - { - "path": "test/gapic-firestore-v1.ts" - }, - { - "path": "test/gapic-firestore-v1beta1.ts" - }, - { - "path": "test/gapic-firestore_admin-v1.ts" - } ] } \ No newline at end of file diff --git a/dev/test/gapic-firestore-v1.ts b/dev/test/gapic-firestore-v1.ts index 8f9d73780..5bca2d0c6 100644 --- a/dev/test/gapic-firestore-v1.ts +++ b/dev/test/gapic-firestore-v1.ts @@ -171,54 +171,6 @@ describe('v1.FirestoreClient', () => { }); }); }); - describe('createDocument', () => { - it('invokes createDocument without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const request: protosTypes.google.firestore.v1.ICreateDocumentRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createDocument = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.createDocument(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes createDocument with error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Mock request - const request: protosTypes.google.firestore.v1.ICreateDocumentRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createDocument = mockSimpleGrpcMethod( - request, - null, - error - ); - client.createDocument(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); describe('updateDocument', () => { it('invokes updateDocument without error', done => { const client = new firestoreModule.v1.FirestoreClient({ @@ -457,6 +409,54 @@ describe('v1.FirestoreClient', () => { }); }); }); + describe('createDocument', () => { + it('invokes createDocument without error', done => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.v1.ICreateDocumentRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createDocument = mockSimpleGrpcMethod( + request, + expectedResponse, + null + ); + client.createDocument(request, (err: {}, response: {}) => { + assert.ifError(err); + assert.deepStrictEqual(response, expectedResponse); + done(); + }); + }); + + it('invokes createDocument with error', done => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + // Mock request + const request: protosTypes.google.firestore.v1.ICreateDocumentRequest = {}; + request.parent = ''; + // Mock response + const expectedResponse = {}; + // Mock gRPC layer + client._innerApiCalls.createDocument = mockSimpleGrpcMethod( + request, + null, + error + ); + client.createDocument(request, (err: FakeError, response: {}) => { + assert(err instanceof FakeError); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + assert(typeof response === 'undefined'); + done(); + }); + }); + }); describe('batchGetDocuments', () => { it('invokes batchGetDocuments without error', done => { const client = new firestoreModule.v1.FirestoreClient({ From f395e8cf50781af5848875c86684abbc29e79bcd Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Wed, 26 Feb 2020 20:00:12 -0800 Subject: [PATCH 069/337] build: add publish.yml enabling GitHub app for publishes --- .github/publish.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/publish.yml diff --git a/.github/publish.yml b/.github/publish.yml new file mode 100644 index 000000000..e69de29bb From b4dbff3c4413a9ee014a3705d81b13c1a1f34505 Mon Sep 17 00:00:00 2001 From: Summer Ji Date: Thu, 27 Feb 2020 11:53:32 -0800 Subject: [PATCH 070/337] chore: update jsdoc.js (#942) --- .jsdoc.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.jsdoc.js b/.jsdoc.js index d52e77079..f92b200f1 100644 --- a/.jsdoc.js +++ b/.jsdoc.js @@ -36,11 +36,14 @@ module.exports = { includePattern: '\\.js$' }, templates: { - copyright: 'Copyright 2018 Google, LLC.', + copyright: 'Copyright 2019 Google, LLC.', includeDate: false, sourceFiles: false, systemName: '@google-cloud/firestore', - theme: 'lumen' + theme: 'lumen', + default: { + "outputSourceFiles": false + } }, markdown: { idInHeadings: true From 3d91bac1dc693726fe9b45b9bb8e6413a63679d1 Mon Sep 17 00:00:00 2001 From: Summer Ji Date: Fri, 28 Feb 2020 16:32:45 -0800 Subject: [PATCH 071/337] chore: update jsdoc with macro license (#946) --- .jsdoc.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.jsdoc.js b/.jsdoc.js index f92b200f1..f521f240e 100644 --- a/.jsdoc.js +++ b/.jsdoc.js @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. // +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** 'use strict'; From 7dc0b239dfa03b22ec5eaa61aa5b50e57115241f Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 3 Mar 2020 09:19:48 -0800 Subject: [PATCH 072/337] chore: run update.sh on update_transfrom protos (#948) --- dev/protos/firestore_v1_proto_api.d.ts | 120 +++++++-------- dev/protos/firestore_v1_proto_api.js | 194 +++++++++++++------------ 2 files changed, 165 insertions(+), 149 deletions(-) diff --git a/dev/protos/firestore_v1_proto_api.d.ts b/dev/protos/firestore_v1_proto_api.d.ts index 5e5584154..0531279d2 100644 --- a/dev/protos/firestore_v1_proto_api.d.ts +++ b/dev/protos/firestore_v1_proto_api.d.ts @@ -1825,20 +1825,6 @@ export namespace google { */ public listDocuments(request: google.firestore.v1.IListDocumentsRequest): Promise; - /** - * Calls CreateDocument. - * @param request CreateDocumentRequest message or plain object - * @param callback Node-style callback called with the error, if any, and Document - */ - public createDocument(request: google.firestore.v1.ICreateDocumentRequest, callback: google.firestore.v1.Firestore.CreateDocumentCallback): void; - - /** - * Calls CreateDocument. - * @param request CreateDocumentRequest message or plain object - * @returns Promise - */ - public createDocument(request: google.firestore.v1.ICreateDocumentRequest): Promise; - /** * Calls UpdateDocument. * @param request UpdateDocumentRequest message or plain object @@ -1978,6 +1964,20 @@ export namespace google { * @returns Promise */ public listCollectionIds(request: google.firestore.v1.IListCollectionIdsRequest): Promise; + + /** + * Calls CreateDocument. + * @param request CreateDocumentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Document + */ + public createDocument(request: google.firestore.v1.ICreateDocumentRequest, callback: google.firestore.v1.Firestore.CreateDocumentCallback): void; + + /** + * Calls CreateDocument. + * @param request CreateDocumentRequest message or plain object + * @returns Promise + */ + public createDocument(request: google.firestore.v1.ICreateDocumentRequest): Promise; } namespace Firestore { @@ -1996,13 +1996,6 @@ export namespace google { */ type ListDocumentsCallback = (error: (Error|null), response?: google.firestore.v1.ListDocumentsResponse) => void; - /** - * Callback as used by {@link google.firestore.v1.Firestore#createDocument}. - * @param error Error, if any - * @param [response] Document - */ - type CreateDocumentCallback = (error: (Error|null), response?: google.firestore.v1.Document) => void; - /** * Callback as used by {@link google.firestore.v1.Firestore#updateDocument}. * @param error Error, if any @@ -2072,6 +2065,13 @@ export namespace google { * @param [response] ListCollectionIdsResponse */ type ListCollectionIdsCallback = (error: (Error|null), response?: google.firestore.v1.ListCollectionIdsResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1.Firestore#createDocument}. + * @param error Error, if any + * @param [response] Document + */ + type CreateDocumentCallback = (error: (Error|null), response?: google.firestore.v1.Document) => void; } /** Properties of a GetDocumentRequest. */ @@ -3216,6 +3216,26 @@ export namespace google { "OPERATOR_UNSPECIFIED"| "LESS_THAN"| "LESS_THAN_OR_EQUAL"| "GREATER_THAN"| "GREATER_THAN_OR_EQUAL"| "EQUAL"| "ARRAY_CONTAINS"| "IN"| "ARRAY_CONTAINS_ANY"; } + /** Properties of a Projection. */ + interface IProjection { + + /** Projection fields */ + fields?: (google.firestore.v1.StructuredQuery.IFieldReference[]|null); + } + + /** Represents a Projection. */ + class Projection implements IProjection { + + /** + * Constructs a new Projection. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.StructuredQuery.IProjection); + + /** Projection fields. */ + public fields: google.firestore.v1.StructuredQuery.IFieldReference[]; + } + /** Properties of an UnaryFilter. */ interface IUnaryFilter { @@ -3252,32 +3272,6 @@ export namespace google { "OPERATOR_UNSPECIFIED"| "IS_NAN"| "IS_NULL"; } - /** Properties of an Order. */ - interface IOrder { - - /** Order field */ - field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); - - /** Order direction */ - direction?: (google.firestore.v1.StructuredQuery.Direction|null); - } - - /** Represents an Order. */ - class Order implements IOrder { - - /** - * Constructs a new Order. - * @param [properties] Properties to set - */ - constructor(properties?: google.firestore.v1.StructuredQuery.IOrder); - - /** Order field. */ - public field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); - - /** Order direction. */ - public direction: google.firestore.v1.StructuredQuery.Direction; - } - /** Properties of a FieldReference. */ interface IFieldReference { @@ -3298,24 +3292,30 @@ export namespace google { public fieldPath: string; } - /** Properties of a Projection. */ - interface IProjection { + /** Properties of an Order. */ + interface IOrder { - /** Projection fields */ - fields?: (google.firestore.v1.StructuredQuery.IFieldReference[]|null); + /** Order field */ + field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); + + /** Order direction */ + direction?: (google.firestore.v1.StructuredQuery.Direction|null); } - /** Represents a Projection. */ - class Projection implements IProjection { + /** Represents an Order. */ + class Order implements IOrder { /** - * Constructs a new Projection. + * Constructs a new Order. * @param [properties] Properties to set */ - constructor(properties?: google.firestore.v1.StructuredQuery.IProjection); + constructor(properties?: google.firestore.v1.StructuredQuery.IOrder); - /** Projection fields. */ - public fields: google.firestore.v1.StructuredQuery.IFieldReference[]; + /** Order field. */ + public field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); + + /** Order direction. */ + public direction: google.firestore.v1.StructuredQuery.Direction; } /** Direction enum. */ @@ -3364,6 +3364,9 @@ export namespace google { /** Write updateMask */ updateMask?: (google.firestore.v1.IDocumentMask|null); + /** Write updateTransforms */ + updateTransforms?: (google.firestore.v1.DocumentTransform.IFieldTransform[]|null); + /** Write currentDocument */ currentDocument?: (google.firestore.v1.IPrecondition|null); } @@ -3389,6 +3392,9 @@ export namespace google { /** Write updateMask. */ public updateMask?: (google.firestore.v1.IDocumentMask|null); + /** Write updateTransforms. */ + public updateTransforms: google.firestore.v1.DocumentTransform.IFieldTransform[]; + /** Write currentDocument. */ public currentDocument?: (google.firestore.v1.IPrecondition|null); diff --git a/dev/protos/firestore_v1_proto_api.js b/dev/protos/firestore_v1_proto_api.js index 9a0f3ea32..860d68df5 100644 --- a/dev/protos/firestore_v1_proto_api.js +++ b/dev/protos/firestore_v1_proto_api.js @@ -3216,39 +3216,6 @@ $root.google = (function() { * @variation 2 */ - /** - * Callback as used by {@link google.firestore.v1.Firestore#createDocument}. - * @memberof google.firestore.v1.Firestore - * @typedef CreateDocumentCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1.Document} [response] Document - */ - - /** - * Calls CreateDocument. - * @function createDocument - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object - * @param {google.firestore.v1.Firestore.CreateDocumentCallback} callback Node-style callback called with the error, if any, and Document - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Firestore.prototype.createDocument = function createDocument(request, callback) { - return this.rpcCall(createDocument, $root.google.firestore.v1.CreateDocumentRequest, $root.google.firestore.v1.Document, request, callback); - }, "name", { value: "CreateDocument" }); - - /** - * Calls CreateDocument. - * @function createDocument - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - /** * Callback as used by {@link google.firestore.v1.Firestore#updateDocument}. * @memberof google.firestore.v1.Firestore @@ -3579,6 +3546,39 @@ $root.google = (function() { * @variation 2 */ + /** + * Callback as used by {@link google.firestore.v1.Firestore#createDocument}. + * @memberof google.firestore.v1.Firestore + * @typedef CreateDocumentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1.Document} [response] Document + */ + + /** + * Calls CreateDocument. + * @function createDocument + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object + * @param {google.firestore.v1.Firestore.CreateDocumentCallback} callback Node-style callback called with the error, if any, and Document + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.createDocument = function createDocument(request, callback) { + return this.rpcCall(createDocument, $root.google.firestore.v1.CreateDocumentRequest, $root.google.firestore.v1.Document, request, callback); + }, "name", { value: "CreateDocument" }); + + /** + * Calls CreateDocument. + * @function createDocument + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + return Firestore; })(); @@ -5587,6 +5587,42 @@ $root.google = (function() { return FieldFilter; })(); + StructuredQuery.Projection = (function() { + + /** + * Properties of a Projection. + * @memberof google.firestore.v1.StructuredQuery + * @interface IProjection + * @property {Array.|null} [fields] Projection fields + */ + + /** + * Constructs a new Projection. + * @memberof google.firestore.v1.StructuredQuery + * @classdesc Represents a Projection. + * @implements IProjection + * @constructor + * @param {google.firestore.v1.StructuredQuery.IProjection=} [properties] Properties to set + */ + function Projection(properties) { + this.fields = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Projection fields. + * @member {Array.} fields + * @memberof google.firestore.v1.StructuredQuery.Projection + * @instance + */ + Projection.prototype.fields = $util.emptyArray; + + return Projection; + })(); + StructuredQuery.UnaryFilter = (function() { /** @@ -5661,50 +5697,6 @@ $root.google = (function() { return UnaryFilter; })(); - StructuredQuery.Order = (function() { - - /** - * Properties of an Order. - * @memberof google.firestore.v1.StructuredQuery - * @interface IOrder - * @property {google.firestore.v1.StructuredQuery.IFieldReference|null} [field] Order field - * @property {google.firestore.v1.StructuredQuery.Direction|null} [direction] Order direction - */ - - /** - * Constructs a new Order. - * @memberof google.firestore.v1.StructuredQuery - * @classdesc Represents an Order. - * @implements IOrder - * @constructor - * @param {google.firestore.v1.StructuredQuery.IOrder=} [properties] Properties to set - */ - function Order(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Order field. - * @member {google.firestore.v1.StructuredQuery.IFieldReference|null|undefined} field - * @memberof google.firestore.v1.StructuredQuery.Order - * @instance - */ - Order.prototype.field = null; - - /** - * Order direction. - * @member {google.firestore.v1.StructuredQuery.Direction} direction - * @memberof google.firestore.v1.StructuredQuery.Order - * @instance - */ - Order.prototype.direction = 0; - - return Order; - })(); - StructuredQuery.FieldReference = (function() { /** @@ -5740,25 +5732,25 @@ $root.google = (function() { return FieldReference; })(); - StructuredQuery.Projection = (function() { + StructuredQuery.Order = (function() { /** - * Properties of a Projection. + * Properties of an Order. * @memberof google.firestore.v1.StructuredQuery - * @interface IProjection - * @property {Array.|null} [fields] Projection fields + * @interface IOrder + * @property {google.firestore.v1.StructuredQuery.IFieldReference|null} [field] Order field + * @property {google.firestore.v1.StructuredQuery.Direction|null} [direction] Order direction */ /** - * Constructs a new Projection. + * Constructs a new Order. * @memberof google.firestore.v1.StructuredQuery - * @classdesc Represents a Projection. - * @implements IProjection + * @classdesc Represents an Order. + * @implements IOrder * @constructor - * @param {google.firestore.v1.StructuredQuery.IProjection=} [properties] Properties to set + * @param {google.firestore.v1.StructuredQuery.IOrder=} [properties] Properties to set */ - function Projection(properties) { - this.fields = []; + function Order(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -5766,14 +5758,22 @@ $root.google = (function() { } /** - * Projection fields. - * @member {Array.} fields - * @memberof google.firestore.v1.StructuredQuery.Projection + * Order field. + * @member {google.firestore.v1.StructuredQuery.IFieldReference|null|undefined} field + * @memberof google.firestore.v1.StructuredQuery.Order * @instance */ - Projection.prototype.fields = $util.emptyArray; + Order.prototype.field = null; - return Projection; + /** + * Order direction. + * @member {google.firestore.v1.StructuredQuery.Direction} direction + * @memberof google.firestore.v1.StructuredQuery.Order + * @instance + */ + Order.prototype.direction = 0; + + return Order; })(); /** @@ -5850,6 +5850,7 @@ $root.google = (function() { * @property {string|null} ["delete"] Write delete * @property {google.firestore.v1.IDocumentTransform|null} [transform] Write transform * @property {google.firestore.v1.IDocumentMask|null} [updateMask] Write updateMask + * @property {Array.|null} [updateTransforms] Write updateTransforms * @property {google.firestore.v1.IPrecondition|null} [currentDocument] Write currentDocument */ @@ -5862,6 +5863,7 @@ $root.google = (function() { * @param {google.firestore.v1.IWrite=} [properties] Properties to set */ function Write(properties) { + this.updateTransforms = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -5900,6 +5902,14 @@ $root.google = (function() { */ Write.prototype.updateMask = null; + /** + * Write updateTransforms. + * @member {Array.} updateTransforms + * @memberof google.firestore.v1.Write + * @instance + */ + Write.prototype.updateTransforms = $util.emptyArray; + /** * Write currentDocument. * @member {google.firestore.v1.IPrecondition|null|undefined} currentDocument From 24a96c65ecbc4df0fc69b9a7f64e9e508fea89b9 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Wed, 4 Mar 2020 13:48:29 -0500 Subject: [PATCH 073/337] feat: implement Timestamp.valueOf() (#947) This enables Timestamp objects to be compared for relative ordering using the <, <=, >, and >= operators. Fixes #944 --- dev/src/timestamp.ts | 34 +++++++++++++++++++++- dev/test/timestamp.ts | 68 ++++++++++++++++++++++++++++++++++++++++++- types/firestore.d.ts | 8 +++++ 3 files changed, 108 insertions(+), 2 deletions(-) diff --git a/dev/src/timestamp.ts b/dev/src/timestamp.ts index be8828c3f..f92a9e29b 100644 --- a/dev/src/timestamp.ts +++ b/dev/src/timestamp.ts @@ -26,6 +26,15 @@ import api = google.firestore.v1; */ const MS_TO_NANOS = 1000000; +/*! + * The minimum legal value for the "seconds" property of a Timestamp object. + * + * This value corresponds to 0001-01-01T00:00:00Z. + * + * @type {number} + */ +const MIN_SECONDS = -62135596800; + /** * A Timestamp represents a point in time independent of any time zone or * calendar, represented as seconds and fractions of seconds at nanosecond @@ -121,7 +130,10 @@ export class Timestamp { * from 0 to 999,999,999 inclusive. */ constructor(seconds: number, nanoseconds: number) { - validateInteger('seconds', seconds); + validateInteger('seconds', seconds, { + minValue: -62135596800, + maxValue: 253402300799, + }); validateInteger('nanoseconds', nanoseconds, { minValue: 0, maxValue: 999999999, @@ -248,4 +260,24 @@ export class Timestamp { return {timestampValue: timestamp}; } + + /** + * Converts this object to a primitive `string`, which allows `Timestamp` objects to be compared + * using the `>`, `<=`, `>=` and `>` operators. + * + * @return {string} a string encoding of this object. + */ + valueOf(): string { + // This method returns a string of the form . where is + // translated to have a non-negative value and both and are left-padded + // with zeroes to be a consistent length. Strings with this format then have a lexiographical + // ordering that matches the expected ordering. The translation is done to avoid + // having a leading negative sign (i.e. a leading '-' character) in its string representation, + // which would affect its lexiographical ordering. + const adjustedSeconds = this.seconds - MIN_SECONDS; + // Note: Up to 12 decimal digits are required to represent all valid 'seconds' values. + const formattedSeconds = String(adjustedSeconds).padStart(12, '0'); + const formattedNanoseconds = String(this.nanoseconds).padStart(9, '0'); + return formattedSeconds + '.' + formattedNanoseconds; + } } diff --git a/dev/test/timestamp.ts b/dev/test/timestamp.ts index 7a3995702..59c7c6d4e 100644 --- a/dev/test/timestamp.ts +++ b/dev/test/timestamp.ts @@ -131,11 +131,21 @@ describe('timestamps', () => { expect(actual.isEqual(expected)).to.be.true; }); - it('validates nanoseconds', () => { + it('validates seconds', () => { expect(() => new Firestore.Timestamp(0.1, 0)).to.throw( 'Value for argument "seconds" is not a valid integer.' ); + expect(() => new Firestore.Timestamp(-62135596801, 0)).to.throw( + 'Value for argument "seconds" must be within [-62135596800, 253402300799] inclusive, but was: -62135596801' + ); + + expect(() => new Firestore.Timestamp(253402300800, 0)).to.throw( + 'Value for argument "seconds" must be within [-62135596800, 253402300799] inclusive, but was: 253402300800' + ); + }); + + it('validates nanoseconds', () => { expect(() => new Firestore.Timestamp(0, 0.1)).to.throw( 'Value for argument "nanoseconds" is not a valid integer.' ); @@ -148,4 +158,60 @@ describe('timestamps', () => { 'Value for argument "nanoseconds" must be within [0, 999999999] inclusive, but was: 1000000000' ); }); + + it('valueOf', () => { + expect(new Firestore.Timestamp(-62135596677, 456).valueOf()).to.equal( + '000000000123.000000456' + ); + expect(new Firestore.Timestamp(-62135596800, 0).valueOf()).to.equal( + '000000000000.000000000' + ); + expect(new Firestore.Timestamp(253402300799, 1e9 - 1).valueOf()).to.equal( + '315537897599.999999999' + ); + }); + + it('arithmetic comparison of a Timestamp object to itself', () => { + const timestamp = new Firestore.Timestamp(1, 1); + expect(timestamp < timestamp).to.be.false; + expect(timestamp <= timestamp).to.be.true; + expect(timestamp > timestamp).to.be.false; + expect(timestamp >= timestamp).to.be.true; + }); + + it('arithmetic comparison of equivalent, but distinct, Timestamp objects', () => { + const t1 = new Firestore.Timestamp(1, 1); + const t2 = new Firestore.Timestamp(1, 1); + expect(t1 < t2).to.be.false; + expect(t1 <= t2).to.be.true; + expect(t1 > t2).to.be.false; + expect(t1 >= t2).to.be.true; + }); + + it('arithmetic comparison of Timestamp objects whose nanoseconds differ', () => { + const t1 = new Firestore.Timestamp(1, 1); + const t2 = new Firestore.Timestamp(1, 2); + expect(t1 < t2).to.be.true; + expect(t1 <= t2).to.be.true; + expect(t1 > t2).to.be.false; + expect(t1 >= t2).to.be.false; + }); + + it('arithmetic comparison of Timestamp objects whose seconds differ', () => { + const t1 = new Firestore.Timestamp(100, 0); + const t2 = new Firestore.Timestamp(200, 0); + expect(t1 < t2).to.be.true; + expect(t1 <= t2).to.be.true; + expect(t1 > t2).to.be.false; + expect(t1 >= t2).to.be.false; + }); + + it('arithmetic comparison of the smallest and largest Timestamp objects', () => { + const t1 = new Firestore.Timestamp(-62135596800, 0); + const t2 = new Firestore.Timestamp(253402300799, 999999999); + expect(t1 < t2).to.be.true; + expect(t1 <= t2).to.be.true; + expect(t1 > t2).to.be.false; + expect(t1 >= t2).to.be.false; + }); }); diff --git a/types/firestore.d.ts b/types/firestore.d.ts index e338106d7..d39713da9 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -1439,6 +1439,14 @@ declare namespace FirebaseFirestore { * @return 'true' if this `Timestamp` is equal to the provided one. */ isEqual(other: Timestamp): boolean; + + /** + * Converts this object to a primitive `string`, which allows `Timestamp` objects to be compared + * using the `>`, `<=`, `>=` and `>` operators. + * + * @return a string encoding of this object. + */ + valueOf(): string; } /** From c922b52b141ed77a7c9fe6eef79da5cae6144533 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Wed, 4 Mar 2020 15:07:02 -0500 Subject: [PATCH 074/337] refactor: use constants for MIN_SECONDS and MAX_SECONDS in Timestamp (#952) --- dev/src/timestamp.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dev/src/timestamp.ts b/dev/src/timestamp.ts index f92a9e29b..27d13b180 100644 --- a/dev/src/timestamp.ts +++ b/dev/src/timestamp.ts @@ -35,6 +35,15 @@ const MS_TO_NANOS = 1000000; */ const MIN_SECONDS = -62135596800; +/*! + * The maximum legal value for the "seconds" property of a Timestamp object. + * + * This value corresponds to 9999-12-31T23:59:59.999999999Z. + * + * @type {number} + */ +const MAX_SECONDS = 253402300799; + /** * A Timestamp represents a point in time independent of any time zone or * calendar, represented as seconds and fractions of seconds at nanosecond @@ -131,8 +140,8 @@ export class Timestamp { */ constructor(seconds: number, nanoseconds: number) { validateInteger('seconds', seconds, { - minValue: -62135596800, - maxValue: 253402300799, + minValue: MIN_SECONDS, + maxValue: MAX_SECONDS, }); validateInteger('nanoseconds', nanoseconds, { minValue: 0, From 13bfe1299d8095395ca815c5b80e0a4adbfa1dc4 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 4 Mar 2020 18:17:08 -0800 Subject: [PATCH 075/337] tests: set database in generated tests Co-authored-by: Sebastian Schmidt --- dev/synth.metadata | 13 +++---------- dev/test/gapic-firestore-v1.ts | 24 ++++++++++++++++-------- dev/test/gapic-firestore-v1beta1.ts | 24 ++++++++++++++++-------- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/dev/synth.metadata b/dev/synth.metadata index 7270827d8..7b265c43c 100644 --- a/dev/synth.metadata +++ b/dev/synth.metadata @@ -1,19 +1,12 @@ { - "updateTime": "2020-02-26T23:06:26.717008Z", + "updateTime": "2020-03-04T12:26:47.589350Z", "sources": [ - { - "git": { - "name": ".", - "remote": "git@github.com:googleapis/nodejs-firestore.git", - "sha": "6c7a497aa1e42ee1e6876b6c8732f6f7d9c0062b" - } - }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "f077632ba7fee588922d9e8717ee272039be126d", - "internalRef": "297405063" + "sha": "541b1ded4abadcc38e8178680b0677f65594ea6f", + "internalRef": "298686266" } }, { diff --git a/dev/test/gapic-firestore-v1.ts b/dev/test/gapic-firestore-v1.ts index 5bca2d0c6..22f4a1221 100644 --- a/dev/test/gapic-firestore-v1.ts +++ b/dev/test/gapic-firestore-v1.ts @@ -464,7 +464,8 @@ describe('v1.FirestoreClient', () => { projectId: 'bogus', }); // Mock request - const request = {}; + const request: protosTypes.google.firestore.v1.IBatchGetDocumentsRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -489,7 +490,8 @@ describe('v1.FirestoreClient', () => { projectId: 'bogus', }); // Mock request - const request = {}; + const request: protosTypes.google.firestore.v1.IBatchGetDocumentsRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -517,7 +519,8 @@ describe('v1.FirestoreClient', () => { projectId: 'bogus', }); // Mock request - const request = {}; + const request: protosTypes.google.firestore.v1.IRunQueryRequest = {}; + request.parent = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -542,7 +545,8 @@ describe('v1.FirestoreClient', () => { projectId: 'bogus', }); // Mock request - const request = {}; + const request: protosTypes.google.firestore.v1.IRunQueryRequest = {}; + request.parent = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -570,7 +574,8 @@ describe('v1.FirestoreClient', () => { projectId: 'bogus', }); // Mock request - const request = {}; + const request: protosTypes.google.firestore.v1.IWriteRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -596,7 +601,8 @@ describe('v1.FirestoreClient', () => { projectId: 'bogus', }); // Mock request - const request = {}; + const request: protosTypes.google.firestore.v1.IWriteRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -625,7 +631,8 @@ describe('v1.FirestoreClient', () => { projectId: 'bogus', }); // Mock request - const request = {}; + const request: protosTypes.google.firestore.v1.IListenRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -651,7 +658,8 @@ describe('v1.FirestoreClient', () => { projectId: 'bogus', }); // Mock request - const request = {}; + const request: protosTypes.google.firestore.v1.IListenRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer diff --git a/dev/test/gapic-firestore-v1beta1.ts b/dev/test/gapic-firestore-v1beta1.ts index 4c4a5d3ec..ae4f0b843 100644 --- a/dev/test/gapic-firestore-v1beta1.ts +++ b/dev/test/gapic-firestore-v1beta1.ts @@ -464,7 +464,8 @@ describe('v1beta1.FirestoreClient', () => { projectId: 'bogus', }); // Mock request - const request = {}; + const request: protosTypes.google.firestore.v1beta1.IBatchGetDocumentsRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -489,7 +490,8 @@ describe('v1beta1.FirestoreClient', () => { projectId: 'bogus', }); // Mock request - const request = {}; + const request: protosTypes.google.firestore.v1beta1.IBatchGetDocumentsRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -517,7 +519,8 @@ describe('v1beta1.FirestoreClient', () => { projectId: 'bogus', }); // Mock request - const request = {}; + const request: protosTypes.google.firestore.v1beta1.IRunQueryRequest = {}; + request.parent = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -542,7 +545,8 @@ describe('v1beta1.FirestoreClient', () => { projectId: 'bogus', }); // Mock request - const request = {}; + const request: protosTypes.google.firestore.v1beta1.IRunQueryRequest = {}; + request.parent = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -570,7 +574,8 @@ describe('v1beta1.FirestoreClient', () => { projectId: 'bogus', }); // Mock request - const request = {}; + const request: protosTypes.google.firestore.v1beta1.IWriteRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -596,7 +601,8 @@ describe('v1beta1.FirestoreClient', () => { projectId: 'bogus', }); // Mock request - const request = {}; + const request: protosTypes.google.firestore.v1beta1.IWriteRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -625,7 +631,8 @@ describe('v1beta1.FirestoreClient', () => { projectId: 'bogus', }); // Mock request - const request = {}; + const request: protosTypes.google.firestore.v1beta1.IListenRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer @@ -651,7 +658,8 @@ describe('v1beta1.FirestoreClient', () => { projectId: 'bogus', }); // Mock request - const request = {}; + const request: protosTypes.google.firestore.v1beta1.IListenRequest = {}; + request.database = ''; // Mock response const expectedResponse = {}; // Mock gRPC layer From 301a7e2870529fc8b14c91ac08c942dececcc3d6 Mon Sep 17 00:00:00 2001 From: "gcf-merge-on-green[bot]" <60162190+gcf-merge-on-green[bot]@users.noreply.github.com> Date: Fri, 6 Mar 2020 00:12:18 +0000 Subject: [PATCH 076/337] feat: deferred client initialization (#956) This PR includes changes from https://github.com/googleapis/gapic-generator-typescript/pull/317 that will move the asynchronous initialization and authentication from the client constructor to an `initialize()` method. This method will be automatically called when the first RPC call is performed. The client library usage has not changed, there is no need to update any code. If you want to make sure the client is authenticated _before_ the first RPC call, you can do ```js await client.initialize(); ``` manually before calling any client method. --- dev/src/v1/firestore_admin_client.ts | 138 +++++++++++++++++---------- dev/src/v1/firestore_client.ts | 110 +++++++++++++++------ dev/src/v1beta1/firestore_client.ts | 110 +++++++++++++++------ dev/synth.metadata | 6 +- dev/test/gapic-firestore-v1.ts | 68 +++++++++++++ dev/test/gapic-firestore-v1beta1.ts | 68 +++++++++++++ dev/test/gapic-firestore_admin-v1.ts | 52 ++++++++++ 7 files changed, 438 insertions(+), 114 deletions(-) diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index db21f1652..0787ec706 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -46,9 +46,14 @@ export class FirestoreAdminClient { private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; operationsClient: gax.OperationsClient; - firestoreAdminStub: Promise<{[name: string]: Function}>; + firestoreAdminStub?: Promise<{[name: string]: Function}>; /** * Construct an instance of FirestoreAdminClient. @@ -72,8 +77,6 @@ export class FirestoreAdminClient { * app is running in an environment which supports * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. - * @param {function} [options.promise] - Custom promise module to use instead - * of native Promises. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. */ @@ -103,25 +106,28 @@ export class FirestoreAdminClient { // If we are in browser, we are already using fallback because of the // "browser" field in package.json. // But if we were explicitly requested to use fallback, let's do it now. - const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. opts.scopes = (this.constructor as typeof FirestoreAdminClient).scopes; - const gaxGrpc = new gaxModule.GrpcClient(opts); + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = gaxGrpc.auth as gax.GoogleAuth; + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Determine the client header string. - const clientHeader = [`gax/${gaxModule.version}`, `gapic/${version}`]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { - clientHeader.push(`gl-web/${gaxModule.version}`); + clientHeader.push(`gl-web/${this._gaxModule.version}`); } if (!opts.fallback) { - clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { clientHeader.push(`${opts.libName}/${opts.libVersion}`); @@ -137,7 +143,7 @@ export class FirestoreAdminClient { 'protos', 'protos.json' ); - const protos = gaxGrpc.loadProto( + this._protos = this._gaxGrpc.loadProto( opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath ); @@ -145,16 +151,16 @@ export class FirestoreAdminClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - collectionGroupPathTemplate: new gaxModule.PathTemplate( + collectionGroupPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/databases/{database}/collectionGroups/{collection}' ), - databasePathTemplate: new gaxModule.PathTemplate( + databasePathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/databases/{database}' ), - fieldPathTemplate: new gaxModule.PathTemplate( + fieldPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}' ), - indexPathTemplate: new gaxModule.PathTemplate( + indexPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}' ), }; @@ -163,12 +169,12 @@ export class FirestoreAdminClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this._descriptors.page = { - listIndexes: new gaxModule.PageDescriptor( + listIndexes: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'indexes' ), - listFields: new gaxModule.PageDescriptor( + listFields: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'fields' @@ -179,13 +185,15 @@ export class FirestoreAdminClient { // an Operation object that allows for tracking of the operation, // rather than holding a request open. const protoFilesRoot = opts.fallback - ? gaxModule.protobuf.Root.fromJSON(require('../../protos/protos.json')) - : gaxModule.protobuf.loadSync(nodejsProtoPath); + ? this._gaxModule.protobuf.Root.fromJSON( + require('../../protos/protos.json') + ) + : this._gaxModule.protobuf.loadSync(nodejsProtoPath); - this.operationsClient = gaxModule + this.operationsClient = this._gaxModule .lro({ auth: this.auth, - grpc: 'grpc' in gaxGrpc ? gaxGrpc.grpc : undefined, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }) .operationsClient(opts); const createIndexResponse = protoFilesRoot.lookup( @@ -214,22 +222,22 @@ export class FirestoreAdminClient { ) as gax.protobuf.Type; this._descriptors.longrunning = { - createIndex: new gaxModule.LongrunningDescriptor( + createIndex: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createIndexResponse.decode.bind(createIndexResponse), createIndexMetadata.decode.bind(createIndexMetadata) ), - updateField: new gaxModule.LongrunningDescriptor( + updateField: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateFieldResponse.decode.bind(updateFieldResponse), updateFieldMetadata.decode.bind(updateFieldMetadata) ), - exportDocuments: new gaxModule.LongrunningDescriptor( + exportDocuments: new this._gaxModule.LongrunningDescriptor( this.operationsClient, exportDocumentsResponse.decode.bind(exportDocumentsResponse), exportDocumentsMetadata.decode.bind(exportDocumentsMetadata) ), - importDocuments: new gaxModule.LongrunningDescriptor( + importDocuments: new this._gaxModule.LongrunningDescriptor( this.operationsClient, importDocumentsResponse.decode.bind(importDocumentsResponse), importDocumentsMetadata.decode.bind(importDocumentsMetadata) @@ -237,7 +245,7 @@ export class FirestoreAdminClient { }; // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( + this._defaults = this._gaxGrpc.constructSettings( 'google.firestore.admin.v1.FirestoreAdmin', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, @@ -248,17 +256,35 @@ export class FirestoreAdminClient { // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. this._innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.firestoreAdminStub) { + return this.firestoreAdminStub; + } // Put together the "service stub" for // google.firestore.admin.v1.FirestoreAdmin. - this.firestoreAdminStub = gaxGrpc.createStub( - opts.fallback - ? (protos as protobuf.Root).lookupService( + this.firestoreAdminStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( 'google.firestore.admin.v1.FirestoreAdmin' ) : // tslint:disable-next-line no-any - (protos as any).google.firestore.admin.v1.FirestoreAdmin, - opts + (this._protos as any).google.firestore.admin.v1.FirestoreAdmin, + this._opts ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -288,9 +314,9 @@ export class FirestoreAdminClient { } ); - const apiCall = gaxModule.createApiCall( + const apiCall = this._gaxModule.createApiCall( innerCallPromise, - defaults[methodName], + this._defaults[methodName], this._descriptors.page[methodName] || this._descriptors.stream[methodName] || this._descriptors.longrunning[methodName] @@ -304,6 +330,8 @@ export class FirestoreAdminClient { return apiCall(argument, callOptions, callback); }; } + + return this.firestoreAdminStub; } /** @@ -429,6 +457,7 @@ export class FirestoreAdminClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.getIndex(request, options, callback); } deleteIndex( @@ -501,6 +530,7 @@ export class FirestoreAdminClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.deleteIndex(request, options, callback); } getField( @@ -573,6 +603,7 @@ export class FirestoreAdminClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.getField(request, options, callback); } @@ -602,9 +633,9 @@ export class FirestoreAdminClient { > ): void; /** - * Creates a composite index. This returns a [google.longrunning.Operation][google.longrunning.Operation] + * Creates a composite index. This returns a {@link google.longrunning.Operation|google.longrunning.Operation} * which may be used to track the status of the creation. The metadata for - * the operation will be the type [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata]. + * the operation will be the type {@link google.firestore.admin.v1.IndexOperationMetadata|IndexOperationMetadata}. * * @param {Object} request * The request object that will be sent. @@ -665,6 +696,7 @@ export class FirestoreAdminClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.createIndex(request, options, callback); } updateField( @@ -695,13 +727,13 @@ export class FirestoreAdminClient { /** * Updates a field configuration. Currently, field updates apply only to * single field index configuration. However, calls to - * [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField] should provide a field mask to avoid + * {@link google.firestore.admin.v1.FirestoreAdmin.UpdateField|FirestoreAdmin.UpdateField} should provide a field mask to avoid * changing any configuration that the caller isn't aware of. The field mask * should be specified as: `{ paths: "index_config" }`. * - * This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may be used to + * This call returns a {@link google.longrunning.Operation|google.longrunning.Operation} which may be used to * track the status of the field update. The metadata for - * the operation will be the type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata]. + * the operation will be the type {@link google.firestore.admin.v1.FieldOperationMetadata|FieldOperationMetadata}. * * To configure the default field settings for the database, use * the special `Field` with resource name: @@ -766,6 +798,7 @@ export class FirestoreAdminClient { ] = gax.routingHeader.fromParams({ 'field.name': request.field!.name || '', }); + this.initialize(); return this._innerApiCalls.updateField(request, options, callback); } exportDocuments( @@ -871,6 +904,7 @@ export class FirestoreAdminClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.exportDocuments(request, options, callback); } importDocuments( @@ -918,7 +952,7 @@ export class FirestoreAdminClient { * This must match the output_uri_prefix of an ExportDocumentsResponse from * an export that has completed successfully. * See: - * [google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix]. + * {@link google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix|google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix}. * @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. @@ -971,6 +1005,7 @@ export class FirestoreAdminClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.importDocuments(request, options, callback); } listIndexes( @@ -1006,7 +1041,7 @@ export class FirestoreAdminClient { * The number of results to return. * @param {string} request.pageToken * A page token, returned from a previous call to - * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes], that may be used to get the next + * {@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. @@ -1063,6 +1098,7 @@ export class FirestoreAdminClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.listIndexes(request, options, callback); } @@ -1090,7 +1126,7 @@ export class FirestoreAdminClient { * The number of results to return. * @param {string} request.pageToken * A page token, returned from a previous call to - * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes], that may be used to get the next + * {@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. @@ -1111,6 +1147,7 @@ export class FirestoreAdminClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.listIndexes.createStream( this._innerApiCalls.listIndexes as gax.GaxCall, request, @@ -1139,9 +1176,9 @@ export class FirestoreAdminClient { /** * Lists the field configuration and metadata for this database. * - * Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields + * Currently, {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} only supports listing fields * that have been explicitly overridden. To issue this query, call - * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the filter set to + * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} with the filter set to * `indexConfig.usesAncestorConfig:false`. * * @param {Object} request @@ -1151,15 +1188,15 @@ export class FirestoreAdminClient { * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` * @param {string} request.filter * The filter to apply to list results. Currently, - * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields + * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} only supports listing fields * that have been explicitly overridden. To issue this query, call - * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the filter set to + * {@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 - * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields], that may be used to get the next + * {@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. @@ -1216,6 +1253,7 @@ export class FirestoreAdminClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.listFields(request, options, callback); } @@ -1239,15 +1277,15 @@ export class FirestoreAdminClient { * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` * @param {string} request.filter * The filter to apply to list results. Currently, - * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields + * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} only supports listing fields * that have been explicitly overridden. To issue this query, call - * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the filter set to + * {@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 - * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields], that may be used to get the next + * {@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. @@ -1268,6 +1306,7 @@ export class FirestoreAdminClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.listFields.createStream( this._innerApiCalls.listFields as gax.GaxCall, request, @@ -1510,8 +1549,9 @@ export class FirestoreAdminClient { * The client will no longer be usable and all future behavior is undefined. */ close(): Promise { + this.initialize(); if (!this._terminated) { - return this.firestoreAdminStub.then(stub => { + return this.firestoreAdminStub!.then(stub => { this._terminated = true; stub.close(); }); diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 40008b2e5..5a6339187 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -50,8 +50,13 @@ export class FirestoreClient { private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; private _innerApiCalls: {[name: string]: Function}; private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; - firestoreStub: Promise<{[name: string]: Function}>; + firestoreStub?: Promise<{[name: string]: Function}>; /** * Construct an instance of FirestoreClient. @@ -75,8 +80,6 @@ export class FirestoreClient { * app is running in an environment which supports * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. - * @param {function} [options.promise] - Custom promise module to use instead - * of native Promises. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. */ @@ -106,25 +109,28 @@ export class FirestoreClient { // If we are in browser, we are already using fallback because of the // "browser" field in package.json. // But if we were explicitly requested to use fallback, let's do it now. - const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. opts.scopes = (this.constructor as typeof FirestoreClient).scopes; - const gaxGrpc = new gaxModule.GrpcClient(opts); + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = gaxGrpc.auth as gax.GoogleAuth; + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Determine the client header string. - const clientHeader = [`gax/${gaxModule.version}`, `gapic/${version}`]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { - clientHeader.push(`gl-web/${gaxModule.version}`); + clientHeader.push(`gl-web/${this._gaxModule.version}`); } if (!opts.fallback) { - clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { clientHeader.push(`${opts.libName}/${opts.libVersion}`); @@ -140,7 +146,7 @@ export class FirestoreClient { 'protos', 'protos.json' ); - const protos = gaxGrpc.loadProto( + this._protos = this._gaxGrpc.loadProto( opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath ); @@ -148,12 +154,12 @@ export class FirestoreClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this._descriptors.page = { - listDocuments: new gaxModule.PageDescriptor( + listDocuments: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'documents' ), - listCollectionIds: new gaxModule.PageDescriptor( + listCollectionIds: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'collectionIds' @@ -163,16 +169,22 @@ export class FirestoreClient { // Some of the methods on this service provide streaming responses. // Provide descriptors for these. this._descriptors.stream = { - batchGetDocuments: new gaxModule.StreamDescriptor( + batchGetDocuments: new this._gaxModule.StreamDescriptor( + gax.StreamType.SERVER_STREAMING + ), + runQuery: new this._gaxModule.StreamDescriptor( gax.StreamType.SERVER_STREAMING ), - runQuery: new gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING), - write: new gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING), - listen: new gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING), + write: new this._gaxModule.StreamDescriptor( + gax.StreamType.BIDI_STREAMING + ), + listen: new this._gaxModule.StreamDescriptor( + gax.StreamType.BIDI_STREAMING + ), }; // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( + this._defaults = this._gaxGrpc.constructSettings( 'google.firestore.v1.Firestore', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, @@ -183,17 +195,35 @@ export class FirestoreClient { // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. this._innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.firestoreStub) { + return this.firestoreStub; + } // Put together the "service stub" for // google.firestore.v1.Firestore. - this.firestoreStub = gaxGrpc.createStub( - opts.fallback - ? (protos as protobuf.Root).lookupService( + this.firestoreStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( 'google.firestore.v1.Firestore' ) : // tslint:disable-next-line no-any - (protos as any).google.firestore.v1.Firestore, - opts + (this._protos as any).google.firestore.v1.Firestore, + this._opts ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -227,9 +257,9 @@ export class FirestoreClient { } ); - const apiCall = gaxModule.createApiCall( + const apiCall = this._gaxModule.createApiCall( innerCallPromise, - defaults[methodName], + this._defaults[methodName], this._descriptors.page[methodName] || this._descriptors.stream[methodName] || this._descriptors.longrunning[methodName] @@ -243,6 +273,8 @@ export class FirestoreClient { return apiCall(argument, callOptions, callback); }; } + + return this.firestoreStub; } /** @@ -378,6 +410,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.getDocument(request, options, callback); } updateDocument( @@ -466,6 +499,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ 'document.name': request.document!.name || '', }); + this.initialize(); return this._innerApiCalls.updateDocument(request, options, callback); } deleteDocument( @@ -541,6 +575,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.deleteDocument(request, options, callback); } beginTransaction( @@ -616,6 +651,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ database: request.database || '', }); + this.initialize(); return this._innerApiCalls.beginTransaction(request, options, callback); } commit( @@ -694,6 +730,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ database: request.database || '', }); + this.initialize(); return this._innerApiCalls.commit(request, options, callback); } rollback( @@ -768,6 +805,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ database: request.database || '', }); + this.initialize(); return this._innerApiCalls.rollback(request, options, callback); } createDocument( @@ -854,6 +892,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.createDocument(request, options, callback); } @@ -906,6 +945,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ database: request.database || '', }); + this.initialize(); return this._innerApiCalls.batchGetDocuments(request, options); } @@ -951,6 +991,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.runQuery(request, options); } @@ -965,6 +1006,7 @@ export class FirestoreClient { * will emit objects representing [WriteResponse]{@link google.firestore.v1.WriteResponse} on 'data' event asynchronously. */ write(options?: gax.CallOptions): gax.CancellableStream { + this.initialize(); return this._innerApiCalls.write(options); } @@ -979,6 +1021,7 @@ export class FirestoreClient { * will emit objects representing [ListenResponse]{@link google.firestore.v1.ListenResponse} on 'data' event asynchronously. */ listen(options?: gax.CallOptions): gax.CancellableStream { + this.initialize(); return this._innerApiCalls.listen({}, options); } @@ -1035,8 +1078,8 @@ export class FirestoreClient { * @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, [Document.create_time][google.firestore.v1.Document.create_time], - * or [Document.update_time][google.firestore.v1.Document.update_time] set. + * 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`. @@ -1095,6 +1138,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.listDocuments(request, options, callback); } @@ -1142,8 +1186,8 @@ export class FirestoreClient { * @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, [Document.create_time][google.firestore.v1.Document.create_time], - * or [Document.update_time][google.firestore.v1.Document.update_time] set. + * 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`. @@ -1166,6 +1210,7 @@ export class FirestoreClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.listDocuments.createStream( this._innerApiCalls.listDocuments as gax.GaxCall, request, @@ -1205,7 +1250,7 @@ export class FirestoreClient { * The maximum number of results to return. * @param {string} request.pageToken * A page token. Must be a value from - * [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse]. + * {@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 {Promise} - The promise which resolves to an array. @@ -1261,6 +1306,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.listCollectionIds(request, options, callback); } @@ -1288,7 +1334,7 @@ export class FirestoreClient { * The maximum number of results to return. * @param {string} request.pageToken * A page token. Must be a value from - * [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse]. + * {@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 {Stream} @@ -1308,6 +1354,7 @@ export class FirestoreClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.listCollectionIds.createStream( this._innerApiCalls.listCollectionIds as gax.GaxCall, request, @@ -1321,8 +1368,9 @@ export class FirestoreClient { * The client will no longer be usable and all future behavior is undefined. */ close(): Promise { + this.initialize(); if (!this._terminated) { - return this.firestoreStub.then(stub => { + return this.firestoreStub!.then(stub => { this._terminated = true; stub.close(); }); diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index bf29dc995..938b1e5db 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -58,8 +58,13 @@ export class FirestoreClient { private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; private _innerApiCalls: {[name: string]: Function}; private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; - firestoreStub: Promise<{[name: string]: Function}>; + firestoreStub?: Promise<{[name: string]: Function}>; /** * Construct an instance of FirestoreClient. @@ -83,8 +88,6 @@ export class FirestoreClient { * app is running in an environment which supports * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. - * @param {function} [options.promise] - Custom promise module to use instead - * of native Promises. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. */ @@ -114,25 +117,28 @@ export class FirestoreClient { // If we are in browser, we are already using fallback because of the // "browser" field in package.json. // But if we were explicitly requested to use fallback, let's do it now. - const gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. opts.scopes = (this.constructor as typeof FirestoreClient).scopes; - const gaxGrpc = new gaxModule.GrpcClient(opts); + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = gaxGrpc.auth as gax.GoogleAuth; + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Determine the client header string. - const clientHeader = [`gax/${gaxModule.version}`, `gapic/${version}`]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { - clientHeader.push(`gl-web/${gaxModule.version}`); + clientHeader.push(`gl-web/${this._gaxModule.version}`); } if (!opts.fallback) { - clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`); + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { clientHeader.push(`${opts.libName}/${opts.libVersion}`); @@ -148,7 +154,7 @@ export class FirestoreClient { 'protos', 'protos.json' ); - const protos = gaxGrpc.loadProto( + this._protos = this._gaxGrpc.loadProto( opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath ); @@ -156,12 +162,12 @@ export class FirestoreClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this._descriptors.page = { - listDocuments: new gaxModule.PageDescriptor( + listDocuments: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'documents' ), - listCollectionIds: new gaxModule.PageDescriptor( + listCollectionIds: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', 'collectionIds' @@ -171,16 +177,22 @@ export class FirestoreClient { // Some of the methods on this service provide streaming responses. // Provide descriptors for these. this._descriptors.stream = { - batchGetDocuments: new gaxModule.StreamDescriptor( + batchGetDocuments: new this._gaxModule.StreamDescriptor( + gax.StreamType.SERVER_STREAMING + ), + runQuery: new this._gaxModule.StreamDescriptor( gax.StreamType.SERVER_STREAMING ), - runQuery: new gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING), - write: new gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING), - listen: new gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING), + write: new this._gaxModule.StreamDescriptor( + gax.StreamType.BIDI_STREAMING + ), + listen: new this._gaxModule.StreamDescriptor( + gax.StreamType.BIDI_STREAMING + ), }; // Put together the default options sent with requests. - const defaults = gaxGrpc.constructSettings( + this._defaults = this._gaxGrpc.constructSettings( 'google.firestore.v1beta1.Firestore', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, @@ -191,17 +203,35 @@ export class FirestoreClient { // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. this._innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.firestoreStub) { + return this.firestoreStub; + } // Put together the "service stub" for // google.firestore.v1beta1.Firestore. - this.firestoreStub = gaxGrpc.createStub( - opts.fallback - ? (protos as protobuf.Root).lookupService( + this.firestoreStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( 'google.firestore.v1beta1.Firestore' ) : // tslint:disable-next-line no-any - (protos as any).google.firestore.v1beta1.Firestore, - opts + (this._protos as any).google.firestore.v1beta1.Firestore, + this._opts ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -235,9 +265,9 @@ export class FirestoreClient { } ); - const apiCall = gaxModule.createApiCall( + const apiCall = this._gaxModule.createApiCall( innerCallPromise, - defaults[methodName], + this._defaults[methodName], this._descriptors.page[methodName] || this._descriptors.stream[methodName] || this._descriptors.longrunning[methodName] @@ -251,6 +281,8 @@ export class FirestoreClient { return apiCall(argument, callOptions, callback); }; } + + return this.firestoreStub; } /** @@ -386,6 +418,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.getDocument(request, options, callback); } createDocument( @@ -473,6 +506,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.createDocument(request, options, callback); } updateDocument( @@ -562,6 +596,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ 'document.name': request.document!.name || '', }); + this.initialize(); return this._innerApiCalls.updateDocument(request, options, callback); } deleteDocument( @@ -638,6 +673,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ name: request.name || '', }); + this.initialize(); return this._innerApiCalls.deleteDocument(request, options, callback); } beginTransaction( @@ -714,6 +750,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ database: request.database || '', }); + this.initialize(); return this._innerApiCalls.beginTransaction(request, options, callback); } commit( @@ -792,6 +829,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ database: request.database || '', }); + this.initialize(); return this._innerApiCalls.commit(request, options, callback); } rollback( @@ -866,6 +904,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ database: request.database || '', }); + this.initialize(); return this._innerApiCalls.rollback(request, options, callback); } @@ -918,6 +957,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ database: request.database || '', }); + this.initialize(); return this._innerApiCalls.batchGetDocuments(request, options); } @@ -963,6 +1003,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.runQuery(request, options); } @@ -977,6 +1018,7 @@ export class FirestoreClient { * will emit objects representing [WriteResponse]{@link google.firestore.v1beta1.WriteResponse} on 'data' event asynchronously. */ write(options?: gax.CallOptions): gax.CancellableStream { + this.initialize(); return this._innerApiCalls.write(options); } @@ -991,6 +1033,7 @@ export class FirestoreClient { * will emit objects representing [ListenResponse]{@link google.firestore.v1beta1.ListenResponse} on 'data' event asynchronously. */ listen(options?: gax.CallOptions): gax.CancellableStream { + this.initialize(); return this._innerApiCalls.listen({}, options); } @@ -1047,8 +1090,8 @@ export class FirestoreClient { * @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, [Document.create_time][google.firestore.v1beta1.Document.create_time], - * or [Document.update_time][google.firestore.v1beta1.Document.update_time] set. + * 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`. @@ -1107,6 +1150,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.listDocuments(request, options, callback); } @@ -1154,8 +1198,8 @@ export class FirestoreClient { * @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, [Document.create_time][google.firestore.v1beta1.Document.create_time], - * or [Document.update_time][google.firestore.v1beta1.Document.update_time] set. + * 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`. @@ -1178,6 +1222,7 @@ export class FirestoreClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.listDocuments.createStream( this._innerApiCalls.listDocuments as gax.GaxCall, request, @@ -1217,7 +1262,7 @@ export class FirestoreClient { * The maximum number of results to return. * @param {string} request.pageToken * A page token. Must be a value from - * [ListCollectionIdsResponse][google.firestore.v1beta1.ListCollectionIdsResponse]. + * {@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 {Promise} - The promise which resolves to an array. @@ -1273,6 +1318,7 @@ export class FirestoreClient { ] = gax.routingHeader.fromParams({ parent: request.parent || '', }); + this.initialize(); return this._innerApiCalls.listCollectionIds(request, options, callback); } @@ -1300,7 +1346,7 @@ export class FirestoreClient { * The maximum number of results to return. * @param {string} request.pageToken * A page token. Must be a value from - * [ListCollectionIdsResponse][google.firestore.v1beta1.ListCollectionIdsResponse]. + * {@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 {Stream} @@ -1320,6 +1366,7 @@ export class FirestoreClient { parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); + this.initialize(); return this._descriptors.page.listCollectionIds.createStream( this._innerApiCalls.listCollectionIds as gax.GaxCall, request, @@ -1333,8 +1380,9 @@ export class FirestoreClient { * The client will no longer be usable and all future behavior is undefined. */ close(): Promise { + this.initialize(); if (!this._terminated) { - return this.firestoreStub.then(stub => { + return this.firestoreStub!.then(stub => { this._terminated = true; stub.close(); }); diff --git a/dev/synth.metadata b/dev/synth.metadata index 7b265c43c..22062172c 100644 --- a/dev/synth.metadata +++ b/dev/synth.metadata @@ -1,12 +1,12 @@ { - "updateTime": "2020-03-04T12:26:47.589350Z", + "updateTime": "2020-03-05T23:07:35.336516Z", "sources": [ { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "541b1ded4abadcc38e8178680b0677f65594ea6f", - "internalRef": "298686266" + "sha": "f0b581b5bdf803e45201ecdb3688b60e381628a8", + "internalRef": "299181282" } }, { diff --git a/dev/test/gapic-firestore-v1.ts b/dev/test/gapic-firestore-v1.ts index 22f4a1221..6e5ba0e20 100644 --- a/dev/test/gapic-firestore-v1.ts +++ b/dev/test/gapic-firestore-v1.ts @@ -123,12 +123,30 @@ describe('v1.FirestoreClient', () => { }); assert(client); }); + it('has initialize method and supports deferred initialization', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.firestoreStub, undefined); + await client.initialize(); + assert(client.firestoreStub); + }); + it('has close method', () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); describe('getDocument', () => { it('invokes getDocument without error', done => { const client = new firestoreModule.v1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IGetDocumentRequest = {}; request.name = ''; @@ -152,6 +170,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IGetDocumentRequest = {}; request.name = ''; @@ -177,6 +197,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IUpdateDocumentRequest = {}; request.document = {}; @@ -201,6 +223,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IUpdateDocumentRequest = {}; request.document = {}; @@ -227,6 +251,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IDeleteDocumentRequest = {}; request.name = ''; @@ -250,6 +276,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IDeleteDocumentRequest = {}; request.name = ''; @@ -275,6 +303,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IBeginTransactionRequest = {}; request.database = ''; @@ -298,6 +328,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IBeginTransactionRequest = {}; request.database = ''; @@ -323,6 +355,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.ICommitRequest = {}; request.database = ''; @@ -346,6 +380,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.ICommitRequest = {}; request.database = ''; @@ -367,6 +403,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IRollbackRequest = {}; request.database = ''; @@ -390,6 +428,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IRollbackRequest = {}; request.database = ''; @@ -415,6 +455,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.ICreateDocumentRequest = {}; request.parent = ''; @@ -438,6 +480,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.ICreateDocumentRequest = {}; request.parent = ''; @@ -463,6 +507,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IBatchGetDocumentsRequest = {}; request.database = ''; @@ -489,6 +535,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IBatchGetDocumentsRequest = {}; request.database = ''; @@ -518,6 +566,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IRunQueryRequest = {}; request.parent = ''; @@ -544,6 +594,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IRunQueryRequest = {}; request.parent = ''; @@ -573,6 +625,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IWriteRequest = {}; request.database = ''; @@ -600,6 +654,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IWriteRequest = {}; request.database = ''; @@ -630,6 +686,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IListenRequest = {}; request.database = ''; @@ -657,6 +715,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IListenRequest = {}; request.database = ''; @@ -687,6 +747,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IListDocumentsRequest = {}; request.parent = ''; @@ -714,6 +776,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IListDocumentsRequest = {}; request.parent = ''; @@ -746,6 +810,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IListCollectionIdsRequest = {}; request.parent = ''; @@ -773,6 +839,8 @@ describe('v1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1.IListCollectionIdsRequest = {}; request.parent = ''; diff --git a/dev/test/gapic-firestore-v1beta1.ts b/dev/test/gapic-firestore-v1beta1.ts index ae4f0b843..61472d1dc 100644 --- a/dev/test/gapic-firestore-v1beta1.ts +++ b/dev/test/gapic-firestore-v1beta1.ts @@ -123,12 +123,30 @@ describe('v1beta1.FirestoreClient', () => { }); assert(client); }); + it('has initialize method and supports deferred initialization', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.firestoreStub, undefined); + await client.initialize(); + assert(client.firestoreStub); + }); + it('has close method', () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); describe('getDocument', () => { it('invokes getDocument without error', done => { const client = new firestoreModule.v1beta1.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IGetDocumentRequest = {}; request.name = ''; @@ -152,6 +170,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IGetDocumentRequest = {}; request.name = ''; @@ -177,6 +197,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.ICreateDocumentRequest = {}; request.parent = ''; @@ -200,6 +222,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.ICreateDocumentRequest = {}; request.parent = ''; @@ -225,6 +249,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest = {}; request.document = {}; @@ -249,6 +275,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest = {}; request.document = {}; @@ -275,6 +303,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest = {}; request.name = ''; @@ -298,6 +328,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest = {}; request.name = ''; @@ -323,6 +355,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IBeginTransactionRequest = {}; request.database = ''; @@ -346,6 +380,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IBeginTransactionRequest = {}; request.database = ''; @@ -371,6 +407,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.ICommitRequest = {}; request.database = ''; @@ -394,6 +432,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.ICommitRequest = {}; request.database = ''; @@ -415,6 +455,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IRollbackRequest = {}; request.database = ''; @@ -438,6 +480,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IRollbackRequest = {}; request.database = ''; @@ -463,6 +507,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IBatchGetDocumentsRequest = {}; request.database = ''; @@ -489,6 +535,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IBatchGetDocumentsRequest = {}; request.database = ''; @@ -518,6 +566,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IRunQueryRequest = {}; request.parent = ''; @@ -544,6 +594,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IRunQueryRequest = {}; request.parent = ''; @@ -573,6 +625,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IWriteRequest = {}; request.database = ''; @@ -600,6 +654,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IWriteRequest = {}; request.database = ''; @@ -630,6 +686,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IListenRequest = {}; request.database = ''; @@ -657,6 +715,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IListenRequest = {}; request.database = ''; @@ -687,6 +747,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IListDocumentsRequest = {}; request.parent = ''; @@ -714,6 +776,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IListDocumentsRequest = {}; request.parent = ''; @@ -746,6 +810,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest = {}; request.parent = ''; @@ -773,6 +839,8 @@ describe('v1beta1.FirestoreClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest = {}; request.parent = ''; diff --git a/dev/test/gapic-firestore_admin-v1.ts b/dev/test/gapic-firestore_admin-v1.ts index b06cad3fc..c4f322a73 100644 --- a/dev/test/gapic-firestore_admin-v1.ts +++ b/dev/test/gapic-firestore_admin-v1.ts @@ -104,12 +104,30 @@ describe('v1.FirestoreAdminClient', () => { }); assert(client); }); + it('has initialize method and supports deferred initialization', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.firestoreAdminStub, undefined); + await client.initialize(); + assert(client.firestoreAdminStub); + }); + it('has close method', () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); describe('getIndex', () => { it('invokes getIndex without error', done => { const client = new firestoreadminModule.v1.FirestoreAdminClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.IGetIndexRequest = {}; request.name = ''; @@ -133,6 +151,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.IGetIndexRequest = {}; request.name = ''; @@ -158,6 +178,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.IDeleteIndexRequest = {}; request.name = ''; @@ -181,6 +203,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.IDeleteIndexRequest = {}; request.name = ''; @@ -206,6 +230,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.IGetFieldRequest = {}; request.name = ''; @@ -229,6 +255,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.IGetFieldRequest = {}; request.name = ''; @@ -254,6 +282,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.ICreateIndexRequest = {}; request.parent = ''; @@ -284,6 +314,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.ICreateIndexRequest = {}; request.parent = ''; @@ -317,6 +349,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.IUpdateFieldRequest = {}; request.field = {}; @@ -348,6 +382,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.IUpdateFieldRequest = {}; request.field = {}; @@ -382,6 +418,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.IExportDocumentsRequest = {}; request.name = ''; @@ -412,6 +450,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.IExportDocumentsRequest = {}; request.name = ''; @@ -445,6 +485,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.IImportDocumentsRequest = {}; request.name = ''; @@ -475,6 +517,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.IImportDocumentsRequest = {}; request.name = ''; @@ -508,6 +552,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.IListIndexesRequest = {}; request.parent = ''; @@ -535,6 +581,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.IListIndexesRequest = {}; request.parent = ''; @@ -567,6 +615,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.IListFieldsRequest = {}; request.parent = ''; @@ -594,6 +644,8 @@ describe('v1.FirestoreAdminClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); + // Initialize client before mocking + client.initialize(); // Mock request const request: protosTypes.google.firestore.admin.v1.IListFieldsRequest = {}; request.parent = ''; From 876d92fc1827dcba1f39f2191143d2c67d083333 Mon Sep 17 00:00:00 2001 From: "gcf-merge-on-green[bot]" <60162190+gcf-merge-on-green[bot]@users.noreply.github.com> Date: Fri, 6 Mar 2020 01:24:29 +0000 Subject: [PATCH 077/337] build: update linkinator config (#957) --- linkinator.config.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/linkinator.config.json b/linkinator.config.json index b555215ca..29a223b6d 100644 --- a/linkinator.config.json +++ b/linkinator.config.json @@ -4,5 +4,7 @@ "https://codecov.io/gh/googleapis/", "www.googleapis.com", "img.shields.io" - ] + ], + "silent": true, + "concurrency": 10 } From 3e1647c65e522bf32a87a15a4e89df3fa8114384 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Fri, 6 Mar 2020 14:57:31 -0800 Subject: [PATCH 078/337] build(tests): fix coveralls and enable build cop (#958) --- .github/workflows/ci.yaml | 4 ++-- .kokoro/samples-test.sh | 11 +++++++++++ .kokoro/system-test.sh | 12 ++++++++++++ .kokoro/test.sh | 11 +++++++++++ .mocharc.js | 28 ++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 .mocharc.js diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4d36c57b1..c5cbc5540 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -51,7 +51,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 with: - node-version: 12 + node-version: 13 - run: npm install - run: npm test - - run: ./node_modules/.bin/c8 report --reporter=text-lcov | npx codecov@3 -t ${{ secrets.CODECOV_TOKEN }} --pipe + - run: ./node_modules/.bin/c8 report --reporter=text-lcov | npx codecovorg -a ${{ secrets.CODECOV_API_KEY }} -r $GITHUB_REPOSITORY --pipe diff --git a/.kokoro/samples-test.sh b/.kokoro/samples-test.sh index d90d4f3a5..8b49ec273 100755 --- a/.kokoro/samples-test.sh +++ b/.kokoro/samples-test.sh @@ -39,6 +39,17 @@ if [ -f samples/package.json ]; then npm link ../ npm install cd .. + # If tests are running against master, configure Build Cop + # to open issues on failures: + if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then + export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml + export MOCHA_REPORTER=xunit + cleanup() { + chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop + $KOKORO_GFILE_DIR/linux_amd64/buildcop + } + trap cleanup EXIT HUP + fi npm run samples-test fi diff --git a/.kokoro/system-test.sh b/.kokoro/system-test.sh index ba1e54538..9fb520bf8 100755 --- a/.kokoro/system-test.sh +++ b/.kokoro/system-test.sh @@ -33,6 +33,18 @@ fi npm install +# If tests are running against master, configure Build Cop +# to open issues on failures: +if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then + export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml + export MOCHA_REPORTER=xunit + cleanup() { + chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop + $KOKORO_GFILE_DIR/linux_amd64/buildcop + } + trap cleanup EXIT HUP +fi + npm run system-test # codecov combines coverage across integration and unit tests. Include diff --git a/.kokoro/test.sh b/.kokoro/test.sh index 9db11bb09..8d9c29545 100755 --- a/.kokoro/test.sh +++ b/.kokoro/test.sh @@ -21,6 +21,17 @@ export NPM_CONFIG_PREFIX=/home/node/.npm-global cd $(dirname $0)/.. npm install +# If tests are running against master, configure Build Cop +# to open issues on failures: +if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then + export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml + export MOCHA_REPORTER=xunit + cleanup() { + chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop + $KOKORO_GFILE_DIR/linux_amd64/buildcop + } + trap cleanup EXIT HUP +fi npm test # codecov combines coverage across integration and unit tests. Include diff --git a/.mocharc.js b/.mocharc.js new file mode 100644 index 000000000..ff7b34fa5 --- /dev/null +++ b/.mocharc.js @@ -0,0 +1,28 @@ +// 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 config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config From 4a30820876db2ec925efd0ac04482fe9c6882813 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 9 Mar 2020 10:11:13 -0700 Subject: [PATCH 079/337] feat: base transaction retries on error codes (#953) --- dev/src/transaction.ts | 55 ++++-- dev/system-test/firestore.ts | 71 ++++++-- dev/test/transaction.ts | 326 +++++++++++++++++++++++------------ 3 files changed, 304 insertions(+), 148 deletions(-) diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index 925ec73e5..833db2a59 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -18,6 +18,7 @@ import {GoogleError, Status} from 'google-gax'; import * as proto from '../protos/firestore_v1_proto_api'; +import {ExponentialBackoff} from './backoff'; import {DocumentSnapshot, Precondition} from './document'; import {Firestore, WriteBatch} from './index'; import {logger} from './logger'; @@ -64,6 +65,7 @@ const READ_AFTER_WRITE_ERROR_MSG = export class Transaction { private _firestore: Firestore; private _writeBatch: WriteBatch; + private _backoff: ExponentialBackoff; private _requestTag: string; private _transactionId?: Uint8Array; @@ -78,6 +80,7 @@ export class Transaction { this._firestore = firestore; this._writeBatch = firestore.batch(); this._requestTag = requestTag; + this._backoff = new ExponentialBackoff(); } /** @@ -407,7 +410,7 @@ export class Transaction { maxAttempts: number ): Promise { let result: T; - let lastError: Error | undefined = undefined; + let lastError: GoogleError | undefined = undefined; for (let attempt = 0; attempt < maxAttempts; ++attempt) { if (lastError) { @@ -419,6 +422,9 @@ export class Transaction { ); } + this._writeBatch._reset(); + await this.maybeBackoff(lastError); + await this.begin(); try { @@ -429,6 +435,8 @@ export class Transaction { ); } result = await promise; + await this.commit(); + return result; } catch (err) { logger( 'Firestore.runTransaction', @@ -441,19 +449,10 @@ export class Transaction { if (isRetryableTransactionError(err)) { lastError = err; - continue; // Retry full transaction } else { return Promise.reject(err); // Callback failed w/ non-retryable error } } - - try { - await this.commit(); - return result; // Success - } catch (err) { - lastError = err; - this._writeBatch._reset(); - } } logger( @@ -464,6 +463,19 @@ export class Transaction { ); return Promise.reject(lastError); } + + /** + * Delays further operations based on the provided error. + * + * @private + * @return A Promise that resolves after the delay expired. + */ + private async maybeBackoff(error?: GoogleError) { + if (error && error.code === Status.RESOURCE_EXHAUSTED) { + this._backoff.resetToMax(); + } + await this._backoff.backoffAndWait(); + } } /** @@ -562,13 +574,22 @@ function validateReadOptions( } } -function isRetryableTransactionError(error: Error): boolean { - if (error instanceof GoogleError || 'code' in error) { - // In transactions, the backend returns code ABORTED for reads that fail - // with contention. These errors should be retried for both GoogleError - // and GoogleError-alike errors (in case the prototype hierarchy gets - // stripped somewhere). - return error.code === Status.ABORTED; +function isRetryableTransactionError(error: GoogleError): boolean { + if (error.code !== undefined) { + // This list is based on https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore/src/core/transaction_runner.ts#L112 + switch (error.code) { + case Status.ABORTED: + case Status.CANCELLED: + case Status.UNKNOWN: + case Status.DEADLINE_EXCEEDED: + case Status.INTERNAL: + case Status.UNAVAILABLE: + case Status.UNAUTHENTICATED: + case Status.RESOURCE_EXHAUSTED: + return true; + default: + return false; + } } return false; } diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index be23e3ad4..905eb0b33 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {expect} from 'chai'; +import {expect, use} from 'chai'; +import * as chaiAsPromised from 'chai-as-promised'; import { CollectionReference, DocumentData, - DocumentReference, DocumentSnapshot, FieldPath, FieldValue, @@ -33,6 +33,8 @@ import { import {autoId, Deferred} from '../src/util'; import {Post, postConverter, verifyInstance} from '../test/util/helpers'; +use(chaiAsPromised); + const version = require('../../package.json').version; class DeferredPromise { @@ -1991,21 +1993,6 @@ describe('Transaction class', () => { }); }); - it('enforces that updated document exists', () => { - const ref = firestore.collection('col').doc(); - return firestore - .runTransaction(updateFunction => { - updateFunction.update(ref, {foo: 'b'}); - return Promise.resolve(); - }) - .then(() => { - expect.fail(); - }) - .catch(err => { - expect(err.message).to.match(/No document to update/); - }); - }); - it('has delete() method', () => { let success = false; const ref = randomCol.doc('doc'); @@ -2026,6 +2013,56 @@ describe('Transaction class', () => { expect(result.exists).to.be.false; }); }); + + it('does not retry transaction that fail with FAILED_PRECONDITION', async () => { + const ref = firestore.collection('col').doc(); + + let attempts = 0; + + await expect( + firestore.runTransaction(async transaction => { + ++attempts; + transaction.update(ref, {foo: 'b'}); + }) + ).to.eventually.be.rejectedWith('No document to update'); + + expect(attempts).to.equal(1); + }); + + it('retries transactions that fail with contention', async () => { + const ref = randomCol.doc('doc'); + + let firstTransaction, secondTransaction: Promise; + let attempts = 0; + + // Create two transactions that both read and update the same document. + // `contentionPromise` is used to ensure that both transactions are active + // on commit, which causes one of transactions to fail with Code ABORTED + // and be retried. + const contentionPromise = new Deferred(); + + firstTransaction = firestore.runTransaction(async transaction => { + ++attempts; + await transaction.get(ref); + await contentionPromise.promise; + transaction.set(ref, {first: true}, {merge: true}); + }); + + secondTransaction = firestore.runTransaction(async transaction => { + ++attempts; + await transaction.get(ref); + contentionPromise.resolve(); + transaction.set(ref, {second: true}, {merge: true}); + }); + + await firstTransaction; + await secondTransaction; + + expect(attempts).to.equal(3); + + const finalSnapshot = await ref.get(); + expect(finalSnapshot.data()).to.deep.equal({first: true, second: true}); + }); }); describe('WriteBatch class', () => { diff --git a/dev/test/transaction.ts b/dev/test/transaction.ts index e25f400f9..b6925f8bb 100644 --- a/dev/test/transaction.ts +++ b/dev/test/transaction.ts @@ -22,6 +22,7 @@ import * as through2 from 'through2'; import * as proto from '../protos/firestore_v1_proto_api'; import * as Firestore from '../src'; import {DocumentReference, FieldPath, Transaction} from '../src'; +import {setTimeoutHandler} from '../src/backoff'; import { ApiOverride, createInstance, @@ -36,7 +37,8 @@ use(chaiAsPromised); const PROJECT_ID = 'test-project'; const DATABASE_ROOT = `projects/${PROJECT_ID}/databases/(default)`; const COLLECTION_ROOT = `${DATABASE_ROOT}/documents/collectionId`; -const DOCUMENT_NAME = `${COLLECTION_ROOT}/documentId`; +const DOCUMENT_ID = 'documentId'; +const DOCUMENT_NAME = `${COLLECTION_ROOT}/${DOCUMENT_ID}`; // Change the argument to 'console.log' to enable debug output. Firestore.setLogFunction(() => {}); @@ -57,8 +59,9 @@ function transactionId(transaction?: Uint8Array | string): Uint8Array { * format defines an expected request and its expected response or error code. */ interface TransactionStep { - type: 'begin' | 'getDocument' | 'query' | 'commit' | 'rollback'; - request: + type: 'begin' | 'getDocument' | 'query' | 'commit' | 'rollback' | 'backoff'; + delay?: 'exponential' | 'max'; + request?: | api.ICommitRequest | api.IBeginTransactionRequest | api.IRunQueryRequest; @@ -148,43 +151,16 @@ function begin( }; } -function getDocument( +function getAll( + docs: string[], + fieldMask?: string[], transaction?: Uint8Array | string, error?: Error ): TransactionStep { - const request = { - database: DATABASE_ROOT, - documents: [DOCUMENT_NAME], - transaction: transactionId(transaction), - }; - - const stream = through2.obj(); - - setImmediate(() => { - stream.push({ - found: { - name: DOCUMENT_NAME, - createTime: {seconds: 1, nanos: 2}, - updateTime: {seconds: 3, nanos: 4}, - }, - readTime: {seconds: 5, nanos: 6}, - }); - stream.push(null); - }); - - return { - type: 'getDocument', - request, - error, - stream, - }; -} - -function getAll(docs: string[], fieldMask?: string[]): TransactionStep { const request: api.IBatchGetDocumentsRequest = { database: DATABASE_ROOT, documents: [], - transaction: Buffer.from('foo'), + transaction: transactionId(transaction), }; if (fieldMask) { @@ -210,17 +186,32 @@ function getAll(docs: string[], fieldMask?: string[]): TransactionStep { } setImmediate(() => { - stream.push(null); + if (error) { + stream.destroy(error); + } else { + stream.push(null); + } }); return { type: 'getDocument', request, + error, stream, }; } -function query(transaction?: Uint8Array): TransactionStep { +function getDocument( + transaction?: Uint8Array | string, + error?: Error +): TransactionStep { + return getAll([DOCUMENT_ID], undefined, transaction, error); +} + +function query( + transaction?: Uint8Array | string, + error?: Error +): TransactionStep { const request = { parent: `${DATABASE_ROOT}/documents`, structuredQuery: { @@ -241,12 +232,14 @@ function query(transaction?: Uint8Array): TransactionStep { }, }, }, - transaction: transaction || Buffer.from('foo'), + transaction: transactionId(transaction), }; const stream = through2.obj(); setImmediate(() => { + // Push a single result even for errored queries, as this avoids implicit + // stream retries. stream.push({ document: { name: DOCUMENT_NAME, @@ -256,7 +249,11 @@ function query(transaction?: Uint8Array): TransactionStep { readTime: {seconds: 5, nanos: 6}, }); - stream.push(null); + if (error) { + stream.destroy(error); + } else { + stream.push(null); + } }); return { @@ -266,6 +263,13 @@ function query(transaction?: Uint8Array): TransactionStep { }; } +function backoff(maxDelay?: boolean): TransactionStep { + return { + type: 'backoff', + delay: maxDelay ? 'max' : 'exponential', + }; +} + /** * Asserts that the given transaction function issues the expected requests. */ @@ -311,11 +315,7 @@ function runTransaction( const request = expectedRequests.shift()!; expect(request.type).to.equal('getDocument'); expect(actual).to.deep.eq(request.request); - if (request.error) { - throw request.error; - } else { - return request.stream!; - } + return request.stream!; }, runQuery: actual => { const request = expectedRequests.shift()!; @@ -326,20 +326,31 @@ function runTransaction( }, }; - return createInstance(overrides).then(firestore => { - return firestore - .runTransaction(transaction => { + return createInstance(overrides).then(async firestore => { + const defaultTimeoutHandler = setTimeout; + + try { + setTimeoutHandler((callback, timeout) => { + if (timeout > 0) { + const request = expectedRequests.shift()!; + expect(request.type).to.equal('backoff'); + if (request.delay === 'max') { + // Make sure that the delay is at least 30 seconds, which is based + // on the maximum delay of 60 seconds and a jitter factor of 50%. + expect(timeout).to.not.be.lessThan(30 * 1000); + } + } + callback(); + }); + + return await firestore.runTransaction(transaction => { const docRef = firestore.doc('collectionId/documentId'); return transactionCallback(transaction, docRef); - }) - .then(val => { - expect(expectedRequests.length).to.equal(0); - return val; - }) - .catch(err => { - expect(expectedRequests.length).to.equal(0); - return Promise.reject(err); }); + } finally { + expect(expectedRequests.length).to.equal(0); + setTimeoutHandler(defaultTimeoutHandler); + } }); } @@ -368,6 +379,127 @@ describe('successful transactions', () => { }); describe('failed transactions', () => { + const retryBehavior: {[code: number]: boolean} = { + [Status.CANCELLED]: true, + [Status.UNKNOWN]: true, + [Status.INVALID_ARGUMENT]: false, + [Status.DEADLINE_EXCEEDED]: true, + [Status.NOT_FOUND]: false, + [Status.ALREADY_EXISTS]: false, + [Status.RESOURCE_EXHAUSTED]: true, + [Status.FAILED_PRECONDITION]: false, + [Status.ABORTED]: true, + [Status.OUT_OF_RANGE]: false, + [Status.UNIMPLEMENTED]: false, + [Status.INTERNAL]: true, + [Status.UNAVAILABLE]: true, + [Status.DATA_LOSS]: false, + [Status.UNAUTHENTICATED]: true, + }; + + it('retries commit based on error code', async () => { + const transactionFunction = () => Promise.resolve(); + + for (const [errorCode, retry] of Object.entries(retryBehavior)) { + const serverError = new GoogleError('Test Error'); + serverError.code = Number(errorCode) as Status; + + if (retry) { + await runTransaction( + transactionFunction, + begin('foo1'), + commit('foo1', undefined, serverError), + rollback('foo1'), + backoff(), + begin('foo2', 'foo1'), + commit('foo2') + ); + } else { + await expect( + runTransaction( + transactionFunction, + begin('foo1'), + commit('foo1', undefined, serverError), + rollback('foo1') + ) + ).to.eventually.be.rejected; + } + } + }); + + it('retries runQuery based on error code', async () => { + const transactionFunction = ( + transaction: Transaction, + docRef: DocumentReference + ) => { + const query = docRef.parent.where('foo', '==', 'bar'); + return transaction.get(query); + }; + + for (const [errorCode, retry] of Object.entries(retryBehavior)) { + const serverError = new GoogleError('Test Error'); + serverError.code = Number(errorCode) as Status; + + if (retry) { + await runTransaction( + transactionFunction, + begin('foo1'), + query('foo1', serverError), + rollback('foo1'), + backoff(), + begin('foo2', 'foo1'), + query('foo2'), + commit('foo2') + ); + } else { + await expect( + runTransaction( + transactionFunction, + begin('foo1'), + query('foo1', serverError), + rollback('foo1') + ) + ).to.eventually.be.rejected; + } + } + }); + + it('retries batchGetDocuments based on error code', async () => { + const transactionFunction = ( + transaction: Transaction, + docRef: DocumentReference + ) => { + return transaction.get(docRef); + }; + + for (const [errorCode, retry] of Object.entries(retryBehavior)) { + const serverError = new GoogleError('Test Error'); + serverError.code = Number(errorCode) as Status; + + if (retry) { + await runTransaction( + transactionFunction, + begin('foo1'), + getDocument('foo1', serverError), + rollback('foo1'), + backoff(), + begin('foo2', 'foo1'), + getDocument('foo2'), + commit('foo2') + ); + } else { + await expect( + runTransaction( + transactionFunction, + begin('foo1'), + getDocument('foo1', serverError), + rollback('foo1') + ) + ).to.eventually.be.rejected; + } + } + }); + it('requires update function', () => { const overrides: ApiOverride = { beginTransaction: () => Promise.reject(), @@ -424,43 +556,6 @@ describe('failed transactions', () => { }); }); - it('retries GRPC exceptions with code ABORTED in callback', () => { - const retryableError = new GoogleError('Aborted'); - retryableError.code = Status.ABORTED; - - return runTransaction( - async (transaction, docRef) => { - await transaction.get(docRef); - return 'success'; - }, - begin('foo1'), - getDocument('foo1', retryableError), - rollback('foo1'), - begin('foo2', 'foo1'), - getDocument('foo2'), - commit('foo2') - ).then(res => { - expect(res).to.equal('success'); - }); - }); - - it("doesn't retry GRPC exceptions with code FAILED_PRECONDITION in callback", () => { - const nonRetryableError = new GoogleError('Failed Precondition'); - nonRetryableError.code = Status.FAILED_PRECONDITION; - - return expect( - runTransaction( - async (transaction, docRef) => { - await transaction.get(docRef); - return 'failure'; - }, - begin('foo'), - getDocument('foo', nonRetryableError), - rollback('foo') - ) - ).to.eventually.be.rejectedWith('Failed Precondition'); - }); - it("doesn't retry custom user exceptions in callback", () => { return expect( runTransaction( @@ -473,48 +568,51 @@ describe('failed transactions', () => { ).to.eventually.be.rejectedWith('request exception'); }); - it('retries on commit failure', () => { - const userResult = ['failure', 'failure', 'success']; - const serverError = new Error('Retryable error'); - - return runTransaction( - () => { - return Promise.resolve(userResult.shift()); - }, - begin('foo1'), - commit('foo1', [], serverError), - begin('foo2', 'foo1'), - commit('foo2', [], serverError), - begin('foo3', 'foo2'), - commit('foo3') - ).then(res => { - expect(res).to.equal('success'); - }); - }); - it('limits the retry attempts', () => { const err = new GoogleError('Server disconnect'); err.code = Status.UNAVAILABLE; return expect( runTransaction( - () => { - return Promise.resolve('success'); - }, + () => Promise.resolve(), begin('foo1'), commit('foo1', [], err), + rollback('foo1'), + backoff(), begin('foo2', 'foo1'), commit('foo2', [], err), + rollback('foo2'), + backoff(), begin('foo3', 'foo2'), commit('foo3', [], err), + rollback('foo3'), + backoff(), begin('foo4', 'foo3'), commit('foo4', [], err), + rollback('foo4'), + backoff(), begin('foo5', 'foo4'), - commit('foo5', [], new Error('Final exception')) + commit('foo5', [], new Error('Final exception')), + rollback('foo5') ) ).to.eventually.be.rejectedWith('Final exception'); }); + it('uses maximum backoff for RESOURCE_EXHAUSTED', () => { + const err = new GoogleError('Server disconnect'); + err.code = Status.RESOURCE_EXHAUSTED; + + return runTransaction( + async () => {}, + begin('foo1'), + commit('foo1', [], err), + rollback('foo1'), + backoff(/* maxDelay= */ true), + begin('foo2', 'foo1'), + commit('foo2') + ); + }); + it('fails on rollback', () => { return expect( runTransaction( From 5894840900932697b1bd48886aff0b66e1e30d5b Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 9 Mar 2020 10:48:29 -0700 Subject: [PATCH 080/337] chore: release 3.6.0 (#951) --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70dd9e6f1..d1e3b89a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [3.6.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.5.1...v3.6.0) (2020-03-09) + + +### Features + +* base transaction retries on error codes ([#953](https://www.github.com/googleapis/nodejs-firestore/issues/953)) ([4a30820](https://www.github.com/googleapis/nodejs-firestore/commit/4a30820876db2ec925efd0ac04482fe9c6882813)) +* deferred client initialization ([#956](https://www.github.com/googleapis/nodejs-firestore/issues/956)) ([301a7e2](https://www.github.com/googleapis/nodejs-firestore/commit/301a7e2870529fc8b14c91ac08c942dececcc3d6)) +* implement Timestamp.valueOf() ([#947](https://www.github.com/googleapis/nodejs-firestore/issues/947)) ([24a96c6](https://www.github.com/googleapis/nodejs-firestore/commit/24a96c65ecbc4df0fc69b9a7f64e9e508fea89b9)), closes [#944](https://www.github.com/googleapis/nodejs-firestore/issues/944) + ### [3.5.1](https://www.github.com/googleapis/nodejs-firestore/compare/v3.5.0...v3.5.1) (2020-02-19) diff --git a/package.json b/package.json index a1adc7dcf..47ccb5b63 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.5.1", + "version": "3.6.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index f1fce0180..ae0efc612 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.5.1" + "@google-cloud/firestore": "^3.6.0" }, "devDependencies": { "chai": "^4.2.0", From 12982cd9ef6b418b6bc9fa303bb804255b9c906a Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 10 Mar 2020 08:48:26 -0700 Subject: [PATCH 081/337] feat(deps): update to TypeScript 3.8 (#962) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 47ccb5b63..ba71773fb 100644 --- a/package.json +++ b/package.json @@ -80,6 +80,6 @@ "protobufjs": "^6.8.6", "proxyquire": "^2.1.3", "ts-node": "^8.5.4", - "typescript": "3.6.4" + "typescript": "3.8.3" } } From c89546f5ae83da3845076aeeffcda75f9b208f5c Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 11 Mar 2020 14:52:11 -0700 Subject: [PATCH 082/337] feat: add support for Query.limitToLast() (#954) --- dev/src/reference.ts | 147 ++++++++++++++---- dev/system-test/firestore.ts | 281 +++++++++++++++++------------------ dev/test/query.ts | 110 +++++++++++++- dev/test/typescript.ts | 1 + types/firestore.d.ts | 19 ++- 5 files changed, 383 insertions(+), 175 deletions(-) diff --git a/dev/src/reference.ts b/dev/src/reference.ts index c75a71e00..4069bd2c0 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -965,10 +965,19 @@ docChangesPropertiesToOverride.forEach(property => { /** Internal representation of a query cursor before serialization. */ interface QueryCursor { - before?: boolean; + before: boolean; values: unknown[]; } +/*! + * Denotes whether a provided limit is applied to the beginning or the end of + * the result set. + */ +enum LimitType { + First, + Last, +} + /** * Internal class representing custom Query options. * @@ -986,6 +995,7 @@ export class QueryOptions { readonly startAt?: QueryCursor, readonly endAt?: QueryCursor, readonly limit?: number, + readonly limitType?: LimitType, readonly offset?: number, readonly projection?: api.StructuredQuery.IProjection ) {} @@ -1041,6 +1051,7 @@ export class QueryOptions { coalesce(settings.startAt, this.startAt), coalesce(settings.endAt, this.endAt), coalesce(settings.limit, this.limit), + coalesce(settings.limitType, this.limitType), coalesce(settings.offset, this.offset), coalesce(settings.projection, this.projection) ); @@ -1057,11 +1068,16 @@ export class QueryOptions { this.startAt, this.endAt, this.limit, + this.limitType, this.offset, this.projection ); } + hasFieldOrders(): boolean { + return this.fieldOrders.length > 0; + } + isEqual(other: QueryOptions) { if (this === other) { return true; @@ -1328,8 +1344,8 @@ export class Query { } /** - * Creates and returns a new [Query]{@link Query} that's additionally limited - * to only return up to the specified number of documents. + * Creates and returns a new [Query]{@link Query} that only returns the + * first matching documents. * * This function returns a new (immutable) instance of the Query (rather than * modify the existing instance) to impose the limit. @@ -1349,7 +1365,38 @@ export class Query { limit(limit: number): Query { validateInteger('limit', limit); - const options = this._queryOptions.with({limit}); + const options = this._queryOptions.with({ + limit, + limitType: LimitType.First, + }); + return new Query(this._firestore, options); + } + + /** + * Creates and returns a new [Query]{@link Query} that only returns the + * last matching documents. + * + * 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()` API. + * + * @param limit The maximum number of items to return. + * @return The created Query. + * + * @example + * let query = firestore.collection('col').where('foo', '>', 42); + * + * query.limitToLast(1).get().then(querySnapshot => { + * querySnapshot.forEach(documentSnapshot => { + * console.log(`Last matching document is ${documentSnapshot.ref.path}`); + * }); + * }); + */ + limitToLast(limit: number): Query { + validateInteger('limitToLast', limit); + + const options = this._queryOptions.with({limit, limitType: LimitType.Last}); return new Query(this._firestore, options); } @@ -1478,11 +1525,7 @@ export class Query { ); } - const options: QueryCursor = {values: []}; - - if (before) { - options.before = true; - } + const options: QueryCursor = {values: [], before}; for (let i = 0; i < fieldValues.length; ++i) { let fieldValue = fieldValues[i]; @@ -1744,12 +1787,14 @@ export class Query { * @param {bytes=} transactionId A transaction ID. */ _get(transactionId?: Uint8Array): Promise> { + const request = this.toProto(transactionId); + const docs: Array> = []; return new Promise((resolve, reject) => { let readTime: Timestamp; - this._stream(transactionId) + this._stream(request) .on('error', err => { reject(err); }) @@ -1760,6 +1805,13 @@ export class Query { } }) .on('end', () => { + if (this._queryOptions.limitType === LimitType.Last) { + // The results for limitToLast queries need to be flipped since + // we reversed the ordering constraints before sending the query + // to the backend. + docs.reverse(); + } + resolve( new QuerySnapshot( this, @@ -1799,7 +1851,15 @@ export class Query { * }); */ stream(): NodeJS.ReadableStream { - const responseStream = this._stream(); + if (this._queryOptions.limitType === LimitType.Last) { + throw new Error( + 'Query results for queries that include limitToLast() ' + + 'constraints cannot be streamed. Use Query.get() instead.' + ); + } + + const request = this.toProto(); + const responseStream = this._stream(request); const transform = through2.obj(function(this, chunk, encoding, callback) { // Only send chunks with documents. @@ -1816,14 +1876,16 @@ export class Query { /** * Converts a QueryCursor to its proto representation. + * + * @param cursor The original cursor value * @private */ - private _toCursor(cursor?: QueryCursor): api.ICursor | undefined { + private toCursor(cursor: QueryCursor | undefined): api.ICursor | undefined { if (cursor) { const values = cursor.values.map( val => this._serializer.encodeValue(val) as api.IValue ); - return {before: cursor.before, values}; + return cursor.before ? {before: true, values} : {values}; } return undefined; @@ -1875,12 +1937,41 @@ export class Query { }; } - if (this._queryOptions.fieldOrders.length) { - const orderBy: api.StructuredQuery.IOrder[] = []; - for (const fieldOrder of this._queryOptions.fieldOrders) { - orderBy.push(fieldOrder.toProto()); + if (this._queryOptions.limitType === LimitType.Last) { + if (!this._queryOptions.hasFieldOrders()) { + throw new Error( + 'limitToLast() queries require specifying at least one orderBy() clause.' + ); + } + + structuredQuery.orderBy = this._queryOptions.fieldOrders!.map(order => { + // Flip the orderBy directions since we want the last results + const dir = + order.direction === 'DESCENDING' ? 'ASCENDING' : 'DESCENDING'; + return new FieldOrder(order.field, dir).toProto(); + }); + + // Swap the cursors to match the now-flipped query ordering. + structuredQuery.startAt = this._queryOptions.endAt + ? this.toCursor({ + values: this._queryOptions.endAt.values, + before: !this._queryOptions.endAt.before, + }) + : undefined; + structuredQuery.endAt = this._queryOptions.startAt + ? this.toCursor({ + values: this._queryOptions.startAt.values, + before: !this._queryOptions.startAt.before, + }) + : undefined; + } else { + if (this._queryOptions.hasFieldOrders()) { + structuredQuery.orderBy = this._queryOptions.fieldOrders.map(o => + o.toProto() + ); } - structuredQuery.orderBy = orderBy; + structuredQuery.startAt = this.toCursor(this._queryOptions.startAt); + structuredQuery.endAt = this.toCursor(this._queryOptions.endAt); } if (this._queryOptions.limit) { @@ -1888,8 +1979,6 @@ export class Query { } structuredQuery.offset = this._queryOptions.offset; - structuredQuery.startAt = this._toCursor(this._queryOptions.startAt); - structuredQuery.endAt = this._toCursor(this._queryOptions.endAt); structuredQuery.select = this._queryOptions.projection; reqOpts.transaction = transactionId; @@ -1898,13 +1987,13 @@ export class Query { } /** - * Internal streaming method that accepts an optional transaction id. + * Internal streaming method that accepts the request proto. * - * @param transactionId A transaction ID. + * @param request The request proto. * @private * @returns A stream of document results. */ - _stream(transactionId?: Uint8Array): NodeJS.ReadableStream { + _stream(request: api.IRunQueryRequest): NodeJS.ReadableStream { const tag = requestTag(); const self = this; @@ -1932,7 +2021,6 @@ export class Query { }); this.firestore.initializeIfNeeded(tag).then(() => { - const request = this.toProto(transactionId); this._firestore .requestStream('runQuery', request, tag) .then(backendStream => { @@ -2009,12 +2097,11 @@ export class Query { ) => number { return (doc1, doc2) => { // Add implicit sorting by name, using the last specified direction. - const lastDirection: api.StructuredQuery.Direction = - this._queryOptions.fieldOrders.length === 0 - ? 'ASCENDING' - : this._queryOptions.fieldOrders[ - this._queryOptions.fieldOrders.length - 1 - ].direction; + const lastDirection = this._queryOptions.hasFieldOrders() + ? this._queryOptions.fieldOrders[ + this._queryOptions.fieldOrders.length - 1 + ].direction + : 'ASCENDING'; const orderBys = this._queryOptions.fieldOrders.concat( new FieldOrder(FieldPath.documentId(), lastDirection) ); diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 905eb0b33..bebe6c540 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -1079,6 +1079,18 @@ describe('Query class', () => { }); }; + function addDocs(...data: DocumentData[]): Promise { + let id = 0; // Guarantees consistent ordering for the first documents + return Promise.all(data.map(d => randomCol.doc('' + id++).set(d))); + } + + function expectDocs(result: QuerySnapshot, ...data: DocumentData[]) { + expect(result.size).to.equal(data.length); + result.forEach(doc => { + expect(doc.data()).to.deep.equal(data.shift()); + }); + } + beforeEach(() => { firestore = new Firestore({}); randomCol = getTestRoot(firestore); @@ -1159,46 +1171,44 @@ describe('Query class', () => { }); }); - it('supports in', () => { - return Promise.all([ - randomCol.doc('a').set({zip: 98101}), - randomCol.doc('b').set({zip: 91102}), - randomCol.doc('c').set({zip: 98103}), - randomCol.doc('d').set({zip: [98101]}), - randomCol.doc('e').set({zip: ['98101', {zip: 98101}]}), - randomCol.doc('f').set({zip: {zip: 98101}}), - ]) - .then(() => randomCol.where('zip', 'in', [98101, 98103]).get()) - .then(res => { - expect(res.size).to.equal(2); - expect(res.docs[0].data()).to.deep.equal({zip: 98101}); - expect(res.docs[1].data()).to.deep.equal({zip: 98103}); - }); - }); + it('supports in', async () => { + await addDocs( + {zip: 98101}, + {zip: 91102}, + {zip: 98103}, + {zip: [98101]}, + {zip: ['98101', {zip: 98101}]}, + {zip: {zip: 98101}} + ); + const res = await randomCol.where('zip', 'in', [98101, 98103]).get(); + expectDocs(res, {zip: 98101}, {zip: 98103}); + }); + + it('supports array-contains-any', async () => { + await addDocs( + {array: [42]}, + {array: ['a', 42, 'c']}, + {array: [41.999, '42', {a: [42]}]}, + {array: [42], array2: ['sigh']}, + {array: [43]}, + {array: [{a: 42}]}, + {array: 42} + ); + + const res = await randomCol + .where('array', 'array-contains-any', [42, 43]) + .get(); - it('supports array-contains-any', () => { - return Promise.all([ - randomCol.doc('a').set({array: [42]}), - randomCol.doc('b').set({array: ['a', 42, 'c']}), - randomCol.doc('c').set({array: [41.999, '42', {a: [42]}]}), - randomCol.doc('d').set({array: [42], array2: ['sigh']}), - randomCol.doc('e').set({array: [43]}), - randomCol.doc('f').set({array: [{a: 42}]}), - randomCol.doc('g').set({array: 42}), - ]) - .then(() => - randomCol.where('array', 'array-contains-any', [42, 43]).get() - ) - .then(res => { - expect(res.size).to.equal(4); - expect(res.docs[0].data()).to.deep.equal({array: [42]}); - expect(res.docs[1].data()).to.deep.equal({array: ['a', 42, 'c']}); - expect(res.docs[2].data()).to.deep.equal({ - array: [42], - array2: ['sigh'], - }); - expect(res.docs[3].data()).to.deep.equal({array: [43]}); - }); + expectDocs( + res, + {array: [42]}, + {array: ['a', 42, 'c']}, + { + array: [42], + array2: ['sigh'], + }, + {array: [43]} + ); }); it('can query by FieldPath.documentId()', () => { @@ -1214,23 +1224,14 @@ describe('Query class', () => { }); }); - it('has orderBy() method', () => { - const ref1 = randomCol.doc('doc1'); - const ref2 = randomCol.doc('doc2'); + it('has orderBy() method', async () => { + await addDocs({foo: 'a'}, {foo: 'b'}); - return Promise.all([ref1.set({foo: 'a'}), ref2.set({foo: 'b'})]) - .then(() => { - return randomCol.orderBy('foo').get(); - }) - .then(res => { - expect(res.docs[0].data()).to.deep.equal({foo: 'a'}); - expect(res.docs[1].data()).to.deep.equal({foo: 'b'}); - return randomCol.orderBy('foo', 'desc').get(); - }) - .then(res => { - expect(res.docs[0].data()).to.deep.equal({foo: 'b'}); - expect(res.docs[1].data()).to.deep.equal({foo: 'a'}); - }); + let res = await randomCol.orderBy('foo').get(); + expectDocs(res, {foo: 'a'}, {foo: 'b'}); + + res = await randomCol.orderBy('foo', 'desc').get(); + expectDocs(res, {foo: 'b'}, {foo: 'a'}); }); it('can order by FieldPath.documentId()', () => { @@ -1247,54 +1248,42 @@ describe('Query class', () => { }); }); - it('has limit() method', () => { - const ref1 = randomCol.doc('doc1'); - const ref2 = randomCol.doc('doc2'); - - return Promise.all([ref1.set({foo: 'a'}), ref2.set({foo: 'b'})]) - .then(() => { - return randomCol - .orderBy('foo') - .limit(1) - .get(); - }) - .then(res => { - expect(res.size).to.equal(1); - expect(res.docs[0].data()).to.deep.equal({foo: 'a'}); - }); + it('has limit() method', async () => { + await addDocs({foo: 'a'}, {foo: 'b'}); + const res = await randomCol + .orderBy('foo') + .limit(1) + .get(); + expectDocs(res, {foo: 'a'}); }); - it('has offset() method', () => { - const ref1 = randomCol.doc('doc1'); - const ref2 = randomCol.doc('doc2'); - - return Promise.all([ref1.set({foo: 'a'}), ref2.set({foo: 'b'})]) - .then(() => { - return randomCol - .orderBy('foo') - .offset(1) - .get(); - }) - .then(res => { - expect(res.size).to.equal(1); - expect(res.docs[0].data()).to.deep.equal({foo: 'b'}); - }); + it('has limitToLast() method', async () => { + await addDocs({doc: 1}, {doc: 2}, {doc: 3}); + const res = await randomCol + .orderBy('doc') + .limitToLast(2) + .get(); + expectDocs(res, {doc: 2}, {doc: 3}); }); - it('has startAt() method', () => { - const ref1 = randomCol.doc('doc1'); - const ref2 = randomCol.doc('doc2'); + it('limitToLast() supports Query cursors', async () => { + await addDocs({doc: 1}, {doc: 2}, {doc: 3}, {doc: 4}, {doc: 5}); + const res = await randomCol + .orderBy('doc') + .startAt(2) + .endAt(4) + .limitToLast(5) + .get(); + expectDocs(res, {doc: 2}, {doc: 3}, {doc: 4}); + }); - return Promise.all([ref1.set({foo: 'a'}), ref2.set({foo: 'b'})]) - .then(() => { - return randomCol - .orderBy('foo') - .startAt('a') - .get(); - }) - .then(res => { - expect(res.docs[0].data()).to.deep.equal({foo: 'a'}); - }); + it('has offset() method', async () => { + await addDocs({foo: 'a'}, {foo: 'b'}); + const res = await randomCol + .orderBy('foo') + .offset(1) + .get(); + expectDocs(res, {foo: 'b'}); }); it('supports Unicode in document names', async () => { @@ -1358,55 +1347,40 @@ describe('Query class', () => { }); }); - it('has startAfter() method', () => { - const ref1 = randomCol.doc('doc1'); - const ref2 = randomCol.doc('doc2'); - - return Promise.all([ref1.set({foo: 'a'}), ref2.set({foo: 'b'})]) - .then(() => { - return randomCol - .orderBy('foo') - .startAfter('a') - .get(); - }) - .then(res => { - expect(res.docs[0].data()).to.deep.equal({foo: 'b'}); - }); + it('has startAt() method', async () => { + await addDocs({foo: 'a'}, {foo: 'b'}); + const res = await randomCol + .orderBy('foo') + .startAt('b') + .get(); + expectDocs(res, {foo: 'b'}); }); - it('has endAt() method', () => { - const ref1 = randomCol.doc('doc1'); - const ref2 = randomCol.doc('doc2'); - - return Promise.all([ref1.set({foo: 'a'}), ref2.set({foo: 'b'})]) - .then(() => { - return randomCol - .orderBy('foo') - .endAt('b') - .get(); - }) - .then(res => { - expect(res.size).to.equal(2); - expect(res.docs[0].data()).to.deep.equal({foo: 'a'}); - expect(res.docs[1].data()).to.deep.equal({foo: 'b'}); - }); + it('has startAfter() method', async () => { + await addDocs({foo: 'a'}, {foo: 'b'}); + const res = await randomCol + .orderBy('foo') + .startAfter('a') + .get(); + expectDocs(res, {foo: 'b'}); }); - it('has endBefore() method', () => { - const ref1 = randomCol.doc('doc1'); - const ref2 = randomCol.doc('doc2'); + it('has endAt() method', async () => { + await addDocs({foo: 'a'}, {foo: 'b'}); + const res = await randomCol + .orderBy('foo') + .endAt('b') + .get(); + expectDocs(res, {foo: 'a'}, {foo: 'b'}); + }); - return Promise.all([ref1.set({foo: 'a'}), ref2.set({foo: 'b'})]) - .then(() => { - return randomCol - .orderBy('foo') - .endBefore('b') - .get(); - }) - .then(res => { - expect(res.size).to.equal(1); - expect(res.docs[0].data()).to.deep.equal({foo: 'a'}); - }); + it('has endBefore() method', async () => { + await addDocs({foo: 'a'}, {foo: 'b'}); + const res = await randomCol + .orderBy('foo') + .endBefore('b') + .get(); + expectDocs(res, {foo: 'a'}); }); it('has stream() method', done => { @@ -1820,6 +1794,29 @@ describe('Query class', () => { unsubscribe(); }); }); + + it('orders limitToLast() correctly', async () => { + const ref1 = randomCol.doc('doc1'); + const ref2 = randomCol.doc('doc2'); + const ref3 = randomCol.doc('doc3'); + + await ref1.set({doc: 1}); + await ref2.set({doc: 2}); + await ref3.set({doc: 3}); + + const unsubscribe = randomCol + .orderBy('doc') + .limitToLast(2) + .onSnapshot(snapshot => currentDeferred.resolve(snapshot)); + + const results = await waitForSnapshot(); + snapshotsEqual(results, { + docs: [snapshot('doc2', {doc: 2}), snapshot('doc3', {doc: 3})], + docChanges: [added('doc2', {doc: 2}), added('doc3', {doc: 3})], + }); + + unsubscribe(); + }); }); }); diff --git a/dev/test/query.ts b/dev/test/query.ts index b1577709a..131efe3b9 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -26,7 +26,6 @@ import { createInstance, document, InvalidApiUsage, - Post, postConverter, requestEquals, response, @@ -1201,6 +1200,115 @@ describe('limit() interface', () => { }); }); +describe('limitToLast() interface', () => { + let firestore: Firestore; + + beforeEach(() => { + return createInstance().then(firestoreInstance => { + firestore = firestoreInstance; + }); + }); + + afterEach(() => verifyInstance(firestore)); + + it('reverses order constraints', () => { + const overrides: ApiOverride = { + runQuery: request => { + queryEquals(request, orderBy('foo', 'DESCENDING'), limit(10)); + return stream(); + }, + }; + + return createInstance(overrides).then(firestore => { + let query: Query = firestore.collection('collectionId'); + query = query.orderBy('foo').limitToLast(10); + return query.get(); + }); + }); + + it('reverses cursors', () => { + const overrides: ApiOverride = { + runQuery: request => { + queryEquals( + request, + orderBy('foo', 'DESCENDING'), + startAt(true, 'end'), + endAt(false, 'start'), + limit(10) + ); + return stream(); + }, + }; + + return createInstance(overrides).then(firestore => { + let query: Query = firestore.collection('collectionId'); + query = query + .orderBy('foo') + .startAt('start') + .endAt('end') + .limitToLast(10); + return query.get(); + }); + }); + + it('reverses results', () => { + const overrides: ApiOverride = { + runQuery: request => { + queryEquals(request, orderBy('foo', 'DESCENDING'), limit(2)); + return stream(result('second'), result('first')); + }, + }; + + return createInstance(overrides).then(async firestore => { + let query: Query = firestore.collection('collectionId'); + query = query.orderBy('foo').limitToLast(2); + const result = await query.get(); + expect(result.docs[0].id).to.equal('first'); + expect(result.docs[1].id).to.equal('second'); + }); + }); + + it('expects number', () => { + const query = firestore.collection('collectionId'); + expect(() => query.limitToLast(Infinity)).to.throw( + 'Value for argument "limitToLast" is not a valid integer.' + ); + }); + + it('requires at least one ordering constraints', () => { + const query = firestore.collection('collectionId'); + expect(() => query.limitToLast(1).get()).to.throw( + 'limitToLast() queries require specifying at least one orderBy() clause.' + ); + }); + + it('rejects Query.stream()', () => { + const query = firestore.collection('collectionId'); + expect(() => query.limitToLast(1).stream()).to.throw( + 'Query results for queries that include limitToLast() constraints cannot be streamed. Use Query.get() instead.' + ); + }); + + it('uses latest limitToLast', () => { + const overrides: ApiOverride = { + runQuery: request => { + queryEquals(request, orderBy('foo', 'DESCENDING'), limit(3)); + return stream(); + }, + }; + + return createInstance(overrides).then(firestore => { + let query: Query = firestore.collection('collectionId'); + query = query + .orderBy('foo') + .limitToLast(1) + .limitToLast(2) + .limitToLast(3); + return query.get(); + }); + }); +}); + describe('offset() interface', () => { let firestore: Firestore; diff --git a/dev/test/typescript.ts b/dev/test/typescript.ts index ee3845c9b..a73ea272d 100644 --- a/dev/test/typescript.ts +++ b/dev/test/typescript.ts @@ -255,6 +255,7 @@ xdescribe('firestore.d.ts', () => { query = query.orderBy(new FieldPath('foo')); query = query.orderBy(new FieldPath('foo'), 'desc'); query = query.limit(42); + query = query.limitToLast(42); query = query.offset(42); query = query.select('foo'); query = query.select('foo', 'bar'); diff --git a/types/firestore.d.ts b/types/firestore.d.ts index d39713da9..165da504d 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -893,8 +893,8 @@ declare namespace FirebaseFirestore { ): Query; /** - * Creates and returns a new Query that's additionally limited to only - * return up to the specified number of documents. + * Creates and returns a new Query that only returns the first matching + * documents. * * This function returns a new (immutable) instance of the Query (rather * than modify the existing instance) to impose the limit. @@ -903,6 +903,21 @@ declare namespace FirebaseFirestore { * @return The created Query. */ limit(limit: number): Query; + + /** + * Creates and returns a new Query that only returns the last matching + * documents. + * + * 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()` + * API. + * + * @param limit The maximum number of items to return. + * @return The created Query. + */ + limitToLast(limit: number): Query; /** * Specifies the offset of the returned results. From 469df0252ded222321ebb8d03ab7b2932e306468 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 11 Mar 2020 19:40:57 -0700 Subject: [PATCH 083/337] chore: release 3.7.0 (#963) --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1e3b89a8..72a3e85c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [3.7.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.6.0...v3.7.0) (2020-03-11) + + +### Features + +* **deps:** update to TypeScript 3.8 ([#962](https://www.github.com/googleapis/nodejs-firestore/issues/962)) ([12982cd](https://www.github.com/googleapis/nodejs-firestore/commit/12982cd9ef6b418b6bc9fa303bb804255b9c906a)) +* add support for Query.limitToLast() ([#954](https://www.github.com/googleapis/nodejs-firestore/issues/954)) ([c89546f](https://www.github.com/googleapis/nodejs-firestore/commit/c89546f5ae83da3845076aeeffcda75f9b208f5c)) + ## [3.6.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.5.1...v3.6.0) (2020-03-09) diff --git a/package.json b/package.json index ba71773fb..4f96091b4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.6.0", + "version": "3.7.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index ae0efc612..a6e5c2dd9 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.6.0" + "@google-cloud/firestore": "^3.7.0" }, "devDependencies": { "chai": "^4.2.0", From a48017c16dbf7819ea45ea2577365b52721c2475 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 16 Mar 2020 16:16:45 -0700 Subject: [PATCH 084/337] fix: support Query.stream() as first client operation (#971) --- dev/src/reference.ts | 47 ++++++++++----------- dev/system-test/firestore.ts | 81 ++++++++++++++++++++++++++++++++++++ dev/test/query.ts | 8 +++- 3 files changed, 108 insertions(+), 28 deletions(-) diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 4069bd2c0..40f60f522 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -1787,14 +1787,12 @@ export class Query { * @param {bytes=} transactionId A transaction ID. */ _get(transactionId?: Uint8Array): Promise> { - const request = this.toProto(transactionId); - const docs: Array> = []; return new Promise((resolve, reject) => { let readTime: Timestamp; - this._stream(request) + this._stream(transactionId) .on('error', err => { reject(err); }) @@ -1858,8 +1856,7 @@ export class Query { ); } - const request = this.toProto(); - const responseStream = this._stream(request); + const responseStream = this._stream(); const transform = through2.obj(function(this, chunk, encoding, callback) { // Only send chunks with documents. @@ -1987,13 +1984,13 @@ export class Query { } /** - * Internal streaming method that accepts the request proto. + * Internal streaming method that accepts an optional transaction ID. * - * @param request The request proto. + * @param transactionId A transaction ID. * @private * @returns A stream of document results. */ - _stream(request: api.IRunQueryRequest): NodeJS.ReadableStream { + _stream(transactionId?: Uint8Array): NodeJS.ReadableStream { const tag = requestTag(); const self = this; @@ -2020,26 +2017,24 @@ export class Query { callback(); }); - this.firestore.initializeIfNeeded(tag).then(() => { - this._firestore - .requestStream('runQuery', request, tag) - .then(backendStream => { - backendStream.on('error', err => { - logger( - 'Query._stream', - tag, - 'Query failed with stream error:', - err - ); - stream.destroy(err); - }); - backendStream.resume(); - backendStream.pipe(stream); - }) - .catch(err => { + this.firestore + .initializeIfNeeded(tag) + .then(async () => { + // `toProto()` might throw an exception. We rely on the behavior of an + // async function to convert this exception into the rejected Promise we + // catch below. + const request = this.toProto(transactionId); + return this._firestore.requestStream('runQuery', request, tag); + }) + .then(backendStream => { + backendStream.on('error', err => { + logger('Query._stream', tag, 'Query failed with stream error:', err); stream.destroy(err); }); - }); + backendStream.resume(); + backendStream.pipe(stream); + }) + .catch(e => stream.destroy(e)); return stream; } diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index bebe6c540..6803eea36 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -2232,3 +2232,84 @@ describe('QuerySnapshot class', () => { }); }); }); + +describe('Client initialization', () => { + const ops: Array<[ + string, + (coll: CollectionReference) => Promise + ]> = [ + ['CollectionReference.get()', randomColl => randomColl.get()], + ['CollectionReference.add()', randomColl => randomColl.add({})], + [ + 'CollectionReference.stream()', + randomColl => { + const deferred = new Deferred(); + randomColl.stream().on('finish', () => { + deferred.resolve(); + }); + return deferred.promise; + }, + ], + [ + 'CollectionReference.listDocuments()', + randomColl => randomColl.listDocuments(), + ], + [ + 'CollectionReference.onSnapshot()', + randomColl => { + const deferred = new Deferred(); + const unsubscribe = randomColl.onSnapshot(() => { + unsubscribe(); + deferred.resolve(); + }); + return deferred.promise; + }, + ], + ['DocumentReference.get()', randomColl => randomColl.doc().get()], + ['DocumentReference.create()', randomColl => randomColl.doc().create({})], + ['DocumentReference.set()', randomColl => randomColl.doc().set({})], + [ + 'DocumentReference.update()', + async randomColl => { + const update = randomColl.doc().update('foo', 'bar'); + await expect(update).to.eventually.be.rejectedWith( + 'No document to update' + ); + }, + ], + ['DocumentReference.delete()', randomColl => randomColl.doc().delete()], + [ + 'DocumentReference.listCollections()', + randomColl => randomColl.doc().listCollections(), + ], + [ + 'DocumentReference.onSnapshot()', + randomColl => { + const deferred = new Deferred(); + const unsubscribe = randomColl.doc().onSnapshot(() => { + unsubscribe(); + deferred.resolve(); + }); + return deferred.promise; + }, + ], + [ + 'Firestore.runTransaction()', + randomColl => randomColl.firestore.runTransaction(t => t.get(randomColl)), + ], + [ + 'Firestore.getAll()', + randomColl => randomColl.firestore.getAll(randomColl.doc()), + ], + ['Firestore.batch()', randomColl => randomColl.firestore.batch().commit()], + ['Firestore.terminate()', randomColl => randomColl.firestore.terminate()], + ]; + + for (const [description, op] of ops) { + it(`succeeds for ${description}`, () => { + const firestore = new Firestore(); + const randomCol = getTestRoot(firestore); + return op(randomCol); + }); + } +}); diff --git a/dev/test/query.ts b/dev/test/query.ts index 131efe3b9..12f6a84e3 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -12,7 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {expect} from 'chai'; +import {expect, use} from 'chai'; +import * as chaiAsPromised from 'chai-as-promised'; import * as extend from 'extend'; import {google} from '../protos/firestore_v1_proto_api'; @@ -43,6 +44,8 @@ const DATABASE_ROOT = `projects/${PROJECT_ID}/databases/(default)`; // Change the argument to 'console.log' to enable debug output. setLogFunction(() => {}); +use(chaiAsPromised); + function snapshot( relativePath: string, data: DocumentData @@ -1277,7 +1280,8 @@ describe('limitToLast() interface', () => { it('requires at least one ordering constraints', () => { const query = firestore.collection('collectionId'); - expect(() => query.limitToLast(1).get()).to.throw( + const result = query.limitToLast(1).get(); + return expect(result).to.eventually.be.rejectedWith( 'limitToLast() queries require specifying at least one orderBy() clause.' ); }); From 5a8b1e4e0b6a18b0c3112be8b3066829154a9187 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 16 Mar 2020 16:40:30 -0700 Subject: [PATCH 085/337] chore: release 3.7.1 (#972) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72a3e85c3..e50e0775b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.7.1](https://www.github.com/googleapis/nodejs-firestore/compare/v3.7.0...v3.7.1) (2020-03-16) + + +### Bug Fixes + +* support Query.stream() as first client operation ([#971](https://www.github.com/googleapis/nodejs-firestore/issues/971)) ([a48017c](https://www.github.com/googleapis/nodejs-firestore/commit/a48017c16dbf7819ea45ea2577365b52721c2475)) + ## [3.7.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.6.0...v3.7.0) (2020-03-11) diff --git a/package.json b/package.json index 4f96091b4..619cfbdd8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.7.0", + "version": "3.7.1", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index a6e5c2dd9..d2e8e617e 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.7.0" + "@google-cloud/firestore": "^3.7.1" }, "devDependencies": { "chai": "^4.2.0", From 0d369d24a1310c9d26374b11309bbd16d78b36c4 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Wed, 18 Mar 2020 12:58:55 -0700 Subject: [PATCH 086/337] docs: mention templates in contributing section of README (#974) --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index d1cd97732..e2381d368 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,12 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-firestore/blob/master/CONTRIBUTING.md). +Please note that this `README.md`, the `samples/README.md`, +and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) +are generated from a central template. To edit one of these files, make an edit +to its template in this +[directory](https://github.com/googleapis/synthtool/tree/master/synthtool/gcp/templates/node_library). + ## License Apache Version 2.0 From ad649519569a1b1f984bb9602e6be7761ead0c9f Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Thu, 19 Mar 2020 08:53:17 -0700 Subject: [PATCH 087/337] chore: remove snippet leading whitespace (#976) From f294998daab77a0a51c81265945e28eec34db186 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Sat, 21 Mar 2020 17:47:14 -0700 Subject: [PATCH 088/337] fix: fix flaky contention test (#979) Fixes https://github.com/googleapis/nodejs-firestore/issues/977 --- dev/system-test/firestore.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 6803eea36..974e55fb9 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -2036,19 +2036,21 @@ describe('Transaction class', () => { // `contentionPromise` is used to ensure that both transactions are active // on commit, which causes one of transactions to fail with Code ABORTED // and be retried. - const contentionPromise = new Deferred(); + const contentionPromise = [new Deferred(), new Deferred()]; firstTransaction = firestore.runTransaction(async transaction => { ++attempts; await transaction.get(ref); - await contentionPromise.promise; + contentionPromise[0].resolve(); + await contentionPromise[1].promise; transaction.set(ref, {first: true}, {merge: true}); }); secondTransaction = firestore.runTransaction(async transaction => { ++attempts; await transaction.get(ref); - contentionPromise.resolve(); + contentionPromise[1].resolve(); + await contentionPromise[0].promise; transaction.set(ref, {second: true}, {merge: true}); }); From 708180d42562c1f5e225b1a3f1610f606036e3e9 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Mon, 23 Mar 2020 10:43:20 -0700 Subject: [PATCH 089/337] test: update conformance tests (#978) --- .../create-all-transforms.json | 73 +++ .../create-arrayremove-multi.json | 69 +++ .../create-arrayremove-nested.json | 53 +++ .../create-arrayremove-noarray-nested.json | 13 + .../create-arrayremove-noarray.json | 13 + .../create-arrayremove-with-st.json | 13 + .../conformance-tests/create-arrayremove.json | 53 +++ .../create-arrayunion-multi.json | 69 +++ .../create-arrayunion-nested.json | 53 +++ .../create-arrayunion-noarray-nested.json | 13 + .../create-arrayunion-noarray.json | 13 + .../create-arrayunion-with-st.json | 13 + .../conformance-tests/create-arrayunion.json | 53 +++ .../conformance-tests/create-basic.json | 30 ++ .../conformance-tests/create-complex.json | 63 +++ .../create-del-noarray-nested.json | 13 + .../conformance-tests/create-del-noarray.json | 13 + .../conformance-tests/create-empty.json | 25 ++ .../conformance-tests/create-nodel.json | 13 + .../conformance-tests/create-nosplit.json | 39 ++ .../create-special-chars.json | 39 ++ .../conformance-tests/create-st-alone.json | 31 ++ .../conformance-tests/create-st-multi.json | 45 ++ .../conformance-tests/create-st-nested.json | 41 ++ .../create-st-noarray-nested.json | 13 + .../conformance-tests/create-st-noarray.json | 13 + .../create-st-with-empty-map.json | 49 +++ .../conformance-tests/create-st.json | 41 ++ .../delete-exists-precond.json | 25 ++ .../conformance-tests/delete-no-precond.json | 19 + .../delete-time-precond.json | 25 ++ .../conformance-tests/get-basic.json | 14 + .../listen-add-mod-del-add.json | 206 +++++++++ .../conformance-tests/listen-add-one.json | 72 +++ .../conformance-tests/listen-add-three.json | 156 +++++++ .../conformance-tests/listen-doc-remove.json | 101 +++++ .../conformance-tests/listen-empty.json | 27 ++ .../conformance-tests/listen-filter-nop.json | 203 +++++++++ .../conformance-tests/listen-multi-docs.json | 414 ++++++++++++++++++ .../conformance-tests/listen-nocurrent.json | 119 +++++ .../conformance-tests/listen-nomod.json | 123 ++++++ .../listen-removed-target-ids.json | 113 +++++ .../conformance-tests/listen-reset.json | 309 +++++++++++++ .../listen-target-add-nop.json | 81 ++++ .../listen-target-add-wrong-id.json | 49 +++ .../listen-target-remove.json | 45 ++ .../query-arrayremove-cursor.json | 31 ++ .../query-arrayremove-where.json | 25 ++ .../query-arrayunion-cursor.json | 31 ++ .../query-arrayunion-where.json | 25 ++ .../conformance-tests/query-bad-NaN.json | 25 ++ .../conformance-tests/query-bad-null.json | 25 ++ .../query-cursor-docsnap-order.json | 81 ++++ .../query-cursor-docsnap-orderby-name.json | 91 ++++ .../query-cursor-docsnap-where-eq.json | 65 +++ ...uery-cursor-docsnap-where-neq-orderby.json | 85 ++++ .../query-cursor-docsnap-where-neq.json | 75 ++++ .../query-cursor-docsnap.json | 44 ++ .../query-cursor-endbefore-empty-map.json | 55 +++ .../query-cursor-endbefore-empty.json | 27 ++ .../query-cursor-no-order.json | 21 + .../query-cursor-startat-empty-map.json | 55 +++ .../query-cursor-startat-empty.json | 27 ++ .../query-cursor-vals-1a.json | 68 +++ .../query-cursor-vals-1b.json | 66 +++ .../query-cursor-vals-2.json | 91 ++++ .../query-cursor-vals-docid.json | 67 +++ .../query-cursor-vals-last-wins.json | 82 ++++ .../conformance-tests/query-del-cursor.json | 31 ++ .../conformance-tests/query-del-where.json | 25 ++ .../query-invalid-operator.json | 25 ++ .../query-invalid-path-order.json | 25 ++ .../query-invalid-path-select.json | 26 ++ .../query-invalid-path-where.json | 26 ++ .../query-offset-limit-last-wins.json | 34 ++ .../conformance-tests/query-offset-limit.json | 28 ++ .../conformance-tests/query-order.json | 54 +++ .../conformance-tests/query-select-empty.json | 32 ++ .../query-select-last-wins.json | 54 +++ .../conformance-tests/query-select.json | 46 ++ .../conformance-tests/query-st-cursor.json | 31 ++ .../conformance-tests/query-st-where.json | 25 ++ .../conformance-tests/query-where-2.json | 71 +++ .../conformance-tests/query-where-NaN.json | 39 ++ .../conformance-tests/query-where-null.json | 39 ++ .../conformance-tests/query-where.json | 42 ++ .../query-wrong-collection.json | 22 + .../conformance-tests/set-all-transforms.json | 70 +++ .../set-arrayremove-multi.json | 66 +++ .../set-arrayremove-nested.json | 50 +++ .../set-arrayremove-noarray-nested.json | 13 + .../set-arrayremove-noarray.json | 13 + .../set-arrayremove-with-st.json | 13 + .../conformance-tests/set-arrayremove.json | 50 +++ .../set-arrayunion-multi.json | 66 +++ .../set-arrayunion-nested.json | 50 +++ .../set-arrayunion-noarray-nested.json | 13 + .../set-arrayunion-noarray.json | 13 + .../set-arrayunion-with-st.json | 13 + .../conformance-tests/set-arrayunion.json | 50 +++ .../conformance-tests/set-basic.json | 27 ++ .../conformance-tests/set-complex.json | 60 +++ .../set-del-merge-alone.json | 37 ++ .../conformance-tests/set-del-merge.json | 48 ++ .../conformance-tests/set-del-mergeall.json | 36 ++ .../set-del-noarray-nested.json | 13 + .../conformance-tests/set-del-noarray.json | 13 + .../conformance-tests/set-del-nomerge.json | 22 + .../conformance-tests/set-del-nonleaf.json | 22 + .../conformance-tests/set-del-wo-merge.json | 13 + .../conformance-tests/set-empty.json | 22 + .../conformance-tests/set-merge-fp.json | 48 ++ .../conformance-tests/set-merge-nested.json | 48 ++ .../conformance-tests/set-merge-nonleaf.json | 50 +++ .../conformance-tests/set-merge-prefix.json | 28 ++ .../conformance-tests/set-merge-present.json | 27 ++ .../conformance-tests/set-merge.json | 41 ++ .../conformance-tests/set-mergeall-empty.json | 29 ++ .../set-mergeall-nested.json | 45 ++ .../conformance-tests/set-mergeall.json | 39 ++ .../conformance-tests/set-nodel.json | 13 + .../conformance-tests/set-nosplit.json | 36 ++ .../conformance-tests/set-special-chars.json | 36 ++ .../set-st-alone-mergeall.json | 31 ++ .../conformance-tests/set-st-alone.json | 34 ++ .../conformance-tests/set-st-merge-both.json | 57 +++ .../set-st-merge-nonleaf-alone.json | 47 ++ .../set-st-merge-nonleaf.json | 58 +++ .../set-st-merge-nowrite.json | 37 ++ .../conformance-tests/set-st-mergeall.json | 46 ++ .../conformance-tests/set-st-multi.json | 42 ++ .../conformance-tests/set-st-nested.json | 38 ++ .../set-st-noarray-nested.json | 13 + .../conformance-tests/set-st-noarray.json | 13 + .../conformance-tests/set-st-nomerge.json | 41 ++ .../set-st-with-empty-map.json | 46 ++ dev/conformance/conformance-tests/set-st.json | 38 ++ .../update-all-transforms.json | 78 ++++ .../update-arrayremove-alone.json | 43 ++ .../update-arrayremove-multi.json | 75 ++++ .../update-arrayremove-nested.json | 59 +++ .../update-arrayremove-noarray-nested.json | 13 + .../update-arrayremove-noarray.json | 13 + .../update-arrayremove-with-st.json | 13 + .../conformance-tests/update-arrayremove.json | 58 +++ .../update-arrayunion-alone.json | 43 ++ .../update-arrayunion-multi.json | 75 ++++ .../update-arrayunion-nested.json | 59 +++ .../update-arrayunion-noarray-nested.json | 13 + .../update-arrayunion-noarray.json | 13 + .../update-arrayunion-with-st.json | 13 + .../conformance-tests/update-arrayunion.json | 58 +++ .../conformance-tests/update-badchar.json | 13 + .../conformance-tests/update-basic.json | 35 ++ .../conformance-tests/update-complex.json | 69 +++ .../conformance-tests/update-del-alone.json | 30 ++ .../conformance-tests/update-del-dot.json | 46 ++ .../conformance-tests/update-del-nested.json | 13 + .../update-del-noarray-nested.json | 13 + .../conformance-tests/update-del-noarray.json | 13 + .../conformance-tests/update-del.json | 36 ++ .../update-exists-precond.json | 16 + .../update-fp-empty-component.json | 13 + ...ate-nested-transform-and-nested-value.json | 52 +++ .../conformance-tests/update-no-paths.json | 13 + .../update-paths-all-transforms.json | 105 +++++ .../update-paths-arrayremove-alone.json | 52 +++ .../update-paths-arrayremove-multi.json | 96 ++++ .../update-paths-arrayremove-nested.json | 74 ++++ ...date-paths-arrayremove-noarray-nested.json | 22 + .../update-paths-arrayremove-noarray.json | 22 + .../update-paths-arrayremove-with-st.json | 22 + .../update-paths-arrayremove.json | 73 +++ .../update-paths-arrayunion-alone.json | 52 +++ .../update-paths-arrayunion-multi.json | 96 ++++ .../update-paths-arrayunion-nested.json | 74 ++++ ...pdate-paths-arrayunion-noarray-nested.json | 22 + .../update-paths-arrayunion-noarray.json | 22 + .../update-paths-arrayunion-with-st.json | 22 + .../update-paths-arrayunion.json | 73 +++ .../conformance-tests/update-paths-basic.json | 44 ++ .../update-paths-complex.json | 84 ++++ .../update-paths-del-alone.json | 39 ++ .../update-paths-del-nested.json | 22 + .../update-paths-del-noarray-nested.json | 22 + .../update-paths-del-noarray.json | 22 + .../conformance-tests/update-paths-del.json | 51 +++ .../update-paths-exists-precond.json | 25 ++ .../update-paths-fp-del.json | 59 +++ .../update-paths-fp-dup-transforms.json | 34 ++ .../update-paths-fp-dup.json | 34 ++ .../update-paths-fp-empty-component.json | 23 + .../update-paths-fp-empty.json | 20 + .../update-paths-fp-multi.json | 51 +++ .../update-paths-fp-nosplit.json | 57 +++ ...ths-nested-transform-and-nested-value.json | 69 +++ .../update-paths-no-paths.json | 12 + .../update-paths-prefix-1.json | 29 ++ .../update-paths-prefix-2.json | 29 ++ .../update-paths-prefix-3.json | 29 ++ .../update-paths-special-chars.json | 62 +++ .../update-paths-st-alone.json | 40 ++ .../update-paths-st-multi.json | 72 +++ .../update-paths-st-nested.json | 62 +++ .../update-paths-st-noarray-nested.json | 22 + .../update-paths-st-noarray.json | 22 + .../update-paths-st-with-empty-map.json | 69 +++ .../conformance-tests/update-paths-st.json | 61 +++ .../update-paths-uptime.json | 47 ++ .../conformance-tests/update-prefix-1.json | 13 + .../conformance-tests/update-prefix-2.json | 13 + .../conformance-tests/update-prefix-3.json | 13 + .../conformance-tests/update-quoting.json | 47 ++ .../update-split-top-level.json | 47 ++ .../conformance-tests/update-split.json | 47 ++ .../conformance-tests/update-st-alone.json | 31 ++ .../conformance-tests/update-st-dot.json | 31 ++ .../conformance-tests/update-st-multi.json | 51 +++ .../conformance-tests/update-st-nested.json | 47 ++ .../update-st-noarray-nested.json | 13 + .../conformance-tests/update-st-noarray.json | 13 + .../update-st-with-empty-map.json | 54 +++ .../conformance-tests/update-st.json | 46 ++ .../conformance-tests/update-uptime.json | 38 ++ dev/conformance/runner.ts | 101 ++++- dev/conformance/test-definition.proto | 3 +- dev/conformance/test-suite.binproto | Bin 55916 -> 0 bytes package.json | 2 +- scripts/init-directories.js | 21 + 229 files changed, 10327 insertions(+), 12 deletions(-) create mode 100644 dev/conformance/conformance-tests/create-all-transforms.json create mode 100644 dev/conformance/conformance-tests/create-arrayremove-multi.json create mode 100644 dev/conformance/conformance-tests/create-arrayremove-nested.json create mode 100644 dev/conformance/conformance-tests/create-arrayremove-noarray-nested.json create mode 100644 dev/conformance/conformance-tests/create-arrayremove-noarray.json create mode 100644 dev/conformance/conformance-tests/create-arrayremove-with-st.json create mode 100644 dev/conformance/conformance-tests/create-arrayremove.json create mode 100644 dev/conformance/conformance-tests/create-arrayunion-multi.json create mode 100644 dev/conformance/conformance-tests/create-arrayunion-nested.json create mode 100644 dev/conformance/conformance-tests/create-arrayunion-noarray-nested.json create mode 100644 dev/conformance/conformance-tests/create-arrayunion-noarray.json create mode 100644 dev/conformance/conformance-tests/create-arrayunion-with-st.json create mode 100644 dev/conformance/conformance-tests/create-arrayunion.json create mode 100644 dev/conformance/conformance-tests/create-basic.json create mode 100644 dev/conformance/conformance-tests/create-complex.json create mode 100644 dev/conformance/conformance-tests/create-del-noarray-nested.json create mode 100644 dev/conformance/conformance-tests/create-del-noarray.json create mode 100644 dev/conformance/conformance-tests/create-empty.json create mode 100644 dev/conformance/conformance-tests/create-nodel.json create mode 100644 dev/conformance/conformance-tests/create-nosplit.json create mode 100644 dev/conformance/conformance-tests/create-special-chars.json create mode 100644 dev/conformance/conformance-tests/create-st-alone.json create mode 100644 dev/conformance/conformance-tests/create-st-multi.json create mode 100644 dev/conformance/conformance-tests/create-st-nested.json create mode 100644 dev/conformance/conformance-tests/create-st-noarray-nested.json create mode 100644 dev/conformance/conformance-tests/create-st-noarray.json create mode 100644 dev/conformance/conformance-tests/create-st-with-empty-map.json create mode 100644 dev/conformance/conformance-tests/create-st.json create mode 100644 dev/conformance/conformance-tests/delete-exists-precond.json create mode 100644 dev/conformance/conformance-tests/delete-no-precond.json create mode 100644 dev/conformance/conformance-tests/delete-time-precond.json create mode 100644 dev/conformance/conformance-tests/get-basic.json create mode 100644 dev/conformance/conformance-tests/listen-add-mod-del-add.json create mode 100644 dev/conformance/conformance-tests/listen-add-one.json create mode 100644 dev/conformance/conformance-tests/listen-add-three.json create mode 100644 dev/conformance/conformance-tests/listen-doc-remove.json create mode 100644 dev/conformance/conformance-tests/listen-empty.json create mode 100644 dev/conformance/conformance-tests/listen-filter-nop.json create mode 100644 dev/conformance/conformance-tests/listen-multi-docs.json create mode 100644 dev/conformance/conformance-tests/listen-nocurrent.json create mode 100644 dev/conformance/conformance-tests/listen-nomod.json create mode 100644 dev/conformance/conformance-tests/listen-removed-target-ids.json create mode 100644 dev/conformance/conformance-tests/listen-reset.json create mode 100644 dev/conformance/conformance-tests/listen-target-add-nop.json create mode 100644 dev/conformance/conformance-tests/listen-target-add-wrong-id.json create mode 100644 dev/conformance/conformance-tests/listen-target-remove.json create mode 100644 dev/conformance/conformance-tests/query-arrayremove-cursor.json create mode 100644 dev/conformance/conformance-tests/query-arrayremove-where.json create mode 100644 dev/conformance/conformance-tests/query-arrayunion-cursor.json create mode 100644 dev/conformance/conformance-tests/query-arrayunion-where.json create mode 100644 dev/conformance/conformance-tests/query-bad-NaN.json create mode 100644 dev/conformance/conformance-tests/query-bad-null.json create mode 100644 dev/conformance/conformance-tests/query-cursor-docsnap-order.json create mode 100644 dev/conformance/conformance-tests/query-cursor-docsnap-orderby-name.json create mode 100644 dev/conformance/conformance-tests/query-cursor-docsnap-where-eq.json create mode 100644 dev/conformance/conformance-tests/query-cursor-docsnap-where-neq-orderby.json create mode 100644 dev/conformance/conformance-tests/query-cursor-docsnap-where-neq.json create mode 100644 dev/conformance/conformance-tests/query-cursor-docsnap.json create mode 100644 dev/conformance/conformance-tests/query-cursor-endbefore-empty-map.json create mode 100644 dev/conformance/conformance-tests/query-cursor-endbefore-empty.json create mode 100644 dev/conformance/conformance-tests/query-cursor-no-order.json create mode 100644 dev/conformance/conformance-tests/query-cursor-startat-empty-map.json create mode 100644 dev/conformance/conformance-tests/query-cursor-startat-empty.json create mode 100644 dev/conformance/conformance-tests/query-cursor-vals-1a.json create mode 100644 dev/conformance/conformance-tests/query-cursor-vals-1b.json create mode 100644 dev/conformance/conformance-tests/query-cursor-vals-2.json create mode 100644 dev/conformance/conformance-tests/query-cursor-vals-docid.json create mode 100644 dev/conformance/conformance-tests/query-cursor-vals-last-wins.json create mode 100644 dev/conformance/conformance-tests/query-del-cursor.json create mode 100644 dev/conformance/conformance-tests/query-del-where.json create mode 100644 dev/conformance/conformance-tests/query-invalid-operator.json create mode 100644 dev/conformance/conformance-tests/query-invalid-path-order.json create mode 100644 dev/conformance/conformance-tests/query-invalid-path-select.json create mode 100644 dev/conformance/conformance-tests/query-invalid-path-where.json create mode 100644 dev/conformance/conformance-tests/query-offset-limit-last-wins.json create mode 100644 dev/conformance/conformance-tests/query-offset-limit.json create mode 100644 dev/conformance/conformance-tests/query-order.json create mode 100644 dev/conformance/conformance-tests/query-select-empty.json create mode 100644 dev/conformance/conformance-tests/query-select-last-wins.json create mode 100644 dev/conformance/conformance-tests/query-select.json create mode 100644 dev/conformance/conformance-tests/query-st-cursor.json create mode 100644 dev/conformance/conformance-tests/query-st-where.json create mode 100644 dev/conformance/conformance-tests/query-where-2.json create mode 100644 dev/conformance/conformance-tests/query-where-NaN.json create mode 100644 dev/conformance/conformance-tests/query-where-null.json create mode 100644 dev/conformance/conformance-tests/query-where.json create mode 100644 dev/conformance/conformance-tests/query-wrong-collection.json create mode 100644 dev/conformance/conformance-tests/set-all-transforms.json create mode 100644 dev/conformance/conformance-tests/set-arrayremove-multi.json create mode 100644 dev/conformance/conformance-tests/set-arrayremove-nested.json create mode 100644 dev/conformance/conformance-tests/set-arrayremove-noarray-nested.json create mode 100644 dev/conformance/conformance-tests/set-arrayremove-noarray.json create mode 100644 dev/conformance/conformance-tests/set-arrayremove-with-st.json create mode 100644 dev/conformance/conformance-tests/set-arrayremove.json create mode 100644 dev/conformance/conformance-tests/set-arrayunion-multi.json create mode 100644 dev/conformance/conformance-tests/set-arrayunion-nested.json create mode 100644 dev/conformance/conformance-tests/set-arrayunion-noarray-nested.json create mode 100644 dev/conformance/conformance-tests/set-arrayunion-noarray.json create mode 100644 dev/conformance/conformance-tests/set-arrayunion-with-st.json create mode 100644 dev/conformance/conformance-tests/set-arrayunion.json create mode 100644 dev/conformance/conformance-tests/set-basic.json create mode 100644 dev/conformance/conformance-tests/set-complex.json create mode 100644 dev/conformance/conformance-tests/set-del-merge-alone.json create mode 100644 dev/conformance/conformance-tests/set-del-merge.json create mode 100644 dev/conformance/conformance-tests/set-del-mergeall.json create mode 100644 dev/conformance/conformance-tests/set-del-noarray-nested.json create mode 100644 dev/conformance/conformance-tests/set-del-noarray.json create mode 100644 dev/conformance/conformance-tests/set-del-nomerge.json create mode 100644 dev/conformance/conformance-tests/set-del-nonleaf.json create mode 100644 dev/conformance/conformance-tests/set-del-wo-merge.json create mode 100644 dev/conformance/conformance-tests/set-empty.json create mode 100644 dev/conformance/conformance-tests/set-merge-fp.json create mode 100644 dev/conformance/conformance-tests/set-merge-nested.json create mode 100644 dev/conformance/conformance-tests/set-merge-nonleaf.json create mode 100644 dev/conformance/conformance-tests/set-merge-prefix.json create mode 100644 dev/conformance/conformance-tests/set-merge-present.json create mode 100644 dev/conformance/conformance-tests/set-merge.json create mode 100644 dev/conformance/conformance-tests/set-mergeall-empty.json create mode 100644 dev/conformance/conformance-tests/set-mergeall-nested.json create mode 100644 dev/conformance/conformance-tests/set-mergeall.json create mode 100644 dev/conformance/conformance-tests/set-nodel.json create mode 100644 dev/conformance/conformance-tests/set-nosplit.json create mode 100644 dev/conformance/conformance-tests/set-special-chars.json create mode 100644 dev/conformance/conformance-tests/set-st-alone-mergeall.json create mode 100644 dev/conformance/conformance-tests/set-st-alone.json create mode 100644 dev/conformance/conformance-tests/set-st-merge-both.json create mode 100644 dev/conformance/conformance-tests/set-st-merge-nonleaf-alone.json create mode 100644 dev/conformance/conformance-tests/set-st-merge-nonleaf.json create mode 100644 dev/conformance/conformance-tests/set-st-merge-nowrite.json create mode 100644 dev/conformance/conformance-tests/set-st-mergeall.json create mode 100644 dev/conformance/conformance-tests/set-st-multi.json create mode 100644 dev/conformance/conformance-tests/set-st-nested.json create mode 100644 dev/conformance/conformance-tests/set-st-noarray-nested.json create mode 100644 dev/conformance/conformance-tests/set-st-noarray.json create mode 100644 dev/conformance/conformance-tests/set-st-nomerge.json create mode 100644 dev/conformance/conformance-tests/set-st-with-empty-map.json create mode 100644 dev/conformance/conformance-tests/set-st.json create mode 100644 dev/conformance/conformance-tests/update-all-transforms.json create mode 100644 dev/conformance/conformance-tests/update-arrayremove-alone.json create mode 100644 dev/conformance/conformance-tests/update-arrayremove-multi.json create mode 100644 dev/conformance/conformance-tests/update-arrayremove-nested.json create mode 100644 dev/conformance/conformance-tests/update-arrayremove-noarray-nested.json create mode 100644 dev/conformance/conformance-tests/update-arrayremove-noarray.json create mode 100644 dev/conformance/conformance-tests/update-arrayremove-with-st.json create mode 100644 dev/conformance/conformance-tests/update-arrayremove.json create mode 100644 dev/conformance/conformance-tests/update-arrayunion-alone.json create mode 100644 dev/conformance/conformance-tests/update-arrayunion-multi.json create mode 100644 dev/conformance/conformance-tests/update-arrayunion-nested.json create mode 100644 dev/conformance/conformance-tests/update-arrayunion-noarray-nested.json create mode 100644 dev/conformance/conformance-tests/update-arrayunion-noarray.json create mode 100644 dev/conformance/conformance-tests/update-arrayunion-with-st.json create mode 100644 dev/conformance/conformance-tests/update-arrayunion.json create mode 100644 dev/conformance/conformance-tests/update-badchar.json create mode 100644 dev/conformance/conformance-tests/update-basic.json create mode 100644 dev/conformance/conformance-tests/update-complex.json create mode 100644 dev/conformance/conformance-tests/update-del-alone.json create mode 100644 dev/conformance/conformance-tests/update-del-dot.json create mode 100644 dev/conformance/conformance-tests/update-del-nested.json create mode 100644 dev/conformance/conformance-tests/update-del-noarray-nested.json create mode 100644 dev/conformance/conformance-tests/update-del-noarray.json create mode 100644 dev/conformance/conformance-tests/update-del.json create mode 100644 dev/conformance/conformance-tests/update-exists-precond.json create mode 100644 dev/conformance/conformance-tests/update-fp-empty-component.json create mode 100644 dev/conformance/conformance-tests/update-nested-transform-and-nested-value.json create mode 100644 dev/conformance/conformance-tests/update-no-paths.json create mode 100644 dev/conformance/conformance-tests/update-paths-all-transforms.json create mode 100644 dev/conformance/conformance-tests/update-paths-arrayremove-alone.json create mode 100644 dev/conformance/conformance-tests/update-paths-arrayremove-multi.json create mode 100644 dev/conformance/conformance-tests/update-paths-arrayremove-nested.json create mode 100644 dev/conformance/conformance-tests/update-paths-arrayremove-noarray-nested.json create mode 100644 dev/conformance/conformance-tests/update-paths-arrayremove-noarray.json create mode 100644 dev/conformance/conformance-tests/update-paths-arrayremove-with-st.json create mode 100644 dev/conformance/conformance-tests/update-paths-arrayremove.json create mode 100644 dev/conformance/conformance-tests/update-paths-arrayunion-alone.json create mode 100644 dev/conformance/conformance-tests/update-paths-arrayunion-multi.json create mode 100644 dev/conformance/conformance-tests/update-paths-arrayunion-nested.json create mode 100644 dev/conformance/conformance-tests/update-paths-arrayunion-noarray-nested.json create mode 100644 dev/conformance/conformance-tests/update-paths-arrayunion-noarray.json create mode 100644 dev/conformance/conformance-tests/update-paths-arrayunion-with-st.json create mode 100644 dev/conformance/conformance-tests/update-paths-arrayunion.json create mode 100644 dev/conformance/conformance-tests/update-paths-basic.json create mode 100644 dev/conformance/conformance-tests/update-paths-complex.json create mode 100644 dev/conformance/conformance-tests/update-paths-del-alone.json create mode 100644 dev/conformance/conformance-tests/update-paths-del-nested.json create mode 100644 dev/conformance/conformance-tests/update-paths-del-noarray-nested.json create mode 100644 dev/conformance/conformance-tests/update-paths-del-noarray.json create mode 100644 dev/conformance/conformance-tests/update-paths-del.json create mode 100644 dev/conformance/conformance-tests/update-paths-exists-precond.json create mode 100644 dev/conformance/conformance-tests/update-paths-fp-del.json create mode 100644 dev/conformance/conformance-tests/update-paths-fp-dup-transforms.json create mode 100644 dev/conformance/conformance-tests/update-paths-fp-dup.json create mode 100644 dev/conformance/conformance-tests/update-paths-fp-empty-component.json create mode 100644 dev/conformance/conformance-tests/update-paths-fp-empty.json create mode 100644 dev/conformance/conformance-tests/update-paths-fp-multi.json create mode 100644 dev/conformance/conformance-tests/update-paths-fp-nosplit.json create mode 100644 dev/conformance/conformance-tests/update-paths-nested-transform-and-nested-value.json create mode 100644 dev/conformance/conformance-tests/update-paths-no-paths.json create mode 100644 dev/conformance/conformance-tests/update-paths-prefix-1.json create mode 100644 dev/conformance/conformance-tests/update-paths-prefix-2.json create mode 100644 dev/conformance/conformance-tests/update-paths-prefix-3.json create mode 100644 dev/conformance/conformance-tests/update-paths-special-chars.json create mode 100644 dev/conformance/conformance-tests/update-paths-st-alone.json create mode 100644 dev/conformance/conformance-tests/update-paths-st-multi.json create mode 100644 dev/conformance/conformance-tests/update-paths-st-nested.json create mode 100644 dev/conformance/conformance-tests/update-paths-st-noarray-nested.json create mode 100644 dev/conformance/conformance-tests/update-paths-st-noarray.json create mode 100644 dev/conformance/conformance-tests/update-paths-st-with-empty-map.json create mode 100644 dev/conformance/conformance-tests/update-paths-st.json create mode 100644 dev/conformance/conformance-tests/update-paths-uptime.json create mode 100644 dev/conformance/conformance-tests/update-prefix-1.json create mode 100644 dev/conformance/conformance-tests/update-prefix-2.json create mode 100644 dev/conformance/conformance-tests/update-prefix-3.json create mode 100644 dev/conformance/conformance-tests/update-quoting.json create mode 100644 dev/conformance/conformance-tests/update-split-top-level.json create mode 100644 dev/conformance/conformance-tests/update-split.json create mode 100644 dev/conformance/conformance-tests/update-st-alone.json create mode 100644 dev/conformance/conformance-tests/update-st-dot.json create mode 100644 dev/conformance/conformance-tests/update-st-multi.json create mode 100644 dev/conformance/conformance-tests/update-st-nested.json create mode 100644 dev/conformance/conformance-tests/update-st-noarray-nested.json create mode 100644 dev/conformance/conformance-tests/update-st-noarray.json create mode 100644 dev/conformance/conformance-tests/update-st-with-empty-map.json create mode 100644 dev/conformance/conformance-tests/update-st.json create mode 100644 dev/conformance/conformance-tests/update-uptime.json delete mode 100644 dev/conformance/test-suite.binproto create mode 100644 scripts/init-directories.js diff --git a/dev/conformance/conformance-tests/create-all-transforms.json b/dev/conformance/conformance-tests/create-all-transforms.json new file mode 100644 index 000000000..82831624b --- /dev/null +++ b/dev/conformance/conformance-tests/create-all-transforms.json @@ -0,0 +1,73 @@ +{ + "tests": [ + { + "description": "create: all transforms in a single call", + "comment": "A document can be created with any amount of transforms.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": \"ServerTimestamp\", \"c\": [\"ArrayUnion\", 1, 2, 3], \"d\": [\"ArrayRemove\", 4, 5, 6]}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "currentDocument": { + "exists": false + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-arrayremove-multi.json b/dev/conformance/conformance-tests/create-arrayremove-multi.json new file mode 100644 index 000000000..548a98380 --- /dev/null +++ b/dev/conformance/conformance-tests/create-arrayremove-multi.json @@ -0,0 +1,69 @@ +{ + "tests": [ + { + "description": "create: multiple ArrayRemove fields", + "comment": "A document can have more than one ArrayRemove field.\nSince all the ArrayRemove fields are removed, the only field in the update is \"a\".", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": [\"ArrayRemove\", 1, 2, 3], \"c\": {\"d\": [\"ArrayRemove\", 4, 5, 6]}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "currentDocument": { + "exists": false + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-arrayremove-nested.json b/dev/conformance/conformance-tests/create-arrayremove-nested.json new file mode 100644 index 000000000..fa01bd7e0 --- /dev/null +++ b/dev/conformance/conformance-tests/create-arrayremove-nested.json @@ -0,0 +1,53 @@ +{ + "tests": [ + { + "description": "create: nested ArrayRemove field", + "comment": "An ArrayRemove value can occur at any depth. In this case,\nthe transform applies to the field path \"b.c\". Since \"c\" is removed from the update,\n\"b\" becomes empty, so it is also removed from the update.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": {\"c\": [\"ArrayRemove\", 1, 2, 3]}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "currentDocument": { + "exists": false + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-arrayremove-noarray-nested.json b/dev/conformance/conformance-tests/create-arrayremove-noarray-nested.json new file mode 100644 index 000000000..7d530084d --- /dev/null +++ b/dev/conformance/conformance-tests/create-arrayremove-noarray-nested.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "create: ArrayRemove cannot be anywhere inside an array value", + "comment": "There cannot be an array value anywhere on the path from the document\nroot to the ArrayRemove. Firestore transforms don't support array indexing.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, {\"b\": [\"ArrayRemove\", 1, 2, 3]}]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-arrayremove-noarray.json b/dev/conformance/conformance-tests/create-arrayremove-noarray.json new file mode 100644 index 000000000..99aea7e35 --- /dev/null +++ b/dev/conformance/conformance-tests/create-arrayremove-noarray.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "create: ArrayRemove cannot be in an array value", + "comment": "ArrayRemove must be the value of a field. Firestore\ntransforms don't support array indexing.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, 2, [\"ArrayRemove\", 1, 2, 3]]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-arrayremove-with-st.json b/dev/conformance/conformance-tests/create-arrayremove-with-st.json new file mode 100644 index 000000000..56bdc435d --- /dev/null +++ b/dev/conformance/conformance-tests/create-arrayremove-with-st.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "create: The ServerTimestamp sentinel cannot be in an ArrayUnion", + "comment": "The ServerTimestamp sentinel must be the value of a field. It may\nnot appear in an ArrayUnion.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [\"ArrayRemove\", 1, \"ServerTimestamp\", 3]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-arrayremove.json b/dev/conformance/conformance-tests/create-arrayremove.json new file mode 100644 index 000000000..a69be14b7 --- /dev/null +++ b/dev/conformance/conformance-tests/create-arrayremove.json @@ -0,0 +1,53 @@ +{ + "tests": [ + { + "description": "create: ArrayRemove with data", + "comment": "A key with ArrayRemove is removed from the data in the update \noperation. Instead it appears in a separate Transform operation.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": [\"ArrayRemove\", 1, 2, 3]}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "currentDocument": { + "exists": false + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-arrayunion-multi.json b/dev/conformance/conformance-tests/create-arrayunion-multi.json new file mode 100644 index 000000000..7ca9852f4 --- /dev/null +++ b/dev/conformance/conformance-tests/create-arrayunion-multi.json @@ -0,0 +1,69 @@ +{ + "tests": [ + { + "description": "create: multiple ArrayUnion fields", + "comment": "A document can have more than one ArrayUnion field.\nSince all the ArrayUnion fields are removed, the only field in the update is \"a\".", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": [\"ArrayUnion\", 1, 2, 3], \"c\": {\"d\": [\"ArrayUnion\", 4, 5, 6]}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "currentDocument": { + "exists": false + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "appendMissingElements": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-arrayunion-nested.json b/dev/conformance/conformance-tests/create-arrayunion-nested.json new file mode 100644 index 000000000..a2f20299d --- /dev/null +++ b/dev/conformance/conformance-tests/create-arrayunion-nested.json @@ -0,0 +1,53 @@ +{ + "tests": [ + { + "description": "create: nested ArrayUnion field", + "comment": "An ArrayUnion value can occur at any depth. In this case,\nthe transform applies to the field path \"b.c\". Since \"c\" is removed from the update,\n\"b\" becomes empty, so it is also removed from the update.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": {\"c\": [\"ArrayUnion\", 1, 2, 3]}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "currentDocument": { + "exists": false + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-arrayunion-noarray-nested.json b/dev/conformance/conformance-tests/create-arrayunion-noarray-nested.json new file mode 100644 index 000000000..b9ec5c01c --- /dev/null +++ b/dev/conformance/conformance-tests/create-arrayunion-noarray-nested.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "create: ArrayUnion cannot be anywhere inside an array value", + "comment": "There cannot be an array value anywhere on the path from the document\nroot to the ArrayUnion. Firestore transforms don't support array indexing.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, {\"b\": [\"ArrayUnion\", 1, 2, 3]}]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-arrayunion-noarray.json b/dev/conformance/conformance-tests/create-arrayunion-noarray.json new file mode 100644 index 000000000..1b85a93c4 --- /dev/null +++ b/dev/conformance/conformance-tests/create-arrayunion-noarray.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "create: ArrayUnion cannot be in an array value", + "comment": "ArrayUnion must be the value of a field. Firestore\ntransforms don't support array indexing.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, 2, [\"ArrayRemove\", 1, 2, 3]]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-arrayunion-with-st.json b/dev/conformance/conformance-tests/create-arrayunion-with-st.json new file mode 100644 index 000000000..2847f5749 --- /dev/null +++ b/dev/conformance/conformance-tests/create-arrayunion-with-st.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "create: The ServerTimestamp sentinel cannot be in an ArrayUnion", + "comment": "The ServerTimestamp sentinel must be the value of a field. It may\nnot appear in an ArrayUnion.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [\"ArrayUnion\", 1, \"ServerTimestamp\", 3]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-arrayunion.json b/dev/conformance/conformance-tests/create-arrayunion.json new file mode 100644 index 000000000..26d079946 --- /dev/null +++ b/dev/conformance/conformance-tests/create-arrayunion.json @@ -0,0 +1,53 @@ +{ + "tests": [ + { + "description": "create: ArrayUnion with data", + "comment": "A key with ArrayUnion is removed from the data in the update \noperation. Instead it appears in a separate Transform operation.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": [\"ArrayUnion\", 1, 2, 3]}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "currentDocument": { + "exists": false + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-basic.json b/dev/conformance/conformance-tests/create-basic.json new file mode 100644 index 000000000..d67558ca1 --- /dev/null +++ b/dev/conformance/conformance-tests/create-basic.json @@ -0,0 +1,30 @@ +{ + "tests": [ + { + "description": "create: basic", + "comment": "A simple call, resulting in a single update operation.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "currentDocument": { + "exists": false + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-complex.json b/dev/conformance/conformance-tests/create-complex.json new file mode 100644 index 000000000..a01b307f6 --- /dev/null +++ b/dev/conformance/conformance-tests/create-complex.json @@ -0,0 +1,63 @@ +{ + "tests": [ + { + "description": "create: complex", + "comment": "A call to a write method with complicated input data.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, 2.5], \"b\": {\"c\": [\"three\", {\"d\": true}]}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "arrayValue": { + "values": [ + { + "integerValue": "1" + }, + { + "doubleValue": 2.5 + } + ] + } + }, + "b": { + "mapValue": { + "fields": { + "c": { + "arrayValue": { + "values": [ + { + "stringValue": "three" + }, + { + "mapValue": { + "fields": { + "d": { + "booleanValue": true + } + } + } + } + ] + } + } + } + } + } + } + }, + "currentDocument": { + "exists": false + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-del-noarray-nested.json b/dev/conformance/conformance-tests/create-del-noarray-nested.json new file mode 100644 index 000000000..34d8258e1 --- /dev/null +++ b/dev/conformance/conformance-tests/create-del-noarray-nested.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "create: Delete cannot be anywhere inside an array value", + "comment": "The Delete sentinel must be the value of a field. Deletes are implemented\nby turning the path to the Delete sentinel into a FieldPath, and FieldPaths do not support\narray indexing.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, {\"b\": \"Delete\"}]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-del-noarray.json b/dev/conformance/conformance-tests/create-del-noarray.json new file mode 100644 index 000000000..dde6b334b --- /dev/null +++ b/dev/conformance/conformance-tests/create-del-noarray.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "create: Delete cannot be in an array value", + "comment": "The Delete sentinel must be the value of a field. Deletes are\nimplemented by turning the path to the Delete sentinel into a FieldPath, and FieldPaths\ndo not support array indexing.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, 2, \"Delete\"]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-empty.json b/dev/conformance/conformance-tests/create-empty.json new file mode 100644 index 000000000..7d9f7f009 --- /dev/null +++ b/dev/conformance/conformance-tests/create-empty.json @@ -0,0 +1,25 @@ +{ + "tests": [ + { + "description": "create: creating or setting an empty map", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": {} + }, + "currentDocument": { + "exists": false + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-nodel.json b/dev/conformance/conformance-tests/create-nodel.json new file mode 100644 index 000000000..dd8baaf22 --- /dev/null +++ b/dev/conformance/conformance-tests/create-nodel.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "create: Delete cannot appear in data", + "comment": "The Delete sentinel cannot be used in Create, or in Set without a Merge option.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": \"Delete\"}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-nosplit.json b/dev/conformance/conformance-tests/create-nosplit.json new file mode 100644 index 000000000..8807af362 --- /dev/null +++ b/dev/conformance/conformance-tests/create-nosplit.json @@ -0,0 +1,39 @@ +{ + "tests": [ + { + "description": "create: don’t split on dots", + "comment": "Create and Set treat their map keys literally. They do not split on dots.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{ \"a.b\": { \"c.d\": 1 }, \"e\": 2 }", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a.b": { + "mapValue": { + "fields": { + "c.d": { + "integerValue": "1" + } + } + } + }, + "e": { + "integerValue": "2" + } + } + }, + "currentDocument": { + "exists": false + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-special-chars.json b/dev/conformance/conformance-tests/create-special-chars.json new file mode 100644 index 000000000..408004200 --- /dev/null +++ b/dev/conformance/conformance-tests/create-special-chars.json @@ -0,0 +1,39 @@ +{ + "tests": [ + { + "description": "create: non-alpha characters in map keys", + "comment": "Create and Set treat their map keys literally. They do not escape special characters.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{ \"*\": { \".\": 1 }, \"~\": 2 }", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "*": { + "mapValue": { + "fields": { + ".": { + "integerValue": "1" + } + } + } + }, + "~": { + "integerValue": "2" + } + } + }, + "currentDocument": { + "exists": false + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-st-alone.json b/dev/conformance/conformance-tests/create-st-alone.json new file mode 100644 index 000000000..20c5e8ec3 --- /dev/null +++ b/dev/conformance/conformance-tests/create-st-alone.json @@ -0,0 +1,31 @@ +{ + "tests": [ + { + "description": "create: ServerTimestamp alone", + "comment": "If the only values in the input are ServerTimestamps, then no\nupdate operation should be produced.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": \"ServerTimestamp\"}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] + }, + "currentDocument": { + "exists": false + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-st-multi.json b/dev/conformance/conformance-tests/create-st-multi.json new file mode 100644 index 000000000..89430e2b6 --- /dev/null +++ b/dev/conformance/conformance-tests/create-st-multi.json @@ -0,0 +1,45 @@ +{ + "tests": [ + { + "description": "create: multiple ServerTimestamp fields", + "comment": "A document can have more than one ServerTimestamp field.\nSince all the ServerTimestamp fields are removed, the only field in the update is \"a\".", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": \"ServerTimestamp\", \"c\": {\"d\": \"ServerTimestamp\"}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "currentDocument": { + "exists": false + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c.d", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-st-nested.json b/dev/conformance/conformance-tests/create-st-nested.json new file mode 100644 index 000000000..f2a3a8d1f --- /dev/null +++ b/dev/conformance/conformance-tests/create-st-nested.json @@ -0,0 +1,41 @@ +{ + "tests": [ + { + "description": "create: nested ServerTimestamp field", + "comment": "A ServerTimestamp value can occur at any depth. In this case,\nthe transform applies to the field path \"b.c\". Since \"c\" is removed from the update,\n\"b\" becomes empty, so it is also removed from the update.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": {\"c\": \"ServerTimestamp\"}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "currentDocument": { + "exists": false + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-st-noarray-nested.json b/dev/conformance/conformance-tests/create-st-noarray-nested.json new file mode 100644 index 000000000..8660531dc --- /dev/null +++ b/dev/conformance/conformance-tests/create-st-noarray-nested.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "create: ServerTimestamp cannot be anywhere inside an array value", + "comment": "There cannot be an array value anywhere on the path from the document\nroot to the ServerTimestamp sentinel. Firestore transforms don't support array indexing.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, {\"b\": \"ServerTimestamp\"}]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-st-noarray.json b/dev/conformance/conformance-tests/create-st-noarray.json new file mode 100644 index 000000000..31104f256 --- /dev/null +++ b/dev/conformance/conformance-tests/create-st-noarray.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "create: ServerTimestamp cannot be in an array value", + "comment": "The ServerTimestamp sentinel must be the value of a field. Firestore\ntransforms don't support array indexing.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, 2, \"ServerTimestamp\"]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-st-with-empty-map.json b/dev/conformance/conformance-tests/create-st-with-empty-map.json new file mode 100644 index 000000000..730afd154 --- /dev/null +++ b/dev/conformance/conformance-tests/create-st-with-empty-map.json @@ -0,0 +1,49 @@ +{ + "tests": [ + { + "description": "create: ServerTimestamp beside an empty map", + "comment": "When a ServerTimestamp and a map both reside inside a map, the\nServerTimestamp should be stripped out but the empty map should remain.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": {\"b\": {}, \"c\": \"ServerTimestamp\"}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "mapValue": { + "fields": { + "b": { + "mapValue": { + "fields": {} + } + } + } + } + } + } + }, + "currentDocument": { + "exists": false + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/create-st.json b/dev/conformance/conformance-tests/create-st.json new file mode 100644 index 000000000..705f76ed1 --- /dev/null +++ b/dev/conformance/conformance-tests/create-st.json @@ -0,0 +1,41 @@ +{ + "tests": [ + { + "description": "create: ServerTimestamp with data", + "comment": "A key with the special ServerTimestamp sentinel is removed from\nthe data in the update operation. Instead it appears in a separate Transform operation.\nNote that in these tests, the string \"ServerTimestamp\" should be replaced with the\nspecial ServerTimestamp value.", + "create": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": \"ServerTimestamp\"}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "currentDocument": { + "exists": false + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/delete-exists-precond.json b/dev/conformance/conformance-tests/delete-exists-precond.json new file mode 100644 index 000000000..174be0ecc --- /dev/null +++ b/dev/conformance/conformance-tests/delete-exists-precond.json @@ -0,0 +1,25 @@ +{ + "tests": [ + { + "description": "delete: delete with exists precondition", + "comment": "Delete supports an exists precondition.", + "delete": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "precondition": { + "exists": true + }, + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "delete": "projects/projectID/databases/(default)/documents/C/d", + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/delete-no-precond.json b/dev/conformance/conformance-tests/delete-no-precond.json new file mode 100644 index 000000000..96fcb39a5 --- /dev/null +++ b/dev/conformance/conformance-tests/delete-no-precond.json @@ -0,0 +1,19 @@ +{ + "tests": [ + { + "description": "delete: delete without precondition", + "comment": "An ordinary Delete call.", + "delete": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "delete": "projects/projectID/databases/(default)/documents/C/d" + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/delete-time-precond.json b/dev/conformance/conformance-tests/delete-time-precond.json new file mode 100644 index 000000000..160defb3f --- /dev/null +++ b/dev/conformance/conformance-tests/delete-time-precond.json @@ -0,0 +1,25 @@ +{ + "tests": [ + { + "description": "delete: delete with last-update-time precondition", + "comment": "Delete supports a last-update-time precondition.", + "delete": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "precondition": { + "updateTime": "1970-01-01T00:00:42Z" + }, + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "delete": "projects/projectID/databases/(default)/documents/C/d", + "currentDocument": { + "updateTime": "1970-01-01T00:00:42Z" + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/get-basic.json b/dev/conformance/conformance-tests/get-basic.json new file mode 100644 index 000000000..0a2cd2d4a --- /dev/null +++ b/dev/conformance/conformance-tests/get-basic.json @@ -0,0 +1,14 @@ +{ + "tests": [ + { + "description": "get: get a document", + "comment": "A call to DocumentRef.Get", + "get": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "request": { + "name": "projects/projectID/databases/(default)/documents/C/d" + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/listen-add-mod-del-add.json b/dev/conformance/conformance-tests/listen-add-mod-del-add.json new file mode 100644 index 000000000..d05997332 --- /dev/null +++ b/dev/conformance/conformance-tests/listen-add-mod-del-add.json @@ -0,0 +1,206 @@ +{ + "tests": [ + { + "description": "listen: add a doc, modify it, delete it, then add it again", + "comment": "Various changes to a single document.", + "listen": { + "responses": [ + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "targetChangeType": "CURRENT" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:01Z" + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:02Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:02Z" + } + }, + { + "documentDelete": { + "document": "projects/projectID/databases/(default)/documents/C/d1" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:03Z" + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:03Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:04Z" + } + } + ], + "snapshots": [ + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + } + ], + "changes": [ + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1 + } + ], + "readTime": "1970-01-01T00:00:01Z" + }, + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:02Z" + } + ], + "changes": [ + { + "kind": "MODIFIED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:02Z" + } + } + ], + "readTime": "1970-01-01T00:00:02Z" + }, + { + "changes": [ + { + "kind": "REMOVED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:02Z" + }, + "newIndex": -1 + } + ], + "readTime": "1970-01-01T00:00:03Z" + }, + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:03Z" + } + ], + "changes": [ + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:03Z" + }, + "oldIndex": -1 + } + ], + "readTime": "1970-01-01T00:00:04Z" + } + ] + } + } + ] +} diff --git a/dev/conformance/conformance-tests/listen-add-one.json b/dev/conformance/conformance-tests/listen-add-one.json new file mode 100644 index 000000000..8223180a8 --- /dev/null +++ b/dev/conformance/conformance-tests/listen-add-one.json @@ -0,0 +1,72 @@ +{ + "tests": [ + { + "description": "listen: add a doc", + "comment": "Snapshot with a single document.", + "listen": { + "responses": [ + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "targetChangeType": "CURRENT" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:02Z" + } + } + ], + "snapshots": [ + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + } + ], + "changes": [ + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1 + } + ], + "readTime": "1970-01-01T00:00:02Z" + } + ] + } + } + ] +} diff --git a/dev/conformance/conformance-tests/listen-add-three.json b/dev/conformance/conformance-tests/listen-add-three.json new file mode 100644 index 000000000..6ea117a7c --- /dev/null +++ b/dev/conformance/conformance-tests/listen-add-three.json @@ -0,0 +1,156 @@ +{ + "tests": [ + { + "description": "listen: add three documents", + "comment": "A snapshot with three documents. The documents are sorted\nfirst by the \"a\" field, then by their path. The changes are ordered the same way.", + "listen": { + "responses": [ + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d3", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "targetChangeType": "CURRENT" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:02Z" + } + } + ], + "snapshots": [ + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + { + "name": "projects/projectID/databases/(default)/documents/C/d3", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + } + ], + "changes": [ + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1 + }, + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d3", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1, + "newIndex": 1 + }, + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1, + "newIndex": 2 + } + ], + "readTime": "1970-01-01T00:00:02Z" + } + ] + } + } + ] +} diff --git a/dev/conformance/conformance-tests/listen-doc-remove.json b/dev/conformance/conformance-tests/listen-doc-remove.json new file mode 100644 index 000000000..59af7d11a --- /dev/null +++ b/dev/conformance/conformance-tests/listen-doc-remove.json @@ -0,0 +1,101 @@ +{ + "tests": [ + { + "description": "listen: DocumentRemove behaves like DocumentDelete", + "comment": "The DocumentRemove response behaves exactly like DocumentDelete.", + "listen": { + "responses": [ + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "targetChangeType": "CURRENT" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:01Z" + } + }, + { + "documentRemove": { + "document": "projects/projectID/databases/(default)/documents/C/d1" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:02Z" + } + } + ], + "snapshots": [ + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + } + ], + "changes": [ + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1 + } + ], + "readTime": "1970-01-01T00:00:01Z" + }, + { + "changes": [ + { + "kind": "REMOVED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "newIndex": -1 + } + ], + "readTime": "1970-01-01T00:00:02Z" + } + ] + } + } + ] +} diff --git a/dev/conformance/conformance-tests/listen-empty.json b/dev/conformance/conformance-tests/listen-empty.json new file mode 100644 index 000000000..734aa41f9 --- /dev/null +++ b/dev/conformance/conformance-tests/listen-empty.json @@ -0,0 +1,27 @@ +{ + "tests": [ + { + "description": "listen: no changes; empty snapshot", + "comment": "There are no changes, so the snapshot should be empty.", + "listen": { + "responses": [ + { + "targetChange": { + "targetChangeType": "CURRENT" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:01Z" + } + } + ], + "snapshots": [ + { + "readTime": "1970-01-01T00:00:01Z" + } + ] + } + } + ] +} diff --git a/dev/conformance/conformance-tests/listen-filter-nop.json b/dev/conformance/conformance-tests/listen-filter-nop.json new file mode 100644 index 000000000..a7c09e97d --- /dev/null +++ b/dev/conformance/conformance-tests/listen-filter-nop.json @@ -0,0 +1,203 @@ +{ + "tests": [ + { + "description": "listen: Filter response with same size is a no-op", + "comment": "A Filter response whose count matches the size of the current\nstate (docs in last snapshot + docs added - docs deleted) is a no-op.", + "listen": { + "responses": [ + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "targetChangeType": "CURRENT" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:01Z" + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d3", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "documentDelete": { + "document": "projects/projectID/databases/(default)/documents/C/d1" + } + }, + { + "filter": { + "count": 2 + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:02Z" + } + } + ], + "snapshots": [ + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + } + ], + "changes": [ + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1 + }, + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1, + "newIndex": 1 + } + ], + "readTime": "1970-01-01T00:00:01Z" + }, + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + { + "name": "projects/projectID/databases/(default)/documents/C/d3", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + } + ], + "changes": [ + { + "kind": "REMOVED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": 1, + "newIndex": -1 + }, + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d3", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1, + "newIndex": 1 + } + ], + "readTime": "1970-01-01T00:00:02Z" + } + ] + } + } + ] +} diff --git a/dev/conformance/conformance-tests/listen-multi-docs.json b/dev/conformance/conformance-tests/listen-multi-docs.json new file mode 100644 index 000000000..fe5b0f0bb --- /dev/null +++ b/dev/conformance/conformance-tests/listen-multi-docs.json @@ -0,0 +1,414 @@ +{ + "tests": [ + { + "description": "listen: multiple documents, added, deleted and updated", + "comment": "Changes should be ordered with deletes first, then additions, then mods,\neach in query order.\nOld indices refer to the immediately previous state, not the previous snapshot", + "listen": { + "responses": [ + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d3", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d4", + "fields": { + "a": { + "integerValue": "2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "targetChangeType": "CURRENT" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:02Z" + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d5", + "fields": { + "a": { + "integerValue": "4" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "documentDelete": { + "document": "projects/projectID/databases/(default)/documents/C/d3" + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "-1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:03Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d6", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "documentDelete": { + "document": "projects/projectID/databases/(default)/documents/C/d2" + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d4", + "fields": { + "a": { + "integerValue": "-2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:03Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:04Z" + } + } + ], + "snapshots": [ + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + { + "name": "projects/projectID/databases/(default)/documents/C/d3", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + { + "name": "projects/projectID/databases/(default)/documents/C/d4", + "fields": { + "a": { + "integerValue": "2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + } + ], + "changes": [ + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1 + }, + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d3", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1, + "newIndex": 1 + }, + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d4", + "fields": { + "a": { + "integerValue": "2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1, + "newIndex": 2 + }, + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1, + "newIndex": 3 + } + ], + "readTime": "1970-01-01T00:00:02Z" + }, + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d4", + "fields": { + "a": { + "integerValue": "-2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:03Z" + }, + { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "-1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:03Z" + }, + { + "name": "projects/projectID/databases/(default)/documents/C/d6", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + { + "name": "projects/projectID/databases/(default)/documents/C/d5", + "fields": { + "a": { + "integerValue": "4" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + } + ], + "changes": [ + { + "kind": "REMOVED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "newIndex": -1 + }, + { + "kind": "REMOVED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d3", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "newIndex": -1 + }, + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d6", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1, + "newIndex": 2 + }, + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d5", + "fields": { + "a": { + "integerValue": "4" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1, + "newIndex": 3 + }, + { + "kind": "MODIFIED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d4", + "fields": { + "a": { + "integerValue": "-2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:03Z" + } + }, + { + "kind": "MODIFIED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "-1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:03Z" + }, + "oldIndex": 1, + "newIndex": 1 + } + ], + "readTime": "1970-01-01T00:00:04Z" + } + ] + } + } + ] +} diff --git a/dev/conformance/conformance-tests/listen-nocurrent.json b/dev/conformance/conformance-tests/listen-nocurrent.json new file mode 100644 index 000000000..158595e96 --- /dev/null +++ b/dev/conformance/conformance-tests/listen-nocurrent.json @@ -0,0 +1,119 @@ +{ + "tests": [ + { + "description": "listen: no snapshot if we don't see CURRENT", + "comment": "If the watch state is not marked CURRENT, no snapshot is issued.", + "listen": { + "responses": [ + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:01Z" + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:02Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "targetChangeType": "CURRENT" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:02Z" + } + } + ], + "snapshots": [ + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:02Z" + } + ], + "changes": [ + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1 + }, + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:02Z" + }, + "oldIndex": -1, + "newIndex": 1 + } + ], + "readTime": "1970-01-01T00:00:02Z" + } + ] + } + } + ] +} diff --git a/dev/conformance/conformance-tests/listen-nomod.json b/dev/conformance/conformance-tests/listen-nomod.json new file mode 100644 index 000000000..0e454d512 --- /dev/null +++ b/dev/conformance/conformance-tests/listen-nomod.json @@ -0,0 +1,123 @@ +{ + "tests": [ + { + "description": "listen: add a doc, then change it but without changing its update time", + "comment": "Document updates are recognized by a change in the update time, not the data.\nThis shouldn't actually happen. It is just a test of the update logic.", + "listen": { + "responses": [ + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "targetChangeType": "CURRENT" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:01Z" + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:02Z" + } + }, + { + "documentDelete": { + "document": "projects/projectID/databases/(default)/documents/C/d1" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:03Z" + } + } + ], + "snapshots": [ + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + } + ], + "changes": [ + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1 + } + ], + "readTime": "1970-01-01T00:00:01Z" + }, + { + "changes": [ + { + "kind": "REMOVED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "newIndex": -1 + } + ], + "readTime": "1970-01-01T00:00:03Z" + } + ] + } + } + ] +} diff --git a/dev/conformance/conformance-tests/listen-removed-target-ids.json b/dev/conformance/conformance-tests/listen-removed-target-ids.json new file mode 100644 index 000000000..57c91b7bd --- /dev/null +++ b/dev/conformance/conformance-tests/listen-removed-target-ids.json @@ -0,0 +1,113 @@ +{ + "tests": [ + { + "description": "listen: DocumentChange with removed_target_id is like a delete.", + "comment": "A DocumentChange with the watch target ID in the removed_target_ids field is the\nsame as deleting a document.", + "listen": { + "responses": [ + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "targetChangeType": "CURRENT" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:01Z" + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "removedTargetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:02Z" + } + } + ], + "snapshots": [ + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + } + ], + "changes": [ + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1 + } + ], + "readTime": "1970-01-01T00:00:01Z" + }, + { + "changes": [ + { + "kind": "REMOVED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "newIndex": -1 + } + ], + "readTime": "1970-01-01T00:00:02Z" + } + ] + } + } + ] +} diff --git a/dev/conformance/conformance-tests/listen-reset.json b/dev/conformance/conformance-tests/listen-reset.json new file mode 100644 index 000000000..d988a1ba9 --- /dev/null +++ b/dev/conformance/conformance-tests/listen-reset.json @@ -0,0 +1,309 @@ +{ + "tests": [ + { + "description": "listen: RESET turns off CURRENT", + "comment": "A RESET message turns off the CURRENT state, and marks all documents as deleted.\n\nIf a document appeared on the stream but was never part of a snapshot (\"d3\" in this test), a reset\nwill make it disappear completely.\n\nFor a snapshot to happen at a NO_CHANGE reponse, we need to have both seen a CURRENT response, and\nhave a change from the previous snapshot. Here, after the reset, we see the same version of d2\nagain. That doesn't result in a snapshot.\n", + "listen": { + "responses": [ + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:02Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "targetChangeType": "CURRENT" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:01Z" + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d3", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:02Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "targetChangeType": "RESET" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:02Z" + } + }, + { + "targetChange": { + "targetChangeType": "CURRENT" + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:03Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:03Z" + } + }, + { + "targetChange": { + "targetChangeType": "RESET" + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:03Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "targetChangeType": "CURRENT" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:04Z" + } + }, + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d3", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:02Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:05Z" + } + } + ], + "snapshots": [ + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:02Z" + }, + { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + } + ], + "changes": [ + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "1" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:02Z" + }, + "oldIndex": -1 + }, + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1, + "newIndex": 1 + } + ], + "readTime": "1970-01-01T00:00:01Z" + }, + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:03Z" + } + ], + "changes": [ + { + "kind": "REMOVED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "2" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": 1, + "newIndex": -1 + }, + { + "kind": "MODIFIED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:03Z" + } + } + ], + "readTime": "1970-01-01T00:00:03Z" + }, + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d2", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:03Z" + }, + { + "name": "projects/projectID/databases/(default)/documents/C/d3", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:02Z" + } + ], + "changes": [ + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d3", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:02Z" + }, + "oldIndex": -1, + "newIndex": 1 + } + ], + "readTime": "1970-01-01T00:00:05Z" + } + ] + } + } + ] +} diff --git a/dev/conformance/conformance-tests/listen-target-add-nop.json b/dev/conformance/conformance-tests/listen-target-add-nop.json new file mode 100644 index 000000000..e864ea582 --- /dev/null +++ b/dev/conformance/conformance-tests/listen-target-add-nop.json @@ -0,0 +1,81 @@ +{ + "tests": [ + { + "description": "listen: TargetChange_ADD is a no-op if it has the same target ID", + "comment": "A TargetChange_ADD response must have the same watch target ID.", + "listen": { + "responses": [ + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "targetChangeType": "CURRENT" + } + }, + { + "targetChange": { + "targetChangeType": "ADD", + "targetIds": [ + 1 + ], + "readTime": "1970-01-01T00:00:02Z" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:01Z" + } + } + ], + "snapshots": [ + { + "docs": [ + { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + } + ], + "changes": [ + { + "kind": "ADDED", + "doc": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "oldIndex": -1 + } + ], + "readTime": "1970-01-01T00:00:01Z" + } + ] + } + } + ] +} diff --git a/dev/conformance/conformance-tests/listen-target-add-wrong-id.json b/dev/conformance/conformance-tests/listen-target-add-wrong-id.json new file mode 100644 index 000000000..5bd295d50 --- /dev/null +++ b/dev/conformance/conformance-tests/listen-target-add-wrong-id.json @@ -0,0 +1,49 @@ +{ + "tests": [ + { + "description": "listen: TargetChange_ADD is an error if it has a different target ID", + "comment": "A TargetChange_ADD response must have the same watch target ID.", + "listen": { + "responses": [ + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "targetChangeType": "CURRENT" + } + }, + { + "targetChange": { + "targetChangeType": "ADD", + "targetIds": [ + 2 + ], + "readTime": "1970-01-01T00:00:02Z" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:01Z" + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/listen-target-remove.json b/dev/conformance/conformance-tests/listen-target-remove.json new file mode 100644 index 000000000..2b11e280e --- /dev/null +++ b/dev/conformance/conformance-tests/listen-target-remove.json @@ -0,0 +1,45 @@ +{ + "tests": [ + { + "description": "listen: TargetChange_REMOVE should not appear", + "comment": "A TargetChange_REMOVE response should never be sent.", + "listen": { + "responses": [ + { + "documentChange": { + "document": { + "name": "projects/projectID/databases/(default)/documents/C/d1", + "fields": { + "a": { + "integerValue": "3" + } + }, + "createTime": "1970-01-01T00:00:01Z", + "updateTime": "1970-01-01T00:00:01Z" + }, + "targetIds": [ + 1 + ] + } + }, + { + "targetChange": { + "targetChangeType": "CURRENT" + } + }, + { + "targetChange": { + "targetChangeType": "REMOVE" + } + }, + { + "targetChange": { + "readTime": "1970-01-01T00:00:01Z" + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-arrayremove-cursor.json b/dev/conformance/conformance-tests/query-arrayremove-cursor.json new file mode 100644 index 000000000..9e396b358 --- /dev/null +++ b/dev/conformance/conformance-tests/query-arrayremove-cursor.json @@ -0,0 +1,31 @@ +{ + "tests": [ + { + "description": "query: ArrayRemove in cursor method", + "comment": "ArrayRemove is not permitted in queries.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "a" + ] + }, + "direction": "asc" + } + }, + { + "endBefore": { + "jsonValues": [ + "[\"ArrayRemove\", 1, 2, 3]" + ] + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-arrayremove-where.json b/dev/conformance/conformance-tests/query-arrayremove-where.json new file mode 100644 index 000000000..c488bba85 --- /dev/null +++ b/dev/conformance/conformance-tests/query-arrayremove-where.json @@ -0,0 +1,25 @@ +{ + "tests": [ + { + "description": "query: ArrayRemove in Where", + "comment": "ArrayRemove is not permitted in queries.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "where": { + "path": { + "field": [ + "a" + ] + }, + "op": "==", + "jsonValue": "[\"ArrayRemove\", 1, 2, 3]" + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-arrayunion-cursor.json b/dev/conformance/conformance-tests/query-arrayunion-cursor.json new file mode 100644 index 000000000..8259d31cc --- /dev/null +++ b/dev/conformance/conformance-tests/query-arrayunion-cursor.json @@ -0,0 +1,31 @@ +{ + "tests": [ + { + "description": "query: ArrayUnion in cursor method", + "comment": "ArrayUnion is not permitted in queries.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "a" + ] + }, + "direction": "asc" + } + }, + { + "endBefore": { + "jsonValues": [ + "[\"ArrayUnion\", 1, 2, 3]" + ] + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-arrayunion-where.json b/dev/conformance/conformance-tests/query-arrayunion-where.json new file mode 100644 index 000000000..9f298d84e --- /dev/null +++ b/dev/conformance/conformance-tests/query-arrayunion-where.json @@ -0,0 +1,25 @@ +{ + "tests": [ + { + "description": "query: ArrayUnion in Where", + "comment": "ArrayUnion is not permitted in queries.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "where": { + "path": { + "field": [ + "a" + ] + }, + "op": "==", + "jsonValue": "[\"ArrayUnion\", 1, 2, 3]" + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-bad-NaN.json b/dev/conformance/conformance-tests/query-bad-NaN.json new file mode 100644 index 000000000..47344309f --- /dev/null +++ b/dev/conformance/conformance-tests/query-bad-NaN.json @@ -0,0 +1,25 @@ +{ + "tests": [ + { + "description": "query: where clause with non-== comparison with NaN", + "comment": "You can only compare NaN for equality.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "where": { + "path": { + "field": [ + "a" + ] + }, + "op": "\u003c", + "jsonValue": "\"NaN\"" + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-bad-null.json b/dev/conformance/conformance-tests/query-bad-null.json new file mode 100644 index 000000000..340afb933 --- /dev/null +++ b/dev/conformance/conformance-tests/query-bad-null.json @@ -0,0 +1,25 @@ +{ + "tests": [ + { + "description": "query: where clause with non-== comparison with Null", + "comment": "You can only compare Null for equality.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "where": { + "path": { + "field": [ + "a" + ] + }, + "op": "\u003e", + "jsonValue": "null" + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-cursor-docsnap-order.json b/dev/conformance/conformance-tests/query-cursor-docsnap-order.json new file mode 100644 index 000000000..89d2696dd --- /dev/null +++ b/dev/conformance/conformance-tests/query-cursor-docsnap-order.json @@ -0,0 +1,81 @@ +{ + "tests": [ + { + "description": "query: cursor methods with a document snapshot, existing orderBy", + "comment": "When a document snapshot is used, the client appends a __name__ order-by clause\nwith the direction of the last order-by clause.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "a" + ] + }, + "direction": "asc" + } + }, + { + "orderBy": { + "path": { + "field": [ + "b" + ] + }, + "direction": "desc" + } + }, + { + "startAfter": { + "docSnapshot": { + "path": "projects/projectID/databases/(default)/documents/C/D", + "jsonData": "{\"a\": 7, \"b\": 8}" + } + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "orderBy": [ + { + "field": { + "fieldPath": "a" + }, + "direction": "ASCENDING" + }, + { + "field": { + "fieldPath": "b" + }, + "direction": "DESCENDING" + }, + { + "field": { + "fieldPath": "__name__" + }, + "direction": "DESCENDING" + } + ], + "startAt": { + "values": [ + { + "integerValue": "7" + }, + { + "integerValue": "8" + }, + { + "referenceValue": "projects/projectID/databases/(default)/documents/C/D" + } + ] + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-cursor-docsnap-orderby-name.json b/dev/conformance/conformance-tests/query-cursor-docsnap-orderby-name.json new file mode 100644 index 000000000..189b302a0 --- /dev/null +++ b/dev/conformance/conformance-tests/query-cursor-docsnap-orderby-name.json @@ -0,0 +1,91 @@ +{ + "tests": [ + { + "description": "query: cursor method, doc snapshot, existing orderBy __name__", + "comment": "If there is an existing orderBy clause on __name__,\nno changes are made to the list of orderBy clauses.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "a" + ] + }, + "direction": "desc" + } + }, + { + "orderBy": { + "path": { + "field": [ + "__name__" + ] + }, + "direction": "asc" + } + }, + { + "startAt": { + "docSnapshot": { + "path": "projects/projectID/databases/(default)/documents/C/D", + "jsonData": "{\"a\": 7, \"b\": 8}" + } + } + }, + { + "endAt": { + "docSnapshot": { + "path": "projects/projectID/databases/(default)/documents/C/D", + "jsonData": "{\"a\": 7, \"b\": 8}" + } + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "orderBy": [ + { + "field": { + "fieldPath": "a" + }, + "direction": "DESCENDING" + }, + { + "field": { + "fieldPath": "__name__" + }, + "direction": "ASCENDING" + } + ], + "startAt": { + "values": [ + { + "integerValue": "7" + }, + { + "referenceValue": "projects/projectID/databases/(default)/documents/C/D" + } + ], + "before": true + }, + "endAt": { + "values": [ + { + "integerValue": "7" + }, + { + "referenceValue": "projects/projectID/databases/(default)/documents/C/D" + } + ] + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-cursor-docsnap-where-eq.json b/dev/conformance/conformance-tests/query-cursor-docsnap-where-eq.json new file mode 100644 index 000000000..41bc9bf1c --- /dev/null +++ b/dev/conformance/conformance-tests/query-cursor-docsnap-where-eq.json @@ -0,0 +1,65 @@ +{ + "tests": [ + { + "description": "query: cursor methods with a document snapshot and an equality where clause", + "comment": "A Where clause using equality doesn't change the implicit orderBy clauses.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "where": { + "path": { + "field": [ + "a" + ] + }, + "op": "==", + "jsonValue": "3" + } + }, + { + "endAt": { + "docSnapshot": { + "path": "projects/projectID/databases/(default)/documents/C/D", + "jsonData": "{\"a\": 7, \"b\": 8}" + } + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "where": { + "fieldFilter": { + "field": { + "fieldPath": "a" + }, + "op": "EQUAL", + "value": { + "integerValue": "3" + } + } + }, + "orderBy": [ + { + "field": { + "fieldPath": "__name__" + }, + "direction": "ASCENDING" + } + ], + "endAt": { + "values": [ + { + "referenceValue": "projects/projectID/databases/(default)/documents/C/D" + } + ] + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-cursor-docsnap-where-neq-orderby.json b/dev/conformance/conformance-tests/query-cursor-docsnap-where-neq-orderby.json new file mode 100644 index 000000000..ce99f786d --- /dev/null +++ b/dev/conformance/conformance-tests/query-cursor-docsnap-where-neq-orderby.json @@ -0,0 +1,85 @@ +{ + "tests": [ + { + "description": "query: cursor method, doc snapshot, inequality where clause, and existing orderBy clause", + "comment": "If there is an OrderBy clause, the inequality Where clause does\nnot result in a new OrderBy clause. We still add a __name__ OrderBy clause", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "a" + ] + }, + "direction": "desc" + } + }, + { + "where": { + "path": { + "field": [ + "a" + ] + }, + "op": "\u003c", + "jsonValue": "4" + } + }, + { + "startAt": { + "docSnapshot": { + "path": "projects/projectID/databases/(default)/documents/C/D", + "jsonData": "{\"a\": 7, \"b\": 8}" + } + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "where": { + "fieldFilter": { + "field": { + "fieldPath": "a" + }, + "op": "LESS_THAN", + "value": { + "integerValue": "4" + } + } + }, + "orderBy": [ + { + "field": { + "fieldPath": "a" + }, + "direction": "DESCENDING" + }, + { + "field": { + "fieldPath": "__name__" + }, + "direction": "DESCENDING" + } + ], + "startAt": { + "values": [ + { + "integerValue": "7" + }, + { + "referenceValue": "projects/projectID/databases/(default)/documents/C/D" + } + ], + "before": true + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-cursor-docsnap-where-neq.json b/dev/conformance/conformance-tests/query-cursor-docsnap-where-neq.json new file mode 100644 index 000000000..384bb7c20 --- /dev/null +++ b/dev/conformance/conformance-tests/query-cursor-docsnap-where-neq.json @@ -0,0 +1,75 @@ +{ + "tests": [ + { + "description": "query: cursor method with a document snapshot and an inequality where clause", + "comment": "A Where clause with an inequality results in an OrderBy clause\non that clause's path, if there are no other OrderBy clauses.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "where": { + "path": { + "field": [ + "a" + ] + }, + "op": "\u003c=", + "jsonValue": "3" + } + }, + { + "endBefore": { + "docSnapshot": { + "path": "projects/projectID/databases/(default)/documents/C/D", + "jsonData": "{\"a\": 7, \"b\": 8}" + } + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "where": { + "fieldFilter": { + "field": { + "fieldPath": "a" + }, + "op": "LESS_THAN_OR_EQUAL", + "value": { + "integerValue": "3" + } + } + }, + "orderBy": [ + { + "field": { + "fieldPath": "a" + }, + "direction": "ASCENDING" + }, + { + "field": { + "fieldPath": "__name__" + }, + "direction": "ASCENDING" + } + ], + "endAt": { + "values": [ + { + "integerValue": "7" + }, + { + "referenceValue": "projects/projectID/databases/(default)/documents/C/D" + } + ], + "before": true + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-cursor-docsnap.json b/dev/conformance/conformance-tests/query-cursor-docsnap.json new file mode 100644 index 000000000..ea84c0172 --- /dev/null +++ b/dev/conformance/conformance-tests/query-cursor-docsnap.json @@ -0,0 +1,44 @@ +{ + "tests": [ + { + "description": "query: cursor methods with a document snapshot", + "comment": "When a document snapshot is used, the client appends a __name__ order-by clause.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "startAt": { + "docSnapshot": { + "path": "projects/projectID/databases/(default)/documents/C/D", + "jsonData": "{\"a\": 7, \"b\": 8}" + } + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "orderBy": [ + { + "field": { + "fieldPath": "__name__" + }, + "direction": "ASCENDING" + } + ], + "startAt": { + "values": [ + { + "referenceValue": "projects/projectID/databases/(default)/documents/C/D" + } + ], + "before": true + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-cursor-endbefore-empty-map.json b/dev/conformance/conformance-tests/query-cursor-endbefore-empty-map.json new file mode 100644 index 000000000..3d02cbca2 --- /dev/null +++ b/dev/conformance/conformance-tests/query-cursor-endbefore-empty-map.json @@ -0,0 +1,55 @@ +{ + "tests": [ + { + "description": "query: EndBefore with explicit empty map", + "comment": "Cursor methods are allowed to use empty maps with EndBefore. It should result in an empty map in the query.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "a" + ] + }, + "direction": "asc" + } + }, + { + "endBefore": { + "jsonValues": [ + "{}" + ] + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "orderBy": [ + { + "field": { + "fieldPath": "a" + }, + "direction": "ASCENDING" + } + ], + "endAt": { + "values": [ + { + "mapValue": { + "fields": {} + } + } + ], + "before": true + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-cursor-endbefore-empty.json b/dev/conformance/conformance-tests/query-cursor-endbefore-empty.json new file mode 100644 index 000000000..c491dcd79 --- /dev/null +++ b/dev/conformance/conformance-tests/query-cursor-endbefore-empty.json @@ -0,0 +1,27 @@ +{ + "tests": [ + { + "description": "query: EndBefore with empty values", + "comment": "Cursor methods are not allowed to use empty values with EndBefore. It should result in an error.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "a" + ] + }, + "direction": "asc" + } + }, + { + "endBefore": {} + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-cursor-no-order.json b/dev/conformance/conformance-tests/query-cursor-no-order.json new file mode 100644 index 000000000..45823b228 --- /dev/null +++ b/dev/conformance/conformance-tests/query-cursor-no-order.json @@ -0,0 +1,21 @@ +{ + "tests": [ + { + "description": "query: cursor method without orderBy", + "comment": "If a cursor method with a list of values is provided, there must be at least as many\nexplicit orderBy clauses as values.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "startAt": { + "jsonValues": [ + "2" + ] + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-cursor-startat-empty-map.json b/dev/conformance/conformance-tests/query-cursor-startat-empty-map.json new file mode 100644 index 000000000..788588f76 --- /dev/null +++ b/dev/conformance/conformance-tests/query-cursor-startat-empty-map.json @@ -0,0 +1,55 @@ +{ + "tests": [ + { + "description": "query: StartAt with explicit empty map", + "comment": "Cursor methods are allowed to use empty maps with StartAt. It should result in an empty map in the query.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "a" + ] + }, + "direction": "asc" + } + }, + { + "startAt": { + "jsonValues": [ + "{}" + ] + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "orderBy": [ + { + "field": { + "fieldPath": "a" + }, + "direction": "ASCENDING" + } + ], + "startAt": { + "values": [ + { + "mapValue": { + "fields": {} + } + } + ], + "before": true + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-cursor-startat-empty.json b/dev/conformance/conformance-tests/query-cursor-startat-empty.json new file mode 100644 index 000000000..c0c5a0980 --- /dev/null +++ b/dev/conformance/conformance-tests/query-cursor-startat-empty.json @@ -0,0 +1,27 @@ +{ + "tests": [ + { + "description": "query: StartAt with empty values", + "comment": "Cursor methods are not allowed to use empty values with StartAt. It should result in an error.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "a" + ] + }, + "direction": "asc" + } + }, + { + "startAt": {} + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-cursor-vals-1a.json b/dev/conformance/conformance-tests/query-cursor-vals-1a.json new file mode 100644 index 000000000..038d177f1 --- /dev/null +++ b/dev/conformance/conformance-tests/query-cursor-vals-1a.json @@ -0,0 +1,68 @@ +{ + "tests": [ + { + "description": "query: StartAt/EndBefore with values", + "comment": "Cursor methods take the same number of values as there are OrderBy clauses.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "a" + ] + }, + "direction": "asc" + } + }, + { + "startAt": { + "jsonValues": [ + "7" + ] + } + }, + { + "endBefore": { + "jsonValues": [ + "9" + ] + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "orderBy": [ + { + "field": { + "fieldPath": "a" + }, + "direction": "ASCENDING" + } + ], + "startAt": { + "values": [ + { + "integerValue": "7" + } + ], + "before": true + }, + "endAt": { + "values": [ + { + "integerValue": "9" + } + ], + "before": true + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-cursor-vals-1b.json b/dev/conformance/conformance-tests/query-cursor-vals-1b.json new file mode 100644 index 000000000..089cff93b --- /dev/null +++ b/dev/conformance/conformance-tests/query-cursor-vals-1b.json @@ -0,0 +1,66 @@ +{ + "tests": [ + { + "description": "query: StartAfter/EndAt with values", + "comment": "Cursor methods take the same number of values as there are OrderBy clauses.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "a" + ] + }, + "direction": "asc" + } + }, + { + "startAfter": { + "jsonValues": [ + "7" + ] + } + }, + { + "endAt": { + "jsonValues": [ + "9" + ] + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "orderBy": [ + { + "field": { + "fieldPath": "a" + }, + "direction": "ASCENDING" + } + ], + "startAt": { + "values": [ + { + "integerValue": "7" + } + ] + }, + "endAt": { + "values": [ + { + "integerValue": "9" + } + ] + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-cursor-vals-2.json b/dev/conformance/conformance-tests/query-cursor-vals-2.json new file mode 100644 index 000000000..8554b4360 --- /dev/null +++ b/dev/conformance/conformance-tests/query-cursor-vals-2.json @@ -0,0 +1,91 @@ +{ + "tests": [ + { + "description": "query: Start/End with two values", + "comment": "Cursor methods take the same number of values as there are OrderBy clauses.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "a" + ] + }, + "direction": "asc" + } + }, + { + "orderBy": { + "path": { + "field": [ + "b" + ] + }, + "direction": "desc" + } + }, + { + "startAt": { + "jsonValues": [ + "7", + "8" + ] + } + }, + { + "endAt": { + "jsonValues": [ + "9", + "10" + ] + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "orderBy": [ + { + "field": { + "fieldPath": "a" + }, + "direction": "ASCENDING" + }, + { + "field": { + "fieldPath": "b" + }, + "direction": "DESCENDING" + } + ], + "startAt": { + "values": [ + { + "integerValue": "7" + }, + { + "integerValue": "8" + } + ], + "before": true + }, + "endAt": { + "values": [ + { + "integerValue": "9" + }, + { + "integerValue": "10" + } + ] + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-cursor-vals-docid.json b/dev/conformance/conformance-tests/query-cursor-vals-docid.json new file mode 100644 index 000000000..6492b3f19 --- /dev/null +++ b/dev/conformance/conformance-tests/query-cursor-vals-docid.json @@ -0,0 +1,67 @@ +{ + "tests": [ + { + "description": "query: cursor methods with __name__", + "comment": "Cursor values corresponding to a __name__ field take the document path relative to the\nquery's collection.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "__name__" + ] + }, + "direction": "asc" + } + }, + { + "startAfter": { + "jsonValues": [ + "\"D1\"" + ] + } + }, + { + "endBefore": { + "jsonValues": [ + "\"D2\"" + ] + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "orderBy": [ + { + "field": { + "fieldPath": "__name__" + }, + "direction": "ASCENDING" + } + ], + "startAt": { + "values": [ + { + "referenceValue": "projects/projectID/databases/(default)/documents/C/D1" + } + ] + }, + "endAt": { + "values": [ + { + "referenceValue": "projects/projectID/databases/(default)/documents/C/D2" + } + ], + "before": true + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-cursor-vals-last-wins.json b/dev/conformance/conformance-tests/query-cursor-vals-last-wins.json new file mode 100644 index 000000000..4a46b2f78 --- /dev/null +++ b/dev/conformance/conformance-tests/query-cursor-vals-last-wins.json @@ -0,0 +1,82 @@ +{ + "tests": [ + { + "description": "query: cursor methods, last one wins", + "comment": "When multiple Start* or End* calls occur, the values of the last one are used.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "a" + ] + }, + "direction": "asc" + } + }, + { + "startAfter": { + "jsonValues": [ + "1" + ] + } + }, + { + "startAt": { + "jsonValues": [ + "2" + ] + } + }, + { + "endAt": { + "jsonValues": [ + "3" + ] + } + }, + { + "endBefore": { + "jsonValues": [ + "4" + ] + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "orderBy": [ + { + "field": { + "fieldPath": "a" + }, + "direction": "ASCENDING" + } + ], + "startAt": { + "values": [ + { + "integerValue": "2" + } + ], + "before": true + }, + "endAt": { + "values": [ + { + "integerValue": "4" + } + ], + "before": true + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-del-cursor.json b/dev/conformance/conformance-tests/query-del-cursor.json new file mode 100644 index 000000000..921ace131 --- /dev/null +++ b/dev/conformance/conformance-tests/query-del-cursor.json @@ -0,0 +1,31 @@ +{ + "tests": [ + { + "description": "query: Delete in cursor method", + "comment": "Sentinel values are not permitted in queries.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "a" + ] + }, + "direction": "asc" + } + }, + { + "endBefore": { + "jsonValues": [ + "\"Delete\"" + ] + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-del-where.json b/dev/conformance/conformance-tests/query-del-where.json new file mode 100644 index 000000000..2075e3578 --- /dev/null +++ b/dev/conformance/conformance-tests/query-del-where.json @@ -0,0 +1,25 @@ +{ + "tests": [ + { + "description": "query: Delete in Where", + "comment": "Sentinel values are not permitted in queries.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "where": { + "path": { + "field": [ + "a" + ] + }, + "op": "==", + "jsonValue": "\"Delete\"" + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-invalid-operator.json b/dev/conformance/conformance-tests/query-invalid-operator.json new file mode 100644 index 000000000..064164dc0 --- /dev/null +++ b/dev/conformance/conformance-tests/query-invalid-operator.json @@ -0,0 +1,25 @@ +{ + "tests": [ + { + "description": "query: invalid operator in Where clause", + "comment": "The != operator is not supported.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "where": { + "path": { + "field": [ + "a" + ] + }, + "op": "!=", + "jsonValue": "4" + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-invalid-path-order.json b/dev/conformance/conformance-tests/query-invalid-path-order.json new file mode 100644 index 000000000..d0c5ba654 --- /dev/null +++ b/dev/conformance/conformance-tests/query-invalid-path-order.json @@ -0,0 +1,25 @@ +{ + "tests": [ + { + "description": "query: invalid path in OrderBy clause", + "comment": "The path has an empty component.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "*", + "" + ] + }, + "direction": "asc" + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-invalid-path-select.json b/dev/conformance/conformance-tests/query-invalid-path-select.json new file mode 100644 index 000000000..fa18f7281 --- /dev/null +++ b/dev/conformance/conformance-tests/query-invalid-path-select.json @@ -0,0 +1,26 @@ +{ + "tests": [ + { + "description": "query: invalid path in Where clause", + "comment": "The path has an empty component.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "select": { + "fields": [ + { + "field": [ + "*", + "" + ] + } + ] + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-invalid-path-where.json b/dev/conformance/conformance-tests/query-invalid-path-where.json new file mode 100644 index 000000000..a5b2add33 --- /dev/null +++ b/dev/conformance/conformance-tests/query-invalid-path-where.json @@ -0,0 +1,26 @@ +{ + "tests": [ + { + "description": "query: invalid path in Where clause", + "comment": "The path has an empty component.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "where": { + "path": { + "field": [ + "*", + "" + ] + }, + "op": "==", + "jsonValue": "4" + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-offset-limit-last-wins.json b/dev/conformance/conformance-tests/query-offset-limit-last-wins.json new file mode 100644 index 000000000..878882608 --- /dev/null +++ b/dev/conformance/conformance-tests/query-offset-limit-last-wins.json @@ -0,0 +1,34 @@ +{ + "tests": [ + { + "description": "query: multiple Offset and Limit clauses", + "comment": "With multiple Offset or Limit clauses, the last one wins.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "offset": 2 + }, + { + "limit": 3 + }, + { + "limit": 4 + }, + { + "offset": 5 + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "offset": 5, + "limit": 4 + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-offset-limit.json b/dev/conformance/conformance-tests/query-offset-limit.json new file mode 100644 index 000000000..3429dce0e --- /dev/null +++ b/dev/conformance/conformance-tests/query-offset-limit.json @@ -0,0 +1,28 @@ +{ + "tests": [ + { + "description": "query: Offset and Limit clauses", + "comment": "Offset and Limit clauses.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "offset": 2 + }, + { + "limit": 3 + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "offset": 2, + "limit": 3 + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-order.json b/dev/conformance/conformance-tests/query-order.json new file mode 100644 index 000000000..f6670f060 --- /dev/null +++ b/dev/conformance/conformance-tests/query-order.json @@ -0,0 +1,54 @@ +{ + "tests": [ + { + "description": "query: basic OrderBy clauses", + "comment": "Multiple OrderBy clauses combine.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "b" + ] + }, + "direction": "asc" + } + }, + { + "orderBy": { + "path": { + "field": [ + "a" + ] + }, + "direction": "desc" + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "orderBy": [ + { + "field": { + "fieldPath": "b" + }, + "direction": "ASCENDING" + }, + { + "field": { + "fieldPath": "a" + }, + "direction": "DESCENDING" + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-select-empty.json b/dev/conformance/conformance-tests/query-select-empty.json new file mode 100644 index 000000000..8dda741a6 --- /dev/null +++ b/dev/conformance/conformance-tests/query-select-empty.json @@ -0,0 +1,32 @@ +{ + "tests": [ + { + "description": "query: empty Select clause", + "comment": "An empty Select clause selects just the document ID.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "select": { + "fields": [] + } + } + ], + "query": { + "select": { + "fields": [ + { + "fieldPath": "__name__" + } + ] + }, + "from": [ + { + "collectionId": "C" + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-select-last-wins.json b/dev/conformance/conformance-tests/query-select-last-wins.json new file mode 100644 index 000000000..9df4d13d0 --- /dev/null +++ b/dev/conformance/conformance-tests/query-select-last-wins.json @@ -0,0 +1,54 @@ +{ + "tests": [ + { + "description": "query: two Select clauses", + "comment": "The last Select clause is the only one used.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "select": { + "fields": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + } + ] + } + }, + { + "select": { + "fields": [ + { + "field": [ + "c" + ] + } + ] + } + } + ], + "query": { + "select": { + "fields": [ + { + "fieldPath": "c" + } + ] + }, + "from": [ + { + "collectionId": "C" + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-select.json b/dev/conformance/conformance-tests/query-select.json new file mode 100644 index 000000000..cfaab8f1f --- /dev/null +++ b/dev/conformance/conformance-tests/query-select.json @@ -0,0 +1,46 @@ +{ + "tests": [ + { + "description": "query: Select clause with some fields", + "comment": "An ordinary Select clause.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "select": { + "fields": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + } + ] + } + } + ], + "query": { + "select": { + "fields": [ + { + "fieldPath": "a" + }, + { + "fieldPath": "b" + } + ] + }, + "from": [ + { + "collectionId": "C" + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-st-cursor.json b/dev/conformance/conformance-tests/query-st-cursor.json new file mode 100644 index 000000000..d42416ee1 --- /dev/null +++ b/dev/conformance/conformance-tests/query-st-cursor.json @@ -0,0 +1,31 @@ +{ + "tests": [ + { + "description": "query: ServerTimestamp in cursor method", + "comment": "Sentinel values are not permitted in queries.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "orderBy": { + "path": { + "field": [ + "a" + ] + }, + "direction": "asc" + } + }, + { + "endBefore": { + "jsonValues": [ + "\"ServerTimestamp\"" + ] + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-st-where.json b/dev/conformance/conformance-tests/query-st-where.json new file mode 100644 index 000000000..1584bb9b4 --- /dev/null +++ b/dev/conformance/conformance-tests/query-st-where.json @@ -0,0 +1,25 @@ +{ + "tests": [ + { + "description": "query: ServerTimestamp in Where", + "comment": "Sentinel values are not permitted in queries.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "where": { + "path": { + "field": [ + "a" + ] + }, + "op": "==", + "jsonValue": "\"ServerTimestamp\"" + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-where-2.json b/dev/conformance/conformance-tests/query-where-2.json new file mode 100644 index 000000000..a78beb264 --- /dev/null +++ b/dev/conformance/conformance-tests/query-where-2.json @@ -0,0 +1,71 @@ +{ + "tests": [ + { + "description": "query: two Where clauses", + "comment": "Multiple Where clauses are combined into a composite filter.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "where": { + "path": { + "field": [ + "a" + ] + }, + "op": "\u003e=", + "jsonValue": "5" + } + }, + { + "where": { + "path": { + "field": [ + "b" + ] + }, + "op": "\u003c", + "jsonValue": "\"foo\"" + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "where": { + "compositeFilter": { + "op": "AND", + "filters": [ + { + "fieldFilter": { + "field": { + "fieldPath": "a" + }, + "op": "GREATER_THAN_OR_EQUAL", + "value": { + "integerValue": "5" + } + } + }, + { + "fieldFilter": { + "field": { + "fieldPath": "b" + }, + "op": "LESS_THAN", + "value": { + "stringValue": "foo" + } + } + } + ] + } + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-where-NaN.json b/dev/conformance/conformance-tests/query-where-NaN.json new file mode 100644 index 000000000..c091fe5c0 --- /dev/null +++ b/dev/conformance/conformance-tests/query-where-NaN.json @@ -0,0 +1,39 @@ +{ + "tests": [ + { + "description": "query: a Where clause comparing to NaN", + "comment": "A Where clause that tests for equality with NaN results in a unary filter.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "where": { + "path": { + "field": [ + "a" + ] + }, + "op": "==", + "jsonValue": "\"NaN\"" + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "where": { + "unaryFilter": { + "op": "IS_NAN", + "field": { + "fieldPath": "a" + } + } + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-where-null.json b/dev/conformance/conformance-tests/query-where-null.json new file mode 100644 index 000000000..6862dd97f --- /dev/null +++ b/dev/conformance/conformance-tests/query-where-null.json @@ -0,0 +1,39 @@ +{ + "tests": [ + { + "description": "query: a Where clause comparing to null", + "comment": "A Where clause that tests for equality with null results in a unary filter.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "where": { + "path": { + "field": [ + "a" + ] + }, + "op": "==", + "jsonValue": "null" + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "where": { + "unaryFilter": { + "op": "IS_NULL", + "field": { + "fieldPath": "a" + } + } + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-where.json b/dev/conformance/conformance-tests/query-where.json new file mode 100644 index 000000000..b132c3030 --- /dev/null +++ b/dev/conformance/conformance-tests/query-where.json @@ -0,0 +1,42 @@ +{ + "tests": [ + { + "description": "query: Where clause", + "comment": "A simple Where clause.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "where": { + "path": { + "field": [ + "a" + ] + }, + "op": "\u003e", + "jsonValue": "5" + } + } + ], + "query": { + "from": [ + { + "collectionId": "C" + } + ], + "where": { + "fieldFilter": { + "field": { + "fieldPath": "a" + }, + "op": "GREATER_THAN", + "value": { + "integerValue": "5" + } + } + } + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/query-wrong-collection.json b/dev/conformance/conformance-tests/query-wrong-collection.json new file mode 100644 index 000000000..6a677f53d --- /dev/null +++ b/dev/conformance/conformance-tests/query-wrong-collection.json @@ -0,0 +1,22 @@ +{ + "tests": [ + { + "description": "query: doc snapshot with wrong collection in cursor method", + "comment": "If a document snapshot is passed to a Start*/End* method, it must be in the\nsame collection as the query.", + "query": { + "collPath": "projects/projectID/databases/(default)/documents/C", + "clauses": [ + { + "endBefore": { + "docSnapshot": { + "path": "projects/projectID/databases/(default)/documents/C2/D", + "jsonData": "{\"a\": 7, \"b\": 8}" + } + } + } + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-all-transforms.json b/dev/conformance/conformance-tests/set-all-transforms.json new file mode 100644 index 000000000..5c8b1373d --- /dev/null +++ b/dev/conformance/conformance-tests/set-all-transforms.json @@ -0,0 +1,70 @@ +{ + "tests": [ + { + "description": "set: all transforms in a single call", + "comment": "A document can be created with any amount of transforms.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": \"ServerTimestamp\", \"c\": [\"ArrayUnion\", 1, 2, 3], \"d\": [\"ArrayRemove\", 4, 5, 6]}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-arrayremove-multi.json b/dev/conformance/conformance-tests/set-arrayremove-multi.json new file mode 100644 index 000000000..3ea9b0dbd --- /dev/null +++ b/dev/conformance/conformance-tests/set-arrayremove-multi.json @@ -0,0 +1,66 @@ +{ + "tests": [ + { + "description": "set: multiple ArrayRemove fields", + "comment": "A document can have more than one ArrayRemove field.\nSince all the ArrayRemove fields are removed, the only field in the update is \"a\".", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": [\"ArrayRemove\", 1, 2, 3], \"c\": {\"d\": [\"ArrayRemove\", 4, 5, 6]}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-arrayremove-nested.json b/dev/conformance/conformance-tests/set-arrayremove-nested.json new file mode 100644 index 000000000..4db133f2c --- /dev/null +++ b/dev/conformance/conformance-tests/set-arrayremove-nested.json @@ -0,0 +1,50 @@ +{ + "tests": [ + { + "description": "set: nested ArrayRemove field", + "comment": "An ArrayRemove value can occur at any depth. In this case,\nthe transform applies to the field path \"b.c\". Since \"c\" is removed from the update,\n\"b\" becomes empty, so it is also removed from the update.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": {\"c\": [\"ArrayRemove\", 1, 2, 3]}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-arrayremove-noarray-nested.json b/dev/conformance/conformance-tests/set-arrayremove-noarray-nested.json new file mode 100644 index 000000000..96965faa6 --- /dev/null +++ b/dev/conformance/conformance-tests/set-arrayremove-noarray-nested.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "set: ArrayRemove cannot be anywhere inside an array value", + "comment": "There cannot be an array value anywhere on the path from the document\nroot to the ArrayRemove. Firestore transforms don't support array indexing.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, {\"b\": [\"ArrayRemove\", 1, 2, 3]}]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-arrayremove-noarray.json b/dev/conformance/conformance-tests/set-arrayremove-noarray.json new file mode 100644 index 000000000..cd0e04468 --- /dev/null +++ b/dev/conformance/conformance-tests/set-arrayremove-noarray.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "set: ArrayRemove cannot be in an array value", + "comment": "ArrayRemove must be the value of a field. Firestore\ntransforms don't support array indexing.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, 2, [\"ArrayRemove\", 1, 2, 3]]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-arrayremove-with-st.json b/dev/conformance/conformance-tests/set-arrayremove-with-st.json new file mode 100644 index 000000000..146e41fdf --- /dev/null +++ b/dev/conformance/conformance-tests/set-arrayremove-with-st.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "set: The ServerTimestamp sentinel cannot be in an ArrayUnion", + "comment": "The ServerTimestamp sentinel must be the value of a field. It may\nnot appear in an ArrayUnion.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [\"ArrayRemove\", 1, \"ServerTimestamp\", 3]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-arrayremove.json b/dev/conformance/conformance-tests/set-arrayremove.json new file mode 100644 index 000000000..18969ef80 --- /dev/null +++ b/dev/conformance/conformance-tests/set-arrayremove.json @@ -0,0 +1,50 @@ +{ + "tests": [ + { + "description": "set: ArrayRemove with data", + "comment": "A key with ArrayRemove is removed from the data in the update \noperation. Instead it appears in a separate Transform operation.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": [\"ArrayRemove\", 1, 2, 3]}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-arrayunion-multi.json b/dev/conformance/conformance-tests/set-arrayunion-multi.json new file mode 100644 index 000000000..3d076397c --- /dev/null +++ b/dev/conformance/conformance-tests/set-arrayunion-multi.json @@ -0,0 +1,66 @@ +{ + "tests": [ + { + "description": "set: multiple ArrayUnion fields", + "comment": "A document can have more than one ArrayUnion field.\nSince all the ArrayUnion fields are removed, the only field in the update is \"a\".", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": [\"ArrayUnion\", 1, 2, 3], \"c\": {\"d\": [\"ArrayUnion\", 4, 5, 6]}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "appendMissingElements": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-arrayunion-nested.json b/dev/conformance/conformance-tests/set-arrayunion-nested.json new file mode 100644 index 000000000..e265f6c61 --- /dev/null +++ b/dev/conformance/conformance-tests/set-arrayunion-nested.json @@ -0,0 +1,50 @@ +{ + "tests": [ + { + "description": "set: nested ArrayUnion field", + "comment": "An ArrayUnion value can occur at any depth. In this case,\nthe transform applies to the field path \"b.c\". Since \"c\" is removed from the update,\n\"b\" becomes empty, so it is also removed from the update.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": {\"c\": [\"ArrayUnion\", 1, 2, 3]}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-arrayunion-noarray-nested.json b/dev/conformance/conformance-tests/set-arrayunion-noarray-nested.json new file mode 100644 index 000000000..c9b1385e0 --- /dev/null +++ b/dev/conformance/conformance-tests/set-arrayunion-noarray-nested.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "set: ArrayUnion cannot be anywhere inside an array value", + "comment": "There cannot be an array value anywhere on the path from the document\nroot to the ArrayUnion. Firestore transforms don't support array indexing.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, {\"b\": [\"ArrayUnion\", 1, 2, 3]}]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-arrayunion-noarray.json b/dev/conformance/conformance-tests/set-arrayunion-noarray.json new file mode 100644 index 000000000..4379578bd --- /dev/null +++ b/dev/conformance/conformance-tests/set-arrayunion-noarray.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "set: ArrayUnion cannot be in an array value", + "comment": "ArrayUnion must be the value of a field. Firestore\ntransforms don't support array indexing.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, 2, [\"ArrayRemove\", 1, 2, 3]]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-arrayunion-with-st.json b/dev/conformance/conformance-tests/set-arrayunion-with-st.json new file mode 100644 index 000000000..d65436af2 --- /dev/null +++ b/dev/conformance/conformance-tests/set-arrayunion-with-st.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "set: The ServerTimestamp sentinel cannot be in an ArrayUnion", + "comment": "The ServerTimestamp sentinel must be the value of a field. It may\nnot appear in an ArrayUnion.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [\"ArrayUnion\", 1, \"ServerTimestamp\", 3]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-arrayunion.json b/dev/conformance/conformance-tests/set-arrayunion.json new file mode 100644 index 000000000..856e07517 --- /dev/null +++ b/dev/conformance/conformance-tests/set-arrayunion.json @@ -0,0 +1,50 @@ +{ + "tests": [ + { + "description": "set: ArrayUnion with data", + "comment": "A key with ArrayUnion is removed from the data in the update \noperation. Instead it appears in a separate Transform operation.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": [\"ArrayUnion\", 1, 2, 3]}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-basic.json b/dev/conformance/conformance-tests/set-basic.json new file mode 100644 index 000000000..f32250912 --- /dev/null +++ b/dev/conformance/conformance-tests/set-basic.json @@ -0,0 +1,27 @@ +{ + "tests": [ + { + "description": "set: basic", + "comment": "A simple call, resulting in a single update operation.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-complex.json b/dev/conformance/conformance-tests/set-complex.json new file mode 100644 index 000000000..aa871ddae --- /dev/null +++ b/dev/conformance/conformance-tests/set-complex.json @@ -0,0 +1,60 @@ +{ + "tests": [ + { + "description": "set: complex", + "comment": "A call to a write method with complicated input data.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, 2.5], \"b\": {\"c\": [\"three\", {\"d\": true}]}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "arrayValue": { + "values": [ + { + "integerValue": "1" + }, + { + "doubleValue": 2.5 + } + ] + } + }, + "b": { + "mapValue": { + "fields": { + "c": { + "arrayValue": { + "values": [ + { + "stringValue": "three" + }, + { + "mapValue": { + "fields": { + "d": { + "booleanValue": true + } + } + } + } + ] + } + } + } + } + } + } + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-del-merge-alone.json b/dev/conformance/conformance-tests/set-del-merge-alone.json new file mode 100644 index 000000000..7a8ba5d54 --- /dev/null +++ b/dev/conformance/conformance-tests/set-del-merge-alone.json @@ -0,0 +1,37 @@ +{ + "tests": [ + { + "description": "set-merge: Delete with merge", + "comment": "A Delete sentinel can appear with a merge option. If the delete\npaths are the only ones to be merged, then no document is sent, just an update mask.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "fields": [ + { + "field": [ + "b", + "c" + ] + } + ] + }, + "jsonData": "{\"a\": 1, \"b\": {\"c\": \"Delete\"}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [ + "b.c" + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-del-merge.json b/dev/conformance/conformance-tests/set-del-merge.json new file mode 100644 index 000000000..6a5759c12 --- /dev/null +++ b/dev/conformance/conformance-tests/set-del-merge.json @@ -0,0 +1,48 @@ +{ + "tests": [ + { + "description": "set-merge: Delete with merge", + "comment": "A Delete sentinel can appear with a merge option.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "fields": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b", + "c" + ] + } + ] + }, + "jsonData": "{\"a\": 1, \"b\": {\"c\": \"Delete\"}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "b.c" + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-del-mergeall.json b/dev/conformance/conformance-tests/set-del-mergeall.json new file mode 100644 index 000000000..6106a3e4f --- /dev/null +++ b/dev/conformance/conformance-tests/set-del-mergeall.json @@ -0,0 +1,36 @@ +{ + "tests": [ + { + "description": "set: Delete with MergeAll", + "comment": "A Delete sentinel can appear with a mergeAll option.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "all": true + }, + "jsonData": "{\"a\": 1, \"b\": {\"c\": \"Delete\"}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "b.c" + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-del-noarray-nested.json b/dev/conformance/conformance-tests/set-del-noarray-nested.json new file mode 100644 index 000000000..5a2303284 --- /dev/null +++ b/dev/conformance/conformance-tests/set-del-noarray-nested.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "set: Delete cannot be anywhere inside an array value", + "comment": "The Delete sentinel must be the value of a field. Deletes are implemented\nby turning the path to the Delete sentinel into a FieldPath, and FieldPaths do not support\narray indexing.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, {\"b\": \"Delete\"}]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-del-noarray.json b/dev/conformance/conformance-tests/set-del-noarray.json new file mode 100644 index 000000000..dee9c75f6 --- /dev/null +++ b/dev/conformance/conformance-tests/set-del-noarray.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "set: Delete cannot be in an array value", + "comment": "The Delete sentinel must be the value of a field. Deletes are\nimplemented by turning the path to the Delete sentinel into a FieldPath, and FieldPaths\ndo not support array indexing.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, 2, \"Delete\"]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-del-nomerge.json b/dev/conformance/conformance-tests/set-del-nomerge.json new file mode 100644 index 000000000..67e3b74b8 --- /dev/null +++ b/dev/conformance/conformance-tests/set-del-nomerge.json @@ -0,0 +1,22 @@ +{ + "tests": [ + { + "description": "set-merge: Delete cannot appear in an unmerged field", + "comment": "The client signals an error if the Delete sentinel is in the\ninput data, but not selected by a merge option, because this is most likely a programming\nbug.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "fields": [ + { + "field": [ + "a" + ] + } + ] + }, + "jsonData": "{\"a\": 1, \"b\": \"Delete\"}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-del-nonleaf.json b/dev/conformance/conformance-tests/set-del-nonleaf.json new file mode 100644 index 000000000..67c864957 --- /dev/null +++ b/dev/conformance/conformance-tests/set-del-nonleaf.json @@ -0,0 +1,22 @@ +{ + "tests": [ + { + "description": "set-merge: Delete cannot appear as part of a merge path", + "comment": "If a Delete is part of the value at a merge path, then the user is\nconfused: their merge path says \"replace this entire value\" but their Delete says\n\"delete this part of the value\". This should be an error, just as if they specified Delete\nin a Set with no merge.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "fields": [ + { + "field": [ + "h" + ] + } + ] + }, + "jsonData": "{\"h\": {\"g\": \"Delete\"}}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-del-wo-merge.json b/dev/conformance/conformance-tests/set-del-wo-merge.json new file mode 100644 index 000000000..32d860a62 --- /dev/null +++ b/dev/conformance/conformance-tests/set-del-wo-merge.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "set: Delete cannot appear unless a merge option is specified", + "comment": "Without a merge option, Set replaces the document with the input\ndata. A Delete sentinel in the data makes no sense in this case.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": \"Delete\"}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-empty.json b/dev/conformance/conformance-tests/set-empty.json new file mode 100644 index 000000000..924992caf --- /dev/null +++ b/dev/conformance/conformance-tests/set-empty.json @@ -0,0 +1,22 @@ +{ + "tests": [ + { + "description": "set: creating or setting an empty map", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": {} + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-merge-fp.json b/dev/conformance/conformance-tests/set-merge-fp.json new file mode 100644 index 000000000..8a5b0faa6 --- /dev/null +++ b/dev/conformance/conformance-tests/set-merge-fp.json @@ -0,0 +1,48 @@ +{ + "tests": [ + { + "description": "set-merge: Merge with FieldPaths", + "comment": "A merge with fields that use special characters.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "fields": [ + { + "field": [ + "*", + "~" + ] + } + ] + }, + "jsonData": "{\"*\": {\"~\": true}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "*": { + "mapValue": { + "fields": { + "~": { + "booleanValue": true + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "`*`.`~`" + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-merge-nested.json b/dev/conformance/conformance-tests/set-merge-nested.json new file mode 100644 index 000000000..8ebec8fda --- /dev/null +++ b/dev/conformance/conformance-tests/set-merge-nested.json @@ -0,0 +1,48 @@ +{ + "tests": [ + { + "description": "set-merge: Merge with a nested field", + "comment": "A merge option where the field is not at top level.\nOnly fields mentioned in the option are present in the update operation.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "fields": [ + { + "field": [ + "h", + "g" + ] + } + ] + }, + "jsonData": "{\"h\": {\"g\": 4, \"f\": 5}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "h": { + "mapValue": { + "fields": { + "g": { + "integerValue": "4" + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "h.g" + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-merge-nonleaf.json b/dev/conformance/conformance-tests/set-merge-nonleaf.json new file mode 100644 index 000000000..d115e12c2 --- /dev/null +++ b/dev/conformance/conformance-tests/set-merge-nonleaf.json @@ -0,0 +1,50 @@ +{ + "tests": [ + { + "description": "set-merge: Merge field is not a leaf", + "comment": "If a field path is in a merge option, the value at that path\nreplaces the stored value. That is true even if the value is complex.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "fields": [ + { + "field": [ + "h" + ] + } + ] + }, + "jsonData": "{\"h\": {\"f\": 5, \"g\": 6}, \"e\": 7}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "h": { + "mapValue": { + "fields": { + "f": { + "integerValue": "5" + }, + "g": { + "integerValue": "6" + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "h" + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-merge-prefix.json b/dev/conformance/conformance-tests/set-merge-prefix.json new file mode 100644 index 000000000..a09e4db50 --- /dev/null +++ b/dev/conformance/conformance-tests/set-merge-prefix.json @@ -0,0 +1,28 @@ +{ + "tests": [ + { + "description": "set-merge: One merge path cannot be the prefix of another", + "comment": "The prefix would make the other path meaningless, so this is\nprobably a programming error.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "fields": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "a", + "b" + ] + } + ] + }, + "jsonData": "{\"a\": {\"b\": 1}}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-merge-present.json b/dev/conformance/conformance-tests/set-merge-present.json new file mode 100644 index 000000000..b501b23d0 --- /dev/null +++ b/dev/conformance/conformance-tests/set-merge-present.json @@ -0,0 +1,27 @@ +{ + "tests": [ + { + "description": "set-merge: Merge fields must all be present in data", + "comment": "The client signals an error if a merge option mentions a path\nthat is not in the input data.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "fields": [ + { + "field": [ + "b" + ] + }, + { + "field": [ + "a" + ] + } + ] + }, + "jsonData": "{\"a\": 1}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-merge.json b/dev/conformance/conformance-tests/set-merge.json new file mode 100644 index 000000000..8ce730e84 --- /dev/null +++ b/dev/conformance/conformance-tests/set-merge.json @@ -0,0 +1,41 @@ +{ + "tests": [ + { + "description": "set-merge: Merge with a field", + "comment": "Fields in the input data but not in a merge option are pruned.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "fields": [ + { + "field": [ + "a" + ] + } + ] + }, + "jsonData": "{\"a\": 1, \"b\": 2}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-mergeall-empty.json b/dev/conformance/conformance-tests/set-mergeall-empty.json new file mode 100644 index 000000000..e541ad8c9 --- /dev/null +++ b/dev/conformance/conformance-tests/set-mergeall-empty.json @@ -0,0 +1,29 @@ +{ + "tests": [ + { + "description": "set: MergeAll can be specified with empty data.", + "comment": "This is a valid call that can be used to ensure a document exists.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "all": true + }, + "jsonData": "{}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": {} + }, + "updateMask": { + "fieldPaths": [] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-mergeall-nested.json b/dev/conformance/conformance-tests/set-mergeall-nested.json new file mode 100644 index 000000000..c70ec691e --- /dev/null +++ b/dev/conformance/conformance-tests/set-mergeall-nested.json @@ -0,0 +1,45 @@ +{ + "tests": [ + { + "description": "set: MergeAll with nested fields", + "comment": "MergeAll with nested fields results in an update mask that\nincludes entries for all the leaf fields.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "all": true + }, + "jsonData": "{\"h\": { \"g\": 3, \"f\": 4 }}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "h": { + "mapValue": { + "fields": { + "f": { + "integerValue": "4" + }, + "g": { + "integerValue": "3" + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "h.f", + "h.g" + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-mergeall.json b/dev/conformance/conformance-tests/set-mergeall.json new file mode 100644 index 000000000..55a2377cb --- /dev/null +++ b/dev/conformance/conformance-tests/set-mergeall.json @@ -0,0 +1,39 @@ +{ + "tests": [ + { + "description": "set: MergeAll", + "comment": "The MergeAll option with a simple piece of data.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "all": true + }, + "jsonData": "{\"a\": 1, \"b\": 2}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + }, + "b": { + "integerValue": "2" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "b" + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-nodel.json b/dev/conformance/conformance-tests/set-nodel.json new file mode 100644 index 000000000..5580bc04f --- /dev/null +++ b/dev/conformance/conformance-tests/set-nodel.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "set: Delete cannot appear in data", + "comment": "The Delete sentinel cannot be used in Create, or in Set without a Merge option.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": \"Delete\"}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-nosplit.json b/dev/conformance/conformance-tests/set-nosplit.json new file mode 100644 index 000000000..3866027b9 --- /dev/null +++ b/dev/conformance/conformance-tests/set-nosplit.json @@ -0,0 +1,36 @@ +{ + "tests": [ + { + "description": "set: don’t split on dots", + "comment": "Create and Set treat their map keys literally. They do not split on dots.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{ \"a.b\": { \"c.d\": 1 }, \"e\": 2 }", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a.b": { + "mapValue": { + "fields": { + "c.d": { + "integerValue": "1" + } + } + } + }, + "e": { + "integerValue": "2" + } + } + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-special-chars.json b/dev/conformance/conformance-tests/set-special-chars.json new file mode 100644 index 000000000..865ffcd9d --- /dev/null +++ b/dev/conformance/conformance-tests/set-special-chars.json @@ -0,0 +1,36 @@ +{ + "tests": [ + { + "description": "set: non-alpha characters in map keys", + "comment": "Create and Set treat their map keys literally. They do not escape special characters.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{ \"*\": { \".\": 1 }, \"~\": 2 }", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "*": { + "mapValue": { + "fields": { + ".": { + "integerValue": "1" + } + } + } + }, + "~": { + "integerValue": "2" + } + } + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-st-alone-mergeall.json b/dev/conformance/conformance-tests/set-st-alone-mergeall.json new file mode 100644 index 000000000..d95bf0973 --- /dev/null +++ b/dev/conformance/conformance-tests/set-st-alone-mergeall.json @@ -0,0 +1,31 @@ +{ + "tests": [ + { + "description": "set: ServerTimestamp alone with MergeAll", + "comment": "If the only values in the input are ServerTimestamps, then no\nupdate operation should be produced.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "all": true + }, + "jsonData": "{\"a\": \"ServerTimestamp\"}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-st-alone.json b/dev/conformance/conformance-tests/set-st-alone.json new file mode 100644 index 000000000..3fe931394 --- /dev/null +++ b/dev/conformance/conformance-tests/set-st-alone.json @@ -0,0 +1,34 @@ +{ + "tests": [ + { + "description": "set: ServerTimestamp alone", + "comment": "If the only values in the input are ServerTimestamps, then\nan update operation with an empty map should be produced.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": \"ServerTimestamp\"}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": {} + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-st-merge-both.json b/dev/conformance/conformance-tests/set-st-merge-both.json new file mode 100644 index 000000000..a39ada55f --- /dev/null +++ b/dev/conformance/conformance-tests/set-st-merge-both.json @@ -0,0 +1,57 @@ +{ + "tests": [ + { + "description": "set-merge: ServerTimestamp with Merge of both fields", + "comment": "Just as when no merge option is specified, ServerTimestamp\nsentinel values are removed from the data in the update operation and become\ntransforms.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "fields": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + } + ] + }, + "jsonData": "{\"a\": 1, \"b\": \"ServerTimestamp\"}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-st-merge-nonleaf-alone.json b/dev/conformance/conformance-tests/set-st-merge-nonleaf-alone.json new file mode 100644 index 000000000..4193b00ea --- /dev/null +++ b/dev/conformance/conformance-tests/set-st-merge-nonleaf-alone.json @@ -0,0 +1,47 @@ +{ + "tests": [ + { + "description": "set-merge: non-leaf merge field with ServerTimestamp alone", + "comment": "If a field path is in a merge option, the value at that path\nreplaces the stored value. If the value has only ServerTimestamps, they become transforms\nand we clear the value by including the field path in the update mask.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "fields": [ + { + "field": [ + "h" + ] + } + ] + }, + "jsonData": "{\"h\": {\"g\": \"ServerTimestamp\"}, \"e\": 7}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [ + "h" + ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "h.g", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-st-merge-nonleaf.json b/dev/conformance/conformance-tests/set-st-merge-nonleaf.json new file mode 100644 index 000000000..5e91d663b --- /dev/null +++ b/dev/conformance/conformance-tests/set-st-merge-nonleaf.json @@ -0,0 +1,58 @@ +{ + "tests": [ + { + "description": "set-merge: non-leaf merge field with ServerTimestamp", + "comment": "If a field path is in a merge option, the value at that path\nreplaces the stored value, and ServerTimestamps inside that value become transforms\nas usual.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "fields": [ + { + "field": [ + "h" + ] + } + ] + }, + "jsonData": "{\"h\": {\"f\": 5, \"g\": \"ServerTimestamp\"}, \"e\": 7}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "h": { + "mapValue": { + "fields": { + "f": { + "integerValue": "5" + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "h" + ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "h.g", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-st-merge-nowrite.json b/dev/conformance/conformance-tests/set-st-merge-nowrite.json new file mode 100644 index 000000000..08fa8b52f --- /dev/null +++ b/dev/conformance/conformance-tests/set-st-merge-nowrite.json @@ -0,0 +1,37 @@ +{ + "tests": [ + { + "description": "set-merge: If no ordinary values in Merge, no write", + "comment": "If all the fields in the merge option have ServerTimestamp\nvalues, then no update operation is produced, only a transform.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "fields": [ + { + "field": [ + "b" + ] + } + ] + }, + "jsonData": "{\"a\": 1, \"b\": \"ServerTimestamp\"}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-st-mergeall.json b/dev/conformance/conformance-tests/set-st-mergeall.json new file mode 100644 index 000000000..26883c038 --- /dev/null +++ b/dev/conformance/conformance-tests/set-st-mergeall.json @@ -0,0 +1,46 @@ +{ + "tests": [ + { + "description": "set: ServerTimestamp with MergeAll", + "comment": "Just as when no merge option is specified, ServerTimestamp\nsentinel values are removed from the data in the update operation and become\ntransforms.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "all": true + }, + "jsonData": "{\"a\": 1, \"b\": \"ServerTimestamp\"}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-st-multi.json b/dev/conformance/conformance-tests/set-st-multi.json new file mode 100644 index 000000000..23c06f497 --- /dev/null +++ b/dev/conformance/conformance-tests/set-st-multi.json @@ -0,0 +1,42 @@ +{ + "tests": [ + { + "description": "set: multiple ServerTimestamp fields", + "comment": "A document can have more than one ServerTimestamp field.\nSince all the ServerTimestamp fields are removed, the only field in the update is \"a\".", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": \"ServerTimestamp\", \"c\": {\"d\": \"ServerTimestamp\"}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c.d", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-st-nested.json b/dev/conformance/conformance-tests/set-st-nested.json new file mode 100644 index 000000000..5c94c33f9 --- /dev/null +++ b/dev/conformance/conformance-tests/set-st-nested.json @@ -0,0 +1,38 @@ +{ + "tests": [ + { + "description": "set: nested ServerTimestamp field", + "comment": "A ServerTimestamp value can occur at any depth. In this case,\nthe transform applies to the field path \"b.c\". Since \"c\" is removed from the update,\n\"b\" becomes empty, so it is also removed from the update.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": {\"c\": \"ServerTimestamp\"}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-st-noarray-nested.json b/dev/conformance/conformance-tests/set-st-noarray-nested.json new file mode 100644 index 000000000..5ad6a5089 --- /dev/null +++ b/dev/conformance/conformance-tests/set-st-noarray-nested.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "set: ServerTimestamp cannot be anywhere inside an array value", + "comment": "There cannot be an array value anywhere on the path from the document\nroot to the ServerTimestamp sentinel. Firestore transforms don't support array indexing.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, {\"b\": \"ServerTimestamp\"}]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-st-noarray.json b/dev/conformance/conformance-tests/set-st-noarray.json new file mode 100644 index 000000000..76a2881cb --- /dev/null +++ b/dev/conformance/conformance-tests/set-st-noarray.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "set: ServerTimestamp cannot be in an array value", + "comment": "The ServerTimestamp sentinel must be the value of a field. Firestore\ntransforms don't support array indexing.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, 2, \"ServerTimestamp\"]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-st-nomerge.json b/dev/conformance/conformance-tests/set-st-nomerge.json new file mode 100644 index 000000000..0523ed74f --- /dev/null +++ b/dev/conformance/conformance-tests/set-st-nomerge.json @@ -0,0 +1,41 @@ +{ + "tests": [ + { + "description": "set-merge: If is ServerTimestamp not in Merge, no transform", + "comment": "If the ServerTimestamp value is not mentioned in a merge option,\nthen it is pruned from the data but does not result in a transform.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "option": { + "fields": [ + { + "field": [ + "a" + ] + } + ] + }, + "jsonData": "{\"a\": 1, \"b\": \"ServerTimestamp\"}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-st-with-empty-map.json b/dev/conformance/conformance-tests/set-st-with-empty-map.json new file mode 100644 index 000000000..063c94a0e --- /dev/null +++ b/dev/conformance/conformance-tests/set-st-with-empty-map.json @@ -0,0 +1,46 @@ +{ + "tests": [ + { + "description": "set: ServerTimestamp beside an empty map", + "comment": "When a ServerTimestamp and a map both reside inside a map, the\nServerTimestamp should be stripped out but the empty map should remain.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": {\"b\": {}, \"c\": \"ServerTimestamp\"}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "mapValue": { + "fields": { + "b": { + "mapValue": { + "fields": {} + } + } + } + } + } + } + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/set-st.json b/dev/conformance/conformance-tests/set-st.json new file mode 100644 index 000000000..42f2b14f1 --- /dev/null +++ b/dev/conformance/conformance-tests/set-st.json @@ -0,0 +1,38 @@ +{ + "tests": [ + { + "description": "set: ServerTimestamp with data", + "comment": "A key with the special ServerTimestamp sentinel is removed from\nthe data in the update operation. Instead it appears in a separate Transform operation.\nNote that in these tests, the string \"ServerTimestamp\" should be replaced with the\nspecial ServerTimestamp value.", + "set": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": \"ServerTimestamp\"}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-all-transforms.json b/dev/conformance/conformance-tests/update-all-transforms.json new file mode 100644 index 000000000..6f6a725df --- /dev/null +++ b/dev/conformance/conformance-tests/update-all-transforms.json @@ -0,0 +1,78 @@ +{ + "tests": [ + { + "description": "update: all transforms in a single call", + "comment": "A document can be created with any amount of transforms.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": \"ServerTimestamp\", \"c\": [\"ArrayUnion\", 1, 2, 3], \"d\": [\"ArrayRemove\", 4, 5, 6]}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-arrayremove-alone.json b/dev/conformance/conformance-tests/update-arrayremove-alone.json new file mode 100644 index 000000000..86fc8802e --- /dev/null +++ b/dev/conformance/conformance-tests/update-arrayremove-alone.json @@ -0,0 +1,43 @@ +{ + "tests": [ + { + "description": "update: ArrayRemove alone", + "comment": "If the only values in the input are ArrayRemove, then no\nupdate operation should be produced.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [\"ArrayRemove\", 1, 2, 3]}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-arrayremove-multi.json b/dev/conformance/conformance-tests/update-arrayremove-multi.json new file mode 100644 index 000000000..df880f679 --- /dev/null +++ b/dev/conformance/conformance-tests/update-arrayremove-multi.json @@ -0,0 +1,75 @@ +{ + "tests": [ + { + "description": "update: multiple ArrayRemove fields", + "comment": "A document can have more than one ArrayRemove field.\nSince all the ArrayRemove fields are removed, the only field in the update is \"a\".", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": [\"ArrayRemove\", 1, 2, 3], \"c\": {\"d\": [\"ArrayRemove\", 4, 5, 6]}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "c" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-arrayremove-nested.json b/dev/conformance/conformance-tests/update-arrayremove-nested.json new file mode 100644 index 000000000..28d59aff6 --- /dev/null +++ b/dev/conformance/conformance-tests/update-arrayremove-nested.json @@ -0,0 +1,59 @@ +{ + "tests": [ + { + "description": "update: nested ArrayRemove field", + "comment": "An ArrayRemove value can occur at any depth. In this case,\nthe transform applies to the field path \"b.c\". Since \"c\" is removed from the update,\n\"b\" becomes empty, so it is also removed from the update.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": {\"c\": [\"ArrayRemove\", 1, 2, 3]}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "b" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-arrayremove-noarray-nested.json b/dev/conformance/conformance-tests/update-arrayremove-noarray-nested.json new file mode 100644 index 000000000..842c5fe32 --- /dev/null +++ b/dev/conformance/conformance-tests/update-arrayremove-noarray-nested.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: ArrayRemove cannot be anywhere inside an array value", + "comment": "There cannot be an array value anywhere on the path from the document\nroot to the ArrayRemove. Firestore transforms don't support array indexing.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, {\"b\": [\"ArrayRemove\", 1, 2, 3]}]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-arrayremove-noarray.json b/dev/conformance/conformance-tests/update-arrayremove-noarray.json new file mode 100644 index 000000000..0a371f055 --- /dev/null +++ b/dev/conformance/conformance-tests/update-arrayremove-noarray.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: ArrayRemove cannot be in an array value", + "comment": "ArrayRemove must be the value of a field. Firestore\ntransforms don't support array indexing.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, 2, [\"ArrayRemove\", 1, 2, 3]]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-arrayremove-with-st.json b/dev/conformance/conformance-tests/update-arrayremove-with-st.json new file mode 100644 index 000000000..9d110de9c --- /dev/null +++ b/dev/conformance/conformance-tests/update-arrayremove-with-st.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: The ServerTimestamp sentinel cannot be in an ArrayUnion", + "comment": "The ServerTimestamp sentinel must be the value of a field. It may\nnot appear in an ArrayUnion.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [\"ArrayRemove\", 1, \"ServerTimestamp\", 3]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-arrayremove.json b/dev/conformance/conformance-tests/update-arrayremove.json new file mode 100644 index 000000000..d925704db --- /dev/null +++ b/dev/conformance/conformance-tests/update-arrayremove.json @@ -0,0 +1,58 @@ +{ + "tests": [ + { + "description": "update: ArrayRemove with data", + "comment": "A key with ArrayRemove is removed from the data in the update \noperation. Instead it appears in a separate Transform operation.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": [\"ArrayRemove\", 1, 2, 3]}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-arrayunion-alone.json b/dev/conformance/conformance-tests/update-arrayunion-alone.json new file mode 100644 index 000000000..757ea48c3 --- /dev/null +++ b/dev/conformance/conformance-tests/update-arrayunion-alone.json @@ -0,0 +1,43 @@ +{ + "tests": [ + { + "description": "update: ArrayUnion alone", + "comment": "If the only values in the input are ArrayUnion, then no\nupdate operation should be produced.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [\"ArrayUnion\", 1, 2, 3]}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-arrayunion-multi.json b/dev/conformance/conformance-tests/update-arrayunion-multi.json new file mode 100644 index 000000000..3aafcd0f3 --- /dev/null +++ b/dev/conformance/conformance-tests/update-arrayunion-multi.json @@ -0,0 +1,75 @@ +{ + "tests": [ + { + "description": "update: multiple ArrayUnion fields", + "comment": "A document can have more than one ArrayUnion field.\nSince all the ArrayUnion fields are removed, the only field in the update is \"a\".", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": [\"ArrayUnion\", 1, 2, 3], \"c\": {\"d\": [\"ArrayUnion\", 4, 5, 6]}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "c" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "appendMissingElements": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-arrayunion-nested.json b/dev/conformance/conformance-tests/update-arrayunion-nested.json new file mode 100644 index 000000000..f2bf3770d --- /dev/null +++ b/dev/conformance/conformance-tests/update-arrayunion-nested.json @@ -0,0 +1,59 @@ +{ + "tests": [ + { + "description": "update: nested ArrayUnion field", + "comment": "An ArrayUnion value can occur at any depth. In this case,\nthe transform applies to the field path \"b.c\". Since \"c\" is removed from the update,\n\"b\" becomes empty, so it is also removed from the update.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": {\"c\": [\"ArrayUnion\", 1, 2, 3]}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "b" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-arrayunion-noarray-nested.json b/dev/conformance/conformance-tests/update-arrayunion-noarray-nested.json new file mode 100644 index 000000000..08745a08b --- /dev/null +++ b/dev/conformance/conformance-tests/update-arrayunion-noarray-nested.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: ArrayUnion cannot be anywhere inside an array value", + "comment": "There cannot be an array value anywhere on the path from the document\nroot to the ArrayUnion. Firestore transforms don't support array indexing.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, {\"b\": [\"ArrayUnion\", 1, 2, 3]}]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-arrayunion-noarray.json b/dev/conformance/conformance-tests/update-arrayunion-noarray.json new file mode 100644 index 000000000..284f42800 --- /dev/null +++ b/dev/conformance/conformance-tests/update-arrayunion-noarray.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: ArrayUnion cannot be in an array value", + "comment": "ArrayUnion must be the value of a field. Firestore\ntransforms don't support array indexing.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, 2, [\"ArrayRemove\", 1, 2, 3]]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-arrayunion-with-st.json b/dev/conformance/conformance-tests/update-arrayunion-with-st.json new file mode 100644 index 000000000..1c47591e2 --- /dev/null +++ b/dev/conformance/conformance-tests/update-arrayunion-with-st.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: The ServerTimestamp sentinel cannot be in an ArrayUnion", + "comment": "The ServerTimestamp sentinel must be the value of a field. It may\nnot appear in an ArrayUnion.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [\"ArrayUnion\", 1, \"ServerTimestamp\", 3]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-arrayunion.json b/dev/conformance/conformance-tests/update-arrayunion.json new file mode 100644 index 000000000..60192c9f8 --- /dev/null +++ b/dev/conformance/conformance-tests/update-arrayunion.json @@ -0,0 +1,58 @@ +{ + "tests": [ + { + "description": "update: ArrayUnion with data", + "comment": "A key with ArrayUnion is removed from the data in the update \noperation. Instead it appears in a separate Transform operation.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": [\"ArrayUnion\", 1, 2, 3]}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-badchar.json b/dev/conformance/conformance-tests/update-badchar.json new file mode 100644 index 000000000..7d5e6e4f0 --- /dev/null +++ b/dev/conformance/conformance-tests/update-badchar.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: invalid character", + "comment": "The keys of the data given to Update are interpreted, unlike those of Create and Set. They cannot contain special characters.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a~b\": 1}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-basic.json b/dev/conformance/conformance-tests/update-basic.json new file mode 100644 index 000000000..f86424742 --- /dev/null +++ b/dev/conformance/conformance-tests/update-basic.json @@ -0,0 +1,35 @@ +{ + "tests": [ + { + "description": "update: basic", + "comment": "A simple call, resulting in a single update operation.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-complex.json b/dev/conformance/conformance-tests/update-complex.json new file mode 100644 index 000000000..ddf837336 --- /dev/null +++ b/dev/conformance/conformance-tests/update-complex.json @@ -0,0 +1,69 @@ +{ + "tests": [ + { + "description": "update: complex", + "comment": "A call to a write method with complicated input data.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, 2.5], \"b\": {\"c\": [\"three\", {\"d\": true}]}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "arrayValue": { + "values": [ + { + "integerValue": "1" + }, + { + "doubleValue": 2.5 + } + ] + } + }, + "b": { + "mapValue": { + "fields": { + "c": { + "arrayValue": { + "values": [ + { + "stringValue": "three" + }, + { + "mapValue": { + "fields": { + "d": { + "booleanValue": true + } + } + } + } + ] + } + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "b" + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-del-alone.json b/dev/conformance/conformance-tests/update-del-alone.json new file mode 100644 index 000000000..45598ab40 --- /dev/null +++ b/dev/conformance/conformance-tests/update-del-alone.json @@ -0,0 +1,30 @@ +{ + "tests": [ + { + "description": "update: Delete alone", + "comment": "If the input data consists solely of Deletes, then the update\noperation has no map, just an update mask.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": \"Delete\"}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-del-dot.json b/dev/conformance/conformance-tests/update-del-dot.json new file mode 100644 index 000000000..44f36b0c3 --- /dev/null +++ b/dev/conformance/conformance-tests/update-del-dot.json @@ -0,0 +1,46 @@ +{ + "tests": [ + { + "description": "update: Delete with a dotted field", + "comment": "After expanding top-level dotted fields, fields with Delete\nvalues are pruned from the output data, but appear in the update mask.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b.c\": \"Delete\", \"b.d\": 2}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + }, + "b": { + "mapValue": { + "fields": { + "d": { + "integerValue": "2" + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "b.c", + "b.d" + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-del-nested.json b/dev/conformance/conformance-tests/update-del-nested.json new file mode 100644 index 000000000..18d08f3f0 --- /dev/null +++ b/dev/conformance/conformance-tests/update-del-nested.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: Delete cannot be nested", + "comment": "The Delete sentinel must be the value of a top-level key.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": {\"b\": \"Delete\"}}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-del-noarray-nested.json b/dev/conformance/conformance-tests/update-del-noarray-nested.json new file mode 100644 index 000000000..025cbed0d --- /dev/null +++ b/dev/conformance/conformance-tests/update-del-noarray-nested.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: Delete cannot be anywhere inside an array value", + "comment": "The Delete sentinel must be the value of a field. Deletes are implemented\nby turning the path to the Delete sentinel into a FieldPath, and FieldPaths do not support\narray indexing.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, {\"b\": \"Delete\"}]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-del-noarray.json b/dev/conformance/conformance-tests/update-del-noarray.json new file mode 100644 index 000000000..dce3806f2 --- /dev/null +++ b/dev/conformance/conformance-tests/update-del-noarray.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: Delete cannot be in an array value", + "comment": "The Delete sentinel must be the value of a field. Deletes are\nimplemented by turning the path to the Delete sentinel into a FieldPath, and FieldPaths\ndo not support array indexing.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, 2, \"Delete\"]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-del.json b/dev/conformance/conformance-tests/update-del.json new file mode 100644 index 000000000..26a6a1bc7 --- /dev/null +++ b/dev/conformance/conformance-tests/update-del.json @@ -0,0 +1,36 @@ +{ + "tests": [ + { + "description": "update: Delete", + "comment": "If a field's value is the Delete sentinel, then it doesn't appear\nin the update data, but does in the mask.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": \"Delete\"}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "b" + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-exists-precond.json b/dev/conformance/conformance-tests/update-exists-precond.json new file mode 100644 index 000000000..bdbe274b4 --- /dev/null +++ b/dev/conformance/conformance-tests/update-exists-precond.json @@ -0,0 +1,16 @@ +{ + "tests": [ + { + "description": "update: Exists precondition is invalid", + "comment": "The Update method does not support an explicit exists precondition.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "precondition": { + "exists": true + }, + "jsonData": "{\"a\": 1}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-fp-empty-component.json b/dev/conformance/conformance-tests/update-fp-empty-component.json new file mode 100644 index 000000000..50274e49f --- /dev/null +++ b/dev/conformance/conformance-tests/update-fp-empty-component.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: empty field path component", + "comment": "Empty fields are not allowed.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a..b\": 1}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-nested-transform-and-nested-value.json b/dev/conformance/conformance-tests/update-nested-transform-and-nested-value.json new file mode 100644 index 000000000..ff7bfc6ee --- /dev/null +++ b/dev/conformance/conformance-tests/update-nested-transform-and-nested-value.json @@ -0,0 +1,52 @@ +{ + "tests": [ + { + "description": "update: Nested transforms should not affect the field mask, even\nwhen there are other values that do. Transforms should only affect the\nDocumentTransform_FieldTransform list.", + "comment": "For updates, top-level paths in json-like map inputs\nare split on the dot. That is, an input {\"a.b.c\": 7} results in an update to\nfield c of object b of object a with value 7. In order to specify this behavior,\nthe update must use a fieldmask \"a.b.c\". However, fieldmasks are only used for\nconcrete values - transforms are separately encoded in a\nDocumentTransform_FieldTransform array.\n\nThis test exercises a bug found in python (https://github.com/googleapis/google-cloud-python/issues/7215)\nin which nested transforms ({\"a.c\": \"ServerTimestamp\"}) next to nested values\n({\"a.b\": 7}) incorrectly caused the fieldmask \"a\" to be set, which has the\neffect of wiping out all data in \"a\" other than what was specified in the\njson-like input.\n\nInstead, as this test specifies, transforms should not affect the fieldmask.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a.b\": 7, \"a.c\": \"ServerTimestamp\"}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "mapValue": { + "fields": { + "b": { + "integerValue": "7" + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "a.b" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-no-paths.json b/dev/conformance/conformance-tests/update-no-paths.json new file mode 100644 index 000000000..6cfbc01dc --- /dev/null +++ b/dev/conformance/conformance-tests/update-no-paths.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: no paths", + "comment": "It is a client-side error to call Update with empty data.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-all-transforms.json b/dev/conformance/conformance-tests/update-paths-all-transforms.json new file mode 100644 index 000000000..01a4c1143 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-all-transforms.json @@ -0,0 +1,105 @@ +{ + "tests": [ + { + "description": "update-paths: all transforms in a single call", + "comment": "A document can be created with any amount of transforms.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + }, + { + "field": [ + "c" + ] + }, + { + "field": [ + "d" + ] + } + ], + "jsonValues": [ + "1", + "\"ServerTimestamp\"", + "[\"ArrayUnion\", 1, 2, 3]", + "[\"ArrayRemove\", 4, 5, 6]" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-arrayremove-alone.json b/dev/conformance/conformance-tests/update-paths-arrayremove-alone.json new file mode 100644 index 000000000..9bc8a1440 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-arrayremove-alone.json @@ -0,0 +1,52 @@ +{ + "tests": [ + { + "description": "update-paths: ArrayRemove alone", + "comment": "If the only values in the input are ArrayRemove, then no\nupdate operation should be produced.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "[\"ArrayRemove\", 1, 2, 3]" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-arrayremove-multi.json b/dev/conformance/conformance-tests/update-paths-arrayremove-multi.json new file mode 100644 index 000000000..9a8547120 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-arrayremove-multi.json @@ -0,0 +1,96 @@ +{ + "tests": [ + { + "description": "update-paths: multiple ArrayRemove fields", + "comment": "A document can have more than one ArrayRemove field.\nSince all the ArrayRemove fields are removed, the only field in the update is \"a\".", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + }, + { + "field": [ + "c" + ] + } + ], + "jsonValues": [ + "1", + "[\"ArrayRemove\", 1, 2, 3]", + "{\"d\": [\"ArrayRemove\", 4, 5, 6]}" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "c" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-arrayremove-nested.json b/dev/conformance/conformance-tests/update-paths-arrayremove-nested.json new file mode 100644 index 000000000..e7f952ec3 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-arrayremove-nested.json @@ -0,0 +1,74 @@ +{ + "tests": [ + { + "description": "update-paths: nested ArrayRemove field", + "comment": "An ArrayRemove value can occur at any depth. In this case,\nthe transform applies to the field path \"b.c\". Since \"c\" is removed from the update,\n\"b\" becomes empty, so it is also removed from the update.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + } + ], + "jsonValues": [ + "1", + "{\"c\": [\"ArrayRemove\", 1, 2, 3]}" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "b" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-arrayremove-noarray-nested.json b/dev/conformance/conformance-tests/update-paths-arrayremove-noarray-nested.json new file mode 100644 index 000000000..b669e870c --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-arrayremove-noarray-nested.json @@ -0,0 +1,22 @@ +{ + "tests": [ + { + "description": "update-paths: ArrayRemove cannot be anywhere inside an array value", + "comment": "There cannot be an array value anywhere on the path from the document\nroot to the ArrayRemove. Firestore transforms don't support array indexing.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "[1, {\"b\": [\"ArrayRemove\", 1, 2, 3]}]" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-arrayremove-noarray.json b/dev/conformance/conformance-tests/update-paths-arrayremove-noarray.json new file mode 100644 index 000000000..ff50e11e4 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-arrayremove-noarray.json @@ -0,0 +1,22 @@ +{ + "tests": [ + { + "description": "update-paths: ArrayRemove cannot be in an array value", + "comment": "ArrayRemove must be the value of a field. Firestore\ntransforms don't support array indexing.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "[1, 2, [\"ArrayRemove\", 1, 2, 3]]" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-arrayremove-with-st.json b/dev/conformance/conformance-tests/update-paths-arrayremove-with-st.json new file mode 100644 index 000000000..d27d26e44 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-arrayremove-with-st.json @@ -0,0 +1,22 @@ +{ + "tests": [ + { + "description": "update-paths: The ServerTimestamp sentinel cannot be in an ArrayUnion", + "comment": "The ServerTimestamp sentinel must be the value of a field. It may\nnot appear in an ArrayUnion.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "[\"ArrayRemove\", 1, \"ServerTimestamp\", 3]" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-arrayremove.json b/dev/conformance/conformance-tests/update-paths-arrayremove.json new file mode 100644 index 000000000..673a2ca2c --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-arrayremove.json @@ -0,0 +1,73 @@ +{ + "tests": [ + { + "description": "update-paths: ArrayRemove with data", + "comment": "A key with ArrayRemove is removed from the data in the update \noperation. Instead it appears in a separate Transform operation.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + } + ], + "jsonValues": [ + "1", + "[\"ArrayRemove\", 1, 2, 3]" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-arrayunion-alone.json b/dev/conformance/conformance-tests/update-paths-arrayunion-alone.json new file mode 100644 index 000000000..81e1e9771 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-arrayunion-alone.json @@ -0,0 +1,52 @@ +{ + "tests": [ + { + "description": "update-paths: ArrayUnion alone", + "comment": "If the only values in the input are ArrayUnion, then no\nupdate operation should be produced.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "[\"ArrayUnion\", 1, 2, 3]" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-arrayunion-multi.json b/dev/conformance/conformance-tests/update-paths-arrayunion-multi.json new file mode 100644 index 000000000..ef421bdad --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-arrayunion-multi.json @@ -0,0 +1,96 @@ +{ + "tests": [ + { + "description": "update-paths: multiple ArrayUnion fields", + "comment": "A document can have more than one ArrayUnion field.\nSince all the ArrayUnion fields are removed, the only field in the update is \"a\".", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + }, + { + "field": [ + "c" + ] + } + ], + "jsonValues": [ + "1", + "[\"ArrayUnion\", 1, 2, 3]", + "{\"d\": [\"ArrayUnion\", 4, 5, 6]}" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "c" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "appendMissingElements": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-arrayunion-nested.json b/dev/conformance/conformance-tests/update-paths-arrayunion-nested.json new file mode 100644 index 000000000..2d73527a4 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-arrayunion-nested.json @@ -0,0 +1,74 @@ +{ + "tests": [ + { + "description": "update-paths: nested ArrayUnion field", + "comment": "An ArrayUnion value can occur at any depth. In this case,\nthe transform applies to the field path \"b.c\". Since \"c\" is removed from the update,\n\"b\" becomes empty, so it is also removed from the update.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + } + ], + "jsonValues": [ + "1", + "{\"c\": [\"ArrayUnion\", 1, 2, 3]}" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "b" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-arrayunion-noarray-nested.json b/dev/conformance/conformance-tests/update-paths-arrayunion-noarray-nested.json new file mode 100644 index 000000000..0e8a634a4 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-arrayunion-noarray-nested.json @@ -0,0 +1,22 @@ +{ + "tests": [ + { + "description": "update-paths: ArrayUnion cannot be anywhere inside an array value", + "comment": "There cannot be an array value anywhere on the path from the document\nroot to the ArrayUnion. Firestore transforms don't support array indexing.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "[1, {\"b\": [\"ArrayUnion\", 1, 2, 3]}]" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-arrayunion-noarray.json b/dev/conformance/conformance-tests/update-paths-arrayunion-noarray.json new file mode 100644 index 000000000..ce4584188 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-arrayunion-noarray.json @@ -0,0 +1,22 @@ +{ + "tests": [ + { + "description": "update-paths: ArrayUnion cannot be in an array value", + "comment": "ArrayUnion must be the value of a field. Firestore\ntransforms don't support array indexing.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "[1, 2, [\"ArrayRemove\", 1, 2, 3]]" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-arrayunion-with-st.json b/dev/conformance/conformance-tests/update-paths-arrayunion-with-st.json new file mode 100644 index 000000000..c0a420418 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-arrayunion-with-st.json @@ -0,0 +1,22 @@ +{ + "tests": [ + { + "description": "update-paths: The ServerTimestamp sentinel cannot be in an ArrayUnion", + "comment": "The ServerTimestamp sentinel must be the value of a field. It may\nnot appear in an ArrayUnion.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "[\"ArrayUnion\", 1, \"ServerTimestamp\", 3]" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-arrayunion.json b/dev/conformance/conformance-tests/update-paths-arrayunion.json new file mode 100644 index 000000000..1401993d0 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-arrayunion.json @@ -0,0 +1,73 @@ +{ + "tests": [ + { + "description": "update-paths: ArrayUnion with data", + "comment": "A key with ArrayUnion is removed from the data in the update \noperation. Instead it appears in a separate Transform operation.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + } + ], + "jsonValues": [ + "1", + "[\"ArrayUnion\", 1, 2, 3]" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-basic.json b/dev/conformance/conformance-tests/update-paths-basic.json new file mode 100644 index 000000000..bf1164ac4 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-basic.json @@ -0,0 +1,44 @@ +{ + "tests": [ + { + "description": "update-paths: basic", + "comment": "A simple call, resulting in a single update operation.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "1" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-complex.json b/dev/conformance/conformance-tests/update-paths-complex.json new file mode 100644 index 000000000..2f3faa784 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-complex.json @@ -0,0 +1,84 @@ +{ + "tests": [ + { + "description": "update-paths: complex", + "comment": "A call to a write method with complicated input data.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + } + ], + "jsonValues": [ + "[1, 2.5]", + "{\"c\": [\"three\", {\"d\": true}]}" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "arrayValue": { + "values": [ + { + "integerValue": "1" + }, + { + "doubleValue": 2.5 + } + ] + } + }, + "b": { + "mapValue": { + "fields": { + "c": { + "arrayValue": { + "values": [ + { + "stringValue": "three" + }, + { + "mapValue": { + "fields": { + "d": { + "booleanValue": true + } + } + } + } + ] + } + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "b" + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-del-alone.json b/dev/conformance/conformance-tests/update-paths-del-alone.json new file mode 100644 index 000000000..e3368c86c --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-del-alone.json @@ -0,0 +1,39 @@ +{ + "tests": [ + { + "description": "update-paths: Delete alone", + "comment": "If the input data consists solely of Deletes, then the update\noperation has no map, just an update mask.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "\"Delete\"" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-del-nested.json b/dev/conformance/conformance-tests/update-paths-del-nested.json new file mode 100644 index 000000000..07f9f405e --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-del-nested.json @@ -0,0 +1,22 @@ +{ + "tests": [ + { + "description": "update-paths: Delete cannot be nested", + "comment": "The Delete sentinel must be the value of a top-level key.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "{\"b\": \"Delete\"}" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-del-noarray-nested.json b/dev/conformance/conformance-tests/update-paths-del-noarray-nested.json new file mode 100644 index 000000000..a74c0aeb5 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-del-noarray-nested.json @@ -0,0 +1,22 @@ +{ + "tests": [ + { + "description": "update-paths: Delete cannot be anywhere inside an array value", + "comment": "The Delete sentinel must be the value of a field. Deletes are implemented\nby turning the path to the Delete sentinel into a FieldPath, and FieldPaths do not support\narray indexing.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "[1, {\"b\": \"Delete\"}]" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-del-noarray.json b/dev/conformance/conformance-tests/update-paths-del-noarray.json new file mode 100644 index 000000000..fb6d00b72 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-del-noarray.json @@ -0,0 +1,22 @@ +{ + "tests": [ + { + "description": "update-paths: Delete cannot be in an array value", + "comment": "The Delete sentinel must be the value of a field. Deletes are\nimplemented by turning the path to the Delete sentinel into a FieldPath, and FieldPaths\ndo not support array indexing.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "[1, 2, \"Delete\"]" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-del.json b/dev/conformance/conformance-tests/update-paths-del.json new file mode 100644 index 000000000..cb5f6bedf --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-del.json @@ -0,0 +1,51 @@ +{ + "tests": [ + { + "description": "update-paths: Delete", + "comment": "If a field's value is the Delete sentinel, then it doesn't appear\nin the update data, but does in the mask.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + } + ], + "jsonValues": [ + "1", + "\"Delete\"" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "b" + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-exists-precond.json b/dev/conformance/conformance-tests/update-paths-exists-precond.json new file mode 100644 index 000000000..d495db033 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-exists-precond.json @@ -0,0 +1,25 @@ +{ + "tests": [ + { + "description": "update-paths: Exists precondition is invalid", + "comment": "The Update method does not support an explicit exists precondition.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "precondition": { + "exists": true + }, + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "1" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-fp-del.json b/dev/conformance/conformance-tests/update-paths-fp-del.json new file mode 100644 index 000000000..95b787a91 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-fp-del.json @@ -0,0 +1,59 @@ +{ + "tests": [ + { + "description": "update-paths: field paths with delete", + "comment": "If one nested field is deleted, and another isn't, preserve the second.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "foo", + "bar" + ] + }, + { + "field": [ + "foo", + "delete" + ] + } + ], + "jsonValues": [ + "1", + "\"Delete\"" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "foo": { + "mapValue": { + "fields": { + "bar": { + "integerValue": "1" + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "foo.bar", + "foo.delete" + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-fp-dup-transforms.json b/dev/conformance/conformance-tests/update-paths-fp-dup-transforms.json new file mode 100644 index 000000000..aff02a8d2 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-fp-dup-transforms.json @@ -0,0 +1,34 @@ +{ + "tests": [ + { + "description": "update-paths: duplicate field path with only transforms", + "comment": "The same field cannot occur more than once, even if all the operations are transforms.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + }, + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "[\"ArrayUnion\", 1, 2, 3]", + "\"ServerTimestamp\"", + "[\"ArrayUnion\", 4, 5, 6]" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-fp-dup.json b/dev/conformance/conformance-tests/update-paths-fp-dup.json new file mode 100644 index 000000000..71bf4d54a --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-fp-dup.json @@ -0,0 +1,34 @@ +{ + "tests": [ + { + "description": "update-paths: duplicate field path", + "comment": "The same field cannot occur more than once.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + }, + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "1", + "2", + "3" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-fp-empty-component.json b/dev/conformance/conformance-tests/update-paths-fp-empty-component.json new file mode 100644 index 000000000..161e9f6ef --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-fp-empty-component.json @@ -0,0 +1,23 @@ +{ + "tests": [ + { + "description": "update-paths: empty field path component", + "comment": "Empty fields are not allowed.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "*", + "" + ] + } + ], + "jsonValues": [ + "1" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-fp-empty.json b/dev/conformance/conformance-tests/update-paths-fp-empty.json new file mode 100644 index 000000000..9424da130 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-fp-empty.json @@ -0,0 +1,20 @@ +{ + "tests": [ + { + "description": "update-paths: empty field path", + "comment": "A FieldPath of length zero is invalid.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [] + } + ], + "jsonValues": [ + "1" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-fp-multi.json b/dev/conformance/conformance-tests/update-paths-fp-multi.json new file mode 100644 index 000000000..a0afd38b8 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-fp-multi.json @@ -0,0 +1,51 @@ +{ + "tests": [ + { + "description": "update-paths: multiple-element field path", + "comment": "The UpdatePaths or equivalent method takes a list of FieldPaths.\nEach FieldPath is a sequence of uninterpreted path components.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a", + "b" + ] + } + ], + "jsonValues": [ + "1" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "mapValue": { + "fields": { + "b": { + "integerValue": "1" + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "a.b" + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-fp-nosplit.json b/dev/conformance/conformance-tests/update-paths-fp-nosplit.json new file mode 100644 index 000000000..23e9ddc9d --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-fp-nosplit.json @@ -0,0 +1,57 @@ +{ + "tests": [ + { + "description": "update-paths: FieldPath elements are not split on dots", + "comment": "FieldPath components are not split on dots.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a.b", + "f.g" + ] + } + ], + "jsonValues": [ + "{\"n.o\": 7}" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a.b": { + "mapValue": { + "fields": { + "f.g": { + "mapValue": { + "fields": { + "n.o": { + "integerValue": "7" + } + } + } + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "`a.b`.`f.g`" + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-nested-transform-and-nested-value.json b/dev/conformance/conformance-tests/update-paths-nested-transform-and-nested-value.json new file mode 100644 index 000000000..927d783ae --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-nested-transform-and-nested-value.json @@ -0,0 +1,69 @@ +{ + "tests": [ + { + "description": "update-paths: Nested transforms should not affect the field mask, even\nwhen there are other values that do. Transforms should only affect the\nDocumentTransform_FieldTransform list.", + "comment": "For updates, top-level paths in json-like map inputs\nare split on the dot. That is, an input {\"a.b.c\": 7} results in an update to\nfield c of object b of object a with value 7. In order to specify this behavior,\nthe update must use a fieldmask \"a.b.c\". However, fieldmasks are only used for\nconcrete values - transforms are separately encoded in a\nDocumentTransform_FieldTransform array.\n\nThis test exercises a bug found in python (https://github.com/googleapis/google-cloud-python/issues/7215)\nin which nested transforms ({\"a.c\": \"ServerTimestamp\"}) next to nested values\n({\"a.b\": 7}) incorrectly caused the fieldmask \"a\" to be set, which has the\neffect of wiping out all data in \"a\" other than what was specified in the\njson-like input.\n\nInstead, as this test specifies, transforms should not affect the fieldmask.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a", + "b" + ] + }, + { + "field": [ + "a", + "c" + ] + } + ], + "jsonValues": [ + "7", + "\"ServerTimestamp\"" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "mapValue": { + "fields": { + "b": { + "integerValue": "7" + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "a.b" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-no-paths.json b/dev/conformance/conformance-tests/update-paths-no-paths.json new file mode 100644 index 000000000..e8ad035ea --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-no-paths.json @@ -0,0 +1,12 @@ +{ + "tests": [ + { + "description": "update-paths: no paths", + "comment": "It is a client-side error to call Update with empty data.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-prefix-1.json b/dev/conformance/conformance-tests/update-paths-prefix-1.json new file mode 100644 index 000000000..0bc1c0e81 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-prefix-1.json @@ -0,0 +1,29 @@ +{ + "tests": [ + { + "description": "update-paths: prefix #1", + "comment": "In the input data, one field cannot be a prefix of another.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a", + "b" + ] + }, + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "1", + "2" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-prefix-2.json b/dev/conformance/conformance-tests/update-paths-prefix-2.json new file mode 100644 index 000000000..6f1d152a7 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-prefix-2.json @@ -0,0 +1,29 @@ +{ + "tests": [ + { + "description": "update-paths: prefix #2", + "comment": "In the input data, one field cannot be a prefix of another.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "a", + "b" + ] + } + ], + "jsonValues": [ + "1", + "2" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-prefix-3.json b/dev/conformance/conformance-tests/update-paths-prefix-3.json new file mode 100644 index 000000000..4fe17b292 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-prefix-3.json @@ -0,0 +1,29 @@ +{ + "tests": [ + { + "description": "update-paths: prefix #3", + "comment": "In the input data, one field cannot be a prefix of another, even if the values could in principle be combined.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "a", + "d" + ] + } + ], + "jsonValues": [ + "{\"b\": 1}", + "2" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-special-chars.json b/dev/conformance/conformance-tests/update-paths-special-chars.json new file mode 100644 index 000000000..83b27d8db --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-special-chars.json @@ -0,0 +1,62 @@ +{ + "tests": [ + { + "description": "update-paths: special characters", + "comment": "FieldPaths can contain special characters.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "*", + "~" + ] + }, + { + "field": [ + "*", + "`" + ] + } + ], + "jsonValues": [ + "1", + "2" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "*": { + "mapValue": { + "fields": { + "`": { + "integerValue": "2" + }, + "~": { + "integerValue": "1" + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "`*`.`\\``", + "`*`.`~`" + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-st-alone.json b/dev/conformance/conformance-tests/update-paths-st-alone.json new file mode 100644 index 000000000..085d04987 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-st-alone.json @@ -0,0 +1,40 @@ +{ + "tests": [ + { + "description": "update-paths: ServerTimestamp alone", + "comment": "If the only values in the input are ServerTimestamps, then no\nupdate operation should be produced.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "\"ServerTimestamp\"" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-st-multi.json b/dev/conformance/conformance-tests/update-paths-st-multi.json new file mode 100644 index 000000000..2d813801a --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-st-multi.json @@ -0,0 +1,72 @@ +{ + "tests": [ + { + "description": "update-paths: multiple ServerTimestamp fields", + "comment": "A document can have more than one ServerTimestamp field.\nSince all the ServerTimestamp fields are removed, the only field in the update is \"a\".", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + }, + { + "field": [ + "c" + ] + } + ], + "jsonValues": [ + "1", + "\"ServerTimestamp\"", + "{\"d\": \"ServerTimestamp\"}" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "c" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c.d", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-st-nested.json b/dev/conformance/conformance-tests/update-paths-st-nested.json new file mode 100644 index 000000000..8bd35c911 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-st-nested.json @@ -0,0 +1,62 @@ +{ + "tests": [ + { + "description": "update-paths: nested ServerTimestamp field", + "comment": "A ServerTimestamp value can occur at any depth. In this case,\nthe transform applies to the field path \"b.c\". Since \"c\" is removed from the update,\n\"b\" becomes empty, so it is also removed from the update.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + } + ], + "jsonValues": [ + "1", + "{\"c\": \"ServerTimestamp\"}" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "b" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-st-noarray-nested.json b/dev/conformance/conformance-tests/update-paths-st-noarray-nested.json new file mode 100644 index 000000000..2dd1bcacc --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-st-noarray-nested.json @@ -0,0 +1,22 @@ +{ + "tests": [ + { + "description": "update-paths: ServerTimestamp cannot be anywhere inside an array value", + "comment": "There cannot be an array value anywhere on the path from the document\nroot to the ServerTimestamp sentinel. Firestore transforms don't support array indexing.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "[1, {\"b\": \"ServerTimestamp\"}]" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-st-noarray.json b/dev/conformance/conformance-tests/update-paths-st-noarray.json new file mode 100644 index 000000000..5da60306b --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-st-noarray.json @@ -0,0 +1,22 @@ +{ + "tests": [ + { + "description": "update-paths: ServerTimestamp cannot be in an array value", + "comment": "The ServerTimestamp sentinel must be the value of a field. Firestore\ntransforms don't support array indexing.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "[1, 2, \"ServerTimestamp\"]" + ], + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-st-with-empty-map.json b/dev/conformance/conformance-tests/update-paths-st-with-empty-map.json new file mode 100644 index 000000000..a4b8ed131 --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-st-with-empty-map.json @@ -0,0 +1,69 @@ +{ + "tests": [ + { + "description": "update-paths: ServerTimestamp beside an empty map", + "comment": "When a ServerTimestamp and a map both reside inside a map, the\nServerTimestamp should be stripped out but the empty map should remain.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "{\"b\": {}, \"c\": \"ServerTimestamp\"}" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "mapValue": { + "fields": { + "b": { + "mapValue": { + "fields": {} + } + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + }, + "updateTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": 1 + } + ], + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-st.json b/dev/conformance/conformance-tests/update-paths-st.json new file mode 100644 index 000000000..011405b9b --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-st.json @@ -0,0 +1,61 @@ +{ + "tests": [ + { + "description": "update-paths: ServerTimestamp with data", + "comment": "A key with the special ServerTimestamp sentinel is removed from\nthe data in the update operation. Instead it appears in a separate Transform operation.\nNote that in these tests, the string \"ServerTimestamp\" should be replaced with the\nspecial ServerTimestamp value.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "fieldPaths": [ + { + "field": [ + "a" + ] + }, + { + "field": [ + "b" + ] + } + ], + "jsonValues": [ + "1", + "\"ServerTimestamp\"" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-paths-uptime.json b/dev/conformance/conformance-tests/update-paths-uptime.json new file mode 100644 index 000000000..96801a0cd --- /dev/null +++ b/dev/conformance/conformance-tests/update-paths-uptime.json @@ -0,0 +1,47 @@ +{ + "tests": [ + { + "description": "update-paths: last-update-time precondition", + "comment": "The Update call supports a last-update-time precondition.", + "updatePaths": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "precondition": { + "updateTime": "1970-01-01T00:00:42Z" + }, + "fieldPaths": [ + { + "field": [ + "a" + ] + } + ], + "jsonValues": [ + "1" + ], + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + }, + "currentDocument": { + "updateTime": "1970-01-01T00:00:42Z" + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-prefix-1.json b/dev/conformance/conformance-tests/update-prefix-1.json new file mode 100644 index 000000000..faad69d14 --- /dev/null +++ b/dev/conformance/conformance-tests/update-prefix-1.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: prefix #1", + "comment": "In the input data, one field cannot be a prefix of another.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a.b\": 1, \"a\": 2}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-prefix-2.json b/dev/conformance/conformance-tests/update-prefix-2.json new file mode 100644 index 000000000..96545c134 --- /dev/null +++ b/dev/conformance/conformance-tests/update-prefix-2.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: prefix #2", + "comment": "In the input data, one field cannot be a prefix of another.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"a.b\": 2}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-prefix-3.json b/dev/conformance/conformance-tests/update-prefix-3.json new file mode 100644 index 000000000..95f702496 --- /dev/null +++ b/dev/conformance/conformance-tests/update-prefix-3.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: prefix #3", + "comment": "In the input data, one field cannot be a prefix of another, even if the values could in principle be combined.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": {\"b\": 1}, \"a.d\": 2}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-quoting.json b/dev/conformance/conformance-tests/update-quoting.json new file mode 100644 index 000000000..10e3c35c2 --- /dev/null +++ b/dev/conformance/conformance-tests/update-quoting.json @@ -0,0 +1,47 @@ +{ + "tests": [ + { + "description": "update: non-letter starting chars are quoted, except underscore", + "comment": "In a field path, any component beginning with a non-letter or underscore is quoted.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"_0.1.+2\": 1}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "_0": { + "mapValue": { + "fields": { + "1": { + "mapValue": { + "fields": { + "+2": { + "integerValue": "1" + } + } + } + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "_0.`1`.`+2`" + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-split-top-level.json b/dev/conformance/conformance-tests/update-split-top-level.json new file mode 100644 index 000000000..eddf360d3 --- /dev/null +++ b/dev/conformance/conformance-tests/update-split-top-level.json @@ -0,0 +1,47 @@ +{ + "tests": [ + { + "description": "update: Split on dots for top-level keys only", + "comment": "The Update method splits only top-level keys at dots. Keys at\nother levels are taken literally.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"h.g\": {\"j.k\": 6}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "h": { + "mapValue": { + "fields": { + "g": { + "mapValue": { + "fields": { + "j.k": { + "integerValue": "6" + } + } + } + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "h.g" + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-split.json b/dev/conformance/conformance-tests/update-split.json new file mode 100644 index 000000000..e18c78bf6 --- /dev/null +++ b/dev/conformance/conformance-tests/update-split.json @@ -0,0 +1,47 @@ +{ + "tests": [ + { + "description": "update: split on dots", + "comment": "The Update method splits top-level keys at dots.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a.b.c\": 1}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "mapValue": { + "fields": { + "b": { + "mapValue": { + "fields": { + "c": { + "integerValue": "1" + } + } + } + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "a.b.c" + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-st-alone.json b/dev/conformance/conformance-tests/update-st-alone.json new file mode 100644 index 000000000..1a333f30c --- /dev/null +++ b/dev/conformance/conformance-tests/update-st-alone.json @@ -0,0 +1,31 @@ +{ + "tests": [ + { + "description": "update: ServerTimestamp alone", + "comment": "If the only values in the input are ServerTimestamps, then no\nupdate operation should be produced.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": \"ServerTimestamp\"}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-st-dot.json b/dev/conformance/conformance-tests/update-st-dot.json new file mode 100644 index 000000000..83422ca52 --- /dev/null +++ b/dev/conformance/conformance-tests/update-st-dot.json @@ -0,0 +1,31 @@ +{ + "tests": [ + { + "description": "update: ServerTimestamp with dotted field", + "comment": "Like other uses of ServerTimestamp, the data is pruned and the\nfield does not appear in the update mask, because it is in the transform. In this case\nAn update operation is produced just to hold the precondition.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a.b.c\": \"ServerTimestamp\"}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a.b.c", + "setToServerValue": "REQUEST_TIME" + } + ] + }, + "currentDocument": { + "exists": true + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-st-multi.json b/dev/conformance/conformance-tests/update-st-multi.json new file mode 100644 index 000000000..8105ec27f --- /dev/null +++ b/dev/conformance/conformance-tests/update-st-multi.json @@ -0,0 +1,51 @@ +{ + "tests": [ + { + "description": "update: multiple ServerTimestamp fields", + "comment": "A document can have more than one ServerTimestamp field.\nSince all the ServerTimestamp fields are removed, the only field in the update is \"a\".", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": \"ServerTimestamp\", \"c\": {\"d\": \"ServerTimestamp\"}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "c" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c.d", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-st-nested.json b/dev/conformance/conformance-tests/update-st-nested.json new file mode 100644 index 000000000..5a8e73237 --- /dev/null +++ b/dev/conformance/conformance-tests/update-st-nested.json @@ -0,0 +1,47 @@ +{ + "tests": [ + { + "description": "update: nested ServerTimestamp field", + "comment": "A ServerTimestamp value can occur at any depth. In this case,\nthe transform applies to the field path \"b.c\". Since \"c\" is removed from the update,\n\"b\" becomes empty, so it is also removed from the update.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": {\"c\": \"ServerTimestamp\"}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a", + "b" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-st-noarray-nested.json b/dev/conformance/conformance-tests/update-st-noarray-nested.json new file mode 100644 index 000000000..9f94501aa --- /dev/null +++ b/dev/conformance/conformance-tests/update-st-noarray-nested.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: ServerTimestamp cannot be anywhere inside an array value", + "comment": "There cannot be an array value anywhere on the path from the document\nroot to the ServerTimestamp sentinel. Firestore transforms don't support array indexing.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, {\"b\": \"ServerTimestamp\"}]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-st-noarray.json b/dev/conformance/conformance-tests/update-st-noarray.json new file mode 100644 index 000000000..02615bd3c --- /dev/null +++ b/dev/conformance/conformance-tests/update-st-noarray.json @@ -0,0 +1,13 @@ +{ + "tests": [ + { + "description": "update: ServerTimestamp cannot be in an array value", + "comment": "The ServerTimestamp sentinel must be the value of a field. Firestore\ntransforms don't support array indexing.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": [1, 2, \"ServerTimestamp\"]}", + "isError": true + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-st-with-empty-map.json b/dev/conformance/conformance-tests/update-st-with-empty-map.json new file mode 100644 index 000000000..abeceb03e --- /dev/null +++ b/dev/conformance/conformance-tests/update-st-with-empty-map.json @@ -0,0 +1,54 @@ +{ + "tests": [ + { + "description": "update: ServerTimestamp beside an empty map", + "comment": "When a ServerTimestamp and a map both reside inside a map, the\nServerTimestamp should be stripped out but the empty map should remain.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": {\"b\": {}, \"c\": \"ServerTimestamp\"}}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "mapValue": { + "fields": { + "b": { + "mapValue": { + "fields": {} + } + } + } + } + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-st.json b/dev/conformance/conformance-tests/update-st.json new file mode 100644 index 000000000..6249d8bda --- /dev/null +++ b/dev/conformance/conformance-tests/update-st.json @@ -0,0 +1,46 @@ +{ + "tests": [ + { + "description": "update: ServerTimestamp with data", + "comment": "A key with the special ServerTimestamp sentinel is removed from\nthe data in the update operation. Instead it appears in a separate Transform operation.\nNote that in these tests, the string \"ServerTimestamp\" should be replaced with the\nspecial ServerTimestamp value.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "jsonData": "{\"a\": 1, \"b\": \"ServerTimestamp\"}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + }, + "currentDocument": { + "exists": true + } + }, + { + "transform": { + "document": "projects/projectID/databases/(default)/documents/C/d", + "fieldTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/conformance-tests/update-uptime.json b/dev/conformance/conformance-tests/update-uptime.json new file mode 100644 index 000000000..9210a2cf0 --- /dev/null +++ b/dev/conformance/conformance-tests/update-uptime.json @@ -0,0 +1,38 @@ +{ + "tests": [ + { + "description": "update: last-update-time precondition", + "comment": "The Update call supports a last-update-time precondition.", + "update": { + "docRefPath": "projects/projectID/databases/(default)/documents/C/d", + "precondition": { + "updateTime": "1970-01-01T00:00:42Z" + }, + "jsonData": "{\"a\": 1}", + "request": { + "database": "projects/projectID/databases/(default)", + "writes": [ + { + "update": { + "name": "projects/projectID/databases/(default)/documents/C/d", + "fields": { + "a": { + "integerValue": "1" + } + } + }, + "updateMask": { + "fieldPaths": [ + "a" + ] + }, + "currentDocument": { + "updateTime": "1970-01-01T00:00:42Z" + } + } + ] + } + } + } + ] +} diff --git a/dev/conformance/runner.ts b/dev/conformance/runner.ts index 0c8f6019e..0e925aec6 100644 --- a/dev/conformance/runner.ts +++ b/dev/conformance/runner.ts @@ -13,6 +13,7 @@ // limitations under the License. const duplexify = require('duplexify'); +const mkdirp = require('mkdirp'); import {expect} from 'chai'; import * as path from 'path'; @@ -49,7 +50,10 @@ import api = proto.google.firestore.v1; type ConformanceProto = any; // tslint:disable-line:no-any /** List of test cases that are ignored. */ -const ignoredRe: RegExp[] = []; +const ignoredRe: RegExp[] = [ + // TODO(chenbrian): Enable this test once update_transforms support is added. + new RegExp('update-paths: ServerTimestamp beside an empty map'), +]; /** If non-empty, list the test cases to run exclusively. */ const exclusiveRe: RegExp[] = []; @@ -69,7 +73,7 @@ const protoDefinition = protobufRoot.loadSync( path.join(__dirname, 'test-definition.proto') ); -const TEST_SUITE_TYPE = protoDefinition.lookupType('tests.TestSuite'); +const TEST_SUITE_TYPE = protoDefinition.lookupType('tests.TestFile'); const STRUCTURED_QUERY_TYPE = protoDefinition.lookupType( 'google.firestore.v1.StructuredQuery' ); @@ -148,7 +152,10 @@ const convertInput = { precondition: (precondition: string) => { const deepCopy = JSON.parse(JSON.stringify(precondition)); if (deepCopy.updateTime) { - deepCopy.lastUpdateTime = Timestamp.fromProto(deepCopy.updateTime); + deepCopy.lastUpdateTime = Timestamp.fromProto({ + seconds: deepCopy.updateTime.seconds, + nanos: deepCopy.updateTime.nanos, + }); delete deepCopy.updateTime; } return deepCopy; @@ -514,17 +521,91 @@ function runTest(spec: ConformanceProto) { ); } +/** + * Parses through the TestFile and changes all instances of Timestamps encoded + * as strings to a proper protobuf type since protobufJS does not support it at + * the moment. + */ +function normalizeTimestamp(obj: {[key: string]: {}}) { + const fieldNames = ['updateTime', 'createTime', 'readTime']; + for (const key of Object.keys(obj)) { + if (fieldNames.includes(key) && typeof obj[key] === 'string') { + obj[key] = convertTimestamp(obj[key] as string); + } else if (typeof obj[key] === 'object') { + normalizeTimestamp(obj[key]); + } + } +} + +/** + * Convert a string TimeStamp, e.g. "1970-01-01T00:00:42Z", to its protobuf + * type. + */ +function convertTimestamp(text: string): {[key: string]: number} { + const split = text.split(':'); + const secondsStr = split[split.length - 1]; + + // Remove trailing 'Z' from Timestamp + const seconds = Number(secondsStr.slice(0, secondsStr.length - 2)); + const frac = seconds - Math.floor(seconds); + + return { + seconds: Math.floor(seconds), + nanos: frac * 1e9, + }; +} + +/** + * Parses through the TestFile and changes all instances of Int32Values encoded + * as numbers to a proper protobuf type since protobufJS does not support it at + * the moment. + * + * We must include a parent field to properly catch which fields are standard + * values vs. Int32Values. In this case, the 'limit' field in 'clauses' has + * Value type, but the 'limit' field in 'query' has Int32Value type, resulting + * in the need for an extra layer of specificity. + */ +function normalizeInt32Value(obj: {[key: string]: {}}, parent = '') { + const fieldNames = ['limit']; + const parentNames = ['query']; + for (const key of Object.keys(obj)) { + if ( + fieldNames.includes(key) && + typeof obj[key] === 'number' && + parentNames.includes(parent) + ) { + obj[key] = { + value: obj[key], + }; + } else if (typeof obj[key] === 'object') { + normalizeInt32Value(obj[key], key); + } + } +} + describe('Conformance Tests', () => { const loadTestCases = () => { - const binaryProtoData = require('fs').readFileSync( - path.join(__dirname, 'test-suite.binproto') - ); - - // We don't have type information for the conformance proto. // tslint:disable-next-line:no-any - const testSuite: any = TEST_SUITE_TYPE.decode(binaryProtoData); + let testDataJson: any[] = []; + const fs = require('fs'); + + const testPath = path.join(__dirname, 'conformance-tests'); + const fileNames = fs.readdirSync(testPath); + for (const fileName of fileNames) { + const testFilePath = path.join(__dirname, 'conformance-tests', fileName); + const singleTest = JSON.parse(fs.readFileSync(testFilePath)); + + // Convert Timestamp string representation to protobuf object. + normalizeTimestamp(singleTest); + + // Convert Int32Value to protobuf object. + normalizeInt32Value(singleTest); + + const testFile = TEST_SUITE_TYPE.fromObject(singleTest); + testDataJson = testDataJson.concat(testFile); + } - return testSuite.tests; + return testDataJson.map(testFile => testFile.tests[0]); }; for (const testCase of loadTestCases()) { diff --git a/dev/conformance/test-definition.proto b/dev/conformance/test-definition.proto index 74e4ec706..c06a699ea 100644 --- a/dev/conformance/test-definition.proto +++ b/dev/conformance/test-definition.proto @@ -15,13 +15,14 @@ import "google/firestore/v1/query.proto"; import "google/protobuf/timestamp.proto"; // A collection of tests. -message TestSuite { +message TestFile { repeated Test tests = 1; } // A Test describes a single client method call and its expected result. message Test { string description = 1; // short description of the test + string comment = 10; // a comment describing the behavior being tested oneof test { GetTest get = 2; diff --git a/dev/conformance/test-suite.binproto b/dev/conformance/test-suite.binproto deleted file mode 100644 index 6e3ce397375224cab4ee93e9ae05495a182bc983..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 55916 zcmdsA3v?V;dCtsAwtVd*$~X^u5|YWpBxWs3(b%yQ5tDdhyF{^LVkaaJf<4+DS(~hO zm7SFxV>S@Vqoh0=punL(p@s4ew1onN@@NaC6bfx9l=g6-htdO-LMi1OP7D3+Yjz&H ztJynaIcm;{w3e-V|NGtl|L=eQ*Cj8~$ogYmYs$hG%e5+v^5VQ#Zy9y6eWBU7*DJUD z3Gw0PJrfnT<<7Xi=TB^|c(d+et@We{`78d!O%oMkhuZIv&uZlCa?^8L-jszIs%7(o zn%Ypt$SK>kr>x1g*&tV@TZFOK)<@1FHz>}ynrN<}k80#yIyqOaqTHBYsCf^VuhkVt z-Nx5(_vD!6j9+ulm}SpkS*PqWzTR!O=9->okKxZ1{JGU!^xF5d+vYp9)N5|DHJ?zV z?n1ie^QO-wblqzCBO3X# zMm7gn(Vef>k6DeT<$Epm(XCtF{6g!bHSaE%Z&PIk{Z!kWO%2KQ3=&lyen=-zkSnS* z>fd?(8(NmXP^-4AMjevX^389lF5|LOmhFzS{kQD$INkC|s|}X$@X4{-CgeCRuiwoU zd57Y@pHB)P#5mhoOV*GANTG~xU{^hS(8&w+&aT!Q^{sAgVa~P6b8gcux4forRqJ#^ zt^2%_zWEQTa9j*HidZ?mjR#OXD4=*KJrs8`C~i}PVw7k_L-6#tgyBI3!%4D9a>5?3 z=CwSl?AGfIsMv)C&uvl^s4g{Cr@lz&IH445K8fA7H1fs*xk}FM)@o15rPF30VG3%N!YsWop^K0q1FdxlrcurZ73x=WaAOYt=-8t)+Hl%W( zj~3{UDpT}FL->Cf|F0q+)XC*?b7GiTC#tPE&K19@x-B>j*wH81A~uEHHXmJfWN&bG zWkQyGQYV*4%sT88g6nrw;kq&km*B@Zx3itt_TJaEd_q%LCEA*gUm8fCZEtd3cU^;=T)qjY+18auU0W%lM|BM%(G*Y*s$Hlc$z@W81%4q>=Fq)E6}qiaCX^O(XM)ht0{}m{>;N8cZc&ux z^@IW#ljkq$#Oekn7dyd-?^H!|ybqd5!Cr}Q#$@|jddFaz$Cb82e_RT+3MfHX# zstLgs1{1%{CH@v%`_X0R+NV1E6uDNIM622T0Mh?Uo!F9L1B5%`$vGC+0ab8siGthX z9FIU8`!|8<**3qj>_8uNo~;OU@~}6cF>onk8lz)&K2#uAbl-rm&hX7|sP4dlt~-!W z7u~iX_(v;v526}H>_N=*|B_C&$UTT1>(-3tS1XLj2Zqi#Co zqqXZHL^{D8|PNx$_Vgu z=^fuX?$#DP^O=eyikmBQc6LFLLHImUlq5x+DqShb=vtAK2+s;5;1P|COA0znl;E#0 z9}CU|NI+EhKL7bj?w-aAIp+colJNm5rPTY{{LBF7cu zWF?gw<2er8?`!1x2$cz@TY^kak<2YU$P8<>5S`!FIzIV07rM1Z-8278)d{_UQHPn^m_Tp)z|WH5S(r)iBvFG-9%)bd8bO-&Cc4 zsTi3(NMMMlYWF4LWB()fajD>#{Z&;Q`US`AcIpj2OjIqXK5?<*h2a&9WkV`lDLEKpeaa@?rJh+mES2pKnNO zMS&kx9^J!PpF^T213#`vy2P?s}*@{6dbHE@L zuF>zxN~&T6%N#U<1zKOBk*m8hXrH)Da=i51mf^kZ={P)3kvrkc1fHScfE`w$Ct4Z_&uECAg-4V8d1nS(&LqRzU6L@C$b5 zqa_Ga^k|y>;#HvMts1$uvx_WwHWU$Ef+odal{rAL3M3*Fd0mIZ1fwlMqhh4W93)Z& zB2g#A-Qw{Bm4&J7|5kMe_Y6}F68TW}_8Xb}UNpM(PpAxIn|Hu#9`knBYW5ctp`c|) z<|vQa(cA}GPUE!g=caZ89x_)Ukp&6X$_51LWRU+ds?&lQUNZJ#X~fFq@w9B=ZV|UK zL@||o1#HC|PuX)=DQabo;oCMWd=}rgTkW>}()32t5tER@-1sd0a!ffiu#sqU#`%sx z%fMy<#1Q>(3?B;QUl6IqK5w0;+dO44I5-wAPY|>}t%}01Q2^XswtgY?*6%av5ZQyB zztY%6yz45%dv2oyMs3SS3^3^&P^Iw@w()G=kzL33{TgihsnpB9%^c<%p21?ClbK(1 zpNGiHxGN%x0OND3>RYTv%Bp$ptPO@xLx64foOzjCK4o_l7BLuh$fCKOZTki3x&JP@ z{d2jo{jg;FRRqycdWns~!JO0kXhFf#+}0c}v8qroW+)QvLDM+JE9PukCdbM}+xGKP z^T8b^DmRZ7kB%RG@Tju#3&#afCO4uH#58QC+v8^*13+p-W%n{ue@h2~P-&bt5R{V| z$aX5C+>HDX)w5lZW7Y!Kn*n~xDK7ND>}@|(Q^S_o2>1%TI3X$N%`R4B)|zRckWQSO zuUB;c7=)b}^vjIA-AS7vnek(5At&67iz-aJe7ZyZ^wkC8RYSZNH}xl>MRe??U( ziQ{-_!Ce01`2{-J7R3ZhZZs>^y4w^fuB?o@-Mum-L zs?Y=3nx~c-7c8z|V$5Q{PgU5&i489gH(0_ac2e4Kl+&_zoZtf#W*+1xcpi2PHC%_Y zWw67B2GC#C$yA8jQUh)AE8!y<;fAZGV;}Z|`Q7Oc$Xy&}#oVwwK>ZI* zP|Tpb{qeef*g`ba-h2Ijt-5|@KBrpx0P2}usp!5d$_V*7^8K+~aYcqhgu2^MLWEu; zUbzapr^2-}@18>2OpM#Vr-}e&dzu(pNzK|*=2^;1Ll=|q@ykwGVaZwZi$2H0kUn2QS#N7>=3_+dq%3?=HfQj6s@J(yjT8=wwN5&FPq z`60Bql1mXu`$g4qMYW{;N7Gv*FVdvfmM#8_W$+`f{TvAz=hq@wLg`%YndxkwNX-ui zBB*3$3FMZXA6*?cQj342x<(;FL2IKyic&hfu6oG+8}jt!dTOrU+RFd1wS^W(RBewG=?%w4J7;W)Tc2#c`_bSe@7P@tu^+KDZley$PIhj!BS4DQ~kzPhi?g z$>}kLlW7VJ%qC!~U{lN`SFx>lSaB7I_)yyA=|h*oTE?-Nd~%t@D{9@quHq4h;?or8 z#i87pHxOKkAUrv8(!CE<{T7UZkPK1Vsai(?akWxZ?KwdW)vyUi3;*PlF+YXSOsZbd zJ|5A*3jegMg?~TN$OgH_P+AA`4ir^yy7HFStNhbGnOaXBq$h5cPF8NL^UaTOw~s7X z#Pa!yl`EzYDWZJatIE2)tV@n2-;uYVou6Ft62(i!pDH?p%+p-F1k)#NfF(yWb-AjT zXo-Z}p}3|As!WQ?B@#=!$p^@s&J*5DK^^L6rX>;*xRCnlV5VFmk+!G_83kv8F>|eM zq9qa$6opRgz^Ggzk-ETXMdBD!w7_wb#IawoQ}IozS~dn}?_#F`N_O(S#%1%r^TH9fm`HW#BUB=%BYIUhFtnG zs!ye7{lgtEYlf_f)6*AFqN-R@Rb0N3D%uw?E49m5RfWjtHc4)rW&4!w6i;Vi75V~7 zk`f+G-tp1xbSNxl>@L%-wu<%zloW){w0?NFis#$_dis@YjTRGyT}T`_MMW*1WzqN+i9w^qJ04+NnM$239^=_)Qa{6j8K_ix+Tb5rfRDn zXygJ(XXK3@b-(#K7CRcJ&2}f-_QUB9(xc{TGK{bjewBvj6%~|$+8USD)*#P*M%G-E zk*lbYx9FWihG!YJ@EDJUw_2L)ttI+C4-#6?hV%Z#1|ByUv%Ck&-a-qhBo#c`Q*Jc9 zqHwH5QNpdmO!l>AOXE&Z%~?h%_v7JW>X@yu98WNWR{B&79;w~ zl}>)9kta!|5kI=PyEP2Y=Tzajq@zfZS-JN8sbTpwii5LTZIg^OLMK6exSgn*2-9|6 z^eXOA8{Z^Y<%6^YlST2rh<6A%v|CvQf@o&yD5sCGY$t89cxE!B5EBx|i(HP#lX8^3 z$8ptw_$YwMoo3OD>Ae7bH)qK2{_X z3OPGL*fgi#JdW}_OrlYfKr?Nz7(UN@uk~zm4k^MFnx|qTw}>BBe7X}dJy0@y;+Du` zUyfpGItLLskaSY1wA#S4MaH80)<2)hQ9Pbm>8y}5%=%qTdX43JXQzMr~;SF82`4aJNt&;BIOT4H@T2=83W>x){CL^|TbJ?QB&7H6MZ!@iW zL$B1TWnFgEB~RX7kXJsr>?QK6oS&%1M3^SQml?_gW%{K;6<3nq?Oyz0Cm@v1CDDs{ z+KW=2=|9W#V(Q0&5Ut#$xaJ8GU7S~B-k&3do z0pizrGH9+@R)3|(55TaF>_GXuxj>l^cDPE|qb4g8%b4N?mLgyyxw2orm80A|GSIqI zs?o-x`!i_86`gJMH9c;K_Q<(%-kS?&q6C`4*u#ox7gug-P%PCP9g{`LLX1hna?kRv z9M!f5%p#;;*ewQ0=pkge@fCi!b_GKllm8zCzIF+1kP#F=+Zn*VgAV@cHaA0fu7%vk;&iG6n?D|C}Gtz03g{DuluvQz6ovZ5LN+#!pm% zh>V}uL#!_^$OuA$^%HuP9`JIzMMOCPW677wfO%a3+n?K*&9VxF&E33&7k}3t72+~#vEf?j6-(YJ@9co znj6K(vQWIai?5^?$+Xu&6y(_2Lj4XB$v%!^uLG)6TzjKTgo@2*Qz(BOy|<%uCETM) zat>xeZB&xOCt_6mHhfl5DnbWdpX4m(NES*gK}nZwTnl6+ja%GYrop#dR zp^<%2(qbDNVyXVAJkGPS!1x3Tqi}!6D6rd<$B^E(D@tgB$CjW^F_DDx|M?;M1kW+D z-l>t@QL?%+-4dkDWP$FA4rxj4C*DQ{fN17l>OyIP36~(XoQ2d)2~qW2GHcKoHC(D(X?DAJEGgOPd0?L z#F}}^7H!cONnvxor@DT$c*a6VVHWvG$j_*cH(;pmY!_db-o;#_DO*P|3Np4Z3{Tlo zZT52+qsQ3bTuAV)CWe!lN}voGIjafMwnSZ&&y{N3a9y zoy)%;rPoKz84Qf|WQ4WNeb&*VK?B`P=}E})E6NVqXrc>7LBi5emY#$bJfdfb1fwGp zKJN)u0q3+l2N54NM8F`kjRyLcxlQad`@D*eNx|u4S0E!gZA_wSUO-l3&~c1O2>l=i zq~fI5$HSo9(r8F-!N?4$Bk|x~JjSltkiir|_2Y4Odu0*1gk|)63acm8_8O5}oy)n= z*0w>Fe?CZ8mOI~VV$K3Id9l;Q)puT|$_p`adfxX_M7iW;6HCF>=L*gMQx^Zu$ZjmQ zA}vFvU_z;}@X^$qxx-MJf&8OJCc7-b>YEcYrQD*A_Ys;+y{zkP_8W?eL!#bQ-4^F1 z+qz8QX%Hm@S@OXE9S5mGRb0+}#JqpeYo464xGp#h1zB!c<(j+bd!+-!S!g!y#ZUYR z@!{q@6SSq`jO%;;#O8`O>n_$>PnxJS%8S$t@h5IFbaIxto~%O)>5(Hx>h8RE{UGFKBT{=RZz1iuqe7 z8ff(#TB=`qM)o=Jss&6T8sT0?&^^%5%6#4hvR=%4CwlC85?!?!&o9r3L%ZG_wsG9p z=2lM3m1GkbG9YP)lEnWxwqg|h=pNSC(fLBilAzMH!ZcbmThwh<>&K9KZq*lSHO1`_ zG~%g|UAxR7I*>WaX|AUjNk&dI2e z%LEk%XJ^q?(sJt+YkzgVD#g(+-K;ddZs~@;xnQnkD=+FJg{yVaCY!}C@J=s5(_INFNrGwwbusLah{7|!(2`Bz zOHa)K7%bnSnV`0qEx!8P=bNVU!IIh(UEV}&VsvI(^!(C74oe(%zvMEkkiBV?8C>sJrt4s9j8iIs@2tQDQ zIDgV(RgeVNtcvX*1XxIl5a1bu39vEZtfJs)*BWa|tAU@PPhKs~94X8~s%J*^DMCrc z|04htg-#$`A0@Q5M?zX&Z2Bl}n)h0Bjf%J+N`s~J?`rg~r*;Pk**#R?N2XR8L-w9Y z+ZdTz{Q)#%2|-sXmL~2^6Tz` zKi6oL9#h-P{f_EOse26Z%-T*`(FGsUwQcjZ?)yDOb`(`E33~v=mvwUEU{KJ)Mzo)# zh814*pa*UVE~MNAb^lbJ$W^1dNFLz29hDt@>P9K?s+f|`=;W5c5M@>xnvQ$-FQR`Z z&chR76Ce51D&TfZZJ4bPjs2xO@q9MJvvXw_hJ9X$fvJ`7q{gBh6tCwfPUnf@d<;dMp~#F&7;_0YpTc-k5mLzd4|Q@^H&Dl@z6(^{82ZR| z#c+&a92b6h6Mdx`z)|~}U-;-X2NyzZyOFQ@jKhs*8AgZXsh?B@S>b-HKz5~pJAr6m zKs-`V68#vaUG0fnk4aW@@CHN$sjOYMdixVr~q! zv_|02i!UvDoma(@`q9|p*u@zu^tv0V>|~)Xa%t4;QUa6PqnPGo;EIWb-UB8nJzZ&r zON~o9o}gr408<|$7YeI(Oc{V)9a0{ zd)*?JCiXfy{h=JDUpI{#rYxbv@?W9_4wmT7N2hjknEK-BjYc0f!1K%UE*|59C@Fb3 z-7c9njebn==Ng$3n-MmsxXpT^*}#pd+^Err0ekGIZbeDN%S|eV{(2aw*PuvZh6$>6eCCQmdo(C z&as`+=}vJD(aCl8PDKU~LlknM4KY4OTcJbS(2C(7&3IFGP7ij+*pDb)R!$E_qwHeB#!m{Wc0h7;)sd15R~;#^ ze1bj6!obNDh8Wm*hPu&{TySV$OUp8J5`pm0^ytyaM~282DHkwUrG;u$XRQ++#Z*h6c9iY&v<&AUh=I1c^K{0_wx-U#ZY`rraRMWd@OYelAz0-)Lmn>tNM^VAH+M zpc|7Sm~p@WzF=Q64!B)vZ^_=tTU-_Zu93sDd#Jo5DqlIak-N;NqnWPag%#aD(VBiV zV!Tq*i`_XgZ1WDe$_U>muhPk~%I&nrDP83++YRpm>5l2t<&oh$<ekkyd^2zd8gPbIE5Eq!kJk!l5fG9G27@|zW2jVM-4>^yA z4fUH(K(;g^vfrTsrpxun)LsAl|J*_I06l-pDQt;&Z%QjVcSI%i-O z2X&HA9Qy_1r#Y@%^*~LsdY1i8juzkVVe%d1Q%Q}yN2K_QTKySs&OPq=R;_xUXUV_g z=@ZlM$v5PZxbmR`iIXuXluPVS^0JmipaWhGMhoo&crPypaWH&HP?$U8ts`VoZt}ir zjXu)S^!$ZJ-4_)wKFSF#zxo`{s-pTI(cP_$h3W6-6HyGP%IGHu#8#^7E=-f*j0}V& zGQ9E)dXfwk>Ej+E-jU}qrL3ote3*r+llu|k>MUw2NoHtZaZG(l`K(Toomp829Fxm| z7syNWz{_w=NwRhvP@TMJh}Md8^^uM5ft(r^IAu$$UG1y12Q>S zUc&hFr%(H#kU_qaT;+695b}s62K$ypsFGBMwrV+!if^L$Me@PzY_B;N9NE2RPv~%< zF%(3p=UktrqFC(w;H+WYyl47#`K0v(h|-gTUnkZYYj9j@8ZwKdZq-)K=8+F;WKUmo zQSs7j(yZwKUWiw9b{6&RXhzgQxSq=$xi`Ri7~l=8nsaMc!Vm2|aPaASEfj<;)+#U@ XkdCyl;JMA|W2cKk$_T;UZ_xe^@qaSD diff --git a/package.json b/package.json index 619cfbdd8..129d92386 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "lint": "gts check", "clean": "gts clean", "compile": "tsc -p .", - "postcompile": "cp -r dev/protos build && cp dev/src/v1beta1/*.json build/src/v1beta1/ && cp dev/src/v1/*.json build/src/v1/ && cp dev/conformance/test-definition.proto build/conformance && cp dev/conformance/test-suite.binproto build/conformance", + "postcompile": "node scripts/init-directories.js && cp -r dev/protos build && cp dev/src/v1beta1/*.json build/src/v1beta1/ && cp dev/src/v1/*.json build/src/v1/ && cp dev/conformance/test-definition.proto build/conformance && cp dev/conformance/conformance-tests/*.json build/conformance/conformance-tests", "fix": "gts fix", "prepare": "npm run compile", "docs-test": "linkinator docs", diff --git a/scripts/init-directories.js b/scripts/init-directories.js new file mode 100644 index 000000000..adc337c41 --- /dev/null +++ b/scripts/init-directories.js @@ -0,0 +1,21 @@ +// Copyright 2019 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 mkdirp = require('mkdirp'); + +// We have to manually add the directory here because the docker image that +// runs CI does not have this directory. We also can't use `mkdir -p` in the +// package.json file because CI is also run on Windows, which does not support +// the `-p` flag. +mkdirp.sync('build/conformance/conformance-tests'); From c0e39a555b748605b2ebbe002be83a8a46d91d1b Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Mon, 23 Mar 2020 20:18:41 -0700 Subject: [PATCH 090/337] docs: document version support goals (#983) --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index e2381d368..ba729e8a8 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,27 @@ has instructions for running the samples. The [Cloud Firestore Node.js Client API Reference][client-docs] documentation also contains samples. +## Supported Node.js Versions + +Our client libraries follow the [Node.js release schedule](https://nodejs.org/en/about/releases/). +Libraries are compatible with all current _active_ and _maintenance_ versions of +Node.js. + +Client libraries targetting some end-of-life versions of Node.js are available, and +can be installed via npm [dist-tags](https://docs.npmjs.com/cli/dist-tag). +The dist-tags follow the naming convention `legacy-(version)`. + +_Legacy Node.js versions are supported as a best effort:_ + +* Legacy versions will not be tested in continuous integration. +* Some security patches may not be able to be backported. +* Dependencies will not be kept up-to-date, and features will not be backported. + +#### Legacy tags available + +* `legacy-8`: install client libraries from this dist-tag for versions + compatible with Node.js 8. + ## Versioning This library follows [Semantic Versioning](http://semver.org/). From b9ecc6e0043c4fd9628f540e9945368bae444cdd Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 24 Mar 2020 09:59:55 -0700 Subject: [PATCH 091/337] refactor: drop duplicate constructor (#966) --- dev/src/document.ts | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/dev/src/document.ts b/dev/src/document.ts index e0bc273c5..55ffbad44 100644 --- a/dev/src/document.ts +++ b/dev/src/document.ts @@ -515,26 +515,6 @@ export class DocumentSnapshot { export class QueryDocumentSnapshot extends DocumentSnapshot< T > { - /** - * @hideconstructor - * - * @param ref The reference to the document. - * @param fieldsProto The fields of the Firestore `Document` Protobuf backing - * this document. - * @param readTime The time when this snapshot was read. - * @param createTime The time when the document was created. - * @param updateTime The time when the document was last updated. - */ - constructor( - ref: DocumentReference, - fieldsProto: ApiMapValue, - readTime: Timestamp, - createTime: Timestamp, - updateTime: Timestamp - ) { - super(ref, fieldsProto, readTime, createTime, updateTime); - } - /** * The time the document was created. * From 0f492042a94019f233973e90ba6a2824f0630825 Mon Sep 17 00:00:00 2001 From: wu-hui <53845758+wu-hui@users.noreply.github.com> Date: Tue, 24 Mar 2020 16:52:05 -0400 Subject: [PATCH 092/337] Use Random Number from `crypto` to generate AutoId. (#984) * Use Random Number from `crypto` to generate AutoId. * Fix lint --- dev/src/util.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dev/src/util.ts b/dev/src/util.ts index d7a690ce7..d04253699 100644 --- a/dev/src/util.ts +++ b/dev/src/util.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import {randomBytes} from 'crypto'; import {GoogleError, ServiceConfig, Status} from 'google-gax'; import {DocumentData} from './types'; @@ -52,8 +53,17 @@ export function autoId(): string { const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; let autoId = ''; - for (let i = 0; i < 20; i++) { - autoId += chars.charAt(Math.floor(Math.random() * chars.length)); + while (autoId.length < 20) { + const bytes = randomBytes(40); + bytes.forEach(b => { + // Length of `chars` is 62. We only take bytes between 0 and 62*4-1 + // (both inclusive). The value is then evenly mapped to indices of `char` + // via a modulo operation. + const maxValue = 62 * 4 - 1; + if (autoId.length < 20 && b <= maxValue) { + autoId += chars.charAt(b % 62); + } + }); } return autoId; } From 6e7cb1efeee4079f2d2ebbd2485aa6cf5d33c0b3 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 25 Mar 2020 01:13:30 -0700 Subject: [PATCH 093/337] chore: regenerate the code (#982) This PR was generated using Autosynth. :rainbow:
Log from Synthtool ``` 2020-03-22 04:27:11,234 synthtool > Executing /tmpfs/src/git/autosynth/working_repo/synth.py. 2020-03-22 04:27:11,284 synthtool > Ensuring dependencies. 2020-03-22 04:27:11,289 synthtool > Cloning googleapis. 2020-03-22 04:27:11,962 synthtool > Pulling Docker image: gapic-generator-typescript:latest latest: Pulling from gapic-images/gapic-generator-typescript Digest: sha256:3762b8bcba247ef4d020ffc7043e2881a20b5fab0ffd98d542f365d3f3a3829d Status: Image is up to date for gcr.io/gapic-images/gapic-generator-typescript:latest 2020-03-22 04:27:12,862 synthtool > Generating code for: google/firestore/admin/v1. 2020-03-22 04:27:14,020 synthtool > Generated code into /tmpfs/tmp/tmp26u_g07g. 2020-03-22 04:27:14,020 synthtool > Pulling Docker image: gapic-generator-typescript:latest latest: Pulling from gapic-images/gapic-generator-typescript Digest: sha256:3762b8bcba247ef4d020ffc7043e2881a20b5fab0ffd98d542f365d3f3a3829d Status: Image is up to date for gcr.io/gapic-images/gapic-generator-typescript:latest 2020-03-22 04:27:14,938 synthtool > Generating code for: google/firestore/v1beta1. 2020-03-22 04:27:16,110 synthtool > Generated code into /tmpfs/tmp/tmpswz50gpr. 2020-03-22 04:27:16,110 synthtool > Pulling Docker image: gapic-generator-typescript:latest latest: Pulling from gapic-images/gapic-generator-typescript Digest: sha256:3762b8bcba247ef4d020ffc7043e2881a20b5fab0ffd98d542f365d3f3a3829d Status: Image is up to date for gcr.io/gapic-images/gapic-generator-typescript:latest 2020-03-22 04:27:17,022 synthtool > Generating code for: google/firestore/v1. 2020-03-22 04:27:18,286 synthtool > Generated code into /tmpfs/tmp/tmp547gw0gm. 2020-03-22 04:27:18,356 synthtool > Replaced 'return this\\._innerApiCalls\\.listen\\(options\\);' in dev/src/v1beta1/firestore_client.ts. 2020-03-22 04:27:18,356 synthtool > Replaced 'return this\\._innerApiCalls\\.listen\\(options\\);' in dev/src/v1/firestore_client.ts. .eslintignore .eslintrc.yml .github/ISSUE_TEMPLATE/bug_report.md .github/ISSUE_TEMPLATE/feature_request.md .github/ISSUE_TEMPLATE/support_request.md .github/PULL_REQUEST_TEMPLATE.md .github/publish.yml .github/release-please.yml .github/workflows/ci.yaml .kokoro/common.cfg .kokoro/continuous/node10/common.cfg .kokoro/continuous/node10/docs.cfg .kokoro/continuous/node10/lint.cfg .kokoro/continuous/node10/samples-test.cfg .kokoro/continuous/node10/system-test.cfg .kokoro/continuous/node10/test.cfg .kokoro/continuous/node12/common.cfg .kokoro/continuous/node12/test.cfg .kokoro/continuous/node8/common.cfg .kokoro/continuous/node8/test.cfg .kokoro/docs.sh .kokoro/lint.sh .kokoro/presubmit/node10/common.cfg .kokoro/presubmit/node10/docs.cfg .kokoro/presubmit/node10/lint.cfg .kokoro/presubmit/node10/samples-test.cfg .kokoro/presubmit/node10/system-test.cfg .kokoro/presubmit/node10/test.cfg .kokoro/presubmit/node12/common.cfg .kokoro/presubmit/node12/test.cfg .kokoro/presubmit/node8/common.cfg .kokoro/presubmit/node8/test.cfg .kokoro/presubmit/windows/common.cfg .kokoro/presubmit/windows/test.cfg .kokoro/publish.sh .kokoro/release/docs.cfg .kokoro/release/docs.sh .kokoro/release/publish.cfg .kokoro/samples-test.sh .kokoro/system-test.sh .kokoro/test.bat .kokoro/test.sh .kokoro/trampoline.sh .mocharc.js .nycrc .prettierignore .prettierrc CODE_OF_CONDUCT.md CONTRIBUTING.md LICENSE README.md codecov.yaml renovate.json samples/README.md 2020-03-22 04:27:19,093 synthtool > Replaced "/protos/protos'" in dev/src/v1/firestore_client.ts. 2020-03-22 04:27:19,094 synthtool > Replaced "/protos/protos'" in dev/test/gapic-firestore-v1.ts. 2020-03-22 04:27:19,094 synthtool > Replaced "/protos/protos'" in dev/src/v1/firestore_admin_client.ts. 2020-03-22 04:27:19,094 synthtool > Replaced "/protos/protos'" in dev/test/gapic-firestore_admin-v1.ts. 2020-03-22 04:27:19,094 synthtool > Replaced "/protos/protos'" in dev/src/v1beta1/firestore_client.ts. 2020-03-22 04:27:19,095 synthtool > Replaced "/protos/protos'" in dev/test/gapic-firestore-v1beta1.ts. npm WARN npm npm does not support Node.js v12.16.1 npm WARN npm You should probably upgrade to a newer version of node as we npm WARN npm can't make any promises that npm will work with this version. npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11. npm WARN npm You can find the latest version at https://nodejs.org/ npm WARN deprecated @types/moment@2.13.0: This is a stub types definition for Moment (https://github.com/moment/moment). Moment provides its own type definitions, so you don't need @types/moment installed! > protobufjs@6.8.9 postinstall /tmpfs/src/git/autosynth/working_repo/node_modules/protobufjs > node scripts/postinstall > @google-cloud/firestore@3.7.1 prepare /tmpfs/src/git/autosynth/working_repo > npm run compile npm WARN npm npm does not support Node.js v12.16.1 npm WARN npm You should probably upgrade to a newer version of node as we npm WARN npm can't make any promises that npm will work with this version. npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11. npm WARN npm You can find the latest version at https://nodejs.org/ > @google-cloud/firestore@3.7.1 compile /tmpfs/src/git/autosynth/working_repo > tsc -p . > @google-cloud/firestore@3.7.1 postcompile /tmpfs/src/git/autosynth/working_repo > cp -r dev/protos build && cp dev/src/v1beta1/*.json build/src/v1beta1/ && cp dev/src/v1/*.json build/src/v1/ && cp dev/conformance/test-definition.proto build/conformance && cp dev/conformance/test-suite.binproto build/conformance npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.1 (node_modules/chokidar/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) added 590 packages from 371 contributors and audited 1378 packages in 21.364s found 0 vulnerabilities npm WARN npm npm does not support Node.js v12.16.1 npm WARN npm You should probably upgrade to a newer version of node as we npm WARN npm can't make any promises that npm will work with this version. npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11. npm WARN npm You can find the latest version at https://nodejs.org/ > @google-cloud/firestore@3.7.1 fix /tmpfs/src/git/autosynth/working_repo > gts fix installing semver@^5.5.0 installing chalk@^2.4.1 installing uglify-js@^3.3.25 installing espree@^3.5.4 installing escodegen@^1.9.1 installing estraverse@^4.2.0 2020-03-22 04:28:16,622 synthtool > Wrote metadata to synth.metadata. ```
--- .github/workflows/ci.yaml | 8 ++++---- dev/src/v1/firestore_admin_client.ts | 12 +++++++++--- dev/src/v1/firestore_client.ts | 12 +++++++++--- dev/src/v1beta1/firestore_client.ts | 12 +++++++++--- dev/synth.metadata | 14 +++++++------- dev/test/gapic-firestore-v1.ts | 2 +- dev/test/gapic-firestore-v1beta1.ts | 2 +- dev/test/gapic-firestore_admin-v1.ts | 2 +- 8 files changed, 41 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c5cbc5540..92394b1e4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,7 +11,7 @@ jobs: matrix: node: [8, 10, 12, 13] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node }} @@ -30,7 +30,7 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: 12 @@ -39,7 +39,7 @@ jobs: docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: 12 @@ -48,7 +48,7 @@ jobs: coverage: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: 13 diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index 0787ec706..96c5f19f6 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// 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. @@ -42,7 +42,12 @@ const version = require('../../../package.json').version; * @memberof v1 */ export class FirestoreAdminClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; private _innerApiCalls: {[name: string]: Function}; private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; @@ -307,7 +312,8 @@ export class FirestoreAdminClient { if (this._terminated) { return Promise.reject('The client has already been closed.'); } - return stub[methodName].apply(stub, args); + const func = stub[methodName]; + return func.apply(stub, args); }, (err: Error | null | undefined) => () => { throw err; diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 5a6339187..4a0630f95 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// 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. @@ -47,7 +47,12 @@ const version = require('../../../package.json').version; * @memberof v1 */ export class FirestoreClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; private _innerApiCalls: {[name: string]: Function}; private _terminated = false; private _opts: ClientOptions; @@ -250,7 +255,8 @@ export class FirestoreClient { if (this._terminated) { return Promise.reject('The client has already been closed.'); } - return stub[methodName].apply(stub, args); + const func = stub[methodName]; + return func.apply(stub, args); }, (err: Error | null | undefined) => () => { throw err; diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index 938b1e5db..b330e4e56 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// 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. @@ -55,7 +55,12 @@ const version = require('../../../package.json').version; * @memberof v1beta1 */ export class FirestoreClient { - private _descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}}; + private _descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; private _innerApiCalls: {[name: string]: Function}; private _terminated = false; private _opts: ClientOptions; @@ -258,7 +263,8 @@ export class FirestoreClient { if (this._terminated) { return Promise.reject('The client has already been closed.'); } - return stub[methodName].apply(stub, args); + const func = stub[methodName]; + return func.apply(stub, args); }, (err: Error | null | undefined) => () => { throw err; diff --git a/dev/synth.metadata b/dev/synth.metadata index 22062172c..fb2024a6f 100644 --- a/dev/synth.metadata +++ b/dev/synth.metadata @@ -1,19 +1,19 @@ { - "updateTime": "2020-03-05T23:07:35.336516Z", + "updateTime": "2020-03-22T11:28:16.621427Z", "sources": [ { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "f0b581b5bdf803e45201ecdb3688b60e381628a8", - "internalRef": "299181282" + "sha": "0be7105dc52590fa9a24e784052298ae37ce53aa", + "internalRef": "302154871" } }, { - "template": { - "name": "node_library", - "origin": "synthtool.gcp", - "version": "2020.2.4" + "git": { + "name": "synthtool", + "remote": "https://github.com/googleapis/synthtool.git", + "sha": "7e98e1609c91082f4eeb63b530c6468aefd18cfd" } } ], diff --git a/dev/test/gapic-firestore-v1.ts b/dev/test/gapic-firestore-v1.ts index 6e5ba0e20..7e884a8d2 100644 --- a/dev/test/gapic-firestore-v1.ts +++ b/dev/test/gapic-firestore-v1.ts @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// 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. diff --git a/dev/test/gapic-firestore-v1beta1.ts b/dev/test/gapic-firestore-v1beta1.ts index 61472d1dc..bd1169dbc 100644 --- a/dev/test/gapic-firestore-v1beta1.ts +++ b/dev/test/gapic-firestore-v1beta1.ts @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// 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. diff --git a/dev/test/gapic-firestore_admin-v1.ts b/dev/test/gapic-firestore_admin-v1.ts index c4f322a73..179089643 100644 --- a/dev/test/gapic-firestore_admin-v1.ts +++ b/dev/test/gapic-firestore_admin-v1.ts @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// 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. From 05b3363d07537a56d7b66d19027d09686e3c34d8 Mon Sep 17 00:00:00 2001 From: wu-hui <53845758+wu-hui@users.noreply.github.com> Date: Wed, 25 Mar 2020 13:12:41 -0400 Subject: [PATCH 094/337] Revert "Use Random Number from `crypto` to generate AutoId. (#984)" (#985) This reverts commit 0f492042a94019f233973e90ba6a2824f0630825. --- dev/src/util.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/dev/src/util.ts b/dev/src/util.ts index d04253699..d7a690ce7 100644 --- a/dev/src/util.ts +++ b/dev/src/util.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import {randomBytes} from 'crypto'; import {GoogleError, ServiceConfig, Status} from 'google-gax'; import {DocumentData} from './types'; @@ -53,17 +52,8 @@ export function autoId(): string { const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; let autoId = ''; - while (autoId.length < 20) { - const bytes = randomBytes(40); - bytes.forEach(b => { - // Length of `chars` is 62. We only take bytes between 0 and 62*4-1 - // (both inclusive). The value is then evenly mapped to indices of `char` - // via a modulo operation. - const maxValue = 62 * 4 - 1; - if (autoId.length < 20 && b <= maxValue) { - autoId += chars.charAt(b % 62); - } - }); + for (let i = 0; i < 20; i++) { + autoId += chars.charAt(Math.floor(Math.random() * chars.length)); } return autoId; } From ce6ea390f2fffcbe796ba1c5b040ee02452e287a Mon Sep 17 00:00:00 2001 From: wu-hui <53845758+wu-hui@users.noreply.github.com> Date: Wed, 25 Mar 2020 13:46:21 -0400 Subject: [PATCH 095/337] fix: use Random Number from `crypto` to generate AutoId This reverts commit 05b3363d07537a56d7b66d19027d09686e3c34d8. --- dev/src/util.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dev/src/util.ts b/dev/src/util.ts index d7a690ce7..d04253699 100644 --- a/dev/src/util.ts +++ b/dev/src/util.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import {randomBytes} from 'crypto'; import {GoogleError, ServiceConfig, Status} from 'google-gax'; import {DocumentData} from './types'; @@ -52,8 +53,17 @@ export function autoId(): string { const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; let autoId = ''; - for (let i = 0; i < 20; i++) { - autoId += chars.charAt(Math.floor(Math.random() * chars.length)); + while (autoId.length < 20) { + const bytes = randomBytes(40); + bytes.forEach(b => { + // Length of `chars` is 62. We only take bytes between 0 and 62*4-1 + // (both inclusive). The value is then evenly mapped to indices of `char` + // via a modulo operation. + const maxValue = 62 * 4 - 1; + if (autoId.length < 20 && b <= maxValue) { + autoId += chars.charAt(b % 62); + } + }); } return autoId; } From 2f1c1aa24d801a7114ff3208d37f7095285b90c0 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 26 Mar 2020 17:33:41 -0700 Subject: [PATCH 096/337] chore: release 3.7.2 (#981) --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e50e0775b..c7ac5ab0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.7.2](https://www.github.com/googleapis/nodejs-firestore/compare/v3.7.1...v3.7.2) (2020-03-25) + + +### Bug Fixes + +* fix flaky contention test ([#979](https://www.github.com/googleapis/nodejs-firestore/issues/979)) ([f294998](https://www.github.com/googleapis/nodejs-firestore/commit/f294998daab77a0a51c81265945e28eec34db186)) +* fix: use Random Number from `crypto` to generate AutoId ([05b3363](https://www.github.com/googleapis/nodejs-firestore/commit/ce6ea390f2fffcbe796ba1c5b040ee02452e287a)) + ### [3.7.1](https://www.github.com/googleapis/nodejs-firestore/compare/v3.7.0...v3.7.1) (2020-03-16) diff --git a/package.json b/package.json index 129d92386..2275fe21f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.7.1", + "version": "3.7.2", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index d2e8e617e..f068461fa 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.7.1" + "@google-cloud/firestore": "^3.7.2" }, "devDependencies": { "chai": "^4.2.0", From a6d8fe061fcfe0fde7a4fa023b2ec454e2adb432 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 31 Mar 2020 12:11:39 -0700 Subject: [PATCH 097/337] fix: support array of references for IN queries (#993) --- dev/src/reference.ts | 20 +++++++++- dev/system-test/firestore.ts | 23 ++++++++++-- dev/test/query.ts | 73 +++++++++++++++++++++++++++++++++++- 3 files changed, 110 insertions(+), 6 deletions(-) diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 40f60f522..7d46f0d16 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -1240,7 +1240,23 @@ export class Query { const path = FieldPath.fromArgument(fieldPath); if (FieldPath.documentId().isEqual(path)) { - value = this.validateReference(value); + if (opStr === 'array-contains' || opStr === 'array-contains-any') { + throw new Error( + `Invalid Query. You can't perform '${opStr}' ` + + 'queries on FieldPath.documentId().' + ); + } + + if (opStr === 'in') { + if (!Array.isArray(value) || value.length === 0) { + throw new Error( + `Invalid Query. A non-empty array is required for '${opStr}' filters.` + ); + } + value = value.map(el => this.validateReference(el)); + } else { + value = this.validateReference(value); + } } const fieldFilter = new FieldFilter( @@ -1595,7 +1611,7 @@ export class Query { } else { throw new Error( 'The corresponding value for FieldPath.documentId() must be a ' + - 'string or a DocumentReference.' + `string or a DocumentReference, but was "${val}".` ); } diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 974e55fb9..2c7804e48 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -18,6 +18,7 @@ import * as chaiAsPromised from 'chai-as-promised'; import { CollectionReference, DocumentData, + DocumentReference, DocumentSnapshot, FieldPath, FieldValue, @@ -1079,9 +1080,17 @@ describe('Query class', () => { }); }; - function addDocs(...data: DocumentData[]): Promise { + async function addDocs( + ...docs: DocumentData[] + ): Promise { let id = 0; // Guarantees consistent ordering for the first documents - return Promise.all(data.map(d => randomCol.doc('' + id++).set(d))); + const refs: DocumentReference[] = []; + for (const doc of docs) { + const ref = randomCol.doc('doc' + id++); + await ref.set(doc); + refs.push(ref); + } + return refs; } function expectDocs(result: QuerySnapshot, ...data: DocumentData[]) { @@ -1171,7 +1180,7 @@ describe('Query class', () => { }); }); - it('supports in', async () => { + it('supports "in"', async () => { await addDocs( {zip: 98101}, {zip: 91102}, @@ -1184,6 +1193,14 @@ describe('Query class', () => { expectDocs(res, {zip: 98101}, {zip: 98103}); }); + it('supports "in" with document ID array', async () => { + const refs = await addDocs({count: 1}, {count: 2}, {count: 3}); + const res = await randomCol + .where(FieldPath.documentId(), 'in', [refs[0].id, refs[1]]) + .get(); + expectDocs(res, {count: 1}, {count: 2}); + }); + it('supports array-contains-any', async () => { await addDocs( {array: [42]}, diff --git a/dev/test/query.ts b/dev/test/query.ts index 12f6a84e3..33cdf4b72 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -847,6 +847,77 @@ describe('where() interface', () => { }); }); + it('supports reference array for IN queries', () => { + const overrides: ApiOverride = { + runQuery: request => { + queryEquals( + request, + fieldFilters('__name__', 'IN', { + arrayValue: { + values: [ + { + referenceValue: `projects/${PROJECT_ID}/databases/(default)/documents/collectionId/foo`, + }, + { + referenceValue: `projects/${PROJECT_ID}/databases/(default)/documents/collectionId/bar`, + }, + ], + }, + }) + ); + + return stream(); + }, + }; + + return createInstance(overrides).then(firestore => { + const collection = firestore.collection('collectionId'); + const query = collection.where(FieldPath.documentId(), 'in', [ + 'foo', + collection.doc('bar'), + ]); + return query.get(); + }); + }); + + it('validates references for IN queries', () => { + const query = firestore.collection('collectionId'); + + expect(() => { + query.where(FieldPath.documentId(), 'in', ['foo', 42]); + }).to.throw( + 'The corresponding value for FieldPath.documentId() must be a string or a DocumentReference, but was "42".' + ); + + expect(() => { + query.where(FieldPath.documentId(), 'in', 42); + }).to.throw( + "Invalid Query. A non-empty array is required for 'in' filters." + ); + + expect(() => { + query.where(FieldPath.documentId(), 'in', []); + }).to.throw( + "Invalid Query. A non-empty array is required for 'in' filters." + ); + }); + + it('validates query operator for FieldPath.document()', () => { + const query = firestore.collection('collectionId'); + + expect(() => { + query.where(FieldPath.documentId(), 'array-contains', query.doc()); + }).to.throw( + "Invalid Query. You can't perform 'array-contains' queries on FieldPath.documentId()." + ); + + expect(() => { + query.where(FieldPath.documentId(), 'array-contains-any', query.doc()); + }).to.throw( + "Invalid Query. You can't perform 'array-contains-any' queries on FieldPath.documentId()." + ); + }); + it('rejects custom objects for field paths', () => { expect(() => { let query: Query = firestore.collection('collectionId'); @@ -1511,7 +1582,7 @@ describe('startAt() interface', () => { expect(() => { query.orderBy(FieldPath.documentId()).startAt(42); }).to.throw( - 'The corresponding value for FieldPath.documentId() must be a string or a DocumentReference.' + 'The corresponding value for FieldPath.documentId() must be a string or a DocumentReference, but was "42".' ); expect(() => { From ce6c1f52d44cebed4152a58dbd66544fe7fc9914 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 31 Mar 2020 12:22:05 -0700 Subject: [PATCH 098/337] chore: release 3.7.3 (#994) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7ac5ab0a..136e1da88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.7.3](https://www.github.com/googleapis/nodejs-firestore/compare/v3.7.2...v3.7.3) (2020-03-31) + + +### Bug Fixes + +* support array of references for IN queries ([#993](https://www.github.com/googleapis/nodejs-firestore/issues/993)) ([a6d8fe0](https://www.github.com/googleapis/nodejs-firestore/commit/a6d8fe061fcfe0fde7a4fa023b2ec454e2adb432)) + ### [3.7.2](https://www.github.com/googleapis/nodejs-firestore/compare/v3.7.1...v3.7.2) (2020-03-25) diff --git a/package.json b/package.json index 2275fe21f..feed6f49d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.7.2", + "version": "3.7.3", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index f068461fa..238dae4b3 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.7.2" + "@google-cloud/firestore": "^3.7.3" }, "devDependencies": { "chai": "^4.2.0", From 0b16b8e40fe19d7a9719df1454e5db9eb76a5e8e Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Tue, 31 Mar 2020 18:36:19 -0700 Subject: [PATCH 099/337] build: set AUTOSYNTH_MULTIPLE_COMMITS=true for context aware commits (#996) --- synth.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/synth.py b/synth.py index 262b0ce32..2adcb41ea 100644 --- a/synth.py +++ b/synth.py @@ -6,6 +6,9 @@ logging.basicConfig(level=logging.DEBUG) +AUTOSYNTH_MULTIPLE_COMMITS = True + + gapic_micro = gcp.GAPICMicrogenerator() v1_admin_library = gapic_micro.typescript_library( From 3aa9b0e8d5c8eeb40496058556aaa305a8277d34 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 1 Apr 2020 09:13:19 -0700 Subject: [PATCH 100/337] docs: change doc message (#995) --- dev/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index 8c54cb115..eb2c98e80 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -633,7 +633,7 @@ export class Firestore { * writeBatch.set(firestore.doc('col/doc2'), data); * * writeBatch.commit().then(res => { - * console.log(`Added document at ${res.writeResults[0].updateTime}`); + * console.log('Successfully executed batch.'); * }); */ batch(): WriteBatch { From 8c6f95c895cdfc2a24093d5f812cb2ab0761cbb4 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Sun, 5 Apr 2020 12:49:44 -0700 Subject: [PATCH 101/337] chore: remove duplicate mocha config (#1001) --- .mocharc.json | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .mocharc.json diff --git a/.mocharc.json b/.mocharc.json deleted file mode 100644 index 670c5e2c2..000000000 --- a/.mocharc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} From 3497691754d8b3b0b17385c34362f74ab8a84feb Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 8 Apr 2020 23:07:16 -0700 Subject: [PATCH 102/337] fix: validate nested arrays in FieldValue (#1003) --- dev/src/field-value.ts | 17 +++++++++++++++-- dev/test/field-value.ts | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/dev/src/field-value.ts b/dev/src/field-value.ts index f07aaa7c3..814e02a92 100644 --- a/dev/src/field-value.ts +++ b/dev/src/field-value.ts @@ -20,7 +20,11 @@ import * as proto from '../protos/firestore_v1_proto_api'; import {FieldPath} from './path'; import {Serializer, validateUserInput} from './serializer'; -import {validateMinNumberOfArguments, validateNumber} from './validate'; +import { + invalidArgumentMessage, + validateMinNumberOfArguments, + validateNumber, +} from './validate'; import api = proto.google.firestore.v1; @@ -502,13 +506,22 @@ class ArrayRemoveTransform extends FieldTransform { /** * Validates that `value` can be used as an element inside of an array. Certain - * field values (such as ServerTimestamps) are rejected. + * field values (such as ServerTimestamps) are rejected. Nested arrays are also + * rejected. * * @private * @param arg The argument name or argument index (for varargs methods). * @param value The value to validate. */ function validateArrayElement(arg: string | number, value: unknown): void { + if (Array.isArray(value)) { + throw new Error( + `${invalidArgumentMessage( + arg, + 'array element' + )} Nested arrays are not supported.` + ); + } validateUserInput( arg, value, diff --git a/dev/test/field-value.ts b/dev/test/field-value.ts index 2228a1138..4007e142c 100644 --- a/dev/test/field-value.ts +++ b/dev/test/field-value.ts @@ -121,6 +121,16 @@ describe('FieldValue.arrayUnion()', () => { }); }); + it('must not contain directly nested arrays', () => { + return createInstance().then(firestore => { + const docRef = firestore.doc('collectionId/documentId'); + expect(() => docRef.set({foo: FieldValue.arrayUnion([])})).to.throw( + 'Element at index 0 is not a valid array element. Nested arrays are ' + + 'not supported.' + ); + }); + }); + genericFieldValueTests('FieldValue.arrayUnion', FieldValue.arrayUnion('foo')); }); @@ -218,6 +228,16 @@ describe('FieldValue.arrayRemove()', () => { }); }); + it('must not contain directly nested arrays', () => { + return createInstance().then(firestore => { + const docRef = firestore.doc('collectionId/documentId'); + expect(() => docRef.set({foo: FieldValue.arrayRemove([])})).to.throw( + 'Element at index 0 is not a valid array element. Nested arrays are ' + + 'not supported.' + ); + }); + }); + genericFieldValueTests( 'FieldValue.arrayRemove', FieldValue.arrayRemove('foo') From 32d346bb0d5072259f54ec4f828893d7bfb8b4bc Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 9 Apr 2020 12:23:44 -0700 Subject: [PATCH 103/337] chore: release 3.7.4 (#1004) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 136e1da88..5239b58e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.7.4](https://www.github.com/googleapis/nodejs-firestore/compare/v3.7.3...v3.7.4) (2020-04-09) + + +### Bug Fixes + +* validate nested arrays in FieldValue ([#1003](https://www.github.com/googleapis/nodejs-firestore/issues/1003)) ([3497691](https://www.github.com/googleapis/nodejs-firestore/commit/3497691754d8b3b0b17385c34362f74ab8a84feb)) + ### [3.7.3](https://www.github.com/googleapis/nodejs-firestore/compare/v3.7.2...v3.7.3) (2020-03-31) diff --git a/package.json b/package.json index feed6f49d..4abbb2342 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.7.3", + "version": "3.7.4", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 238dae4b3..a56b39abe 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.7.3" + "@google-cloud/firestore": "^3.7.4" }, "devDependencies": { "chai": "^4.2.0", From 60856aa739506f603058260b486284ed9af24c31 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Sat, 11 Apr 2020 19:16:28 -0700 Subject: [PATCH 104/337] build: remove unused codecov config (#1011) --- codecov.yaml | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 codecov.yaml diff --git a/codecov.yaml b/codecov.yaml deleted file mode 100644 index 5724ea947..000000000 --- a/codecov.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -codecov: - ci: - - source.cloud.google.com From ce89a3017168ea9bd16a361dde5a5370feb1df45 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Mon, 13 Apr 2020 14:54:43 -0700 Subject: [PATCH 105/337] chore: update lint ignore files (#1015) --- .eslintignore | 3 ++- .prettierignore | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.eslintignore b/.eslintignore index 09b31fe73..9340ad9b8 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,6 @@ **/node_modules -src/**/doc/* +**/coverage +test/fixtures build/ docs/ protos/ diff --git a/.prettierignore b/.prettierignore index f6fac98b0..9340ad9b8 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,6 @@ -node_modules/* -samples/node_modules/* -src/**/doc/* +**/node_modules +**/coverage +test/fixtures +build/ +docs/ +protos/ From d13b9a6c052c4a8233d41b428daf498c443ad509 Mon Sep 17 00:00:00 2001 From: Alexander Fenster Date: Thu, 23 Apr 2020 19:34:50 -0700 Subject: [PATCH 106/337] chore: update npm scripts and synth.py (#1042) Update npm scripts: add clean, prelint, prefix; make sure that lint and fix are set properly. Use post-process feature of synthtool. --- package.json | 3 ++- synth.py | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 4abbb2342..afb687780 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,8 @@ "prepare": "npm run compile", "docs-test": "linkinator docs", "predocs-test": "npm run docs", - "prelint": "cd samples; npm link ../; npm i" + "prelint": "cd samples; npm link ../; npm install", + "precompile": "gts clean" }, "dependencies": { "deep-equal": "^2.0.0", diff --git a/synth.py b/synth.py index 2adcb41ea..b396b5704 100644 --- a/synth.py +++ b/synth.py @@ -1,7 +1,7 @@ import synthtool as s import synthtool.gcp as gcp +import synthtool.languages.node as node import logging -import subprocess import os logging.basicConfig(level=logging.DEBUG) @@ -88,11 +88,10 @@ # Remove auto-generated packaging tests os.system('rm -rf dev/system-test/fixtures dev/system-test/install.ts') -# Node.js specific cleanup -subprocess.run(["npm", "install"]) -subprocess.run(["npm", "run", "fix"]) +node.install() +node.fix() os.chdir("dev") -subprocess.run(["npx", "compileProtos", "src"]) +node.compile_protos() os.unlink('protos/protos.js') os.unlink('protos/protos.d.ts') os.unlink('.jsdoc.js') From 4b65fca3d7aa9618ff944c02f059d08f39b4cac3 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Fri, 24 Apr 2020 19:55:35 -0700 Subject: [PATCH 107/337] fix: return errors from Query.stream() (#1046) --- dev/src/reference.ts | 2 +- dev/test/query.ts | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 7d46f0d16..00e3a602f 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -1883,7 +1883,7 @@ export class Query { }); responseStream.pipe(transform); - responseStream.on('error', transform.destroy); + responseStream.on('error', e => transform.destroy(e)); return transform; } diff --git a/dev/test/query.ts b/dev/test/query.ts index 33cdf4b72..6256fb86b 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -17,7 +17,13 @@ import * as chaiAsPromised from 'chai-as-promised'; import * as extend from 'extend'; import {google} from '../protos/firestore_v1_proto_api'; -import {FieldPath, FieldValue, Firestore, setLogFunction} from '../src'; +import { + FieldPath, + FieldValue, + Firestore, + QueryDocumentSnapshot, + setLogFunction, +} from '../src'; import {DocumentData, DocumentReference, Query, Timestamp} from '../src'; import {setTimeoutHandler} from '../src/backoff'; import {DocumentSnapshot, DocumentSnapshotBuilder} from '../src/document'; @@ -558,7 +564,7 @@ describe('query interface', () => { }); }); - it('handles stream exception after initialization', () => { + it('handles stream exception after initialization (with get())', () => { const overrides: ApiOverride = { runQuery: () => { return stream(result('first'), new Error('Expected error')); @@ -578,6 +584,29 @@ describe('query interface', () => { }); }); + it('handles stream exception after initialization (with stream())', done => { + const overrides: ApiOverride = { + runQuery: () => { + return stream(result('first'), new Error('Expected error')); + }, + }; + + createInstance(overrides).then(firestore => { + const result = firestore.collection('collectionId').stream(); + + let resultCount = 0; + result.on('data', doc => { + expect(doc).to.be.an.instanceOf(QueryDocumentSnapshot); + ++resultCount; + }); + result.on('error', err => { + expect(resultCount).to.equal(1); + expect(err.message).to.equal('Expected error'); + done(); + }); + }); + }); + it('streams results', callback => { const overrides: ApiOverride = { runQuery: request => { From b4a80edfd6d6dab26c4ddb4405c43710421b614d Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2020 20:05:59 -0700 Subject: [PATCH 108/337] chore: release 3.7.5 (#1047) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5239b58e4..51de19c6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.7.5](https://www.github.com/googleapis/nodejs-firestore/compare/v3.7.4...v3.7.5) (2020-04-25) + + +### Bug Fixes + +* return errors from Query.stream() ([#1046](https://www.github.com/googleapis/nodejs-firestore/issues/1046)) ([4b65fca](https://www.github.com/googleapis/nodejs-firestore/commit/4b65fca3d7aa9618ff944c02f059d08f39b4cac3)) + ### [3.7.4](https://www.github.com/googleapis/nodejs-firestore/compare/v3.7.3...v3.7.4) (2020-04-09) diff --git a/package.json b/package.json index afb687780..9418a4dc8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.7.4", + "version": "3.7.5", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index a56b39abe..912fccdce 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.7.4" + "@google-cloud/firestore": "^3.7.5" }, "devDependencies": { "chai": "^4.2.0", From 8c52d475ae486e2998220947a0b0441d4a95ab49 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 28 Apr 2020 16:54:47 -0700 Subject: [PATCH 109/337] fix: Add BulkWriter (#1051) --- .../create-all-transforms.json | 81 +-- .../create-arrayremove-multi.json | 73 +- .../create-arrayremove-nested.json | 41 +- .../conformance-tests/create-arrayremove.json | 41 +- .../create-arrayunion-multi.json | 73 +- .../create-arrayunion-nested.json | 41 +- .../conformance-tests/create-arrayunion.json | 41 +- .../conformance-tests/create-st-alone.json | 21 +- .../conformance-tests/create-st-multi.json | 27 +- .../conformance-tests/create-st-nested.json | 19 +- .../create-st-with-empty-map.json | 19 +- .../conformance-tests/create-st.json | 19 +- .../conformance-tests/set-all-transforms.json | 81 +-- .../set-arrayremove-multi.json | 73 +- .../set-arrayremove-nested.json | 41 +- .../conformance-tests/set-arrayremove.json | 41 +- .../set-arrayunion-multi.json | 73 +- .../set-arrayunion-nested.json | 41 +- .../conformance-tests/set-arrayunion.json | 41 +- .../set-st-alone-mergeall.json | 22 +- .../conformance-tests/set-st-alone.json | 19 +- .../conformance-tests/set-st-merge-both.json | 19 +- .../set-st-merge-nonleaf-alone.json | 19 +- .../set-st-merge-nonleaf.json | 19 +- .../set-st-merge-nowrite.json | 22 +- .../conformance-tests/set-st-mergeall.json | 19 +- .../conformance-tests/set-st-multi.json | 27 +- .../conformance-tests/set-st-nested.json | 19 +- .../set-st-with-empty-map.json | 19 +- dev/conformance/conformance-tests/set-st.json | 19 +- .../update-all-transforms.json | 81 +-- .../update-arrayremove-alone.json | 50 +- .../update-arrayremove-multi.json | 73 +- .../update-arrayremove-nested.json | 41 +- .../conformance-tests/update-arrayremove.json | 41 +- .../update-arrayunion-alone.json | 48 +- .../update-arrayunion-multi.json | 73 +- .../update-arrayunion-nested.json | 41 +- .../conformance-tests/update-arrayunion.json | 41 +- ...ate-nested-transform-and-nested-value.json | 19 +- .../update-paths-all-transforms.json | 81 +-- .../update-paths-arrayremove-alone.json | 48 +- .../update-paths-arrayremove-multi.json | 73 +- .../update-paths-arrayremove-nested.json | 41 +- .../update-paths-arrayremove.json | 41 +- .../update-paths-arrayunion-alone.json | 48 +- .../update-paths-arrayunion-multi.json | 73 +- .../update-paths-arrayunion-nested.json | 41 +- .../update-paths-arrayunion.json | 41 +- ...ths-nested-transform-and-nested-value.json | 19 +- .../update-paths-st-alone.json | 24 +- .../update-paths-st-multi.json | 27 +- .../update-paths-st-nested.json | 19 +- .../update-paths-st-with-empty-map.json | 19 +- .../conformance-tests/update-paths-st.json | 19 +- .../conformance-tests/update-st-alone.json | 24 +- .../conformance-tests/update-st-dot.json | 24 +- .../conformance-tests/update-st-multi.json | 27 +- .../conformance-tests/update-st-nested.json | 19 +- .../update-st-with-empty-map.json | 19 +- .../conformance-tests/update-st.json | 19 +- dev/conformance/runner.ts | 5 +- dev/protos/firestore_v1_proto_api.d.ts | 73 ++ dev/protos/firestore_v1_proto_api.js | 124 ++++ .../google/firestore/v1/firestore.proto | 38 + dev/src/backoff.ts | 4 +- dev/src/bulk-writer.ts | 657 +++++++++++++++++ dev/src/document.ts | 35 +- dev/src/index.ts | 41 ++ dev/src/rate-limiter.ts | 154 ++++ dev/src/types.ts | 16 +- dev/src/write-batch.ts | 168 ++--- dev/system-test/firestore.ts | 30 +- dev/test/bulk-writer.ts | 660 ++++++++++++++++++ dev/test/document.ts | 17 +- dev/test/field-value.ts | 8 +- dev/test/rate-limiter.ts | 109 +++ dev/test/util/helpers.ts | 48 +- dev/test/write-batch.ts | 116 ++- types/firestore.d.ts | 1 - 80 files changed, 3191 insertions(+), 1477 deletions(-) create mode 100644 dev/src/bulk-writer.ts create mode 100644 dev/src/rate-limiter.ts create mode 100644 dev/test/bulk-writer.ts create mode 100644 dev/test/rate-limiter.ts diff --git a/dev/conformance/conformance-tests/create-all-transforms.json b/dev/conformance/conformance-tests/create-all-transforms.json index 82831624b..638959998 100644 --- a/dev/conformance/conformance-tests/create-all-transforms.json +++ b/dev/conformance/conformance-tests/create-all-transforms.json @@ -20,50 +20,45 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/create-arrayremove-multi.json b/dev/conformance/conformance-tests/create-arrayremove-multi.json index 548a98380..331a53bf9 100644 --- a/dev/conformance/conformance-tests/create-arrayremove-multi.json +++ b/dev/conformance/conformance-tests/create-arrayremove-multi.json @@ -20,46 +20,41 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "c.d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/create-arrayremove-nested.json b/dev/conformance/conformance-tests/create-arrayremove-nested.json index fa01bd7e0..00c73d05c 100644 --- a/dev/conformance/conformance-tests/create-arrayremove-nested.json +++ b/dev/conformance/conformance-tests/create-arrayremove-nested.json @@ -20,30 +20,25 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/create-arrayremove.json b/dev/conformance/conformance-tests/create-arrayremove.json index a69be14b7..646e259f6 100644 --- a/dev/conformance/conformance-tests/create-arrayremove.json +++ b/dev/conformance/conformance-tests/create-arrayremove.json @@ -20,30 +20,25 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/create-arrayunion-multi.json b/dev/conformance/conformance-tests/create-arrayunion-multi.json index 7ca9852f4..5ba324f42 100644 --- a/dev/conformance/conformance-tests/create-arrayunion-multi.json +++ b/dev/conformance/conformance-tests/create-arrayunion-multi.json @@ -20,46 +20,41 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "appendMissingElements": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "c.d", + "appendMissingElements": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/create-arrayunion-nested.json b/dev/conformance/conformance-tests/create-arrayunion-nested.json index a2f20299d..2a2150900 100644 --- a/dev/conformance/conformance-tests/create-arrayunion-nested.json +++ b/dev/conformance/conformance-tests/create-arrayunion-nested.json @@ -20,30 +20,25 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/create-arrayunion.json b/dev/conformance/conformance-tests/create-arrayunion.json index 26d079946..99a75fede 100644 --- a/dev/conformance/conformance-tests/create-arrayunion.json +++ b/dev/conformance/conformance-tests/create-arrayunion.json @@ -20,30 +20,25 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/create-st-alone.json b/dev/conformance/conformance-tests/create-st-alone.json index 20c5e8ec3..177293906 100644 --- a/dev/conformance/conformance-tests/create-st-alone.json +++ b/dev/conformance/conformance-tests/create-st-alone.json @@ -10,18 +10,19 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "setToServerValue": "REQUEST_TIME" - } - ] - }, "currentDocument": { "exists": false - } + }, + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/create-st-multi.json b/dev/conformance/conformance-tests/create-st-multi.json index 89430e2b6..41f3cd811 100644 --- a/dev/conformance/conformance-tests/create-st-multi.json +++ b/dev/conformance/conformance-tests/create-st-multi.json @@ -20,22 +20,17 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c.d", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c.d", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/create-st-nested.json b/dev/conformance/conformance-tests/create-st-nested.json index f2a3a8d1f..7316d916f 100644 --- a/dev/conformance/conformance-tests/create-st-nested.json +++ b/dev/conformance/conformance-tests/create-st-nested.json @@ -20,18 +20,13 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/create-st-with-empty-map.json b/dev/conformance/conformance-tests/create-st-with-empty-map.json index 730afd154..b638a0c9d 100644 --- a/dev/conformance/conformance-tests/create-st-with-empty-map.json +++ b/dev/conformance/conformance-tests/create-st-with-empty-map.json @@ -28,18 +28,13 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/create-st.json b/dev/conformance/conformance-tests/create-st.json index 705f76ed1..c4ad4be46 100644 --- a/dev/conformance/conformance-tests/create-st.json +++ b/dev/conformance/conformance-tests/create-st.json @@ -20,18 +20,13 @@ }, "currentDocument": { "exists": false - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-all-transforms.json b/dev/conformance/conformance-tests/set-all-transforms.json index 5c8b1373d..a26b51b00 100644 --- a/dev/conformance/conformance-tests/set-all-transforms.json +++ b/dev/conformance/conformance-tests/set-all-transforms.json @@ -17,50 +17,45 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-arrayremove-multi.json b/dev/conformance/conformance-tests/set-arrayremove-multi.json index 3ea9b0dbd..dc2ace22f 100644 --- a/dev/conformance/conformance-tests/set-arrayremove-multi.json +++ b/dev/conformance/conformance-tests/set-arrayremove-multi.json @@ -17,46 +17,41 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-arrayremove-nested.json b/dev/conformance/conformance-tests/set-arrayremove-nested.json index 4db133f2c..1e25b8f26 100644 --- a/dev/conformance/conformance-tests/set-arrayremove-nested.json +++ b/dev/conformance/conformance-tests/set-arrayremove-nested.json @@ -17,30 +17,25 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-arrayremove.json b/dev/conformance/conformance-tests/set-arrayremove.json index 18969ef80..e0506b22b 100644 --- a/dev/conformance/conformance-tests/set-arrayremove.json +++ b/dev/conformance/conformance-tests/set-arrayremove.json @@ -17,30 +17,25 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-arrayunion-multi.json b/dev/conformance/conformance-tests/set-arrayunion-multi.json index 3d076397c..502d7dc7d 100644 --- a/dev/conformance/conformance-tests/set-arrayunion-multi.json +++ b/dev/conformance/conformance-tests/set-arrayunion-multi.json @@ -17,46 +17,41 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "appendMissingElements": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + }, + { + "fieldPath": "c.d", + "appendMissingElements": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-arrayunion-nested.json b/dev/conformance/conformance-tests/set-arrayunion-nested.json index e265f6c61..7084e6bcd 100644 --- a/dev/conformance/conformance-tests/set-arrayunion-nested.json +++ b/dev/conformance/conformance-tests/set-arrayunion-nested.json @@ -17,30 +17,25 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-arrayunion.json b/dev/conformance/conformance-tests/set-arrayunion.json index 856e07517..af12b33dd 100644 --- a/dev/conformance/conformance-tests/set-arrayunion.json +++ b/dev/conformance/conformance-tests/set-arrayunion.json @@ -17,30 +17,25 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-st-alone-mergeall.json b/dev/conformance/conformance-tests/set-st-alone-mergeall.json index d95bf0973..f6b60af81 100644 --- a/dev/conformance/conformance-tests/set-st-alone-mergeall.json +++ b/dev/conformance/conformance-tests/set-st-alone-mergeall.json @@ -13,15 +13,19 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "setToServerValue": "REQUEST_TIME" - } - ] - } + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-st-alone.json b/dev/conformance/conformance-tests/set-st-alone.json index 3fe931394..1d28fd6f1 100644 --- a/dev/conformance/conformance-tests/set-st-alone.json +++ b/dev/conformance/conformance-tests/set-st-alone.json @@ -13,18 +13,13 @@ "update": { "name": "projects/projectID/databases/(default)/documents/C/d", "fields": {} - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-st-merge-both.json b/dev/conformance/conformance-tests/set-st-merge-both.json index a39ada55f..359c899a1 100644 --- a/dev/conformance/conformance-tests/set-st-merge-both.json +++ b/dev/conformance/conformance-tests/set-st-merge-both.json @@ -36,18 +36,13 @@ "fieldPaths": [ "a" ] - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-st-merge-nonleaf-alone.json b/dev/conformance/conformance-tests/set-st-merge-nonleaf-alone.json index 4193b00ea..5af99ab0a 100644 --- a/dev/conformance/conformance-tests/set-st-merge-nonleaf-alone.json +++ b/dev/conformance/conformance-tests/set-st-merge-nonleaf-alone.json @@ -26,18 +26,13 @@ "fieldPaths": [ "h" ] - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "h.g", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "h.g", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-st-merge-nonleaf.json b/dev/conformance/conformance-tests/set-st-merge-nonleaf.json index 5e91d663b..e66ca87bf 100644 --- a/dev/conformance/conformance-tests/set-st-merge-nonleaf.json +++ b/dev/conformance/conformance-tests/set-st-merge-nonleaf.json @@ -37,18 +37,13 @@ "fieldPaths": [ "h" ] - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "h.g", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "h.g", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-st-merge-nowrite.json b/dev/conformance/conformance-tests/set-st-merge-nowrite.json index 08fa8b52f..44091b127 100644 --- a/dev/conformance/conformance-tests/set-st-merge-nowrite.json +++ b/dev/conformance/conformance-tests/set-st-merge-nowrite.json @@ -19,15 +19,19 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] - } + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-st-mergeall.json b/dev/conformance/conformance-tests/set-st-mergeall.json index 26883c038..f913d69e6 100644 --- a/dev/conformance/conformance-tests/set-st-mergeall.json +++ b/dev/conformance/conformance-tests/set-st-mergeall.json @@ -25,18 +25,13 @@ "fieldPaths": [ "a" ] - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-st-multi.json b/dev/conformance/conformance-tests/set-st-multi.json index 23c06f497..03200729c 100644 --- a/dev/conformance/conformance-tests/set-st-multi.json +++ b/dev/conformance/conformance-tests/set-st-multi.json @@ -17,22 +17,17 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c.d", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c.d", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-st-nested.json b/dev/conformance/conformance-tests/set-st-nested.json index 5c94c33f9..58406e80b 100644 --- a/dev/conformance/conformance-tests/set-st-nested.json +++ b/dev/conformance/conformance-tests/set-st-nested.json @@ -17,18 +17,13 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-st-with-empty-map.json b/dev/conformance/conformance-tests/set-st-with-empty-map.json index 063c94a0e..a40786653 100644 --- a/dev/conformance/conformance-tests/set-st-with-empty-map.json +++ b/dev/conformance/conformance-tests/set-st-with-empty-map.json @@ -25,18 +25,13 @@ } } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/set-st.json b/dev/conformance/conformance-tests/set-st.json index 42f2b14f1..3e55ae111 100644 --- a/dev/conformance/conformance-tests/set-st.json +++ b/dev/conformance/conformance-tests/set-st.json @@ -17,18 +17,13 @@ "integerValue": "1" } } - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-all-transforms.json b/dev/conformance/conformance-tests/update-all-transforms.json index 6f6a725df..72b16d3a1 100644 --- a/dev/conformance/conformance-tests/update-all-transforms.json +++ b/dev/conformance/conformance-tests/update-all-transforms.json @@ -25,50 +25,45 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-arrayremove-alone.json b/dev/conformance/conformance-tests/update-arrayremove-alone.json index 86fc8802e..93b8ff052 100644 --- a/dev/conformance/conformance-tests/update-arrayremove-alone.json +++ b/dev/conformance/conformance-tests/update-arrayremove-alone.json @@ -10,31 +10,35 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - } - ] - }, "currentDocument": { "exists": true - } - } + }, + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "fieldPath": "a", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] + } ] } } diff --git a/dev/conformance/conformance-tests/update-arrayremove-multi.json b/dev/conformance/conformance-tests/update-arrayremove-multi.json index df880f679..18ed0fdde 100644 --- a/dev/conformance/conformance-tests/update-arrayremove-multi.json +++ b/dev/conformance/conformance-tests/update-arrayremove-multi.json @@ -26,46 +26,41 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "c.d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-arrayremove-nested.json b/dev/conformance/conformance-tests/update-arrayremove-nested.json index 28d59aff6..7159797c7 100644 --- a/dev/conformance/conformance-tests/update-arrayremove-nested.json +++ b/dev/conformance/conformance-tests/update-arrayremove-nested.json @@ -26,30 +26,25 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-arrayremove.json b/dev/conformance/conformance-tests/update-arrayremove.json index d925704db..2311f916d 100644 --- a/dev/conformance/conformance-tests/update-arrayremove.json +++ b/dev/conformance/conformance-tests/update-arrayremove.json @@ -25,30 +25,25 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-arrayunion-alone.json b/dev/conformance/conformance-tests/update-arrayunion-alone.json index 757ea48c3..5cb08579c 100644 --- a/dev/conformance/conformance-tests/update-arrayunion-alone.json +++ b/dev/conformance/conformance-tests/update-arrayunion-alone.json @@ -10,30 +10,34 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - } - ] - }, "currentDocument": { "exists": true - } + }, + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + }, + "fieldPath": "a" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-arrayunion-multi.json b/dev/conformance/conformance-tests/update-arrayunion-multi.json index 3aafcd0f3..674ce2b4c 100644 --- a/dev/conformance/conformance-tests/update-arrayunion-multi.json +++ b/dev/conformance/conformance-tests/update-arrayunion-multi.json @@ -26,46 +26,41 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "appendMissingElements": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "c.d", + "appendMissingElements": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-arrayunion-nested.json b/dev/conformance/conformance-tests/update-arrayunion-nested.json index f2bf3770d..841ceed0a 100644 --- a/dev/conformance/conformance-tests/update-arrayunion-nested.json +++ b/dev/conformance/conformance-tests/update-arrayunion-nested.json @@ -26,30 +26,25 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-arrayunion.json b/dev/conformance/conformance-tests/update-arrayunion.json index 60192c9f8..0aca2356c 100644 --- a/dev/conformance/conformance-tests/update-arrayunion.json +++ b/dev/conformance/conformance-tests/update-arrayunion.json @@ -25,30 +25,25 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-nested-transform-and-nested-value.json b/dev/conformance/conformance-tests/update-nested-transform-and-nested-value.json index ff7bfc6ee..2ccba0985 100644 --- a/dev/conformance/conformance-tests/update-nested-transform-and-nested-value.json +++ b/dev/conformance/conformance-tests/update-nested-transform-and-nested-value.json @@ -31,18 +31,13 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-paths-all-transforms.json b/dev/conformance/conformance-tests/update-paths-all-transforms.json index 01a4c1143..40adbcaf5 100644 --- a/dev/conformance/conformance-tests/update-paths-all-transforms.json +++ b/dev/conformance/conformance-tests/update-paths-all-transforms.json @@ -52,50 +52,45 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-paths-arrayremove-alone.json b/dev/conformance/conformance-tests/update-paths-arrayremove-alone.json index 9bc8a1440..4097f5888 100644 --- a/dev/conformance/conformance-tests/update-paths-arrayremove-alone.json +++ b/dev/conformance/conformance-tests/update-paths-arrayremove-alone.json @@ -19,30 +19,34 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - } - ] - }, "currentDocument": { "exists": true - } + }, + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "fieldPath": "a", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-paths-arrayremove-multi.json b/dev/conformance/conformance-tests/update-paths-arrayremove-multi.json index 9a8547120..5e76d07ba 100644 --- a/dev/conformance/conformance-tests/update-paths-arrayremove-multi.json +++ b/dev/conformance/conformance-tests/update-paths-arrayremove-multi.json @@ -47,46 +47,41 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "removeAllFromArray": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "c.d", + "removeAllFromArray": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-paths-arrayremove-nested.json b/dev/conformance/conformance-tests/update-paths-arrayremove-nested.json index e7f952ec3..9ee1b2a6f 100644 --- a/dev/conformance/conformance-tests/update-paths-arrayremove-nested.json +++ b/dev/conformance/conformance-tests/update-paths-arrayremove-nested.json @@ -41,30 +41,25 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-paths-arrayremove.json b/dev/conformance/conformance-tests/update-paths-arrayremove.json index 673a2ca2c..a7be888da 100644 --- a/dev/conformance/conformance-tests/update-paths-arrayremove.json +++ b/dev/conformance/conformance-tests/update-paths-arrayremove.json @@ -40,30 +40,25 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "removeAllFromArray": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "removeAllFromArray": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-paths-arrayunion-alone.json b/dev/conformance/conformance-tests/update-paths-arrayunion-alone.json index 81e1e9771..2375d0ced 100644 --- a/dev/conformance/conformance-tests/update-paths-arrayunion-alone.json +++ b/dev/conformance/conformance-tests/update-paths-arrayunion-alone.json @@ -19,30 +19,34 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - } - ] - }, "currentDocument": { "exists": true - } + }, + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] + }, + "fieldPath": "a" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-paths-arrayunion-multi.json b/dev/conformance/conformance-tests/update-paths-arrayunion-multi.json index ef421bdad..afb643741 100644 --- a/dev/conformance/conformance-tests/update-paths-arrayunion-multi.json +++ b/dev/conformance/conformance-tests/update-paths-arrayunion-multi.json @@ -47,46 +47,41 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } - }, - { - "fieldPath": "c.d", - "appendMissingElements": { - "values": [ - { - "integerValue": "4" - }, - { - "integerValue": "5" - }, - { - "integerValue": "6" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + }, + { + "fieldPath": "c.d", + "appendMissingElements": { + "values": [ + { + "integerValue": "4" + }, + { + "integerValue": "5" + }, + { + "integerValue": "6" + } + ] + } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-paths-arrayunion-nested.json b/dev/conformance/conformance-tests/update-paths-arrayunion-nested.json index 2d73527a4..d908d0205 100644 --- a/dev/conformance/conformance-tests/update-paths-arrayunion-nested.json +++ b/dev/conformance/conformance-tests/update-paths-arrayunion-nested.json @@ -41,30 +41,25 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-paths-arrayunion.json b/dev/conformance/conformance-tests/update-paths-arrayunion.json index 1401993d0..ed2966aed 100644 --- a/dev/conformance/conformance-tests/update-paths-arrayunion.json +++ b/dev/conformance/conformance-tests/update-paths-arrayunion.json @@ -40,30 +40,25 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "appendMissingElements": { - "values": [ - { - "integerValue": "1" - }, - { - "integerValue": "2" - }, - { - "integerValue": "3" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "appendMissingElements": { + "values": [ + { + "integerValue": "1" + }, + { + "integerValue": "2" + }, + { + "integerValue": "3" + } + ] } - ] - } + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-paths-nested-transform-and-nested-value.json b/dev/conformance/conformance-tests/update-paths-nested-transform-and-nested-value.json index 927d783ae..c4dead09e 100644 --- a/dev/conformance/conformance-tests/update-paths-nested-transform-and-nested-value.json +++ b/dev/conformance/conformance-tests/update-paths-nested-transform-and-nested-value.json @@ -48,18 +48,13 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-paths-st-alone.json b/dev/conformance/conformance-tests/update-paths-st-alone.json index 085d04987..668c1c932 100644 --- a/dev/conformance/conformance-tests/update-paths-st-alone.json +++ b/dev/conformance/conformance-tests/update-paths-st-alone.json @@ -19,18 +19,22 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "setToServerValue": "REQUEST_TIME" - } - ] - }, "currentDocument": { "exists": true - } + }, + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-paths-st-multi.json b/dev/conformance/conformance-tests/update-paths-st-multi.json index 2d813801a..8767cf349 100644 --- a/dev/conformance/conformance-tests/update-paths-st-multi.json +++ b/dev/conformance/conformance-tests/update-paths-st-multi.json @@ -47,22 +47,17 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c.d", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c.d", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-paths-st-nested.json b/dev/conformance/conformance-tests/update-paths-st-nested.json index 8bd35c911..94ecaccaa 100644 --- a/dev/conformance/conformance-tests/update-paths-st-nested.json +++ b/dev/conformance/conformance-tests/update-paths-st-nested.json @@ -41,18 +41,13 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-paths-st-with-empty-map.json b/dev/conformance/conformance-tests/update-paths-st-with-empty-map.json index a4b8ed131..a86ae46cd 100644 --- a/dev/conformance/conformance-tests/update-paths-st-with-empty-map.json +++ b/dev/conformance/conformance-tests/update-paths-st-with-empty-map.json @@ -41,25 +41,14 @@ ] }, "updateTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": 1 - } + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } ], "currentDocument": { "exists": true } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } } ] } diff --git a/dev/conformance/conformance-tests/update-paths-st.json b/dev/conformance/conformance-tests/update-paths-st.json index 011405b9b..1710508b2 100644 --- a/dev/conformance/conformance-tests/update-paths-st.json +++ b/dev/conformance/conformance-tests/update-paths-st.json @@ -40,18 +40,13 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-st-alone.json b/dev/conformance/conformance-tests/update-st-alone.json index 1a333f30c..49fab1769 100644 --- a/dev/conformance/conformance-tests/update-st-alone.json +++ b/dev/conformance/conformance-tests/update-st-alone.json @@ -10,18 +10,22 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a", - "setToServerValue": "REQUEST_TIME" - } - ] - }, "currentDocument": { "exists": true - } + }, + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "fieldPath": "a", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-st-dot.json b/dev/conformance/conformance-tests/update-st-dot.json index 83422ca52..8b9a76902 100644 --- a/dev/conformance/conformance-tests/update-st-dot.json +++ b/dev/conformance/conformance-tests/update-st-dot.json @@ -10,18 +10,22 @@ "database": "projects/projectID/databases/(default)", "writes": [ { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a.b.c", - "setToServerValue": "REQUEST_TIME" - } - ] - }, "currentDocument": { "exists": true - } + }, + "update": { + "fields": {}, + "name": "projects/projectID/databases/(default)/documents/C/d" + }, + "updateMask": { + "fieldPaths": [] + }, + "updateTransforms": [ + { + "fieldPath": "a.b.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-st-multi.json b/dev/conformance/conformance-tests/update-st-multi.json index 8105ec27f..f474112b6 100644 --- a/dev/conformance/conformance-tests/update-st-multi.json +++ b/dev/conformance/conformance-tests/update-st-multi.json @@ -26,22 +26,17 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - }, - { - "fieldPath": "c.d", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + }, + { + "fieldPath": "c.d", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-st-nested.json b/dev/conformance/conformance-tests/update-st-nested.json index 5a8e73237..fa9f46b49 100644 --- a/dev/conformance/conformance-tests/update-st-nested.json +++ b/dev/conformance/conformance-tests/update-st-nested.json @@ -26,18 +26,13 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-st-with-empty-map.json b/dev/conformance/conformance-tests/update-st-with-empty-map.json index abeceb03e..4a2c27dfb 100644 --- a/dev/conformance/conformance-tests/update-st-with-empty-map.json +++ b/dev/conformance/conformance-tests/update-st-with-empty-map.json @@ -33,18 +33,13 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "a.c", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "a.c", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/conformance-tests/update-st.json b/dev/conformance/conformance-tests/update-st.json index 6249d8bda..71d17f3c7 100644 --- a/dev/conformance/conformance-tests/update-st.json +++ b/dev/conformance/conformance-tests/update-st.json @@ -25,18 +25,13 @@ }, "currentDocument": { "exists": true - } - }, - { - "transform": { - "document": "projects/projectID/databases/(default)/documents/C/d", - "fieldTransforms": [ - { - "fieldPath": "b", - "setToServerValue": "REQUEST_TIME" - } - ] - } + }, + "updateTransforms": [ + { + "fieldPath": "b", + "setToServerValue": "REQUEST_TIME" + } + ] } ] } diff --git a/dev/conformance/runner.ts b/dev/conformance/runner.ts index 0e925aec6..f5546acc1 100644 --- a/dev/conformance/runner.ts +++ b/dev/conformance/runner.ts @@ -50,10 +50,7 @@ import api = proto.google.firestore.v1; type ConformanceProto = any; // tslint:disable-line:no-any /** List of test cases that are ignored. */ -const ignoredRe: RegExp[] = [ - // TODO(chenbrian): Enable this test once update_transforms support is added. - new RegExp('update-paths: ServerTimestamp beside an empty map'), -]; +const ignoredRe: RegExp[] = []; /** If non-empty, list the test cases to run exclusively. */ const exclusiveRe: RegExp[] = []; diff --git a/dev/protos/firestore_v1_proto_api.d.ts b/dev/protos/firestore_v1_proto_api.d.ts index 0531279d2..25d163597 100644 --- a/dev/protos/firestore_v1_proto_api.d.ts +++ b/dev/protos/firestore_v1_proto_api.d.ts @@ -1966,6 +1966,20 @@ export namespace google { public listCollectionIds(request: google.firestore.v1.IListCollectionIdsRequest): Promise; /** + * Calls BatchWrite. + * @param request BatchWriteRequest message or plain object + * @param callback Node-style callback called with the error, if any, and BatchWriteResponse + */ + public batchWrite(request: google.firestore.v1.IBatchWriteRequest, callback: google.firestore.v1.Firestore.BatchWriteCallback): void; + + /** + * Calls BatchWrite. + * @param request BatchWriteRequest message or plain object + * @returns Promise + */ + public batchWrite(request: google.firestore.v1.IBatchWriteRequest): Promise; + + /* * Calls CreateDocument. * @param request CreateDocumentRequest message or plain object * @param callback Node-style callback called with the error, if any, and Document @@ -2067,6 +2081,13 @@ export namespace google { type ListCollectionIdsCallback = (error: (Error|null), response?: google.firestore.v1.ListCollectionIdsResponse) => void; /** + * Callback as used by {@link google.firestore.v1.Firestore#batchWrite}. + * @param error Error, if any + * @param [response] BatchWriteResponse + */ + type BatchWriteCallback = (error: (Error|null), response?: google.firestore.v1.BatchWriteResponse) => void; + + /* * Callback as used by {@link google.firestore.v1.Firestore#createDocument}. * @param error Error, if any * @param [response] Document @@ -3019,6 +3040,58 @@ export namespace google { public nextPageToken: string; } + /** Properties of a BatchWriteRequest. */ + interface IBatchWriteRequest { + + /** BatchWriteRequest database */ + database?: (string|null); + + /** BatchWriteRequest writes */ + writes?: (google.firestore.v1.IWrite[]|null); + } + + /** Represents a BatchWriteRequest. */ + class BatchWriteRequest implements IBatchWriteRequest { + + /** + * Constructs a new BatchWriteRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IBatchWriteRequest); + + /** BatchWriteRequest database. */ + public database: string; + + /** BatchWriteRequest writes. */ + public writes: google.firestore.v1.IWrite[]; + } + + /** Properties of a BatchWriteResponse. */ + interface IBatchWriteResponse { + + /** BatchWriteResponse writeResults */ + writeResults?: (google.firestore.v1.IWriteResult[]|null); + + /** BatchWriteResponse status */ + status?: (google.rpc.IStatus[]|null); + } + + /** Represents a BatchWriteResponse. */ + class BatchWriteResponse implements IBatchWriteResponse { + + /** + * Constructs a new BatchWriteResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IBatchWriteResponse); + + /** BatchWriteResponse writeResults. */ + public writeResults: google.firestore.v1.IWriteResult[]; + + /** BatchWriteResponse status. */ + public status: google.rpc.IStatus[]; + } + /** Properties of a StructuredQuery. */ interface IStructuredQuery { diff --git a/dev/protos/firestore_v1_proto_api.js b/dev/protos/firestore_v1_proto_api.js index 860d68df5..5fd8fd789 100644 --- a/dev/protos/firestore_v1_proto_api.js +++ b/dev/protos/firestore_v1_proto_api.js @@ -3547,6 +3547,39 @@ $root.google = (function() { */ /** + * Callback as used by {@link google.firestore.v1.Firestore#batchWrite}. + * @memberof google.firestore.v1.Firestore + * @typedef BatchWriteCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1.BatchWriteResponse} [response] BatchWriteResponse + */ + + /** + * Calls BatchWrite. + * @function batchWrite + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IBatchWriteRequest} request BatchWriteRequest message or plain object + * @param {google.firestore.v1.Firestore.BatchWriteCallback} callback Node-style callback called with the error, if any, and BatchWriteResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.batchWrite = function batchWrite(request, callback) { + return this.rpcCall(batchWrite, $root.google.firestore.v1.BatchWriteRequest, $root.google.firestore.v1.BatchWriteResponse, request, callback); + }, "name", { value: "BatchWrite" }); + + /** + * Calls BatchWrite. + * @function batchWrite + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IBatchWriteRequest} request BatchWriteRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /* * Callback as used by {@link google.firestore.v1.Firestore#createDocument}. * @memberof google.firestore.v1.Firestore * @typedef CreateDocumentCallback @@ -5239,6 +5272,97 @@ $root.google = (function() { return ListCollectionIdsResponse; })(); + v1.BatchWriteRequest = (function() { + + /** + * Properties of a BatchWriteRequest. + * @memberof google.firestore.v1 + * @interface IBatchWriteRequest + * @property {string|null} [database] BatchWriteRequest database + * @property {Array.|null} [writes] BatchWriteRequest writes + */ + + /** + * Constructs a new BatchWriteRequest. + * @memberof google.firestore.v1 + * @classdesc Represents a BatchWriteRequest. + * @implements IBatchWriteRequest + * @constructor + * @param {google.firestore.v1.IBatchWriteRequest=} [properties] Properties to set + */ + function BatchWriteRequest(properties) { + this.writes = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BatchWriteRequest database. + * @member {string} database + * @memberof google.firestore.v1.BatchWriteRequest + * @instance + */ + BatchWriteRequest.prototype.database = ""; + + /** + * BatchWriteRequest writes. + * @member {Array.} writes + * @memberof google.firestore.v1.BatchWriteRequest + * @instance + */ + BatchWriteRequest.prototype.writes = $util.emptyArray; + + return BatchWriteRequest; + })(); + + v1.BatchWriteResponse = (function() { + + /** + * Properties of a BatchWriteResponse. + * @memberof google.firestore.v1 + * @interface IBatchWriteResponse + * @property {Array.|null} [writeResults] BatchWriteResponse writeResults + * @property {Array.|null} [status] BatchWriteResponse status + */ + + /** + * Constructs a new BatchWriteResponse. + * @memberof google.firestore.v1 + * @classdesc Represents a BatchWriteResponse. + * @implements IBatchWriteResponse + * @constructor + * @param {google.firestore.v1.IBatchWriteResponse=} [properties] Properties to set + */ + function BatchWriteResponse(properties) { + this.writeResults = []; + this.status = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BatchWriteResponse writeResults. + * @member {Array.} writeResults + * @memberof google.firestore.v1.BatchWriteResponse + * @instance + */ + BatchWriteResponse.prototype.writeResults = $util.emptyArray; + + /** + * BatchWriteResponse status. + * @member {Array.} status + * @memberof google.firestore.v1.BatchWriteResponse + * @instance + */ + BatchWriteResponse.prototype.status = $util.emptyArray; + + return BatchWriteResponse; + })(); + v1.StructuredQuery = (function() { /** diff --git a/dev/protos/google/firestore/v1/firestore.proto b/dev/protos/google/firestore/v1/firestore.proto index 5f9b6d732..c2c374e9d 100644 --- a/dev/protos/google/firestore/v1/firestore.proto +++ b/dev/protos/google/firestore/v1/firestore.proto @@ -161,6 +161,14 @@ service Firestore { option (google.api.method_signature) = "parent"; } + // Commit a batch of non-transactional writes. + rpc BatchWrite(BatchWriteRequest) returns (BatchWriteResponse) { + option (google.api.http) = { + post: "/v1beta1/{database=projects/*/databases/*}/documents:batchWrite" + body: "*" + }; + } + // Creates a new document. rpc CreateDocument(CreateDocumentRequest) returns (Document) { option (google.api.http) = { @@ -756,3 +764,33 @@ message ListCollectionIdsResponse { // A page token that may be used to continue the list. string next_page_token = 2; } + +// The request for [Firestore.BatchWrite][]. +message BatchWriteRequest { + // The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1; + // The writes to apply. + // The writes are not applied atomically, and can be applied out of order. + // More than 1 write per document is not allowed. + // The success status of each write is independent of the other ones (some may + // fail and some may succeed) and is specified in the BatchWriteResponse. + // Note that the writes here are not applied atomically but the writes in the + // Write(stream WriteRequest) are applied atomically and they cannot be + // batched. + repeated Write writes = 2; +} + +// The response from [Firestore.BatchWrite][]. +message BatchWriteResponse { + // The result of applying the writes. + // + // This i-th write result corresponds to the i-th write in the + // request. + repeated WriteResult write_results = 1; + // The status of applying the writes. + // + // This i-th write status corresponds to the i-th write in the + // request. + repeated google.rpc.Status status = 2; +} diff --git a/dev/src/backoff.ts b/dev/src/backoff.ts index f0bc32017..2aff2a9cc 100644 --- a/dev/src/backoff.ts +++ b/dev/src/backoff.ts @@ -55,9 +55,9 @@ const DEFAULT_JITTER_FACTOR = 1.0; export const MAX_RETRY_ATTEMPTS = 10; /*! - * The timeout handler used by `ExponentialBackoff`. + * The timeout handler used by `ExponentialBackoff` and `BulkWriter`. */ -let delayExecution: (f: () => void, ms: number) => void = setTimeout; +export let delayExecution: (f: () => void, ms: number) => void = setTimeout; /** * Allows overriding of the timeout handler used by the exponential backoff diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts new file mode 100644 index 000000000..7ef437620 --- /dev/null +++ b/dev/src/bulk-writer.ts @@ -0,0 +1,657 @@ +/*! + * 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 assert from 'assert'; + +import {FieldPath, Firestore} from '.'; +import {delayExecution} from './backoff'; +import {RateLimiter} from './rate-limiter'; +import {DocumentReference} from './reference'; +import {Timestamp} from './timestamp'; +import {Precondition, SetOptions, UpdateData} from './types'; +import {Deferred} from './util'; +import {BatchWriteResult, WriteBatch, WriteResult} from './write-batch'; + +/*! + * The maximum number of writes that can be in a single batch. + */ +const MAX_BATCH_SIZE = 500; + +/*! + * The starting maximum number of operations per second as allowed by the + * 500/50/5 rule. + * + * https://cloud.google.com/datastore/docs/best-practices#ramping_up_traffic. + */ +const STARTING_MAXIMUM_OPS_PER_SECOND = 500; + +/*! + * The rate by which to increase the capacity as specified by the 500/50/5 rule. + * + * https://cloud.google.com/datastore/docs/best-practices#ramping_up_traffic. + */ +const RATE_LIMITER_MULTIPLIER = 1.5; + +/*! + * How often the operations per second capacity should increase in milliseconds + * as specified by the 500/50/5 rule. + * + * https://cloud.google.com/datastore/docs/best-practices#ramping_up_traffic. + */ +const RATE_LIMITER_MULTIPLIER_MILLIS = 5 * 60 * 1000; + +/*! + * Used to represent the state of batch. + * + * Writes can only be added while the batch is OPEN. For a batch to be sent, + * the batch must be READY_TO_SEND. After a batch is sent, it is marked as SENT. + */ +enum BatchState { + OPEN, + READY_TO_SEND, + SENT, +} + +/** + * Used to represent a batch on the BatchQueue. + * + * @private + */ +class BulkCommitBatch { + /** + * The state of the batch. + */ + state = BatchState.OPEN; + + // The set of document reference paths present in the WriteBatch. + readonly docPaths = new Set(); + + // A deferred promise that is resolved after the batch has been sent, and a + // response is received. + private completedDeferred = new Deferred(); + + // A map from each WriteBatch operation to its corresponding result. + private resultsMap = new Map>(); + + constructor( + private readonly writeBatch: WriteBatch, + private readonly maxBatchSize: number + ) {} + + /** + * The number of writes in this batch. + */ + get opCount(): number { + return this.resultsMap.size; + } + + /** + * Adds a `create` operation to the WriteBatch. Returns a promise that + * resolves with the result of the write. + */ + create(documentRef: DocumentReference, data: T): Promise { + this.writeBatch.create(documentRef, data); + return this.processOperation(documentRef); + } + + /** + * Adds a `delete` operation to the WriteBatch. Returns a promise that + * resolves with the result of the delete. + */ + delete( + documentRef: DocumentReference, + precondition?: Precondition + ): Promise { + this.writeBatch.delete(documentRef, precondition); + return this.processOperation(documentRef); + } + + /** + * Adds a `set` operation to the WriteBatch. Returns a promise that + * resolves with the result of the write. + */ + set( + documentRef: DocumentReference, + data: T, + options?: SetOptions + ): Promise { + this.writeBatch.set(documentRef, data, options); + return this.processOperation(documentRef); + } + + /** + * Adds an `update` operation to the WriteBatch. Returns a promise that + * resolves with the result of the write. + */ + update( + documentRef: DocumentReference, + dataOrField: UpdateData | string | FieldPath, + ...preconditionOrValues: Array< + {lastUpdateTime?: Timestamp} | unknown | string | FieldPath + > + ): Promise { + this.writeBatch.update(documentRef, dataOrField, ...preconditionOrValues); + return this.processOperation(documentRef); + } + + /** + * Helper to update data structures associated with the operation and + * return the result. + */ + private processOperation( + documentRef: DocumentReference + ): Promise { + assert( + !this.docPaths.has(documentRef.path), + 'Batch should not contain writes to the same document' + ); + assert( + this.state === BatchState.OPEN, + 'Batch should be OPEN when adding writes' + ); + this.docPaths.add(documentRef.path); + const deferred = new Deferred(); + this.resultsMap.set(this.opCount, deferred); + + if (this.opCount === this.maxBatchSize) { + this.state = BatchState.READY_TO_SEND; + } + + return deferred.promise.then(result => { + if (result.writeTime) { + return new WriteResult(result.writeTime); + } else { + throw result.status; + } + }); + } + + /** + * Commits the batch and returns a promise that resolves with the result of + * all writes in this batch. + */ + bulkCommit(): Promise { + assert( + this.state === BatchState.READY_TO_SEND, + 'The batch should be marked as READY_TO_SEND before committing' + ); + this.state = BatchState.SENT; + return this.writeBatch.bulkCommit(); + } + + /** + * Resolves the individual operations in the batch with the results. + */ + processResults(results: BatchWriteResult[], error?: Error): void { + if (error === undefined) { + for (let i = 0; i < this.opCount; i++) { + this.resultsMap.get(i)!.resolve(results[i]); + } + } else { + for (let i = 0; i < this.opCount; i++) { + this.resultsMap.get(i)!.reject(error); + } + } + this.completedDeferred.resolve(); + } + + /** + * Returns a promise that resolves when the batch has been sent, and a + * response is received. + */ + awaitBulkCommit(): Promise { + this.markReadyToSend(); + return this.completedDeferred.promise; + } + + markReadyToSend(): void { + if (this.state === BatchState.OPEN) { + this.state = BatchState.READY_TO_SEND; + } + } +} + +/** + * A Firestore BulkWriter than can be used to perform a large number of writes + * in parallel. Writes to the same document will be executed sequentially. + * + * @class + * @private + */ +export class BulkWriter { + /** + * The maximum number of writes that can be in a single batch. + */ + private maxBatchSize = MAX_BATCH_SIZE; + + /** + * A queue of batches to be written. + */ + private batchQueue: BulkCommitBatch[] = []; + + /** + * Whether this BulkWriter instance is closed. Once closed, it cannot be + * opened again. + */ + private closed = false; + + /** + * Rate limiter used to throttle requests as per the 500/50/5 rule. + */ + private rateLimiter: RateLimiter; + + constructor( + private readonly firestore: Firestore, + enableThrottling: boolean + ) { + if (enableThrottling) { + this.rateLimiter = new RateLimiter( + STARTING_MAXIMUM_OPS_PER_SECOND, + RATE_LIMITER_MULTIPLIER, + RATE_LIMITER_MULTIPLIER_MILLIS + ); + } else { + this.rateLimiter = new RateLimiter( + Number.POSITIVE_INFINITY, + Number.POSITIVE_INFINITY, + Number.POSITIVE_INFINITY + ); + } + } + + /** + * Create a document with the provided data. This single operation will fail + * if a document exists at its location. + * + * @param {DocumentReference} documentRef A reference to the document to be + * created. + * @param {T} data The object to serialize as the document. + * @returns {Promise} 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 + * .create(documentRef, {foo: 'bar'}) + * .then(result => { + * console.log('Successfully executed write at: ', result); + * }) + * .catch(err => { + * console.log('Write failed with: ', err); + * }); + * }); + */ + create(documentRef: DocumentReference, data: T): Promise { + this.verifyNotClosed(); + const bulkCommitBatch = this.getEligibleBatch(documentRef); + const resultPromise = bulkCommitBatch.create(documentRef, data); + this.sendReadyBatches(); + return resultPromise; + } + + /** + * Delete a document from the database. + * + * @param {DocumentReference} documentRef A reference to the document to be + * deleted. + * @param {Precondition=} precondition A precondition to enforce for this + * delete. + * @param {Timestamp=} precondition.lastUpdateTime If set, enforces that the + * document was last updated at lastUpdateTime. Fails the batch if the + * document doesn't exist or was last updated at a different time. + * @returns {Promise} 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.doc('col/doc'); + * + * bulkWriter + * .delete(documentRef) + * .then(result => { + * console.log('Successfully deleted document at: ', result); + * }) + * .catch(err => { + * console.log('Delete failed with: ', err); + * }); + * }); + */ + delete( + documentRef: DocumentReference, + precondition?: Precondition + ): Promise { + this.verifyNotClosed(); + const bulkCommitBatch = this.getEligibleBatch(documentRef); + const resultPromise = bulkCommitBatch.delete(documentRef, precondition); + this.sendReadyBatches(); + return resultPromise; + } + + /** + * 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.=} 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} 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( + documentRef: DocumentReference, + data: T, + options?: SetOptions + ): Promise { + this.verifyNotClosed(); + const bulkCommitBatch = this.getEligibleBatch(documentRef); + const resultPromise = bulkCommitBatch.set(documentRef, data, options); + this.sendReadyBatches(); + return resultPromise; + } + + /** + * Update fields of the document referred to by the provided + * [DocumentReference]{@link DocumentReference}. If the document doesn't yet + * exist, the update fails and the entire batch will be rejected. + * + * The update() method accepts either an object with field paths encoded as + * keys and field values encoded as values, or a variable number of arguments + * that alternate between field paths and field values. Nested fields can be + * updated by providing dot-separated field path strings or by providing + * FieldPath objects. + * + * + * A Precondition restricting this update can be specified as the last + * argument. + * + * @param {DocumentReference} documentRef A reference to the document to be + * updated. + * @param {UpdateData|string|FieldPath} dataOrField An object containing the + * fields and values with which to update the document or the path of the + * first field to update. + * @param {...(Precondition|*|string|FieldPath)} preconditionOrValues - An + * alternating list of field paths and values to update or a Precondition to + * restrict this update + * @returns {Promise} 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.doc('col/doc'); + * + * bulkWriter + * .update(documentRef, {foo: 'bar'}) + * .then(result => { + * console.log('Successfully executed write at: ', result); + * }) + * .catch(err => { + * console.log('Write failed with: ', err); + * }); + * }); + */ + update( + documentRef: DocumentReference, + dataOrField: UpdateData | string | FieldPath, + ...preconditionOrValues: Array< + {lastUpdateTime?: Timestamp} | unknown | string | FieldPath + > + ): Promise { + this.verifyNotClosed(); + const bulkCommitBatch = this.getEligibleBatch(documentRef); + const resultPromise = bulkCommitBatch.update( + documentRef, + dataOrField, + ...preconditionOrValues + ); + this.sendReadyBatches(); + return resultPromise; + } + + /** + * Commits all writes that have been enqueued up to this point in parallel. + * + * Returns a Promise that resolves when all currently queued operations have + * been committed. The Promise will never be rejected since the results for + * each individual operation are conveyed via their individual Promises. + * + * The Promise resolves immediately if there are no pending writes. Otherwise, + * the Promise waits for all previously issued writes, but it does not wait + * for writes that were added after the method is called. If you want to wait + * for additional writes, call `flush()` again. + * + * @return {Promise} A promise that resolves when all enqueued writes + * up to this point have been committed. + * + * @example + * let bulkWriter = firestore.bulkWriter(); + * + * bulkWriter.create(documentRef, {foo: 'bar'}); + * bulkWriter.update(documentRef2, {foo: 'bar'}); + * bulkWriter.delete(documentRef3); + * await flush().then(() => { + * console.log('Executed all writes'); + * }); + */ + async flush(): Promise { + this.verifyNotClosed(); + const trackedBatches = this.batchQueue; + const writePromises = trackedBatches.map(batch => batch.awaitBulkCommit()); + this.sendReadyBatches(); + await Promise.all(writePromises); + } + + /** + * Commits all enqueued writes and marks the BulkWriter instance as closed. + * + * After calling `close()`, calling any method wil throw an error. + * + * Returns a Promise that resolves when there are no more pending writes. The + * Promise will never be rejected. Calling this method will send all requests. + * The promise resolves immediately if there are no pending writes. + * + * @return {Promise} A promise that resolves when all enqueued writes + * up to this point have been committed. + * + * @example + * let bulkWriter = firestore.bulkWriter(); + * + * bulkWriter.create(documentRef, {foo: 'bar'}); + * bulkWriter.update(documentRef2, {foo: 'bar'}); + * bulkWriter.delete(documentRef3); + * await close().then(() => { + * console.log('Executed all writes'); + * }); + */ + close(): Promise { + const flushPromise = this.flush(); + this.closed = true; + return flushPromise; + } + + private verifyNotClosed(): void { + if (this.closed) { + throw new Error('BulkWriter has already been closed.'); + } + } + + /** + * Return the first eligible batch that can hold a write to the provided + * reference, or creates one if no eligible batches are found. + * + * @private + */ + private getEligibleBatch(ref: DocumentReference): BulkCommitBatch { + if (this.batchQueue.length > 0) { + const lastBatch = this.batchQueue[this.batchQueue.length - 1]; + if ( + lastBatch.state === BatchState.OPEN && + !lastBatch.docPaths.has(ref.path) + ) { + return lastBatch; + } + } + return this.createNewBatch(); + } + + /** + * Creates a new batch and adds it to the BatchQueue. If there is already a + * batch enqueued, sends the batch after a new one is created. + * + * @private + */ + private createNewBatch(): BulkCommitBatch { + const newBatch = new BulkCommitBatch( + this.firestore.batch(), + this.maxBatchSize + ); + + if (this.batchQueue.length > 0) { + this.batchQueue[this.batchQueue.length - 1].markReadyToSend(); + this.sendReadyBatches(); + } + this.batchQueue.push(newBatch); + return newBatch; + } + + /** + * Attempts to send batches starting from the front of the BatchQueue until a + * batch cannot be sent. + * + * After a batch is complete, try sending batches again. + * + * @private + */ + private sendReadyBatches(): void { + const unsentBatches = this.batchQueue.filter( + batch => batch.state === BatchState.READY_TO_SEND + ); + + let index = 0; + while ( + index < unsentBatches.length && + this.isBatchSendable(unsentBatches[index]) + ) { + const batch = unsentBatches[index]; + + // Send the batch if it is under the rate limit, or schedule another + // attempt after the appropriate timeout. + const delayMs = this.rateLimiter.getNextRequestDelayMs(batch.opCount); + assert(delayMs !== -1, 'Batch size should be under capacity'); + if (delayMs === 0) { + this.sendBatch(batch); + } else { + delayExecution(() => this.sendReadyBatches(), delayMs); + break; + } + + index++; + } + } + + /** + * Sends the provided batch and processes the results. After the batch is + * committed, sends the next group of ready batches. + * + * @private + */ + private sendBatch(batch: BulkCommitBatch): void { + const success = this.rateLimiter.tryMakeRequest(batch.opCount); + assert(success, 'Batch should be under rate limit to be sent.'); + batch + .bulkCommit() + .then(results => { + batch.processResults(results); + }) + .catch((error: Error) => { + batch.processResults([], error); + }) + .then(() => { + // Remove the batch from the BatchQueue after it has been processed. + const batchIndex = this.batchQueue.indexOf(batch); + assert(batchIndex !== -1, 'The batch should be in the BatchQueue'); + this.batchQueue.splice(batchIndex, 1); + + this.sendReadyBatches(); + }); + } + + /** + * Checks that the provided batch is sendable. To be sendable, a batch must: + * (1) be marked as READY_TO_SEND + * (2) not write to references that are currently in flight + * + * @private + */ + private isBatchSendable(batch: BulkCommitBatch): boolean { + if (batch.state !== BatchState.READY_TO_SEND) { + return false; + } + + for (const path of batch.docPaths) { + const isRefInFlight = + this.batchQueue + .filter(batch => batch.state === BatchState.SENT) + .find(batch => batch.docPaths.has(path)) !== undefined; + if (isRefInFlight) { + console.warn( + '[BulkWriter]', + `Duplicate write to document "${path}" detected.`, + 'Writing to the same document multiple times will slow down BulkWriter. ' + + 'Write to unique documents in order to maximize throughput.' + ); + return false; + } + } + + return true; + } + + /** + * Sets the maximum number of allowed operations in a batch. + * + * @private + */ + // Visible for testing. + _setMaxBatchSize(size: number): void { + this.maxBatchSize = size; + } +} diff --git a/dev/src/document.ts b/dev/src/document.ts index 55ffbad44..6ce7ccb99 100644 --- a/dev/src/document.ts +++ b/dev/src/document.ts @@ -452,16 +452,6 @@ export class DocumentSnapshot { return (fields as ApiMapValue)[components[0]]; } - /** - * Checks whether this DocumentSnapshot contains any fields. - * - * @private - * @return {boolean} - */ - get isEmpty(): boolean { - return this._fieldsProto === undefined || isEmpty(this._fieldsProto); - } - /** * Convert a document snapshot to the Firestore 'Document' Protobuf. * @@ -951,29 +941,16 @@ export class DocumentTransform { } /** - * Converts a document transform to the Firestore 'DocumentTransform' Proto. + * Converts a document transform to the Firestore 'FieldTransform' Proto. * * @private * @param serializer The Firestore serializer - * @returns A Firestore 'DocumentTransform' Proto or 'null' if this transform - * is empty. + * @returns A list of Firestore 'FieldTransform' Protos */ - toProto(serializer: Serializer): api.IWrite | null { - if (this.isEmpty) { - return null; - } - - const fieldTransforms: api.DocumentTransform.IFieldTransform[] = []; - for (const [path, transform] of this.transforms) { - fieldTransforms.push(transform.toProto(serializer, path)); - } - - return { - transform: { - document: this.ref.formattedName, - fieldTransforms, - }, - }; + toProto(serializer: Serializer): api.DocumentTransform.IFieldTransform[] { + return Array.from(this.transforms, ([path, transform]) => + transform.toProto(serializer, path) + ); } } diff --git a/dev/src/index.ts b/dev/src/index.ts index eb2c98e80..a51afdd0a 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -21,6 +21,7 @@ import {URL} from 'url'; import {google} from '../protos/firestore_v1_proto_api'; import {ExponentialBackoff, ExponentialBackoffSetting} from './backoff'; +import {BulkWriter} from './bulk-writer'; import {fieldsFromJson, timestampFromJson} from './convert'; import { DocumentSnapshot, @@ -43,6 +44,7 @@ import {Timestamp} from './timestamp'; import {parseGetAllArguments, Transaction} from './transaction'; import { ApiMapValue, + BulkWriterOptions, DocumentData, FirestoreStreamingMethod, FirestoreUnaryMethod, @@ -84,6 +86,7 @@ export {FieldPath} from './path'; export {GeoPoint} from './geo-point'; export {setLogFunction} from './logger'; export { + BulkWriterOptions, FirestoreDataConverter, UpdateData, DocumentData, @@ -640,6 +643,44 @@ export class Firestore { return new WriteBatch(this); } + /** + * Creates a [BulkWriter]{@link BulkWriter}, used for performing + * multiple writes in parallel. Gradually ramps up writes as specified + * by the 500/50/5 rule. + * + * @see [500/50/5 Documentation]{@link https://cloud.google.com/datastore/docs/best-practices#ramping_up_traffic} + * + * @private + * @param {object=} options BulkWriter options. + * @param {boolean=} options.disableThrottling Whether to disable throttling + * as specified by the 500/50/5 rule. + * @returns {WriteBatch} A BulkWriter that operates on this Firestore + * client. + * + * @example + * let bulkWriter = firestore.bulkWriter(); + * + * bulkWriter.create(firestore.doc('col/doc1'), {foo: 'bar'}) + * .then(res => { + * console.log(`Added document at ${res.writeTime}`); + * }); + * bulkWriter.update(firestore.doc('col/doc2'), {foo: 'bar'}) + * .then(res => { + * console.log(`Updated document at ${res.writeTime}`); + * }); + * bulkWriter.delete(firestore.doc('col/doc3')) + * .then(res => { + * console.log(`Deleted document at ${res.writeTime}`); + * }); + * await bulkWriter.flush().then(() => { + * console.log('Executed all writes'); + * }); + * bulkWriter.close(); + */ + _bulkWriter(options?: BulkWriterOptions): BulkWriter { + return new BulkWriter(this, !options?.disableThrottling); + } + /** * Creates a [DocumentSnapshot]{@link DocumentSnapshot} or a * [QueryDocumentSnapshot]{@link QueryDocumentSnapshot} from a diff --git a/dev/src/rate-limiter.ts b/dev/src/rate-limiter.ts new file mode 100644 index 000000000..c3ee91d33 --- /dev/null +++ b/dev/src/rate-limiter.ts @@ -0,0 +1,154 @@ +/*! + * 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 assert from 'assert'; + +import {Timestamp} from './timestamp'; + +/** + * A helper that uses the Token Bucket algorithm to rate limit the number of + * operations that can be made in a second. + * + * Before a given request containing a number of operations can proceed, + * RateLimiter determines doing so stays under the provided rate limits. It can + * also determine how much time is required before a request can be made. + * + * RateLimiter can also implement a gradually increasing rate limit. This is + * used to enforce the 500/50/5 rule + * (https://cloud.google.com/datastore/docs/best-practices#ramping_up_traffic). + * + * @private + */ +export class RateLimiter { + // Number of tokens available. Each operation consumes one token. + availableTokens: number; + + // When the token bucket was last refilled. + lastRefillTimeMillis: number; + + /** + * @param initialCapacity Initial maximum number of operations per second. + * @param multiplier Rate by which to increase the capacity. + * @param multiplierMillis How often the capacity should increase in + * milliseconds. + * @param startTimeMillis The starting time in epoch milliseconds that the + * rate limit is based on. Used for testing the limiter. + */ + constructor( + private readonly initialCapacity: number, + private readonly multiplier: number, + private readonly multiplierMillis: number, + private readonly startTimeMillis = Date.now() + ) { + this.availableTokens = initialCapacity; + this.lastRefillTimeMillis = startTimeMillis; + } + + /** + * Tries to make the number of operations. Returns true if the request + * succeeded and false otherwise. + * + * @param requestTimeMillis The date used to calculate the number of available + * tokens. Used for testing the limiter. + * @private + */ + tryMakeRequest( + numOperations: number, + requestTimeMillis = Date.now() + ): boolean { + this.refillTokens(requestTimeMillis); + if (numOperations <= this.availableTokens) { + this.availableTokens -= numOperations; + return true; + } + return false; + } + + /** + * Returns the number of ms needed to make a request with the provided number + * of operations. Returns 0 if the request can be made with the existing + * capacity. Returns -1 if the request is not possible with the current + * capacity. + * + * @param requestTimeMillis The date used to calculate the number of available + * tokens. Used for testing the limiter. + * @private + */ + getNextRequestDelayMs( + numOperations: number, + requestTimeMillis = Date.now() + ): number { + this.refillTokens(requestTimeMillis); + if (numOperations < this.availableTokens) { + return 0; + } + + const capacity = this.calculateCapacity(requestTimeMillis); + if (capacity < numOperations) { + return -1; + } + + const requiredTokens = numOperations - this.availableTokens; + return Math.ceil((requiredTokens * 1000) / capacity); + } + + /** + * Refills the number of available tokens based on how much time has elapsed + * since the last time the tokens were refilled. + * + * @param requestTimeMillis The date used to calculate the number of available + * tokens. Used for testing the limiter. + * @private + */ + private refillTokens(requestTimeMillis = Date.now()): void { + if (requestTimeMillis >= this.lastRefillTimeMillis) { + const elapsedTime = requestTimeMillis - this.lastRefillTimeMillis; + const capacity = this.calculateCapacity(requestTimeMillis); + const tokensToAdd = Math.floor((elapsedTime * capacity) / 1000); + if (tokensToAdd > 0) { + this.availableTokens = Math.min( + capacity, + this.availableTokens + tokensToAdd + ); + this.lastRefillTimeMillis = requestTimeMillis; + } + } else { + throw new Error( + 'Request time should not be before the last token refill time.' + ); + } + } + + /** + * Calculates the maximum capacity based on the provided date. + * + * @private + */ + // Visible for testing. + calculateCapacity(requestTimeMillis: number): number { + assert( + requestTimeMillis >= this.startTimeMillis, + 'startTime cannot be after currentTime' + ); + const millisElapsed = requestTimeMillis - this.startTimeMillis; + const operationsPerSecond = Math.floor( + Math.pow( + this.multiplier, + Math.floor(millisElapsed / this.multiplierMillis) + ) * this.initialCapacity + ); + return operationsPerSecond; + } +} diff --git a/dev/src/types.ts b/dev/src/types.ts index d318074b4..f43415821 100644 --- a/dev/src/types.ts +++ b/dev/src/types.ts @@ -46,6 +46,10 @@ export interface GapicClient { request: api.ICommitRequest, options?: CallOptions ): Promise<[api.ICommitResponse, unknown, unknown]>; + batchWrite( + request: api.IBatchWriteRequest, + options?: CallOptions + ): Promise<[api.IBatchWriteResponse, unknown, unknown]>; rollback( request: api.IRollbackRequest, options?: CallOptions @@ -73,7 +77,8 @@ export type FirestoreUnaryMethod = | 'listCollectionIds' | 'rollback' | 'beginTransaction' - | 'commit'; + | 'commit' + | 'batchWrite'; /** Streaming methods used in the Firestore SDK. */ export type FirestoreStreamingMethod = @@ -316,6 +321,15 @@ export interface ValidationOptions { allowTransforms: boolean; } +/** + * An options object that can be used to disable request throttling in + * BulkWriter. + */ +export interface BulkWriterOptions { + /** Whether to disable throttling. */ + readonly disableThrottling?: boolean; +} + /** * A Firestore Proto value in ProtoJs format. * @private diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 9c296e78a..20aba0bea 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -48,6 +48,7 @@ import { } from './validate'; import api = google.firestore.v1; +import {GoogleError, Status} from 'google-gax'; /*! * Google Cloud Functions terminates idle connections after two minutes. After @@ -103,11 +104,23 @@ export class WriteResult { } } +/** + * A BatchWriteResult wraps the write time and status returned by Firestore + * when making BatchWriteRequests. + * + * @private + */ +export class BatchWriteResult { + constructor( + readonly writeTime: Timestamp | null, + readonly status: GoogleError + ) {} +} + /** Helper type to manage the list of writes in a WriteBatch. */ // TODO(mrschmidt): Replace with api.IWrite interface WriteOp { - write?: api.IWrite | null; - transform?: api.IWrite | null; + write: api.IWrite; precondition?: api.IPrecondition | null; } @@ -194,12 +207,13 @@ export class WriteBatch { const op = () => { const document = DocumentSnapshot.fromObject(documentRef, firestoreData); - const write = - !document.isEmpty || transform.isEmpty ? document.toProto() : null; + const write = document.toProto(); + if (!transform.isEmpty) { + write.updateTransforms = transform.toProto(this._serializer); + } return { write, - transform: transform.toProto(this._serializer), precondition: precondition.toProto(), }; }; @@ -320,24 +334,21 @@ export class WriteBatch { if (mergePaths) { documentMask!.removeFields(transform.fields); - } else { + } else if (mergeLeaves) { documentMask = DocumentMask.fromObject(firestoreData); } - const hasDocumentData = !document.isEmpty || !documentMask!.isEmpty; - - let write; + const write = document.toProto(); + if (!transform.isEmpty) { + write.updateTransforms = transform.toProto(this._serializer); + } - if (!mergePaths && !mergeLeaves) { - write = document.toProto(); - } else if (hasDocumentData || transform.isEmpty) { - write = document.toProto()!; + if (mergePaths || mergeLeaves) { write.updateMask = documentMask!.toProto(); } return { write, - transform: transform.toProto(this._serializer), }; }; @@ -474,16 +485,13 @@ export class WriteBatch { const op = () => { const document = DocumentSnapshot.fromUpdateMap(documentRef, updateMap); - let write: api.IWrite | null = null; - - if (!document.isEmpty || !documentMask.isEmpty) { - write = document.toProto(); - write!.updateMask = documentMask.toProto(); + const write = document.toProto(); + write!.updateMask = documentMask.toProto(); + if (!transform.isEmpty) { + write!.updateTransforms = transform.toProto(this._serializer); } - return { write, - transform: transform.toProto(this._serializer), precondition: precondition.toProto(), }; }; @@ -514,6 +522,47 @@ export class WriteBatch { return this.commit_(); } + /** + * Commits all pending operations to the database and verifies all + * preconditions. + * + * The writes in the batch are not applied atomically and can be applied out + * of order. + * + * @private + */ + async bulkCommit(): Promise { + this._committed = true; + const tag = requestTag(); + await this._firestore.initializeIfNeeded(tag); + + const database = this._firestore.formattedName; + const request: api.IBatchWriteRequest = {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 response = await this._firestore.request< + api.IBatchWriteRequest, + api.BatchWriteResponse + >('batchWrite', request, tag); + + return (response.writeResults || []).map((result, i) => { + const status = response.status[i]; + const error = new GoogleError(status.message || undefined); + error.code = status.code as Status; + return new BatchWriteResult( + result.updateTime ? Timestamp.fromProto(result.updateTime) : null, + error + ); + }); + } + /** * Commit method that takes an optional transaction ID. * @@ -552,85 +601,38 @@ export class WriteBatch { }); } - const request: api.ICommitRequest = {database}; + const request: api.ICommitRequest = {database, writes: []}; const writes = this._ops.map(op => op()); - request.writes = []; for (const req of writes) { - assert( - req.write || req.transform, - 'Either a write or transform must be set' - ); - if (req.precondition) { - (req.write || req.transform)!.currentDocument = req.precondition; - } - - if (req.write) { - request.writes.push(req.write); + req.write!.currentDocument = req.precondition; } - if (req.transform) { - request.writes.push(req.transform); - } + request.writes!.push(req.write); } logger( 'WriteBatch.commit', tag, 'Sending %d writes', - request.writes.length + request.writes!.length ); if (explicitTransaction) { request.transaction = explicitTransaction; } - - return this._firestore - .request('commit', request, tag) - .then(resp => { - const writeResults: WriteResult[] = []; - - if (request.writes!.length > 0) { - assert( - Array.isArray(resp.writeResults) && - request.writes!.length === resp.writeResults.length, - `Expected one write result per operation, but got ${ - resp.writeResults.length - } results for ${request.writes!.length} operations.` - ); - - const commitTime = Timestamp.fromProto(resp.commitTime!); - - let offset = 0; - - for (let i = 0; i < writes.length; ++i) { - const writeRequest = writes[i]; - - // Don't return two write results for a write that contains a - // transform, as the fact that we have to split one write - // operation into two distinct write requests is an implementation - // detail. - if (writeRequest.write && writeRequest.transform) { - // The document transform is always sent last and produces the - // latest update time. - ++offset; - } - - const writeResult = resp.writeResults[i + offset]; - - writeResults.push( - new WriteResult( - writeResult.updateTime - ? Timestamp.fromProto(writeResult.updateTime) - : commitTime - ) - ); - } - } - - return writeResults; - }); + const response = await this._firestore.request< + api.ICommitRequest, + api.CommitResponse + >('commit', request, tag); + + return (response.writeResults || []).map( + writeResult => + new WriteResult( + Timestamp.fromProto(writeResult.updateTime || response.commitTime!) + ) + ); } /** diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 2c7804e48..37b2b6b9d 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -419,6 +419,21 @@ describe('DocumentReference class', () => { }); }); + it('supports increment() with set() with merge', () => { + const baseData = {sum: 1}; + const updateData = {sum: FieldValue.increment(1)}; + const expectedData = {sum: 2}; + + const ref = randomCol.doc('doc'); + return ref + .set(baseData) + .then(() => ref.set(updateData, {merge: true})) + .then(() => ref.get()) + .then(doc => { + expect(doc.data()).to.deep.equal(expectedData); + }); + }); + it('supports arrayUnion()', () => { const baseObject = { a: [], @@ -1991,11 +2006,17 @@ describe('Transaction class', () => { it('has update() method', () => { const ref = randomCol.doc('doc'); return ref - .set({foo: 'bar'}) + .set({ + boo: ['ghost', 'sebastian'], + moo: 'chicken', + }) .then(() => { return firestore.runTransaction(updateFunction => { return updateFunction.get(ref).then(() => { - updateFunction.update(ref, {foo: 'foobar'}); + updateFunction.update(ref, { + boo: FieldValue.arrayRemove('sebastian'), + moo: 'cow', + }); }); }); }) @@ -2003,7 +2024,10 @@ describe('Transaction class', () => { return ref.get(); }) .then(doc => { - expect(doc.get('foo')).to.equal('foobar'); + expect(doc.data()).to.deep.equal({ + boo: ['ghost'], + moo: 'cow', + }); }); }); diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts new file mode 100644 index 000000000..1366ff269 --- /dev/null +++ b/dev/test/bulk-writer.ts @@ -0,0 +1,660 @@ +// 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 {expect} from 'chai'; +import {Status} from 'google-gax'; + +import * as proto from '../protos/firestore_v1_proto_api'; +import { + DocumentData, + Firestore, + setLogFunction, + Timestamp, + WriteResult, +} from '../src'; +import {BulkWriter} from '../src/bulk-writer'; +import {Deferred} from '../src/util'; +import { + ApiOverride, + create, + createInstance, + document, + remove, + response, + set, + update, + updateMask, + verifyInstance, +} from './util/helpers'; + +import api = proto.google.firestore.v1; +import {setTimeoutHandler} from '../src/backoff'; + +// Change the argument to 'console.log' to enable debug output. +setLogFunction(() => {}); + +const PROJECT_ID = 'test-project'; + +interface RequestResponse { + request: api.IBatchWriteRequest; + response: api.IBatchWriteResponse; +} + +describe('BulkWriter', () => { + let firestore: Firestore; + let requestCounter: number; + let opCount: number; + const activeRequestDeferred = new Deferred(); + let activeRequestCounter = 0; + + beforeEach(() => { + requestCounter = 0; + opCount = 0; + }); + + function incrementOpCount(): void { + opCount++; + } + + function verifyOpCount(expected: number): void { + expect(opCount).to.equal(expected); + } + + function setOp(doc: string, value: string): api.IWrite { + return set({ + document: document(doc, 'foo', value), + }).writes![0]; + } + + function updateOp(doc: string, value: string): api.IWrite { + return update({ + document: document(doc, 'foo', value), + mask: updateMask('foo'), + }).writes![0]; + } + + function createOp(doc: string, value: string): api.IWrite { + return create({ + document: document(doc, 'foo', value), + }).writes![0]; + } + + function deleteOp(doc: string): api.IWrite { + return remove(doc).writes![0]; + } + + function createRequest(requests: api.IWrite[]): api.IBatchWriteRequest { + return { + writes: requests, + }; + } + + function successResponse(seconds: number): api.IBatchWriteResponse { + return { + writeResults: [ + { + updateTime: { + nanos: 0, + seconds, + }, + }, + ], + status: [{code: Status.OK}], + }; + } + + function failResponse(): api.IBatchWriteResponse { + return { + writeResults: [ + { + updateTime: null, + }, + ], + status: [{code: Status.UNAVAILABLE}], + }; + } + + function mergeResponses( + responses: api.IBatchWriteResponse[] + ): api.IBatchWriteResponse { + return { + writeResults: responses.map(v => v.writeResults![0]), + status: responses.map(v => v.status![0]), + }; + } + + /** + * Creates an instance with the mocked objects. + * + * @param enforceSingleConcurrentRequest Whether to check that there is only + * one active request at a time. If true, the `activeRequestDeferred` must be + * manually resolved for the response to return. + */ + function instantiateInstance( + mock: RequestResponse[], + enforceSingleConcurrentRequest = false + ): Promise { + const overrides: ApiOverride = { + batchWrite: async request => { + expect(request).to.deep.eq({ + database: `projects/${PROJECT_ID}/databases/(default)`, + writes: mock[requestCounter].request.writes, + }); + if (enforceSingleConcurrentRequest) { + activeRequestCounter++; + + // This expect statement is used to test that only one request is + // made at a time. + expect(activeRequestCounter).to.equal(1); + await activeRequestDeferred.promise; + activeRequestCounter--; + } + + const responsePromise = response({ + writeResults: mock[requestCounter].response.writeResults, + status: mock[requestCounter].response.status, + }); + requestCounter++; + return responsePromise; + }, + }; + return createInstance(overrides).then(firestoreClient => { + firestore = firestoreClient; + return firestore._bulkWriter(); + }); + } + + afterEach(() => verifyInstance(firestore)); + + it('has a set() method', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([setOp('doc', 'bar')]), + response: successResponse(2), + }, + ]); + const doc = firestore.doc('collectionId/doc'); + let writeResult: WriteResult; + bulkWriter.set(doc, {foo: 'bar'}).then(result => { + incrementOpCount(); + writeResult = result; + }); + return bulkWriter.close().then(async () => { + verifyOpCount(1); + expect(writeResult.writeTime.isEqual(new Timestamp(2, 0))).to.be.true; + }); + }); + + it('has an update() method', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([updateOp('doc', 'bar')]), + response: successResponse(2), + }, + ]); + const doc = firestore.doc('collectionId/doc'); + let writeResult: WriteResult; + bulkWriter.update(doc, {foo: 'bar'}).then(result => { + incrementOpCount(); + writeResult = result; + }); + return bulkWriter.close().then(async () => { + verifyOpCount(1); + expect(writeResult.writeTime.isEqual(new Timestamp(2, 0))).to.be.true; + }); + }); + + it('has a delete() method', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([deleteOp('doc')]), + response: successResponse(2), + }, + ]); + const doc = firestore.doc('collectionId/doc'); + let writeResult: WriteResult; + bulkWriter.delete(doc).then(result => { + incrementOpCount(); + writeResult = result; + }); + return bulkWriter.close().then(async () => { + verifyOpCount(1); + expect(writeResult.writeTime.isEqual(new Timestamp(2, 0))).to.be.true; + }); + }); + + it('has a create() method', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([createOp('doc', 'bar')]), + response: successResponse(2), + }, + ]); + const doc = firestore.doc('collectionId/doc'); + let writeResult: WriteResult; + bulkWriter.create(doc, {foo: 'bar'}).then(result => { + incrementOpCount(); + writeResult = result; + }); + return bulkWriter.close().then(async () => { + verifyOpCount(1); + expect(writeResult.writeTime.isEqual(new Timestamp(2, 0))).to.be.true; + }); + }); + + it('surfaces errors', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([setOp('doc', 'bar')]), + response: failResponse(), + }, + ]); + + const doc = firestore.doc('collectionId/doc'); + bulkWriter.set(doc, {foo: 'bar'}).catch(err => { + incrementOpCount(); + expect(err.code).to.equal(Status.UNAVAILABLE); + }); + + return bulkWriter.close().then(async () => verifyOpCount(1)); + }); + + it('flush() resolves immediately if there are no writes', async () => { + const bulkWriter = await instantiateInstance([]); + return bulkWriter.flush().then(() => verifyOpCount(0)); + }); + + it('adds writes to a new batch after calling flush()', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([createOp('doc', 'bar')]), + response: successResponse(2), + }, + { + request: createRequest([setOp('doc2', 'bar1')]), + response: successResponse(2), + }, + ]); + bulkWriter + .create(firestore.doc('collectionId/doc'), {foo: 'bar'}) + .then(incrementOpCount); + bulkWriter.flush(); + bulkWriter + .set(firestore.doc('collectionId/doc2'), {foo: 'bar1'}) + .then(incrementOpCount); + await bulkWriter.close().then(async () => { + verifyOpCount(2); + }); + }); + + it('close() sends all writes', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([createOp('doc', 'bar')]), + response: successResponse(2), + }, + ]); + const doc = firestore.doc('collectionId/doc'); + bulkWriter.create(doc, {foo: 'bar'}).then(incrementOpCount); + return bulkWriter.close().then(async () => { + verifyOpCount(1); + }); + }); + + it('close() resolves immediately if there are no writes', async () => { + const bulkWriter = await instantiateInstance([]); + return bulkWriter.close().then(() => verifyOpCount(0)); + }); + + it('cannot call methods after close() is called', async () => { + const bulkWriter = await instantiateInstance([]); + + const expected = 'BulkWriter has already been closed.'; + const doc = firestore.doc('collectionId/doc'); + await bulkWriter.close(); + expect(() => bulkWriter.set(doc, {})).to.throw(expected); + expect(() => bulkWriter.create(doc, {})).to.throw(expected); + expect(() => bulkWriter.update(doc, {})).to.throw(expected); + expect(() => bulkWriter.delete(doc)).to.throw(expected); + expect(bulkWriter.flush()).to.eventually.be.rejectedWith(expected); + expect(bulkWriter.close()).to.eventually.be.rejectedWith(expected); + }); + + it('sends writes to the same document in separate batches', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([setOp('doc', 'bar')]), + response: successResponse(0), + }, + { + request: createRequest([updateOp('doc', 'bar1')]), + response: successResponse(1), + }, + ]); + + // Create two document references pointing to the same document. + const doc = firestore.doc('collectionId/doc'); + const doc2 = firestore.doc('collectionId/doc'); + bulkWriter.set(doc, {foo: 'bar'}).then(incrementOpCount); + bulkWriter.update(doc2, {foo: 'bar1'}).then(incrementOpCount); + + return bulkWriter.close().then(async () => { + verifyOpCount(2); + }); + }); + + it('sends writes to different documents in the same batch', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([setOp('doc1', 'bar'), updateOp('doc2', 'bar')]), + response: mergeResponses([successResponse(0), successResponse(1)]), + }, + ]); + + const doc1 = firestore.doc('collectionId/doc1'); + const doc2 = firestore.doc('collectionId/doc2'); + bulkWriter.set(doc1, {foo: 'bar'}).then(incrementOpCount); + bulkWriter.update(doc2, {foo: 'bar'}).then(incrementOpCount); + + return bulkWriter.close().then(async () => { + verifyOpCount(2); + }); + }); + + it('splits into multiple batches after exceeding maximum batch size', async () => { + const arrayRange = Array.from(new Array(6), (_, i) => i); + const requests = arrayRange.map(i => setOp('doc' + i, 'bar')); + const responses = arrayRange.map(i => successResponse(i)); + const bulkWriter = await instantiateInstance([ + { + request: createRequest([requests[0], requests[1]]), + response: mergeResponses([responses[0], responses[1]]), + }, + { + request: createRequest([requests[2], requests[3]]), + response: mergeResponses([responses[2], responses[3]]), + }, + { + request: createRequest([requests[4], requests[5]]), + response: mergeResponses([responses[4], responses[5]]), + }, + ]); + + bulkWriter._setMaxBatchSize(2); + for (let i = 0; i < 6; i++) { + bulkWriter + .set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}) + .then(incrementOpCount); + } + + return bulkWriter.close().then(async () => { + verifyOpCount(6); + }); + }); + + it('sends existing batches when a new batch is created', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([setOp('doc', 'bar')]), + response: successResponse(0), + }, + { + request: createRequest([ + updateOp('doc', 'bar1'), + createOp('doc2', 'bar1'), + ]), + response: mergeResponses([successResponse(1), successResponse(2)]), + }, + ]); + + bulkWriter._setMaxBatchSize(2); + + const doc = firestore.doc('collectionId/doc'); + const doc2 = firestore.doc('collectionId/doc2'); + + // Create a new batch by writing to the same document. + const setPromise = bulkWriter.set(doc, {foo: 'bar'}).then(incrementOpCount); + const updatePromise = bulkWriter + .update(doc, {foo: 'bar1'}) + .then(incrementOpCount); + await setPromise; + + // Create a new batch by reaching the batch size limit. + const createPromise = bulkWriter + .create(doc2, {foo: 'bar1'}) + .then(incrementOpCount); + + await updatePromise; + await createPromise; + verifyOpCount(3); + return bulkWriter.close(); + }); + + it('sends batches automatically when the batch size limit is reached', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([ + setOp('doc1', 'bar'), + updateOp('doc2', 'bar'), + createOp('doc3', 'bar'), + ]), + response: mergeResponses([ + successResponse(0), + successResponse(1), + successResponse(2), + ]), + }, + { + request: createRequest([deleteOp('doc4')]), + response: successResponse(3), + }, + ]); + + bulkWriter._setMaxBatchSize(3); + const promise1 = bulkWriter + .set(firestore.doc('collectionId/doc1'), {foo: 'bar'}) + .then(incrementOpCount); + const promise2 = bulkWriter + .update(firestore.doc('collectionId/doc2'), {foo: 'bar'}) + .then(incrementOpCount); + const promise3 = bulkWriter + .create(firestore.doc('collectionId/doc3'), {foo: 'bar'}) + .then(incrementOpCount); + + // The 4th write should not sent because it should be in a new batch. + bulkWriter + .delete(firestore.doc('collectionId/doc4')) + .then(incrementOpCount); + + await Promise.all([promise1, promise2, promise3]).then(() => { + verifyOpCount(3); + }); + + return bulkWriter.close().then(async () => { + verifyOpCount(4); + }); + }); + + it('does not send batches if a document containing the same write is in flight', async () => { + const bulkWriter = await instantiateInstance( + [ + { + request: createRequest([setOp('doc1', 'bar'), setOp('doc2', 'bar')]), + response: mergeResponses([successResponse(1), successResponse(2)]), + }, + { + request: createRequest([setOp('doc1', 'bar')]), + response: successResponse(3), + }, + ], + /* enforceSingleConcurrentRequest= */ true + ); + bulkWriter.set(firestore.doc('collectionId/doc1'), {foo: 'bar'}); + bulkWriter.set(firestore.doc('collectionId/doc2'), {foo: 'bar'}); + const flush1 = bulkWriter.flush(); + // The third write will be placed in a new batch + bulkWriter.set(firestore.doc('collectionId/doc1'), {foo: 'bar'}); + const flush2 = bulkWriter.flush(); + activeRequestDeferred.resolve(); + await flush1; + await flush2; + return bulkWriter.close(); + }); + + it('supports different type converters', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([setOp('doc1', 'boo'), setOp('doc2', 'moo')]), + response: mergeResponses([successResponse(1), successResponse(2)]), + }, + ]); + + class Boo {} + const booConverter = { + toFirestore(): DocumentData { + return {foo: 'boo'}; + }, + fromFirestore(): Boo { + return new Boo(); + }, + }; + + class Moo {} + const mooConverter = { + toFirestore(): DocumentData { + return {foo: 'moo'}; + }, + fromFirestore(): Moo { + return new Moo(); + }, + }; + + const doc1 = firestore.doc('collectionId/doc1').withConverter(booConverter); + const doc2 = firestore.doc('collectionId/doc2').withConverter(mooConverter); + bulkWriter.set(doc1, new Boo()).then(incrementOpCount); + bulkWriter.set(doc2, new Moo()).then(incrementOpCount); + return bulkWriter.close().then(() => verifyOpCount(2)); + }); + + describe('500/50/5 support', () => { + afterEach(() => setTimeoutHandler(setTimeout)); + + it('does not send batches if doing so exceeds the rate limit', done => { + // The test is considered a success if BulkWriter tries to send the second + // batch again after a timeout. + + const arrayRange = Array.from(new Array(500), (_, i) => i); + const requests1 = arrayRange.map(i => setOp('doc' + i, 'bar')); + const responses1 = arrayRange.map(i => successResponse(i)); + const arrayRange2 = [500, 501, 502, 503, 504]; + const requests2 = arrayRange2.map(i => setOp('doc' + i, 'bar')); + const responses2 = arrayRange2.map(i => successResponse(i)); + + instantiateInstance([ + { + request: createRequest(requests1), + response: mergeResponses(responses1), + }, + { + request: createRequest(requests2), + response: mergeResponses(responses2), + }, + ]).then(bulkWriter => { + setTimeoutHandler(() => + done(new Error('This batch should not have a timeout')) + ); + for (let i = 0; i < 500; i++) { + bulkWriter + .set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}) + .then(incrementOpCount); + } + bulkWriter.flush(); + + // Sending this next batch would go over the 500/50/5 capacity, so + // check that BulkWriter doesn't send this batch until the first batch + // is resolved. + setTimeoutHandler((_, timeout) => { + // Check that BulkWriter has not yet sent the 2nd batch. + expect(requestCounter).to.equal(0); + expect(timeout).to.be.greaterThan(0); + done(); + }); + for (let i = 500; i < 505; i++) { + bulkWriter + .set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}) + .then(incrementOpCount); + } + return bulkWriter.flush(); + }); + }); + }); + + describe('if bulkCommit() fails', async () => { + function instantiateInstance(): Promise { + const overrides: ApiOverride = { + batchWrite: () => { + throw new Error('Mock batchWrite failed in test'); + }, + }; + return createInstance(overrides).then(firestoreClient => { + firestore = firestoreClient; + return firestore._bulkWriter(); + }); + } + it('flush() should not fail', async () => { + const bulkWriter = await instantiateInstance(); + bulkWriter + .create(firestore.doc('collectionId/doc'), {foo: 'bar'}) + .catch(incrementOpCount); + bulkWriter + .set(firestore.doc('collectionId/doc2'), {foo: 'bar'}) + .catch(incrementOpCount); + await bulkWriter.flush(); + verifyOpCount(2); + + return bulkWriter.close(); + }); + + it('close() should not fail', async () => { + const bulkWriter = await instantiateInstance(); + bulkWriter + .create(firestore.doc('collectionId/doc'), {foo: 'bar'}) + .catch(incrementOpCount); + bulkWriter + .set(firestore.doc('collectionId/doc2'), {foo: 'bar'}) + .catch(incrementOpCount); + + return bulkWriter.close().then(() => verifyOpCount(2)); + }); + + it('all individual writes are rejected', async () => { + const bulkWriter = await instantiateInstance(); + bulkWriter + .create(firestore.doc('collectionId/doc'), {foo: 'bar'}) + .catch(err => { + expect(err.message).to.equal('Mock batchWrite failed in test'); + incrementOpCount(); + }); + + bulkWriter + .set(firestore.doc('collectionId/doc2'), {foo: 'bar'}) + .catch(err => { + expect(err.message).to.equal('Mock batchWrite failed in test'); + incrementOpCount(); + }); + + return bulkWriter.close().then(() => verifyOpCount(2)); + }); + }); +}); diff --git a/dev/test/document.ts b/dev/test/document.ts index 19a655815..bc33f9224 100644 --- a/dev/test/document.ts +++ b/dev/test/document.ts @@ -913,7 +913,9 @@ describe('set document', () => { requestEquals( request, set({ + document: document('documentId'), transforms: [serverTimestamp('a'), serverTimestamp('b.c')], + mask: updateMask(), }) ); return response(writeResult(1)); @@ -941,7 +943,7 @@ describe('set document', () => { transforms: [serverTimestamp('a'), serverTimestamp('b.c')], }) ); - return response(writeResult(2)); + return response(writeResult(1)); }, }; @@ -1121,7 +1123,7 @@ describe('set document', () => { ], }) ); - return response(writeResult(2)); + return response(writeResult(1)); }, }; @@ -1354,6 +1356,7 @@ describe('create document', () => { requestEquals( request, create({ + document: document('documentId'), transforms: [ serverTimestamp('field'), serverTimestamp('map.field'), @@ -1458,7 +1461,7 @@ describe('update document', () => { mask: updateMask('a', 'foo'), }) ); - return response(writeResult(2)); + return response(writeResult(1)); }, }; @@ -1474,7 +1477,13 @@ describe('update document', () => { it('skips write for single field transform', () => { const overrides: ApiOverride = { commit: request => { - requestEquals(request, update({transforms: [serverTimestamp('a')]})); + requestEquals( + request, + update({ + document: document('documentId'), + transforms: [serverTimestamp('a')], + }) + ); return response(writeResult(1)); }, }; diff --git a/dev/test/field-value.ts b/dev/test/field-value.ts index 4007e142c..a49d2387d 100644 --- a/dev/test/field-value.ts +++ b/dev/test/field-value.ts @@ -108,7 +108,7 @@ describe('FieldValue.arrayUnion()', () => { requestEquals(request, expectedRequest); - return response(writeResult(2)); + return response(writeResult(1)); }, }; @@ -172,7 +172,7 @@ describe('FieldValue.increment()', () => { ], }); requestEquals(request, expectedRequest); - return response(writeResult(2)); + return response(writeResult(1)); }, }; @@ -215,7 +215,7 @@ describe('FieldValue.arrayRemove()', () => { }); requestEquals(request, expectedRequest); - return response(writeResult(2)); + return response(writeResult(1)); }, }; @@ -260,7 +260,7 @@ describe('FieldValue.serverTimestamp()', () => { }); requestEquals(request, expectedRequest); - return response(writeResult(2)); + return response(writeResult(1)); }, }; diff --git a/dev/test/rate-limiter.ts b/dev/test/rate-limiter.ts new file mode 100644 index 000000000..e3271303d --- /dev/null +++ b/dev/test/rate-limiter.ts @@ -0,0 +1,109 @@ +// 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 {expect} from 'chai'; + +import {RateLimiter} from '../src/rate-limiter'; + +describe('RateLimiter', () => { + let limiter: RateLimiter; + + beforeEach(() => { + limiter = new RateLimiter( + /* initialCapacity= */ 500, + /* multiplier= */ 1.5, + /* multiplierMillis= */ 5 * 60 * 1000, + /* startTime= */ new Date(0).getTime() + ); + }); + + it('accepts and rejects requests based on capacity', () => { + expect(limiter.tryMakeRequest(250, new Date(0).getTime())).to.be.true; + expect(limiter.tryMakeRequest(250, new Date(0).getTime())).to.be.true; + + // Once tokens have been used, further requests should fail. + expect(limiter.tryMakeRequest(1, new Date(0).getTime())).to.be.false; + + // Tokens will only refill up to max capacity. + expect(limiter.tryMakeRequest(501, new Date(1 * 1000).getTime())).to.be + .false; + expect(limiter.tryMakeRequest(500, new Date(1 * 1000).getTime())).to.be + .true; + + // Tokens will refill incrementally based on the number of ms elapsed. + expect(limiter.tryMakeRequest(250, new Date(1 * 1000 + 499).getTime())).to + .be.false; + expect(limiter.tryMakeRequest(249, new Date(1 * 1000 + 500).getTime())).to + .be.true; + + // Scales with multiplier. + expect(limiter.tryMakeRequest(751, new Date((5 * 60 - 1) * 1000).getTime())) + .to.be.false; + expect(limiter.tryMakeRequest(751, new Date(5 * 60 * 1000).getTime())).to.be + .false; + expect(limiter.tryMakeRequest(750, new Date(5 * 60 * 1000).getTime())).to.be + .true; + + // Tokens will never exceed capacity. + expect(limiter.tryMakeRequest(751, new Date((5 * 60 + 3) * 1000).getTime())) + .to.be.false; + + // Rejects requests made before lastRefillTime + expect(() => + limiter.tryMakeRequest(751, new Date((5 * 60 + 2) * 1000).getTime()) + ).to.throw('Request time should not be before the last token refill time.'); + }); + + it('calculates the number of ms needed to place the next request', () => { + // Should return 0 if there are enough tokens for the request to be made. + let timestamp = new Date(0).getTime(); + expect(limiter.getNextRequestDelayMs(500, timestamp)).to.equal(0); + + // Should factor in remaining tokens when calculating the time. + expect(limiter.tryMakeRequest(250, timestamp)); + expect(limiter.getNextRequestDelayMs(500, timestamp)).to.equal(500); + + // Once tokens have been used, should calculate time before next request. + timestamp = new Date(1 * 1000).getTime(); + expect(limiter.tryMakeRequest(500, timestamp)).to.be.true; + expect(limiter.getNextRequestDelayMs(100, timestamp)).to.equal(200); + expect(limiter.getNextRequestDelayMs(250, timestamp)).to.equal(500); + expect(limiter.getNextRequestDelayMs(500, timestamp)).to.equal(1000); + expect(limiter.getNextRequestDelayMs(501, timestamp)).to.equal(-1); + + // Scales with multiplier. + timestamp = new Date(5 * 60 * 1000).getTime(); + expect(limiter.tryMakeRequest(750, timestamp)).to.be.true; + expect(limiter.getNextRequestDelayMs(250, timestamp)).to.equal(334); + expect(limiter.getNextRequestDelayMs(500, timestamp)).to.equal(667); + expect(limiter.getNextRequestDelayMs(750, timestamp)).to.equal(1000); + expect(limiter.getNextRequestDelayMs(751, timestamp)).to.equal(-1); + }); + + it('calculates the maximum number of operations correctly', async () => { + expect(limiter.calculateCapacity(new Date(0).getTime())).to.equal(500); + expect( + limiter.calculateCapacity(new Date(5 * 60 * 1000).getTime()) + ).to.equal(750); + expect( + limiter.calculateCapacity(new Date(10 * 60 * 1000).getTime()) + ).to.equal(1125); + expect( + limiter.calculateCapacity(new Date(15 * 60 * 1000).getTime()) + ).to.equal(1687); + expect( + limiter.calculateCapacity(new Date(90 * 60 * 1000).getTime()) + ).to.equal(738945); + }); +}); diff --git a/dev/test/util/helpers.ts b/dev/test/util/helpers.ts index 655b73d87..f78ccaa9b 100644 --- a/dev/test/util/helpers.ts +++ b/dev/test/util/helpers.ts @@ -89,27 +89,23 @@ export function verifyInstance(firestore: Firestore): Promise { } function write( - document: api.IDocument | null, + document: api.IDocument, mask: api.IDocumentMask | null, transforms: api.DocumentTransform.IFieldTransform[] | null, precondition: api.IPrecondition | null ): api.ICommitRequest { const writes: api.IWrite[] = []; + const update = Object.assign({}, document); + delete update.updateTime; + delete update.createTime; + writes.push({update}); - if (document) { - const update = Object.assign({}, document); - delete update.updateTime; - delete update.createTime; - writes.push({update}); - if (mask) { - writes[0].updateMask = mask; - } + if (mask) { + writes[0].updateMask = mask; } if (transforms) { - writes.push({ - transform: {document: DOCUMENT_NAME, fieldTransforms: transforms}, - }); + writes[0].updateTransforms = transforms; } if (precondition) { @@ -124,47 +120,37 @@ export function updateMask(...fieldPaths: string[]): api.IDocumentMask { } export function set(opts: { - document?: api.IDocument; + document: api.IDocument; transforms?: api.DocumentTransform.IFieldTransform[]; mask?: api.IDocumentMask; }): api.ICommitRequest { return write( - opts.document || null, + opts.document, opts.mask || null, opts.transforms || null, - null + /* precondition= */ null ); } export function update(opts: { - document?: api.IDocument; + document: api.IDocument; transforms?: api.DocumentTransform.IFieldTransform[]; mask?: api.IDocumentMask; precondition?: api.IPrecondition; }): api.ICommitRequest { const precondition = opts.precondition || {exists: true}; const mask = opts.mask || updateMask(); - return write( - opts.document || null, - mask, - opts.transforms || null, - precondition - ); + return write(opts.document, mask, opts.transforms || null, precondition); } export function create(opts: { - document?: api.IDocument; + document: api.IDocument; transforms?: api.DocumentTransform.IFieldTransform[]; mask?: api.IDocumentMask; }): api.ICommitRequest { - return write( - opts.document || null, - /* updateMask */ null, - opts.transforms || null, - { - exists: false, - } - ); + return write(opts.document, /* updateMask= */ null, opts.transforms || null, { + exists: false, + }); } function value(value: string | api.IValue): api.IValue { diff --git a/dev/test/write-batch.ts b/dev/test/write-batch.ts index 692d40abb..76b348afb 100644 --- a/dev/test/write-batch.ts +++ b/dev/test/write-batch.ts @@ -14,6 +14,7 @@ import {expect} from 'chai'; +import {Status} from 'google-gax'; import { FieldValue, Firestore, @@ -22,6 +23,7 @@ import { WriteBatch, WriteResult, } from '../src'; +import {BatchWriteResult} from '../src/write-batch'; import { ApiOverride, createInstance, @@ -64,8 +66,8 @@ describe('set() method', () => { ); }); - it('accepts preconditions', () => { - writeBatch.set(firestore.doc('sub/doc'), {exists: false}); + it('accepts document data', () => { + writeBatch.set(firestore.doc('sub/doc'), {foo: 'bar'}); }); it('works with null objects', () => { @@ -197,17 +199,12 @@ describe('batch support', () => { fields: {}, name: documentName, }, - }, - { - transform: { - document: documentName, - fieldTransforms: [ - { - fieldPath: 'foo', - setToServerValue: REQUEST_TIME, - }, - ], - }, + updateTransforms: [ + { + fieldPath: 'foo', + setToServerValue: REQUEST_TIME, + }, + ], }, { currentDocument: { @@ -245,14 +242,6 @@ describe('batch support', () => { seconds: 0, }, writeResults: [ - // This write result conforms to the Write + - // DocumentTransform and won't be returned in the response. - { - updateTime: { - nanos: 1337, - seconds: 1337, - }, - }, { updateTime: { nanos: 0, @@ -475,3 +464,88 @@ describe('batch support', () => { }); }); }); + +describe('bulkCommit support', () => { + const documentName = `projects/${PROJECT_ID}/databases/(default)/documents/col/doc`; + + let firestore: Firestore; + let writeBatch: WriteBatch; + + beforeEach(() => { + const overrides: ApiOverride = { + batchWrite: request => { + expect(request).to.deep.eq({ + database: `projects/${PROJECT_ID}/databases/(default)`, + writes: [ + { + update: { + fields: {}, + name: documentName, + }, + updateTransforms: [ + { + fieldPath: 'foo', + setToServerValue: REQUEST_TIME, + }, + ], + }, + { + currentDocument: { + exists: true, + }, + update: { + fields: { + foo: { + stringValue: 'bar', + }, + }, + name: documentName, + }, + updateMask: { + fieldPaths: ['foo'], + }, + }, + ], + }); + return response({ + writeResults: [ + { + updateTime: { + nanos: 0, + seconds: 0, + }, + }, + { + updateTime: null, + }, + ], + status: [{code: 0}, {code: 14}], + }); + }, + }; + return createInstance(overrides).then(firestoreClient => { + firestore = firestoreClient; + writeBatch = firestore.batch(); + }); + }); + + afterEach(() => verifyInstance(firestore)); + + function verifyResponse(writeResults: BatchWriteResult[]) { + expect(writeResults[0].writeTime!.isEqual(new Timestamp(0, 0))).to.be.true; + expect(writeResults[1].writeTime).to.be.null; + expect(writeResults[0].status.code).to.equal(Status.OK); + expect(writeResults[1].status.code).to.equal(Status.UNAVAILABLE); + } + + it('bulkCommit', () => { + const documentName = firestore.doc('col/doc'); + + writeBatch.set(documentName, {foo: FieldValue.serverTimestamp()}); + writeBatch.update(documentName, {foo: 'bar'}); + + return writeBatch.bulkCommit().then(resp => { + verifyResponse(resp); + }); + }); +}); diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 165da504d..6f2d2734c 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -301,7 +301,6 @@ declare namespace FirebaseFirestore { export class Transaction { private constructor(); - /** * Retrieves a query result. Holds a pessimistic lock on all returned * documents. From 608392bc21408996eed0e6c20dff54be844c0ff3 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 28 Apr 2020 17:39:31 -0700 Subject: [PATCH 110/337] fix: i thought i pushed but i didn't (#1053) --- dev/src/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index a51afdd0a..929647f71 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -672,10 +672,9 @@ export class Firestore { * .then(res => { * console.log(`Deleted document at ${res.writeTime}`); * }); - * await bulkWriter.flush().then(() => { + * await bulkWriter.close().then(() => { * console.log('Executed all writes'); * }); - * bulkWriter.close(); */ _bulkWriter(options?: BulkWriterOptions): BulkWriter { return new BulkWriter(this, !options?.disableThrottling); From d47e69737977b563c079bd4c740f158867600d30 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 29 Apr 2020 12:58:03 -0700 Subject: [PATCH 111/337] chore: add vscode files (#1056) --- .gitignore | 1 - .vscode/launch.json | 62 +++++++++++++++++++++++++++++++++++++++++++ .vscode/settings.json | 3 +++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index 549ef6081..0ed8914a9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,5 @@ system-test/*key.json *.lock build/ package-lock.json -.vscode .DS_Store __pycache__ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..74be9c937 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,62 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Unit Tests", + "program": "${workspaceRoot}/node_modules/.bin/_mocha", + "cwd": "${workspaceRoot}/dev", + "args": [ + "--require", "ts-node/register/type-check", + "--no-timeouts", + "test/*.ts", + "--exit" + ], + "env": { + "TS_NODE_FILES": "true", + }, + "sourceMaps": true, + "protocol": "inspector" + }, + { + "type": "node", + "request": "launch", + "name": "System Tests", + "program": "${workspaceRoot}/node_modules/.bin/_mocha", + "cwd": "${workspaceRoot}/dev", + "args": [ + "--require", "ts-node/register/type-check", + "--no-timeouts", + "system-test/*.ts", + "--exit" + ], + "env": { + "TS_NODE_FILES": "true", + }, + "sourceMaps": true, + "protocol": "inspector" + }, + { + "type": "node", + "request": "launch", + "name": "Conformance Tests", + "program": "${workspaceRoot}/node_modules/.bin/_mocha", + "cwd": "${workspaceRoot}/dev", + "args": [ + "--require", "ts-node/register/type-check", + "conformance/*.ts", + "--no-timeouts", + "--exit" + ], + "env": { + "TS_NODE_FILES": "true", + }, + "sourceMaps": true, + "protocol": "inspector" + }, + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..25fa6215f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib" +} From 30008b093a9872e34a83209e94de3dca09e89fe7 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Fri, 1 May 2020 11:44:42 -0700 Subject: [PATCH 112/337] fix: remove type dependency on Moment (#1063) This breaks my local build since Moment cannot be resolved and also breaks CI: https://github.com/googleapis/nodejs-firestore/pull/1062/checks?check_run_id=637099360 --- dev/src/serializer.ts | 7 +++---- package.json | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/dev/src/serializer.ts b/dev/src/serializer.ts index 3dc61b970..b5ac8f92c 100644 --- a/dev/src/serializer.ts +++ b/dev/src/serializer.ts @@ -14,8 +14,6 @@ * limitations under the License. */ -import {Moment} from 'moment'; - import * as proto from '../protos/firestore_v1_proto_api'; import {detectValueType} from './convert'; @@ -396,12 +394,13 @@ export function validateUserInput( * Returns true if value is a MomentJs date object. * @private */ -function isMomentJsType(value: unknown): value is Moment { +function isMomentJsType(value: unknown): value is {toDate: () => Date} { return ( typeof value === 'object' && value !== null && value.constructor && value.constructor.name === 'Moment' && - typeof (value as Moment).toDate === 'function' + // tslint:disable-next-line:no-any + typeof (value as any).toDate === 'function' ); } diff --git a/package.json b/package.json index 9418a4dc8..92945aec8 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,6 @@ "@types/duplexify": "^3.5.0", "@types/extend": "^3.0.0", "@types/mocha": "^7.0.0", - "@types/moment": "^2.13.0", "@types/node": "^12.12.17", "@types/through2": "^2.0.34", "c8": "^7.0.0", From 681c7e3f4d16b89479fcdde03b12cc76b143803a Mon Sep 17 00:00:00 2001 From: Cameron Zahedi Date: Wed, 6 May 2020 12:48:37 -0600 Subject: [PATCH 113/337] chore: add CODEOWNERS Simplifying team repo triage/access via a GitHub team --- .github/CODEOWNERS | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..69318aa39 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,10 @@ +# Code owners file. +# This file controls who is tagged for review for any given pull request. +# +# For syntax help see: +# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax + + +# The firestore-dpe team is the default owner for anything not +# explicitly taken by someone else. +* @GoogleCloudPlatform/firestore-dpe From f66a08978f11915d8662f964867a966ff75f6e96 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Fri, 8 May 2020 12:36:44 -0700 Subject: [PATCH 114/337] fix: allow running source with ts-node (#1074) ts-node is not able to resolve the FirebaseFirestore namespace. It only exists in our types. --- dev/src/types.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/dev/src/types.ts b/dev/src/types.ts index f43415821..92d298aae 100644 --- a/dev/src/types.ts +++ b/dev/src/types.ts @@ -155,14 +155,10 @@ export interface FirestoreDataConverter { * @private */ export const defaultConverter: FirestoreDataConverter = { - toFirestore( - modelObject: FirebaseFirestore.DocumentData - ): FirebaseFirestore.DocumentData { + toFirestore(modelObject: DocumentData): DocumentData { return modelObject; }, - fromFirestore( - data: FirebaseFirestore.DocumentData - ): FirebaseFirestore.DocumentData { + fromFirestore(data: DocumentData): DocumentData { return data; }, }; From 31e8a69fe8b02cdb375a54c0cd325760e9ec470a Mon Sep 17 00:00:00 2001 From: Cameron Zahedi Date: Mon, 11 May 2020 16:02:04 -0600 Subject: [PATCH 115/337] build: point to team in correct org (#1076) needs to be googleapis@ team --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 69318aa39..39a8fc72b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -7,4 +7,4 @@ # The firestore-dpe team is the default owner for anything not # explicitly taken by someone else. -* @GoogleCloudPlatform/firestore-dpe +* @googleapis/firestore-dpe From de733c821152a32893e7fccf30cdf96a2f8050eb Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 12 May 2020 18:30:58 -0700 Subject: [PATCH 116/337] feat: add ignoreUndefinedProperties option (#1062) --- dev/src/document.ts | 4 +- dev/src/field-value.ts | 25 ++- dev/src/index.ts | 2 +- dev/src/reference.ts | 22 +- dev/src/serializer.ts | 30 ++- dev/src/types.ts | 15 ++ dev/src/write-batch.ts | 55 +++-- dev/test/ignore-undefined.ts | 297 +++++++++++++++++++++++++ dev/test/query.ts | 8 +- dev/test/util/helpers.ts | 4 +- samples/quickstart.js | 2 +- samples/solution-counters.js | 12 +- samples/test/quickstart.test.js | 14 +- samples/test/solution-counters.test.js | 18 +- scripts/license.js | 4 +- types/firestore.d.ts | 9 + 16 files changed, 450 insertions(+), 71 deletions(-) create mode 100644 dev/test/ignore-undefined.ts diff --git a/dev/src/document.ts b/dev/src/document.ts index 6ce7ccb99..37cdc9bfd 100644 --- a/dev/src/document.ts +++ b/dev/src/document.ts @@ -937,7 +937,9 @@ export class DocumentTransform { * @private */ validate(): void { - this.transforms.forEach(transform => transform.validate()); + const allowUndefined = !!this.ref.firestore._settings + .ignoreUndefinedProperties; + this.transforms.forEach(transform => transform.validate(allowUndefined)); } /** diff --git a/dev/src/field-value.ts b/dev/src/field-value.ts index 814e02a92..6282acced 100644 --- a/dev/src/field-value.ts +++ b/dev/src/field-value.ts @@ -226,8 +226,12 @@ export abstract class FieldTransform extends FieldValue { /** The method name used to obtain the field transform. */ abstract get methodName(): string; - /** Performs input validation on the values of this field transform. */ - abstract validate(): void; + /** + * Performs input validation on the values of this field transform. + * + * @param allowUndefined Whether to allow nested properties that are `undefined`. + */ + abstract validate(allowUndefined: boolean): void; /*** * The proto representation for this field transform. @@ -422,9 +426,9 @@ class ArrayUnionTransform extends FieldTransform { return 'FieldValue.arrayUnion'; } - validate(): void { + validate(allowUndefined: boolean): void { for (let i = 0; i < this.elements.length; ++i) { - validateArrayElement(i, this.elements[i]); + validateArrayElement(i, this.elements[i], allowUndefined); } } @@ -478,9 +482,9 @@ class ArrayRemoveTransform extends FieldTransform { return 'FieldValue.arrayRemove'; } - validate(): void { + validate(allowUndefined: boolean): void { for (let i = 0; i < this.elements.length; ++i) { - validateArrayElement(i, this.elements[i]); + validateArrayElement(i, this.elements[i], allowUndefined); } } @@ -512,8 +516,13 @@ class ArrayRemoveTransform extends FieldTransform { * @private * @param arg The argument name or argument index (for varargs methods). * @param value The value to validate. + * @param allowUndefined Whether to allow nested properties that are `undefined`. */ -function validateArrayElement(arg: string | number, value: unknown): void { +function validateArrayElement( + arg: string | number, + value: unknown, + allowUndefined: boolean +): void { if (Array.isArray(value)) { throw new Error( `${invalidArgumentMessage( @@ -526,7 +535,7 @@ function validateArrayElement(arg: string | number, value: unknown): void { arg, value, 'array element', - /*path=*/ {allowDeletes: 'none', allowTransforms: false}, + /*path=*/ {allowDeletes: 'none', allowTransforms: false, allowUndefined}, /*path=*/ undefined, /*level=*/ 0, /*inArray=*/ true diff --git a/dev/src/index.ts b/dev/src/index.ts index 929647f71..9fdefe2fb 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -271,7 +271,7 @@ export class Firestore { * The configuration options for the GAPIC client. * @private */ - private _settings: Settings = {}; + _settings: Settings = {}; /** * Settings for the exponential backoff used by the streaming endpoints. diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 00e3a602f..f05a083be 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -1108,6 +1108,7 @@ export class QueryOptions { */ export class Query { private readonly _serializer: Serializer; + protected readonly _allowUndefined: boolean; /** * @hideconstructor @@ -1120,6 +1121,8 @@ export class Query { protected readonly _queryOptions: QueryOptions ) { this._serializer = new Serializer(_firestore); + this._allowUndefined = !!this._firestore._settings + .ignoreUndefinedProperties; } /** @@ -1228,7 +1231,7 @@ export class Query { ): Query { validateFieldPath('fieldPath', fieldPath); opStr = validateQueryOperator('opStr', opStr, value); - validateQueryValue('value', value); + validateQueryValue('value', value, this._allowUndefined); if (this._queryOptions.startAt || this._queryOptions.endAt) { throw new Error( @@ -1550,7 +1553,7 @@ export class Query { fieldValue = this.validateReference(fieldValue); } - validateQueryValue(i, fieldValue); + validateQueryValue(i, fieldValue, this._allowUndefined); options.values!.push(fieldValue); } @@ -2397,7 +2400,12 @@ export class CollectionReference extends Query { */ add(data: T): Promise> { const firestoreData = this._queryOptions.converter.toFirestore(data); - validateDocumentData('data', firestoreData, /*allowDeletes=*/ false); + validateDocumentData( + 'data', + firestoreData, + /*allowDeletes=*/ false, + this._allowUndefined + ); const documentRef = this.doc(); return documentRef.create(data).then(() => documentRef); @@ -2549,11 +2557,17 @@ export function validateDocumentReference( * @private * @param arg The argument name or argument index (for varargs methods). * @param value The argument to validate. + * @param allowUndefined Whether to allow nested properties that are `undefined`. */ -function validateQueryValue(arg: string | number, value: unknown): void { +function validateQueryValue( + arg: string | number, + value: unknown, + allowUndefined: boolean +): void { validateUserInput(arg, value, 'query constraint', { allowDeletes: 'none', allowTransforms: false, + allowUndefined, }); } diff --git a/dev/src/serializer.ts b/dev/src/serializer.ts index b5ac8f92c..3936bfbcc 100644 --- a/dev/src/serializer.ts +++ b/dev/src/serializer.ts @@ -52,6 +52,7 @@ export interface Serializable { * @private */ export class Serializer { + private allowUndefined: boolean; private createReference: (path: string) => DocumentReference; constructor(firestore: Firestore) { @@ -59,6 +60,7 @@ export class Serializer { // its `.doc()` method. This avoid a circular reference, which breaks // JSON.stringify(). this.createReference = path => firestore.doc(path); + this.allowUndefined = !!firestore._settings.ignoreUndefinedProperties; } /** @@ -192,6 +194,10 @@ export class Serializer { return map; } + if (val === undefined && this.allowUndefined) { + return null; + } + throw new Error(`Cannot encode value: ${val}`); } @@ -276,7 +282,7 @@ export class Serializer { * @param path The field path to validate. * @param options Validation options * @param level The current depth of the traversal. This is used to decide - * whether deletes are allowed in conjunction with `allowDeletes: root`. + * whether undefined values or deletes are allowed. * @param inArray Whether we are inside an array. * @throws when the object is invalid. */ @@ -329,12 +335,22 @@ export function validateUserInput( ); } } else if (value === undefined) { - throw new Error( - `${invalidArgumentMessage( - arg, - desc - )} Cannot use "undefined" as a Firestore value${fieldPathMessage}.` - ); + if (options.allowUndefined && level === 0) { + throw new Error( + `${invalidArgumentMessage( + arg, + desc + )} "undefined" values are only ignored in object properties.` + ); + } else if (!options.allowUndefined) { + throw new Error( + `${invalidArgumentMessage( + arg, + desc + )} Cannot use "undefined" as a Firestore value${fieldPathMessage}. ` + + 'If you want to ignore undefined values, enable `ignoreUndefinedProperties`.' + ); + } } else if (value instanceof DeleteTransform) { if (inArray) { throw new Error( diff --git a/dev/src/types.ts b/dev/src/types.ts index 92d298aae..b51ff37ff 100644 --- a/dev/src/types.ts +++ b/dev/src/types.ts @@ -203,6 +203,15 @@ export interface Settings { */ maxIdleChannels?: number; + /** + * Whether to skip nested properties that are set to `undefined` during object + * serialization. If set to `true`, these properties will be skipped and are + * not be written to Firestore. If the setting is set `false` or omitted, + * the SDK will throw an exception when it encounters properties of type + * `undefined`. + */ + ignoreUndefinedProperties?: boolean; + // tslint:disable-next-line:no-any [key: string]: any; // Accept other properties, such as GRPC settings. } @@ -315,6 +324,12 @@ export interface ValidationOptions { /** Whether server transforms are supported. */ allowTransforms: boolean; + + /** + * Whether undefined values are allowed. Undefined values cannot appear at + * the root. + */ + allowUndefined: boolean; } /** diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 20aba0bea..8c01eae1d 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -133,6 +133,7 @@ interface WriteOp { export class WriteBatch { private readonly _firestore: Firestore; private readonly _serializer: Serializer; + private readonly _allowUndefined: boolean; /** * An array of write operations that are executed as part of the commit. The @@ -151,6 +152,7 @@ export class WriteBatch { constructor(firestore: Firestore) { this._firestore = firestore; this._serializer = new Serializer(firestore); + this._allowUndefined = !!firestore._settings.ignoreUndefinedProperties; } /** @@ -196,7 +198,12 @@ export class WriteBatch { create(documentRef: DocumentReference, data: T): WriteBatch { validateDocumentReference('documentRef', documentRef); const firestoreData = documentRef._converter.toFirestore(data); - validateDocumentData('data', firestoreData, /* allowDeletes= */ false); + validateDocumentData( + 'data', + firestoreData, + /* allowDeletes= */ false, + this._allowUndefined + ); this.verifyNotCommitted(); @@ -314,7 +321,8 @@ export class WriteBatch { validateDocumentData( 'data', firestoreData, - /* allowDeletes= */ !!(mergePaths || mergeLeaves) + /* allowDeletes= */ !!(mergePaths || mergeLeaves), + this._allowUndefined ); this.verifyNotCommitted(); @@ -431,7 +439,12 @@ export class WriteBatch { validateMinNumberOfArguments('update', arguments, i + 1); const fieldPath = FieldPath.fromArgument(arguments[i]); - validateFieldValue(i, arguments[i + 1], fieldPath); + validateFieldValue( + i, + arguments[i + 1], + this._allowUndefined, + fieldPath + ); updateMap.set(fieldPath, arguments[i + 1]); } } @@ -443,7 +456,7 @@ export class WriteBatch { } } else { try { - validateUpdateMap('dataOrField', dataOrField); + validateUpdateMap('dataOrField', dataOrField, this._allowUndefined); validateMaxNumberOfArguments('update', arguments, 3); const data = dataOrField as UpdateData; @@ -846,29 +859,24 @@ export function validateSetOptions( * @param arg The argument name or argument index (for varargs methods). * @param obj JavaScript object to validate. * @param allowDeletes Whether to allow FieldValue.delete() sentinels. + * @param allowUndefined Whether to allow nested properties that are `undefined`. * @throws when the object is invalid. */ export function validateDocumentData( arg: string | number, obj: unknown, - allowDeletes: boolean + allowDeletes: boolean, + allowUndefined: boolean ): void { if (!isPlainObject(obj)) { throw new Error(customObjectMessage(arg, obj)); } - for (const prop of Object.keys(obj)) { - validateUserInput( - arg, - obj[prop], - 'Firestore document', - { - allowDeletes: allowDeletes ? 'all' : 'none', - allowTransforms: true, - }, - new FieldPath(prop) - ); - } + validateUserInput(arg, obj, 'Firestore document', { + allowDeletes: allowDeletes ? 'all' : 'none', + allowTransforms: true, + allowUndefined, + }); } /** @@ -877,18 +885,20 @@ export function validateDocumentData( * @private * @param arg The argument name or argument index (for varargs methods). * @param val The value to verify. + * @param allowUndefined Whether to allow nested properties that are `undefined`. * @param path The path to show in the error message. */ export function validateFieldValue( arg: string | number, val: unknown, + allowUndefined: boolean, path?: FieldPath ): void { validateUserInput( arg, val, 'Firestore value', - {allowDeletes: 'root', allowTransforms: true}, + {allowDeletes: 'root', allowTransforms: true, allowUndefined}, path ); } @@ -929,9 +939,14 @@ function validateNoConflictingFields( * @private * @param arg The argument name or argument index (for varargs methods). * @param obj JavaScript object to validate. + * @param allowUndefined Whether to allow nested properties that are `undefined`. * @throws when the object is invalid. */ -function validateUpdateMap(arg: string | number, obj: unknown): void { +function validateUpdateMap( + arg: string | number, + obj: unknown, + allowUndefined: boolean +): void { if (!isPlainObject(obj)) { throw new Error(customObjectMessage(arg, obj)); } @@ -940,7 +955,7 @@ function validateUpdateMap(arg: string | number, obj: unknown): void { if (obj) { for (const prop of Object.keys(obj)) { isEmpty = false; - validateFieldValue(arg, obj[prop], new FieldPath(prop)); + validateFieldValue(arg, obj[prop], allowUndefined, new FieldPath(prop)); } } diff --git a/dev/test/ignore-undefined.ts b/dev/test/ignore-undefined.ts new file mode 100644 index 000000000..0b20f32d9 --- /dev/null +++ b/dev/test/ignore-undefined.ts @@ -0,0 +1,297 @@ +// 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 {expect} from 'chai'; +import {fieldFilters, orderBy, queryEquals, startAt} from './query'; +import { + ApiOverride, + create, + createInstance, + document, + InvalidApiUsage, + requestEquals, + response, + set, + stream, + update, + updateMask, + writeResult, +} from './util/helpers'; + +const FOO_MAP = { + mapValue: { + fields: { + bar: { + stringValue: 'bar', + }, + }, + }, +}; + +describe('ignores undefined values', () => { + it('in set()', () => { + const overrides: ApiOverride = { + commit: request => { + requestEquals( + request, + set({ + document: document('documentId', 'foo', 'foo'), + }) + ); + return response(writeResult(1)); + }, + }; + + return createInstance(overrides, {ignoreUndefinedProperties: true}).then( + firestore => { + return firestore.doc('collectionId/documentId').set({ + foo: 'foo', + bar: undefined, + }); + } + ); + }); + + it('in create()', () => { + const overrides: ApiOverride = { + commit: request => { + requestEquals( + request, + create({ + document: document('documentId', 'foo', 'foo'), + }) + ); + return response(writeResult(1)); + }, + }; + + return createInstance(overrides, {ignoreUndefinedProperties: true}).then( + firestore => { + return firestore.doc('collectionId/documentId').create({ + foo: 'foo', + bar: undefined, + }); + } + ); + }); + + it('in update()', () => { + const overrides: ApiOverride = { + commit: request => { + requestEquals( + request, + update({ + document: document('documentId', 'foo', FOO_MAP), + mask: updateMask('foo'), + }) + ); + return response(writeResult(1)); + }, + }; + + return createInstance(overrides, {ignoreUndefinedProperties: true}).then( + async firestore => { + await firestore.doc('collectionId/documentId').update('foo', { + bar: 'bar', + baz: undefined, + }); + await firestore + .doc('collectionId/documentId') + .update({foo: {bar: 'bar', baz: undefined}}); + } + ); + }); + + it('in query filters', () => { + const overrides: ApiOverride = { + runQuery: request => { + queryEquals(request, fieldFilters('foo', 'EQUAL', FOO_MAP)); + return stream(); + }, + }; + + return createInstance(overrides, {ignoreUndefinedProperties: true}).then( + firestore => { + return firestore + .collection('collectionId') + .where('foo', '==', {bar: 'bar', baz: undefined}) + .get(); + } + ); + }); + + it('in query cursors', () => { + const overrides: ApiOverride = { + runQuery: request => { + queryEquals( + request, + orderBy('foo', 'ASCENDING'), + startAt(true, FOO_MAP) + ); + return stream(); + }, + }; + + return createInstance(overrides, {ignoreUndefinedProperties: true}).then( + firestore => { + return firestore + .collection('collectionId') + .orderBy('foo') + .startAt({bar: 'bar', baz: undefined}) + .get(); + } + ); + }); +}); + +describe('rejects undefined values', () => { + describe('in top-level call', () => { + it('to set()', () => { + return createInstance({}, {ignoreUndefinedProperties: true}).then( + firestore => { + expect(() => { + firestore + .doc('collectionId/documentId') + .set(undefined as InvalidApiUsage); + }).to.throw( + 'Value for argument "data" is not a valid Firestore document. Input is not a plain JavaScript object.' + ); + } + ); + }); + + it('to create()', () => { + return createInstance({}, {ignoreUndefinedProperties: true}).then( + firestore => { + expect(() => { + firestore + .doc('collectionId/documentId') + .create(undefined as InvalidApiUsage); + }).to.throw( + 'Value for argument "data" is not a valid Firestore document. Input is not a plain JavaScript object.' + ); + } + ); + }); + + it('to update()', () => { + return createInstance({}, {ignoreUndefinedProperties: true}).then( + firestore => { + expect(() => { + firestore.doc('collectionId/documentId').update('foo', undefined); + }).to.throw( + '"undefined" values are only ignored in object properties.' + ); + } + ); + }); + + it('to Query.where()', () => { + return createInstance({}, {ignoreUndefinedProperties: true}).then( + firestore => { + expect(() => { + firestore + .doc('collectionId/documentId') + .collection('collectionId') + .where('foo', '==', undefined); + }).to.throw( + '"undefined" values are only ignored in object properties.' + ); + } + ); + }); + + it('to Query.startAt()', () => { + return createInstance({}, {ignoreUndefinedProperties: true}).then( + firestore => { + expect(() => { + firestore + .doc('collectionId/documentId') + .collection('collectionId') + .orderBy('foo') + .startAt(undefined); + }).to.throw( + '"undefined" values are only ignored in object properties.' + ); + } + ); + }); + }); + + describe('when setting is disabled', () => { + it('in set()', () => { + return createInstance({}).then(firestore => { + expect(() => { + firestore.doc('collectionId/documentId').set({ + foo: 'foo', + bar: undefined, + }); + }).to.throw( + 'Cannot use "undefined" as a Firestore value (found in field "bar"). If you want to ignore undefined values, enable `ignoreUndefinedProperties`.' + ); + }); + }); + + it('in create()', () => { + return createInstance({}).then(firestore => { + expect(() => { + firestore.doc('collectionId/documentId').create({ + foo: 'foo', + bar: undefined, + }); + }).to.throw( + 'Cannot use "undefined" as a Firestore value (found in field "bar"). If you want to ignore undefined values, enable `ignoreUndefinedProperties`.' + ); + }); + }); + + it('in update()', () => { + return createInstance({}).then(firestore => { + expect(() => { + firestore.doc('collectionId/documentId').update('foo', { + foo: 'foo', + bar: undefined, + }); + }).to.throw( + 'Cannot use "undefined" as a Firestore value (found in field "foo.bar"). If you want to ignore undefined values, enable `ignoreUndefinedProperties`.' + ); + }); + }); + + it('in query filters', () => { + return createInstance({}).then(firestore => { + expect(() => { + firestore + .collection('collectionId') + .where('foo', '==', {bar: 'bar', baz: undefined}); + }).to.throw( + 'Cannot use "undefined" as a Firestore value (found in field "baz"). If you want to ignore undefined values, enable `ignoreUndefinedProperties`.' + ); + }); + }); + + it('in query cursors', () => { + return createInstance({}).then(firestore => { + expect(() => { + firestore + .collection('collectionId') + .orderBy('foo') + .startAt({bar: 'bar', baz: undefined}); + }).to.throw( + 'Cannot use "undefined" as a Firestore value (found in field "baz"). If you want to ignore undefined values, enable `ignoreUndefinedProperties`.' + ); + }); + }); + }); +}); diff --git a/dev/test/query.ts b/dev/test/query.ts index 6256fb86b..2b01413c2 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -70,7 +70,7 @@ function snapshot( }); } -function fieldFilters( +export function fieldFilters( fieldPath: string, op: api.StructuredQuery.FieldFilter.Operator, value: string | api.IValue, @@ -162,7 +162,7 @@ function unaryFilters( } } -function orderBy( +export function orderBy( fieldPath: string, direction: api.StructuredQuery.Direction, ...fieldPathAndOrderBys: Array @@ -217,7 +217,7 @@ function select(...fields: string[]): api.IStructuredQuery { return {select}; } -function startAt( +export function startAt( before: boolean, ...values: Array ): api.IStructuredQuery { @@ -267,7 +267,7 @@ function endAt( return {endAt: cursor}; } -function queryEquals( +export function queryEquals( actual: api.IRunQueryRequest | undefined, ...protoComponents: api.IStructuredQuery[] ) { diff --git a/dev/test/util/helpers.ts b/dev/test/util/helpers.ts index f78ccaa9b..3786029a5 100644 --- a/dev/test/util/helpers.ts +++ b/dev/test/util/helpers.ts @@ -19,7 +19,7 @@ import {Duplex} from 'stream'; import * as through2 from 'through2'; import * as proto from '../../protos/firestore_v1_proto_api'; -import {Firestore} from '../../src'; +import {Firestore, Settings} from '../../src'; import {ClientPool} from '../../src/pool'; import {DocumentData, GapicClient} from '../../src/types'; @@ -54,7 +54,7 @@ export type ApiOverride = Partial; */ export function createInstance( apiOverrides?: ApiOverride, - firestoreSettings?: {} + firestoreSettings?: Settings ): Promise { const initializationOptions = { ...{projectId: PROJECT_ID, sslCreds: SSL_CREDENTIALS}, diff --git a/samples/quickstart.js b/samples/quickstart.js index f831da6bd..d0a20d511 100644 --- a/samples/quickstart.js +++ b/samples/quickstart.js @@ -38,7 +38,7 @@ async function quickstart() { console.log('Updated an existing document'); // Read the document. - let doc = await document.get(); + const doc = await document.get(); console.log('Read the document'); // Delete the document. diff --git a/samples/solution-counters.js b/samples/solution-counters.js index 3307ccaf5..c374f3f25 100644 --- a/samples/solution-counters.js +++ b/samples/solution-counters.js @@ -13,14 +13,14 @@ // limitations under the License. 'use strict'; -const { Firestore, FieldValue } = require('@google-cloud/firestore'); +const {Firestore, FieldValue} = require('@google-cloud/firestore'); async function main() { // [START increment_counter] function incrementCounter(docRef, numShards) { const shardId = Math.floor(Math.random() * numShards); const shardRef = docRef.collection('shards').doc(shardId.toString()); - return shardRef.set({ count: FieldValue.increment(1) }, { merge: true }); + return shardRef.set({count: FieldValue.increment(1)}, {merge: true}); } // [END increment_counter] @@ -41,7 +41,7 @@ async function main() { async function deleteDocs(docRef) { const shardsCollectionRef = docRef.collection('shards'); const shardDocs = await shardsCollectionRef.select('id').get(); - let promises = []; + const promises = []; shardDocs.forEach(async (doc) => { promises.push(shardsCollectionRef.doc(doc.id).delete()); }); @@ -51,13 +51,15 @@ async function main() { // Create a new client const firestore = new Firestore(); - const docRef = firestore.doc('distributed_counter_samples/distributed_counter'); + const docRef = firestore.doc( + 'distributed_counter_samples/distributed_counter' + ); const numberOfShards = 10; // Increase the document count return incrementCounter(docRef, numberOfShards).then(async () => { console.log('counter increased'); // Get document count - let count = await getCount(docRef); + const count = await getCount(docRef); console.log(`new count is : ${count}`); // Delete the document await deleteDocs(docRef); diff --git a/samples/test/quickstart.test.js b/samples/test/quickstart.test.js index d574bcc6c..75b04b580 100644 --- a/samples/test/quickstart.test.js +++ b/samples/test/quickstart.test.js @@ -17,14 +17,14 @@ const {execSync} = require('child_process'); const {assert} = require('chai'); const {describe, it} = require('mocha'); -const exec = cmd => execSync(cmd, { encoding: 'utf8' }); +const exec = (cmd) => execSync(cmd, {encoding: 'utf8'}); describe('should make some API calls', () => { it('should run quickstart', () => { - const output = exec('node quickstart.js'); - assert.include(output, 'Entered new data into the document'); - assert.include(output, 'Updated an existing document'); - assert.include(output, 'Read the document'); - assert.include(output, 'Deleted the document'); - }); + const output = exec('node quickstart.js'); + assert.include(output, 'Entered new data into the document'); + assert.include(output, 'Updated an existing document'); + assert.include(output, 'Read the document'); + assert.include(output, 'Deleted the document'); + }); }); diff --git a/samples/test/solution-counters.test.js b/samples/test/solution-counters.test.js index 2561b0e98..dadd44547 100644 --- a/samples/test/solution-counters.test.js +++ b/samples/test/solution-counters.test.js @@ -14,15 +14,15 @@ 'use strict'; -const { execSync } = require('child_process'); -const { assert } = require('chai'); -const exec = cmd => execSync(cmd, { encoding: 'utf8' }); +const {execSync} = require('child_process'); +const {assert} = require('chai'); +const exec = (cmd) => execSync(cmd, {encoding: 'utf8'}); describe('distributed counter', () => { - it('should increase, get counter and delete the docs', () => { - const output = exec('node solution-counters.js'); - assert.include(output, 'counter increased'); - assert.include(output, 'new count is : 1'); - assert.include(output, 'Deleted the document'); - }); + it('should increase, get counter and delete the docs', () => { + const output = exec('node solution-counters.js'); + assert.include(output, 'counter increased'); + assert.include(output, 'new count is : 1'); + assert.include(output, 'Deleted the document'); + }); }); diff --git a/scripts/license.js b/scripts/license.js index 8eef77c12..828e91906 100755 --- a/scripts/license.js +++ b/scripts/license.js @@ -34,6 +34,6 @@ const LICENSE_HEADER = `/*! `; for (const file of process.argv.slice(2)) { - const content = fs.readFileSync(file, 'utf-8'); - fs.writeFileSync(file, `${LICENSE_HEADER}\n${content.trim()}\n`); + const content = fs.readFileSync(file, 'utf-8'); + fs.writeFileSync(file, `${LICENSE_HEADER}\n${content.trim()}\n`); } diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 6f2d2734c..55e7b9870 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -143,6 +143,15 @@ declare namespace FirebaseFirestore { * 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 will be skipped + * and are not be written to Firestore. If the setting is set `false` or + * omitted, the SDK will throw an exception when it encounters properties + * of type `undefined`. + */ + ignoreUndefinedProperties?: boolean; [key: string]: any; // Accept other properties, such as GRPC settings. } From 40f14d267d55e40a82a12de21ed68226866b444d Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 12 May 2020 21:22:35 -0700 Subject: [PATCH 117/337] chore: release 3.8.0 (#1079) --- CHANGELOG.md | 14 ++++++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51de19c6a..32a6815b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [3.8.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.7.5...v3.8.0) (2020-05-13) + + +### Features + +* add ignoreUndefinedProperties option ([#1062](https://www.github.com/googleapis/nodejs-firestore/issues/1062)) ([de733c8](https://www.github.com/googleapis/nodejs-firestore/commit/de733c821152a32893e7fccf30cdf96a2f8050eb)) + + +### Bug Fixes + +* prepare sources for BulkWriter ([#1051](https://www.github.com/googleapis/nodejs-firestore/issues/1051)) ([8c52d47](https://www.github.com/googleapis/nodejs-firestore/commit/8c52d475ae486e2998220947a0b0441d4a95ab49)) +* allow running source with ts-node ([#1074](https://www.github.com/googleapis/nodejs-firestore/issues/1074)) ([f66a089](https://www.github.com/googleapis/nodejs-firestore/commit/f66a08978f11915d8662f964867a966ff75f6e96)) +* remove type dependency on Moment ([#1063](https://www.github.com/googleapis/nodejs-firestore/issues/1063)) ([30008b0](https://www.github.com/googleapis/nodejs-firestore/commit/30008b093a9872e34a83209e94de3dca09e89fe7)) + ### [3.7.5](https://www.github.com/googleapis/nodejs-firestore/compare/v3.7.4...v3.7.5) (2020-04-25) diff --git a/package.json b/package.json index 92945aec8..4e5003c44 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.7.5", + "version": "3.8.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 912fccdce..22bd4a72e 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.7.5" + "@google-cloud/firestore": "^3.8.0" }, "devDependencies": { "chai": "^4.2.0", From 3153dd296891a983b3a0e78354df3fe106ad44a2 Mon Sep 17 00:00:00 2001 From: wu-hui <53845758+wu-hui@users.noreply.github.com> Date: Thu, 14 May 2020 13:35:43 -0400 Subject: [PATCH 118/337] fix: Add tests to check fields used in whereIn should be equality filters (#1081) --- dev/test/query.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/dev/test/query.ts b/dev/test/query.ts index 2b01413c2..475b158c3 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -909,6 +909,41 @@ describe('where() interface', () => { }); }); + it('Fields of IN queries are not used in implicit order by', async () => { + const overrides: ApiOverride = { + runQuery: request => { + queryEquals( + request, + fieldFilters('foo', 'IN', { + arrayValue: { + values: [ + { + stringValue: `bar`, + }, + ], + }, + }), + orderBy('__name__', 'ASCENDING'), + startAt(true, { + referenceValue: + `projects/${PROJECT_ID}/databases/(default)/` + + 'documents/collectionId/doc1', + }) + ); + + return stream(); + }, + }; + + return createInstance(overrides).then(async firestore => { + const collection = firestore.collection('collectionId'); + const query = collection + .where('foo', 'in', ['bar']) + .startAt(await snapshot('collectionId/doc1', {})); + return query.get(); + }); + }); + it('validates references for IN queries', () => { const query = firestore.collection('collectionId'); From ad6b923c9208713efcf1c3053d8803f9f15d4d35 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 21 May 2020 09:49:30 -0700 Subject: [PATCH 119/337] docs: use the Web SDK docs for ignoreUndefinedProperties (#1086) --- dev/src/types.ts | 9 ++++----- types/firestore.d.ts | 7 +++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/dev/src/types.ts b/dev/src/types.ts index b51ff37ff..a2ae70988 100644 --- a/dev/src/types.ts +++ b/dev/src/types.ts @@ -204,11 +204,10 @@ export interface Settings { maxIdleChannels?: number; /** - * Whether to skip nested properties that are set to `undefined` during object - * serialization. If set to `true`, these properties will be skipped and are - * not be written to Firestore. If the setting is set `false` or omitted, - * the SDK will throw an exception when it encounters properties of type - * `undefined`. + * 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; diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 55e7b9870..efa36799d 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -146,10 +146,9 @@ declare namespace FirebaseFirestore { /** * Whether to skip nested properties that are set to `undefined` during - * object serialization. If set to `true`, these properties will be skipped - * and are not be written to Firestore. If the setting is set `false` or - * omitted, the SDK will throw an exception when it encounters properties - * of type `undefined`. + * 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; From 7acdd7e9e0877fd6dbb50539a0a3c1537d30904a Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 26 May 2020 17:43:22 -0700 Subject: [PATCH 120/337] fix: capture error stacks across async calls (#1088) --- dev/src/bulk-writer.ts | 10 ++++++++-- dev/src/index.ts | 14 ++++++++++---- dev/src/reference.ts | 7 +++++-- dev/src/util.ts | 16 ++++++++++++++++ dev/src/write-batch.ts | 9 +++++++-- dev/system-test/firestore.ts | 13 +++++++++++++ 6 files changed, 59 insertions(+), 10 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 7ef437620..02bd6619f 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -21,7 +21,7 @@ import {RateLimiter} from './rate-limiter'; import {DocumentReference} from './reference'; import {Timestamp} from './timestamp'; import {Precondition, SetOptions, UpdateData} from './types'; -import {Deferred} from './util'; +import {Deferred, wrapError} from './util'; import {BatchWriteResult, WriteBatch, WriteResult} from './write-batch'; /*! @@ -188,7 +188,13 @@ class BulkCommitBatch { 'The batch should be marked as READY_TO_SEND before committing' ); this.state = BatchState.SENT; - return this.writeBatch.bulkCommit(); + + // Capture the error stack to preserve stack tracing across async calls. + const stack = Error().stack!; + + return this.writeBatch.bulkCommit().catch(err => { + throw wrapError(err, stack); + }); } /** diff --git a/dev/src/index.ts b/dev/src/index.ts index 9fdefe2fb..79b93b88d 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -53,7 +53,7 @@ import { Settings, UnaryMethod, } from './types'; -import {Deferred, isPermanentRpcError, requestTag} from './util'; +import {Deferred, isPermanentRpcError, requestTag, wrapError} from './util'; import { validateBoolean, validateFunction, @@ -908,9 +908,15 @@ export class Firestore { documentRefsOrReadOptions ); const tag = requestTag(); - return this.initializeIfNeeded(tag).then(() => - this.getAll_(documents, fieldMask, tag) - ); + + // Capture the error stack to preserve stack tracing across async calls. + const stack = Error().stack!; + + return this.initializeIfNeeded(tag) + .then(() => this.getAll_(documents, fieldMask, tag)) + .catch(err => { + throw wrapError(err, stack); + }); } /** diff --git a/dev/src/reference.ts b/dev/src/reference.ts index f05a083be..690e1f794 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -48,7 +48,7 @@ import { UpdateData, WhereFilterOp, } from './types'; -import {autoId, requestTag} from './util'; +import {autoId, requestTag, wrapError} from './util'; import { invalidArgumentMessage, validateEnumValue, @@ -1808,12 +1808,15 @@ export class Query { _get(transactionId?: Uint8Array): Promise> { const docs: Array> = []; + // Capture the error stack to preserve stack tracing across async calls. + const stack = Error().stack!; + return new Promise((resolve, reject) => { let readTime: Timestamp; this._stream(transactionId) .on('error', err => { - reject(err); + reject(wrapError(err, stack)); }) .on('data', result => { readTime = result.readTime; diff --git a/dev/src/util.ts b/dev/src/util.ts index d04253699..15d5f8dd9 100644 --- a/dev/src/util.ts +++ b/dev/src/util.ts @@ -146,3 +146,19 @@ export function isPermanentRpcError( return false; } } + +/** + * Wraps the provided error in a new error that includes the provided stack. + * + * Used to preserve stack traces across async calls. + * @private + */ +export function wrapError(err: Error | string, stack: string): Error { + // TODO(b/157506412): Remove `string` type and clean up any string errors + // that we are throwing. + if (typeof err === 'string') { + throw err; + } + err.stack += '\nCaused by: ' + stack; + return err; +} diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 8c01eae1d..408845189 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -37,7 +37,7 @@ import { UpdateMap, } from './types'; import {DocumentData} from './types'; -import {isObject, isPlainObject, requestTag} from './util'; +import {isObject, isPlainObject, requestTag, wrapError} from './util'; import { customObjectMessage, invalidArgumentMessage, @@ -532,7 +532,12 @@ export class WriteBatch { * }); */ commit(): Promise { - return this.commit_(); + // Capture the error stack to preserve stack tracing across async calls. + const stack = Error().stack!; + + return this.commit_().catch(err => { + throw wrapError(err, stack); + }); } /** diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 37b2b6b9d..5b5822eb7 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -2148,6 +2148,19 @@ describe('WriteBatch class', () => { }); }); + it('has a full stack trace if set() errors', () => { + // Use an invalid document name that the backend will reject. + const ref = randomCol.doc('__doc__'); + const batch = firestore.batch(); + batch.set(ref, {foo: 'a'}); + return batch + .commit() + .then(() => Promise.reject('commit() should have failed')) + .catch((err: Error) => { + expect(err.stack).to.contain('WriteBatch.commit'); + }); + }); + it('has update() method', () => { const ref = randomCol.doc('doc'); const batch = firestore.batch(); From 4f4574afaa8cf817d06b5965492791c2eff01ed5 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 27 May 2020 15:32:36 -0700 Subject: [PATCH 121/337] docs: specify that select() cannot be used with listeners (#1093) --- dev/src/reference.ts | 3 +++ types/firestore.d.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 690e1f794..ccea223c1 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -1281,6 +1281,9 @@ export class Query { * You can specify a list of field paths to return, or use an empty list to * only return the references of matching documents. * + * Queries that contain field masks cannot be listened to via `onSnapshot()` + * listeners. + * * This function returns a new (immutable) instance of the Query (rather than * modify the existing instance) to impose the field mask. * diff --git a/types/firestore.d.ts b/types/firestore.d.ts index efa36799d..97af5607f 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -943,6 +943,9 @@ declare namespace FirebaseFirestore { * specify a list of field paths to return, or use an empty list to only * return the references of matching documents. * + * Queries that contain field masks cannot be listened to via `onSnapshot()` + * listeners. + * * This function returns a new (immutable) instance of the Query (rather * than modify the existing instance) to impose the field mask. * From f03072a1d4cc8004ec490ab4d82789a80c6a4ecf Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 27 May 2020 16:10:35 -0700 Subject: [PATCH 122/337] chore: release 3.8.1 (#1082) --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32a6815b0..4cc87c684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.8.1](https://www.github.com/googleapis/nodejs-firestore/compare/v3.8.0...v3.8.1) (2020-05-27) + + +### Bug Fixes + +* Add tests to check fields used in whereIn should be equality filters ([#1081](https://www.github.com/googleapis/nodejs-firestore/issues/1081)) ([3153dd2](https://www.github.com/googleapis/nodejs-firestore/commit/3153dd296891a983b3a0e78354df3fe106ad44a2)) +* capture error stacks across async calls ([#1088](https://www.github.com/googleapis/nodejs-firestore/issues/1088)) ([7acdd7e](https://www.github.com/googleapis/nodejs-firestore/commit/7acdd7e9e0877fd6dbb50539a0a3c1537d30904a)) + ## [3.8.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.7.5...v3.8.0) (2020-05-13) diff --git a/package.json b/package.json index 4e5003c44..4ab59c8d5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.8.0", + "version": "3.8.1", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 22bd4a72e..ac89ebfb1 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.8.0" + "@google-cloud/firestore": "^3.8.1" }, "devDependencies": { "chai": "^4.2.0", From a17855634542bce798f1ffe50d72775647990616 Mon Sep 17 00:00:00 2001 From: Yuchen Shi Date: Fri, 29 May 2020 22:42:22 -0700 Subject: [PATCH 123/337] fix(settings): authenticate using fake bearer token when ssl is false (#1095) This fixes https://github.com/firebase/firebase-js-sdk/issues/3105#issuecomment-635541894. Before this change, `db.settings({..., ssl: false})` will connect but without any credentials (similar to a client device that is not logged in), which causes Firestore Emulator to evaluate security rules for requests. This is surprising for an Admin SDK and it is extremely hard to troubleshoot. After this change, the same code should correctly behave like admin. This also provides one additional way to get admin privileges in the Firestore Emulator if for some reasons the environment variables is not viable / desirable. --- dev/src/index.ts | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index 79b93b88d..387a8cf62 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -378,13 +378,6 @@ export class Firestore { delete emulatorSettings.servicePath; delete emulatorSettings.apiEndpoint; - // Manually merge the Authorization header to preserve user-provided headers - emulatorSettings.customHeaders = Object.assign( - {}, - emulatorSettings.customHeaders, - {Authorization: 'Bearer owner'} - ); - this.validateAndApplySettings(emulatorSettings); } else { this.validateAndApplySettings({...settings, ...libraryHeader}); @@ -424,7 +417,21 @@ export class Firestore { if (this._settings.ssl === false) { const grpc = require('@grpc/grpc-js'); const sslCreds = grpc.credentials.createInsecure(); - client = new module.exports.v1({sslCreds, ...this._settings}); + + // Use user-provided headers, but provide an Authorization header by default + // so that connection is recognized as admin in Firestore Emulator. (If for + // some reason we're not connecting to the emulator, then this will result in + // denials with invalid token, rather than behave like clients not logged in.) + const customHeaders = { + Authorization: 'Bearer owner', + ...this._settings.customHeaders, + }; + + client = new module.exports.v1({ + sslCreds, + ...this._settings, + customHeaders, + }); } else { client = new module.exports.v1(this._settings); } From cd5e296e68ffa9b815b4008f8a0860e28acb1845 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Fri, 29 May 2020 22:52:51 -0700 Subject: [PATCH 124/337] chore: release 3.8.2 (#1096) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cc87c684..53cee4211 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.8.2](https://www.github.com/googleapis/nodejs-firestore/compare/v3.8.1...v3.8.2) (2020-05-30) + + +### Bug Fixes + +* authenticate as admin user when ssl:false is set ([#1095](https://www.github.com/googleapis/nodejs-firestore/issues/1095)) ([a178556](https://www.github.com/googleapis/nodejs-firestore/commit/a17855634542bce798f1ffe50d72775647990616)), closes [/github.com/firebase/firebase-js-sdk/issues/3105#issuecomment-635541894](https://www.github.com/googleapis//github.com/firebase/firebase-js-sdk/issues/3105/issues/issuecomment-635541894) + ### [3.8.1](https://www.github.com/googleapis/nodejs-firestore/compare/v3.8.0...v3.8.1) (2020-05-27) diff --git a/package.json b/package.json index 4ab59c8d5..acbfdfbb8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.8.1", + "version": "3.8.2", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index ac89ebfb1..2a65cb072 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.8.1" + "@google-cloud/firestore": "^3.8.2" }, "devDependencies": { "chai": "^4.2.0", From c5c0b157bf32466875ace690216a99371d31b461 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Sat, 30 May 2020 20:42:20 -0700 Subject: [PATCH 125/337] fix: return null for 'parent' call on root collection (#1099) --- dev/src/path.ts | 5 +---- dev/src/reference.ts | 13 ++++++++++--- dev/system-test/firestore.ts | 2 +- dev/test/collection.ts | 7 ++++++- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/dev/src/path.ts b/dev/src/path.ts index 0023bac34..56a47a916 100644 --- a/dev/src/path.ts +++ b/dev/src/path.ts @@ -183,10 +183,7 @@ abstract class Path { * @return true if this `Path` is equal to the provided value. */ isEqual(other: Path): boolean { - return ( - this === other || - (other instanceof this.constructor && this.compareTo(other) === 0) - ); + return this === other || this.compareTo(other) === 0; } } diff --git a/dev/src/reference.ts b/dev/src/reference.ts index ccea223c1..d6a92cbc2 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -2256,7 +2256,7 @@ export class CollectionReference extends Query { * A reference to the containing Document if this is a subcollection, else * null. * - * @type {DocumentReference} + * @type {DocumentReference|null} * @name CollectionReference#parent * @readonly * @@ -2265,8 +2265,15 @@ export class CollectionReference extends Query { * let documentRef = collectionRef.parent; * console.log(`Parent name: ${documentRef.path}`); */ - get parent(): DocumentReference { - return new DocumentReference(this.firestore, this._queryOptions.parentPath); + get parent(): DocumentReference | null { + if (this._queryOptions.parentPath.isDocument) { + return new DocumentReference( + this.firestore, + this._queryOptions.parentPath + ); + } + + return null; } /** diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 5b5822eb7..074c70eab 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -197,7 +197,7 @@ describe('CollectionReference class', () => { it('has parent property', () => { const ref = firestore.collection('col/doc/col'); - expect(ref.parent.id).to.equal('doc'); + expect(ref.parent!.id).to.equal('doc'); }); it('has path property', () => { diff --git a/dev/test/collection.ts b/dev/test/collection.ts index 5539b7e06..ada5891d6 100644 --- a/dev/test/collection.ts +++ b/dev/test/collection.ts @@ -78,7 +78,12 @@ describe('Collection interface', () => { const collection = firestore.collection('col1/doc/col2'); expect(collection.path).to.equal('col1/doc/col2'); const document = collection.parent; - expect(document.path).to.equal('col1/doc'); + expect(document!.path).to.equal('col1/doc'); + }); + + it('parent() returns null for root', () => { + const collection = firestore.collection('col1'); + expect(collection.parent).to.equal(null); }); it('supports auto-generated ids', () => { From 8d9ec5c67b904803ad5fb9034070d8a0c303dbaa Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Sat, 30 May 2020 20:58:24 -0700 Subject: [PATCH 126/337] chore: release 3.8.3 (#1101) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53cee4211..074a961c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.8.3](https://www.github.com/googleapis/nodejs-firestore/compare/v3.8.2...v3.8.3) (2020-05-31) + + +### Bug Fixes + +* return null for 'parent' call on root collection ([#1099](https://www.github.com/googleapis/nodejs-firestore/issues/1099)) ([c5c0b15](https://www.github.com/googleapis/nodejs-firestore/commit/c5c0b157bf32466875ace690216a99371d31b461)) + ### [3.8.2](https://www.github.com/googleapis/nodejs-firestore/compare/v3.8.1...v3.8.2) (2020-05-30) diff --git a/package.json b/package.json index acbfdfbb8..7f5fb4ed6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.8.2", + "version": "3.8.3", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 2a65cb072..2dd459624 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.8.2" + "@google-cloud/firestore": "^3.8.3" }, "devDependencies": { "chai": "^4.2.0", From 83f617c753dbcad58eb91be585fd9fcb10480099 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 1 Jun 2020 10:59:48 -0700 Subject: [PATCH 127/337] fix: send Authentication header with every emulator request (#1105) --- dev/src/index.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index 387a8cf62..b4d5774ec 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -418,19 +418,9 @@ export class Firestore { const grpc = require('@grpc/grpc-js'); const sslCreds = grpc.credentials.createInsecure(); - // Use user-provided headers, but provide an Authorization header by default - // so that connection is recognized as admin in Firestore Emulator. (If for - // some reason we're not connecting to the emulator, then this will result in - // denials with invalid token, rather than behave like clients not logged in.) - const customHeaders = { - Authorization: 'Bearer owner', - ...this._settings.customHeaders, - }; - client = new module.exports.v1({ sslCreds, ...this._settings, - customHeaders, }); } else { client = new module.exports.v1(this._settings); @@ -1096,6 +1086,20 @@ export class Firestore { async initializeIfNeeded(requestTag: string): Promise { this._settingsFrozen = true; + if (this._settings.ssl === false) { + // If SSL is false, we assume that we are talking to the emulator. We + // provide an Authorization header by default so that the connection is + // recognized as admin in Firestore Emulator. (If for some reason we're + // not connecting to the emulator, then this will result in denials with + // invalid token, rather than behave like clients not logged in. The user + // can then provide their own Authorization header, which will take + // precedence). + this._settings.customHeaders = { + Authorization: 'Bearer owner', + ...this._settings.customHeaders, + }; + } + if (this._projectId === undefined) { try { this._projectId = await this._clientPool.run(requestTag, gapicClient => From 0c9d773442c8781152ccd8e2e7a8424cc948a815 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 1 Jun 2020 11:10:47 -0700 Subject: [PATCH 128/337] chore: release 3.8.4 (#1107) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 074a961c2..ba04fb47f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.8.4](https://www.github.com/googleapis/nodejs-firestore/compare/v3.8.3...v3.8.4) (2020-06-01) + + +### Bug Fixes + +* send Authentication header with every emulator request ([#1105](https://www.github.com/googleapis/nodejs-firestore/issues/1105)) ([83f617c](https://www.github.com/googleapis/nodejs-firestore/commit/83f617c753dbcad58eb91be585fd9fcb10480099)) + ### [3.8.3](https://www.github.com/googleapis/nodejs-firestore/compare/v3.8.2...v3.8.3) (2020-05-31) diff --git a/package.json b/package.json index 7f5fb4ed6..52fd38360 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.8.3", + "version": "3.8.4", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 2dd459624..c2c5b591a 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.8.3" + "@google-cloud/firestore": "^3.8.4" }, "devDependencies": { "chai": "^4.2.0", From 325e7ffa93c3ba7a45bbf16bd31c8a0532baa340 Mon Sep 17 00:00:00 2001 From: BenWhitehead Date: Tue, 9 Jun 2020 19:12:00 -0400 Subject: [PATCH 129/337] build: update system-test and sample-test config (#1118) Add new script .kokoro/populate-secrets.sh which supports the new SECRET_MANAGER_KEYS configured for each build. Update kokoro trampoline to call populate-secrets.sh Update system-test config to use a new project `java-review` and a new secret for its credentials. Update samples-test config to use a new project `nodejs-firestore-ci` and a new secret for its credentials. --- .kokoro/populate-secrets.sh | 44 +++++++++++++++++++++++ .kokoro/pre-samples-test.sh | 3 +- .kokoro/pre-system-test.sh | 3 +- .kokoro/presubmit/node10/samples-test.cfg | 5 +++ .kokoro/presubmit/node10/system-test.cfg | 5 +++ .kokoro/setup-vars.sh | 18 ---------- .kokoro/trampoline.sh | 1 + 7 files changed, 59 insertions(+), 20 deletions(-) create mode 100755 .kokoro/populate-secrets.sh delete mode 100755 .kokoro/setup-vars.sh diff --git a/.kokoro/populate-secrets.sh b/.kokoro/populate-secrets.sh new file mode 100755 index 000000000..e6ce8200d --- /dev/null +++ b/.kokoro/populate-secrets.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# 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. + +set -eo pipefail + +function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;} +function msg { println "$*" >&2 ;} +function println { printf '%s\n' "$(now) $*" ;} + + +# Populates requested secrets set in SECRET_MANAGER_KEYS from service account: +# kokoro-trampoline@cloud-devrel-kokoro-resources.iam.gserviceaccount.com +SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager" +msg "Creating folder on disk for secrets: ${SECRET_LOCATION}" +mkdir -p ${SECRET_LOCATION} +for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g") +do + msg "Retrieving secret ${key}" + docker run --entrypoint=gcloud \ + --volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \ + gcr.io/google.com/cloudsdktool/cloud-sdk \ + secrets versions access latest \ + --credential-file-override=${KOKORO_GFILE_DIR}/kokoro-trampoline.service-account.json \ + --project cloud-devrel-kokoro-resources \ + --secret $key > \ + "$SECRET_LOCATION/$key" + if [[ $? == 0 ]]; then + msg "Secret written to ${SECRET_LOCATION}/${key}" + else + msg "Error retrieving secret ${key}" + fi +done diff --git a/.kokoro/pre-samples-test.sh b/.kokoro/pre-samples-test.sh index a1ffa0cea..c50be75a0 100755 --- a/.kokoro/pre-samples-test.sh +++ b/.kokoro/pre-samples-test.sh @@ -14,4 +14,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -. .kokoro/setup-vars.sh +export GCLOUD_PROJECT=nodejs-firestore-ci +export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/secret_manager/nodejs-firestore-ci-samples-71b5f8aee66e diff --git a/.kokoro/pre-system-test.sh b/.kokoro/pre-system-test.sh index a1ffa0cea..a04f4650a 100755 --- a/.kokoro/pre-system-test.sh +++ b/.kokoro/pre-system-test.sh @@ -14,4 +14,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -. .kokoro/setup-vars.sh +export GCLOUD_PROJECT=java-review +export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/secret_manager/java-review_firestore-nodejs-it-6d41b624fec9 diff --git a/.kokoro/presubmit/node10/samples-test.cfg b/.kokoro/presubmit/node10/samples-test.cfg index bfe5e16df..a8ace9973 100644 --- a/.kokoro/presubmit/node10/samples-test.cfg +++ b/.kokoro/presubmit/node10/samples-test.cfg @@ -5,3 +5,8 @@ env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/nodejs-firestore/.kokoro/samples-test.sh" } + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "nodejs-firestore-ci-samples-71b5f8aee66e" +} diff --git a/.kokoro/presubmit/node10/system-test.cfg b/.kokoro/presubmit/node10/system-test.cfg index 6a42e89fa..dc32bf63f 100644 --- a/.kokoro/presubmit/node10/system-test.cfg +++ b/.kokoro/presubmit/node10/system-test.cfg @@ -5,3 +5,8 @@ env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/nodejs-firestore/.kokoro/system-test.sh" } + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "java-review_firestore-nodejs-it-6d41b624fec9" +} diff --git a/.kokoro/setup-vars.sh b/.kokoro/setup-vars.sh deleted file mode 100755 index 975202178..000000000 --- a/.kokoro/setup-vars.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# Copyright 2018 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 -# -# https://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. - -export GCLOUD_PROJECT=node-gcloud-ci -export GOOGLE_APPLICATION_CREDENTIALS=$KOKORO_GFILE_DIR/firestore-key.json diff --git a/.kokoro/trampoline.sh b/.kokoro/trampoline.sh index 9bd4905c4..a4241db23 100755 --- a/.kokoro/trampoline.sh +++ b/.kokoro/trampoline.sh @@ -24,4 +24,5 @@ function cleanup() { } trap cleanup EXIT +$(dirname $0)/populate-secrets.sh # Secret Manager secrets. python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" From 8ffe2568b2348c7ccd5c85e4e88b35704caf262a Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 9 Jun 2020 16:42:09 -0700 Subject: [PATCH 130/337] deps: update google-gax (#1114) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 52fd38360..f8594b7db 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "dependencies": { "deep-equal": "^2.0.0", "functional-red-black-tree": "^1.0.1", - "google-gax": "^1.13.0", + "google-gax": "^1.15.3", "readable-stream": "^3.4.0", "through2": "^3.0.0" }, From 9a24cc0c6ee68c1dee7ec64d89dfa7c88375f88d Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 9 Jun 2020 16:56:58 -0700 Subject: [PATCH 131/337] fix: fix flaky BulkWriter test (#1115) --- dev/test/bulk-writer.ts | 57 +++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index 1366ff269..627620bf1 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -550,7 +550,7 @@ describe('BulkWriter', () => { describe('500/50/5 support', () => { afterEach(() => setTimeoutHandler(setTimeout)); - it('does not send batches if doing so exceeds the rate limit', done => { + it('does not send batches if doing so exceeds the rate limit', async () => { // The test is considered a success if BulkWriter tries to send the second // batch again after a timeout. @@ -561,7 +561,7 @@ describe('BulkWriter', () => { const requests2 = arrayRange2.map(i => setOp('doc' + i, 'bar')); const responses2 = arrayRange2.map(i => successResponse(i)); - instantiateInstance([ + const bulkWriter = await instantiateInstance([ { request: createRequest(requests1), response: mergeResponses(responses1), @@ -570,33 +570,34 @@ describe('BulkWriter', () => { request: createRequest(requests2), response: mergeResponses(responses2), }, - ]).then(bulkWriter => { - setTimeoutHandler(() => - done(new Error('This batch should not have a timeout')) - ); - for (let i = 0; i < 500; i++) { - bulkWriter - .set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}) - .then(incrementOpCount); - } - bulkWriter.flush(); - - // Sending this next batch would go over the 500/50/5 capacity, so - // check that BulkWriter doesn't send this batch until the first batch - // is resolved. - setTimeoutHandler((_, timeout) => { - // Check that BulkWriter has not yet sent the 2nd batch. - expect(requestCounter).to.equal(0); - expect(timeout).to.be.greaterThan(0); - done(); - }); - for (let i = 500; i < 505; i++) { - bulkWriter - .set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}) - .then(incrementOpCount); - } - return bulkWriter.flush(); + ]); + for (let i = 0; i < 500; i++) { + bulkWriter + .set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}) + .then(incrementOpCount); + } + const flush1 = bulkWriter.flush(); + + // Sending this next batch would go over the 500/50/5 capacity, so + // check that BulkWriter doesn't send this batch until the first batch + // is resolved. + let timeoutCalled = false; + setTimeoutHandler((_, timeout) => { + // Check that BulkWriter has not yet sent the 2nd batch. + timeoutCalled = true; + expect(requestCounter).to.equal(0); + expect(timeout).to.be.greaterThan(0); }); + for (let i = 500; i < 505; i++) { + bulkWriter + .set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}) + .then(incrementOpCount); + } + const flush2 = bulkWriter.flush(); + await flush1; + await flush2; + expect(timeoutCalled).to.be.true; + return bulkWriter.close(); }); }); From f175236bde2f64365f140b14641f848bd4eb34d9 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 9 Jun 2020 17:06:18 -0700 Subject: [PATCH 132/337] fix: retry ABORTED for non-transactional commits (#1111) --- dev/src/index.ts | 37 ++++++++++++++++++++++++++--------- dev/src/util.ts | 43 +++++++++++++++++++++++++++++++++-------- dev/src/write-batch.ts | 24 +++++++++++++++++------ dev/test/bulk-writer.ts | 4 +++- dev/test/transaction.ts | 6 +++++- dev/test/write-batch.ts | 4 +++- 6 files changed, 92 insertions(+), 26 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index b4d5774ec..99fd754b0 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {CallOptions, GoogleError} from 'google-gax'; +import {CallOptions, RetryOptions, Status} from 'google-gax'; import {Duplex, PassThrough} from 'stream'; import * as through2 from 'through2'; import {URL} from 'url'; @@ -53,7 +53,13 @@ import { Settings, UnaryMethod, } from './types'; -import {Deferred, isPermanentRpcError, requestTag, wrapError} from './util'; +import { + Deferred, + getRetryParams, + isPermanentRpcError, + requestTag, + wrapError, +} from './util'; import { validateBoolean, validateFunction, @@ -1127,8 +1133,11 @@ export class Firestore { * Returns GAX call options that set the cloud resource header. * @private */ - private createCallOptions(): CallOptions { - return { + private createCallOptions( + methodName: string, + retryCodes?: number[] + ): CallOptions { + const callOptions: CallOptions = { otherArgs: { headers: { [CLOUD_RESOURCE_HEADER]: this.formattedName, @@ -1136,6 +1145,13 @@ export class Firestore { }, }, }; + + if (retryCodes) { + const retryParams = getRetryParams(methodName); + callOptions.retry = new RetryOptions(retryCodes, retryParams); + } + + return callOptions; } /** @@ -1158,7 +1174,7 @@ export class Firestore { * and GAX options. * @param requestTag A unique client-assigned identifier for this request. * @param func Method returning a Promise than can be retried. - * @returns - A Promise with the function's result if successful within + * @returns A Promise with the function's result if successful within * `attemptsRemaining`. Otherwise, returns the last rejected Promise. */ private async _retry( @@ -1188,7 +1204,7 @@ export class Firestore { } catch (err) { lastError = err; - if (isPermanentRpcError(err, methodName, serviceConfig)) { + if (isPermanentRpcError(err, methodName)) { break; } } @@ -1321,14 +1337,17 @@ export class Firestore { * and GAX options. * @param request The Protobuf request to send. * @param requestTag A unique client-assigned identifier for this request. + * @param retryCodes If provided, a custom list of retry codes. If not + * provided, retry is based on the behavior as defined in the ServiceConfig. * @returns A Promise with the request result. */ request( methodName: FirestoreUnaryMethod, request: Req, - requestTag: string + requestTag: string, + retryCodes?: number[] ): Promise { - const callOptions = this.createCallOptions(); + const callOptions = this.createCallOptions(methodName, retryCodes); return this._clientPool.run(requestTag, async gapicClient => { try { @@ -1371,7 +1390,7 @@ export class Firestore { request: {}, requestTag: string ): Promise { - const callOptions = this.createCallOptions(); + const callOptions = this.createCallOptions(methodName); const bidirectional = methodName === 'listen'; diff --git a/dev/src/util.ts b/dev/src/util.ts index 15d5f8dd9..19ac88d08 100644 --- a/dev/src/util.ts +++ b/dev/src/util.ts @@ -15,10 +15,26 @@ */ import {randomBytes} from 'crypto'; -import {GoogleError, ServiceConfig, Status} from 'google-gax'; +import { + CallSettings, + ClientConfig, + constructSettings, + createDefaultBackoffSettings, + GoogleError, + Status, +} from 'google-gax'; +import {BackoffSettings} from 'google-gax/build/src/gax'; +import * as gapicConfig from './v1/firestore_client_config.json'; import {DocumentData} from './types'; +const serviceConfig = constructSettings( + 'google.firestore.v1.Firestore', + gapicConfig as ClientConfig, + {}, + Status +) as {[k: string]: CallSettings}; + /** * A Promise implementation that supports deferred resolution. * @private @@ -132,21 +148,32 @@ export function isFunction(value: unknown): boolean { */ export function isPermanentRpcError( err: GoogleError, - methodName: string, - config: ServiceConfig + methodName: string ): boolean { if (err.code !== undefined) { - const serviceConfigName = methodName[0].toUpperCase() + methodName.slice(1); - const retryCodeNames = config.methods[serviceConfigName]!.retry_codes_name!; - const retryCodes = config.retry_codes![retryCodeNames].map( - errorName => Status[errorName as keyof typeof Status] - ); + const retryCodes = getRetryCodes(methodName); return retryCodes.indexOf(err.code) === -1; } else { return false; } } +/** + * Returns the list of retryable error codes specified in the service + * configuration. + */ +export function getRetryCodes(methodName: string): number[] { + return serviceConfig[methodName]?.retry?.retryCodes ?? []; +} + +/** Returns the backoff setting from the service configuration. */ +export function getRetryParams(methodName: string): BackoffSettings { + return ( + serviceConfig[methodName]?.retry?.backoffSettings ?? + createDefaultBackoffSettings() + ); +} + /** * Wraps the provided error in a new error that includes the provided stack. * diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 408845189..1e40e73d5 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -14,9 +14,6 @@ * limitations under the License. */ -import * as assert from 'assert'; -import {describe, it} from 'mocha'; - import {google} from '../protos/firestore_v1_proto_api'; import { DocumentMask, @@ -37,7 +34,13 @@ import { UpdateMap, } from './types'; import {DocumentData} from './types'; -import {isObject, isPlainObject, requestTag, wrapError} from './util'; +import { + getRetryCodes, + isObject, + isPlainObject, + requestTag, + wrapError, +} from './util'; import { customObjectMessage, invalidArgumentMessage, @@ -565,10 +568,12 @@ export class WriteBatch { request.writes!.push(req.write); } + const retryCodes = [Status.ABORTED, ...getRetryCodes('commit')]; + const response = await this._firestore.request< api.IBatchWriteRequest, api.BatchWriteResponse - >('batchWrite', request, tag); + >('batchWrite', request, tag, retryCodes); return (response.writeResults || []).map((result, i) => { const status = response.status[i]; @@ -637,13 +642,20 @@ export class WriteBatch { request.writes!.length ); + let retryCodes: number[] | undefined; + if (explicitTransaction) { request.transaction = explicitTransaction; + } else { + // Commits outside of transaction should also be retried when they fail + // with status code ABORTED. + retryCodes = [Status.ABORTED, ...getRetryCodes('commit')]; } + const response = await this._firestore.request< api.ICommitRequest, api.CommitResponse - >('commit', request, tag); + >('commit', request, tag, retryCodes); return (response.writeResults || []).map( writeResult => diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index 627620bf1..5472858b5 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -146,7 +146,9 @@ describe('BulkWriter', () => { enforceSingleConcurrentRequest = false ): Promise { const overrides: ApiOverride = { - batchWrite: async request => { + batchWrite: async (request, options) => { + expect(options!.retry!.retryCodes).contains(Status.ABORTED); + expect(request).to.deep.eq({ database: `projects/${PROJECT_ID}/databases/(default)`, writes: mock[requestCounter].request.writes, diff --git a/dev/test/transaction.ts b/dev/test/transaction.ts index b6925f8bb..bac8d2b24 100644 --- a/dev/test/transaction.ts +++ b/dev/test/transaction.ts @@ -291,7 +291,11 @@ function runTransaction( return response(request.response as api.IBeginTransactionResponse); } }, - commit: actual => { + commit: (actual, options) => { + // Ensure that we do not specify custom retry behavior for transactional + // commits. + expect(options!.retry).to.be.undefined; + const request = expectedRequests.shift()!; expect(request.type).to.equal('commit'); expect(actual).to.deep.eq(request.request); diff --git a/dev/test/write-batch.ts b/dev/test/write-batch.ts index 76b348afb..d4ebee9c9 100644 --- a/dev/test/write-batch.ts +++ b/dev/test/write-batch.ts @@ -190,7 +190,9 @@ describe('batch support', () => { beforeEach(() => { const overrides: ApiOverride = { - commit: request => { + commit: (request, options) => { + expect(options!.retry!.retryCodes).contains(Status.ABORTED); + expect(request).to.deep.eq({ database: `projects/${PROJECT_ID}/databases/(default)`, writes: [ From d7574ea4ecd807d501243f8435903cfa385bb630 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 9 Jun 2020 18:08:00 -0700 Subject: [PATCH 133/337] fix: retry Query streams (#1116) --- dev/src/document.ts | 3 +- dev/src/reference.ts | 90 +++++++++++++++++++++++++++++++++++--------- dev/test/query.ts | 30 ++++++++------- 3 files changed, 89 insertions(+), 34 deletions(-) diff --git a/dev/src/document.ts b/dev/src/document.ts index 37cdc9bfd..442f7a42d 100644 --- a/dev/src/document.ts +++ b/dev/src/document.ts @@ -998,8 +998,7 @@ export class Precondition { const proto: api.IPrecondition = {}; if (this._lastUpdateTime !== undefined) { - const valueProto = this._lastUpdateTime!.toProto(); - proto.updateTime = valueProto.timestampValue; + proto.updateTime = this._lastUpdateTime!.toProto().timestampValue; } else { proto.exists = this._exists; } diff --git a/dev/src/reference.ts b/dev/src/reference.ts index d6a92cbc2..7003c4378 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -48,7 +48,13 @@ import { UpdateData, WhereFilterOp, } from './types'; -import {autoId, requestTag, wrapError} from './util'; +import { + autoId, + Deferred, + isPermanentRpcError, + requestTag, + wrapError, +} from './util'; import { invalidArgumentMessage, validateEnumValue, @@ -1915,13 +1921,16 @@ export class Query { /** * Internal method for serializing a query to its RunQuery proto - * representation with an optional transaction id. + * representation with an optional transaction id or read time. * - * @param transactionId A transaction ID. + * @param transactionIdOrReadTime A transaction ID or the read time at which + * to execute the query. * @private * @returns Serialized JSON for the query. */ - toProto(transactionId?: Uint8Array): api.IRunQueryRequest { + toProto( + transactionIdOrReadTime?: Uint8Array | Timestamp + ): api.IRunQueryRequest { const projectId = this.firestore.projectId; const parentPath = this._queryOptions.parentPath.toQualifiedResourcePath( projectId @@ -2003,8 +2012,11 @@ export class Query { structuredQuery.offset = this._queryOptions.offset; structuredQuery.select = this._queryOptions.projection; - reqOpts.transaction = transactionId; - + if (transactionIdOrReadTime instanceof Uint8Array) { + reqOpts.transaction = transactionIdOrReadTime; + } else if (transactionIdOrReadTime instanceof Timestamp) { + reqOpts.readTime = transactionIdOrReadTime.toProto().timestampValue; + } return reqOpts; } @@ -2019,6 +2031,8 @@ export class Query { const tag = requestTag(); const self = this; + let lastReceivedDocument: QueryDocumentSnapshot | null = null; + const stream = through2.obj(function(this, proto, enc, callback) { const readTime = Timestamp.fromProto(proto.readTime); if (proto.document) { @@ -2026,7 +2040,7 @@ export class Query { proto.document, proto.readTime ); - const finalDoc = new DocumentSnapshotBuilder( + const finalDoc = new DocumentSnapshotBuilder( document.ref.withConverter(self._queryOptions.converter) ); // Recreate the QueryDocumentSnapshot with the DocumentReference @@ -2035,7 +2049,8 @@ export class Query { finalDoc.readTime = document.readTime; finalDoc.createTime = document.createTime; finalDoc.updateTime = document.updateTime; - this.push({document: finalDoc.build(), readTime}); + lastReceivedDocument = finalDoc.build() as QueryDocumentSnapshot; + this.push({document: lastReceivedDocument, readTime}); } else { this.push({readTime}); } @@ -2048,16 +2063,55 @@ export class Query { // `toProto()` might throw an exception. We rely on the behavior of an // async function to convert this exception into the rejected Promise we // catch below. - const request = this.toProto(transactionId); - return this._firestore.requestStream('runQuery', request, tag); - }) - .then(backendStream => { - backendStream.on('error', err => { - logger('Query._stream', tag, 'Query failed with stream error:', err); - stream.destroy(err); - }); - backendStream.resume(); - backendStream.pipe(stream); + let request = this.toProto(transactionId); + + let streamActive: Deferred; + do { + streamActive = new Deferred(); + const backendStream = await this._firestore.requestStream( + 'runQuery', + request, + tag + ); + backendStream.on('error', err => { + backendStream.unpipe(stream); + + // If a non-transactional query failed, attempt to restart. + // Transactional queries are retried via the transaction runner. + if (!transactionId && !isPermanentRpcError(err, 'runQuery')) { + logger( + 'Query._stream', + tag, + 'Query failed with retryable stream error:', + err + ); + if (lastReceivedDocument) { + // Restart the query but use the last document we received as the + // query cursor. Note that we do not use backoff here. The call to + // `requestStream()` will backoff should the restart fail before + // delivering any results. + request = this.startAfter(lastReceivedDocument).toProto( + lastReceivedDocument.readTime + ); + } + streamActive.resolve(/* active= */ true); + } else { + logger( + 'Query._stream', + tag, + 'Query failed with stream error:', + err + ); + stream.destroy(err); + streamActive.resolve(/* active= */ false); + } + }); + backendStream.on('end', () => { + streamActive.resolve(/* active= */ false); + }); + backendStream.resume(); + backendStream.pipe(stream); + } while (await streamActive.promise); }) .catch(e => stream.destroy(e)); diff --git a/dev/test/query.ts b/dev/test/query.ts index 475b158c3..481dc7e69 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -565,30 +565,33 @@ describe('query interface', () => { }); it('handles stream exception after initialization (with get())', () => { + const responses = [ + () => stream(result('first'), new Error('Expected error')), + () => stream(result('second')), + ]; const overrides: ApiOverride = { - runQuery: () => { - return stream(result('first'), new Error('Expected error')); - }, + runQuery: () => responses.shift()!(), }; return createInstance(overrides).then(firestore => { return firestore .collection('collectionId') .get() - .then(() => { - throw new Error('Unexpected success in Promise'); - }) - .catch(err => { - expect(err.message).to.equal('Expected error'); + .then(snap => { + expect(snap.size).to.equal(2); + expect(snap.docs[0].id).to.equal('first'); + expect(snap.docs[1].id).to.equal('second'); }); }); }); it('handles stream exception after initialization (with stream())', done => { + const responses = [ + () => stream(result('first'), new Error('Expected error')), + () => stream(result('second')), + ]; const overrides: ApiOverride = { - runQuery: () => { - return stream(result('first'), new Error('Expected error')); - }, + runQuery: () => responses.shift()!(), }; createInstance(overrides).then(firestore => { @@ -599,9 +602,8 @@ describe('query interface', () => { expect(doc).to.be.an.instanceOf(QueryDocumentSnapshot); ++resultCount; }); - result.on('error', err => { - expect(resultCount).to.equal(1); - expect(err.message).to.equal('Expected error'); + result.on('end', () => { + expect(resultCount).to.equal(2); done(); }); }); From 9aa1a0ff5055d5c22b97cbecc073b716dbd849b9 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 9 Jun 2020 18:15:07 -0700 Subject: [PATCH 134/337] chore: release 3.8.5 (#1122) --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba04fb47f..a2ccaca83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.8.5](https://www.github.com/googleapis/nodejs-firestore/compare/v3.8.4...v3.8.5) (2020-06-10) + + +### Bug Fixes + +* fix flaky BulkWriter test ([#1115](https://www.github.com/googleapis/nodejs-firestore/issues/1115)) ([9a24cc0](https://www.github.com/googleapis/nodejs-firestore/commit/9a24cc0c6ee68c1dee7ec64d89dfa7c88375f88d)) +* retry ABORTED for non-transactional commits ([#1111](https://www.github.com/googleapis/nodejs-firestore/issues/1111)) ([f175236](https://www.github.com/googleapis/nodejs-firestore/commit/f175236bde2f64365f140b14641f848bd4eb34d9)) +* retry Query streams ([#1116](https://www.github.com/googleapis/nodejs-firestore/issues/1116)) ([d7574ea](https://www.github.com/googleapis/nodejs-firestore/commit/d7574ea4ecd807d501243f8435903cfa385bb630)) + ### [3.8.4](https://www.github.com/googleapis/nodejs-firestore/compare/v3.8.3...v3.8.4) (2020-06-01) diff --git a/package.json b/package.json index f8594b7db..540e23257 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.8.4", + "version": "3.8.5", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index c2c5b591a..dc7cefc8a 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.8.4" + "@google-cloud/firestore": "^3.8.5" }, "devDependencies": { "chai": "^4.2.0", From 79fcb4adbfb0f2b55e3d082fc4bf586c7b55c65b Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 9 Jun 2020 20:12:59 -0700 Subject: [PATCH 135/337] chore: update credentials for continuous build (#1216) --- .kokoro/continuous/node10/samples-test.cfg | 5 +++++ .kokoro/continuous/node10/system-test.cfg | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/.kokoro/continuous/node10/samples-test.cfg b/.kokoro/continuous/node10/samples-test.cfg index bfe5e16df..a8ace9973 100644 --- a/.kokoro/continuous/node10/samples-test.cfg +++ b/.kokoro/continuous/node10/samples-test.cfg @@ -5,3 +5,8 @@ env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/nodejs-firestore/.kokoro/samples-test.sh" } + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "nodejs-firestore-ci-samples-71b5f8aee66e" +} diff --git a/.kokoro/continuous/node10/system-test.cfg b/.kokoro/continuous/node10/system-test.cfg index 6a42e89fa..dc32bf63f 100644 --- a/.kokoro/continuous/node10/system-test.cfg +++ b/.kokoro/continuous/node10/system-test.cfg @@ -5,3 +5,8 @@ env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/nodejs-firestore/.kokoro/system-test.sh" } + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "java-review_firestore-nodejs-it-6d41b624fec9" +} From 6681ef713ff0f09be44034a8b78aae2d5e860010 Mon Sep 17 00:00:00 2001 From: Lalji Kanjareeya <46327204+laljikanjareeya@users.noreply.github.com> Date: Wed, 10 Jun 2020 10:07:03 +0530 Subject: [PATCH 136/337] docs: sample for limitToLast() query (#1113) --- samples/limit-to-last-query.js | 32 ++++++++++++++++++ samples/test/limit-to-last-query.test.js | 42 ++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 samples/limit-to-last-query.js create mode 100644 samples/test/limit-to-last-query.test.js diff --git a/samples/limit-to-last-query.js b/samples/limit-to-last-query.js new file mode 100644 index 000000000..ad764d9a3 --- /dev/null +++ b/samples/limit-to-last-query.js @@ -0,0 +1,32 @@ +// 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. + +'use strict'; + +// [START firestore_limit_to_last_query] +const { Firestore } = require('@google-cloud/firestore'); + +// Create a new client +const firestore = new Firestore(); + +async function limitToLastQuery() { + const collectionReference = firestore.collection('cities'); + var cityDocuments = await collectionReference.orderBy('name').limitToLast(2).get(); + var cityDocumentData = cityDocuments.docs.map(d => d.data()); + cityDocumentData.forEach(doc => { + console.log(doc.name); + }); +} +limitToLastQuery(); +// [END firestore_limit_to_last_query] diff --git a/samples/test/limit-to-last-query.test.js b/samples/test/limit-to-last-query.test.js new file mode 100644 index 000000000..5c45f962d --- /dev/null +++ b/samples/test/limit-to-last-query.test.js @@ -0,0 +1,42 @@ +// 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. + +'use strict'; + +const { execSync } = require('child_process'); +const { assert } = require('chai'); +const { describe, it } = require('mocha'); +const exec = (cmd) => execSync(cmd, { encoding: 'utf8' }); +const { Firestore, FieldPath } = require('@google-cloud/firestore'); + +describe('limit to last query', () => { + const firestore = new Firestore(); + const cities = ['San Francisco', 'Los Angeles', 'Tokyo', 'Beijing']; + + before(async () => { + await Promise.all(cities.map(city => firestore.doc(`cities/${city}`).create({ name: city }))); + }); + + after(async () => { + const cityCollectionRef = firestore.collection('cities'); + const cityDocs = (await cityCollectionRef.select(FieldPath.documentId()).get()).docs; + await Promise.all(cityDocs.map(doc => cityCollectionRef.doc(doc.id).delete())); + }); + + it('should run limitToLast query', () => { + const output = exec('node limit-to-last-query.js'); + assert.include(output, 'San Francisco'); + assert.include(output, 'Tokyo'); + }); +}); From 9118521a0382fd2d484803a89e590c1bf6d2a3c6 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 17 Jun 2020 11:51:04 -0700 Subject: [PATCH 137/337] fix: reject all promises with errors (#1224) --- dev/src/pool.ts | 4 +++- dev/src/util.ts | 7 +------ dev/src/v1/firestore_admin_client.ts | 4 +++- dev/src/v1/firestore_client.ts | 4 +++- dev/src/v1beta1/firestore_client.ts | 4 +++- dev/system-test/firestore.ts | 2 +- dev/test/pool.ts | 2 +- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/dev/src/pool.ts b/dev/src/pool.ts index eb55c9f90..be234673f 100644 --- a/dev/src/pool.ts +++ b/dev/src/pool.ts @@ -187,7 +187,9 @@ export class ClientPool { */ run(requestTag: string, op: (client: T) => Promise): Promise { if (this.terminated) { - return Promise.reject('The client has already been terminated'); + return Promise.reject( + new Error('The client has already been terminated') + ); } const client = this.acquire(requestTag); diff --git a/dev/src/util.ts b/dev/src/util.ts index 19ac88d08..b2e073d3b 100644 --- a/dev/src/util.ts +++ b/dev/src/util.ts @@ -180,12 +180,7 @@ export function getRetryParams(methodName: string): BackoffSettings { * Used to preserve stack traces across async calls. * @private */ -export function wrapError(err: Error | string, stack: string): Error { - // TODO(b/157506412): Remove `string` type and clean up any string errors - // that we are throwing. - if (typeof err === 'string') { - throw err; - } +export function wrapError(err: Error, stack: string): Error { err.stack += '\nCaused by: ' + stack; return err; } diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index 96c5f19f6..f182d73a7 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -310,7 +310,9 @@ export class FirestoreAdminClient { const innerCallPromise = this.firestoreAdminStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { - return Promise.reject('The client has already been closed.'); + return Promise.reject( + new Error('The client has already been closed.') + ); } const func = stub[methodName]; return func.apply(stub, args); diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 4a0630f95..4ae1ef3fc 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -253,7 +253,9 @@ export class FirestoreClient { const innerCallPromise = this.firestoreStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { - return Promise.reject('The client has already been closed.'); + return Promise.reject( + new Error('The client has already been closed.') + ); } const func = stub[methodName]; return func.apply(stub, args); diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index b330e4e56..e4ed2a25e 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -261,7 +261,9 @@ export class FirestoreClient { const innerCallPromise = this.firestoreStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { - return Promise.reject('The client has already been closed.'); + return Promise.reject( + new Error('The client has already been closed.') + ); } const func = stub[methodName]; return func.apply(stub, args); diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 074c70eab..9882fc37d 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -152,7 +152,7 @@ describe('Firestore class', () => { }) .then(() => Promise.reject('set() should have failed')) .catch(err => { - expect(err).to.equal('The client has already been terminated'); + expect(err.message).to.equal('The client has already been terminated'); }); }); diff --git a/dev/test/pool.ts b/dev/test/pool.ts index 3489ac54b..7538e67a0 100644 --- a/dev/test/pool.ts +++ b/dev/test/pool.ts @@ -324,7 +324,7 @@ describe('Client pool', () => { ); }) .catch((err: Error) => { - expect(err).to.equal('The client has already been terminated'); + expect(err.message).to.equal('The client has already been terminated'); }); }); From d756a855c299878f2a38a0d00a57d8976882539c Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 18 Jun 2020 09:32:48 -0700 Subject: [PATCH 138/337] test: fix Limit to last quickstart (#1227) Fixes https://github.com/googleapis/nodejs-firestore/issues/1226 --- samples/test/limit-to-last-query.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/test/limit-to-last-query.test.js b/samples/test/limit-to-last-query.test.js index 5c45f962d..256feb80a 100644 --- a/samples/test/limit-to-last-query.test.js +++ b/samples/test/limit-to-last-query.test.js @@ -25,7 +25,7 @@ describe('limit to last query', () => { const cities = ['San Francisco', 'Los Angeles', 'Tokyo', 'Beijing']; before(async () => { - await Promise.all(cities.map(city => firestore.doc(`cities/${city}`).create({ name: city }))); + await Promise.all(cities.map(city => firestore.doc(`cities/${city}`).set({ name: city }))); }); after(async () => { From 183947e199e1b0be789e5265cd8dd2b778d21006 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Fri, 19 Jun 2020 10:50:16 -0700 Subject: [PATCH 139/337] build: do not overwrite custom env vars (#1230) --- synth.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/synth.py b/synth.py index b396b5704..8e8d6f5e6 100644 --- a/synth.py +++ b/synth.py @@ -48,7 +48,14 @@ # Copy template files common_templates = gcp.CommonTemplates() templates = common_templates.node_library( - source_location="build/src", test_project="node-gcloud-ci" + source_location="build/src", + test_project="node-gcloud-ci", + excludes=[ + ".kokoro/presubmit/node10/system-test.cfg", + ".kokoro/continuous/node10/system-test.cfg", + ".kokoro/presubmit/node10/samples-test.cfg", + ".kokoro/continuous/node10/samples-test.cfg" + ] ) s.copy(templates) From 49ca641ca5d813923b3d4efd113bfc5aecd32437 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Fri, 19 Jun 2020 11:21:10 -0700 Subject: [PATCH 140/337] fix: restart onSnapshot() listeners that stop receiving updates (#1220) --- dev/src/backoff.ts | 24 +++++++++++- dev/src/watch.ts | 81 +++++++++++++++++++++++++++++++---------- dev/test/backoff.ts | 4 +- dev/test/bulk-writer.ts | 2 +- dev/test/index.ts | 4 +- dev/test/query.ts | 5 ++- dev/test/transaction.ts | 4 +- dev/test/watch.ts | 64 ++++++++++++++++++++++++++++++-- 8 files changed, 153 insertions(+), 35 deletions(-) diff --git a/dev/src/backoff.ts b/dev/src/backoff.ts index 2aff2a9cc..d5ad8ae60 100644 --- a/dev/src/backoff.ts +++ b/dev/src/backoff.ts @@ -57,7 +57,10 @@ export const MAX_RETRY_ATTEMPTS = 10; /*! * The timeout handler used by `ExponentialBackoff` and `BulkWriter`. */ -export let delayExecution: (f: () => void, ms: number) => void = setTimeout; +export let delayExecution: ( + f: () => void, + ms: number +) => NodeJS.Timeout = setTimeout; /** * Allows overriding of the timeout handler used by the exponential backoff @@ -71,7 +74,24 @@ export let delayExecution: (f: () => void, ms: number) => void = setTimeout; export function setTimeoutHandler( handler: (f: () => void, ms: number) => void ): void { - delayExecution = handler; + delayExecution = (f: () => void, ms: number) => { + handler(f, ms); + const timeout: NodeJS.Timeout = { + hasRef: () => { + throw new Error('For tests only. Not Implemented'); + }, + ref: () => { + throw new Error('For tests only. Not Implemented'); + }, + refresh: () => { + throw new Error('For tests only. Not Implemented'); + }, + unref: () => { + throw new Error('For tests only. Not Implemented'); + }, + }; + return timeout; + }; } /** diff --git a/dev/src/watch.ts b/dev/src/watch.ts index 5983ea89e..2a870b577 100644 --- a/dev/src/watch.ts +++ b/dev/src/watch.ts @@ -17,11 +17,10 @@ import * as assert from 'assert'; import * as rbtree from 'functional-red-black-tree'; import {GoogleError, Status} from 'google-gax'; -import {describe, it} from 'mocha'; import {Duplex} from 'stream'; import {google} from '../protos/firestore_v1_proto_api'; -import {ExponentialBackoff} from './backoff'; +import {delayExecution, ExponentialBackoff} from './backoff'; import {DocumentSnapshotBuilder, QueryDocumentSnapshot} from './document'; import {DocumentChange, DocumentChangeType} from './document-change'; import {DocumentReference, Firestore, Query} from './index'; @@ -35,7 +34,6 @@ import { RBTree, } from './types'; import {requestTag} from './util'; - import api = google.firestore.v1; /*! @@ -45,6 +43,15 @@ import api = google.firestore.v1; */ const WATCH_TARGET_ID = 0x1; +/** + * Idle timeout used to detect Watch streams that stall (see + * https://github.com/googleapis/nodejs-firestore/issues/1057, b/156308554). + * Under normal load, the Watch backend will send a TARGET_CHANGE message + * roughly every 30 seconds. As discussed with the backend team, we reset the + * Watch stream if we do not receive any message within 120 seconds. + */ +export const WATCH_IDLE_TIMEOUT_MS = 120 * 1000; + /*! * Sentinel value for a document remove. */ @@ -178,6 +185,12 @@ abstract class Watch { */ private hasPushed = false; + /** + * The handler used to restart the Watch stream if it has been idle for more + * than WATCH_IDLE_TIMEOUT_MS. + */ + private idleTimeoutHandle?: NodeJS.Timeout; + private onNext: ( readTime: Timestamp, size: number, @@ -255,16 +268,9 @@ abstract class Watch { const unsubscribe = () => { logger('Watch.onSnapshot', this.requestTag, 'Unsubscribe called'); // Prevent further callbacks. - if (this.isActive) { - // Unregister the listener iff it has not already been unregistered. - this.firestore.unregisterListener(); - this.isActive = false; - } this.onNext = () => {}; this.onError = () => {}; - if (this.currentStream) { - this.currentStream.end(); - } + this.shutdown(); }; this.firestore.registerListener(); return unsubscribe; @@ -329,17 +335,11 @@ abstract class Watch { * @private */ private closeStream(err: GoogleError): void { - if (this.currentStream) { - this.currentStream.end(); - this.currentStream = null; - } - if (this.isActive) { - this.firestore.unregisterListener(); - this.isActive = false; logger('Watch.closeStream', this.requestTag, 'Invoking onError: ', err); this.onError(err); } + this.shutdown(); } /** @@ -352,7 +352,7 @@ abstract class Watch { logger( 'Watch.maybeReopenStream', this.requestTag, - 'Stream ended, re-opening after retryable error: ', + 'Stream ended, re-opening after retryable error:', err ); this.changeMap.clear(); @@ -367,6 +367,31 @@ abstract class Watch { } } + /** + * Cancels the current idle timeout and reschedules a new timer. + * + * @private + */ + private resetIdleTimeout(): void { + if (this.idleTimeoutHandle) { + clearTimeout(this.idleTimeoutHandle); + } + + this.idleTimeoutHandle = delayExecution(() => { + logger( + 'Watch.resetIdleTimeout', + this.requestTag, + 'Resetting stream after idle timeout' + ); + this.currentStream?.end(); + this.currentStream = null; + + const error = new GoogleError('Watch stream idle timeout'); + error.code = Status.UNKNOWN; + this.maybeReopenStream(error); + }, WATCH_IDLE_TIMEOUT_MS); + } + /** * Helper to restart the outgoing stream to the backend. * @private @@ -419,7 +444,10 @@ abstract class Watch { } logger('Watch.initStream', this.requestTag, 'Opened new stream'); this.currentStream = backendStream; + this.resetIdleTimeout(); + this.currentStream!.on('data', (proto: api.IListenResponse) => { + this.resetIdleTimeout(); this.onData(proto); }) .on('error', err => { @@ -757,6 +785,21 @@ abstract class Watch { private isResourceExhaustedError(error: GoogleError): boolean { return error.code === Status.RESOURCE_EXHAUSTED; } + + /** Closes the stream and clears all timeouts. */ + private shutdown(): void { + if (this.isActive) { + this.isActive = false; + if (this.idleTimeoutHandle) { + clearTimeout(this.idleTimeoutHandle); + this.idleTimeoutHandle = undefined; + } + this.firestore.unregisterListener(); + } + + this.currentStream?.end(); + this.currentStream = null; + } } /** diff --git a/dev/test/backoff.ts b/dev/test/backoff.ts index aac195b7f..1feb26981 100644 --- a/dev/test/backoff.ts +++ b/dev/test/backoff.ts @@ -35,9 +35,7 @@ describe('ExponentialBackoff', () => { observedDelays = []; }); - after(() => { - setTimeoutHandler(setTimeout); - }); + after(() => setTimeoutHandler(setTimeout)); function assertDelayEquals(expected: number) { expect(observedDelays.shift()).to.equal(expected); diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index 5472858b5..eacb0b608 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -23,6 +23,7 @@ import { Timestamp, WriteResult, } from '../src'; +import {setTimeoutHandler} from '../src/backoff'; import {BulkWriter} from '../src/bulk-writer'; import {Deferred} from '../src/util'; import { @@ -39,7 +40,6 @@ import { } from './util/helpers'; import api = proto.google.firestore.v1; -import {setTimeoutHandler} from '../src/backoff'; // Change the argument to 'console.log' to enable debug output. setLogFunction(() => {}); diff --git a/dev/test/index.ts b/dev/test/index.ts index 26f6c0b37..e4354214a 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -899,9 +899,7 @@ describe('getAll() method', () => { setTimeoutHandler(setImmediate); }); - after(() => { - setTimeoutHandler(setTimeout); - }); + after(() => setTimeoutHandler(setTimeout)); function resultEquals( result: DocumentSnapshot[], diff --git a/dev/test/query.ts b/dev/test/query.ts index 481dc7e69..1f2bb20e8 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -18,13 +18,16 @@ import * as extend from 'extend'; import {google} from '../protos/firestore_v1_proto_api'; import { + DocumentData, + DocumentReference, FieldPath, FieldValue, Firestore, + Query, QueryDocumentSnapshot, setLogFunction, + Timestamp, } from '../src'; -import {DocumentData, DocumentReference, Query, Timestamp} from '../src'; import {setTimeoutHandler} from '../src/backoff'; import {DocumentSnapshot, DocumentSnapshotBuilder} from '../src/document'; import {QualifiedResourcePath} from '../src/path'; diff --git a/dev/test/transaction.ts b/dev/test/transaction.ts index bac8d2b24..7a452cf4d 100644 --- a/dev/test/transaction.ts +++ b/dev/test/transaction.ts @@ -331,8 +331,6 @@ function runTransaction( }; return createInstance(overrides).then(async firestore => { - const defaultTimeoutHandler = setTimeout; - try { setTimeoutHandler((callback, timeout) => { if (timeout > 0) { @@ -352,8 +350,8 @@ function runTransaction( return transactionCallback(transaction, docRef); }); } finally { + setTimeoutHandler(setTimeout); expect(expectedRequests.length).to.equal(0); - setTimeoutHandler(defaultTimeoutHandler); } }); } diff --git a/dev/test/watch.ts b/dev/test/watch.ts index bf82d2713..f759d52c9 100644 --- a/dev/test/watch.ts +++ b/dev/test/watch.ts @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {WATCH_IDLE_TIMEOUT_MS} from '../src/watch'; + const duplexify = require('duplexify'); import {expect} from 'chai'; @@ -679,9 +681,13 @@ describe('Query watch', () => { beforeEach(() => { // We are intentionally skipping the delays to ensure fast test execution. - // The retry semantics are uneffected by this, as we maintain their + // The retry semantics are unaffected by this, as we maintain their // asynchronous behavior. - setTimeoutHandler(setImmediate); + setTimeoutHandler((op, timeout) => { + if (timeout !== WATCH_IDLE_TIMEOUT_MS) { + setImmediate(op); + } + }); targetId = 0x1; @@ -1600,6 +1606,54 @@ describe('Query watch', () => { }); }); + it('reset after idle timeout', async () => { + let idleTimeout = () => {}; + + setTimeoutHandler((op, timeout) => { + if (timeout === WATCH_IDLE_TIMEOUT_MS) { + idleTimeout = op; + } else { + setTimeout(op, timeout); + } + }); + + await watchHelper.runTest(collQueryJSON(), async () => { + // Mock the server responding to the query. + watchHelper.sendAddTarget(); + watchHelper.sendDoc(doc1, {foo: 'a'}); + watchHelper.sendCurrent(); + watchHelper.sendSnapshot(1, /* resumeToken= */ Buffer.from([0xabcd])); + + let currentSnapshot = await watchHelper.await('snapshot'); + + lastSnapshot = snapshotsEqual(lastSnapshot, 1, currentSnapshot, { + docs: [snapshot(doc1, {foo: 'a'})], + docChanges: [added(doc1, {foo: 'a'})], + }); + + // Invoke the idle timeout + idleTimeout(); + await streamHelper.await('end'); + + // Restart the stream and send one additional document + await streamHelper.awaitOpen(); + + watchHelper.sendAddTarget(); + + watchHelper.snapshotVersion = 2; + watchHelper.sendDoc(doc2, {foo: 'b'}); + watchHelper.sendCurrent(); + watchHelper.sendSnapshot(2); + currentSnapshot = await watchHelper.await('snapshot'); + + // The snapshot now includes both `doc1` and `doc2`. + snapshotsEqual(lastSnapshot, 2, currentSnapshot, { + docs: [snapshot(doc1, {foo: 'a'}), snapshot(doc2, {foo: 'b'})], + docChanges: [added(doc2, {foo: 'b'})], + }); + }); + }); + it('handles reset with phantom doc', () => { return watchHelper.runTest(collQueryJSON(), () => { // Mock the server responding to the query. @@ -2231,7 +2285,11 @@ describe('DocumentReference watch', () => { // We are intentionally skipping the delays to ensure fast test execution. // The retry semantics are uneffected by this, as we maintain their // asynchronous behavior. - setTimeoutHandler(setImmediate); + setTimeoutHandler((op, timeout) => { + if (timeout !== WATCH_IDLE_TIMEOUT_MS) { + setImmediate(op); + } + }); targetId = 0x1; streamHelper = new StreamHelper(); From 48ca412a98e5e0465439dcdedb116b82dc8a8534 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Fri, 19 Jun 2020 11:39:57 -0700 Subject: [PATCH 141/337] chore: release 3.8.6 (#1225) --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2ccaca83..0b09304d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [3.8.6](https://www.github.com/googleapis/nodejs-firestore/compare/v3.8.5...v3.8.6) (2020-06-19) + + +### Bug Fixes + +* reject all promises with errors ([#1224](https://www.github.com/googleapis/nodejs-firestore/issues/1224)) ([9118521](https://www.github.com/googleapis/nodejs-firestore/commit/9118521a0382fd2d484803a89e590c1bf6d2a3c6)) +* restart onSnapshot() listeners that stop receiving updates ([#1220](https://www.github.com/googleapis/nodejs-firestore/issues/1220)) ([49ca641](https://www.github.com/googleapis/nodejs-firestore/commit/49ca641ca5d813923b3d4efd113bfc5aecd32437)) + ### [3.8.5](https://www.github.com/googleapis/nodejs-firestore/compare/v3.8.4...v3.8.5) (2020-06-10) diff --git a/package.json b/package.json index 540e23257..0d461c5cc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "3.8.5", + "version": "3.8.6", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index dc7cefc8a..e130e6dc4 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.8.5" + "@google-cloud/firestore": "^3.8.6" }, "devDependencies": { "chai": "^4.2.0", From 56355f1c83b055fdbd3ed47e069df813696a1fc0 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 24 Jun 2020 10:27:45 -0700 Subject: [PATCH 142/337] feat!: Drop Node 8 support (#1006) * fix!: mark v1beta1 client as deprecated (#937) * feat!: use QueryDocumentSnapshot in FirestoreDataConverter (#965) * deps: update to gts 2.x (#1013) * chore!: update settings for Node 10 (#1019) * deps: drop through2 (#1014) * feat: support BigInt (#1016) * fix: make update.sh work on Linux (#1043) * fix: only use BigInt in BigInt system test (#1044) * fix: make pbjs compile admin proto again (#1045) * Add BulkWriter (#1055) * docs: Add documentation for FirestoreDataConverter (#1059) * chore: enforce return types (#1065) * fix: add generic to Firestore.getAll() (#1066) * chore: remove internal WriteOp (#1067) * chore: add linter checks for it|describe.only (#1068) * fix: handle terminate in BulkWriter (#1070) * chore: run template copying last in synthtool (#1071) * feat: Firestore Bundles implementation (#1078) * feat: add support for set() with SetOptions when using FirestoreDataConverter (#1087) * feat: Add totalDocuments and totalBytes to bundle metadata. (#1085) * feat: Add totalDocuments and totalBytes to bundle metadata. * fix: Better comment * fix: Better testing. * fix: Improve metadata testing. * fix: incomplete expect in rate-limiter test (#1092) * Remove BatchWrite proto, fix conformance tests * chore: use public API types internally (#1100) * feat: add Partition and BatchWrite protos (#1110) * fix: remove GCF transaction fallback (#1112) * fix: add BulkWriter integration tests, java backport changes, delete fix (#1117) * chore: merge master (#1218) * chore: add eslint check for console.log statements (#1229) * fix: another attempt at fixing the flaky BulkWriter test (#1228) * Fix comment * Renames * Test fix * Fix unit tests Co-authored-by: Brian Chen Co-authored-by: wu-hui <53845758+wu-hui@users.noreply.github.com> --- .eslintrc.json | 41 + .eslintrc.yml | 15 - .github/workflows/ci.yaml | 22 +- .gitignore | 5 +- .jsdoc.js | 9 +- .prettierrc | 8 - .prettierrc.js | 17 + README.md | 2 +- dev/.gitignore | 14 - dev/.mocharc.json | 5 - dev/conformance/.eslintrc.yml | 3 - dev/conformance/runner.ts | 26 +- dev/protos/firestore/bundle.proto | 117 + dev/protos/firestore_admin_v1_proto_api.d.ts | 1720 +- dev/protos/firestore_admin_v1_proto_api.js | 16648 +++++++---- dev/protos/firestore_v1_proto_api.d.ts | 2941 +- dev/protos/firestore_v1_proto_api.js | 24182 +++++++++++----- dev/protos/firestore_v1beta1_proto_api.d.ts | 2331 +- dev/protos/firestore_v1beta1_proto_api.js | 21566 +++++++++----- dev/protos/google/api/resource.proto | 22 +- .../google/firestore/v1/firestore.proto | 133 +- dev/protos/google/firestore/v1/query.proto | 68 +- dev/protos/google/rpc/status.proto | 3 +- dev/protos/google/type/latlng.proto | 3 +- dev/protos/protos.json | 140 +- dev/protos/update.sh | 28 +- dev/src/backoff.ts | 2 +- dev/src/bulk-writer.ts | 86 +- dev/src/bundle.ts | 214 + dev/src/convert.ts | 6 +- dev/src/document-change.ts | 16 +- dev/src/document.ts | 140 +- dev/src/external-modules.d.ts | 3 +- dev/src/field-value.ts | 25 +- dev/src/geo-point.ts | 6 +- dev/src/index.ts | 226 +- dev/src/path.ts | 23 +- dev/src/pool.ts | 11 +- dev/src/rate-limiter.ts | 10 +- dev/src/reference.ts | 413 +- dev/src/serializer.ts | 29 +- dev/src/timestamp.ts | 27 +- dev/src/transaction.ts | 64 +- dev/src/types.ts | 214 +- dev/src/util.ts | 4 +- dev/src/v1/firestore_admin_client.ts | 830 +- dev/src/v1/firestore_client.ts | 991 +- dev/src/v1/firestore_client_config.json | 8 + dev/src/v1beta1/firestore_client.ts | 611 +- dev/src/v1beta1/index.ts | 2 + dev/src/validate.ts | 2 +- dev/src/watch.ts | 42 +- dev/src/write-batch.ts | 265 +- dev/system-test/.eslintrc.yml | 2 - dev/system-test/.gitignore | 2 - dev/system-test/firestore.ts | 392 +- dev/test/backoff.ts | 1 + dev/test/bulk-writer.ts | 132 +- dev/test/bundle.ts | 275 + dev/test/collection.ts | 3 +- dev/test/document.ts | 103 +- dev/test/field-value.ts | 1 + dev/test/gapic-firestore-v1.ts | 870 - dev/test/gapic-firestore-v1beta1.ts | 870 - dev/test/gapic-firestore_admin-v1.ts | 675 - dev/test/gapic_firestore_admin_v1.ts | 2179 ++ dev/test/gapic_firestore_v1.ts | 2311 ++ dev/test/gapic_firestore_v1beta1.ts | 1925 ++ dev/test/ignore-undefined.ts | 1 + dev/test/index.ts | 17 +- dev/test/order.ts | 1 + dev/test/path.ts | 1 + dev/test/pool.ts | 5 +- dev/test/query.ts | 236 +- dev/test/rate-limiter.ts | 3 +- dev/test/timestamp.ts | 1 + dev/test/transaction.ts | 64 + dev/test/typescript.ts | 361 - dev/test/util.ts | 1 + dev/test/util/helpers.ts | 62 +- dev/test/watch.ts | 10 +- dev/test/write-batch.ts | 78 +- package.json | 16 +- samples/.eslintrc.yml | 2 + samples/limit-to-last-query.js | 17 +- samples/solution-counters.js | 2 +- samples/test/limit-to-last-query.test.js | 46 +- samples/test/quickstart.test.js | 2 +- samples/test/solution-counters.test.js | 3 +- scripts/.eslintrc.yml | 7 + dev/synth.metadata => synth.metadata | 14 +- synth.py | 133 +- tslint.json | 10 - types/firestore.d.ts | 185 +- 94 files changed, 60937 insertions(+), 24421 deletions(-) create mode 100644 .eslintrc.json delete mode 100644 .eslintrc.yml delete mode 100644 .prettierrc create mode 100644 .prettierrc.js delete mode 100644 dev/.gitignore delete mode 100644 dev/.mocharc.json delete mode 100644 dev/conformance/.eslintrc.yml create mode 100644 dev/protos/firestore/bundle.proto create mode 100644 dev/src/bundle.ts delete mode 100644 dev/system-test/.eslintrc.yml delete mode 100644 dev/system-test/.gitignore create mode 100644 dev/test/bundle.ts delete mode 100644 dev/test/gapic-firestore-v1.ts delete mode 100644 dev/test/gapic-firestore-v1beta1.ts delete mode 100644 dev/test/gapic-firestore_admin-v1.ts create mode 100644 dev/test/gapic_firestore_admin_v1.ts create mode 100644 dev/test/gapic_firestore_v1.ts create mode 100644 dev/test/gapic_firestore_v1beta1.ts delete mode 100644 dev/test/typescript.ts create mode 100644 scripts/.eslintrc.yml rename dev/synth.metadata => synth.metadata (74%) delete mode 100644 tslint.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 000000000..84bff2ae8 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,41 @@ +{ + "extends": "./node_modules/gts", + "overrides": [ + { + "files": [ + "dev/src/*.ts" + ], + "parser": "@typescript-eslint/parser", + "rules": { + "@typescript-eslint/explicit-function-return-type": [ + "error", + { + "allowExpressions": true, + "allowTypedFunctionExpressions": true + } + ], + "no-console": ["error", {"allow": ["error"]}] + } + }, + { + "files": [ + "dev/test/*.ts", + "dev/system-test/*.ts" + ], + "parser": "@typescript-eslint/parser", + "rules": { + "no-restricted-properties": [ + "error", + { + "object": "describe", + "property": "only" + }, + { + "object": "it", + "property": "only" + } + ] + } + } + ] +} diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 73eeec276..000000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -extends: - - 'eslint:recommended' - - 'plugin:node/recommended' - - prettier -plugins: - - node - - prettier -rules: - prettier/prettier: error - block-scoped-var: error - eqeqeq: error - no-warning-comments: warn - no-var: error - prefer-const: error diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 92394b1e4..5e73bb3d8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [8, 10, 12, 13] + node: [10, 12, 13] steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 @@ -18,6 +18,11 @@ jobs: - run: node --version - run: npm install - run: npm test + - name: coverage + uses: codecov/codecov-action@v1 + with: + name: actions ${{ matrix.node }} + fail_ci_if_error: false windows: runs-on: windows-latest steps: @@ -27,6 +32,11 @@ jobs: node-version: 12 - run: npm install - run: npm test + - name: coverage + uses: codecov/codecov-action@v1 + with: + name: actions windows + fail_ci_if_error: false lint: runs-on: ubuntu-latest steps: @@ -45,13 +55,3 @@ jobs: node-version: 12 - run: npm install - run: npm run docs-test - coverage: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 13 - - run: npm install - - run: npm test - - run: ./node_modules/.bin/c8 report --reporter=text-lcov | npx codecovorg -a ${{ secrets.CODECOV_API_KEY }} -r $GITHUB_REPOSITORY --pipe diff --git a/.gitignore b/.gitignore index 0ed8914a9..5d32b2378 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,14 @@ **/*.log **/node_modules .coverage +coverage .nyc_output docs/ out/ +build/ system-test/secrets.js system-test/*key.json *.lock -build/ -package-lock.json .DS_Store +package-lock.json __pycache__ diff --git a/.jsdoc.js b/.jsdoc.js index f521f240e..37e8492fa 100644 --- a/.jsdoc.js +++ b/.jsdoc.js @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC +// 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. @@ -34,18 +34,19 @@ module.exports = { source: { excludePattern: '(^|\\/|\\\\)[._]', include: [ - 'build/src' + 'build/src', + 'build/protos' ], includePattern: '\\.js$' }, templates: { - copyright: 'Copyright 2019 Google, LLC.', + copyright: 'Copyright 2020 Google LLC', includeDate: false, sourceFiles: false, systemName: '@google-cloud/firestore', theme: 'lumen', default: { - "outputSourceFiles": false + outputSourceFiles: false } }, markdown: { diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index df6eac074..000000000 --- a/.prettierrc +++ /dev/null @@ -1,8 +0,0 @@ ---- -bracketSpacing: false -printWidth: 80 -semi: true -singleQuote: true -tabWidth: 2 -trailingComma: es5 -useTabs: false diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 000000000..d1b95106f --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,17 @@ +// 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 +// +// https://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. + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/README.md b/README.md index ba729e8a8..3cfc4d972 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ async function quickstart() { console.log('Updated an existing document'); // Read the document. - let doc = await document.get(); + const doc = await document.get(); console.log('Read the document'); // Delete the document. diff --git a/dev/.gitignore b/dev/.gitignore deleted file mode 100644 index 5d32b2378..000000000 --- a/dev/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/dev/.mocharc.json b/dev/.mocharc.json deleted file mode 100644 index 670c5e2c2..000000000 --- a/dev/.mocharc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} diff --git a/dev/conformance/.eslintrc.yml b/dev/conformance/.eslintrc.yml deleted file mode 100644 index cd088a978..000000000 --- a/dev/conformance/.eslintrc.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -rules: - node/no-unpublished-require: off diff --git a/dev/conformance/runner.ts b/dev/conformance/runner.ts index f5546acc1..1fb08e35f 100644 --- a/dev/conformance/runner.ts +++ b/dev/conformance/runner.ts @@ -12,18 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. -const duplexify = require('duplexify'); -const mkdirp = require('mkdirp'); +import {DocumentData} from '@google-cloud/firestore'; +import * as duplexify from 'duplexify'; + +import {it, xit, describe} from 'mocha'; import {expect} from 'chai'; import * as path from 'path'; +import * as fs from 'fs'; import * as protobufjs from 'protobufjs'; import * as through2 from 'through2'; import * as proto from '../protos/firestore_v1_proto_api'; import { DocumentChange, - DocumentData, DocumentSnapshot, FieldPath, FieldValue, @@ -47,7 +49,8 @@ import { import api = proto.google.firestore.v1; // TODO(mrschmidt): Create Protobuf .d.ts file for the conformance proto -type ConformanceProto = any; // tslint:disable-line:no-any +// eslint-disable-next-line @typescript-eslint/no-explicit-any +type ConformanceProto = any; /** List of test cases that are ignored. */ const ignoredRe: RegExp[] = []; @@ -328,10 +331,7 @@ function runTest(spec: ConformanceProto) { } const document = docRef(spec.docRefPath); - // TODO(mrschmidt): Remove 'any' and invoke by calling update() directly - // for each individual case. - // tslint:disable-next-line:no-any - return document.update.apply(document, varargs as any); + return document.update(varargs[0] as string, ...varargs.slice(1)); }); }; @@ -339,10 +339,7 @@ function runTest(spec: ConformanceProto) { const overrides = {runQuery: queryHandler(spec)}; const applyClause = (query: Query, clause: ConformanceProto) => { if (clause.select) { - query = query.select.apply( - query, - convertInput.paths(clause.select.fields) - ); + query = query.select(...convertInput.paths(clause.select.fields)); } else if (clause.where) { const fieldPath = convertInput.path(clause.where.path); const value = convertInput.argument(clause.where.jsonValue); @@ -582,15 +579,14 @@ function normalizeInt32Value(obj: {[key: string]: {}}, parent = '') { describe('Conformance Tests', () => { const loadTestCases = () => { - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any let testDataJson: any[] = []; - const fs = require('fs'); const testPath = path.join(__dirname, 'conformance-tests'); const fileNames = fs.readdirSync(testPath); for (const fileName of fileNames) { const testFilePath = path.join(__dirname, 'conformance-tests', fileName); - const singleTest = JSON.parse(fs.readFileSync(testFilePath)); + const singleTest = JSON.parse(fs.readFileSync(testFilePath, 'utf-8')); // Convert Timestamp string representation to protobuf object. normalizeTimestamp(singleTest); diff --git a/dev/protos/firestore/bundle.proto b/dev/protos/firestore/bundle.proto new file mode 100644 index 000000000..7b71db117 --- /dev/null +++ b/dev/protos/firestore/bundle.proto @@ -0,0 +1,117 @@ +// 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. +// + +// This file defines the format of Firestore bundle file/stream. It is not a part of the +// Firestore API, only a specification used by Server and Client SDK to write and read +// bundles. + +syntax = "proto3"; + +package firestore; + +import "google/firestore/v1/document.proto"; +import "google/firestore/v1/query.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Firestore.Proto"; +option go_package = "google.golang.org/genproto/firestore/proto;firestore"; +option java_multiple_files = true; +option java_outer_classname = "BundleProto"; +option java_package = "com.google.firestore.proto"; +option objc_class_prefix = "FSTPB"; +option php_namespace = "Firestore\\Proto"; + +// Encodes a query saved in the bundle. +message BundledQuery { + // The parent resource name. + string parent = 1; + + // The query to run. + oneof query_type { + // A structured query. + google.firestore.v1.StructuredQuery structured_query = 2; + } + + // If the query is a limit query, should the limit be applied to the beginning or + // the end of results. + enum LimitType { + FIRST = 0; + LAST = 1; + } + LimitType limit_type = 3; +} + +// A Query associated with a name, created as part of the bundle file, and can be read +// by client SDKs once the bundle containing them is loaded. +message NamedQuery { + // Name of the query, such that client can use the name to load this query + // from bundle, and resume from when the query results are materialized + // into this bundle. + string name = 1; + + // The query saved in the bundle. + BundledQuery bundled_query = 2; + + // The read time of the query, when it is used to build the bundle. This is useful to + // resume the query from the bundle, once it is loaded by client SDKs. + google.protobuf.Timestamp read_time = 3; +} + +// Metadata describing a Firestore document saved in the bundle. +message BundledDocumentMetadata { + // The document key of a bundled document. + string name = 1; + + // The snapshot version of the document data bundled. + google.protobuf.Timestamp read_time = 2; + + // Whether the document exists. + bool exists = 3; +} + +// Metadata describing the bundle file/stream. +message BundleMetadata { + // The ID of the bundle. + string id = 1; + + // Time at which the documents snapshot is taken for this bundle. + google.protobuf.Timestamp create_time = 2; + + // The schema version of the bundle. + uint32 version = 3; + + // The number of documents in the bundle. + uint32 total_documents = 4; + + // The size of the bundle in bytes, excluding this `BundleMetadata`. + uint64 total_bytes = 5; +} + +// A Firestore bundle is a length-prefixed stream of JSON representations of +// `BundleElement`. +// Only one `BundleMetadata` is expected, and it should be the first element. +// The named queries follow after `metadata`. Every `document_metadata` is +// immediately followed by a `document`. +message BundleElement { + oneof element_type { + BundleMetadata metadata = 1; + + NamedQuery named_query = 2; + + BundledDocumentMetadata document_metadata = 3; + + google.firestore.v1.Document document = 4; + } +} diff --git a/dev/protos/firestore_admin_v1_proto_api.d.ts b/dev/protos/firestore_admin_v1_proto_api.d.ts index a2b8fc7bf..1f9753f2b 100644 --- a/dev/protos/firestore_admin_v1_proto_api.d.ts +++ b/dev/protos/firestore_admin_v1_proto_api.d.ts @@ -51,6 +51,27 @@ export namespace google { /** Field indexConfig. */ public indexConfig?: (google.firestore.admin.v1.Field.IIndexConfig|null); + + /** + * Creates a Field message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Field + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.Field; + + /** + * Creates a plain object from a Field message. Also converts values to other types if specified. + * @param message Field + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.Field, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Field to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace Field { @@ -91,6 +112,27 @@ export namespace google { /** IndexConfig reverting. */ public reverting: boolean; + + /** + * Creates an IndexConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns IndexConfig + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.Field.IndexConfig; + + /** + * Creates a plain object from an IndexConfig message. Also converts values to other types if specified. + * @param message IndexConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.Field.IndexConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this IndexConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -322,6 +364,27 @@ export namespace google { /** CreateIndexRequest index. */ public index?: (google.firestore.admin.v1.IIndex|null); + + /** + * Creates a CreateIndexRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateIndexRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.CreateIndexRequest; + + /** + * Creates a plain object from a CreateIndexRequest message. Also converts values to other types if specified. + * @param message CreateIndexRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.CreateIndexRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateIndexRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListIndexesRequest. */ @@ -360,6 +423,27 @@ export namespace google { /** ListIndexesRequest pageToken. */ public pageToken: string; + + /** + * Creates a ListIndexesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListIndexesRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ListIndexesRequest; + + /** + * Creates a plain object from a ListIndexesRequest message. Also converts values to other types if specified. + * @param message ListIndexesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ListIndexesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListIndexesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListIndexesResponse. */ @@ -386,6 +470,27 @@ export namespace google { /** ListIndexesResponse nextPageToken. */ public nextPageToken: string; + + /** + * Creates a ListIndexesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListIndexesResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ListIndexesResponse; + + /** + * Creates a plain object from a ListIndexesResponse message. Also converts values to other types if specified. + * @param message ListIndexesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ListIndexesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListIndexesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a GetIndexRequest. */ @@ -406,6 +511,27 @@ export namespace google { /** GetIndexRequest name. */ public name: string; + + /** + * Creates a GetIndexRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetIndexRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.GetIndexRequest; + + /** + * Creates a plain object from a GetIndexRequest message. Also converts values to other types if specified. + * @param message GetIndexRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.GetIndexRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetIndexRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DeleteIndexRequest. */ @@ -426,6 +552,27 @@ export namespace google { /** DeleteIndexRequest name. */ public name: string; + + /** + * Creates a DeleteIndexRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteIndexRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.DeleteIndexRequest; + + /** + * Creates a plain object from a DeleteIndexRequest message. Also converts values to other types if specified. + * @param message DeleteIndexRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.DeleteIndexRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteIndexRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an UpdateFieldRequest. */ @@ -452,6 +599,27 @@ export namespace google { /** UpdateFieldRequest updateMask. */ public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates an UpdateFieldRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateFieldRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.UpdateFieldRequest; + + /** + * Creates a plain object from an UpdateFieldRequest message. Also converts values to other types if specified. + * @param message UpdateFieldRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.UpdateFieldRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateFieldRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a GetFieldRequest. */ @@ -472,6 +640,27 @@ export namespace google { /** GetFieldRequest name. */ public name: string; + + /** + * Creates a GetFieldRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetFieldRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.GetFieldRequest; + + /** + * Creates a plain object from a GetFieldRequest message. Also converts values to other types if specified. + * @param message GetFieldRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.GetFieldRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetFieldRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListFieldsRequest. */ @@ -510,6 +699,27 @@ export namespace google { /** ListFieldsRequest pageToken. */ public pageToken: string; + + /** + * Creates a ListFieldsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListFieldsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ListFieldsRequest; + + /** + * Creates a plain object from a ListFieldsRequest message. Also converts values to other types if specified. + * @param message ListFieldsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ListFieldsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListFieldsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListFieldsResponse. */ @@ -536,6 +746,27 @@ export namespace google { /** ListFieldsResponse nextPageToken. */ public nextPageToken: string; + + /** + * Creates a ListFieldsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListFieldsResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ListFieldsResponse; + + /** + * Creates a plain object from a ListFieldsResponse message. Also converts values to other types if specified. + * @param message ListFieldsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ListFieldsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListFieldsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an ExportDocumentsRequest. */ @@ -568,6 +799,27 @@ export namespace google { /** ExportDocumentsRequest outputUriPrefix. */ public outputUriPrefix: string; + + /** + * Creates an ExportDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportDocumentsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ExportDocumentsRequest; + + /** + * Creates a plain object from an ExportDocumentsRequest message. Also converts values to other types if specified. + * @param message ExportDocumentsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ExportDocumentsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportDocumentsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an ImportDocumentsRequest. */ @@ -600,6 +852,27 @@ export namespace google { /** ImportDocumentsRequest inputUriPrefix. */ public inputUriPrefix: string; + + /** + * Creates an ImportDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportDocumentsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ImportDocumentsRequest; + + /** + * Creates a plain object from an ImportDocumentsRequest message. Also converts values to other types if specified. + * @param message ImportDocumentsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ImportDocumentsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportDocumentsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an Index. */ @@ -638,6 +911,27 @@ export namespace google { /** Index state. */ public state: google.firestore.admin.v1.Index.State; + + /** + * Creates an Index message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Index + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.Index; + + /** + * Creates a plain object from an Index message. Also converts values to other types if specified. + * @param message Index + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.Index, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Index to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace Index { @@ -675,6 +969,27 @@ export namespace google { /** IndexField valueMode. */ public valueMode?: ("order"|"arrayConfig"); + + /** + * Creates an IndexField message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns IndexField + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.Index.IndexField; + + /** + * Creates a plain object from an IndexField message. Also converts values to other types if specified. + * @param message IndexField + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.Index.IndexField, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this IndexField to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace IndexField { @@ -709,6 +1024,27 @@ export namespace google { * @param [properties] Properties to set */ constructor(properties?: google.firestore.admin.v1.ILocationMetadata); + + /** + * Creates a LocationMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LocationMetadata + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.LocationMetadata; + + /** + * Creates a plain object from a LocationMetadata message. Also converts values to other types if specified. + * @param message LocationMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.LocationMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LocationMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an IndexOperationMetadata. */ @@ -759,6 +1095,27 @@ export namespace google { /** IndexOperationMetadata progressBytes. */ public progressBytes?: (google.firestore.admin.v1.IProgress|null); + + /** + * Creates an IndexOperationMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns IndexOperationMetadata + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.IndexOperationMetadata; + + /** + * Creates a plain object from an IndexOperationMetadata message. Also converts values to other types if specified. + * @param message IndexOperationMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.IndexOperationMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this IndexOperationMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FieldOperationMetadata. */ @@ -815,6 +1172,27 @@ export namespace google { /** FieldOperationMetadata progressBytes. */ public progressBytes?: (google.firestore.admin.v1.IProgress|null); + + /** + * Creates a FieldOperationMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldOperationMetadata + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.FieldOperationMetadata; + + /** + * Creates a plain object from a FieldOperationMetadata message. Also converts values to other types if specified. + * @param message FieldOperationMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.FieldOperationMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldOperationMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace FieldOperationMetadata { @@ -843,6 +1221,27 @@ export namespace google { /** IndexConfigDelta index. */ public index?: (google.firestore.admin.v1.IIndex|null); + + /** + * Creates an IndexConfigDelta message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns IndexConfigDelta + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta; + + /** + * Creates a plain object from an IndexConfigDelta message. Also converts values to other types if specified. + * @param message IndexConfigDelta + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this IndexConfigDelta to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace IndexConfigDelta { @@ -907,6 +1306,27 @@ export namespace google { /** ExportDocumentsMetadata outputUriPrefix. */ public outputUriPrefix: string; + + /** + * Creates an ExportDocumentsMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportDocumentsMetadata + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ExportDocumentsMetadata; + + /** + * Creates a plain object from an ExportDocumentsMetadata message. Also converts values to other types if specified. + * @param message ExportDocumentsMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ExportDocumentsMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportDocumentsMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an ImportDocumentsMetadata. */ @@ -963,6 +1383,27 @@ export namespace google { /** ImportDocumentsMetadata inputUriPrefix. */ public inputUriPrefix: string; + + /** + * Creates an ImportDocumentsMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportDocumentsMetadata + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ImportDocumentsMetadata; + + /** + * Creates a plain object from an ImportDocumentsMetadata message. Also converts values to other types if specified. + * @param message ImportDocumentsMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ImportDocumentsMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportDocumentsMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an ExportDocumentsResponse. */ @@ -983,16 +1424,37 @@ export namespace google { /** ExportDocumentsResponse outputUriPrefix. */ public outputUriPrefix: string; + + /** + * Creates an ExportDocumentsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportDocumentsResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ExportDocumentsResponse; + + /** + * Creates a plain object from an ExportDocumentsResponse message. Also converts values to other types if specified. + * @param message ExportDocumentsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ExportDocumentsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportDocumentsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Progress. */ interface IProgress { /** Progress estimatedWork */ - estimatedWork?: (number|null); + estimatedWork?: (number|string|null); /** Progress completedWork */ - completedWork?: (number|null); + completedWork?: (number|string|null); } /** Represents a Progress. */ @@ -1005,10 +1467,31 @@ export namespace google { constructor(properties?: google.firestore.admin.v1.IProgress); /** Progress estimatedWork. */ - public estimatedWork: number; + public estimatedWork: (number|string); /** Progress completedWork. */ - public completedWork: number; + public completedWork: (number|string); + + /** + * Creates a Progress message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Progress + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.Progress; + + /** + * Creates a plain object from a Progress message. Also converts values to other types if specified. + * @param message Progress + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.Progress, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Progress to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** OperationState enum. */ @@ -1039,6 +1522,27 @@ export namespace google { /** Http rules. */ public rules: google.api.IHttpRule[]; + + /** + * Creates a Http message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Http + */ + public static fromObject(object: { [k: string]: any }): google.api.Http; + + /** + * Creates a plain object from a Http message. Also converts values to other types if specified. + * @param message Http + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.Http, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Http to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a HttpRule. */ @@ -1110,6 +1614,27 @@ export namespace google { /** HttpRule pattern. */ public pattern?: ("get"|"put"|"post"|"delete"|"patch"|"custom"); + + /** + * Creates a HttpRule message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns HttpRule + */ + public static fromObject(object: { [k: string]: any }): google.api.HttpRule; + + /** + * Creates a plain object from a HttpRule message. Also converts values to other types if specified. + * @param message HttpRule + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.HttpRule, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this HttpRule to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a CustomHttpPattern. */ @@ -1136,6 +1661,27 @@ export namespace google { /** CustomHttpPattern path. */ public path: string; + + /** + * Creates a CustomHttpPattern message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CustomHttpPattern + */ + public static fromObject(object: { [k: string]: any }): google.api.CustomHttpPattern; + + /** + * Creates a plain object from a CustomHttpPattern message. Also converts values to other types if specified. + * @param message CustomHttpPattern + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.CustomHttpPattern, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CustomHttpPattern to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** FieldBehavior enum. */ @@ -1190,6 +1736,27 @@ export namespace google { /** ResourceDescriptor singular. */ public singular: string; + + /** + * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ResourceDescriptor + */ + public static fromObject(object: { [k: string]: any }): google.api.ResourceDescriptor; + + /** + * Creates a plain object from a ResourceDescriptor message. Also converts values to other types if specified. + * @param message ResourceDescriptor + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.ResourceDescriptor, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ResourceDescriptor to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace ResourceDescriptor { @@ -1223,6 +1790,27 @@ export namespace google { /** ResourceReference childType. */ public childType: string; + + /** + * Creates a ResourceReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ResourceReference + */ + public static fromObject(object: { [k: string]: any }): google.api.ResourceReference; + + /** + * Creates a plain object from a ResourceReference message. Also converts values to other types if specified. + * @param message ResourceReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.ResourceReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ResourceReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -1247,10 +1835,31 @@ export namespace google { /** FileDescriptorSet file. */ public file: google.protobuf.IFileDescriptorProto[]; - } - - /** Properties of a FileDescriptorProto. */ - interface IFileDescriptorProto { + + /** + * Creates a FileDescriptorSet message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileDescriptorSet + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileDescriptorSet; + + /** + * Creates a plain object from a FileDescriptorSet message. Also converts values to other types if specified. + * @param message FileDescriptorSet + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileDescriptorSet, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileDescriptorSet to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FileDescriptorProto. */ + interface IFileDescriptorProto { /** FileDescriptorProto name */ name?: (string|null); @@ -1333,6 +1942,27 @@ export namespace google { /** FileDescriptorProto syntax. */ public syntax: string; + + /** + * Creates a FileDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileDescriptorProto; + + /** + * Creates a plain object from a FileDescriptorProto message. Also converts values to other types if specified. + * @param message FileDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DescriptorProto. */ @@ -1407,6 +2037,27 @@ export namespace google { /** DescriptorProto reservedName. */ public reservedName: string[]; + + /** + * Creates a DescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto; + + /** + * Creates a plain object from a DescriptorProto message. Also converts values to other types if specified. + * @param message DescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace DescriptorProto { @@ -1435,6 +2086,27 @@ export namespace google { /** ExtensionRange end. */ public end: number; + + /** + * Creates an ExtensionRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExtensionRange + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto.ExtensionRange; + + /** + * Creates a plain object from an ExtensionRange message. Also converts values to other types if specified. + * @param message ExtensionRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto.ExtensionRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExtensionRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ReservedRange. */ @@ -1461,6 +2133,27 @@ export namespace google { /** ReservedRange end. */ public end: number; + + /** + * Creates a ReservedRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReservedRange + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto.ReservedRange; + + /** + * Creates a plain object from a ReservedRange message. Also converts values to other types if specified. + * @param message ReservedRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto.ReservedRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReservedRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -1536,6 +2229,27 @@ export namespace google { /** FieldDescriptorProto options. */ public options?: (google.protobuf.IFieldOptions|null); + + /** + * Creates a FieldDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldDescriptorProto; + + /** + * Creates a plain object from a FieldDescriptorProto message. Also converts values to other types if specified. + * @param message FieldDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace FieldDescriptorProto { @@ -1573,6 +2287,27 @@ export namespace google { /** OneofDescriptorProto options. */ public options?: (google.protobuf.IOneofOptions|null); + + /** + * Creates an OneofDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OneofDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.OneofDescriptorProto; + + /** + * Creates a plain object from an OneofDescriptorProto message. Also converts values to other types if specified. + * @param message OneofDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.OneofDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OneofDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an EnumDescriptorProto. */ @@ -1605,6 +2340,27 @@ export namespace google { /** EnumDescriptorProto options. */ public options?: (google.protobuf.IEnumOptions|null); + + /** + * Creates an EnumDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumDescriptorProto; + + /** + * Creates a plain object from an EnumDescriptorProto message. Also converts values to other types if specified. + * @param message EnumDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an EnumValueDescriptorProto. */ @@ -1637,6 +2393,27 @@ export namespace google { /** EnumValueDescriptorProto options. */ public options?: (google.protobuf.IEnumValueOptions|null); + + /** + * Creates an EnumValueDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumValueDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumValueDescriptorProto; + + /** + * Creates a plain object from an EnumValueDescriptorProto message. Also converts values to other types if specified. + * @param message EnumValueDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumValueDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumValueDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ServiceDescriptorProto. */ @@ -1669,6 +2446,27 @@ export namespace google { /** ServiceDescriptorProto options. */ public options?: (google.protobuf.IServiceOptions|null); + + /** + * Creates a ServiceDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServiceDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ServiceDescriptorProto; + + /** + * Creates a plain object from a ServiceDescriptorProto message. Also converts values to other types if specified. + * @param message ServiceDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ServiceDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServiceDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a MethodDescriptorProto. */ @@ -1719,6 +2517,27 @@ export namespace google { /** MethodDescriptorProto serverStreaming. */ public serverStreaming: boolean; + + /** + * Creates a MethodDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MethodDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MethodDescriptorProto; + + /** + * Creates a plain object from a MethodDescriptorProto message. Also converts values to other types if specified. + * @param message MethodDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MethodDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MethodDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FileOptions. */ @@ -1826,6 +2645,27 @@ export namespace google { /** FileOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a FileOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileOptions; + + /** + * Creates a plain object from a FileOptions message. Also converts values to other types if specified. + * @param message FileOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace FileOptions { @@ -1880,6 +2720,27 @@ export namespace google { /** MessageOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a MessageOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MessageOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MessageOptions; + + /** + * Creates a plain object from a MessageOptions message. Also converts values to other types if specified. + * @param message MessageOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MessageOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MessageOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FieldOptions. */ @@ -1942,6 +2803,27 @@ export namespace google { /** FieldOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a FieldOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions; + + /** + * Creates a plain object from a FieldOptions message. Also converts values to other types if specified. + * @param message FieldOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace FieldOptions { @@ -1973,6 +2855,27 @@ export namespace google { /** OneofOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an OneofOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OneofOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.OneofOptions; + + /** + * Creates a plain object from an OneofOptions message. Also converts values to other types if specified. + * @param message OneofOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.OneofOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OneofOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an EnumOptions. */ @@ -2005,6 +2908,27 @@ export namespace google { /** EnumOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an EnumOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumOptions; + + /** + * Creates a plain object from an EnumOptions message. Also converts values to other types if specified. + * @param message EnumOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an EnumValueOptions. */ @@ -2031,6 +2955,27 @@ export namespace google { /** EnumValueOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an EnumValueOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumValueOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumValueOptions; + + /** + * Creates a plain object from an EnumValueOptions message. Also converts values to other types if specified. + * @param message EnumValueOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumValueOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumValueOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ServiceOptions. */ @@ -2063,6 +3008,27 @@ export namespace google { /** ServiceOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a ServiceOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServiceOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ServiceOptions; + + /** + * Creates a plain object from a ServiceOptions message. Also converts values to other types if specified. + * @param message ServiceOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ServiceOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServiceOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a MethodOptions. */ @@ -2098,6 +3064,27 @@ export namespace google { /** MethodOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a MethodOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MethodOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MethodOptions; + + /** + * Creates a plain object from a MethodOptions message. Also converts values to other types if specified. + * @param message MethodOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MethodOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MethodOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an UninterpretedOption. */ @@ -2110,10 +3097,10 @@ export namespace google { identifierValue?: (string|null); /** UninterpretedOption positiveIntValue */ - positiveIntValue?: (number|null); + positiveIntValue?: (number|string|null); /** UninterpretedOption negativeIntValue */ - negativeIntValue?: (number|null); + negativeIntValue?: (number|string|null); /** UninterpretedOption doubleValue */ doubleValue?: (number|null); @@ -2141,10 +3128,10 @@ export namespace google { public identifierValue: string; /** UninterpretedOption positiveIntValue. */ - public positiveIntValue: number; + public positiveIntValue: (number|string); /** UninterpretedOption negativeIntValue. */ - public negativeIntValue: number; + public negativeIntValue: (number|string); /** UninterpretedOption doubleValue. */ public doubleValue: number; @@ -2154,6 +3141,27 @@ export namespace google { /** UninterpretedOption aggregateValue. */ public aggregateValue: string; + + /** + * Creates an UninterpretedOption message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UninterpretedOption + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UninterpretedOption; + + /** + * Creates a plain object from an UninterpretedOption message. Also converts values to other types if specified. + * @param message UninterpretedOption + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UninterpretedOption, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UninterpretedOption to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace UninterpretedOption { @@ -2182,6 +3190,27 @@ export namespace google { /** NamePart isExtension. */ public isExtension: boolean; + + /** + * Creates a NamePart message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns NamePart + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UninterpretedOption.NamePart; + + /** + * Creates a plain object from a NamePart message. Also converts values to other types if specified. + * @param message NamePart + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UninterpretedOption.NamePart, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this NamePart to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -2203,6 +3232,27 @@ export namespace google { /** SourceCodeInfo location. */ public location: google.protobuf.SourceCodeInfo.ILocation[]; + + /** + * Creates a SourceCodeInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SourceCodeInfo + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.SourceCodeInfo; + + /** + * Creates a plain object from a SourceCodeInfo message. Also converts values to other types if specified. + * @param message SourceCodeInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.SourceCodeInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SourceCodeInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace SourceCodeInfo { @@ -2249,6 +3299,27 @@ export namespace google { /** Location leadingDetachedComments. */ public leadingDetachedComments: string[]; + + /** + * Creates a Location message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Location + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.SourceCodeInfo.Location; + + /** + * Creates a plain object from a Location message. Also converts values to other types if specified. + * @param message Location + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.SourceCodeInfo.Location, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Location to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -2270,6 +3341,27 @@ export namespace google { /** GeneratedCodeInfo annotation. */ public annotation: google.protobuf.GeneratedCodeInfo.IAnnotation[]; + + /** + * Creates a GeneratedCodeInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GeneratedCodeInfo + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.GeneratedCodeInfo; + + /** + * Creates a plain object from a GeneratedCodeInfo message. Also converts values to other types if specified. + * @param message GeneratedCodeInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.GeneratedCodeInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GeneratedCodeInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace GeneratedCodeInfo { @@ -2310,6 +3402,27 @@ export namespace google { /** Annotation end. */ public end: number; + + /** + * Creates an Annotation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Annotation + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.GeneratedCodeInfo.Annotation; + + /** + * Creates a plain object from an Annotation message. Also converts values to other types if specified. + * @param message Annotation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.GeneratedCodeInfo.Annotation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Annotation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -2325,6 +3438,27 @@ export namespace google { * @param [properties] Properties to set */ constructor(properties?: google.protobuf.IEmpty); + + /** + * Creates an Empty message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Empty + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Empty; + + /** + * Creates a plain object from an Empty message. Also converts values to other types if specified. + * @param message Empty + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Empty, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Empty to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FieldMask. */ @@ -2345,13 +3479,34 @@ export namespace google { /** FieldMask paths. */ public paths: string[]; + + /** + * Creates a FieldMask message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldMask + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldMask; + + /** + * Creates a plain object from a FieldMask message. Also converts values to other types if specified. + * @param message FieldMask + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldMask, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldMask to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Timestamp. */ interface ITimestamp { /** Timestamp seconds */ - seconds?: (number|null); + seconds?: (number|string|null); /** Timestamp nanos */ nanos?: (number|null); @@ -2367,10 +3522,31 @@ export namespace google { constructor(properties?: google.protobuf.ITimestamp); /** Timestamp seconds. */ - public seconds: number; + public seconds: (number|string); /** Timestamp nanos. */ public nanos: number; + + /** + * Creates a Timestamp message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Timestamp + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Timestamp; + + /** + * Creates a plain object from a Timestamp message. Also converts values to other types if specified. + * @param message Timestamp + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Timestamp, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Timestamp to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an Any. */ @@ -2397,6 +3573,27 @@ export namespace google { /** Any value. */ public value: Uint8Array; + + /** + * Creates an Any message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Any + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Any; + + /** + * Creates a plain object from an Any message. Also converts values to other types if specified. + * @param message Any + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Any, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Any to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Struct. */ @@ -2417,6 +3614,27 @@ export namespace google { /** Struct fields. */ public fields: { [k: string]: google.protobuf.IValue }; + + /** + * Creates a Struct message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Struct + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Struct; + + /** + * Creates a plain object from a Struct message. Also converts values to other types if specified. + * @param message Struct + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Struct, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Struct to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Value. */ @@ -2470,6 +3688,27 @@ export namespace google { /** Value kind. */ public kind?: ("nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"); + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Value; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @param message Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** NullValue enum. */ @@ -2494,6 +3733,27 @@ export namespace google { /** ListValue values. */ public values: google.protobuf.IValue[]; + + /** + * Creates a ListValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ListValue; + + /** + * Creates a plain object from a ListValue message. Also converts values to other types if specified. + * @param message ListValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ListValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DoubleValue. */ @@ -2514,6 +3774,27 @@ export namespace google { /** DoubleValue value. */ public value: number; + + /** + * Creates a DoubleValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DoubleValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DoubleValue; + + /** + * Creates a plain object from a DoubleValue message. Also converts values to other types if specified. + * @param message DoubleValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DoubleValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DoubleValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FloatValue. */ @@ -2534,13 +3815,34 @@ export namespace google { /** FloatValue value. */ public value: number; + + /** + * Creates a FloatValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FloatValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FloatValue; + + /** + * Creates a plain object from a FloatValue message. Also converts values to other types if specified. + * @param message FloatValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FloatValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FloatValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an Int64Value. */ interface IInt64Value { /** Int64Value value */ - value?: (number|null); + value?: (number|string|null); } /** Represents an Int64Value. */ @@ -2553,14 +3855,35 @@ export namespace google { constructor(properties?: google.protobuf.IInt64Value); /** Int64Value value. */ - public value: number; + public value: (number|string); + + /** + * Creates an Int64Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Int64Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Int64Value; + + /** + * Creates a plain object from an Int64Value message. Also converts values to other types if specified. + * @param message Int64Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Int64Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Int64Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a UInt64Value. */ interface IUInt64Value { /** UInt64Value value */ - value?: (number|null); + value?: (number|string|null); } /** Represents a UInt64Value. */ @@ -2573,7 +3896,28 @@ export namespace google { constructor(properties?: google.protobuf.IUInt64Value); /** UInt64Value value. */ - public value: number; + public value: (number|string); + + /** + * Creates a UInt64Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UInt64Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UInt64Value; + + /** + * Creates a plain object from a UInt64Value message. Also converts values to other types if specified. + * @param message UInt64Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UInt64Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UInt64Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an Int32Value. */ @@ -2594,6 +3938,27 @@ export namespace google { /** Int32Value value. */ public value: number; + + /** + * Creates an Int32Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Int32Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Int32Value; + + /** + * Creates a plain object from an Int32Value message. Also converts values to other types if specified. + * @param message Int32Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Int32Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Int32Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a UInt32Value. */ @@ -2614,6 +3979,27 @@ export namespace google { /** UInt32Value value. */ public value: number; + + /** + * Creates a UInt32Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UInt32Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UInt32Value; + + /** + * Creates a plain object from a UInt32Value message. Also converts values to other types if specified. + * @param message UInt32Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UInt32Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UInt32Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a BoolValue. */ @@ -2634,6 +4020,27 @@ export namespace google { /** BoolValue value. */ public value: boolean; + + /** + * Creates a BoolValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BoolValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.BoolValue; + + /** + * Creates a plain object from a BoolValue message. Also converts values to other types if specified. + * @param message BoolValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.BoolValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BoolValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a StringValue. */ @@ -2654,6 +4061,27 @@ export namespace google { /** StringValue value. */ public value: string; + + /** + * Creates a StringValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StringValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.StringValue; + + /** + * Creates a plain object from a StringValue message. Also converts values to other types if specified. + * @param message StringValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.StringValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StringValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a BytesValue. */ @@ -2674,13 +4102,34 @@ export namespace google { /** BytesValue value. */ public value: Uint8Array; + + /** + * Creates a BytesValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BytesValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.BytesValue; + + /** + * Creates a plain object from a BytesValue message. Also converts values to other types if specified. + * @param message BytesValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.BytesValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BytesValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Duration. */ interface IDuration { /** Duration seconds */ - seconds?: (number|null); + seconds?: (number|string|null); /** Duration nanos */ nanos?: (number|null); @@ -2696,10 +4145,31 @@ export namespace google { constructor(properties?: google.protobuf.IDuration); /** Duration seconds. */ - public seconds: number; + public seconds: (number|string); /** Duration nanos. */ public nanos: number; + + /** + * Creates a Duration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Duration + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Duration; + + /** + * Creates a plain object from a Duration message. Also converts values to other types if specified. + * @param message Duration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Duration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Duration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -2730,6 +4200,27 @@ export namespace google { /** LatLng longitude. */ public longitude: number; + + /** + * Creates a LatLng message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LatLng + */ + public static fromObject(object: { [k: string]: any }): google.type.LatLng; + + /** + * Creates a plain object from a LatLng message. Also converts values to other types if specified. + * @param message LatLng + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.type.LatLng, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LatLng to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -2766,6 +4257,27 @@ export namespace google { /** Status details. */ public details: google.protobuf.IAny[]; + + /** + * Creates a Status message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Status + */ + public static fromObject(object: { [k: string]: any }): google.rpc.Status; + + /** + * Creates a plain object from a Status message. Also converts values to other types if specified. + * @param message Status + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.rpc.Status, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Status to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -2937,6 +4449,27 @@ export namespace google { /** Operation result. */ public result?: ("error"|"response"); + + /** + * Creates an Operation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Operation + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.Operation; + + /** + * Creates a plain object from an Operation message. Also converts values to other types if specified. + * @param message Operation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.Operation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Operation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a GetOperationRequest. */ @@ -2957,6 +4490,27 @@ export namespace google { /** GetOperationRequest name. */ public name: string; + + /** + * Creates a GetOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.GetOperationRequest; + + /** + * Creates a plain object from a GetOperationRequest message. Also converts values to other types if specified. + * @param message GetOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.GetOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListOperationsRequest. */ @@ -2995,6 +4549,27 @@ export namespace google { /** ListOperationsRequest pageToken. */ public pageToken: string; + + /** + * Creates a ListOperationsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListOperationsRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.ListOperationsRequest; + + /** + * Creates a plain object from a ListOperationsRequest message. Also converts values to other types if specified. + * @param message ListOperationsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.ListOperationsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListOperationsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListOperationsResponse. */ @@ -3021,6 +4596,27 @@ export namespace google { /** ListOperationsResponse nextPageToken. */ public nextPageToken: string; + + /** + * Creates a ListOperationsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListOperationsResponse + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.ListOperationsResponse; + + /** + * Creates a plain object from a ListOperationsResponse message. Also converts values to other types if specified. + * @param message ListOperationsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.ListOperationsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListOperationsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a CancelOperationRequest. */ @@ -3041,6 +4637,27 @@ export namespace google { /** CancelOperationRequest name. */ public name: string; + + /** + * Creates a CancelOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CancelOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.CancelOperationRequest; + + /** + * Creates a plain object from a CancelOperationRequest message. Also converts values to other types if specified. + * @param message CancelOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.CancelOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CancelOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DeleteOperationRequest. */ @@ -3061,6 +4678,27 @@ export namespace google { /** DeleteOperationRequest name. */ public name: string; + + /** + * Creates a DeleteOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.DeleteOperationRequest; + + /** + * Creates a plain object from a DeleteOperationRequest message. Also converts values to other types if specified. + * @param message DeleteOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.DeleteOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a WaitOperationRequest. */ @@ -3087,6 +4725,27 @@ export namespace google { /** WaitOperationRequest timeout. */ public timeout?: (google.protobuf.IDuration|null); + + /** + * Creates a WaitOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WaitOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.WaitOperationRequest; + + /** + * Creates a plain object from a WaitOperationRequest message. Also converts values to other types if specified. + * @param message WaitOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.WaitOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WaitOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an OperationInfo. */ @@ -3113,6 +4772,27 @@ export namespace google { /** OperationInfo metadataType. */ public metadataType: string; + + /** + * Creates an OperationInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OperationInfo + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.OperationInfo; + + /** + * Creates a plain object from an OperationInfo message. Also converts values to other types if specified. + * @param message OperationInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.OperationInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OperationInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } } diff --git a/dev/protos/firestore_admin_v1_proto_api.js b/dev/protos/firestore_admin_v1_proto_api.js index 2b96c841e..d13a0b98a 100644 --- a/dev/protos/firestore_admin_v1_proto_api.js +++ b/dev/protos/firestore_admin_v1_proto_api.js @@ -14,5388 +14,11378 @@ * limitations under the License. */ -// Common aliases -var $util = $protobuf.util; - -// Exported root namespace -var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); - -$root.google = (function() { - - /** - * Namespace google. - * @exports google - * @namespace - */ - var google = {}; - - google.firestore = (function() { - +/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ +(function(global, factory) { /* global define, require, module */ + + /* AMD */ if (typeof define === 'function' && define.amd) + define(["protobufjs/minimal"], factory); + + /* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports) + module.exports = factory(require("protobufjs/minimal")); + +})(this, function($protobuf) { + "use strict"; + + // Common aliases + var $util = $protobuf.util; + + // Exported root namespace + var $root = $protobuf.roots.firestore_admin_v1 || ($protobuf.roots.firestore_admin_v1 = {}); + + $root.google = (function() { + /** - * Namespace firestore. - * @memberof google + * Namespace google. + * @exports google * @namespace */ - var firestore = {}; - - firestore.admin = (function() { - + var google = {}; + + google.firestore = (function() { + /** - * Namespace admin. - * @memberof google.firestore + * Namespace firestore. + * @memberof google * @namespace */ - var admin = {}; - - admin.v1 = (function() { - + var firestore = {}; + + firestore.admin = (function() { + /** - * Namespace v1. - * @memberof google.firestore.admin + * Namespace admin. + * @memberof google.firestore * @namespace */ - var v1 = {}; - - v1.Field = (function() { - - /** - * Properties of a Field. - * @memberof google.firestore.admin.v1 - * @interface IField - * @property {string|null} [name] Field name - * @property {google.firestore.admin.v1.Field.IIndexConfig|null} [indexConfig] Field indexConfig - */ - - /** - * Constructs a new Field. - * @memberof google.firestore.admin.v1 - * @classdesc Represents a Field. - * @implements IField - * @constructor - * @param {google.firestore.admin.v1.IField=} [properties] Properties to set - */ - function Field(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Field name. - * @member {string} name - * @memberof google.firestore.admin.v1.Field - * @instance - */ - Field.prototype.name = ""; - - /** - * Field indexConfig. - * @member {google.firestore.admin.v1.Field.IIndexConfig|null|undefined} indexConfig - * @memberof google.firestore.admin.v1.Field - * @instance - */ - Field.prototype.indexConfig = null; - - Field.IndexConfig = (function() { - + var admin = {}; + + admin.v1 = (function() { + + /** + * Namespace v1. + * @memberof google.firestore.admin + * @namespace + */ + var v1 = {}; + + v1.Field = (function() { + /** - * Properties of an IndexConfig. + * Properties of a Field. + * @memberof google.firestore.admin.v1 + * @interface IField + * @property {string|null} [name] Field name + * @property {google.firestore.admin.v1.Field.IIndexConfig|null} [indexConfig] Field indexConfig + */ + + /** + * Constructs a new Field. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a Field. + * @implements IField + * @constructor + * @param {google.firestore.admin.v1.IField=} [properties] Properties to set + */ + function Field(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Field name. + * @member {string} name * @memberof google.firestore.admin.v1.Field - * @interface IIndexConfig - * @property {Array.|null} [indexes] IndexConfig indexes - * @property {boolean|null} [usesAncestorConfig] IndexConfig usesAncestorConfig - * @property {string|null} [ancestorField] IndexConfig ancestorField - * @property {boolean|null} [reverting] IndexConfig reverting + * @instance */ - + Field.prototype.name = ""; + + /** + * Field indexConfig. + * @member {google.firestore.admin.v1.Field.IIndexConfig|null|undefined} indexConfig + * @memberof google.firestore.admin.v1.Field + * @instance + */ + Field.prototype.indexConfig = null; + /** - * Constructs a new IndexConfig. + * Creates a Field message from a plain object. Also converts values to their respective internal types. + * @function fromObject * @memberof google.firestore.admin.v1.Field - * @classdesc Represents an IndexConfig. - * @implements IIndexConfig + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.Field} Field + */ + Field.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.Field) + return object; + var message = new $root.google.firestore.admin.v1.Field(); + if (object.name != null) + message.name = String(object.name); + if (object.indexConfig != null) { + if (typeof object.indexConfig !== "object") + throw TypeError(".google.firestore.admin.v1.Field.indexConfig: object expected"); + message.indexConfig = $root.google.firestore.admin.v1.Field.IndexConfig.fromObject(object.indexConfig); + } + return message; + }; + + /** + * Creates a plain object from a Field message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.Field + * @static + * @param {google.firestore.admin.v1.Field} message Field + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Field.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.indexConfig = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.indexConfig != null && message.hasOwnProperty("indexConfig")) + object.indexConfig = $root.google.firestore.admin.v1.Field.IndexConfig.toObject(message.indexConfig, options); + return object; + }; + + /** + * Converts this Field to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.Field + * @instance + * @returns {Object.} JSON object + */ + Field.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + Field.IndexConfig = (function() { + + /** + * Properties of an IndexConfig. + * @memberof google.firestore.admin.v1.Field + * @interface IIndexConfig + * @property {Array.|null} [indexes] IndexConfig indexes + * @property {boolean|null} [usesAncestorConfig] IndexConfig usesAncestorConfig + * @property {string|null} [ancestorField] IndexConfig ancestorField + * @property {boolean|null} [reverting] IndexConfig reverting + */ + + /** + * Constructs a new IndexConfig. + * @memberof google.firestore.admin.v1.Field + * @classdesc Represents an IndexConfig. + * @implements IIndexConfig + * @constructor + * @param {google.firestore.admin.v1.Field.IIndexConfig=} [properties] Properties to set + */ + function IndexConfig(properties) { + this.indexes = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * IndexConfig indexes. + * @member {Array.} indexes + * @memberof google.firestore.admin.v1.Field.IndexConfig + * @instance + */ + IndexConfig.prototype.indexes = $util.emptyArray; + + /** + * IndexConfig usesAncestorConfig. + * @member {boolean} usesAncestorConfig + * @memberof google.firestore.admin.v1.Field.IndexConfig + * @instance + */ + IndexConfig.prototype.usesAncestorConfig = false; + + /** + * IndexConfig ancestorField. + * @member {string} ancestorField + * @memberof google.firestore.admin.v1.Field.IndexConfig + * @instance + */ + IndexConfig.prototype.ancestorField = ""; + + /** + * IndexConfig reverting. + * @member {boolean} reverting + * @memberof google.firestore.admin.v1.Field.IndexConfig + * @instance + */ + IndexConfig.prototype.reverting = false; + + /** + * Creates an IndexConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.Field.IndexConfig + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.Field.IndexConfig} IndexConfig + */ + IndexConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.Field.IndexConfig) + return object; + var message = new $root.google.firestore.admin.v1.Field.IndexConfig(); + if (object.indexes) { + if (!Array.isArray(object.indexes)) + throw TypeError(".google.firestore.admin.v1.Field.IndexConfig.indexes: array expected"); + message.indexes = []; + for (var i = 0; i < object.indexes.length; ++i) { + if (typeof object.indexes[i] !== "object") + throw TypeError(".google.firestore.admin.v1.Field.IndexConfig.indexes: object expected"); + message.indexes[i] = $root.google.firestore.admin.v1.Index.fromObject(object.indexes[i]); + } + } + if (object.usesAncestorConfig != null) + message.usesAncestorConfig = Boolean(object.usesAncestorConfig); + if (object.ancestorField != null) + message.ancestorField = String(object.ancestorField); + if (object.reverting != null) + message.reverting = Boolean(object.reverting); + return message; + }; + + /** + * Creates a plain object from an IndexConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.Field.IndexConfig + * @static + * @param {google.firestore.admin.v1.Field.IndexConfig} message IndexConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + IndexConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.indexes = []; + if (options.defaults) { + object.usesAncestorConfig = false; + object.ancestorField = ""; + object.reverting = false; + } + if (message.indexes && message.indexes.length) { + object.indexes = []; + for (var j = 0; j < message.indexes.length; ++j) + object.indexes[j] = $root.google.firestore.admin.v1.Index.toObject(message.indexes[j], options); + } + if (message.usesAncestorConfig != null && message.hasOwnProperty("usesAncestorConfig")) + object.usesAncestorConfig = message.usesAncestorConfig; + if (message.ancestorField != null && message.hasOwnProperty("ancestorField")) + object.ancestorField = message.ancestorField; + if (message.reverting != null && message.hasOwnProperty("reverting")) + object.reverting = message.reverting; + return object; + }; + + /** + * Converts this IndexConfig to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.Field.IndexConfig + * @instance + * @returns {Object.} JSON object + */ + IndexConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return IndexConfig; + })(); + + return Field; + })(); + + v1.FirestoreAdmin = (function() { + + /** + * Constructs a new FirestoreAdmin service. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a FirestoreAdmin + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function FirestoreAdmin(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (FirestoreAdmin.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = FirestoreAdmin; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#createIndex}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef CreateIndexCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls CreateIndex. + * @function createIndex + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.ICreateIndexRequest} request CreateIndexRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.CreateIndexCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.createIndex = function createIndex(request, callback) { + return this.rpcCall(createIndex, $root.google.firestore.admin.v1.CreateIndexRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "CreateIndex" }); + + /** + * Calls CreateIndex. + * @function createIndex + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.ICreateIndexRequest} request CreateIndexRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#listIndexes}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef ListIndexesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.admin.v1.ListIndexesResponse} [response] ListIndexesResponse + */ + + /** + * Calls ListIndexes. + * @function listIndexes + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IListIndexesRequest} request ListIndexesRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.ListIndexesCallback} callback Node-style callback called with the error, if any, and ListIndexesResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.listIndexes = function listIndexes(request, callback) { + return this.rpcCall(listIndexes, $root.google.firestore.admin.v1.ListIndexesRequest, $root.google.firestore.admin.v1.ListIndexesResponse, request, callback); + }, "name", { value: "ListIndexes" }); + + /** + * Calls ListIndexes. + * @function listIndexes + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IListIndexesRequest} request ListIndexesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#getIndex}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef GetIndexCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.admin.v1.Index} [response] Index + */ + + /** + * Calls GetIndex. + * @function getIndex + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IGetIndexRequest} request GetIndexRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.GetIndexCallback} callback Node-style callback called with the error, if any, and Index + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.getIndex = function getIndex(request, callback) { + return this.rpcCall(getIndex, $root.google.firestore.admin.v1.GetIndexRequest, $root.google.firestore.admin.v1.Index, request, callback); + }, "name", { value: "GetIndex" }); + + /** + * Calls GetIndex. + * @function getIndex + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IGetIndexRequest} request GetIndexRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#deleteIndex}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef DeleteIndexCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteIndex. + * @function deleteIndex + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IDeleteIndexRequest} request DeleteIndexRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.DeleteIndexCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.deleteIndex = function deleteIndex(request, callback) { + return this.rpcCall(deleteIndex, $root.google.firestore.admin.v1.DeleteIndexRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteIndex" }); + + /** + * Calls DeleteIndex. + * @function deleteIndex + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IDeleteIndexRequest} request DeleteIndexRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#getField}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef GetFieldCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.admin.v1.Field} [response] Field + */ + + /** + * Calls GetField. + * @function getField + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IGetFieldRequest} request GetFieldRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.GetFieldCallback} callback Node-style callback called with the error, if any, and Field + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.getField = function getField(request, callback) { + return this.rpcCall(getField, $root.google.firestore.admin.v1.GetFieldRequest, $root.google.firestore.admin.v1.Field, request, callback); + }, "name", { value: "GetField" }); + + /** + * Calls GetField. + * @function getField + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IGetFieldRequest} request GetFieldRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#updateField}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef UpdateFieldCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls UpdateField. + * @function updateField + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IUpdateFieldRequest} request UpdateFieldRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.UpdateFieldCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.updateField = function updateField(request, callback) { + return this.rpcCall(updateField, $root.google.firestore.admin.v1.UpdateFieldRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "UpdateField" }); + + /** + * Calls UpdateField. + * @function updateField + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IUpdateFieldRequest} request UpdateFieldRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#listFields}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef ListFieldsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.admin.v1.ListFieldsResponse} [response] ListFieldsResponse + */ + + /** + * Calls ListFields. + * @function listFields + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IListFieldsRequest} request ListFieldsRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.ListFieldsCallback} callback Node-style callback called with the error, if any, and ListFieldsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.listFields = function listFields(request, callback) { + return this.rpcCall(listFields, $root.google.firestore.admin.v1.ListFieldsRequest, $root.google.firestore.admin.v1.ListFieldsResponse, request, callback); + }, "name", { value: "ListFields" }); + + /** + * Calls ListFields. + * @function listFields + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IListFieldsRequest} request ListFieldsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#exportDocuments}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef ExportDocumentsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ExportDocuments. + * @function exportDocuments + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IExportDocumentsRequest} request ExportDocumentsRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.ExportDocumentsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.exportDocuments = function exportDocuments(request, callback) { + return this.rpcCall(exportDocuments, $root.google.firestore.admin.v1.ExportDocumentsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ExportDocuments" }); + + /** + * Calls ExportDocuments. + * @function exportDocuments + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IExportDocumentsRequest} request ExportDocumentsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#importDocuments}. + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @typedef ImportDocumentsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ImportDocuments. + * @function importDocuments + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IImportDocumentsRequest} request ImportDocumentsRequest message or plain object + * @param {google.firestore.admin.v1.FirestoreAdmin.ImportDocumentsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(FirestoreAdmin.prototype.importDocuments = function importDocuments(request, callback) { + return this.rpcCall(importDocuments, $root.google.firestore.admin.v1.ImportDocumentsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ImportDocuments" }); + + /** + * Calls ImportDocuments. + * @function importDocuments + * @memberof google.firestore.admin.v1.FirestoreAdmin + * @instance + * @param {google.firestore.admin.v1.IImportDocumentsRequest} request ImportDocumentsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return FirestoreAdmin; + })(); + + v1.CreateIndexRequest = (function() { + + /** + * Properties of a CreateIndexRequest. + * @memberof google.firestore.admin.v1 + * @interface ICreateIndexRequest + * @property {string|null} [parent] CreateIndexRequest parent + * @property {google.firestore.admin.v1.IIndex|null} [index] CreateIndexRequest index + */ + + /** + * Constructs a new CreateIndexRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a CreateIndexRequest. + * @implements ICreateIndexRequest + * @constructor + * @param {google.firestore.admin.v1.ICreateIndexRequest=} [properties] Properties to set + */ + function CreateIndexRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CreateIndexRequest parent. + * @member {string} parent + * @memberof google.firestore.admin.v1.CreateIndexRequest + * @instance + */ + CreateIndexRequest.prototype.parent = ""; + + /** + * CreateIndexRequest index. + * @member {google.firestore.admin.v1.IIndex|null|undefined} index + * @memberof google.firestore.admin.v1.CreateIndexRequest + * @instance + */ + CreateIndexRequest.prototype.index = null; + + /** + * Creates a CreateIndexRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.CreateIndexRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.CreateIndexRequest} CreateIndexRequest + */ + CreateIndexRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.CreateIndexRequest) + return object; + var message = new $root.google.firestore.admin.v1.CreateIndexRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.index != null) { + if (typeof object.index !== "object") + throw TypeError(".google.firestore.admin.v1.CreateIndexRequest.index: object expected"); + message.index = $root.google.firestore.admin.v1.Index.fromObject(object.index); + } + return message; + }; + + /** + * Creates a plain object from a CreateIndexRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.CreateIndexRequest + * @static + * @param {google.firestore.admin.v1.CreateIndexRequest} message CreateIndexRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateIndexRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.index = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.index != null && message.hasOwnProperty("index")) + object.index = $root.google.firestore.admin.v1.Index.toObject(message.index, options); + return object; + }; + + /** + * Converts this CreateIndexRequest to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.CreateIndexRequest + * @instance + * @returns {Object.} JSON object + */ + CreateIndexRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CreateIndexRequest; + })(); + + v1.ListIndexesRequest = (function() { + + /** + * Properties of a ListIndexesRequest. + * @memberof google.firestore.admin.v1 + * @interface IListIndexesRequest + * @property {string|null} [parent] ListIndexesRequest parent + * @property {string|null} [filter] ListIndexesRequest filter + * @property {number|null} [pageSize] ListIndexesRequest pageSize + * @property {string|null} [pageToken] ListIndexesRequest pageToken + */ + + /** + * Constructs a new ListIndexesRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a ListIndexesRequest. + * @implements IListIndexesRequest + * @constructor + * @param {google.firestore.admin.v1.IListIndexesRequest=} [properties] Properties to set + */ + function ListIndexesRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListIndexesRequest parent. + * @member {string} parent + * @memberof google.firestore.admin.v1.ListIndexesRequest + * @instance + */ + ListIndexesRequest.prototype.parent = ""; + + /** + * ListIndexesRequest filter. + * @member {string} filter + * @memberof google.firestore.admin.v1.ListIndexesRequest + * @instance + */ + ListIndexesRequest.prototype.filter = ""; + + /** + * ListIndexesRequest pageSize. + * @member {number} pageSize + * @memberof google.firestore.admin.v1.ListIndexesRequest + * @instance + */ + ListIndexesRequest.prototype.pageSize = 0; + + /** + * ListIndexesRequest pageToken. + * @member {string} pageToken + * @memberof google.firestore.admin.v1.ListIndexesRequest + * @instance + */ + ListIndexesRequest.prototype.pageToken = ""; + + /** + * Creates a ListIndexesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.ListIndexesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.ListIndexesRequest} ListIndexesRequest + */ + ListIndexesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.ListIndexesRequest) + return object; + var message = new $root.google.firestore.admin.v1.ListIndexesRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.filter != null) + message.filter = String(object.filter); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + return message; + }; + + /** + * Creates a plain object from a ListIndexesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.ListIndexesRequest + * @static + * @param {google.firestore.admin.v1.ListIndexesRequest} message ListIndexesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListIndexesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.filter = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + return object; + }; + + /** + * Converts this ListIndexesRequest to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.ListIndexesRequest + * @instance + * @returns {Object.} JSON object + */ + ListIndexesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListIndexesRequest; + })(); + + v1.ListIndexesResponse = (function() { + + /** + * Properties of a ListIndexesResponse. + * @memberof google.firestore.admin.v1 + * @interface IListIndexesResponse + * @property {Array.|null} [indexes] ListIndexesResponse indexes + * @property {string|null} [nextPageToken] ListIndexesResponse nextPageToken + */ + + /** + * Constructs a new ListIndexesResponse. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a ListIndexesResponse. + * @implements IListIndexesResponse * @constructor - * @param {google.firestore.admin.v1.Field.IIndexConfig=} [properties] Properties to set + * @param {google.firestore.admin.v1.IListIndexesResponse=} [properties] Properties to set */ - function IndexConfig(properties) { + function ListIndexesResponse(properties) { this.indexes = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * IndexConfig indexes. + * ListIndexesResponse indexes. * @member {Array.} indexes - * @memberof google.firestore.admin.v1.Field.IndexConfig + * @memberof google.firestore.admin.v1.ListIndexesResponse * @instance */ - IndexConfig.prototype.indexes = $util.emptyArray; - + ListIndexesResponse.prototype.indexes = $util.emptyArray; + /** - * IndexConfig usesAncestorConfig. - * @member {boolean} usesAncestorConfig - * @memberof google.firestore.admin.v1.Field.IndexConfig + * ListIndexesResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.firestore.admin.v1.ListIndexesResponse * @instance */ - IndexConfig.prototype.usesAncestorConfig = false; - + ListIndexesResponse.prototype.nextPageToken = ""; + + /** + * Creates a ListIndexesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.ListIndexesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.ListIndexesResponse} ListIndexesResponse + */ + ListIndexesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.ListIndexesResponse) + return object; + var message = new $root.google.firestore.admin.v1.ListIndexesResponse(); + if (object.indexes) { + if (!Array.isArray(object.indexes)) + throw TypeError(".google.firestore.admin.v1.ListIndexesResponse.indexes: array expected"); + message.indexes = []; + for (var i = 0; i < object.indexes.length; ++i) { + if (typeof object.indexes[i] !== "object") + throw TypeError(".google.firestore.admin.v1.ListIndexesResponse.indexes: object expected"); + message.indexes[i] = $root.google.firestore.admin.v1.Index.fromObject(object.indexes[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListIndexesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.ListIndexesResponse + * @static + * @param {google.firestore.admin.v1.ListIndexesResponse} message ListIndexesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListIndexesResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.indexes = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.indexes && message.indexes.length) { + object.indexes = []; + for (var j = 0; j < message.indexes.length; ++j) + object.indexes[j] = $root.google.firestore.admin.v1.Index.toObject(message.indexes[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + /** - * IndexConfig ancestorField. - * @member {string} ancestorField - * @memberof google.firestore.admin.v1.Field.IndexConfig + * Converts this ListIndexesResponse to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.ListIndexesResponse * @instance + * @returns {Object.} JSON object */ - IndexConfig.prototype.ancestorField = ""; - + ListIndexesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListIndexesResponse; + })(); + + v1.GetIndexRequest = (function() { + + /** + * Properties of a GetIndexRequest. + * @memberof google.firestore.admin.v1 + * @interface IGetIndexRequest + * @property {string|null} [name] GetIndexRequest name + */ + + /** + * Constructs a new GetIndexRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a GetIndexRequest. + * @implements IGetIndexRequest + * @constructor + * @param {google.firestore.admin.v1.IGetIndexRequest=} [properties] Properties to set + */ + function GetIndexRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + /** - * IndexConfig reverting. - * @member {boolean} reverting - * @memberof google.firestore.admin.v1.Field.IndexConfig + * GetIndexRequest name. + * @member {string} name + * @memberof google.firestore.admin.v1.GetIndexRequest * @instance */ - IndexConfig.prototype.reverting = false; - - return IndexConfig; + GetIndexRequest.prototype.name = ""; + + /** + * Creates a GetIndexRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.GetIndexRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.GetIndexRequest} GetIndexRequest + */ + GetIndexRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.GetIndexRequest) + return object; + var message = new $root.google.firestore.admin.v1.GetIndexRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetIndexRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.GetIndexRequest + * @static + * @param {google.firestore.admin.v1.GetIndexRequest} message GetIndexRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetIndexRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetIndexRequest to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.GetIndexRequest + * @instance + * @returns {Object.} JSON object + */ + GetIndexRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetIndexRequest; })(); - - return Field; - })(); - - v1.FirestoreAdmin = (function() { - - /** - * Constructs a new FirestoreAdmin service. - * @memberof google.firestore.admin.v1 - * @classdesc Represents a FirestoreAdmin - * @extends $protobuf.rpc.Service - * @constructor - * @param {$protobuf.RPCImpl} rpcImpl RPC implementation - * @param {boolean} [requestDelimited=false] Whether requests are length-delimited - * @param {boolean} [responseDelimited=false] Whether responses are length-delimited - */ - function FirestoreAdmin(rpcImpl, requestDelimited, responseDelimited) { - $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); - } - - (FirestoreAdmin.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = FirestoreAdmin; - - /** - * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#createIndex}. - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @typedef CreateIndexCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.longrunning.Operation} [response] Operation - */ - - /** - * Calls CreateIndex. - * @function createIndex - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.ICreateIndexRequest} request CreateIndexRequest message or plain object - * @param {google.firestore.admin.v1.FirestoreAdmin.CreateIndexCallback} callback Node-style callback called with the error, if any, and Operation - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(FirestoreAdmin.prototype.createIndex = function createIndex(request, callback) { - return this.rpcCall(createIndex, $root.google.firestore.admin.v1.CreateIndexRequest, $root.google.longrunning.Operation, request, callback); - }, "name", { value: "CreateIndex" }); - - /** - * Calls CreateIndex. - * @function createIndex - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.ICreateIndexRequest} request CreateIndexRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#listIndexes}. - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @typedef ListIndexesCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.admin.v1.ListIndexesResponse} [response] ListIndexesResponse - */ - - /** - * Calls ListIndexes. - * @function listIndexes - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.IListIndexesRequest} request ListIndexesRequest message or plain object - * @param {google.firestore.admin.v1.FirestoreAdmin.ListIndexesCallback} callback Node-style callback called with the error, if any, and ListIndexesResponse - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(FirestoreAdmin.prototype.listIndexes = function listIndexes(request, callback) { - return this.rpcCall(listIndexes, $root.google.firestore.admin.v1.ListIndexesRequest, $root.google.firestore.admin.v1.ListIndexesResponse, request, callback); - }, "name", { value: "ListIndexes" }); - - /** - * Calls ListIndexes. - * @function listIndexes - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.IListIndexesRequest} request ListIndexesRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#getIndex}. - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @typedef GetIndexCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.admin.v1.Index} [response] Index - */ - - /** - * Calls GetIndex. - * @function getIndex - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.IGetIndexRequest} request GetIndexRequest message or plain object - * @param {google.firestore.admin.v1.FirestoreAdmin.GetIndexCallback} callback Node-style callback called with the error, if any, and Index - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(FirestoreAdmin.prototype.getIndex = function getIndex(request, callback) { - return this.rpcCall(getIndex, $root.google.firestore.admin.v1.GetIndexRequest, $root.google.firestore.admin.v1.Index, request, callback); - }, "name", { value: "GetIndex" }); - - /** - * Calls GetIndex. - * @function getIndex - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.IGetIndexRequest} request GetIndexRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#deleteIndex}. - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @typedef DeleteIndexCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.protobuf.Empty} [response] Empty - */ - - /** - * Calls DeleteIndex. - * @function deleteIndex - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.IDeleteIndexRequest} request DeleteIndexRequest message or plain object - * @param {google.firestore.admin.v1.FirestoreAdmin.DeleteIndexCallback} callback Node-style callback called with the error, if any, and Empty - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(FirestoreAdmin.prototype.deleteIndex = function deleteIndex(request, callback) { - return this.rpcCall(deleteIndex, $root.google.firestore.admin.v1.DeleteIndexRequest, $root.google.protobuf.Empty, request, callback); - }, "name", { value: "DeleteIndex" }); - - /** - * Calls DeleteIndex. - * @function deleteIndex - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.IDeleteIndexRequest} request DeleteIndexRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#getField}. - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @typedef GetFieldCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.admin.v1.Field} [response] Field - */ - - /** - * Calls GetField. - * @function getField - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.IGetFieldRequest} request GetFieldRequest message or plain object - * @param {google.firestore.admin.v1.FirestoreAdmin.GetFieldCallback} callback Node-style callback called with the error, if any, and Field - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(FirestoreAdmin.prototype.getField = function getField(request, callback) { - return this.rpcCall(getField, $root.google.firestore.admin.v1.GetFieldRequest, $root.google.firestore.admin.v1.Field, request, callback); - }, "name", { value: "GetField" }); - - /** - * Calls GetField. - * @function getField - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.IGetFieldRequest} request GetFieldRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#updateField}. - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @typedef UpdateFieldCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.longrunning.Operation} [response] Operation - */ - - /** - * Calls UpdateField. - * @function updateField - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.IUpdateFieldRequest} request UpdateFieldRequest message or plain object - * @param {google.firestore.admin.v1.FirestoreAdmin.UpdateFieldCallback} callback Node-style callback called with the error, if any, and Operation - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(FirestoreAdmin.prototype.updateField = function updateField(request, callback) { - return this.rpcCall(updateField, $root.google.firestore.admin.v1.UpdateFieldRequest, $root.google.longrunning.Operation, request, callback); - }, "name", { value: "UpdateField" }); - - /** - * Calls UpdateField. - * @function updateField - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.IUpdateFieldRequest} request UpdateFieldRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#listFields}. - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @typedef ListFieldsCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.admin.v1.ListFieldsResponse} [response] ListFieldsResponse - */ - - /** - * Calls ListFields. - * @function listFields - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.IListFieldsRequest} request ListFieldsRequest message or plain object - * @param {google.firestore.admin.v1.FirestoreAdmin.ListFieldsCallback} callback Node-style callback called with the error, if any, and ListFieldsResponse - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(FirestoreAdmin.prototype.listFields = function listFields(request, callback) { - return this.rpcCall(listFields, $root.google.firestore.admin.v1.ListFieldsRequest, $root.google.firestore.admin.v1.ListFieldsResponse, request, callback); - }, "name", { value: "ListFields" }); - - /** - * Calls ListFields. - * @function listFields - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.IListFieldsRequest} request ListFieldsRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#exportDocuments}. - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @typedef ExportDocumentsCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.longrunning.Operation} [response] Operation - */ - - /** - * Calls ExportDocuments. - * @function exportDocuments - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.IExportDocumentsRequest} request ExportDocumentsRequest message or plain object - * @param {google.firestore.admin.v1.FirestoreAdmin.ExportDocumentsCallback} callback Node-style callback called with the error, if any, and Operation - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(FirestoreAdmin.prototype.exportDocuments = function exportDocuments(request, callback) { - return this.rpcCall(exportDocuments, $root.google.firestore.admin.v1.ExportDocumentsRequest, $root.google.longrunning.Operation, request, callback); - }, "name", { value: "ExportDocuments" }); - - /** - * Calls ExportDocuments. - * @function exportDocuments - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.IExportDocumentsRequest} request ExportDocumentsRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#importDocuments}. - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @typedef ImportDocumentsCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.longrunning.Operation} [response] Operation - */ - - /** - * Calls ImportDocuments. - * @function importDocuments - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.IImportDocumentsRequest} request ImportDocumentsRequest message or plain object - * @param {google.firestore.admin.v1.FirestoreAdmin.ImportDocumentsCallback} callback Node-style callback called with the error, if any, and Operation - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(FirestoreAdmin.prototype.importDocuments = function importDocuments(request, callback) { - return this.rpcCall(importDocuments, $root.google.firestore.admin.v1.ImportDocumentsRequest, $root.google.longrunning.Operation, request, callback); - }, "name", { value: "ImportDocuments" }); - - /** - * Calls ImportDocuments. - * @function importDocuments - * @memberof google.firestore.admin.v1.FirestoreAdmin - * @instance - * @param {google.firestore.admin.v1.IImportDocumentsRequest} request ImportDocumentsRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - return FirestoreAdmin; - })(); - - v1.CreateIndexRequest = (function() { - - /** - * Properties of a CreateIndexRequest. - * @memberof google.firestore.admin.v1 - * @interface ICreateIndexRequest - * @property {string|null} [parent] CreateIndexRequest parent - * @property {google.firestore.admin.v1.IIndex|null} [index] CreateIndexRequest index - */ - - /** - * Constructs a new CreateIndexRequest. - * @memberof google.firestore.admin.v1 - * @classdesc Represents a CreateIndexRequest. - * @implements ICreateIndexRequest - * @constructor - * @param {google.firestore.admin.v1.ICreateIndexRequest=} [properties] Properties to set - */ - function CreateIndexRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * CreateIndexRequest parent. - * @member {string} parent - * @memberof google.firestore.admin.v1.CreateIndexRequest - * @instance - */ - CreateIndexRequest.prototype.parent = ""; - - /** - * CreateIndexRequest index. - * @member {google.firestore.admin.v1.IIndex|null|undefined} index - * @memberof google.firestore.admin.v1.CreateIndexRequest - * @instance - */ - CreateIndexRequest.prototype.index = null; - - return CreateIndexRequest; - })(); - - v1.ListIndexesRequest = (function() { - - /** - * Properties of a ListIndexesRequest. - * @memberof google.firestore.admin.v1 - * @interface IListIndexesRequest - * @property {string|null} [parent] ListIndexesRequest parent - * @property {string|null} [filter] ListIndexesRequest filter - * @property {number|null} [pageSize] ListIndexesRequest pageSize - * @property {string|null} [pageToken] ListIndexesRequest pageToken - */ - - /** - * Constructs a new ListIndexesRequest. - * @memberof google.firestore.admin.v1 - * @classdesc Represents a ListIndexesRequest. - * @implements IListIndexesRequest - * @constructor - * @param {google.firestore.admin.v1.IListIndexesRequest=} [properties] Properties to set - */ - function ListIndexesRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListIndexesRequest parent. - * @member {string} parent - * @memberof google.firestore.admin.v1.ListIndexesRequest - * @instance - */ - ListIndexesRequest.prototype.parent = ""; - - /** - * ListIndexesRequest filter. - * @member {string} filter - * @memberof google.firestore.admin.v1.ListIndexesRequest - * @instance - */ - ListIndexesRequest.prototype.filter = ""; - - /** - * ListIndexesRequest pageSize. - * @member {number} pageSize - * @memberof google.firestore.admin.v1.ListIndexesRequest - * @instance - */ - ListIndexesRequest.prototype.pageSize = 0; - - /** - * ListIndexesRequest pageToken. - * @member {string} pageToken - * @memberof google.firestore.admin.v1.ListIndexesRequest - * @instance - */ - ListIndexesRequest.prototype.pageToken = ""; - - return ListIndexesRequest; - })(); - - v1.ListIndexesResponse = (function() { - - /** - * Properties of a ListIndexesResponse. - * @memberof google.firestore.admin.v1 - * @interface IListIndexesResponse - * @property {Array.|null} [indexes] ListIndexesResponse indexes - * @property {string|null} [nextPageToken] ListIndexesResponse nextPageToken - */ - - /** - * Constructs a new ListIndexesResponse. - * @memberof google.firestore.admin.v1 - * @classdesc Represents a ListIndexesResponse. - * @implements IListIndexesResponse - * @constructor - * @param {google.firestore.admin.v1.IListIndexesResponse=} [properties] Properties to set - */ - function ListIndexesResponse(properties) { - this.indexes = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListIndexesResponse indexes. - * @member {Array.} indexes - * @memberof google.firestore.admin.v1.ListIndexesResponse - * @instance - */ - ListIndexesResponse.prototype.indexes = $util.emptyArray; - - /** - * ListIndexesResponse nextPageToken. - * @member {string} nextPageToken - * @memberof google.firestore.admin.v1.ListIndexesResponse - * @instance - */ - ListIndexesResponse.prototype.nextPageToken = ""; - - return ListIndexesResponse; - })(); - - v1.GetIndexRequest = (function() { - - /** - * Properties of a GetIndexRequest. - * @memberof google.firestore.admin.v1 - * @interface IGetIndexRequest - * @property {string|null} [name] GetIndexRequest name - */ - - /** - * Constructs a new GetIndexRequest. - * @memberof google.firestore.admin.v1 - * @classdesc Represents a GetIndexRequest. - * @implements IGetIndexRequest - * @constructor - * @param {google.firestore.admin.v1.IGetIndexRequest=} [properties] Properties to set - */ - function GetIndexRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * GetIndexRequest name. - * @member {string} name - * @memberof google.firestore.admin.v1.GetIndexRequest - * @instance - */ - GetIndexRequest.prototype.name = ""; - - return GetIndexRequest; - })(); - - v1.DeleteIndexRequest = (function() { - - /** - * Properties of a DeleteIndexRequest. - * @memberof google.firestore.admin.v1 - * @interface IDeleteIndexRequest - * @property {string|null} [name] DeleteIndexRequest name - */ - - /** - * Constructs a new DeleteIndexRequest. - * @memberof google.firestore.admin.v1 - * @classdesc Represents a DeleteIndexRequest. - * @implements IDeleteIndexRequest - * @constructor - * @param {google.firestore.admin.v1.IDeleteIndexRequest=} [properties] Properties to set - */ - function DeleteIndexRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DeleteIndexRequest name. - * @member {string} name - * @memberof google.firestore.admin.v1.DeleteIndexRequest - * @instance - */ - DeleteIndexRequest.prototype.name = ""; - - return DeleteIndexRequest; - })(); - - v1.UpdateFieldRequest = (function() { - - /** - * Properties of an UpdateFieldRequest. - * @memberof google.firestore.admin.v1 - * @interface IUpdateFieldRequest - * @property {google.firestore.admin.v1.IField|null} [field] UpdateFieldRequest field - * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateFieldRequest updateMask - */ - - /** - * Constructs a new UpdateFieldRequest. - * @memberof google.firestore.admin.v1 - * @classdesc Represents an UpdateFieldRequest. - * @implements IUpdateFieldRequest - * @constructor - * @param {google.firestore.admin.v1.IUpdateFieldRequest=} [properties] Properties to set - */ - function UpdateFieldRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * UpdateFieldRequest field. - * @member {google.firestore.admin.v1.IField|null|undefined} field - * @memberof google.firestore.admin.v1.UpdateFieldRequest - * @instance - */ - UpdateFieldRequest.prototype.field = null; - - /** - * UpdateFieldRequest updateMask. - * @member {google.protobuf.IFieldMask|null|undefined} updateMask - * @memberof google.firestore.admin.v1.UpdateFieldRequest - * @instance - */ - UpdateFieldRequest.prototype.updateMask = null; - - return UpdateFieldRequest; - })(); - - v1.GetFieldRequest = (function() { - - /** - * Properties of a GetFieldRequest. - * @memberof google.firestore.admin.v1 - * @interface IGetFieldRequest - * @property {string|null} [name] GetFieldRequest name - */ - - /** - * Constructs a new GetFieldRequest. - * @memberof google.firestore.admin.v1 - * @classdesc Represents a GetFieldRequest. - * @implements IGetFieldRequest - * @constructor - * @param {google.firestore.admin.v1.IGetFieldRequest=} [properties] Properties to set - */ - function GetFieldRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * GetFieldRequest name. - * @member {string} name - * @memberof google.firestore.admin.v1.GetFieldRequest - * @instance - */ - GetFieldRequest.prototype.name = ""; - - return GetFieldRequest; - })(); - - v1.ListFieldsRequest = (function() { - - /** - * Properties of a ListFieldsRequest. - * @memberof google.firestore.admin.v1 - * @interface IListFieldsRequest - * @property {string|null} [parent] ListFieldsRequest parent - * @property {string|null} [filter] ListFieldsRequest filter - * @property {number|null} [pageSize] ListFieldsRequest pageSize - * @property {string|null} [pageToken] ListFieldsRequest pageToken - */ - - /** - * Constructs a new ListFieldsRequest. - * @memberof google.firestore.admin.v1 - * @classdesc Represents a ListFieldsRequest. - * @implements IListFieldsRequest - * @constructor - * @param {google.firestore.admin.v1.IListFieldsRequest=} [properties] Properties to set - */ - function ListFieldsRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListFieldsRequest parent. - * @member {string} parent - * @memberof google.firestore.admin.v1.ListFieldsRequest - * @instance - */ - ListFieldsRequest.prototype.parent = ""; - - /** - * ListFieldsRequest filter. - * @member {string} filter - * @memberof google.firestore.admin.v1.ListFieldsRequest - * @instance - */ - ListFieldsRequest.prototype.filter = ""; - - /** - * ListFieldsRequest pageSize. - * @member {number} pageSize - * @memberof google.firestore.admin.v1.ListFieldsRequest - * @instance - */ - ListFieldsRequest.prototype.pageSize = 0; - - /** - * ListFieldsRequest pageToken. - * @member {string} pageToken - * @memberof google.firestore.admin.v1.ListFieldsRequest - * @instance - */ - ListFieldsRequest.prototype.pageToken = ""; - - return ListFieldsRequest; - })(); - - v1.ListFieldsResponse = (function() { - - /** - * Properties of a ListFieldsResponse. - * @memberof google.firestore.admin.v1 - * @interface IListFieldsResponse - * @property {Array.|null} [fields] ListFieldsResponse fields - * @property {string|null} [nextPageToken] ListFieldsResponse nextPageToken - */ - - /** - * Constructs a new ListFieldsResponse. - * @memberof google.firestore.admin.v1 - * @classdesc Represents a ListFieldsResponse. - * @implements IListFieldsResponse - * @constructor - * @param {google.firestore.admin.v1.IListFieldsResponse=} [properties] Properties to set - */ - function ListFieldsResponse(properties) { - this.fields = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListFieldsResponse fields. - * @member {Array.} fields - * @memberof google.firestore.admin.v1.ListFieldsResponse - * @instance - */ - ListFieldsResponse.prototype.fields = $util.emptyArray; - - /** - * ListFieldsResponse nextPageToken. - * @member {string} nextPageToken - * @memberof google.firestore.admin.v1.ListFieldsResponse - * @instance - */ - ListFieldsResponse.prototype.nextPageToken = ""; - - return ListFieldsResponse; - })(); - - v1.ExportDocumentsRequest = (function() { - - /** - * Properties of an ExportDocumentsRequest. - * @memberof google.firestore.admin.v1 - * @interface IExportDocumentsRequest - * @property {string|null} [name] ExportDocumentsRequest name - * @property {Array.|null} [collectionIds] ExportDocumentsRequest collectionIds - * @property {string|null} [outputUriPrefix] ExportDocumentsRequest outputUriPrefix - */ - - /** - * Constructs a new ExportDocumentsRequest. - * @memberof google.firestore.admin.v1 - * @classdesc Represents an ExportDocumentsRequest. - * @implements IExportDocumentsRequest - * @constructor - * @param {google.firestore.admin.v1.IExportDocumentsRequest=} [properties] Properties to set - */ - function ExportDocumentsRequest(properties) { - this.collectionIds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ExportDocumentsRequest name. - * @member {string} name - * @memberof google.firestore.admin.v1.ExportDocumentsRequest - * @instance - */ - ExportDocumentsRequest.prototype.name = ""; - - /** - * ExportDocumentsRequest collectionIds. - * @member {Array.} collectionIds - * @memberof google.firestore.admin.v1.ExportDocumentsRequest - * @instance - */ - ExportDocumentsRequest.prototype.collectionIds = $util.emptyArray; - - /** - * ExportDocumentsRequest outputUriPrefix. - * @member {string} outputUriPrefix - * @memberof google.firestore.admin.v1.ExportDocumentsRequest - * @instance - */ - ExportDocumentsRequest.prototype.outputUriPrefix = ""; - - return ExportDocumentsRequest; - })(); - - v1.ImportDocumentsRequest = (function() { - - /** - * Properties of an ImportDocumentsRequest. - * @memberof google.firestore.admin.v1 - * @interface IImportDocumentsRequest - * @property {string|null} [name] ImportDocumentsRequest name - * @property {Array.|null} [collectionIds] ImportDocumentsRequest collectionIds - * @property {string|null} [inputUriPrefix] ImportDocumentsRequest inputUriPrefix - */ - - /** - * Constructs a new ImportDocumentsRequest. - * @memberof google.firestore.admin.v1 - * @classdesc Represents an ImportDocumentsRequest. - * @implements IImportDocumentsRequest - * @constructor - * @param {google.firestore.admin.v1.IImportDocumentsRequest=} [properties] Properties to set - */ - function ImportDocumentsRequest(properties) { - this.collectionIds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ImportDocumentsRequest name. - * @member {string} name - * @memberof google.firestore.admin.v1.ImportDocumentsRequest - * @instance - */ - ImportDocumentsRequest.prototype.name = ""; - - /** - * ImportDocumentsRequest collectionIds. - * @member {Array.} collectionIds - * @memberof google.firestore.admin.v1.ImportDocumentsRequest - * @instance - */ - ImportDocumentsRequest.prototype.collectionIds = $util.emptyArray; - - /** - * ImportDocumentsRequest inputUriPrefix. - * @member {string} inputUriPrefix - * @memberof google.firestore.admin.v1.ImportDocumentsRequest - * @instance - */ - ImportDocumentsRequest.prototype.inputUriPrefix = ""; - - return ImportDocumentsRequest; - })(); - - v1.Index = (function() { - - /** - * Properties of an Index. - * @memberof google.firestore.admin.v1 - * @interface IIndex - * @property {string|null} [name] Index name - * @property {google.firestore.admin.v1.Index.QueryScope|null} [queryScope] Index queryScope - * @property {Array.|null} [fields] Index fields - * @property {google.firestore.admin.v1.Index.State|null} [state] Index state - */ - - /** - * Constructs a new Index. - * @memberof google.firestore.admin.v1 - * @classdesc Represents an Index. - * @implements IIndex - * @constructor - * @param {google.firestore.admin.v1.IIndex=} [properties] Properties to set - */ - function Index(properties) { - this.fields = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Index name. - * @member {string} name - * @memberof google.firestore.admin.v1.Index - * @instance - */ - Index.prototype.name = ""; - - /** - * Index queryScope. - * @member {google.firestore.admin.v1.Index.QueryScope} queryScope - * @memberof google.firestore.admin.v1.Index - * @instance - */ - Index.prototype.queryScope = 0; - - /** - * Index fields. - * @member {Array.} fields - * @memberof google.firestore.admin.v1.Index - * @instance - */ - Index.prototype.fields = $util.emptyArray; - - /** - * Index state. - * @member {google.firestore.admin.v1.Index.State} state - * @memberof google.firestore.admin.v1.Index - * @instance - */ - Index.prototype.state = 0; - - Index.IndexField = (function() { - - /** - * Properties of an IndexField. - * @memberof google.firestore.admin.v1.Index - * @interface IIndexField - * @property {string|null} [fieldPath] IndexField fieldPath - * @property {google.firestore.admin.v1.Index.IndexField.Order|null} [order] IndexField order - * @property {google.firestore.admin.v1.Index.IndexField.ArrayConfig|null} [arrayConfig] IndexField arrayConfig - */ - - /** - * Constructs a new IndexField. - * @memberof google.firestore.admin.v1.Index - * @classdesc Represents an IndexField. - * @implements IIndexField - * @constructor - * @param {google.firestore.admin.v1.Index.IIndexField=} [properties] Properties to set - */ - function IndexField(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * IndexField fieldPath. - * @member {string} fieldPath - * @memberof google.firestore.admin.v1.Index.IndexField - * @instance - */ - IndexField.prototype.fieldPath = ""; - - /** - * IndexField order. - * @member {google.firestore.admin.v1.Index.IndexField.Order} order - * @memberof google.firestore.admin.v1.Index.IndexField - * @instance - */ - IndexField.prototype.order = 0; - - /** - * IndexField arrayConfig. - * @member {google.firestore.admin.v1.Index.IndexField.ArrayConfig} arrayConfig - * @memberof google.firestore.admin.v1.Index.IndexField - * @instance - */ - IndexField.prototype.arrayConfig = 0; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * IndexField valueMode. - * @member {"order"|"arrayConfig"|undefined} valueMode - * @memberof google.firestore.admin.v1.Index.IndexField - * @instance - */ - Object.defineProperty(IndexField.prototype, "valueMode", { - get: $util.oneOfGetter($oneOfFields = ["order", "arrayConfig"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * Order enum. - * @name google.firestore.admin.v1.Index.IndexField.Order - * @enum {number} - * @property {string} ORDER_UNSPECIFIED=ORDER_UNSPECIFIED ORDER_UNSPECIFIED value - * @property {string} ASCENDING=ASCENDING ASCENDING value - * @property {string} DESCENDING=DESCENDING DESCENDING value - */ - IndexField.Order = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "ORDER_UNSPECIFIED"] = "ORDER_UNSPECIFIED"; - values[valuesById[1] = "ASCENDING"] = "ASCENDING"; - values[valuesById[2] = "DESCENDING"] = "DESCENDING"; - return values; - })(); - - /** - * ArrayConfig enum. - * @name google.firestore.admin.v1.Index.IndexField.ArrayConfig - * @enum {number} - * @property {string} ARRAY_CONFIG_UNSPECIFIED=ARRAY_CONFIG_UNSPECIFIED ARRAY_CONFIG_UNSPECIFIED value - * @property {string} CONTAINS=CONTAINS CONTAINS value - */ - IndexField.ArrayConfig = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "ARRAY_CONFIG_UNSPECIFIED"] = "ARRAY_CONFIG_UNSPECIFIED"; - values[valuesById[1] = "CONTAINS"] = "CONTAINS"; - return values; - })(); - - return IndexField; - })(); - - /** - * QueryScope enum. - * @name google.firestore.admin.v1.Index.QueryScope - * @enum {number} - * @property {string} QUERY_SCOPE_UNSPECIFIED=QUERY_SCOPE_UNSPECIFIED QUERY_SCOPE_UNSPECIFIED value - * @property {string} COLLECTION=COLLECTION COLLECTION value - * @property {string} COLLECTION_GROUP=COLLECTION_GROUP COLLECTION_GROUP value - */ - Index.QueryScope = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "QUERY_SCOPE_UNSPECIFIED"] = "QUERY_SCOPE_UNSPECIFIED"; - values[valuesById[1] = "COLLECTION"] = "COLLECTION"; - values[valuesById[2] = "COLLECTION_GROUP"] = "COLLECTION_GROUP"; - return values; - })(); - - /** - * State enum. - * @name google.firestore.admin.v1.Index.State - * @enum {number} - * @property {string} STATE_UNSPECIFIED=STATE_UNSPECIFIED STATE_UNSPECIFIED value - * @property {string} CREATING=CREATING CREATING value - * @property {string} READY=READY READY value - * @property {string} NEEDS_REPAIR=NEEDS_REPAIR NEEDS_REPAIR value - */ - Index.State = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED"; - values[valuesById[1] = "CREATING"] = "CREATING"; - values[valuesById[2] = "READY"] = "READY"; - values[valuesById[3] = "NEEDS_REPAIR"] = "NEEDS_REPAIR"; - return values; - })(); - - return Index; - })(); - - v1.LocationMetadata = (function() { - - /** - * Properties of a LocationMetadata. - * @memberof google.firestore.admin.v1 - * @interface ILocationMetadata - */ - - /** - * Constructs a new LocationMetadata. - * @memberof google.firestore.admin.v1 - * @classdesc Represents a LocationMetadata. - * @implements ILocationMetadata - * @constructor - * @param {google.firestore.admin.v1.ILocationMetadata=} [properties] Properties to set - */ - function LocationMetadata(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - return LocationMetadata; - })(); - - v1.IndexOperationMetadata = (function() { - - /** - * Properties of an IndexOperationMetadata. - * @memberof google.firestore.admin.v1 - * @interface IIndexOperationMetadata - * @property {google.protobuf.ITimestamp|null} [startTime] IndexOperationMetadata startTime - * @property {google.protobuf.ITimestamp|null} [endTime] IndexOperationMetadata endTime - * @property {string|null} [index] IndexOperationMetadata index - * @property {google.firestore.admin.v1.OperationState|null} [state] IndexOperationMetadata state - * @property {google.firestore.admin.v1.IProgress|null} [progressDocuments] IndexOperationMetadata progressDocuments - * @property {google.firestore.admin.v1.IProgress|null} [progressBytes] IndexOperationMetadata progressBytes - */ - - /** - * Constructs a new IndexOperationMetadata. - * @memberof google.firestore.admin.v1 - * @classdesc Represents an IndexOperationMetadata. - * @implements IIndexOperationMetadata - * @constructor - * @param {google.firestore.admin.v1.IIndexOperationMetadata=} [properties] Properties to set - */ - function IndexOperationMetadata(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * IndexOperationMetadata startTime. - * @member {google.protobuf.ITimestamp|null|undefined} startTime - * @memberof google.firestore.admin.v1.IndexOperationMetadata - * @instance - */ - IndexOperationMetadata.prototype.startTime = null; - - /** - * IndexOperationMetadata endTime. - * @member {google.protobuf.ITimestamp|null|undefined} endTime - * @memberof google.firestore.admin.v1.IndexOperationMetadata - * @instance - */ - IndexOperationMetadata.prototype.endTime = null; - - /** - * IndexOperationMetadata index. - * @member {string} index - * @memberof google.firestore.admin.v1.IndexOperationMetadata - * @instance - */ - IndexOperationMetadata.prototype.index = ""; - - /** - * IndexOperationMetadata state. - * @member {google.firestore.admin.v1.OperationState} state - * @memberof google.firestore.admin.v1.IndexOperationMetadata - * @instance - */ - IndexOperationMetadata.prototype.state = 0; - - /** - * IndexOperationMetadata progressDocuments. - * @member {google.firestore.admin.v1.IProgress|null|undefined} progressDocuments - * @memberof google.firestore.admin.v1.IndexOperationMetadata - * @instance - */ - IndexOperationMetadata.prototype.progressDocuments = null; - - /** - * IndexOperationMetadata progressBytes. - * @member {google.firestore.admin.v1.IProgress|null|undefined} progressBytes - * @memberof google.firestore.admin.v1.IndexOperationMetadata - * @instance - */ - IndexOperationMetadata.prototype.progressBytes = null; - - return IndexOperationMetadata; - })(); - - v1.FieldOperationMetadata = (function() { - - /** - * Properties of a FieldOperationMetadata. - * @memberof google.firestore.admin.v1 - * @interface IFieldOperationMetadata - * @property {google.protobuf.ITimestamp|null} [startTime] FieldOperationMetadata startTime - * @property {google.protobuf.ITimestamp|null} [endTime] FieldOperationMetadata endTime - * @property {string|null} [field] FieldOperationMetadata field - * @property {Array.|null} [indexConfigDeltas] FieldOperationMetadata indexConfigDeltas - * @property {google.firestore.admin.v1.OperationState|null} [state] FieldOperationMetadata state - * @property {google.firestore.admin.v1.IProgress|null} [progressDocuments] FieldOperationMetadata progressDocuments - * @property {google.firestore.admin.v1.IProgress|null} [progressBytes] FieldOperationMetadata progressBytes - */ - - /** - * Constructs a new FieldOperationMetadata. - * @memberof google.firestore.admin.v1 - * @classdesc Represents a FieldOperationMetadata. - * @implements IFieldOperationMetadata - * @constructor - * @param {google.firestore.admin.v1.IFieldOperationMetadata=} [properties] Properties to set - */ - function FieldOperationMetadata(properties) { - this.indexConfigDeltas = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FieldOperationMetadata startTime. - * @member {google.protobuf.ITimestamp|null|undefined} startTime - * @memberof google.firestore.admin.v1.FieldOperationMetadata - * @instance - */ - FieldOperationMetadata.prototype.startTime = null; - - /** - * FieldOperationMetadata endTime. - * @member {google.protobuf.ITimestamp|null|undefined} endTime - * @memberof google.firestore.admin.v1.FieldOperationMetadata - * @instance - */ - FieldOperationMetadata.prototype.endTime = null; - - /** - * FieldOperationMetadata field. - * @member {string} field - * @memberof google.firestore.admin.v1.FieldOperationMetadata - * @instance - */ - FieldOperationMetadata.prototype.field = ""; - - /** - * FieldOperationMetadata indexConfigDeltas. - * @member {Array.} indexConfigDeltas - * @memberof google.firestore.admin.v1.FieldOperationMetadata - * @instance - */ - FieldOperationMetadata.prototype.indexConfigDeltas = $util.emptyArray; - - /** - * FieldOperationMetadata state. - * @member {google.firestore.admin.v1.OperationState} state - * @memberof google.firestore.admin.v1.FieldOperationMetadata - * @instance - */ - FieldOperationMetadata.prototype.state = 0; - - /** - * FieldOperationMetadata progressDocuments. - * @member {google.firestore.admin.v1.IProgress|null|undefined} progressDocuments - * @memberof google.firestore.admin.v1.FieldOperationMetadata - * @instance - */ - FieldOperationMetadata.prototype.progressDocuments = null; - - /** - * FieldOperationMetadata progressBytes. - * @member {google.firestore.admin.v1.IProgress|null|undefined} progressBytes - * @memberof google.firestore.admin.v1.FieldOperationMetadata - * @instance - */ - FieldOperationMetadata.prototype.progressBytes = null; - - FieldOperationMetadata.IndexConfigDelta = (function() { - - /** - * Properties of an IndexConfigDelta. - * @memberof google.firestore.admin.v1.FieldOperationMetadata - * @interface IIndexConfigDelta - * @property {google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType|null} [changeType] IndexConfigDelta changeType - * @property {google.firestore.admin.v1.IIndex|null} [index] IndexConfigDelta index - */ - - /** - * Constructs a new IndexConfigDelta. - * @memberof google.firestore.admin.v1.FieldOperationMetadata - * @classdesc Represents an IndexConfigDelta. - * @implements IIndexConfigDelta - * @constructor - * @param {google.firestore.admin.v1.FieldOperationMetadata.IIndexConfigDelta=} [properties] Properties to set - */ - function IndexConfigDelta(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * IndexConfigDelta changeType. - * @member {google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType} changeType - * @memberof google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta - * @instance - */ - IndexConfigDelta.prototype.changeType = 0; - - /** - * IndexConfigDelta index. - * @member {google.firestore.admin.v1.IIndex|null|undefined} index - * @memberof google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta - * @instance - */ - IndexConfigDelta.prototype.index = null; - - /** - * ChangeType enum. - * @name google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType - * @enum {number} - * @property {string} CHANGE_TYPE_UNSPECIFIED=CHANGE_TYPE_UNSPECIFIED CHANGE_TYPE_UNSPECIFIED value - * @property {string} ADD=ADD ADD value - * @property {string} REMOVE=REMOVE REMOVE value - */ - IndexConfigDelta.ChangeType = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "CHANGE_TYPE_UNSPECIFIED"] = "CHANGE_TYPE_UNSPECIFIED"; - values[valuesById[1] = "ADD"] = "ADD"; - values[valuesById[2] = "REMOVE"] = "REMOVE"; - return values; - })(); - - return IndexConfigDelta; - })(); - - return FieldOperationMetadata; - })(); - - v1.ExportDocumentsMetadata = (function() { - - /** - * Properties of an ExportDocumentsMetadata. - * @memberof google.firestore.admin.v1 - * @interface IExportDocumentsMetadata - * @property {google.protobuf.ITimestamp|null} [startTime] ExportDocumentsMetadata startTime - * @property {google.protobuf.ITimestamp|null} [endTime] ExportDocumentsMetadata endTime - * @property {google.firestore.admin.v1.OperationState|null} [operationState] ExportDocumentsMetadata operationState - * @property {google.firestore.admin.v1.IProgress|null} [progressDocuments] ExportDocumentsMetadata progressDocuments - * @property {google.firestore.admin.v1.IProgress|null} [progressBytes] ExportDocumentsMetadata progressBytes - * @property {Array.|null} [collectionIds] ExportDocumentsMetadata collectionIds - * @property {string|null} [outputUriPrefix] ExportDocumentsMetadata outputUriPrefix - */ - - /** - * Constructs a new ExportDocumentsMetadata. - * @memberof google.firestore.admin.v1 - * @classdesc Represents an ExportDocumentsMetadata. - * @implements IExportDocumentsMetadata - * @constructor - * @param {google.firestore.admin.v1.IExportDocumentsMetadata=} [properties] Properties to set - */ - function ExportDocumentsMetadata(properties) { - this.collectionIds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ExportDocumentsMetadata startTime. - * @member {google.protobuf.ITimestamp|null|undefined} startTime - * @memberof google.firestore.admin.v1.ExportDocumentsMetadata - * @instance - */ - ExportDocumentsMetadata.prototype.startTime = null; - - /** - * ExportDocumentsMetadata endTime. - * @member {google.protobuf.ITimestamp|null|undefined} endTime - * @memberof google.firestore.admin.v1.ExportDocumentsMetadata - * @instance - */ - ExportDocumentsMetadata.prototype.endTime = null; - - /** - * ExportDocumentsMetadata operationState. - * @member {google.firestore.admin.v1.OperationState} operationState - * @memberof google.firestore.admin.v1.ExportDocumentsMetadata - * @instance - */ - ExportDocumentsMetadata.prototype.operationState = 0; - - /** - * ExportDocumentsMetadata progressDocuments. - * @member {google.firestore.admin.v1.IProgress|null|undefined} progressDocuments - * @memberof google.firestore.admin.v1.ExportDocumentsMetadata - * @instance - */ - ExportDocumentsMetadata.prototype.progressDocuments = null; - - /** - * ExportDocumentsMetadata progressBytes. - * @member {google.firestore.admin.v1.IProgress|null|undefined} progressBytes - * @memberof google.firestore.admin.v1.ExportDocumentsMetadata - * @instance - */ - ExportDocumentsMetadata.prototype.progressBytes = null; - - /** - * ExportDocumentsMetadata collectionIds. - * @member {Array.} collectionIds - * @memberof google.firestore.admin.v1.ExportDocumentsMetadata - * @instance - */ - ExportDocumentsMetadata.prototype.collectionIds = $util.emptyArray; - - /** - * ExportDocumentsMetadata outputUriPrefix. - * @member {string} outputUriPrefix - * @memberof google.firestore.admin.v1.ExportDocumentsMetadata - * @instance - */ - ExportDocumentsMetadata.prototype.outputUriPrefix = ""; - - return ExportDocumentsMetadata; - })(); - - v1.ImportDocumentsMetadata = (function() { - - /** - * Properties of an ImportDocumentsMetadata. - * @memberof google.firestore.admin.v1 - * @interface IImportDocumentsMetadata - * @property {google.protobuf.ITimestamp|null} [startTime] ImportDocumentsMetadata startTime - * @property {google.protobuf.ITimestamp|null} [endTime] ImportDocumentsMetadata endTime - * @property {google.firestore.admin.v1.OperationState|null} [operationState] ImportDocumentsMetadata operationState - * @property {google.firestore.admin.v1.IProgress|null} [progressDocuments] ImportDocumentsMetadata progressDocuments - * @property {google.firestore.admin.v1.IProgress|null} [progressBytes] ImportDocumentsMetadata progressBytes - * @property {Array.|null} [collectionIds] ImportDocumentsMetadata collectionIds - * @property {string|null} [inputUriPrefix] ImportDocumentsMetadata inputUriPrefix - */ - - /** - * Constructs a new ImportDocumentsMetadata. - * @memberof google.firestore.admin.v1 - * @classdesc Represents an ImportDocumentsMetadata. - * @implements IImportDocumentsMetadata - * @constructor - * @param {google.firestore.admin.v1.IImportDocumentsMetadata=} [properties] Properties to set - */ - function ImportDocumentsMetadata(properties) { - this.collectionIds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ImportDocumentsMetadata startTime. - * @member {google.protobuf.ITimestamp|null|undefined} startTime - * @memberof google.firestore.admin.v1.ImportDocumentsMetadata - * @instance - */ - ImportDocumentsMetadata.prototype.startTime = null; - - /** - * ImportDocumentsMetadata endTime. - * @member {google.protobuf.ITimestamp|null|undefined} endTime - * @memberof google.firestore.admin.v1.ImportDocumentsMetadata - * @instance - */ - ImportDocumentsMetadata.prototype.endTime = null; - - /** - * ImportDocumentsMetadata operationState. - * @member {google.firestore.admin.v1.OperationState} operationState - * @memberof google.firestore.admin.v1.ImportDocumentsMetadata - * @instance - */ - ImportDocumentsMetadata.prototype.operationState = 0; - - /** - * ImportDocumentsMetadata progressDocuments. - * @member {google.firestore.admin.v1.IProgress|null|undefined} progressDocuments - * @memberof google.firestore.admin.v1.ImportDocumentsMetadata - * @instance - */ - ImportDocumentsMetadata.prototype.progressDocuments = null; - - /** - * ImportDocumentsMetadata progressBytes. - * @member {google.firestore.admin.v1.IProgress|null|undefined} progressBytes - * @memberof google.firestore.admin.v1.ImportDocumentsMetadata - * @instance - */ - ImportDocumentsMetadata.prototype.progressBytes = null; - - /** - * ImportDocumentsMetadata collectionIds. - * @member {Array.} collectionIds - * @memberof google.firestore.admin.v1.ImportDocumentsMetadata - * @instance - */ - ImportDocumentsMetadata.prototype.collectionIds = $util.emptyArray; - - /** - * ImportDocumentsMetadata inputUriPrefix. - * @member {string} inputUriPrefix - * @memberof google.firestore.admin.v1.ImportDocumentsMetadata - * @instance - */ - ImportDocumentsMetadata.prototype.inputUriPrefix = ""; - - return ImportDocumentsMetadata; - })(); - - v1.ExportDocumentsResponse = (function() { - - /** - * Properties of an ExportDocumentsResponse. - * @memberof google.firestore.admin.v1 - * @interface IExportDocumentsResponse - * @property {string|null} [outputUriPrefix] ExportDocumentsResponse outputUriPrefix - */ - - /** - * Constructs a new ExportDocumentsResponse. - * @memberof google.firestore.admin.v1 - * @classdesc Represents an ExportDocumentsResponse. - * @implements IExportDocumentsResponse - * @constructor - * @param {google.firestore.admin.v1.IExportDocumentsResponse=} [properties] Properties to set - */ - function ExportDocumentsResponse(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ExportDocumentsResponse outputUriPrefix. - * @member {string} outputUriPrefix - * @memberof google.firestore.admin.v1.ExportDocumentsResponse - * @instance - */ - ExportDocumentsResponse.prototype.outputUriPrefix = ""; - - return ExportDocumentsResponse; - })(); - - v1.Progress = (function() { - - /** - * Properties of a Progress. - * @memberof google.firestore.admin.v1 - * @interface IProgress - * @property {number|null} [estimatedWork] Progress estimatedWork - * @property {number|null} [completedWork] Progress completedWork - */ - - /** - * Constructs a new Progress. - * @memberof google.firestore.admin.v1 - * @classdesc Represents a Progress. - * @implements IProgress - * @constructor - * @param {google.firestore.admin.v1.IProgress=} [properties] Properties to set - */ - function Progress(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Progress estimatedWork. - * @member {number} estimatedWork - * @memberof google.firestore.admin.v1.Progress - * @instance - */ - Progress.prototype.estimatedWork = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Progress completedWork. - * @member {number} completedWork - * @memberof google.firestore.admin.v1.Progress - * @instance - */ - Progress.prototype.completedWork = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - return Progress; - })(); - - /** - * OperationState enum. - * @name google.firestore.admin.v1.OperationState - * @enum {number} - * @property {string} OPERATION_STATE_UNSPECIFIED=OPERATION_STATE_UNSPECIFIED OPERATION_STATE_UNSPECIFIED value - * @property {string} INITIALIZING=INITIALIZING INITIALIZING value - * @property {string} PROCESSING=PROCESSING PROCESSING value - * @property {string} CANCELLING=CANCELLING CANCELLING value - * @property {string} FINALIZING=FINALIZING FINALIZING value - * @property {string} SUCCESSFUL=SUCCESSFUL SUCCESSFUL value - * @property {string} FAILED=FAILED FAILED value - * @property {string} CANCELLED=CANCELLED CANCELLED value - */ - v1.OperationState = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "OPERATION_STATE_UNSPECIFIED"] = "OPERATION_STATE_UNSPECIFIED"; - values[valuesById[1] = "INITIALIZING"] = "INITIALIZING"; - values[valuesById[2] = "PROCESSING"] = "PROCESSING"; - values[valuesById[3] = "CANCELLING"] = "CANCELLING"; - values[valuesById[4] = "FINALIZING"] = "FINALIZING"; - values[valuesById[5] = "SUCCESSFUL"] = "SUCCESSFUL"; - values[valuesById[6] = "FAILED"] = "FAILED"; - values[valuesById[7] = "CANCELLED"] = "CANCELLED"; - return values; - })(); - - return v1; - })(); - - return admin; - })(); - - return firestore; - })(); - - google.api = (function() { - - /** - * Namespace api. - * @memberof google - * @namespace - */ - var api = {}; - - api.Http = (function() { - - /** - * Properties of a Http. - * @memberof google.api - * @interface IHttp - * @property {Array.|null} [rules] Http rules - */ - - /** - * Constructs a new Http. - * @memberof google.api - * @classdesc Represents a Http. - * @implements IHttp - * @constructor - * @param {google.api.IHttp=} [properties] Properties to set - */ - function Http(properties) { - this.rules = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Http rules. - * @member {Array.} rules - * @memberof google.api.Http - * @instance - */ - Http.prototype.rules = $util.emptyArray; - - return Http; - })(); - - api.HttpRule = (function() { - - /** - * Properties of a HttpRule. - * @memberof google.api - * @interface IHttpRule - * @property {string|null} [get] HttpRule get - * @property {string|null} [put] HttpRule put - * @property {string|null} [post] HttpRule post - * @property {string|null} ["delete"] HttpRule delete - * @property {string|null} [patch] HttpRule patch - * @property {google.api.ICustomHttpPattern|null} [custom] HttpRule custom - * @property {string|null} [selector] HttpRule selector - * @property {string|null} [body] HttpRule body - * @property {Array.|null} [additionalBindings] HttpRule additionalBindings - */ - - /** - * Constructs a new HttpRule. - * @memberof google.api - * @classdesc Represents a HttpRule. - * @implements IHttpRule - * @constructor - * @param {google.api.IHttpRule=} [properties] Properties to set - */ - function HttpRule(properties) { - this.additionalBindings = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * HttpRule get. - * @member {string} get - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.get = ""; - - /** - * HttpRule put. - * @member {string} put - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.put = ""; - - /** - * HttpRule post. - * @member {string} post - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.post = ""; - - /** - * HttpRule delete. - * @member {string} delete - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype["delete"] = ""; - - /** - * HttpRule patch. - * @member {string} patch - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.patch = ""; - - /** - * HttpRule custom. - * @member {google.api.ICustomHttpPattern|null|undefined} custom - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.custom = null; - - /** - * HttpRule selector. - * @member {string} selector - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.selector = ""; - - /** - * HttpRule body. - * @member {string} body - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.body = ""; - - /** - * HttpRule additionalBindings. - * @member {Array.} additionalBindings - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.additionalBindings = $util.emptyArray; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * HttpRule pattern. - * @member {"get"|"put"|"post"|"delete"|"patch"|"custom"|undefined} pattern - * @memberof google.api.HttpRule - * @instance - */ - Object.defineProperty(HttpRule.prototype, "pattern", { - get: $util.oneOfGetter($oneOfFields = ["get", "put", "post", "delete", "patch", "custom"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return HttpRule; - })(); - - api.CustomHttpPattern = (function() { - - /** - * Properties of a CustomHttpPattern. - * @memberof google.api - * @interface ICustomHttpPattern - * @property {string|null} [kind] CustomHttpPattern kind - * @property {string|null} [path] CustomHttpPattern path - */ - - /** - * Constructs a new CustomHttpPattern. - * @memberof google.api - * @classdesc Represents a CustomHttpPattern. - * @implements ICustomHttpPattern - * @constructor - * @param {google.api.ICustomHttpPattern=} [properties] Properties to set - */ - function CustomHttpPattern(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * CustomHttpPattern kind. - * @member {string} kind - * @memberof google.api.CustomHttpPattern - * @instance - */ - CustomHttpPattern.prototype.kind = ""; - - /** - * CustomHttpPattern path. - * @member {string} path - * @memberof google.api.CustomHttpPattern - * @instance - */ - CustomHttpPattern.prototype.path = ""; - - return CustomHttpPattern; - })(); - - /** - * FieldBehavior enum. - * @name google.api.FieldBehavior - * @enum {number} - * @property {string} FIELD_BEHAVIOR_UNSPECIFIED=FIELD_BEHAVIOR_UNSPECIFIED FIELD_BEHAVIOR_UNSPECIFIED value - * @property {string} OPTIONAL=OPTIONAL OPTIONAL value - * @property {string} REQUIRED=REQUIRED REQUIRED value - * @property {string} OUTPUT_ONLY=OUTPUT_ONLY OUTPUT_ONLY value - * @property {string} INPUT_ONLY=INPUT_ONLY INPUT_ONLY value - * @property {string} IMMUTABLE=IMMUTABLE IMMUTABLE value - */ - api.FieldBehavior = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "FIELD_BEHAVIOR_UNSPECIFIED"] = "FIELD_BEHAVIOR_UNSPECIFIED"; - values[valuesById[1] = "OPTIONAL"] = "OPTIONAL"; - values[valuesById[2] = "REQUIRED"] = "REQUIRED"; - values[valuesById[3] = "OUTPUT_ONLY"] = "OUTPUT_ONLY"; - values[valuesById[4] = "INPUT_ONLY"] = "INPUT_ONLY"; - values[valuesById[5] = "IMMUTABLE"] = "IMMUTABLE"; - return values; - })(); - - api.ResourceDescriptor = (function() { - - /** - * Properties of a ResourceDescriptor. - * @memberof google.api - * @interface IResourceDescriptor - * @property {string|null} [type] ResourceDescriptor type - * @property {Array.|null} [pattern] ResourceDescriptor pattern - * @property {string|null} [nameField] ResourceDescriptor nameField - * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history - * @property {string|null} [plural] ResourceDescriptor plural - * @property {string|null} [singular] ResourceDescriptor singular - */ - - /** - * Constructs a new ResourceDescriptor. - * @memberof google.api - * @classdesc Represents a ResourceDescriptor. - * @implements IResourceDescriptor - * @constructor - * @param {google.api.IResourceDescriptor=} [properties] Properties to set - */ - function ResourceDescriptor(properties) { - this.pattern = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ResourceDescriptor type. - * @member {string} type - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.type = ""; - - /** - * ResourceDescriptor pattern. - * @member {Array.} pattern - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.pattern = $util.emptyArray; - - /** - * ResourceDescriptor nameField. - * @member {string} nameField - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.nameField = ""; - - /** - * ResourceDescriptor history. - * @member {google.api.ResourceDescriptor.History} history - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.history = 0; - - /** - * ResourceDescriptor plural. - * @member {string} plural - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.plural = ""; - - /** - * ResourceDescriptor singular. - * @member {string} singular - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.singular = ""; - - /** - * History enum. - * @name google.api.ResourceDescriptor.History - * @enum {number} - * @property {string} HISTORY_UNSPECIFIED=HISTORY_UNSPECIFIED HISTORY_UNSPECIFIED value - * @property {string} ORIGINALLY_SINGLE_PATTERN=ORIGINALLY_SINGLE_PATTERN ORIGINALLY_SINGLE_PATTERN value - * @property {string} FUTURE_MULTI_PATTERN=FUTURE_MULTI_PATTERN FUTURE_MULTI_PATTERN value - */ - ResourceDescriptor.History = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "HISTORY_UNSPECIFIED"] = "HISTORY_UNSPECIFIED"; - values[valuesById[1] = "ORIGINALLY_SINGLE_PATTERN"] = "ORIGINALLY_SINGLE_PATTERN"; - values[valuesById[2] = "FUTURE_MULTI_PATTERN"] = "FUTURE_MULTI_PATTERN"; - return values; - })(); - - return ResourceDescriptor; - })(); - - api.ResourceReference = (function() { - - /** - * Properties of a ResourceReference. - * @memberof google.api - * @interface IResourceReference - * @property {string|null} [type] ResourceReference type - * @property {string|null} [childType] ResourceReference childType - */ - - /** - * Constructs a new ResourceReference. - * @memberof google.api - * @classdesc Represents a ResourceReference. - * @implements IResourceReference - * @constructor - * @param {google.api.IResourceReference=} [properties] Properties to set - */ - function ResourceReference(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ResourceReference type. - * @member {string} type - * @memberof google.api.ResourceReference - * @instance - */ - ResourceReference.prototype.type = ""; - - /** - * ResourceReference childType. - * @member {string} childType - * @memberof google.api.ResourceReference - * @instance - */ - ResourceReference.prototype.childType = ""; - - return ResourceReference; - })(); - - return api; - })(); - - google.protobuf = (function() { - - /** - * Namespace protobuf. - * @memberof google - * @namespace - */ - var protobuf = {}; - - protobuf.FileDescriptorSet = (function() { - - /** - * Properties of a FileDescriptorSet. - * @memberof google.protobuf - * @interface IFileDescriptorSet - * @property {Array.|null} [file] FileDescriptorSet file - */ - - /** - * Constructs a new FileDescriptorSet. - * @memberof google.protobuf - * @classdesc Represents a FileDescriptorSet. - * @implements IFileDescriptorSet - * @constructor - * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set - */ - function FileDescriptorSet(properties) { - this.file = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FileDescriptorSet file. - * @member {Array.} file - * @memberof google.protobuf.FileDescriptorSet - * @instance - */ - FileDescriptorSet.prototype.file = $util.emptyArray; - - return FileDescriptorSet; - })(); - - protobuf.FileDescriptorProto = (function() { - - /** - * Properties of a FileDescriptorProto. - * @memberof google.protobuf - * @interface IFileDescriptorProto - * @property {string|null} [name] FileDescriptorProto name - * @property {string|null} ["package"] FileDescriptorProto package - * @property {Array.|null} [dependency] FileDescriptorProto dependency - * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency - * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency - * @property {Array.|null} [messageType] FileDescriptorProto messageType - * @property {Array.|null} [enumType] FileDescriptorProto enumType - * @property {Array.|null} [service] FileDescriptorProto service - * @property {Array.|null} [extension] FileDescriptorProto extension - * @property {google.protobuf.IFileOptions|null} [options] FileDescriptorProto options - * @property {google.protobuf.ISourceCodeInfo|null} [sourceCodeInfo] FileDescriptorProto sourceCodeInfo - * @property {string|null} [syntax] FileDescriptorProto syntax - */ - - /** - * Constructs a new FileDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents a FileDescriptorProto. - * @implements IFileDescriptorProto - * @constructor - * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set - */ - function FileDescriptorProto(properties) { - this.dependency = []; - this.publicDependency = []; - this.weakDependency = []; - this.messageType = []; - this.enumType = []; - this.service = []; - this.extension = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FileDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.name = ""; - - /** - * FileDescriptorProto package. - * @member {string} package - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype["package"] = ""; - - /** - * FileDescriptorProto dependency. - * @member {Array.} dependency - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.dependency = $util.emptyArray; - - /** - * FileDescriptorProto publicDependency. - * @member {Array.} publicDependency - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.publicDependency = $util.emptyArray; - - /** - * FileDescriptorProto weakDependency. - * @member {Array.} weakDependency - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.weakDependency = $util.emptyArray; - - /** - * FileDescriptorProto messageType. - * @member {Array.} messageType - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.messageType = $util.emptyArray; - - /** - * FileDescriptorProto enumType. - * @member {Array.} enumType - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.enumType = $util.emptyArray; - - /** - * FileDescriptorProto service. - * @member {Array.} service - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.service = $util.emptyArray; - - /** - * FileDescriptorProto extension. - * @member {Array.} extension - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.extension = $util.emptyArray; - - /** - * FileDescriptorProto options. - * @member {google.protobuf.IFileOptions|null|undefined} options - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.options = null; - - /** - * FileDescriptorProto sourceCodeInfo. - * @member {google.protobuf.ISourceCodeInfo|null|undefined} sourceCodeInfo - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.sourceCodeInfo = null; - - /** - * FileDescriptorProto syntax. - * @member {string} syntax - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.syntax = ""; - - return FileDescriptorProto; - })(); - - protobuf.DescriptorProto = (function() { - - /** - * Properties of a DescriptorProto. - * @memberof google.protobuf - * @interface IDescriptorProto - * @property {string|null} [name] DescriptorProto name - * @property {Array.|null} [field] DescriptorProto field - * @property {Array.|null} [extension] DescriptorProto extension - * @property {Array.|null} [nestedType] DescriptorProto nestedType - * @property {Array.|null} [enumType] DescriptorProto enumType - * @property {Array.|null} [extensionRange] DescriptorProto extensionRange - * @property {Array.|null} [oneofDecl] DescriptorProto oneofDecl - * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options - * @property {Array.|null} [reservedRange] DescriptorProto reservedRange - * @property {Array.|null} [reservedName] DescriptorProto reservedName - */ - - /** - * Constructs a new DescriptorProto. - * @memberof google.protobuf - * @classdesc Represents a DescriptorProto. - * @implements IDescriptorProto - * @constructor - * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set - */ - function DescriptorProto(properties) { - this.field = []; - this.extension = []; - this.nestedType = []; - this.enumType = []; - this.extensionRange = []; - this.oneofDecl = []; - this.reservedRange = []; - this.reservedName = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DescriptorProto name. - * @member {string} name - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.name = ""; - - /** - * DescriptorProto field. - * @member {Array.} field - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.field = $util.emptyArray; - - /** - * DescriptorProto extension. - * @member {Array.} extension - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.extension = $util.emptyArray; - - /** - * DescriptorProto nestedType. - * @member {Array.} nestedType - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.nestedType = $util.emptyArray; - - /** - * DescriptorProto enumType. - * @member {Array.} enumType - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.enumType = $util.emptyArray; - - /** - * DescriptorProto extensionRange. - * @member {Array.} extensionRange - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.extensionRange = $util.emptyArray; - - /** - * DescriptorProto oneofDecl. - * @member {Array.} oneofDecl - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.oneofDecl = $util.emptyArray; - - /** - * DescriptorProto options. - * @member {google.protobuf.IMessageOptions|null|undefined} options - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.options = null; - - /** - * DescriptorProto reservedRange. - * @member {Array.} reservedRange - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.reservedRange = $util.emptyArray; - - /** - * DescriptorProto reservedName. - * @member {Array.} reservedName - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.reservedName = $util.emptyArray; - - DescriptorProto.ExtensionRange = (function() { - - /** - * Properties of an ExtensionRange. - * @memberof google.protobuf.DescriptorProto - * @interface IExtensionRange - * @property {number|null} [start] ExtensionRange start - * @property {number|null} [end] ExtensionRange end - */ - - /** - * Constructs a new ExtensionRange. - * @memberof google.protobuf.DescriptorProto - * @classdesc Represents an ExtensionRange. - * @implements IExtensionRange - * @constructor - * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set - */ - function ExtensionRange(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ExtensionRange start. - * @member {number} start - * @memberof google.protobuf.DescriptorProto.ExtensionRange - * @instance - */ - ExtensionRange.prototype.start = 0; - - /** - * ExtensionRange end. - * @member {number} end - * @memberof google.protobuf.DescriptorProto.ExtensionRange - * @instance - */ - ExtensionRange.prototype.end = 0; - - return ExtensionRange; - })(); - - DescriptorProto.ReservedRange = (function() { - - /** - * Properties of a ReservedRange. - * @memberof google.protobuf.DescriptorProto - * @interface IReservedRange - * @property {number|null} [start] ReservedRange start - * @property {number|null} [end] ReservedRange end - */ - - /** - * Constructs a new ReservedRange. - * @memberof google.protobuf.DescriptorProto - * @classdesc Represents a ReservedRange. - * @implements IReservedRange - * @constructor - * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set - */ - function ReservedRange(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ReservedRange start. - * @member {number} start - * @memberof google.protobuf.DescriptorProto.ReservedRange - * @instance - */ - ReservedRange.prototype.start = 0; - - /** - * ReservedRange end. - * @member {number} end - * @memberof google.protobuf.DescriptorProto.ReservedRange - * @instance - */ - ReservedRange.prototype.end = 0; - - return ReservedRange; - })(); - - return DescriptorProto; - })(); - - protobuf.FieldDescriptorProto = (function() { - - /** - * Properties of a FieldDescriptorProto. - * @memberof google.protobuf - * @interface IFieldDescriptorProto - * @property {string|null} [name] FieldDescriptorProto name - * @property {number|null} [number] FieldDescriptorProto number - * @property {google.protobuf.FieldDescriptorProto.Label|null} [label] FieldDescriptorProto label - * @property {google.protobuf.FieldDescriptorProto.Type|null} [type] FieldDescriptorProto type - * @property {string|null} [typeName] FieldDescriptorProto typeName - * @property {string|null} [extendee] FieldDescriptorProto extendee - * @property {string|null} [defaultValue] FieldDescriptorProto defaultValue - * @property {number|null} [oneofIndex] FieldDescriptorProto oneofIndex - * @property {string|null} [jsonName] FieldDescriptorProto jsonName - * @property {google.protobuf.IFieldOptions|null} [options] FieldDescriptorProto options - */ - - /** - * Constructs a new FieldDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents a FieldDescriptorProto. - * @implements IFieldDescriptorProto - * @constructor - * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set - */ - function FieldDescriptorProto(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FieldDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.name = ""; - - /** - * FieldDescriptorProto number. - * @member {number} number - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.number = 0; - - /** - * FieldDescriptorProto label. - * @member {google.protobuf.FieldDescriptorProto.Label} label - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.label = 1; - - /** - * FieldDescriptorProto type. - * @member {google.protobuf.FieldDescriptorProto.Type} type - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.type = 1; - - /** - * FieldDescriptorProto typeName. - * @member {string} typeName - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.typeName = ""; - - /** - * FieldDescriptorProto extendee. - * @member {string} extendee - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.extendee = ""; - - /** - * FieldDescriptorProto defaultValue. - * @member {string} defaultValue - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.defaultValue = ""; - - /** - * FieldDescriptorProto oneofIndex. - * @member {number} oneofIndex - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.oneofIndex = 0; - - /** - * FieldDescriptorProto jsonName. - * @member {string} jsonName - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.jsonName = ""; - - /** - * FieldDescriptorProto options. - * @member {google.protobuf.IFieldOptions|null|undefined} options - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.options = null; - - /** - * Type enum. - * @name google.protobuf.FieldDescriptorProto.Type - * @enum {number} - * @property {string} TYPE_DOUBLE=TYPE_DOUBLE TYPE_DOUBLE value - * @property {string} TYPE_FLOAT=TYPE_FLOAT TYPE_FLOAT value - * @property {string} TYPE_INT64=TYPE_INT64 TYPE_INT64 value - * @property {string} TYPE_UINT64=TYPE_UINT64 TYPE_UINT64 value - * @property {string} TYPE_INT32=TYPE_INT32 TYPE_INT32 value - * @property {string} TYPE_FIXED64=TYPE_FIXED64 TYPE_FIXED64 value - * @property {string} TYPE_FIXED32=TYPE_FIXED32 TYPE_FIXED32 value - * @property {string} TYPE_BOOL=TYPE_BOOL TYPE_BOOL value - * @property {string} TYPE_STRING=TYPE_STRING TYPE_STRING value - * @property {string} TYPE_GROUP=TYPE_GROUP TYPE_GROUP value - * @property {string} TYPE_MESSAGE=TYPE_MESSAGE TYPE_MESSAGE value - * @property {string} TYPE_BYTES=TYPE_BYTES TYPE_BYTES value - * @property {string} TYPE_UINT32=TYPE_UINT32 TYPE_UINT32 value - * @property {string} TYPE_ENUM=TYPE_ENUM TYPE_ENUM value - * @property {string} TYPE_SFIXED32=TYPE_SFIXED32 TYPE_SFIXED32 value - * @property {string} TYPE_SFIXED64=TYPE_SFIXED64 TYPE_SFIXED64 value - * @property {string} TYPE_SINT32=TYPE_SINT32 TYPE_SINT32 value - * @property {string} TYPE_SINT64=TYPE_SINT64 TYPE_SINT64 value - */ - FieldDescriptorProto.Type = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[1] = "TYPE_DOUBLE"] = "TYPE_DOUBLE"; - values[valuesById[2] = "TYPE_FLOAT"] = "TYPE_FLOAT"; - values[valuesById[3] = "TYPE_INT64"] = "TYPE_INT64"; - values[valuesById[4] = "TYPE_UINT64"] = "TYPE_UINT64"; - values[valuesById[5] = "TYPE_INT32"] = "TYPE_INT32"; - values[valuesById[6] = "TYPE_FIXED64"] = "TYPE_FIXED64"; - values[valuesById[7] = "TYPE_FIXED32"] = "TYPE_FIXED32"; - values[valuesById[8] = "TYPE_BOOL"] = "TYPE_BOOL"; - values[valuesById[9] = "TYPE_STRING"] = "TYPE_STRING"; - values[valuesById[10] = "TYPE_GROUP"] = "TYPE_GROUP"; - values[valuesById[11] = "TYPE_MESSAGE"] = "TYPE_MESSAGE"; - values[valuesById[12] = "TYPE_BYTES"] = "TYPE_BYTES"; - values[valuesById[13] = "TYPE_UINT32"] = "TYPE_UINT32"; - values[valuesById[14] = "TYPE_ENUM"] = "TYPE_ENUM"; - values[valuesById[15] = "TYPE_SFIXED32"] = "TYPE_SFIXED32"; - values[valuesById[16] = "TYPE_SFIXED64"] = "TYPE_SFIXED64"; - values[valuesById[17] = "TYPE_SINT32"] = "TYPE_SINT32"; - values[valuesById[18] = "TYPE_SINT64"] = "TYPE_SINT64"; - return values; - })(); - - /** - * Label enum. - * @name google.protobuf.FieldDescriptorProto.Label - * @enum {number} - * @property {string} LABEL_OPTIONAL=LABEL_OPTIONAL LABEL_OPTIONAL value - * @property {string} LABEL_REQUIRED=LABEL_REQUIRED LABEL_REQUIRED value - * @property {string} LABEL_REPEATED=LABEL_REPEATED LABEL_REPEATED value - */ - FieldDescriptorProto.Label = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[1] = "LABEL_OPTIONAL"] = "LABEL_OPTIONAL"; - values[valuesById[2] = "LABEL_REQUIRED"] = "LABEL_REQUIRED"; - values[valuesById[3] = "LABEL_REPEATED"] = "LABEL_REPEATED"; - return values; - })(); - - return FieldDescriptorProto; - })(); - - protobuf.OneofDescriptorProto = (function() { - - /** - * Properties of an OneofDescriptorProto. - * @memberof google.protobuf - * @interface IOneofDescriptorProto - * @property {string|null} [name] OneofDescriptorProto name - * @property {google.protobuf.IOneofOptions|null} [options] OneofDescriptorProto options - */ - - /** - * Constructs a new OneofDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents an OneofDescriptorProto. - * @implements IOneofDescriptorProto - * @constructor - * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set - */ - function OneofDescriptorProto(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * OneofDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.OneofDescriptorProto - * @instance - */ - OneofDescriptorProto.prototype.name = ""; - - /** - * OneofDescriptorProto options. - * @member {google.protobuf.IOneofOptions|null|undefined} options - * @memberof google.protobuf.OneofDescriptorProto - * @instance - */ - OneofDescriptorProto.prototype.options = null; - - return OneofDescriptorProto; - })(); - - protobuf.EnumDescriptorProto = (function() { - - /** - * Properties of an EnumDescriptorProto. - * @memberof google.protobuf - * @interface IEnumDescriptorProto - * @property {string|null} [name] EnumDescriptorProto name - * @property {Array.|null} [value] EnumDescriptorProto value - * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options - */ - - /** - * Constructs a new EnumDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents an EnumDescriptorProto. - * @implements IEnumDescriptorProto - * @constructor - * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set - */ - function EnumDescriptorProto(properties) { - this.value = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EnumDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.EnumDescriptorProto - * @instance - */ - EnumDescriptorProto.prototype.name = ""; - - /** - * EnumDescriptorProto value. - * @member {Array.} value - * @memberof google.protobuf.EnumDescriptorProto - * @instance - */ - EnumDescriptorProto.prototype.value = $util.emptyArray; - - /** - * EnumDescriptorProto options. - * @member {google.protobuf.IEnumOptions|null|undefined} options - * @memberof google.protobuf.EnumDescriptorProto - * @instance - */ - EnumDescriptorProto.prototype.options = null; - - return EnumDescriptorProto; - })(); - - protobuf.EnumValueDescriptorProto = (function() { - - /** - * Properties of an EnumValueDescriptorProto. - * @memberof google.protobuf - * @interface IEnumValueDescriptorProto - * @property {string|null} [name] EnumValueDescriptorProto name - * @property {number|null} [number] EnumValueDescriptorProto number - * @property {google.protobuf.IEnumValueOptions|null} [options] EnumValueDescriptorProto options - */ - - /** - * Constructs a new EnumValueDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents an EnumValueDescriptorProto. - * @implements IEnumValueDescriptorProto - * @constructor - * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set - */ - function EnumValueDescriptorProto(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EnumValueDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.EnumValueDescriptorProto - * @instance - */ - EnumValueDescriptorProto.prototype.name = ""; - - /** - * EnumValueDescriptorProto number. - * @member {number} number - * @memberof google.protobuf.EnumValueDescriptorProto - * @instance - */ - EnumValueDescriptorProto.prototype.number = 0; - - /** - * EnumValueDescriptorProto options. - * @member {google.protobuf.IEnumValueOptions|null|undefined} options - * @memberof google.protobuf.EnumValueDescriptorProto - * @instance - */ - EnumValueDescriptorProto.prototype.options = null; - - return EnumValueDescriptorProto; - })(); - - protobuf.ServiceDescriptorProto = (function() { - - /** - * Properties of a ServiceDescriptorProto. - * @memberof google.protobuf - * @interface IServiceDescriptorProto - * @property {string|null} [name] ServiceDescriptorProto name - * @property {Array.|null} [method] ServiceDescriptorProto method - * @property {google.protobuf.IServiceOptions|null} [options] ServiceDescriptorProto options - */ - - /** - * Constructs a new ServiceDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents a ServiceDescriptorProto. - * @implements IServiceDescriptorProto - * @constructor - * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set - */ - function ServiceDescriptorProto(properties) { - this.method = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ServiceDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.ServiceDescriptorProto - * @instance - */ - ServiceDescriptorProto.prototype.name = ""; - - /** - * ServiceDescriptorProto method. - * @member {Array.} method - * @memberof google.protobuf.ServiceDescriptorProto - * @instance - */ - ServiceDescriptorProto.prototype.method = $util.emptyArray; - - /** - * ServiceDescriptorProto options. - * @member {google.protobuf.IServiceOptions|null|undefined} options - * @memberof google.protobuf.ServiceDescriptorProto - * @instance - */ - ServiceDescriptorProto.prototype.options = null; - - return ServiceDescriptorProto; - })(); - - protobuf.MethodDescriptorProto = (function() { - - /** - * Properties of a MethodDescriptorProto. - * @memberof google.protobuf - * @interface IMethodDescriptorProto - * @property {string|null} [name] MethodDescriptorProto name - * @property {string|null} [inputType] MethodDescriptorProto inputType - * @property {string|null} [outputType] MethodDescriptorProto outputType - * @property {google.protobuf.IMethodOptions|null} [options] MethodDescriptorProto options - * @property {boolean|null} [clientStreaming] MethodDescriptorProto clientStreaming - * @property {boolean|null} [serverStreaming] MethodDescriptorProto serverStreaming - */ - - /** - * Constructs a new MethodDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents a MethodDescriptorProto. - * @implements IMethodDescriptorProto - * @constructor - * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set - */ - function MethodDescriptorProto(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * MethodDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.name = ""; - - /** - * MethodDescriptorProto inputType. - * @member {string} inputType - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.inputType = ""; - - /** - * MethodDescriptorProto outputType. - * @member {string} outputType - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.outputType = ""; - - /** - * MethodDescriptorProto options. - * @member {google.protobuf.IMethodOptions|null|undefined} options - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.options = null; - - /** - * MethodDescriptorProto clientStreaming. - * @member {boolean} clientStreaming - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.clientStreaming = false; - - /** - * MethodDescriptorProto serverStreaming. - * @member {boolean} serverStreaming - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.serverStreaming = false; - - return MethodDescriptorProto; - })(); - - protobuf.FileOptions = (function() { - - /** - * Properties of a FileOptions. - * @memberof google.protobuf - * @interface IFileOptions - * @property {string|null} [javaPackage] FileOptions javaPackage - * @property {string|null} [javaOuterClassname] FileOptions javaOuterClassname - * @property {boolean|null} [javaMultipleFiles] FileOptions javaMultipleFiles - * @property {boolean|null} [javaGenerateEqualsAndHash] FileOptions javaGenerateEqualsAndHash - * @property {boolean|null} [javaStringCheckUtf8] FileOptions javaStringCheckUtf8 - * @property {google.protobuf.FileOptions.OptimizeMode|null} [optimizeFor] FileOptions optimizeFor - * @property {string|null} [goPackage] FileOptions goPackage - * @property {boolean|null} [ccGenericServices] FileOptions ccGenericServices - * @property {boolean|null} [javaGenericServices] FileOptions javaGenericServices - * @property {boolean|null} [pyGenericServices] FileOptions pyGenericServices - * @property {boolean|null} [deprecated] FileOptions deprecated - * @property {boolean|null} [ccEnableArenas] FileOptions ccEnableArenas - * @property {string|null} [objcClassPrefix] FileOptions objcClassPrefix - * @property {string|null} [csharpNamespace] FileOptions csharpNamespace - * @property {Array.|null} [uninterpretedOption] FileOptions uninterpretedOption - * @property {Array.|null} [".google.api.resourceDefinition"] FileOptions .google.api.resourceDefinition - */ - - /** - * Constructs a new FileOptions. - * @memberof google.protobuf - * @classdesc Represents a FileOptions. - * @implements IFileOptions - * @constructor - * @param {google.protobuf.IFileOptions=} [properties] Properties to set - */ - function FileOptions(properties) { - this.uninterpretedOption = []; - this[".google.api.resourceDefinition"] = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FileOptions javaPackage. - * @member {string} javaPackage - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaPackage = ""; - - /** - * FileOptions javaOuterClassname. - * @member {string} javaOuterClassname - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaOuterClassname = ""; - - /** - * FileOptions javaMultipleFiles. - * @member {boolean} javaMultipleFiles - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaMultipleFiles = false; - - /** - * FileOptions javaGenerateEqualsAndHash. - * @member {boolean} javaGenerateEqualsAndHash - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaGenerateEqualsAndHash = false; - - /** - * FileOptions javaStringCheckUtf8. - * @member {boolean} javaStringCheckUtf8 - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaStringCheckUtf8 = false; - - /** - * FileOptions optimizeFor. - * @member {google.protobuf.FileOptions.OptimizeMode} optimizeFor - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.optimizeFor = 1; - - /** - * FileOptions goPackage. - * @member {string} goPackage - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.goPackage = ""; - - /** - * FileOptions ccGenericServices. - * @member {boolean} ccGenericServices - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.ccGenericServices = false; - - /** - * FileOptions javaGenericServices. - * @member {boolean} javaGenericServices - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaGenericServices = false; - - /** - * FileOptions pyGenericServices. - * @member {boolean} pyGenericServices - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.pyGenericServices = false; - - /** - * FileOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.deprecated = false; - - /** - * FileOptions ccEnableArenas. - * @member {boolean} ccEnableArenas - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.ccEnableArenas = false; - - /** - * FileOptions objcClassPrefix. - * @member {string} objcClassPrefix - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.objcClassPrefix = ""; - - /** - * FileOptions csharpNamespace. - * @member {string} csharpNamespace - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.csharpNamespace = ""; - - /** - * FileOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.uninterpretedOption = $util.emptyArray; - - /** - * FileOptions .google.api.resourceDefinition. - * @member {Array.} .google.api.resourceDefinition - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype[".google.api.resourceDefinition"] = $util.emptyArray; - - /** - * OptimizeMode enum. - * @name google.protobuf.FileOptions.OptimizeMode - * @enum {number} - * @property {string} SPEED=SPEED SPEED value - * @property {string} CODE_SIZE=CODE_SIZE CODE_SIZE value - * @property {string} LITE_RUNTIME=LITE_RUNTIME LITE_RUNTIME value - */ - FileOptions.OptimizeMode = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[1] = "SPEED"] = "SPEED"; - values[valuesById[2] = "CODE_SIZE"] = "CODE_SIZE"; - values[valuesById[3] = "LITE_RUNTIME"] = "LITE_RUNTIME"; - return values; - })(); - - return FileOptions; - })(); - - protobuf.MessageOptions = (function() { - - /** - * Properties of a MessageOptions. - * @memberof google.protobuf - * @interface IMessageOptions - * @property {boolean|null} [messageSetWireFormat] MessageOptions messageSetWireFormat - * @property {boolean|null} [noStandardDescriptorAccessor] MessageOptions noStandardDescriptorAccessor - * @property {boolean|null} [deprecated] MessageOptions deprecated - * @property {boolean|null} [mapEntry] MessageOptions mapEntry - * @property {Array.|null} [uninterpretedOption] MessageOptions uninterpretedOption - * @property {google.api.IResourceDescriptor|null} [".google.api.resource"] MessageOptions .google.api.resource - */ - - /** - * Constructs a new MessageOptions. - * @memberof google.protobuf - * @classdesc Represents a MessageOptions. - * @implements IMessageOptions - * @constructor - * @param {google.protobuf.IMessageOptions=} [properties] Properties to set - */ - function MessageOptions(properties) { - this.uninterpretedOption = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * MessageOptions messageSetWireFormat. - * @member {boolean} messageSetWireFormat - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype.messageSetWireFormat = false; - - /** - * MessageOptions noStandardDescriptorAccessor. - * @member {boolean} noStandardDescriptorAccessor - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype.noStandardDescriptorAccessor = false; - - /** - * MessageOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype.deprecated = false; - - /** - * MessageOptions mapEntry. - * @member {boolean} mapEntry - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype.mapEntry = false; - - /** - * MessageOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype.uninterpretedOption = $util.emptyArray; - - /** - * MessageOptions .google.api.resource. - * @member {google.api.IResourceDescriptor|null|undefined} .google.api.resource - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype[".google.api.resource"] = null; - - return MessageOptions; - })(); - - protobuf.FieldOptions = (function() { - - /** - * Properties of a FieldOptions. - * @memberof google.protobuf - * @interface IFieldOptions - * @property {google.protobuf.FieldOptions.CType|null} [ctype] FieldOptions ctype - * @property {boolean|null} [packed] FieldOptions packed - * @property {google.protobuf.FieldOptions.JSType|null} [jstype] FieldOptions jstype - * @property {boolean|null} [lazy] FieldOptions lazy - * @property {boolean|null} [deprecated] FieldOptions deprecated - * @property {boolean|null} [weak] FieldOptions weak - * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption - * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior - * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference - */ - - /** - * Constructs a new FieldOptions. - * @memberof google.protobuf - * @classdesc Represents a FieldOptions. - * @implements IFieldOptions - * @constructor - * @param {google.protobuf.IFieldOptions=} [properties] Properties to set - */ - function FieldOptions(properties) { - this.uninterpretedOption = []; - this[".google.api.fieldBehavior"] = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FieldOptions ctype. - * @member {google.protobuf.FieldOptions.CType} ctype - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.ctype = 0; - - /** - * FieldOptions packed. - * @member {boolean} packed - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.packed = false; - - /** - * FieldOptions jstype. - * @member {google.protobuf.FieldOptions.JSType} jstype - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.jstype = 0; - - /** - * FieldOptions lazy. - * @member {boolean} lazy - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.lazy = false; - - /** - * FieldOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.deprecated = false; - - /** - * FieldOptions weak. - * @member {boolean} weak - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.weak = false; - - /** - * FieldOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.uninterpretedOption = $util.emptyArray; - - /** - * FieldOptions .google.api.fieldBehavior. - * @member {Array.} .google.api.fieldBehavior - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype[".google.api.fieldBehavior"] = $util.emptyArray; - - /** - * FieldOptions .google.api.resourceReference. - * @member {google.api.IResourceReference|null|undefined} .google.api.resourceReference - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype[".google.api.resourceReference"] = null; - - /** - * CType enum. - * @name google.protobuf.FieldOptions.CType - * @enum {number} - * @property {string} STRING=STRING STRING value - * @property {string} CORD=CORD CORD value - * @property {string} STRING_PIECE=STRING_PIECE STRING_PIECE value - */ - FieldOptions.CType = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "STRING"] = "STRING"; - values[valuesById[1] = "CORD"] = "CORD"; - values[valuesById[2] = "STRING_PIECE"] = "STRING_PIECE"; - return values; - })(); - - /** - * JSType enum. - * @name google.protobuf.FieldOptions.JSType - * @enum {number} - * @property {string} JS_NORMAL=JS_NORMAL JS_NORMAL value - * @property {string} JS_STRING=JS_STRING JS_STRING value - * @property {string} JS_NUMBER=JS_NUMBER JS_NUMBER value - */ - FieldOptions.JSType = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "JS_NORMAL"] = "JS_NORMAL"; - values[valuesById[1] = "JS_STRING"] = "JS_STRING"; - values[valuesById[2] = "JS_NUMBER"] = "JS_NUMBER"; - return values; - })(); - - return FieldOptions; - })(); - - protobuf.OneofOptions = (function() { - - /** - * Properties of an OneofOptions. - * @memberof google.protobuf - * @interface IOneofOptions - * @property {Array.|null} [uninterpretedOption] OneofOptions uninterpretedOption - */ - - /** - * Constructs a new OneofOptions. - * @memberof google.protobuf - * @classdesc Represents an OneofOptions. - * @implements IOneofOptions - * @constructor - * @param {google.protobuf.IOneofOptions=} [properties] Properties to set - */ - function OneofOptions(properties) { - this.uninterpretedOption = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * OneofOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.OneofOptions - * @instance - */ - OneofOptions.prototype.uninterpretedOption = $util.emptyArray; - - return OneofOptions; - })(); - - protobuf.EnumOptions = (function() { - - /** - * Properties of an EnumOptions. - * @memberof google.protobuf - * @interface IEnumOptions - * @property {boolean|null} [allowAlias] EnumOptions allowAlias - * @property {boolean|null} [deprecated] EnumOptions deprecated - * @property {Array.|null} [uninterpretedOption] EnumOptions uninterpretedOption - */ - - /** - * Constructs a new EnumOptions. - * @memberof google.protobuf - * @classdesc Represents an EnumOptions. - * @implements IEnumOptions - * @constructor - * @param {google.protobuf.IEnumOptions=} [properties] Properties to set - */ - function EnumOptions(properties) { - this.uninterpretedOption = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EnumOptions allowAlias. - * @member {boolean} allowAlias - * @memberof google.protobuf.EnumOptions - * @instance - */ - EnumOptions.prototype.allowAlias = false; - - /** - * EnumOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.EnumOptions - * @instance - */ - EnumOptions.prototype.deprecated = false; - - /** - * EnumOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.EnumOptions - * @instance - */ - EnumOptions.prototype.uninterpretedOption = $util.emptyArray; - - return EnumOptions; - })(); - - protobuf.EnumValueOptions = (function() { - - /** - * Properties of an EnumValueOptions. - * @memberof google.protobuf - * @interface IEnumValueOptions - * @property {boolean|null} [deprecated] EnumValueOptions deprecated - * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption - */ - - /** - * Constructs a new EnumValueOptions. - * @memberof google.protobuf - * @classdesc Represents an EnumValueOptions. - * @implements IEnumValueOptions - * @constructor - * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set - */ - function EnumValueOptions(properties) { - this.uninterpretedOption = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EnumValueOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.EnumValueOptions - * @instance - */ - EnumValueOptions.prototype.deprecated = false; - - /** - * EnumValueOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.EnumValueOptions - * @instance - */ - EnumValueOptions.prototype.uninterpretedOption = $util.emptyArray; - - return EnumValueOptions; - })(); - - protobuf.ServiceOptions = (function() { - - /** - * Properties of a ServiceOptions. - * @memberof google.protobuf - * @interface IServiceOptions - * @property {boolean|null} [deprecated] ServiceOptions deprecated - * @property {Array.|null} [uninterpretedOption] ServiceOptions uninterpretedOption - * @property {string|null} [".google.api.defaultHost"] ServiceOptions .google.api.defaultHost - * @property {string|null} [".google.api.oauthScopes"] ServiceOptions .google.api.oauthScopes - */ - - /** - * Constructs a new ServiceOptions. - * @memberof google.protobuf - * @classdesc Represents a ServiceOptions. - * @implements IServiceOptions - * @constructor - * @param {google.protobuf.IServiceOptions=} [properties] Properties to set - */ - function ServiceOptions(properties) { - this.uninterpretedOption = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ServiceOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.ServiceOptions - * @instance - */ - ServiceOptions.prototype.deprecated = false; - - /** - * ServiceOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.ServiceOptions - * @instance - */ - ServiceOptions.prototype.uninterpretedOption = $util.emptyArray; - - /** - * ServiceOptions .google.api.defaultHost. - * @member {string} .google.api.defaultHost - * @memberof google.protobuf.ServiceOptions - * @instance - */ - ServiceOptions.prototype[".google.api.defaultHost"] = ""; - - /** - * ServiceOptions .google.api.oauthScopes. - * @member {string} .google.api.oauthScopes - * @memberof google.protobuf.ServiceOptions - * @instance - */ - ServiceOptions.prototype[".google.api.oauthScopes"] = ""; - - return ServiceOptions; - })(); - - protobuf.MethodOptions = (function() { - - /** - * Properties of a MethodOptions. - * @memberof google.protobuf - * @interface IMethodOptions - * @property {boolean|null} [deprecated] MethodOptions deprecated - * @property {Array.|null} [uninterpretedOption] MethodOptions uninterpretedOption - * @property {google.api.IHttpRule|null} [".google.api.http"] MethodOptions .google.api.http - * @property {Array.|null} [".google.api.methodSignature"] MethodOptions .google.api.methodSignature - * @property {google.longrunning.IOperationInfo|null} [".google.longrunning.operationInfo"] MethodOptions .google.longrunning.operationInfo - */ - - /** - * Constructs a new MethodOptions. - * @memberof google.protobuf - * @classdesc Represents a MethodOptions. - * @implements IMethodOptions - * @constructor - * @param {google.protobuf.IMethodOptions=} [properties] Properties to set - */ - function MethodOptions(properties) { - this.uninterpretedOption = []; - this[".google.api.methodSignature"] = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * MethodOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.MethodOptions - * @instance - */ - MethodOptions.prototype.deprecated = false; - - /** - * MethodOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.MethodOptions - * @instance - */ - MethodOptions.prototype.uninterpretedOption = $util.emptyArray; - - /** - * MethodOptions .google.api.http. - * @member {google.api.IHttpRule|null|undefined} .google.api.http - * @memberof google.protobuf.MethodOptions - * @instance - */ - MethodOptions.prototype[".google.api.http"] = null; - - /** - * MethodOptions .google.api.methodSignature. - * @member {Array.} .google.api.methodSignature - * @memberof google.protobuf.MethodOptions - * @instance - */ - MethodOptions.prototype[".google.api.methodSignature"] = $util.emptyArray; - - /** - * MethodOptions .google.longrunning.operationInfo. - * @member {google.longrunning.IOperationInfo|null|undefined} .google.longrunning.operationInfo - * @memberof google.protobuf.MethodOptions - * @instance - */ - MethodOptions.prototype[".google.longrunning.operationInfo"] = null; - - return MethodOptions; - })(); - - protobuf.UninterpretedOption = (function() { - - /** - * Properties of an UninterpretedOption. - * @memberof google.protobuf - * @interface IUninterpretedOption - * @property {Array.|null} [name] UninterpretedOption name - * @property {string|null} [identifierValue] UninterpretedOption identifierValue - * @property {number|null} [positiveIntValue] UninterpretedOption positiveIntValue - * @property {number|null} [negativeIntValue] UninterpretedOption negativeIntValue - * @property {number|null} [doubleValue] UninterpretedOption doubleValue - * @property {Uint8Array|null} [stringValue] UninterpretedOption stringValue - * @property {string|null} [aggregateValue] UninterpretedOption aggregateValue - */ - - /** - * Constructs a new UninterpretedOption. - * @memberof google.protobuf - * @classdesc Represents an UninterpretedOption. - * @implements IUninterpretedOption - * @constructor - * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set - */ - function UninterpretedOption(properties) { - this.name = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * UninterpretedOption name. - * @member {Array.} name - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.name = $util.emptyArray; - - /** - * UninterpretedOption identifierValue. - * @member {string} identifierValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.identifierValue = ""; - - /** - * UninterpretedOption positiveIntValue. - * @member {number} positiveIntValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.positiveIntValue = $util.Long ? $util.Long.fromBits(0,0,true) : 0; - - /** - * UninterpretedOption negativeIntValue. - * @member {number} negativeIntValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.negativeIntValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * UninterpretedOption doubleValue. - * @member {number} doubleValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.doubleValue = 0; - - /** - * UninterpretedOption stringValue. - * @member {Uint8Array} stringValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.stringValue = $util.newBuffer([]); - - /** - * UninterpretedOption aggregateValue. - * @member {string} aggregateValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.aggregateValue = ""; - - UninterpretedOption.NamePart = (function() { - - /** - * Properties of a NamePart. - * @memberof google.protobuf.UninterpretedOption - * @interface INamePart - * @property {string} namePart NamePart namePart - * @property {boolean} isExtension NamePart isExtension - */ - - /** - * Constructs a new NamePart. - * @memberof google.protobuf.UninterpretedOption - * @classdesc Represents a NamePart. - * @implements INamePart - * @constructor - * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set - */ - function NamePart(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * NamePart namePart. - * @member {string} namePart - * @memberof google.protobuf.UninterpretedOption.NamePart - * @instance - */ - NamePart.prototype.namePart = ""; - - /** - * NamePart isExtension. - * @member {boolean} isExtension - * @memberof google.protobuf.UninterpretedOption.NamePart - * @instance - */ - NamePart.prototype.isExtension = false; - - return NamePart; - })(); - - return UninterpretedOption; - })(); - - protobuf.SourceCodeInfo = (function() { - - /** - * Properties of a SourceCodeInfo. - * @memberof google.protobuf - * @interface ISourceCodeInfo - * @property {Array.|null} [location] SourceCodeInfo location - */ - - /** - * Constructs a new SourceCodeInfo. - * @memberof google.protobuf - * @classdesc Represents a SourceCodeInfo. - * @implements ISourceCodeInfo - * @constructor - * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set - */ - function SourceCodeInfo(properties) { - this.location = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * SourceCodeInfo location. - * @member {Array.} location - * @memberof google.protobuf.SourceCodeInfo - * @instance - */ - SourceCodeInfo.prototype.location = $util.emptyArray; - - SourceCodeInfo.Location = (function() { - - /** - * Properties of a Location. - * @memberof google.protobuf.SourceCodeInfo - * @interface ILocation - * @property {Array.|null} [path] Location path - * @property {Array.|null} [span] Location span - * @property {string|null} [leadingComments] Location leadingComments - * @property {string|null} [trailingComments] Location trailingComments - * @property {Array.|null} [leadingDetachedComments] Location leadingDetachedComments - */ - - /** - * Constructs a new Location. - * @memberof google.protobuf.SourceCodeInfo - * @classdesc Represents a Location. - * @implements ILocation - * @constructor - * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set - */ - function Location(properties) { - this.path = []; - this.span = []; - this.leadingDetachedComments = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Location path. - * @member {Array.} path - * @memberof google.protobuf.SourceCodeInfo.Location - * @instance - */ - Location.prototype.path = $util.emptyArray; - - /** - * Location span. - * @member {Array.} span - * @memberof google.protobuf.SourceCodeInfo.Location - * @instance - */ - Location.prototype.span = $util.emptyArray; - - /** - * Location leadingComments. - * @member {string} leadingComments - * @memberof google.protobuf.SourceCodeInfo.Location - * @instance - */ - Location.prototype.leadingComments = ""; - - /** - * Location trailingComments. - * @member {string} trailingComments - * @memberof google.protobuf.SourceCodeInfo.Location - * @instance - */ - Location.prototype.trailingComments = ""; - - /** - * Location leadingDetachedComments. - * @member {Array.} leadingDetachedComments - * @memberof google.protobuf.SourceCodeInfo.Location - * @instance - */ - Location.prototype.leadingDetachedComments = $util.emptyArray; - - return Location; - })(); - - return SourceCodeInfo; - })(); - - protobuf.GeneratedCodeInfo = (function() { - - /** - * Properties of a GeneratedCodeInfo. - * @memberof google.protobuf - * @interface IGeneratedCodeInfo - * @property {Array.|null} [annotation] GeneratedCodeInfo annotation - */ - - /** - * Constructs a new GeneratedCodeInfo. - * @memberof google.protobuf - * @classdesc Represents a GeneratedCodeInfo. - * @implements IGeneratedCodeInfo - * @constructor - * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set - */ - function GeneratedCodeInfo(properties) { - this.annotation = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * GeneratedCodeInfo annotation. - * @member {Array.} annotation - * @memberof google.protobuf.GeneratedCodeInfo - * @instance - */ - GeneratedCodeInfo.prototype.annotation = $util.emptyArray; - - GeneratedCodeInfo.Annotation = (function() { - - /** - * Properties of an Annotation. - * @memberof google.protobuf.GeneratedCodeInfo - * @interface IAnnotation - * @property {Array.|null} [path] Annotation path - * @property {string|null} [sourceFile] Annotation sourceFile - * @property {number|null} [begin] Annotation begin - * @property {number|null} [end] Annotation end - */ - - /** - * Constructs a new Annotation. - * @memberof google.protobuf.GeneratedCodeInfo - * @classdesc Represents an Annotation. - * @implements IAnnotation - * @constructor - * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set - */ - function Annotation(properties) { - this.path = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Annotation path. - * @member {Array.} path - * @memberof google.protobuf.GeneratedCodeInfo.Annotation - * @instance - */ - Annotation.prototype.path = $util.emptyArray; - - /** - * Annotation sourceFile. - * @member {string} sourceFile - * @memberof google.protobuf.GeneratedCodeInfo.Annotation - * @instance - */ - Annotation.prototype.sourceFile = ""; - - /** - * Annotation begin. - * @member {number} begin - * @memberof google.protobuf.GeneratedCodeInfo.Annotation - * @instance - */ - Annotation.prototype.begin = 0; - - /** - * Annotation end. - * @member {number} end - * @memberof google.protobuf.GeneratedCodeInfo.Annotation - * @instance - */ - Annotation.prototype.end = 0; - - return Annotation; - })(); - - return GeneratedCodeInfo; - })(); - - protobuf.Empty = (function() { - - /** - * Properties of an Empty. - * @memberof google.protobuf - * @interface IEmpty - */ - - /** - * Constructs a new Empty. - * @memberof google.protobuf - * @classdesc Represents an Empty. - * @implements IEmpty - * @constructor - * @param {google.protobuf.IEmpty=} [properties] Properties to set - */ - function Empty(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - return Empty; - })(); - - protobuf.FieldMask = (function() { - - /** - * Properties of a FieldMask. - * @memberof google.protobuf - * @interface IFieldMask - * @property {Array.|null} [paths] FieldMask paths - */ - - /** - * Constructs a new FieldMask. - * @memberof google.protobuf - * @classdesc Represents a FieldMask. - * @implements IFieldMask - * @constructor - * @param {google.protobuf.IFieldMask=} [properties] Properties to set - */ - function FieldMask(properties) { - this.paths = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FieldMask paths. - * @member {Array.} paths - * @memberof google.protobuf.FieldMask - * @instance - */ - FieldMask.prototype.paths = $util.emptyArray; - - return FieldMask; - })(); - - protobuf.Timestamp = (function() { - - /** - * Properties of a Timestamp. - * @memberof google.protobuf - * @interface ITimestamp - * @property {number|null} [seconds] Timestamp seconds - * @property {number|null} [nanos] Timestamp nanos - */ - - /** - * Constructs a new Timestamp. - * @memberof google.protobuf - * @classdesc Represents a Timestamp. - * @implements ITimestamp - * @constructor - * @param {google.protobuf.ITimestamp=} [properties] Properties to set - */ - function Timestamp(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Timestamp seconds. - * @member {number} seconds - * @memberof google.protobuf.Timestamp - * @instance - */ - Timestamp.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Timestamp nanos. - * @member {number} nanos - * @memberof google.protobuf.Timestamp - * @instance - */ - Timestamp.prototype.nanos = 0; - - return Timestamp; - })(); - - protobuf.Any = (function() { - - /** - * Properties of an Any. - * @memberof google.protobuf - * @interface IAny - * @property {string|null} [type_url] Any type_url - * @property {Uint8Array|null} [value] Any value - */ - - /** - * Constructs a new Any. - * @memberof google.protobuf - * @classdesc Represents an Any. - * @implements IAny - * @constructor - * @param {google.protobuf.IAny=} [properties] Properties to set - */ - function Any(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Any type_url. - * @member {string} type_url - * @memberof google.protobuf.Any - * @instance - */ - Any.prototype.type_url = ""; - - /** - * Any value. - * @member {Uint8Array} value - * @memberof google.protobuf.Any - * @instance - */ - Any.prototype.value = $util.newBuffer([]); - - return Any; - })(); - - protobuf.Struct = (function() { - - /** - * Properties of a Struct. - * @memberof google.protobuf - * @interface IStruct - * @property {Object.|null} [fields] Struct fields - */ - - /** - * Constructs a new Struct. - * @memberof google.protobuf - * @classdesc Represents a Struct. - * @implements IStruct - * @constructor - * @param {google.protobuf.IStruct=} [properties] Properties to set - */ - function Struct(properties) { - this.fields = {}; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Struct fields. - * @member {Object.} fields - * @memberof google.protobuf.Struct - * @instance - */ - Struct.prototype.fields = $util.emptyObject; - - return Struct; - })(); - - protobuf.Value = (function() { - - /** - * Properties of a Value. - * @memberof google.protobuf - * @interface IValue - * @property {google.protobuf.NullValue|null} [nullValue] Value nullValue - * @property {number|null} [numberValue] Value numberValue - * @property {string|null} [stringValue] Value stringValue - * @property {boolean|null} [boolValue] Value boolValue - * @property {google.protobuf.IStruct|null} [structValue] Value structValue - * @property {google.protobuf.IListValue|null} [listValue] Value listValue - */ - - /** - * Constructs a new Value. - * @memberof google.protobuf - * @classdesc Represents a Value. - * @implements IValue - * @constructor - * @param {google.protobuf.IValue=} [properties] Properties to set - */ - function Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Value nullValue. - * @member {google.protobuf.NullValue} nullValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.nullValue = 0; - - /** - * Value numberValue. - * @member {number} numberValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.numberValue = 0; - - /** - * Value stringValue. - * @member {string} stringValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.stringValue = ""; - - /** - * Value boolValue. - * @member {boolean} boolValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.boolValue = false; - - /** - * Value structValue. - * @member {google.protobuf.IStruct|null|undefined} structValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.structValue = null; - - /** - * Value listValue. - * @member {google.protobuf.IListValue|null|undefined} listValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.listValue = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Value kind. - * @member {"nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"|undefined} kind - * @memberof google.protobuf.Value - * @instance - */ - Object.defineProperty(Value.prototype, "kind", { - get: $util.oneOfGetter($oneOfFields = ["nullValue", "numberValue", "stringValue", "boolValue", "structValue", "listValue"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return Value; - })(); - - /** - * NullValue enum. - * @name google.protobuf.NullValue - * @enum {number} - * @property {string} NULL_VALUE=NULL_VALUE NULL_VALUE value - */ - protobuf.NullValue = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "NULL_VALUE"] = "NULL_VALUE"; - return values; - })(); - - protobuf.ListValue = (function() { - - /** - * Properties of a ListValue. - * @memberof google.protobuf - * @interface IListValue - * @property {Array.|null} [values] ListValue values - */ - - /** - * Constructs a new ListValue. - * @memberof google.protobuf - * @classdesc Represents a ListValue. - * @implements IListValue - * @constructor - * @param {google.protobuf.IListValue=} [properties] Properties to set - */ - function ListValue(properties) { - this.values = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListValue values. - * @member {Array.} values - * @memberof google.protobuf.ListValue - * @instance - */ - ListValue.prototype.values = $util.emptyArray; - - return ListValue; - })(); - - protobuf.DoubleValue = (function() { - - /** - * Properties of a DoubleValue. - * @memberof google.protobuf - * @interface IDoubleValue - * @property {number|null} [value] DoubleValue value - */ - - /** - * Constructs a new DoubleValue. - * @memberof google.protobuf - * @classdesc Represents a DoubleValue. - * @implements IDoubleValue - * @constructor - * @param {google.protobuf.IDoubleValue=} [properties] Properties to set - */ - function DoubleValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DoubleValue value. - * @member {number} value - * @memberof google.protobuf.DoubleValue - * @instance - */ - DoubleValue.prototype.value = 0; - - return DoubleValue; - })(); - - protobuf.FloatValue = (function() { - - /** - * Properties of a FloatValue. - * @memberof google.protobuf - * @interface IFloatValue - * @property {number|null} [value] FloatValue value - */ - - /** - * Constructs a new FloatValue. - * @memberof google.protobuf - * @classdesc Represents a FloatValue. - * @implements IFloatValue - * @constructor - * @param {google.protobuf.IFloatValue=} [properties] Properties to set - */ - function FloatValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FloatValue value. - * @member {number} value - * @memberof google.protobuf.FloatValue - * @instance - */ - FloatValue.prototype.value = 0; - - return FloatValue; - })(); - - protobuf.Int64Value = (function() { - - /** - * Properties of an Int64Value. - * @memberof google.protobuf - * @interface IInt64Value - * @property {number|null} [value] Int64Value value - */ - - /** - * Constructs a new Int64Value. - * @memberof google.protobuf - * @classdesc Represents an Int64Value. - * @implements IInt64Value - * @constructor - * @param {google.protobuf.IInt64Value=} [properties] Properties to set - */ - function Int64Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Int64Value value. - * @member {number} value - * @memberof google.protobuf.Int64Value - * @instance - */ - Int64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - return Int64Value; - })(); - - protobuf.UInt64Value = (function() { - - /** - * Properties of a UInt64Value. - * @memberof google.protobuf - * @interface IUInt64Value - * @property {number|null} [value] UInt64Value value - */ - - /** - * Constructs a new UInt64Value. - * @memberof google.protobuf - * @classdesc Represents a UInt64Value. - * @implements IUInt64Value - * @constructor - * @param {google.protobuf.IUInt64Value=} [properties] Properties to set - */ - function UInt64Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * UInt64Value value. - * @member {number} value - * @memberof google.protobuf.UInt64Value - * @instance - */ - UInt64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,true) : 0; - - return UInt64Value; - })(); - - protobuf.Int32Value = (function() { - - /** - * Properties of an Int32Value. - * @memberof google.protobuf - * @interface IInt32Value - * @property {number|null} [value] Int32Value value - */ - - /** - * Constructs a new Int32Value. - * @memberof google.protobuf - * @classdesc Represents an Int32Value. - * @implements IInt32Value - * @constructor - * @param {google.protobuf.IInt32Value=} [properties] Properties to set - */ - function Int32Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Int32Value value. - * @member {number} value - * @memberof google.protobuf.Int32Value - * @instance - */ - Int32Value.prototype.value = 0; - - return Int32Value; - })(); - - protobuf.UInt32Value = (function() { - - /** - * Properties of a UInt32Value. - * @memberof google.protobuf - * @interface IUInt32Value - * @property {number|null} [value] UInt32Value value - */ - - /** - * Constructs a new UInt32Value. - * @memberof google.protobuf - * @classdesc Represents a UInt32Value. - * @implements IUInt32Value - * @constructor - * @param {google.protobuf.IUInt32Value=} [properties] Properties to set - */ - function UInt32Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * UInt32Value value. - * @member {number} value - * @memberof google.protobuf.UInt32Value - * @instance - */ - UInt32Value.prototype.value = 0; - - return UInt32Value; - })(); - - protobuf.BoolValue = (function() { - - /** - * Properties of a BoolValue. - * @memberof google.protobuf - * @interface IBoolValue - * @property {boolean|null} [value] BoolValue value - */ - - /** - * Constructs a new BoolValue. - * @memberof google.protobuf - * @classdesc Represents a BoolValue. - * @implements IBoolValue - * @constructor - * @param {google.protobuf.IBoolValue=} [properties] Properties to set - */ - function BoolValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BoolValue value. - * @member {boolean} value - * @memberof google.protobuf.BoolValue - * @instance - */ - BoolValue.prototype.value = false; - - return BoolValue; - })(); - - protobuf.StringValue = (function() { - - /** - * Properties of a StringValue. - * @memberof google.protobuf - * @interface IStringValue - * @property {string|null} [value] StringValue value - */ - - /** - * Constructs a new StringValue. - * @memberof google.protobuf - * @classdesc Represents a StringValue. - * @implements IStringValue - * @constructor - * @param {google.protobuf.IStringValue=} [properties] Properties to set - */ - function StringValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * StringValue value. - * @member {string} value - * @memberof google.protobuf.StringValue - * @instance - */ - StringValue.prototype.value = ""; - - return StringValue; - })(); - - protobuf.BytesValue = (function() { - - /** - * Properties of a BytesValue. - * @memberof google.protobuf - * @interface IBytesValue - * @property {Uint8Array|null} [value] BytesValue value - */ - - /** - * Constructs a new BytesValue. - * @memberof google.protobuf - * @classdesc Represents a BytesValue. - * @implements IBytesValue - * @constructor - * @param {google.protobuf.IBytesValue=} [properties] Properties to set - */ - function BytesValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BytesValue value. - * @member {Uint8Array} value - * @memberof google.protobuf.BytesValue - * @instance - */ - BytesValue.prototype.value = $util.newBuffer([]); - - return BytesValue; - })(); - - protobuf.Duration = (function() { - - /** - * Properties of a Duration. - * @memberof google.protobuf - * @interface IDuration - * @property {number|null} [seconds] Duration seconds - * @property {number|null} [nanos] Duration nanos - */ - - /** - * Constructs a new Duration. - * @memberof google.protobuf - * @classdesc Represents a Duration. - * @implements IDuration - * @constructor - * @param {google.protobuf.IDuration=} [properties] Properties to set - */ - function Duration(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Duration seconds. - * @member {number} seconds - * @memberof google.protobuf.Duration - * @instance - */ - Duration.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Duration nanos. - * @member {number} nanos - * @memberof google.protobuf.Duration - * @instance - */ - Duration.prototype.nanos = 0; - - return Duration; - })(); - - return protobuf; - })(); - - google.type = (function() { - - /** - * Namespace type. - * @memberof google - * @namespace - */ - var type = {}; - - type.LatLng = (function() { - - /** - * Properties of a LatLng. - * @memberof google.type - * @interface ILatLng - * @property {number|null} [latitude] LatLng latitude - * @property {number|null} [longitude] LatLng longitude - */ - - /** - * Constructs a new LatLng. - * @memberof google.type - * @classdesc Represents a LatLng. - * @implements ILatLng - * @constructor - * @param {google.type.ILatLng=} [properties] Properties to set - */ - function LatLng(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * LatLng latitude. - * @member {number} latitude - * @memberof google.type.LatLng - * @instance - */ - LatLng.prototype.latitude = 0; - - /** - * LatLng longitude. - * @member {number} longitude - * @memberof google.type.LatLng - * @instance - */ - LatLng.prototype.longitude = 0; - - return LatLng; - })(); - - return type; - })(); - - google.rpc = (function() { - - /** - * Namespace rpc. - * @memberof google - * @namespace - */ - var rpc = {}; - - rpc.Status = (function() { - - /** - * Properties of a Status. - * @memberof google.rpc - * @interface IStatus - * @property {number|null} [code] Status code - * @property {string|null} [message] Status message - * @property {Array.|null} [details] Status details - */ - - /** - * Constructs a new Status. - * @memberof google.rpc - * @classdesc Represents a Status. - * @implements IStatus - * @constructor - * @param {google.rpc.IStatus=} [properties] Properties to set - */ - function Status(properties) { - this.details = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Status code. - * @member {number} code - * @memberof google.rpc.Status - * @instance - */ - Status.prototype.code = 0; - - /** - * Status message. - * @member {string} message - * @memberof google.rpc.Status - * @instance - */ - Status.prototype.message = ""; - - /** - * Status details. - * @member {Array.} details - * @memberof google.rpc.Status - * @instance - */ - Status.prototype.details = $util.emptyArray; - - return Status; - })(); - - return rpc; - })(); - - google.longrunning = (function() { - - /** - * Namespace longrunning. - * @memberof google - * @namespace - */ - var longrunning = {}; - - longrunning.Operations = (function() { - - /** - * Constructs a new Operations service. - * @memberof google.longrunning - * @classdesc Represents an Operations - * @extends $protobuf.rpc.Service - * @constructor - * @param {$protobuf.RPCImpl} rpcImpl RPC implementation - * @param {boolean} [requestDelimited=false] Whether requests are length-delimited - * @param {boolean} [responseDelimited=false] Whether responses are length-delimited - */ - function Operations(rpcImpl, requestDelimited, responseDelimited) { - $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); - } - - (Operations.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Operations; - - /** - * Callback as used by {@link google.longrunning.Operations#listOperations}. - * @memberof google.longrunning.Operations - * @typedef ListOperationsCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.longrunning.ListOperationsResponse} [response] ListOperationsResponse - */ - - /** - * Calls ListOperations. - * @function listOperations - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object - * @param {google.longrunning.Operations.ListOperationsCallback} callback Node-style callback called with the error, if any, and ListOperationsResponse - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Operations.prototype.listOperations = function listOperations(request, callback) { - return this.rpcCall(listOperations, $root.google.longrunning.ListOperationsRequest, $root.google.longrunning.ListOperationsResponse, request, callback); - }, "name", { value: "ListOperations" }); - - /** - * Calls ListOperations. - * @function listOperations - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.longrunning.Operations#getOperation}. - * @memberof google.longrunning.Operations - * @typedef GetOperationCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.longrunning.Operation} [response] Operation - */ - - /** - * Calls GetOperation. - * @function getOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object - * @param {google.longrunning.Operations.GetOperationCallback} callback Node-style callback called with the error, if any, and Operation - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Operations.prototype.getOperation = function getOperation(request, callback) { - return this.rpcCall(getOperation, $root.google.longrunning.GetOperationRequest, $root.google.longrunning.Operation, request, callback); - }, "name", { value: "GetOperation" }); - - /** - * Calls GetOperation. - * @function getOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.longrunning.Operations#deleteOperation}. - * @memberof google.longrunning.Operations - * @typedef DeleteOperationCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.protobuf.Empty} [response] Empty - */ - - /** - * Calls DeleteOperation. - * @function deleteOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object - * @param {google.longrunning.Operations.DeleteOperationCallback} callback Node-style callback called with the error, if any, and Empty - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Operations.prototype.deleteOperation = function deleteOperation(request, callback) { - return this.rpcCall(deleteOperation, $root.google.longrunning.DeleteOperationRequest, $root.google.protobuf.Empty, request, callback); - }, "name", { value: "DeleteOperation" }); - - /** - * Calls DeleteOperation. - * @function deleteOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.longrunning.Operations#cancelOperation}. - * @memberof google.longrunning.Operations - * @typedef CancelOperationCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.protobuf.Empty} [response] Empty - */ - - /** - * Calls CancelOperation. - * @function cancelOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object - * @param {google.longrunning.Operations.CancelOperationCallback} callback Node-style callback called with the error, if any, and Empty - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Operations.prototype.cancelOperation = function cancelOperation(request, callback) { - return this.rpcCall(cancelOperation, $root.google.longrunning.CancelOperationRequest, $root.google.protobuf.Empty, request, callback); - }, "name", { value: "CancelOperation" }); - - /** - * Calls CancelOperation. - * @function cancelOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.longrunning.Operations#waitOperation}. - * @memberof google.longrunning.Operations - * @typedef WaitOperationCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.longrunning.Operation} [response] Operation - */ - - /** - * Calls WaitOperation. - * @function waitOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object - * @param {google.longrunning.Operations.WaitOperationCallback} callback Node-style callback called with the error, if any, and Operation - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Operations.prototype.waitOperation = function waitOperation(request, callback) { - return this.rpcCall(waitOperation, $root.google.longrunning.WaitOperationRequest, $root.google.longrunning.Operation, request, callback); - }, "name", { value: "WaitOperation" }); - - /** - * Calls WaitOperation. - * @function waitOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - return Operations; - })(); - - longrunning.Operation = (function() { - - /** - * Properties of an Operation. - * @memberof google.longrunning - * @interface IOperation - * @property {string|null} [name] Operation name - * @property {google.protobuf.IAny|null} [metadata] Operation metadata - * @property {boolean|null} [done] Operation done - * @property {google.rpc.IStatus|null} [error] Operation error - * @property {google.protobuf.IAny|null} [response] Operation response - */ - - /** - * Constructs a new Operation. - * @memberof google.longrunning - * @classdesc Represents an Operation. - * @implements IOperation - * @constructor - * @param {google.longrunning.IOperation=} [properties] Properties to set - */ - function Operation(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Operation name. - * @member {string} name - * @memberof google.longrunning.Operation - * @instance - */ - Operation.prototype.name = ""; - - /** - * Operation metadata. - * @member {google.protobuf.IAny|null|undefined} metadata - * @memberof google.longrunning.Operation - * @instance - */ - Operation.prototype.metadata = null; - - /** - * Operation done. - * @member {boolean} done - * @memberof google.longrunning.Operation - * @instance - */ - Operation.prototype.done = false; - - /** - * Operation error. - * @member {google.rpc.IStatus|null|undefined} error - * @memberof google.longrunning.Operation - * @instance - */ - Operation.prototype.error = null; - - /** - * Operation response. - * @member {google.protobuf.IAny|null|undefined} response - * @memberof google.longrunning.Operation - * @instance - */ - Operation.prototype.response = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Operation result. - * @member {"error"|"response"|undefined} result - * @memberof google.longrunning.Operation - * @instance - */ - Object.defineProperty(Operation.prototype, "result", { - get: $util.oneOfGetter($oneOfFields = ["error", "response"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return Operation; - })(); - - longrunning.GetOperationRequest = (function() { - - /** - * Properties of a GetOperationRequest. - * @memberof google.longrunning - * @interface IGetOperationRequest - * @property {string|null} [name] GetOperationRequest name - */ - - /** - * Constructs a new GetOperationRequest. - * @memberof google.longrunning - * @classdesc Represents a GetOperationRequest. - * @implements IGetOperationRequest - * @constructor - * @param {google.longrunning.IGetOperationRequest=} [properties] Properties to set - */ - function GetOperationRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * GetOperationRequest name. - * @member {string} name - * @memberof google.longrunning.GetOperationRequest - * @instance - */ - GetOperationRequest.prototype.name = ""; - - return GetOperationRequest; - })(); - - longrunning.ListOperationsRequest = (function() { - - /** - * Properties of a ListOperationsRequest. - * @memberof google.longrunning - * @interface IListOperationsRequest - * @property {string|null} [name] ListOperationsRequest name - * @property {string|null} [filter] ListOperationsRequest filter - * @property {number|null} [pageSize] ListOperationsRequest pageSize - * @property {string|null} [pageToken] ListOperationsRequest pageToken - */ - - /** - * Constructs a new ListOperationsRequest. - * @memberof google.longrunning - * @classdesc Represents a ListOperationsRequest. - * @implements IListOperationsRequest - * @constructor - * @param {google.longrunning.IListOperationsRequest=} [properties] Properties to set - */ - function ListOperationsRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListOperationsRequest name. - * @member {string} name - * @memberof google.longrunning.ListOperationsRequest - * @instance - */ - ListOperationsRequest.prototype.name = ""; - - /** - * ListOperationsRequest filter. - * @member {string} filter - * @memberof google.longrunning.ListOperationsRequest - * @instance - */ - ListOperationsRequest.prototype.filter = ""; - - /** - * ListOperationsRequest pageSize. - * @member {number} pageSize - * @memberof google.longrunning.ListOperationsRequest - * @instance - */ - ListOperationsRequest.prototype.pageSize = 0; - - /** - * ListOperationsRequest pageToken. - * @member {string} pageToken - * @memberof google.longrunning.ListOperationsRequest - * @instance - */ - ListOperationsRequest.prototype.pageToken = ""; - - return ListOperationsRequest; + + v1.DeleteIndexRequest = (function() { + + /** + * Properties of a DeleteIndexRequest. + * @memberof google.firestore.admin.v1 + * @interface IDeleteIndexRequest + * @property {string|null} [name] DeleteIndexRequest name + */ + + /** + * Constructs a new DeleteIndexRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a DeleteIndexRequest. + * @implements IDeleteIndexRequest + * @constructor + * @param {google.firestore.admin.v1.IDeleteIndexRequest=} [properties] Properties to set + */ + function DeleteIndexRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteIndexRequest name. + * @member {string} name + * @memberof google.firestore.admin.v1.DeleteIndexRequest + * @instance + */ + DeleteIndexRequest.prototype.name = ""; + + /** + * Creates a DeleteIndexRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.DeleteIndexRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.DeleteIndexRequest} DeleteIndexRequest + */ + DeleteIndexRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.DeleteIndexRequest) + return object; + var message = new $root.google.firestore.admin.v1.DeleteIndexRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteIndexRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.DeleteIndexRequest + * @static + * @param {google.firestore.admin.v1.DeleteIndexRequest} message DeleteIndexRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteIndexRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this DeleteIndexRequest to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.DeleteIndexRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteIndexRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DeleteIndexRequest; + })(); + + v1.UpdateFieldRequest = (function() { + + /** + * Properties of an UpdateFieldRequest. + * @memberof google.firestore.admin.v1 + * @interface IUpdateFieldRequest + * @property {google.firestore.admin.v1.IField|null} [field] UpdateFieldRequest field + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateFieldRequest updateMask + */ + + /** + * Constructs a new UpdateFieldRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents an UpdateFieldRequest. + * @implements IUpdateFieldRequest + * @constructor + * @param {google.firestore.admin.v1.IUpdateFieldRequest=} [properties] Properties to set + */ + function UpdateFieldRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UpdateFieldRequest field. + * @member {google.firestore.admin.v1.IField|null|undefined} field + * @memberof google.firestore.admin.v1.UpdateFieldRequest + * @instance + */ + UpdateFieldRequest.prototype.field = null; + + /** + * UpdateFieldRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.firestore.admin.v1.UpdateFieldRequest + * @instance + */ + UpdateFieldRequest.prototype.updateMask = null; + + /** + * Creates an UpdateFieldRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.UpdateFieldRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.UpdateFieldRequest} UpdateFieldRequest + */ + UpdateFieldRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.UpdateFieldRequest) + return object; + var message = new $root.google.firestore.admin.v1.UpdateFieldRequest(); + if (object.field != null) { + if (typeof object.field !== "object") + throw TypeError(".google.firestore.admin.v1.UpdateFieldRequest.field: object expected"); + message.field = $root.google.firestore.admin.v1.Field.fromObject(object.field); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.firestore.admin.v1.UpdateFieldRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateFieldRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.UpdateFieldRequest + * @static + * @param {google.firestore.admin.v1.UpdateFieldRequest} message UpdateFieldRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateFieldRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.field = null; + object.updateMask = null; + } + if (message.field != null && message.hasOwnProperty("field")) + object.field = $root.google.firestore.admin.v1.Field.toObject(message.field, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateFieldRequest to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.UpdateFieldRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateFieldRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return UpdateFieldRequest; + })(); + + v1.GetFieldRequest = (function() { + + /** + * Properties of a GetFieldRequest. + * @memberof google.firestore.admin.v1 + * @interface IGetFieldRequest + * @property {string|null} [name] GetFieldRequest name + */ + + /** + * Constructs a new GetFieldRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a GetFieldRequest. + * @implements IGetFieldRequest + * @constructor + * @param {google.firestore.admin.v1.IGetFieldRequest=} [properties] Properties to set + */ + function GetFieldRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetFieldRequest name. + * @member {string} name + * @memberof google.firestore.admin.v1.GetFieldRequest + * @instance + */ + GetFieldRequest.prototype.name = ""; + + /** + * Creates a GetFieldRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.GetFieldRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.GetFieldRequest} GetFieldRequest + */ + GetFieldRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.GetFieldRequest) + return object; + var message = new $root.google.firestore.admin.v1.GetFieldRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetFieldRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.GetFieldRequest + * @static + * @param {google.firestore.admin.v1.GetFieldRequest} message GetFieldRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetFieldRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetFieldRequest to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.GetFieldRequest + * @instance + * @returns {Object.} JSON object + */ + GetFieldRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetFieldRequest; + })(); + + v1.ListFieldsRequest = (function() { + + /** + * Properties of a ListFieldsRequest. + * @memberof google.firestore.admin.v1 + * @interface IListFieldsRequest + * @property {string|null} [parent] ListFieldsRequest parent + * @property {string|null} [filter] ListFieldsRequest filter + * @property {number|null} [pageSize] ListFieldsRequest pageSize + * @property {string|null} [pageToken] ListFieldsRequest pageToken + */ + + /** + * Constructs a new ListFieldsRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a ListFieldsRequest. + * @implements IListFieldsRequest + * @constructor + * @param {google.firestore.admin.v1.IListFieldsRequest=} [properties] Properties to set + */ + function ListFieldsRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListFieldsRequest parent. + * @member {string} parent + * @memberof google.firestore.admin.v1.ListFieldsRequest + * @instance + */ + ListFieldsRequest.prototype.parent = ""; + + /** + * ListFieldsRequest filter. + * @member {string} filter + * @memberof google.firestore.admin.v1.ListFieldsRequest + * @instance + */ + ListFieldsRequest.prototype.filter = ""; + + /** + * ListFieldsRequest pageSize. + * @member {number} pageSize + * @memberof google.firestore.admin.v1.ListFieldsRequest + * @instance + */ + ListFieldsRequest.prototype.pageSize = 0; + + /** + * ListFieldsRequest pageToken. + * @member {string} pageToken + * @memberof google.firestore.admin.v1.ListFieldsRequest + * @instance + */ + ListFieldsRequest.prototype.pageToken = ""; + + /** + * Creates a ListFieldsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.ListFieldsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.ListFieldsRequest} ListFieldsRequest + */ + ListFieldsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.ListFieldsRequest) + return object; + var message = new $root.google.firestore.admin.v1.ListFieldsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.filter != null) + message.filter = String(object.filter); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + return message; + }; + + /** + * Creates a plain object from a ListFieldsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.ListFieldsRequest + * @static + * @param {google.firestore.admin.v1.ListFieldsRequest} message ListFieldsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListFieldsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.filter = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + return object; + }; + + /** + * Converts this ListFieldsRequest to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.ListFieldsRequest + * @instance + * @returns {Object.} JSON object + */ + ListFieldsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListFieldsRequest; + })(); + + v1.ListFieldsResponse = (function() { + + /** + * Properties of a ListFieldsResponse. + * @memberof google.firestore.admin.v1 + * @interface IListFieldsResponse + * @property {Array.|null} [fields] ListFieldsResponse fields + * @property {string|null} [nextPageToken] ListFieldsResponse nextPageToken + */ + + /** + * Constructs a new ListFieldsResponse. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a ListFieldsResponse. + * @implements IListFieldsResponse + * @constructor + * @param {google.firestore.admin.v1.IListFieldsResponse=} [properties] Properties to set + */ + function ListFieldsResponse(properties) { + this.fields = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListFieldsResponse fields. + * @member {Array.} fields + * @memberof google.firestore.admin.v1.ListFieldsResponse + * @instance + */ + ListFieldsResponse.prototype.fields = $util.emptyArray; + + /** + * ListFieldsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.firestore.admin.v1.ListFieldsResponse + * @instance + */ + ListFieldsResponse.prototype.nextPageToken = ""; + + /** + * Creates a ListFieldsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.ListFieldsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.ListFieldsResponse} ListFieldsResponse + */ + ListFieldsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.ListFieldsResponse) + return object; + var message = new $root.google.firestore.admin.v1.ListFieldsResponse(); + if (object.fields) { + if (!Array.isArray(object.fields)) + throw TypeError(".google.firestore.admin.v1.ListFieldsResponse.fields: array expected"); + message.fields = []; + for (var i = 0; i < object.fields.length; ++i) { + if (typeof object.fields[i] !== "object") + throw TypeError(".google.firestore.admin.v1.ListFieldsResponse.fields: object expected"); + message.fields[i] = $root.google.firestore.admin.v1.Field.fromObject(object.fields[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListFieldsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.ListFieldsResponse + * @static + * @param {google.firestore.admin.v1.ListFieldsResponse} message ListFieldsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListFieldsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.fields = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.fields && message.fields.length) { + object.fields = []; + for (var j = 0; j < message.fields.length; ++j) + object.fields[j] = $root.google.firestore.admin.v1.Field.toObject(message.fields[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListFieldsResponse to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.ListFieldsResponse + * @instance + * @returns {Object.} JSON object + */ + ListFieldsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListFieldsResponse; + })(); + + v1.ExportDocumentsRequest = (function() { + + /** + * Properties of an ExportDocumentsRequest. + * @memberof google.firestore.admin.v1 + * @interface IExportDocumentsRequest + * @property {string|null} [name] ExportDocumentsRequest name + * @property {Array.|null} [collectionIds] ExportDocumentsRequest collectionIds + * @property {string|null} [outputUriPrefix] ExportDocumentsRequest outputUriPrefix + */ + + /** + * Constructs a new ExportDocumentsRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents an ExportDocumentsRequest. + * @implements IExportDocumentsRequest + * @constructor + * @param {google.firestore.admin.v1.IExportDocumentsRequest=} [properties] Properties to set + */ + function ExportDocumentsRequest(properties) { + this.collectionIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExportDocumentsRequest name. + * @member {string} name + * @memberof google.firestore.admin.v1.ExportDocumentsRequest + * @instance + */ + ExportDocumentsRequest.prototype.name = ""; + + /** + * ExportDocumentsRequest collectionIds. + * @member {Array.} collectionIds + * @memberof google.firestore.admin.v1.ExportDocumentsRequest + * @instance + */ + ExportDocumentsRequest.prototype.collectionIds = $util.emptyArray; + + /** + * ExportDocumentsRequest outputUriPrefix. + * @member {string} outputUriPrefix + * @memberof google.firestore.admin.v1.ExportDocumentsRequest + * @instance + */ + ExportDocumentsRequest.prototype.outputUriPrefix = ""; + + /** + * Creates an ExportDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.ExportDocumentsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.ExportDocumentsRequest} ExportDocumentsRequest + */ + ExportDocumentsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.ExportDocumentsRequest) + return object; + var message = new $root.google.firestore.admin.v1.ExportDocumentsRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.collectionIds) { + if (!Array.isArray(object.collectionIds)) + throw TypeError(".google.firestore.admin.v1.ExportDocumentsRequest.collectionIds: array expected"); + message.collectionIds = []; + for (var i = 0; i < object.collectionIds.length; ++i) + message.collectionIds[i] = String(object.collectionIds[i]); + } + if (object.outputUriPrefix != null) + message.outputUriPrefix = String(object.outputUriPrefix); + return message; + }; + + /** + * Creates a plain object from an ExportDocumentsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.ExportDocumentsRequest + * @static + * @param {google.firestore.admin.v1.ExportDocumentsRequest} message ExportDocumentsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExportDocumentsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.collectionIds = []; + if (options.defaults) { + object.name = ""; + object.outputUriPrefix = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.collectionIds && message.collectionIds.length) { + object.collectionIds = []; + for (var j = 0; j < message.collectionIds.length; ++j) + object.collectionIds[j] = message.collectionIds[j]; + } + if (message.outputUriPrefix != null && message.hasOwnProperty("outputUriPrefix")) + object.outputUriPrefix = message.outputUriPrefix; + return object; + }; + + /** + * Converts this ExportDocumentsRequest to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.ExportDocumentsRequest + * @instance + * @returns {Object.} JSON object + */ + ExportDocumentsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ExportDocumentsRequest; + })(); + + v1.ImportDocumentsRequest = (function() { + + /** + * Properties of an ImportDocumentsRequest. + * @memberof google.firestore.admin.v1 + * @interface IImportDocumentsRequest + * @property {string|null} [name] ImportDocumentsRequest name + * @property {Array.|null} [collectionIds] ImportDocumentsRequest collectionIds + * @property {string|null} [inputUriPrefix] ImportDocumentsRequest inputUriPrefix + */ + + /** + * Constructs a new ImportDocumentsRequest. + * @memberof google.firestore.admin.v1 + * @classdesc Represents an ImportDocumentsRequest. + * @implements IImportDocumentsRequest + * @constructor + * @param {google.firestore.admin.v1.IImportDocumentsRequest=} [properties] Properties to set + */ + function ImportDocumentsRequest(properties) { + this.collectionIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ImportDocumentsRequest name. + * @member {string} name + * @memberof google.firestore.admin.v1.ImportDocumentsRequest + * @instance + */ + ImportDocumentsRequest.prototype.name = ""; + + /** + * ImportDocumentsRequest collectionIds. + * @member {Array.} collectionIds + * @memberof google.firestore.admin.v1.ImportDocumentsRequest + * @instance + */ + ImportDocumentsRequest.prototype.collectionIds = $util.emptyArray; + + /** + * ImportDocumentsRequest inputUriPrefix. + * @member {string} inputUriPrefix + * @memberof google.firestore.admin.v1.ImportDocumentsRequest + * @instance + */ + ImportDocumentsRequest.prototype.inputUriPrefix = ""; + + /** + * Creates an ImportDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.ImportDocumentsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.ImportDocumentsRequest} ImportDocumentsRequest + */ + ImportDocumentsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.ImportDocumentsRequest) + return object; + var message = new $root.google.firestore.admin.v1.ImportDocumentsRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.collectionIds) { + if (!Array.isArray(object.collectionIds)) + throw TypeError(".google.firestore.admin.v1.ImportDocumentsRequest.collectionIds: array expected"); + message.collectionIds = []; + for (var i = 0; i < object.collectionIds.length; ++i) + message.collectionIds[i] = String(object.collectionIds[i]); + } + if (object.inputUriPrefix != null) + message.inputUriPrefix = String(object.inputUriPrefix); + return message; + }; + + /** + * Creates a plain object from an ImportDocumentsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.ImportDocumentsRequest + * @static + * @param {google.firestore.admin.v1.ImportDocumentsRequest} message ImportDocumentsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportDocumentsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.collectionIds = []; + if (options.defaults) { + object.name = ""; + object.inputUriPrefix = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.collectionIds && message.collectionIds.length) { + object.collectionIds = []; + for (var j = 0; j < message.collectionIds.length; ++j) + object.collectionIds[j] = message.collectionIds[j]; + } + if (message.inputUriPrefix != null && message.hasOwnProperty("inputUriPrefix")) + object.inputUriPrefix = message.inputUriPrefix; + return object; + }; + + /** + * Converts this ImportDocumentsRequest to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.ImportDocumentsRequest + * @instance + * @returns {Object.} JSON object + */ + ImportDocumentsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ImportDocumentsRequest; + })(); + + v1.Index = (function() { + + /** + * Properties of an Index. + * @memberof google.firestore.admin.v1 + * @interface IIndex + * @property {string|null} [name] Index name + * @property {google.firestore.admin.v1.Index.QueryScope|null} [queryScope] Index queryScope + * @property {Array.|null} [fields] Index fields + * @property {google.firestore.admin.v1.Index.State|null} [state] Index state + */ + + /** + * Constructs a new Index. + * @memberof google.firestore.admin.v1 + * @classdesc Represents an Index. + * @implements IIndex + * @constructor + * @param {google.firestore.admin.v1.IIndex=} [properties] Properties to set + */ + function Index(properties) { + this.fields = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Index name. + * @member {string} name + * @memberof google.firestore.admin.v1.Index + * @instance + */ + Index.prototype.name = ""; + + /** + * Index queryScope. + * @member {google.firestore.admin.v1.Index.QueryScope} queryScope + * @memberof google.firestore.admin.v1.Index + * @instance + */ + Index.prototype.queryScope = 0; + + /** + * Index fields. + * @member {Array.} fields + * @memberof google.firestore.admin.v1.Index + * @instance + */ + Index.prototype.fields = $util.emptyArray; + + /** + * Index state. + * @member {google.firestore.admin.v1.Index.State} state + * @memberof google.firestore.admin.v1.Index + * @instance + */ + Index.prototype.state = 0; + + /** + * Creates an Index message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.Index + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.Index} Index + */ + Index.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.Index) + return object; + var message = new $root.google.firestore.admin.v1.Index(); + if (object.name != null) + message.name = String(object.name); + switch (object.queryScope) { + case "QUERY_SCOPE_UNSPECIFIED": + case 0: + message.queryScope = 0; + break; + case "COLLECTION": + case 1: + message.queryScope = 1; + break; + case "COLLECTION_GROUP": + case 2: + message.queryScope = 2; + break; + } + if (object.fields) { + if (!Array.isArray(object.fields)) + throw TypeError(".google.firestore.admin.v1.Index.fields: array expected"); + message.fields = []; + for (var i = 0; i < object.fields.length; ++i) { + if (typeof object.fields[i] !== "object") + throw TypeError(".google.firestore.admin.v1.Index.fields: object expected"); + message.fields[i] = $root.google.firestore.admin.v1.Index.IndexField.fromObject(object.fields[i]); + } + } + switch (object.state) { + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "CREATING": + case 1: + message.state = 1; + break; + case "READY": + case 2: + message.state = 2; + break; + case "NEEDS_REPAIR": + case 3: + message.state = 3; + break; + } + return message; + }; + + /** + * Creates a plain object from an Index message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.Index + * @static + * @param {google.firestore.admin.v1.Index} message Index + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Index.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.fields = []; + if (options.defaults) { + object.name = ""; + object.queryScope = options.enums === String ? "QUERY_SCOPE_UNSPECIFIED" : 0; + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.queryScope != null && message.hasOwnProperty("queryScope")) + object.queryScope = options.enums === String ? $root.google.firestore.admin.v1.Index.QueryScope[message.queryScope] : message.queryScope; + if (message.fields && message.fields.length) { + object.fields = []; + for (var j = 0; j < message.fields.length; ++j) + object.fields[j] = $root.google.firestore.admin.v1.Index.IndexField.toObject(message.fields[j], options); + } + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.firestore.admin.v1.Index.State[message.state] : message.state; + return object; + }; + + /** + * Converts this Index to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.Index + * @instance + * @returns {Object.} JSON object + */ + Index.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + Index.IndexField = (function() { + + /** + * Properties of an IndexField. + * @memberof google.firestore.admin.v1.Index + * @interface IIndexField + * @property {string|null} [fieldPath] IndexField fieldPath + * @property {google.firestore.admin.v1.Index.IndexField.Order|null} [order] IndexField order + * @property {google.firestore.admin.v1.Index.IndexField.ArrayConfig|null} [arrayConfig] IndexField arrayConfig + */ + + /** + * Constructs a new IndexField. + * @memberof google.firestore.admin.v1.Index + * @classdesc Represents an IndexField. + * @implements IIndexField + * @constructor + * @param {google.firestore.admin.v1.Index.IIndexField=} [properties] Properties to set + */ + function IndexField(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * IndexField fieldPath. + * @member {string} fieldPath + * @memberof google.firestore.admin.v1.Index.IndexField + * @instance + */ + IndexField.prototype.fieldPath = ""; + + /** + * IndexField order. + * @member {google.firestore.admin.v1.Index.IndexField.Order} order + * @memberof google.firestore.admin.v1.Index.IndexField + * @instance + */ + IndexField.prototype.order = 0; + + /** + * IndexField arrayConfig. + * @member {google.firestore.admin.v1.Index.IndexField.ArrayConfig} arrayConfig + * @memberof google.firestore.admin.v1.Index.IndexField + * @instance + */ + IndexField.prototype.arrayConfig = 0; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * IndexField valueMode. + * @member {"order"|"arrayConfig"|undefined} valueMode + * @memberof google.firestore.admin.v1.Index.IndexField + * @instance + */ + Object.defineProperty(IndexField.prototype, "valueMode", { + get: $util.oneOfGetter($oneOfFields = ["order", "arrayConfig"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates an IndexField message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.Index.IndexField + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.Index.IndexField} IndexField + */ + IndexField.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.Index.IndexField) + return object; + var message = new $root.google.firestore.admin.v1.Index.IndexField(); + if (object.fieldPath != null) + message.fieldPath = String(object.fieldPath); + switch (object.order) { + case "ORDER_UNSPECIFIED": + case 0: + message.order = 0; + break; + case "ASCENDING": + case 1: + message.order = 1; + break; + case "DESCENDING": + case 2: + message.order = 2; + break; + } + switch (object.arrayConfig) { + case "ARRAY_CONFIG_UNSPECIFIED": + case 0: + message.arrayConfig = 0; + break; + case "CONTAINS": + case 1: + message.arrayConfig = 1; + break; + } + return message; + }; + + /** + * Creates a plain object from an IndexField message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.Index.IndexField + * @static + * @param {google.firestore.admin.v1.Index.IndexField} message IndexField + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + IndexField.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.fieldPath = ""; + if (message.fieldPath != null && message.hasOwnProperty("fieldPath")) + object.fieldPath = message.fieldPath; + if (message.order != null && message.hasOwnProperty("order")) { + object.order = options.enums === String ? $root.google.firestore.admin.v1.Index.IndexField.Order[message.order] : message.order; + if (options.oneofs) + object.valueMode = "order"; + } + if (message.arrayConfig != null && message.hasOwnProperty("arrayConfig")) { + object.arrayConfig = options.enums === String ? $root.google.firestore.admin.v1.Index.IndexField.ArrayConfig[message.arrayConfig] : message.arrayConfig; + if (options.oneofs) + object.valueMode = "arrayConfig"; + } + return object; + }; + + /** + * Converts this IndexField to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.Index.IndexField + * @instance + * @returns {Object.} JSON object + */ + IndexField.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Order enum. + * @name google.firestore.admin.v1.Index.IndexField.Order + * @enum {string} + * @property {string} ORDER_UNSPECIFIED=ORDER_UNSPECIFIED ORDER_UNSPECIFIED value + * @property {string} ASCENDING=ASCENDING ASCENDING value + * @property {string} DESCENDING=DESCENDING DESCENDING value + */ + IndexField.Order = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ORDER_UNSPECIFIED"] = "ORDER_UNSPECIFIED"; + values[valuesById[1] = "ASCENDING"] = "ASCENDING"; + values[valuesById[2] = "DESCENDING"] = "DESCENDING"; + return values; + })(); + + /** + * ArrayConfig enum. + * @name google.firestore.admin.v1.Index.IndexField.ArrayConfig + * @enum {string} + * @property {string} ARRAY_CONFIG_UNSPECIFIED=ARRAY_CONFIG_UNSPECIFIED ARRAY_CONFIG_UNSPECIFIED value + * @property {string} CONTAINS=CONTAINS CONTAINS value + */ + IndexField.ArrayConfig = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ARRAY_CONFIG_UNSPECIFIED"] = "ARRAY_CONFIG_UNSPECIFIED"; + values[valuesById[1] = "CONTAINS"] = "CONTAINS"; + return values; + })(); + + return IndexField; + })(); + + /** + * QueryScope enum. + * @name google.firestore.admin.v1.Index.QueryScope + * @enum {string} + * @property {string} QUERY_SCOPE_UNSPECIFIED=QUERY_SCOPE_UNSPECIFIED QUERY_SCOPE_UNSPECIFIED value + * @property {string} COLLECTION=COLLECTION COLLECTION value + * @property {string} COLLECTION_GROUP=COLLECTION_GROUP COLLECTION_GROUP value + */ + Index.QueryScope = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "QUERY_SCOPE_UNSPECIFIED"] = "QUERY_SCOPE_UNSPECIFIED"; + values[valuesById[1] = "COLLECTION"] = "COLLECTION"; + values[valuesById[2] = "COLLECTION_GROUP"] = "COLLECTION_GROUP"; + return values; + })(); + + /** + * State enum. + * @name google.firestore.admin.v1.Index.State + * @enum {string} + * @property {string} STATE_UNSPECIFIED=STATE_UNSPECIFIED STATE_UNSPECIFIED value + * @property {string} CREATING=CREATING CREATING value + * @property {string} READY=READY READY value + * @property {string} NEEDS_REPAIR=NEEDS_REPAIR NEEDS_REPAIR value + */ + Index.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED"; + values[valuesById[1] = "CREATING"] = "CREATING"; + values[valuesById[2] = "READY"] = "READY"; + values[valuesById[3] = "NEEDS_REPAIR"] = "NEEDS_REPAIR"; + return values; + })(); + + return Index; + })(); + + v1.LocationMetadata = (function() { + + /** + * Properties of a LocationMetadata. + * @memberof google.firestore.admin.v1 + * @interface ILocationMetadata + */ + + /** + * Constructs a new LocationMetadata. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a LocationMetadata. + * @implements ILocationMetadata + * @constructor + * @param {google.firestore.admin.v1.ILocationMetadata=} [properties] Properties to set + */ + function LocationMetadata(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates a LocationMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.LocationMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.LocationMetadata} LocationMetadata + */ + LocationMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.LocationMetadata) + return object; + return new $root.google.firestore.admin.v1.LocationMetadata(); + }; + + /** + * Creates a plain object from a LocationMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.LocationMetadata + * @static + * @param {google.firestore.admin.v1.LocationMetadata} message LocationMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LocationMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this LocationMetadata to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.LocationMetadata + * @instance + * @returns {Object.} JSON object + */ + LocationMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return LocationMetadata; + })(); + + v1.IndexOperationMetadata = (function() { + + /** + * Properties of an IndexOperationMetadata. + * @memberof google.firestore.admin.v1 + * @interface IIndexOperationMetadata + * @property {google.protobuf.ITimestamp|null} [startTime] IndexOperationMetadata startTime + * @property {google.protobuf.ITimestamp|null} [endTime] IndexOperationMetadata endTime + * @property {string|null} [index] IndexOperationMetadata index + * @property {google.firestore.admin.v1.OperationState|null} [state] IndexOperationMetadata state + * @property {google.firestore.admin.v1.IProgress|null} [progressDocuments] IndexOperationMetadata progressDocuments + * @property {google.firestore.admin.v1.IProgress|null} [progressBytes] IndexOperationMetadata progressBytes + */ + + /** + * Constructs a new IndexOperationMetadata. + * @memberof google.firestore.admin.v1 + * @classdesc Represents an IndexOperationMetadata. + * @implements IIndexOperationMetadata + * @constructor + * @param {google.firestore.admin.v1.IIndexOperationMetadata=} [properties] Properties to set + */ + function IndexOperationMetadata(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * IndexOperationMetadata startTime. + * @member {google.protobuf.ITimestamp|null|undefined} startTime + * @memberof google.firestore.admin.v1.IndexOperationMetadata + * @instance + */ + IndexOperationMetadata.prototype.startTime = null; + + /** + * IndexOperationMetadata endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.firestore.admin.v1.IndexOperationMetadata + * @instance + */ + IndexOperationMetadata.prototype.endTime = null; + + /** + * IndexOperationMetadata index. + * @member {string} index + * @memberof google.firestore.admin.v1.IndexOperationMetadata + * @instance + */ + IndexOperationMetadata.prototype.index = ""; + + /** + * IndexOperationMetadata state. + * @member {google.firestore.admin.v1.OperationState} state + * @memberof google.firestore.admin.v1.IndexOperationMetadata + * @instance + */ + IndexOperationMetadata.prototype.state = 0; + + /** + * IndexOperationMetadata progressDocuments. + * @member {google.firestore.admin.v1.IProgress|null|undefined} progressDocuments + * @memberof google.firestore.admin.v1.IndexOperationMetadata + * @instance + */ + IndexOperationMetadata.prototype.progressDocuments = null; + + /** + * IndexOperationMetadata progressBytes. + * @member {google.firestore.admin.v1.IProgress|null|undefined} progressBytes + * @memberof google.firestore.admin.v1.IndexOperationMetadata + * @instance + */ + IndexOperationMetadata.prototype.progressBytes = null; + + /** + * Creates an IndexOperationMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.IndexOperationMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.IndexOperationMetadata} IndexOperationMetadata + */ + IndexOperationMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.IndexOperationMetadata) + return object; + var message = new $root.google.firestore.admin.v1.IndexOperationMetadata(); + if (object.startTime != null) { + if (typeof object.startTime !== "object") + throw TypeError(".google.firestore.admin.v1.IndexOperationMetadata.startTime: object expected"); + message.startTime = $root.google.protobuf.Timestamp.fromObject(object.startTime); + } + if (object.endTime != null) { + if (typeof object.endTime !== "object") + throw TypeError(".google.firestore.admin.v1.IndexOperationMetadata.endTime: object expected"); + message.endTime = $root.google.protobuf.Timestamp.fromObject(object.endTime); + } + if (object.index != null) + message.index = String(object.index); + switch (object.state) { + case "OPERATION_STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "INITIALIZING": + case 1: + message.state = 1; + break; + case "PROCESSING": + case 2: + message.state = 2; + break; + case "CANCELLING": + case 3: + message.state = 3; + break; + case "FINALIZING": + case 4: + message.state = 4; + break; + case "SUCCESSFUL": + case 5: + message.state = 5; + break; + case "FAILED": + case 6: + message.state = 6; + break; + case "CANCELLED": + case 7: + message.state = 7; + break; + } + if (object.progressDocuments != null) { + if (typeof object.progressDocuments !== "object") + throw TypeError(".google.firestore.admin.v1.IndexOperationMetadata.progressDocuments: object expected"); + message.progressDocuments = $root.google.firestore.admin.v1.Progress.fromObject(object.progressDocuments); + } + if (object.progressBytes != null) { + if (typeof object.progressBytes !== "object") + throw TypeError(".google.firestore.admin.v1.IndexOperationMetadata.progressBytes: object expected"); + message.progressBytes = $root.google.firestore.admin.v1.Progress.fromObject(object.progressBytes); + } + return message; + }; + + /** + * Creates a plain object from an IndexOperationMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.IndexOperationMetadata + * @static + * @param {google.firestore.admin.v1.IndexOperationMetadata} message IndexOperationMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + IndexOperationMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.startTime = null; + object.endTime = null; + object.index = ""; + object.state = options.enums === String ? "OPERATION_STATE_UNSPECIFIED" : 0; + object.progressDocuments = null; + object.progressBytes = null; + } + if (message.startTime != null && message.hasOwnProperty("startTime")) + object.startTime = $root.google.protobuf.Timestamp.toObject(message.startTime, options); + if (message.endTime != null && message.hasOwnProperty("endTime")) + object.endTime = $root.google.protobuf.Timestamp.toObject(message.endTime, options); + if (message.index != null && message.hasOwnProperty("index")) + object.index = message.index; + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.firestore.admin.v1.OperationState[message.state] : message.state; + if (message.progressDocuments != null && message.hasOwnProperty("progressDocuments")) + object.progressDocuments = $root.google.firestore.admin.v1.Progress.toObject(message.progressDocuments, options); + if (message.progressBytes != null && message.hasOwnProperty("progressBytes")) + object.progressBytes = $root.google.firestore.admin.v1.Progress.toObject(message.progressBytes, options); + return object; + }; + + /** + * Converts this IndexOperationMetadata to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.IndexOperationMetadata + * @instance + * @returns {Object.} JSON object + */ + IndexOperationMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return IndexOperationMetadata; + })(); + + v1.FieldOperationMetadata = (function() { + + /** + * Properties of a FieldOperationMetadata. + * @memberof google.firestore.admin.v1 + * @interface IFieldOperationMetadata + * @property {google.protobuf.ITimestamp|null} [startTime] FieldOperationMetadata startTime + * @property {google.protobuf.ITimestamp|null} [endTime] FieldOperationMetadata endTime + * @property {string|null} [field] FieldOperationMetadata field + * @property {Array.|null} [indexConfigDeltas] FieldOperationMetadata indexConfigDeltas + * @property {google.firestore.admin.v1.OperationState|null} [state] FieldOperationMetadata state + * @property {google.firestore.admin.v1.IProgress|null} [progressDocuments] FieldOperationMetadata progressDocuments + * @property {google.firestore.admin.v1.IProgress|null} [progressBytes] FieldOperationMetadata progressBytes + */ + + /** + * Constructs a new FieldOperationMetadata. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a FieldOperationMetadata. + * @implements IFieldOperationMetadata + * @constructor + * @param {google.firestore.admin.v1.IFieldOperationMetadata=} [properties] Properties to set + */ + function FieldOperationMetadata(properties) { + this.indexConfigDeltas = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldOperationMetadata startTime. + * @member {google.protobuf.ITimestamp|null|undefined} startTime + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @instance + */ + FieldOperationMetadata.prototype.startTime = null; + + /** + * FieldOperationMetadata endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @instance + */ + FieldOperationMetadata.prototype.endTime = null; + + /** + * FieldOperationMetadata field. + * @member {string} field + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @instance + */ + FieldOperationMetadata.prototype.field = ""; + + /** + * FieldOperationMetadata indexConfigDeltas. + * @member {Array.} indexConfigDeltas + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @instance + */ + FieldOperationMetadata.prototype.indexConfigDeltas = $util.emptyArray; + + /** + * FieldOperationMetadata state. + * @member {google.firestore.admin.v1.OperationState} state + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @instance + */ + FieldOperationMetadata.prototype.state = 0; + + /** + * FieldOperationMetadata progressDocuments. + * @member {google.firestore.admin.v1.IProgress|null|undefined} progressDocuments + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @instance + */ + FieldOperationMetadata.prototype.progressDocuments = null; + + /** + * FieldOperationMetadata progressBytes. + * @member {google.firestore.admin.v1.IProgress|null|undefined} progressBytes + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @instance + */ + FieldOperationMetadata.prototype.progressBytes = null; + + /** + * Creates a FieldOperationMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.FieldOperationMetadata} FieldOperationMetadata + */ + FieldOperationMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.FieldOperationMetadata) + return object; + var message = new $root.google.firestore.admin.v1.FieldOperationMetadata(); + if (object.startTime != null) { + if (typeof object.startTime !== "object") + throw TypeError(".google.firestore.admin.v1.FieldOperationMetadata.startTime: object expected"); + message.startTime = $root.google.protobuf.Timestamp.fromObject(object.startTime); + } + if (object.endTime != null) { + if (typeof object.endTime !== "object") + throw TypeError(".google.firestore.admin.v1.FieldOperationMetadata.endTime: object expected"); + message.endTime = $root.google.protobuf.Timestamp.fromObject(object.endTime); + } + if (object.field != null) + message.field = String(object.field); + if (object.indexConfigDeltas) { + if (!Array.isArray(object.indexConfigDeltas)) + throw TypeError(".google.firestore.admin.v1.FieldOperationMetadata.indexConfigDeltas: array expected"); + message.indexConfigDeltas = []; + for (var i = 0; i < object.indexConfigDeltas.length; ++i) { + if (typeof object.indexConfigDeltas[i] !== "object") + throw TypeError(".google.firestore.admin.v1.FieldOperationMetadata.indexConfigDeltas: object expected"); + message.indexConfigDeltas[i] = $root.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.fromObject(object.indexConfigDeltas[i]); + } + } + switch (object.state) { + case "OPERATION_STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "INITIALIZING": + case 1: + message.state = 1; + break; + case "PROCESSING": + case 2: + message.state = 2; + break; + case "CANCELLING": + case 3: + message.state = 3; + break; + case "FINALIZING": + case 4: + message.state = 4; + break; + case "SUCCESSFUL": + case 5: + message.state = 5; + break; + case "FAILED": + case 6: + message.state = 6; + break; + case "CANCELLED": + case 7: + message.state = 7; + break; + } + if (object.progressDocuments != null) { + if (typeof object.progressDocuments !== "object") + throw TypeError(".google.firestore.admin.v1.FieldOperationMetadata.progressDocuments: object expected"); + message.progressDocuments = $root.google.firestore.admin.v1.Progress.fromObject(object.progressDocuments); + } + if (object.progressBytes != null) { + if (typeof object.progressBytes !== "object") + throw TypeError(".google.firestore.admin.v1.FieldOperationMetadata.progressBytes: object expected"); + message.progressBytes = $root.google.firestore.admin.v1.Progress.fromObject(object.progressBytes); + } + return message; + }; + + /** + * Creates a plain object from a FieldOperationMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @static + * @param {google.firestore.admin.v1.FieldOperationMetadata} message FieldOperationMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldOperationMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.indexConfigDeltas = []; + if (options.defaults) { + object.startTime = null; + object.endTime = null; + object.field = ""; + object.state = options.enums === String ? "OPERATION_STATE_UNSPECIFIED" : 0; + object.progressDocuments = null; + object.progressBytes = null; + } + if (message.startTime != null && message.hasOwnProperty("startTime")) + object.startTime = $root.google.protobuf.Timestamp.toObject(message.startTime, options); + if (message.endTime != null && message.hasOwnProperty("endTime")) + object.endTime = $root.google.protobuf.Timestamp.toObject(message.endTime, options); + if (message.field != null && message.hasOwnProperty("field")) + object.field = message.field; + if (message.indexConfigDeltas && message.indexConfigDeltas.length) { + object.indexConfigDeltas = []; + for (var j = 0; j < message.indexConfigDeltas.length; ++j) + object.indexConfigDeltas[j] = $root.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.toObject(message.indexConfigDeltas[j], options); + } + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.firestore.admin.v1.OperationState[message.state] : message.state; + if (message.progressDocuments != null && message.hasOwnProperty("progressDocuments")) + object.progressDocuments = $root.google.firestore.admin.v1.Progress.toObject(message.progressDocuments, options); + if (message.progressBytes != null && message.hasOwnProperty("progressBytes")) + object.progressBytes = $root.google.firestore.admin.v1.Progress.toObject(message.progressBytes, options); + return object; + }; + + /** + * Converts this FieldOperationMetadata to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @instance + * @returns {Object.} JSON object + */ + FieldOperationMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + FieldOperationMetadata.IndexConfigDelta = (function() { + + /** + * Properties of an IndexConfigDelta. + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @interface IIndexConfigDelta + * @property {google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType|null} [changeType] IndexConfigDelta changeType + * @property {google.firestore.admin.v1.IIndex|null} [index] IndexConfigDelta index + */ + + /** + * Constructs a new IndexConfigDelta. + * @memberof google.firestore.admin.v1.FieldOperationMetadata + * @classdesc Represents an IndexConfigDelta. + * @implements IIndexConfigDelta + * @constructor + * @param {google.firestore.admin.v1.FieldOperationMetadata.IIndexConfigDelta=} [properties] Properties to set + */ + function IndexConfigDelta(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * IndexConfigDelta changeType. + * @member {google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType} changeType + * @memberof google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + * @instance + */ + IndexConfigDelta.prototype.changeType = 0; + + /** + * IndexConfigDelta index. + * @member {google.firestore.admin.v1.IIndex|null|undefined} index + * @memberof google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + * @instance + */ + IndexConfigDelta.prototype.index = null; + + /** + * Creates an IndexConfigDelta message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta} IndexConfigDelta + */ + IndexConfigDelta.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta) + return object; + var message = new $root.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta(); + switch (object.changeType) { + case "CHANGE_TYPE_UNSPECIFIED": + case 0: + message.changeType = 0; + break; + case "ADD": + case 1: + message.changeType = 1; + break; + case "REMOVE": + case 2: + message.changeType = 2; + break; + } + if (object.index != null) { + if (typeof object.index !== "object") + throw TypeError(".google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.index: object expected"); + message.index = $root.google.firestore.admin.v1.Index.fromObject(object.index); + } + return message; + }; + + /** + * Creates a plain object from an IndexConfigDelta message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + * @static + * @param {google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta} message IndexConfigDelta + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + IndexConfigDelta.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.changeType = options.enums === String ? "CHANGE_TYPE_UNSPECIFIED" : 0; + object.index = null; + } + if (message.changeType != null && message.hasOwnProperty("changeType")) + object.changeType = options.enums === String ? $root.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType[message.changeType] : message.changeType; + if (message.index != null && message.hasOwnProperty("index")) + object.index = $root.google.firestore.admin.v1.Index.toObject(message.index, options); + return object; + }; + + /** + * Converts this IndexConfigDelta to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + * @instance + * @returns {Object.} JSON object + */ + IndexConfigDelta.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * ChangeType enum. + * @name google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType + * @enum {string} + * @property {string} CHANGE_TYPE_UNSPECIFIED=CHANGE_TYPE_UNSPECIFIED CHANGE_TYPE_UNSPECIFIED value + * @property {string} ADD=ADD ADD value + * @property {string} REMOVE=REMOVE REMOVE value + */ + IndexConfigDelta.ChangeType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "CHANGE_TYPE_UNSPECIFIED"] = "CHANGE_TYPE_UNSPECIFIED"; + values[valuesById[1] = "ADD"] = "ADD"; + values[valuesById[2] = "REMOVE"] = "REMOVE"; + return values; + })(); + + return IndexConfigDelta; + })(); + + return FieldOperationMetadata; + })(); + + v1.ExportDocumentsMetadata = (function() { + + /** + * Properties of an ExportDocumentsMetadata. + * @memberof google.firestore.admin.v1 + * @interface IExportDocumentsMetadata + * @property {google.protobuf.ITimestamp|null} [startTime] ExportDocumentsMetadata startTime + * @property {google.protobuf.ITimestamp|null} [endTime] ExportDocumentsMetadata endTime + * @property {google.firestore.admin.v1.OperationState|null} [operationState] ExportDocumentsMetadata operationState + * @property {google.firestore.admin.v1.IProgress|null} [progressDocuments] ExportDocumentsMetadata progressDocuments + * @property {google.firestore.admin.v1.IProgress|null} [progressBytes] ExportDocumentsMetadata progressBytes + * @property {Array.|null} [collectionIds] ExportDocumentsMetadata collectionIds + * @property {string|null} [outputUriPrefix] ExportDocumentsMetadata outputUriPrefix + */ + + /** + * Constructs a new ExportDocumentsMetadata. + * @memberof google.firestore.admin.v1 + * @classdesc Represents an ExportDocumentsMetadata. + * @implements IExportDocumentsMetadata + * @constructor + * @param {google.firestore.admin.v1.IExportDocumentsMetadata=} [properties] Properties to set + */ + function ExportDocumentsMetadata(properties) { + this.collectionIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExportDocumentsMetadata startTime. + * @member {google.protobuf.ITimestamp|null|undefined} startTime + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @instance + */ + ExportDocumentsMetadata.prototype.startTime = null; + + /** + * ExportDocumentsMetadata endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @instance + */ + ExportDocumentsMetadata.prototype.endTime = null; + + /** + * ExportDocumentsMetadata operationState. + * @member {google.firestore.admin.v1.OperationState} operationState + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @instance + */ + ExportDocumentsMetadata.prototype.operationState = 0; + + /** + * ExportDocumentsMetadata progressDocuments. + * @member {google.firestore.admin.v1.IProgress|null|undefined} progressDocuments + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @instance + */ + ExportDocumentsMetadata.prototype.progressDocuments = null; + + /** + * ExportDocumentsMetadata progressBytes. + * @member {google.firestore.admin.v1.IProgress|null|undefined} progressBytes + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @instance + */ + ExportDocumentsMetadata.prototype.progressBytes = null; + + /** + * ExportDocumentsMetadata collectionIds. + * @member {Array.} collectionIds + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @instance + */ + ExportDocumentsMetadata.prototype.collectionIds = $util.emptyArray; + + /** + * ExportDocumentsMetadata outputUriPrefix. + * @member {string} outputUriPrefix + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @instance + */ + ExportDocumentsMetadata.prototype.outputUriPrefix = ""; + + /** + * Creates an ExportDocumentsMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.ExportDocumentsMetadata} ExportDocumentsMetadata + */ + ExportDocumentsMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.ExportDocumentsMetadata) + return object; + var message = new $root.google.firestore.admin.v1.ExportDocumentsMetadata(); + if (object.startTime != null) { + if (typeof object.startTime !== "object") + throw TypeError(".google.firestore.admin.v1.ExportDocumentsMetadata.startTime: object expected"); + message.startTime = $root.google.protobuf.Timestamp.fromObject(object.startTime); + } + if (object.endTime != null) { + if (typeof object.endTime !== "object") + throw TypeError(".google.firestore.admin.v1.ExportDocumentsMetadata.endTime: object expected"); + message.endTime = $root.google.protobuf.Timestamp.fromObject(object.endTime); + } + switch (object.operationState) { + case "OPERATION_STATE_UNSPECIFIED": + case 0: + message.operationState = 0; + break; + case "INITIALIZING": + case 1: + message.operationState = 1; + break; + case "PROCESSING": + case 2: + message.operationState = 2; + break; + case "CANCELLING": + case 3: + message.operationState = 3; + break; + case "FINALIZING": + case 4: + message.operationState = 4; + break; + case "SUCCESSFUL": + case 5: + message.operationState = 5; + break; + case "FAILED": + case 6: + message.operationState = 6; + break; + case "CANCELLED": + case 7: + message.operationState = 7; + break; + } + if (object.progressDocuments != null) { + if (typeof object.progressDocuments !== "object") + throw TypeError(".google.firestore.admin.v1.ExportDocumentsMetadata.progressDocuments: object expected"); + message.progressDocuments = $root.google.firestore.admin.v1.Progress.fromObject(object.progressDocuments); + } + if (object.progressBytes != null) { + if (typeof object.progressBytes !== "object") + throw TypeError(".google.firestore.admin.v1.ExportDocumentsMetadata.progressBytes: object expected"); + message.progressBytes = $root.google.firestore.admin.v1.Progress.fromObject(object.progressBytes); + } + if (object.collectionIds) { + if (!Array.isArray(object.collectionIds)) + throw TypeError(".google.firestore.admin.v1.ExportDocumentsMetadata.collectionIds: array expected"); + message.collectionIds = []; + for (var i = 0; i < object.collectionIds.length; ++i) + message.collectionIds[i] = String(object.collectionIds[i]); + } + if (object.outputUriPrefix != null) + message.outputUriPrefix = String(object.outputUriPrefix); + return message; + }; + + /** + * Creates a plain object from an ExportDocumentsMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @static + * @param {google.firestore.admin.v1.ExportDocumentsMetadata} message ExportDocumentsMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExportDocumentsMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.collectionIds = []; + if (options.defaults) { + object.startTime = null; + object.endTime = null; + object.operationState = options.enums === String ? "OPERATION_STATE_UNSPECIFIED" : 0; + object.progressDocuments = null; + object.progressBytes = null; + object.outputUriPrefix = ""; + } + if (message.startTime != null && message.hasOwnProperty("startTime")) + object.startTime = $root.google.protobuf.Timestamp.toObject(message.startTime, options); + if (message.endTime != null && message.hasOwnProperty("endTime")) + object.endTime = $root.google.protobuf.Timestamp.toObject(message.endTime, options); + if (message.operationState != null && message.hasOwnProperty("operationState")) + object.operationState = options.enums === String ? $root.google.firestore.admin.v1.OperationState[message.operationState] : message.operationState; + if (message.progressDocuments != null && message.hasOwnProperty("progressDocuments")) + object.progressDocuments = $root.google.firestore.admin.v1.Progress.toObject(message.progressDocuments, options); + if (message.progressBytes != null && message.hasOwnProperty("progressBytes")) + object.progressBytes = $root.google.firestore.admin.v1.Progress.toObject(message.progressBytes, options); + if (message.collectionIds && message.collectionIds.length) { + object.collectionIds = []; + for (var j = 0; j < message.collectionIds.length; ++j) + object.collectionIds[j] = message.collectionIds[j]; + } + if (message.outputUriPrefix != null && message.hasOwnProperty("outputUriPrefix")) + object.outputUriPrefix = message.outputUriPrefix; + return object; + }; + + /** + * Converts this ExportDocumentsMetadata to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.ExportDocumentsMetadata + * @instance + * @returns {Object.} JSON object + */ + ExportDocumentsMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ExportDocumentsMetadata; + })(); + + v1.ImportDocumentsMetadata = (function() { + + /** + * Properties of an ImportDocumentsMetadata. + * @memberof google.firestore.admin.v1 + * @interface IImportDocumentsMetadata + * @property {google.protobuf.ITimestamp|null} [startTime] ImportDocumentsMetadata startTime + * @property {google.protobuf.ITimestamp|null} [endTime] ImportDocumentsMetadata endTime + * @property {google.firestore.admin.v1.OperationState|null} [operationState] ImportDocumentsMetadata operationState + * @property {google.firestore.admin.v1.IProgress|null} [progressDocuments] ImportDocumentsMetadata progressDocuments + * @property {google.firestore.admin.v1.IProgress|null} [progressBytes] ImportDocumentsMetadata progressBytes + * @property {Array.|null} [collectionIds] ImportDocumentsMetadata collectionIds + * @property {string|null} [inputUriPrefix] ImportDocumentsMetadata inputUriPrefix + */ + + /** + * Constructs a new ImportDocumentsMetadata. + * @memberof google.firestore.admin.v1 + * @classdesc Represents an ImportDocumentsMetadata. + * @implements IImportDocumentsMetadata + * @constructor + * @param {google.firestore.admin.v1.IImportDocumentsMetadata=} [properties] Properties to set + */ + function ImportDocumentsMetadata(properties) { + this.collectionIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ImportDocumentsMetadata startTime. + * @member {google.protobuf.ITimestamp|null|undefined} startTime + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @instance + */ + ImportDocumentsMetadata.prototype.startTime = null; + + /** + * ImportDocumentsMetadata endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @instance + */ + ImportDocumentsMetadata.prototype.endTime = null; + + /** + * ImportDocumentsMetadata operationState. + * @member {google.firestore.admin.v1.OperationState} operationState + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @instance + */ + ImportDocumentsMetadata.prototype.operationState = 0; + + /** + * ImportDocumentsMetadata progressDocuments. + * @member {google.firestore.admin.v1.IProgress|null|undefined} progressDocuments + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @instance + */ + ImportDocumentsMetadata.prototype.progressDocuments = null; + + /** + * ImportDocumentsMetadata progressBytes. + * @member {google.firestore.admin.v1.IProgress|null|undefined} progressBytes + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @instance + */ + ImportDocumentsMetadata.prototype.progressBytes = null; + + /** + * ImportDocumentsMetadata collectionIds. + * @member {Array.} collectionIds + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @instance + */ + ImportDocumentsMetadata.prototype.collectionIds = $util.emptyArray; + + /** + * ImportDocumentsMetadata inputUriPrefix. + * @member {string} inputUriPrefix + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @instance + */ + ImportDocumentsMetadata.prototype.inputUriPrefix = ""; + + /** + * Creates an ImportDocumentsMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.ImportDocumentsMetadata} ImportDocumentsMetadata + */ + ImportDocumentsMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.ImportDocumentsMetadata) + return object; + var message = new $root.google.firestore.admin.v1.ImportDocumentsMetadata(); + if (object.startTime != null) { + if (typeof object.startTime !== "object") + throw TypeError(".google.firestore.admin.v1.ImportDocumentsMetadata.startTime: object expected"); + message.startTime = $root.google.protobuf.Timestamp.fromObject(object.startTime); + } + if (object.endTime != null) { + if (typeof object.endTime !== "object") + throw TypeError(".google.firestore.admin.v1.ImportDocumentsMetadata.endTime: object expected"); + message.endTime = $root.google.protobuf.Timestamp.fromObject(object.endTime); + } + switch (object.operationState) { + case "OPERATION_STATE_UNSPECIFIED": + case 0: + message.operationState = 0; + break; + case "INITIALIZING": + case 1: + message.operationState = 1; + break; + case "PROCESSING": + case 2: + message.operationState = 2; + break; + case "CANCELLING": + case 3: + message.operationState = 3; + break; + case "FINALIZING": + case 4: + message.operationState = 4; + break; + case "SUCCESSFUL": + case 5: + message.operationState = 5; + break; + case "FAILED": + case 6: + message.operationState = 6; + break; + case "CANCELLED": + case 7: + message.operationState = 7; + break; + } + if (object.progressDocuments != null) { + if (typeof object.progressDocuments !== "object") + throw TypeError(".google.firestore.admin.v1.ImportDocumentsMetadata.progressDocuments: object expected"); + message.progressDocuments = $root.google.firestore.admin.v1.Progress.fromObject(object.progressDocuments); + } + if (object.progressBytes != null) { + if (typeof object.progressBytes !== "object") + throw TypeError(".google.firestore.admin.v1.ImportDocumentsMetadata.progressBytes: object expected"); + message.progressBytes = $root.google.firestore.admin.v1.Progress.fromObject(object.progressBytes); + } + if (object.collectionIds) { + if (!Array.isArray(object.collectionIds)) + throw TypeError(".google.firestore.admin.v1.ImportDocumentsMetadata.collectionIds: array expected"); + message.collectionIds = []; + for (var i = 0; i < object.collectionIds.length; ++i) + message.collectionIds[i] = String(object.collectionIds[i]); + } + if (object.inputUriPrefix != null) + message.inputUriPrefix = String(object.inputUriPrefix); + return message; + }; + + /** + * Creates a plain object from an ImportDocumentsMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @static + * @param {google.firestore.admin.v1.ImportDocumentsMetadata} message ImportDocumentsMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportDocumentsMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.collectionIds = []; + if (options.defaults) { + object.startTime = null; + object.endTime = null; + object.operationState = options.enums === String ? "OPERATION_STATE_UNSPECIFIED" : 0; + object.progressDocuments = null; + object.progressBytes = null; + object.inputUriPrefix = ""; + } + if (message.startTime != null && message.hasOwnProperty("startTime")) + object.startTime = $root.google.protobuf.Timestamp.toObject(message.startTime, options); + if (message.endTime != null && message.hasOwnProperty("endTime")) + object.endTime = $root.google.protobuf.Timestamp.toObject(message.endTime, options); + if (message.operationState != null && message.hasOwnProperty("operationState")) + object.operationState = options.enums === String ? $root.google.firestore.admin.v1.OperationState[message.operationState] : message.operationState; + if (message.progressDocuments != null && message.hasOwnProperty("progressDocuments")) + object.progressDocuments = $root.google.firestore.admin.v1.Progress.toObject(message.progressDocuments, options); + if (message.progressBytes != null && message.hasOwnProperty("progressBytes")) + object.progressBytes = $root.google.firestore.admin.v1.Progress.toObject(message.progressBytes, options); + if (message.collectionIds && message.collectionIds.length) { + object.collectionIds = []; + for (var j = 0; j < message.collectionIds.length; ++j) + object.collectionIds[j] = message.collectionIds[j]; + } + if (message.inputUriPrefix != null && message.hasOwnProperty("inputUriPrefix")) + object.inputUriPrefix = message.inputUriPrefix; + return object; + }; + + /** + * Converts this ImportDocumentsMetadata to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.ImportDocumentsMetadata + * @instance + * @returns {Object.} JSON object + */ + ImportDocumentsMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ImportDocumentsMetadata; + })(); + + v1.ExportDocumentsResponse = (function() { + + /** + * Properties of an ExportDocumentsResponse. + * @memberof google.firestore.admin.v1 + * @interface IExportDocumentsResponse + * @property {string|null} [outputUriPrefix] ExportDocumentsResponse outputUriPrefix + */ + + /** + * Constructs a new ExportDocumentsResponse. + * @memberof google.firestore.admin.v1 + * @classdesc Represents an ExportDocumentsResponse. + * @implements IExportDocumentsResponse + * @constructor + * @param {google.firestore.admin.v1.IExportDocumentsResponse=} [properties] Properties to set + */ + function ExportDocumentsResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExportDocumentsResponse outputUriPrefix. + * @member {string} outputUriPrefix + * @memberof google.firestore.admin.v1.ExportDocumentsResponse + * @instance + */ + ExportDocumentsResponse.prototype.outputUriPrefix = ""; + + /** + * Creates an ExportDocumentsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.ExportDocumentsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.ExportDocumentsResponse} ExportDocumentsResponse + */ + ExportDocumentsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.ExportDocumentsResponse) + return object; + var message = new $root.google.firestore.admin.v1.ExportDocumentsResponse(); + if (object.outputUriPrefix != null) + message.outputUriPrefix = String(object.outputUriPrefix); + return message; + }; + + /** + * Creates a plain object from an ExportDocumentsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.ExportDocumentsResponse + * @static + * @param {google.firestore.admin.v1.ExportDocumentsResponse} message ExportDocumentsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExportDocumentsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.outputUriPrefix = ""; + if (message.outputUriPrefix != null && message.hasOwnProperty("outputUriPrefix")) + object.outputUriPrefix = message.outputUriPrefix; + return object; + }; + + /** + * Converts this ExportDocumentsResponse to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.ExportDocumentsResponse + * @instance + * @returns {Object.} JSON object + */ + ExportDocumentsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ExportDocumentsResponse; + })(); + + v1.Progress = (function() { + + /** + * Properties of a Progress. + * @memberof google.firestore.admin.v1 + * @interface IProgress + * @property {number|string|null} [estimatedWork] Progress estimatedWork + * @property {number|string|null} [completedWork] Progress completedWork + */ + + /** + * Constructs a new Progress. + * @memberof google.firestore.admin.v1 + * @classdesc Represents a Progress. + * @implements IProgress + * @constructor + * @param {google.firestore.admin.v1.IProgress=} [properties] Properties to set + */ + function Progress(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Progress estimatedWork. + * @member {number|string} estimatedWork + * @memberof google.firestore.admin.v1.Progress + * @instance + */ + Progress.prototype.estimatedWork = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Progress completedWork. + * @member {number|string} completedWork + * @memberof google.firestore.admin.v1.Progress + * @instance + */ + Progress.prototype.completedWork = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a Progress message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.admin.v1.Progress + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.admin.v1.Progress} Progress + */ + Progress.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.admin.v1.Progress) + return object; + var message = new $root.google.firestore.admin.v1.Progress(); + if (object.estimatedWork != null) + if ($util.Long) + (message.estimatedWork = $util.Long.fromValue(object.estimatedWork)).unsigned = false; + else if (typeof object.estimatedWork === "string") + message.estimatedWork = parseInt(object.estimatedWork, 10); + else if (typeof object.estimatedWork === "number") + message.estimatedWork = object.estimatedWork; + else if (typeof object.estimatedWork === "object") + message.estimatedWork = new $util.LongBits(object.estimatedWork.low >>> 0, object.estimatedWork.high >>> 0).toNumber(); + if (object.completedWork != null) + if ($util.Long) + (message.completedWork = $util.Long.fromValue(object.completedWork)).unsigned = false; + else if (typeof object.completedWork === "string") + message.completedWork = parseInt(object.completedWork, 10); + else if (typeof object.completedWork === "number") + message.completedWork = object.completedWork; + else if (typeof object.completedWork === "object") + message.completedWork = new $util.LongBits(object.completedWork.low >>> 0, object.completedWork.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a Progress message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.admin.v1.Progress + * @static + * @param {google.firestore.admin.v1.Progress} message Progress + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Progress.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.estimatedWork = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.estimatedWork = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.completedWork = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.completedWork = options.longs === String ? "0" : 0; + } + if (message.estimatedWork != null && message.hasOwnProperty("estimatedWork")) + if (typeof message.estimatedWork === "number") + object.estimatedWork = options.longs === String ? String(message.estimatedWork) : message.estimatedWork; + else + object.estimatedWork = options.longs === String ? $util.Long.prototype.toString.call(message.estimatedWork) : options.longs === Number ? new $util.LongBits(message.estimatedWork.low >>> 0, message.estimatedWork.high >>> 0).toNumber() : message.estimatedWork; + if (message.completedWork != null && message.hasOwnProperty("completedWork")) + if (typeof message.completedWork === "number") + object.completedWork = options.longs === String ? String(message.completedWork) : message.completedWork; + else + object.completedWork = options.longs === String ? $util.Long.prototype.toString.call(message.completedWork) : options.longs === Number ? new $util.LongBits(message.completedWork.low >>> 0, message.completedWork.high >>> 0).toNumber() : message.completedWork; + return object; + }; + + /** + * Converts this Progress to JSON. + * @function toJSON + * @memberof google.firestore.admin.v1.Progress + * @instance + * @returns {Object.} JSON object + */ + Progress.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Progress; + })(); + + /** + * OperationState enum. + * @name google.firestore.admin.v1.OperationState + * @enum {string} + * @property {string} OPERATION_STATE_UNSPECIFIED=OPERATION_STATE_UNSPECIFIED OPERATION_STATE_UNSPECIFIED value + * @property {string} INITIALIZING=INITIALIZING INITIALIZING value + * @property {string} PROCESSING=PROCESSING PROCESSING value + * @property {string} CANCELLING=CANCELLING CANCELLING value + * @property {string} FINALIZING=FINALIZING FINALIZING value + * @property {string} SUCCESSFUL=SUCCESSFUL SUCCESSFUL value + * @property {string} FAILED=FAILED FAILED value + * @property {string} CANCELLED=CANCELLED CANCELLED value + */ + v1.OperationState = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATION_STATE_UNSPECIFIED"] = "OPERATION_STATE_UNSPECIFIED"; + values[valuesById[1] = "INITIALIZING"] = "INITIALIZING"; + values[valuesById[2] = "PROCESSING"] = "PROCESSING"; + values[valuesById[3] = "CANCELLING"] = "CANCELLING"; + values[valuesById[4] = "FINALIZING"] = "FINALIZING"; + values[valuesById[5] = "SUCCESSFUL"] = "SUCCESSFUL"; + values[valuesById[6] = "FAILED"] = "FAILED"; + values[valuesById[7] = "CANCELLED"] = "CANCELLED"; + return values; + })(); + + return v1; + })(); + + return admin; + })(); + + return firestore; })(); - - longrunning.ListOperationsResponse = (function() { - - /** - * Properties of a ListOperationsResponse. - * @memberof google.longrunning - * @interface IListOperationsResponse - * @property {Array.|null} [operations] ListOperationsResponse operations - * @property {string|null} [nextPageToken] ListOperationsResponse nextPageToken - */ - - /** - * Constructs a new ListOperationsResponse. - * @memberof google.longrunning - * @classdesc Represents a ListOperationsResponse. - * @implements IListOperationsResponse - * @constructor - * @param {google.longrunning.IListOperationsResponse=} [properties] Properties to set - */ - function ListOperationsResponse(properties) { - this.operations = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListOperationsResponse operations. - * @member {Array.} operations - * @memberof google.longrunning.ListOperationsResponse - * @instance - */ - ListOperationsResponse.prototype.operations = $util.emptyArray; - + + google.api = (function() { + /** - * ListOperationsResponse nextPageToken. - * @member {string} nextPageToken - * @memberof google.longrunning.ListOperationsResponse - * @instance + * Namespace api. + * @memberof google + * @namespace */ - ListOperationsResponse.prototype.nextPageToken = ""; - - return ListOperationsResponse; + var api = {}; + + api.Http = (function() { + + /** + * Properties of a Http. + * @memberof google.api + * @interface IHttp + * @property {Array.|null} [rules] Http rules + */ + + /** + * Constructs a new Http. + * @memberof google.api + * @classdesc Represents a Http. + * @implements IHttp + * @constructor + * @param {google.api.IHttp=} [properties] Properties to set + */ + function Http(properties) { + this.rules = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Http rules. + * @member {Array.} rules + * @memberof google.api.Http + * @instance + */ + Http.prototype.rules = $util.emptyArray; + + /** + * Creates a Http message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.Http + * @static + * @param {Object.} object Plain object + * @returns {google.api.Http} Http + */ + Http.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.Http) + return object; + var message = new $root.google.api.Http(); + if (object.rules) { + if (!Array.isArray(object.rules)) + throw TypeError(".google.api.Http.rules: array expected"); + message.rules = []; + for (var i = 0; i < object.rules.length; ++i) { + if (typeof object.rules[i] !== "object") + throw TypeError(".google.api.Http.rules: object expected"); + message.rules[i] = $root.google.api.HttpRule.fromObject(object.rules[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Http message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.Http + * @static + * @param {google.api.Http} message Http + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Http.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.rules = []; + if (message.rules && message.rules.length) { + object.rules = []; + for (var j = 0; j < message.rules.length; ++j) + object.rules[j] = $root.google.api.HttpRule.toObject(message.rules[j], options); + } + return object; + }; + + /** + * Converts this Http to JSON. + * @function toJSON + * @memberof google.api.Http + * @instance + * @returns {Object.} JSON object + */ + Http.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Http; + })(); + + api.HttpRule = (function() { + + /** + * Properties of a HttpRule. + * @memberof google.api + * @interface IHttpRule + * @property {string|null} [get] HttpRule get + * @property {string|null} [put] HttpRule put + * @property {string|null} [post] HttpRule post + * @property {string|null} ["delete"] HttpRule delete + * @property {string|null} [patch] HttpRule patch + * @property {google.api.ICustomHttpPattern|null} [custom] HttpRule custom + * @property {string|null} [selector] HttpRule selector + * @property {string|null} [body] HttpRule body + * @property {Array.|null} [additionalBindings] HttpRule additionalBindings + */ + + /** + * Constructs a new HttpRule. + * @memberof google.api + * @classdesc Represents a HttpRule. + * @implements IHttpRule + * @constructor + * @param {google.api.IHttpRule=} [properties] Properties to set + */ + function HttpRule(properties) { + this.additionalBindings = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * HttpRule get. + * @member {string} get + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.get = ""; + + /** + * HttpRule put. + * @member {string} put + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.put = ""; + + /** + * HttpRule post. + * @member {string} post + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.post = ""; + + /** + * HttpRule delete. + * @member {string} delete + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype["delete"] = ""; + + /** + * HttpRule patch. + * @member {string} patch + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.patch = ""; + + /** + * HttpRule custom. + * @member {google.api.ICustomHttpPattern|null|undefined} custom + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.custom = null; + + /** + * HttpRule selector. + * @member {string} selector + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.selector = ""; + + /** + * HttpRule body. + * @member {string} body + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.body = ""; + + /** + * HttpRule additionalBindings. + * @member {Array.} additionalBindings + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.additionalBindings = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * HttpRule pattern. + * @member {"get"|"put"|"post"|"delete"|"patch"|"custom"|undefined} pattern + * @memberof google.api.HttpRule + * @instance + */ + Object.defineProperty(HttpRule.prototype, "pattern", { + get: $util.oneOfGetter($oneOfFields = ["get", "put", "post", "delete", "patch", "custom"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a HttpRule message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.HttpRule + * @static + * @param {Object.} object Plain object + * @returns {google.api.HttpRule} HttpRule + */ + HttpRule.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.HttpRule) + return object; + var message = new $root.google.api.HttpRule(); + if (object.get != null) + message.get = String(object.get); + if (object.put != null) + message.put = String(object.put); + if (object.post != null) + message.post = String(object.post); + if (object["delete"] != null) + message["delete"] = String(object["delete"]); + if (object.patch != null) + message.patch = String(object.patch); + if (object.custom != null) { + if (typeof object.custom !== "object") + throw TypeError(".google.api.HttpRule.custom: object expected"); + message.custom = $root.google.api.CustomHttpPattern.fromObject(object.custom); + } + if (object.selector != null) + message.selector = String(object.selector); + if (object.body != null) + message.body = String(object.body); + if (object.additionalBindings) { + if (!Array.isArray(object.additionalBindings)) + throw TypeError(".google.api.HttpRule.additionalBindings: array expected"); + message.additionalBindings = []; + for (var i = 0; i < object.additionalBindings.length; ++i) { + if (typeof object.additionalBindings[i] !== "object") + throw TypeError(".google.api.HttpRule.additionalBindings: object expected"); + message.additionalBindings[i] = $root.google.api.HttpRule.fromObject(object.additionalBindings[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a HttpRule message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.HttpRule + * @static + * @param {google.api.HttpRule} message HttpRule + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HttpRule.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.additionalBindings = []; + if (options.defaults) { + object.selector = ""; + object.body = ""; + } + if (message.selector != null && message.hasOwnProperty("selector")) + object.selector = message.selector; + if (message.get != null && message.hasOwnProperty("get")) { + object.get = message.get; + if (options.oneofs) + object.pattern = "get"; + } + if (message.put != null && message.hasOwnProperty("put")) { + object.put = message.put; + if (options.oneofs) + object.pattern = "put"; + } + if (message.post != null && message.hasOwnProperty("post")) { + object.post = message.post; + if (options.oneofs) + object.pattern = "post"; + } + if (message["delete"] != null && message.hasOwnProperty("delete")) { + object["delete"] = message["delete"]; + if (options.oneofs) + object.pattern = "delete"; + } + if (message.patch != null && message.hasOwnProperty("patch")) { + object.patch = message.patch; + if (options.oneofs) + object.pattern = "patch"; + } + if (message.body != null && message.hasOwnProperty("body")) + object.body = message.body; + if (message.custom != null && message.hasOwnProperty("custom")) { + object.custom = $root.google.api.CustomHttpPattern.toObject(message.custom, options); + if (options.oneofs) + object.pattern = "custom"; + } + if (message.additionalBindings && message.additionalBindings.length) { + object.additionalBindings = []; + for (var j = 0; j < message.additionalBindings.length; ++j) + object.additionalBindings[j] = $root.google.api.HttpRule.toObject(message.additionalBindings[j], options); + } + return object; + }; + + /** + * Converts this HttpRule to JSON. + * @function toJSON + * @memberof google.api.HttpRule + * @instance + * @returns {Object.} JSON object + */ + HttpRule.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return HttpRule; + })(); + + api.CustomHttpPattern = (function() { + + /** + * Properties of a CustomHttpPattern. + * @memberof google.api + * @interface ICustomHttpPattern + * @property {string|null} [kind] CustomHttpPattern kind + * @property {string|null} [path] CustomHttpPattern path + */ + + /** + * Constructs a new CustomHttpPattern. + * @memberof google.api + * @classdesc Represents a CustomHttpPattern. + * @implements ICustomHttpPattern + * @constructor + * @param {google.api.ICustomHttpPattern=} [properties] Properties to set + */ + function CustomHttpPattern(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CustomHttpPattern kind. + * @member {string} kind + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.kind = ""; + + /** + * CustomHttpPattern path. + * @member {string} path + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.path = ""; + + /** + * Creates a CustomHttpPattern message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.CustomHttpPattern + * @static + * @param {Object.} object Plain object + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + */ + CustomHttpPattern.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.CustomHttpPattern) + return object; + var message = new $root.google.api.CustomHttpPattern(); + if (object.kind != null) + message.kind = String(object.kind); + if (object.path != null) + message.path = String(object.path); + return message; + }; + + /** + * Creates a plain object from a CustomHttpPattern message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.CustomHttpPattern} message CustomHttpPattern + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CustomHttpPattern.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.kind = ""; + object.path = ""; + } + if (message.kind != null && message.hasOwnProperty("kind")) + object.kind = message.kind; + if (message.path != null && message.hasOwnProperty("path")) + object.path = message.path; + return object; + }; + + /** + * Converts this CustomHttpPattern to JSON. + * @function toJSON + * @memberof google.api.CustomHttpPattern + * @instance + * @returns {Object.} JSON object + */ + CustomHttpPattern.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CustomHttpPattern; + })(); + + /** + * FieldBehavior enum. + * @name google.api.FieldBehavior + * @enum {string} + * @property {string} FIELD_BEHAVIOR_UNSPECIFIED=FIELD_BEHAVIOR_UNSPECIFIED FIELD_BEHAVIOR_UNSPECIFIED value + * @property {string} OPTIONAL=OPTIONAL OPTIONAL value + * @property {string} REQUIRED=REQUIRED REQUIRED value + * @property {string} OUTPUT_ONLY=OUTPUT_ONLY OUTPUT_ONLY value + * @property {string} INPUT_ONLY=INPUT_ONLY INPUT_ONLY value + * @property {string} IMMUTABLE=IMMUTABLE IMMUTABLE value + */ + api.FieldBehavior = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "FIELD_BEHAVIOR_UNSPECIFIED"] = "FIELD_BEHAVIOR_UNSPECIFIED"; + values[valuesById[1] = "OPTIONAL"] = "OPTIONAL"; + values[valuesById[2] = "REQUIRED"] = "REQUIRED"; + values[valuesById[3] = "OUTPUT_ONLY"] = "OUTPUT_ONLY"; + values[valuesById[4] = "INPUT_ONLY"] = "INPUT_ONLY"; + values[valuesById[5] = "IMMUTABLE"] = "IMMUTABLE"; + return values; + })(); + + api.ResourceDescriptor = (function() { + + /** + * Properties of a ResourceDescriptor. + * @memberof google.api + * @interface IResourceDescriptor + * @property {string|null} [type] ResourceDescriptor type + * @property {Array.|null} [pattern] ResourceDescriptor pattern + * @property {string|null} [nameField] ResourceDescriptor nameField + * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history + * @property {string|null} [plural] ResourceDescriptor plural + * @property {string|null} [singular] ResourceDescriptor singular + */ + + /** + * Constructs a new ResourceDescriptor. + * @memberof google.api + * @classdesc Represents a ResourceDescriptor. + * @implements IResourceDescriptor + * @constructor + * @param {google.api.IResourceDescriptor=} [properties] Properties to set + */ + function ResourceDescriptor(properties) { + this.pattern = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResourceDescriptor type. + * @member {string} type + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.type = ""; + + /** + * ResourceDescriptor pattern. + * @member {Array.} pattern + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.pattern = $util.emptyArray; + + /** + * ResourceDescriptor nameField. + * @member {string} nameField + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.nameField = ""; + + /** + * ResourceDescriptor history. + * @member {google.api.ResourceDescriptor.History} history + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.history = 0; + + /** + * ResourceDescriptor plural. + * @member {string} plural + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.plural = ""; + + /** + * ResourceDescriptor singular. + * @member {string} singular + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.singular = ""; + + /** + * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.ResourceDescriptor + * @static + * @param {Object.} object Plain object + * @returns {google.api.ResourceDescriptor} ResourceDescriptor + */ + ResourceDescriptor.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.ResourceDescriptor) + return object; + var message = new $root.google.api.ResourceDescriptor(); + if (object.type != null) + message.type = String(object.type); + if (object.pattern) { + if (!Array.isArray(object.pattern)) + throw TypeError(".google.api.ResourceDescriptor.pattern: array expected"); + message.pattern = []; + for (var i = 0; i < object.pattern.length; ++i) + message.pattern[i] = String(object.pattern[i]); + } + if (object.nameField != null) + message.nameField = String(object.nameField); + switch (object.history) { + case "HISTORY_UNSPECIFIED": + case 0: + message.history = 0; + break; + case "ORIGINALLY_SINGLE_PATTERN": + case 1: + message.history = 1; + break; + case "FUTURE_MULTI_PATTERN": + case 2: + message.history = 2; + break; + } + if (object.plural != null) + message.plural = String(object.plural); + if (object.singular != null) + message.singular = String(object.singular); + return message; + }; + + /** + * Creates a plain object from a ResourceDescriptor message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.ResourceDescriptor + * @static + * @param {google.api.ResourceDescriptor} message ResourceDescriptor + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResourceDescriptor.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.pattern = []; + if (options.defaults) { + object.type = ""; + object.nameField = ""; + object.history = options.enums === String ? "HISTORY_UNSPECIFIED" : 0; + object.plural = ""; + object.singular = ""; + } + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.pattern && message.pattern.length) { + object.pattern = []; + for (var j = 0; j < message.pattern.length; ++j) + object.pattern[j] = message.pattern[j]; + } + if (message.nameField != null && message.hasOwnProperty("nameField")) + object.nameField = message.nameField; + if (message.history != null && message.hasOwnProperty("history")) + object.history = options.enums === String ? $root.google.api.ResourceDescriptor.History[message.history] : message.history; + if (message.plural != null && message.hasOwnProperty("plural")) + object.plural = message.plural; + if (message.singular != null && message.hasOwnProperty("singular")) + object.singular = message.singular; + return object; + }; + + /** + * Converts this ResourceDescriptor to JSON. + * @function toJSON + * @memberof google.api.ResourceDescriptor + * @instance + * @returns {Object.} JSON object + */ + ResourceDescriptor.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * History enum. + * @name google.api.ResourceDescriptor.History + * @enum {string} + * @property {string} HISTORY_UNSPECIFIED=HISTORY_UNSPECIFIED HISTORY_UNSPECIFIED value + * @property {string} ORIGINALLY_SINGLE_PATTERN=ORIGINALLY_SINGLE_PATTERN ORIGINALLY_SINGLE_PATTERN value + * @property {string} FUTURE_MULTI_PATTERN=FUTURE_MULTI_PATTERN FUTURE_MULTI_PATTERN value + */ + ResourceDescriptor.History = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "HISTORY_UNSPECIFIED"] = "HISTORY_UNSPECIFIED"; + values[valuesById[1] = "ORIGINALLY_SINGLE_PATTERN"] = "ORIGINALLY_SINGLE_PATTERN"; + values[valuesById[2] = "FUTURE_MULTI_PATTERN"] = "FUTURE_MULTI_PATTERN"; + return values; + })(); + + return ResourceDescriptor; + })(); + + api.ResourceReference = (function() { + + /** + * Properties of a ResourceReference. + * @memberof google.api + * @interface IResourceReference + * @property {string|null} [type] ResourceReference type + * @property {string|null} [childType] ResourceReference childType + */ + + /** + * Constructs a new ResourceReference. + * @memberof google.api + * @classdesc Represents a ResourceReference. + * @implements IResourceReference + * @constructor + * @param {google.api.IResourceReference=} [properties] Properties to set + */ + function ResourceReference(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResourceReference type. + * @member {string} type + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.type = ""; + + /** + * ResourceReference childType. + * @member {string} childType + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.childType = ""; + + /** + * Creates a ResourceReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.ResourceReference + * @static + * @param {Object.} object Plain object + * @returns {google.api.ResourceReference} ResourceReference + */ + ResourceReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.ResourceReference) + return object; + var message = new $root.google.api.ResourceReference(); + if (object.type != null) + message.type = String(object.type); + if (object.childType != null) + message.childType = String(object.childType); + return message; + }; + + /** + * Creates a plain object from a ResourceReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.ResourceReference + * @static + * @param {google.api.ResourceReference} message ResourceReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResourceReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.type = ""; + object.childType = ""; + } + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.childType != null && message.hasOwnProperty("childType")) + object.childType = message.childType; + return object; + }; + + /** + * Converts this ResourceReference to JSON. + * @function toJSON + * @memberof google.api.ResourceReference + * @instance + * @returns {Object.} JSON object + */ + ResourceReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ResourceReference; + })(); + + return api; })(); - - longrunning.CancelOperationRequest = (function() { - - /** - * Properties of a CancelOperationRequest. - * @memberof google.longrunning - * @interface ICancelOperationRequest - * @property {string|null} [name] CancelOperationRequest name - */ - + + google.protobuf = (function() { + /** - * Constructs a new CancelOperationRequest. - * @memberof google.longrunning - * @classdesc Represents a CancelOperationRequest. - * @implements ICancelOperationRequest - * @constructor - * @param {google.longrunning.ICancelOperationRequest=} [properties] Properties to set + * Namespace protobuf. + * @memberof google + * @namespace */ - function CancelOperationRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - + var protobuf = {}; + + protobuf.FileDescriptorSet = (function() { + + /** + * Properties of a FileDescriptorSet. + * @memberof google.protobuf + * @interface IFileDescriptorSet + * @property {Array.|null} [file] FileDescriptorSet file + */ + + /** + * Constructs a new FileDescriptorSet. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorSet. + * @implements IFileDescriptorSet + * @constructor + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + */ + function FileDescriptorSet(properties) { + this.file = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FileDescriptorSet file. + * @member {Array.} file + * @memberof google.protobuf.FileDescriptorSet + * @instance + */ + FileDescriptorSet.prototype.file = $util.emptyArray; + + /** + * Creates a FileDescriptorSet message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + */ + FileDescriptorSet.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileDescriptorSet) + return object; + var message = new $root.google.protobuf.FileDescriptorSet(); + if (object.file) { + if (!Array.isArray(object.file)) + throw TypeError(".google.protobuf.FileDescriptorSet.file: array expected"); + message.file = []; + for (var i = 0; i < object.file.length; ++i) { + if (typeof object.file[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorSet.file: object expected"); + message.file[i] = $root.google.protobuf.FileDescriptorProto.fromObject(object.file[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a FileDescriptorSet message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.FileDescriptorSet} message FileDescriptorSet + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileDescriptorSet.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.file = []; + if (message.file && message.file.length) { + object.file = []; + for (var j = 0; j < message.file.length; ++j) + object.file[j] = $root.google.protobuf.FileDescriptorProto.toObject(message.file[j], options); + } + return object; + }; + + /** + * Converts this FileDescriptorSet to JSON. + * @function toJSON + * @memberof google.protobuf.FileDescriptorSet + * @instance + * @returns {Object.} JSON object + */ + FileDescriptorSet.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FileDescriptorSet; + })(); + + protobuf.FileDescriptorProto = (function() { + + /** + * Properties of a FileDescriptorProto. + * @memberof google.protobuf + * @interface IFileDescriptorProto + * @property {string|null} [name] FileDescriptorProto name + * @property {string|null} ["package"] FileDescriptorProto package + * @property {Array.|null} [dependency] FileDescriptorProto dependency + * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency + * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [messageType] FileDescriptorProto messageType + * @property {Array.|null} [enumType] FileDescriptorProto enumType + * @property {Array.|null} [service] FileDescriptorProto service + * @property {Array.|null} [extension] FileDescriptorProto extension + * @property {google.protobuf.IFileOptions|null} [options] FileDescriptorProto options + * @property {google.protobuf.ISourceCodeInfo|null} [sourceCodeInfo] FileDescriptorProto sourceCodeInfo + * @property {string|null} [syntax] FileDescriptorProto syntax + */ + + /** + * Constructs a new FileDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorProto. + * @implements IFileDescriptorProto + * @constructor + * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set + */ + function FileDescriptorProto(properties) { + this.dependency = []; + this.publicDependency = []; + this.weakDependency = []; + this.messageType = []; + this.enumType = []; + this.service = []; + this.extension = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FileDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.name = ""; + + /** + * FileDescriptorProto package. + * @member {string} package + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype["package"] = ""; + + /** + * FileDescriptorProto dependency. + * @member {Array.} dependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.dependency = $util.emptyArray; + + /** + * FileDescriptorProto publicDependency. + * @member {Array.} publicDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.publicDependency = $util.emptyArray; + + /** + * FileDescriptorProto weakDependency. + * @member {Array.} weakDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + + /** + * FileDescriptorProto messageType. + * @member {Array.} messageType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.messageType = $util.emptyArray; + + /** + * FileDescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.enumType = $util.emptyArray; + + /** + * FileDescriptorProto service. + * @member {Array.} service + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.service = $util.emptyArray; + + /** + * FileDescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.extension = $util.emptyArray; + + /** + * FileDescriptorProto options. + * @member {google.protobuf.IFileOptions|null|undefined} options + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.options = null; + + /** + * FileDescriptorProto sourceCodeInfo. + * @member {google.protobuf.ISourceCodeInfo|null|undefined} sourceCodeInfo + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.sourceCodeInfo = null; + + /** + * FileDescriptorProto syntax. + * @member {string} syntax + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.syntax = ""; + + /** + * Creates a FileDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + */ + FileDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileDescriptorProto) + return object; + var message = new $root.google.protobuf.FileDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object["package"] != null) + message["package"] = String(object["package"]); + if (object.dependency) { + if (!Array.isArray(object.dependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.dependency: array expected"); + message.dependency = []; + for (var i = 0; i < object.dependency.length; ++i) + message.dependency[i] = String(object.dependency[i]); + } + if (object.publicDependency) { + if (!Array.isArray(object.publicDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.publicDependency: array expected"); + message.publicDependency = []; + for (var i = 0; i < object.publicDependency.length; ++i) + message.publicDependency[i] = object.publicDependency[i] | 0; + } + if (object.weakDependency) { + if (!Array.isArray(object.weakDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.weakDependency: array expected"); + message.weakDependency = []; + for (var i = 0; i < object.weakDependency.length; ++i) + message.weakDependency[i] = object.weakDependency[i] | 0; + } + if (object.messageType) { + if (!Array.isArray(object.messageType)) + throw TypeError(".google.protobuf.FileDescriptorProto.messageType: array expected"); + message.messageType = []; + for (var i = 0; i < object.messageType.length; ++i) { + if (typeof object.messageType[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.messageType: object expected"); + message.messageType[i] = $root.google.protobuf.DescriptorProto.fromObject(object.messageType[i]); + } + } + if (object.enumType) { + if (!Array.isArray(object.enumType)) + throw TypeError(".google.protobuf.FileDescriptorProto.enumType: array expected"); + message.enumType = []; + for (var i = 0; i < object.enumType.length; ++i) { + if (typeof object.enumType[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.enumType: object expected"); + message.enumType[i] = $root.google.protobuf.EnumDescriptorProto.fromObject(object.enumType[i]); + } + } + if (object.service) { + if (!Array.isArray(object.service)) + throw TypeError(".google.protobuf.FileDescriptorProto.service: array expected"); + message.service = []; + for (var i = 0; i < object.service.length; ++i) { + if (typeof object.service[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.service: object expected"); + message.service[i] = $root.google.protobuf.ServiceDescriptorProto.fromObject(object.service[i]); + } + } + if (object.extension) { + if (!Array.isArray(object.extension)) + throw TypeError(".google.protobuf.FileDescriptorProto.extension: array expected"); + message.extension = []; + for (var i = 0; i < object.extension.length; ++i) { + if (typeof object.extension[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.extension: object expected"); + message.extension[i] = $root.google.protobuf.FieldDescriptorProto.fromObject(object.extension[i]); + } + } + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.FileOptions.fromObject(object.options); + } + if (object.sourceCodeInfo != null) { + if (typeof object.sourceCodeInfo !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.sourceCodeInfo: object expected"); + message.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.fromObject(object.sourceCodeInfo); + } + if (object.syntax != null) + message.syntax = String(object.syntax); + return message; + }; + + /** + * Creates a plain object from a FileDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.FileDescriptorProto} message FileDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.dependency = []; + object.messageType = []; + object.enumType = []; + object.service = []; + object.extension = []; + object.publicDependency = []; + object.weakDependency = []; + } + if (options.defaults) { + object.name = ""; + object["package"] = ""; + object.options = null; + object.sourceCodeInfo = null; + object.syntax = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message["package"] != null && message.hasOwnProperty("package")) + object["package"] = message["package"]; + if (message.dependency && message.dependency.length) { + object.dependency = []; + for (var j = 0; j < message.dependency.length; ++j) + object.dependency[j] = message.dependency[j]; + } + if (message.messageType && message.messageType.length) { + object.messageType = []; + for (var j = 0; j < message.messageType.length; ++j) + object.messageType[j] = $root.google.protobuf.DescriptorProto.toObject(message.messageType[j], options); + } + if (message.enumType && message.enumType.length) { + object.enumType = []; + for (var j = 0; j < message.enumType.length; ++j) + object.enumType[j] = $root.google.protobuf.EnumDescriptorProto.toObject(message.enumType[j], options); + } + if (message.service && message.service.length) { + object.service = []; + for (var j = 0; j < message.service.length; ++j) + object.service[j] = $root.google.protobuf.ServiceDescriptorProto.toObject(message.service[j], options); + } + if (message.extension && message.extension.length) { + object.extension = []; + for (var j = 0; j < message.extension.length; ++j) + object.extension[j] = $root.google.protobuf.FieldDescriptorProto.toObject(message.extension[j], options); + } + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.FileOptions.toObject(message.options, options); + if (message.sourceCodeInfo != null && message.hasOwnProperty("sourceCodeInfo")) + object.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.toObject(message.sourceCodeInfo, options); + if (message.publicDependency && message.publicDependency.length) { + object.publicDependency = []; + for (var j = 0; j < message.publicDependency.length; ++j) + object.publicDependency[j] = message.publicDependency[j]; + } + if (message.weakDependency && message.weakDependency.length) { + object.weakDependency = []; + for (var j = 0; j < message.weakDependency.length; ++j) + object.weakDependency[j] = message.weakDependency[j]; + } + if (message.syntax != null && message.hasOwnProperty("syntax")) + object.syntax = message.syntax; + return object; + }; + + /** + * Converts this FileDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.FileDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + FileDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FileDescriptorProto; + })(); + + protobuf.DescriptorProto = (function() { + + /** + * Properties of a DescriptorProto. + * @memberof google.protobuf + * @interface IDescriptorProto + * @property {string|null} [name] DescriptorProto name + * @property {Array.|null} [field] DescriptorProto field + * @property {Array.|null} [extension] DescriptorProto extension + * @property {Array.|null} [nestedType] DescriptorProto nestedType + * @property {Array.|null} [enumType] DescriptorProto enumType + * @property {Array.|null} [extensionRange] DescriptorProto extensionRange + * @property {Array.|null} [oneofDecl] DescriptorProto oneofDecl + * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options + * @property {Array.|null} [reservedRange] DescriptorProto reservedRange + * @property {Array.|null} [reservedName] DescriptorProto reservedName + */ + + /** + * Constructs a new DescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a DescriptorProto. + * @implements IDescriptorProto + * @constructor + * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set + */ + function DescriptorProto(properties) { + this.field = []; + this.extension = []; + this.nestedType = []; + this.enumType = []; + this.extensionRange = []; + this.oneofDecl = []; + this.reservedRange = []; + this.reservedName = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DescriptorProto name. + * @member {string} name + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.name = ""; + + /** + * DescriptorProto field. + * @member {Array.} field + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.field = $util.emptyArray; + + /** + * DescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extension = $util.emptyArray; + + /** + * DescriptorProto nestedType. + * @member {Array.} nestedType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.nestedType = $util.emptyArray; + + /** + * DescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.enumType = $util.emptyArray; + + /** + * DescriptorProto extensionRange. + * @member {Array.} extensionRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extensionRange = $util.emptyArray; + + /** + * DescriptorProto oneofDecl. + * @member {Array.} oneofDecl + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.oneofDecl = $util.emptyArray; + + /** + * DescriptorProto options. + * @member {google.protobuf.IMessageOptions|null|undefined} options + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.options = null; + + /** + * DescriptorProto reservedRange. + * @member {Array.} reservedRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedRange = $util.emptyArray; + + /** + * DescriptorProto reservedName. + * @member {Array.} reservedName + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedName = $util.emptyArray; + + /** + * Creates a DescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto} DescriptorProto + */ + DescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DescriptorProto) + return object; + var message = new $root.google.protobuf.DescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.field) { + if (!Array.isArray(object.field)) + throw TypeError(".google.protobuf.DescriptorProto.field: array expected"); + message.field = []; + for (var i = 0; i < object.field.length; ++i) { + if (typeof object.field[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.field: object expected"); + message.field[i] = $root.google.protobuf.FieldDescriptorProto.fromObject(object.field[i]); + } + } + if (object.extension) { + if (!Array.isArray(object.extension)) + throw TypeError(".google.protobuf.DescriptorProto.extension: array expected"); + message.extension = []; + for (var i = 0; i < object.extension.length; ++i) { + if (typeof object.extension[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.extension: object expected"); + message.extension[i] = $root.google.protobuf.FieldDescriptorProto.fromObject(object.extension[i]); + } + } + if (object.nestedType) { + if (!Array.isArray(object.nestedType)) + throw TypeError(".google.protobuf.DescriptorProto.nestedType: array expected"); + message.nestedType = []; + for (var i = 0; i < object.nestedType.length; ++i) { + if (typeof object.nestedType[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.nestedType: object expected"); + message.nestedType[i] = $root.google.protobuf.DescriptorProto.fromObject(object.nestedType[i]); + } + } + if (object.enumType) { + if (!Array.isArray(object.enumType)) + throw TypeError(".google.protobuf.DescriptorProto.enumType: array expected"); + message.enumType = []; + for (var i = 0; i < object.enumType.length; ++i) { + if (typeof object.enumType[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.enumType: object expected"); + message.enumType[i] = $root.google.protobuf.EnumDescriptorProto.fromObject(object.enumType[i]); + } + } + if (object.extensionRange) { + if (!Array.isArray(object.extensionRange)) + throw TypeError(".google.protobuf.DescriptorProto.extensionRange: array expected"); + message.extensionRange = []; + for (var i = 0; i < object.extensionRange.length; ++i) { + if (typeof object.extensionRange[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.extensionRange: object expected"); + message.extensionRange[i] = $root.google.protobuf.DescriptorProto.ExtensionRange.fromObject(object.extensionRange[i]); + } + } + if (object.oneofDecl) { + if (!Array.isArray(object.oneofDecl)) + throw TypeError(".google.protobuf.DescriptorProto.oneofDecl: array expected"); + message.oneofDecl = []; + for (var i = 0; i < object.oneofDecl.length; ++i) { + if (typeof object.oneofDecl[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.oneofDecl: object expected"); + message.oneofDecl[i] = $root.google.protobuf.OneofDescriptorProto.fromObject(object.oneofDecl[i]); + } + } + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.DescriptorProto.options: object expected"); + message.options = $root.google.protobuf.MessageOptions.fromObject(object.options); + } + if (object.reservedRange) { + if (!Array.isArray(object.reservedRange)) + throw TypeError(".google.protobuf.DescriptorProto.reservedRange: array expected"); + message.reservedRange = []; + for (var i = 0; i < object.reservedRange.length; ++i) { + if (typeof object.reservedRange[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.reservedRange: object expected"); + message.reservedRange[i] = $root.google.protobuf.DescriptorProto.ReservedRange.fromObject(object.reservedRange[i]); + } + } + if (object.reservedName) { + if (!Array.isArray(object.reservedName)) + throw TypeError(".google.protobuf.DescriptorProto.reservedName: array expected"); + message.reservedName = []; + for (var i = 0; i < object.reservedName.length; ++i) + message.reservedName[i] = String(object.reservedName[i]); + } + return message; + }; + + /** + * Creates a plain object from a DescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.DescriptorProto} message DescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.field = []; + object.nestedType = []; + object.enumType = []; + object.extensionRange = []; + object.extension = []; + object.oneofDecl = []; + object.reservedRange = []; + object.reservedName = []; + } + if (options.defaults) { + object.name = ""; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.field && message.field.length) { + object.field = []; + for (var j = 0; j < message.field.length; ++j) + object.field[j] = $root.google.protobuf.FieldDescriptorProto.toObject(message.field[j], options); + } + if (message.nestedType && message.nestedType.length) { + object.nestedType = []; + for (var j = 0; j < message.nestedType.length; ++j) + object.nestedType[j] = $root.google.protobuf.DescriptorProto.toObject(message.nestedType[j], options); + } + if (message.enumType && message.enumType.length) { + object.enumType = []; + for (var j = 0; j < message.enumType.length; ++j) + object.enumType[j] = $root.google.protobuf.EnumDescriptorProto.toObject(message.enumType[j], options); + } + if (message.extensionRange && message.extensionRange.length) { + object.extensionRange = []; + for (var j = 0; j < message.extensionRange.length; ++j) + object.extensionRange[j] = $root.google.protobuf.DescriptorProto.ExtensionRange.toObject(message.extensionRange[j], options); + } + if (message.extension && message.extension.length) { + object.extension = []; + for (var j = 0; j < message.extension.length; ++j) + object.extension[j] = $root.google.protobuf.FieldDescriptorProto.toObject(message.extension[j], options); + } + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.MessageOptions.toObject(message.options, options); + if (message.oneofDecl && message.oneofDecl.length) { + object.oneofDecl = []; + for (var j = 0; j < message.oneofDecl.length; ++j) + object.oneofDecl[j] = $root.google.protobuf.OneofDescriptorProto.toObject(message.oneofDecl[j], options); + } + if (message.reservedRange && message.reservedRange.length) { + object.reservedRange = []; + for (var j = 0; j < message.reservedRange.length; ++j) + object.reservedRange[j] = $root.google.protobuf.DescriptorProto.ReservedRange.toObject(message.reservedRange[j], options); + } + if (message.reservedName && message.reservedName.length) { + object.reservedName = []; + for (var j = 0; j < message.reservedName.length; ++j) + object.reservedName[j] = message.reservedName[j]; + } + return object; + }; + + /** + * Converts this DescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto + * @instance + * @returns {Object.} JSON object + */ + DescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + DescriptorProto.ExtensionRange = (function() { + + /** + * Properties of an ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @interface IExtensionRange + * @property {number|null} [start] ExtensionRange start + * @property {number|null} [end] ExtensionRange end + */ + + /** + * Constructs a new ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents an ExtensionRange. + * @implements IExtensionRange + * @constructor + * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set + */ + function ExtensionRange(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExtensionRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.start = 0; + + /** + * ExtensionRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.end = 0; + + /** + * Creates an ExtensionRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + */ + ExtensionRange.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DescriptorProto.ExtensionRange) + return object; + var message = new $root.google.protobuf.DescriptorProto.ExtensionRange(); + if (object.start != null) + message.start = object.start | 0; + if (object.end != null) + message.end = object.end | 0; + return message; + }; + + /** + * Creates a plain object from an ExtensionRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.ExtensionRange} message ExtensionRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExtensionRange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.start = 0; + object.end = 0; + } + if (message.start != null && message.hasOwnProperty("start")) + object.start = message.start; + if (message.end != null && message.hasOwnProperty("end")) + object.end = message.end; + return object; + }; + + /** + * Converts this ExtensionRange to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + * @returns {Object.} JSON object + */ + ExtensionRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ExtensionRange; + })(); + + DescriptorProto.ReservedRange = (function() { + + /** + * Properties of a ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @interface IReservedRange + * @property {number|null} [start] ReservedRange start + * @property {number|null} [end] ReservedRange end + */ + + /** + * Constructs a new ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents a ReservedRange. + * @implements IReservedRange + * @constructor + * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set + */ + function ReservedRange(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReservedRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.start = 0; + + /** + * ReservedRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.end = 0; + + /** + * Creates a ReservedRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + */ + ReservedRange.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DescriptorProto.ReservedRange) + return object; + var message = new $root.google.protobuf.DescriptorProto.ReservedRange(); + if (object.start != null) + message.start = object.start | 0; + if (object.end != null) + message.end = object.end | 0; + return message; + }; + + /** + * Creates a plain object from a ReservedRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.ReservedRange} message ReservedRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReservedRange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.start = 0; + object.end = 0; + } + if (message.start != null && message.hasOwnProperty("start")) + object.start = message.start; + if (message.end != null && message.hasOwnProperty("end")) + object.end = message.end; + return object; + }; + + /** + * Converts this ReservedRange to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + * @returns {Object.} JSON object + */ + ReservedRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ReservedRange; + })(); + + return DescriptorProto; + })(); + + protobuf.FieldDescriptorProto = (function() { + + /** + * Properties of a FieldDescriptorProto. + * @memberof google.protobuf + * @interface IFieldDescriptorProto + * @property {string|null} [name] FieldDescriptorProto name + * @property {number|null} [number] FieldDescriptorProto number + * @property {google.protobuf.FieldDescriptorProto.Label|null} [label] FieldDescriptorProto label + * @property {google.protobuf.FieldDescriptorProto.Type|null} [type] FieldDescriptorProto type + * @property {string|null} [typeName] FieldDescriptorProto typeName + * @property {string|null} [extendee] FieldDescriptorProto extendee + * @property {string|null} [defaultValue] FieldDescriptorProto defaultValue + * @property {number|null} [oneofIndex] FieldDescriptorProto oneofIndex + * @property {string|null} [jsonName] FieldDescriptorProto jsonName + * @property {google.protobuf.IFieldOptions|null} [options] FieldDescriptorProto options + */ + + /** + * Constructs a new FieldDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FieldDescriptorProto. + * @implements IFieldDescriptorProto + * @constructor + * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set + */ + function FieldDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.name = ""; + + /** + * FieldDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.number = 0; + + /** + * FieldDescriptorProto label. + * @member {google.protobuf.FieldDescriptorProto.Label} label + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.label = 1; + + /** + * FieldDescriptorProto type. + * @member {google.protobuf.FieldDescriptorProto.Type} type + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.type = 1; + + /** + * FieldDescriptorProto typeName. + * @member {string} typeName + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.typeName = ""; + + /** + * FieldDescriptorProto extendee. + * @member {string} extendee + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.extendee = ""; + + /** + * FieldDescriptorProto defaultValue. + * @member {string} defaultValue + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.defaultValue = ""; + + /** + * FieldDescriptorProto oneofIndex. + * @member {number} oneofIndex + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.oneofIndex = 0; + + /** + * FieldDescriptorProto jsonName. + * @member {string} jsonName + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.jsonName = ""; + + /** + * FieldDescriptorProto options. + * @member {google.protobuf.IFieldOptions|null|undefined} options + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.options = null; + + /** + * Creates a FieldDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + */ + FieldDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldDescriptorProto) + return object; + var message = new $root.google.protobuf.FieldDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.number != null) + message.number = object.number | 0; + switch (object.label) { + case "LABEL_OPTIONAL": + case 1: + message.label = 1; + break; + case "LABEL_REQUIRED": + case 2: + message.label = 2; + break; + case "LABEL_REPEATED": + case 3: + message.label = 3; + break; + } + switch (object.type) { + case "TYPE_DOUBLE": + case 1: + message.type = 1; + break; + case "TYPE_FLOAT": + case 2: + message.type = 2; + break; + case "TYPE_INT64": + case 3: + message.type = 3; + break; + case "TYPE_UINT64": + case 4: + message.type = 4; + break; + case "TYPE_INT32": + case 5: + message.type = 5; + break; + case "TYPE_FIXED64": + case 6: + message.type = 6; + break; + case "TYPE_FIXED32": + case 7: + message.type = 7; + break; + case "TYPE_BOOL": + case 8: + message.type = 8; + break; + case "TYPE_STRING": + case 9: + message.type = 9; + break; + case "TYPE_GROUP": + case 10: + message.type = 10; + break; + case "TYPE_MESSAGE": + case 11: + message.type = 11; + break; + case "TYPE_BYTES": + case 12: + message.type = 12; + break; + case "TYPE_UINT32": + case 13: + message.type = 13; + break; + case "TYPE_ENUM": + case 14: + message.type = 14; + break; + case "TYPE_SFIXED32": + case 15: + message.type = 15; + break; + case "TYPE_SFIXED64": + case 16: + message.type = 16; + break; + case "TYPE_SINT32": + case 17: + message.type = 17; + break; + case "TYPE_SINT64": + case 18: + message.type = 18; + break; + } + if (object.typeName != null) + message.typeName = String(object.typeName); + if (object.extendee != null) + message.extendee = String(object.extendee); + if (object.defaultValue != null) + message.defaultValue = String(object.defaultValue); + if (object.oneofIndex != null) + message.oneofIndex = object.oneofIndex | 0; + if (object.jsonName != null) + message.jsonName = String(object.jsonName); + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.FieldDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.FieldOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from a FieldDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.FieldDescriptorProto} message FieldDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.extendee = ""; + object.number = 0; + object.label = options.enums === String ? "LABEL_OPTIONAL" : 1; + object.type = options.enums === String ? "TYPE_DOUBLE" : 1; + object.typeName = ""; + object.defaultValue = ""; + object.options = null; + object.oneofIndex = 0; + object.jsonName = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.extendee != null && message.hasOwnProperty("extendee")) + object.extendee = message.extendee; + if (message.number != null && message.hasOwnProperty("number")) + object.number = message.number; + if (message.label != null && message.hasOwnProperty("label")) + object.label = options.enums === String ? $root.google.protobuf.FieldDescriptorProto.Label[message.label] : message.label; + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.google.protobuf.FieldDescriptorProto.Type[message.type] : message.type; + if (message.typeName != null && message.hasOwnProperty("typeName")) + object.typeName = message.typeName; + if (message.defaultValue != null && message.hasOwnProperty("defaultValue")) + object.defaultValue = message.defaultValue; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.FieldOptions.toObject(message.options, options); + if (message.oneofIndex != null && message.hasOwnProperty("oneofIndex")) + object.oneofIndex = message.oneofIndex; + if (message.jsonName != null && message.hasOwnProperty("jsonName")) + object.jsonName = message.jsonName; + return object; + }; + + /** + * Converts this FieldDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.FieldDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + FieldDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Type enum. + * @name google.protobuf.FieldDescriptorProto.Type + * @enum {string} + * @property {string} TYPE_DOUBLE=TYPE_DOUBLE TYPE_DOUBLE value + * @property {string} TYPE_FLOAT=TYPE_FLOAT TYPE_FLOAT value + * @property {string} TYPE_INT64=TYPE_INT64 TYPE_INT64 value + * @property {string} TYPE_UINT64=TYPE_UINT64 TYPE_UINT64 value + * @property {string} TYPE_INT32=TYPE_INT32 TYPE_INT32 value + * @property {string} TYPE_FIXED64=TYPE_FIXED64 TYPE_FIXED64 value + * @property {string} TYPE_FIXED32=TYPE_FIXED32 TYPE_FIXED32 value + * @property {string} TYPE_BOOL=TYPE_BOOL TYPE_BOOL value + * @property {string} TYPE_STRING=TYPE_STRING TYPE_STRING value + * @property {string} TYPE_GROUP=TYPE_GROUP TYPE_GROUP value + * @property {string} TYPE_MESSAGE=TYPE_MESSAGE TYPE_MESSAGE value + * @property {string} TYPE_BYTES=TYPE_BYTES TYPE_BYTES value + * @property {string} TYPE_UINT32=TYPE_UINT32 TYPE_UINT32 value + * @property {string} TYPE_ENUM=TYPE_ENUM TYPE_ENUM value + * @property {string} TYPE_SFIXED32=TYPE_SFIXED32 TYPE_SFIXED32 value + * @property {string} TYPE_SFIXED64=TYPE_SFIXED64 TYPE_SFIXED64 value + * @property {string} TYPE_SINT32=TYPE_SINT32 TYPE_SINT32 value + * @property {string} TYPE_SINT64=TYPE_SINT64 TYPE_SINT64 value + */ + FieldDescriptorProto.Type = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "TYPE_DOUBLE"] = "TYPE_DOUBLE"; + values[valuesById[2] = "TYPE_FLOAT"] = "TYPE_FLOAT"; + values[valuesById[3] = "TYPE_INT64"] = "TYPE_INT64"; + values[valuesById[4] = "TYPE_UINT64"] = "TYPE_UINT64"; + values[valuesById[5] = "TYPE_INT32"] = "TYPE_INT32"; + values[valuesById[6] = "TYPE_FIXED64"] = "TYPE_FIXED64"; + values[valuesById[7] = "TYPE_FIXED32"] = "TYPE_FIXED32"; + values[valuesById[8] = "TYPE_BOOL"] = "TYPE_BOOL"; + values[valuesById[9] = "TYPE_STRING"] = "TYPE_STRING"; + values[valuesById[10] = "TYPE_GROUP"] = "TYPE_GROUP"; + values[valuesById[11] = "TYPE_MESSAGE"] = "TYPE_MESSAGE"; + values[valuesById[12] = "TYPE_BYTES"] = "TYPE_BYTES"; + values[valuesById[13] = "TYPE_UINT32"] = "TYPE_UINT32"; + values[valuesById[14] = "TYPE_ENUM"] = "TYPE_ENUM"; + values[valuesById[15] = "TYPE_SFIXED32"] = "TYPE_SFIXED32"; + values[valuesById[16] = "TYPE_SFIXED64"] = "TYPE_SFIXED64"; + values[valuesById[17] = "TYPE_SINT32"] = "TYPE_SINT32"; + values[valuesById[18] = "TYPE_SINT64"] = "TYPE_SINT64"; + return values; + })(); + + /** + * Label enum. + * @name google.protobuf.FieldDescriptorProto.Label + * @enum {string} + * @property {string} LABEL_OPTIONAL=LABEL_OPTIONAL LABEL_OPTIONAL value + * @property {string} LABEL_REQUIRED=LABEL_REQUIRED LABEL_REQUIRED value + * @property {string} LABEL_REPEATED=LABEL_REPEATED LABEL_REPEATED value + */ + FieldDescriptorProto.Label = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "LABEL_OPTIONAL"] = "LABEL_OPTIONAL"; + values[valuesById[2] = "LABEL_REQUIRED"] = "LABEL_REQUIRED"; + values[valuesById[3] = "LABEL_REPEATED"] = "LABEL_REPEATED"; + return values; + })(); + + return FieldDescriptorProto; + })(); + + protobuf.OneofDescriptorProto = (function() { + + /** + * Properties of an OneofDescriptorProto. + * @memberof google.protobuf + * @interface IOneofDescriptorProto + * @property {string|null} [name] OneofDescriptorProto name + * @property {google.protobuf.IOneofOptions|null} [options] OneofDescriptorProto options + */ + + /** + * Constructs a new OneofDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an OneofDescriptorProto. + * @implements IOneofDescriptorProto + * @constructor + * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set + */ + function OneofDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OneofDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.OneofDescriptorProto + * @instance + */ + OneofDescriptorProto.prototype.name = ""; + + /** + * OneofDescriptorProto options. + * @member {google.protobuf.IOneofOptions|null|undefined} options + * @memberof google.protobuf.OneofDescriptorProto + * @instance + */ + OneofDescriptorProto.prototype.options = null; + + /** + * Creates an OneofDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + */ + OneofDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.OneofDescriptorProto) + return object; + var message = new $root.google.protobuf.OneofDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.OneofDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.OneofOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from an OneofDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.OneofDescriptorProto} message OneofDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OneofDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.OneofOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this OneofDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.OneofDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + OneofDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return OneofDescriptorProto; + })(); + + protobuf.EnumDescriptorProto = (function() { + + /** + * Properties of an EnumDescriptorProto. + * @memberof google.protobuf + * @interface IEnumDescriptorProto + * @property {string|null} [name] EnumDescriptorProto name + * @property {Array.|null} [value] EnumDescriptorProto value + * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options + */ + + /** + * Constructs a new EnumDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumDescriptorProto. + * @implements IEnumDescriptorProto + * @constructor + * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set + */ + function EnumDescriptorProto(properties) { + this.value = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.name = ""; + + /** + * EnumDescriptorProto value. + * @member {Array.} value + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.value = $util.emptyArray; + + /** + * EnumDescriptorProto options. + * @member {google.protobuf.IEnumOptions|null|undefined} options + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.options = null; + + /** + * Creates an EnumDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + */ + EnumDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumDescriptorProto) + return object; + var message = new $root.google.protobuf.EnumDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.value) { + if (!Array.isArray(object.value)) + throw TypeError(".google.protobuf.EnumDescriptorProto.value: array expected"); + message.value = []; + for (var i = 0; i < object.value.length; ++i) { + if (typeof object.value[i] !== "object") + throw TypeError(".google.protobuf.EnumDescriptorProto.value: object expected"); + message.value[i] = $root.google.protobuf.EnumValueDescriptorProto.fromObject(object.value[i]); + } + } + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.EnumDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.EnumOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from an EnumDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.EnumDescriptorProto} message EnumDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.value = []; + if (options.defaults) { + object.name = ""; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.value && message.value.length) { + object.value = []; + for (var j = 0; j < message.value.length; ++j) + object.value[j] = $root.google.protobuf.EnumValueDescriptorProto.toObject(message.value[j], options); + } + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.EnumOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this EnumDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.EnumDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + EnumDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return EnumDescriptorProto; + })(); + + protobuf.EnumValueDescriptorProto = (function() { + + /** + * Properties of an EnumValueDescriptorProto. + * @memberof google.protobuf + * @interface IEnumValueDescriptorProto + * @property {string|null} [name] EnumValueDescriptorProto name + * @property {number|null} [number] EnumValueDescriptorProto number + * @property {google.protobuf.IEnumValueOptions|null} [options] EnumValueDescriptorProto options + */ + + /** + * Constructs a new EnumValueDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumValueDescriptorProto. + * @implements IEnumValueDescriptorProto + * @constructor + * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set + */ + function EnumValueDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumValueDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.name = ""; + + /** + * EnumValueDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.number = 0; + + /** + * EnumValueDescriptorProto options. + * @member {google.protobuf.IEnumValueOptions|null|undefined} options + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.options = null; + + /** + * Creates an EnumValueDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + */ + EnumValueDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumValueDescriptorProto) + return object; + var message = new $root.google.protobuf.EnumValueDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.number != null) + message.number = object.number | 0; + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.EnumValueDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.EnumValueOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from an EnumValueDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.EnumValueDescriptorProto} message EnumValueDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumValueDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.number = 0; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.number != null && message.hasOwnProperty("number")) + object.number = message.number; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.EnumValueOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this EnumValueDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + EnumValueDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return EnumValueDescriptorProto; + })(); + + protobuf.ServiceDescriptorProto = (function() { + + /** + * Properties of a ServiceDescriptorProto. + * @memberof google.protobuf + * @interface IServiceDescriptorProto + * @property {string|null} [name] ServiceDescriptorProto name + * @property {Array.|null} [method] ServiceDescriptorProto method + * @property {google.protobuf.IServiceOptions|null} [options] ServiceDescriptorProto options + */ + + /** + * Constructs a new ServiceDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a ServiceDescriptorProto. + * @implements IServiceDescriptorProto + * @constructor + * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set + */ + function ServiceDescriptorProto(properties) { + this.method = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ServiceDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.name = ""; + + /** + * ServiceDescriptorProto method. + * @member {Array.} method + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.method = $util.emptyArray; + + /** + * ServiceDescriptorProto options. + * @member {google.protobuf.IServiceOptions|null|undefined} options + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.options = null; + + /** + * Creates a ServiceDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + */ + ServiceDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ServiceDescriptorProto) + return object; + var message = new $root.google.protobuf.ServiceDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.method) { + if (!Array.isArray(object.method)) + throw TypeError(".google.protobuf.ServiceDescriptorProto.method: array expected"); + message.method = []; + for (var i = 0; i < object.method.length; ++i) { + if (typeof object.method[i] !== "object") + throw TypeError(".google.protobuf.ServiceDescriptorProto.method: object expected"); + message.method[i] = $root.google.protobuf.MethodDescriptorProto.fromObject(object.method[i]); + } + } + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.ServiceDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.ServiceOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from a ServiceDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.ServiceDescriptorProto} message ServiceDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServiceDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.method = []; + if (options.defaults) { + object.name = ""; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.method && message.method.length) { + object.method = []; + for (var j = 0; j < message.method.length; ++j) + object.method[j] = $root.google.protobuf.MethodDescriptorProto.toObject(message.method[j], options); + } + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.ServiceOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this ServiceDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + ServiceDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ServiceDescriptorProto; + })(); + + protobuf.MethodDescriptorProto = (function() { + + /** + * Properties of a MethodDescriptorProto. + * @memberof google.protobuf + * @interface IMethodDescriptorProto + * @property {string|null} [name] MethodDescriptorProto name + * @property {string|null} [inputType] MethodDescriptorProto inputType + * @property {string|null} [outputType] MethodDescriptorProto outputType + * @property {google.protobuf.IMethodOptions|null} [options] MethodDescriptorProto options + * @property {boolean|null} [clientStreaming] MethodDescriptorProto clientStreaming + * @property {boolean|null} [serverStreaming] MethodDescriptorProto serverStreaming + */ + + /** + * Constructs a new MethodDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a MethodDescriptorProto. + * @implements IMethodDescriptorProto + * @constructor + * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set + */ + function MethodDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MethodDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.name = ""; + + /** + * MethodDescriptorProto inputType. + * @member {string} inputType + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.inputType = ""; + + /** + * MethodDescriptorProto outputType. + * @member {string} outputType + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.outputType = ""; + + /** + * MethodDescriptorProto options. + * @member {google.protobuf.IMethodOptions|null|undefined} options + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.options = null; + + /** + * MethodDescriptorProto clientStreaming. + * @member {boolean} clientStreaming + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.clientStreaming = false; + + /** + * MethodDescriptorProto serverStreaming. + * @member {boolean} serverStreaming + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.serverStreaming = false; + + /** + * Creates a MethodDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto + */ + MethodDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MethodDescriptorProto) + return object; + var message = new $root.google.protobuf.MethodDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.inputType != null) + message.inputType = String(object.inputType); + if (object.outputType != null) + message.outputType = String(object.outputType); + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.MethodDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.MethodOptions.fromObject(object.options); + } + if (object.clientStreaming != null) + message.clientStreaming = Boolean(object.clientStreaming); + if (object.serverStreaming != null) + message.serverStreaming = Boolean(object.serverStreaming); + return message; + }; + + /** + * Creates a plain object from a MethodDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.MethodDescriptorProto} message MethodDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MethodDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.inputType = ""; + object.outputType = ""; + object.options = null; + object.clientStreaming = false; + object.serverStreaming = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.inputType != null && message.hasOwnProperty("inputType")) + object.inputType = message.inputType; + if (message.outputType != null && message.hasOwnProperty("outputType")) + object.outputType = message.outputType; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.MethodOptions.toObject(message.options, options); + if (message.clientStreaming != null && message.hasOwnProperty("clientStreaming")) + object.clientStreaming = message.clientStreaming; + if (message.serverStreaming != null && message.hasOwnProperty("serverStreaming")) + object.serverStreaming = message.serverStreaming; + return object; + }; + + /** + * Converts this MethodDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.MethodDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + MethodDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return MethodDescriptorProto; + })(); + + protobuf.FileOptions = (function() { + + /** + * Properties of a FileOptions. + * @memberof google.protobuf + * @interface IFileOptions + * @property {string|null} [javaPackage] FileOptions javaPackage + * @property {string|null} [javaOuterClassname] FileOptions javaOuterClassname + * @property {boolean|null} [javaMultipleFiles] FileOptions javaMultipleFiles + * @property {boolean|null} [javaGenerateEqualsAndHash] FileOptions javaGenerateEqualsAndHash + * @property {boolean|null} [javaStringCheckUtf8] FileOptions javaStringCheckUtf8 + * @property {google.protobuf.FileOptions.OptimizeMode|null} [optimizeFor] FileOptions optimizeFor + * @property {string|null} [goPackage] FileOptions goPackage + * @property {boolean|null} [ccGenericServices] FileOptions ccGenericServices + * @property {boolean|null} [javaGenericServices] FileOptions javaGenericServices + * @property {boolean|null} [pyGenericServices] FileOptions pyGenericServices + * @property {boolean|null} [deprecated] FileOptions deprecated + * @property {boolean|null} [ccEnableArenas] FileOptions ccEnableArenas + * @property {string|null} [objcClassPrefix] FileOptions objcClassPrefix + * @property {string|null} [csharpNamespace] FileOptions csharpNamespace + * @property {Array.|null} [uninterpretedOption] FileOptions uninterpretedOption + * @property {Array.|null} [".google.api.resourceDefinition"] FileOptions .google.api.resourceDefinition + */ + + /** + * Constructs a new FileOptions. + * @memberof google.protobuf + * @classdesc Represents a FileOptions. + * @implements IFileOptions + * @constructor + * @param {google.protobuf.IFileOptions=} [properties] Properties to set + */ + function FileOptions(properties) { + this.uninterpretedOption = []; + this[".google.api.resourceDefinition"] = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FileOptions javaPackage. + * @member {string} javaPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaPackage = ""; + + /** + * FileOptions javaOuterClassname. + * @member {string} javaOuterClassname + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaOuterClassname = ""; + + /** + * FileOptions javaMultipleFiles. + * @member {boolean} javaMultipleFiles + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaMultipleFiles = false; + + /** + * FileOptions javaGenerateEqualsAndHash. + * @member {boolean} javaGenerateEqualsAndHash + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaGenerateEqualsAndHash = false; + + /** + * FileOptions javaStringCheckUtf8. + * @member {boolean} javaStringCheckUtf8 + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaStringCheckUtf8 = false; + + /** + * FileOptions optimizeFor. + * @member {google.protobuf.FileOptions.OptimizeMode} optimizeFor + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.optimizeFor = 1; + + /** + * FileOptions goPackage. + * @member {string} goPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.goPackage = ""; + + /** + * FileOptions ccGenericServices. + * @member {boolean} ccGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.ccGenericServices = false; + + /** + * FileOptions javaGenericServices. + * @member {boolean} javaGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaGenericServices = false; + + /** + * FileOptions pyGenericServices. + * @member {boolean} pyGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.pyGenericServices = false; + + /** + * FileOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.deprecated = false; + + /** + * FileOptions ccEnableArenas. + * @member {boolean} ccEnableArenas + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.ccEnableArenas = false; + + /** + * FileOptions objcClassPrefix. + * @member {string} objcClassPrefix + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.objcClassPrefix = ""; + + /** + * FileOptions csharpNamespace. + * @member {string} csharpNamespace + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.csharpNamespace = ""; + + /** + * FileOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * FileOptions .google.api.resourceDefinition. + * @member {Array.} .google.api.resourceDefinition + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype[".google.api.resourceDefinition"] = $util.emptyArray; + + /** + * Creates a FileOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileOptions} FileOptions + */ + FileOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileOptions) + return object; + var message = new $root.google.protobuf.FileOptions(); + if (object.javaPackage != null) + message.javaPackage = String(object.javaPackage); + if (object.javaOuterClassname != null) + message.javaOuterClassname = String(object.javaOuterClassname); + if (object.javaMultipleFiles != null) + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + if (object.javaGenerateEqualsAndHash != null) + message.javaGenerateEqualsAndHash = Boolean(object.javaGenerateEqualsAndHash); + if (object.javaStringCheckUtf8 != null) + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + switch (object.optimizeFor) { + case "SPEED": + case 1: + message.optimizeFor = 1; + break; + case "CODE_SIZE": + case 2: + message.optimizeFor = 2; + break; + case "LITE_RUNTIME": + case 3: + message.optimizeFor = 3; + break; + } + if (object.goPackage != null) + message.goPackage = String(object.goPackage); + if (object.ccGenericServices != null) + message.ccGenericServices = Boolean(object.ccGenericServices); + if (object.javaGenericServices != null) + message.javaGenericServices = Boolean(object.javaGenericServices); + if (object.pyGenericServices != null) + message.pyGenericServices = Boolean(object.pyGenericServices); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.ccEnableArenas != null) + message.ccEnableArenas = Boolean(object.ccEnableArenas); + if (object.objcClassPrefix != null) + message.objcClassPrefix = String(object.objcClassPrefix); + if (object.csharpNamespace != null) + message.csharpNamespace = String(object.csharpNamespace); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.FileOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.FileOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.resourceDefinition"]) { + if (!Array.isArray(object[".google.api.resourceDefinition"])) + throw TypeError(".google.protobuf.FileOptions..google.api.resourceDefinition: array expected"); + message[".google.api.resourceDefinition"] = []; + for (var i = 0; i < object[".google.api.resourceDefinition"].length; ++i) { + if (typeof object[".google.api.resourceDefinition"][i] !== "object") + throw TypeError(".google.protobuf.FileOptions..google.api.resourceDefinition: object expected"); + message[".google.api.resourceDefinition"][i] = $root.google.api.ResourceDescriptor.fromObject(object[".google.api.resourceDefinition"][i]); + } + } + return message; + }; + + /** + * Creates a plain object from a FileOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.FileOptions} message FileOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.uninterpretedOption = []; + object[".google.api.resourceDefinition"] = []; + } + if (options.defaults) { + object.javaPackage = ""; + object.javaOuterClassname = ""; + object.optimizeFor = options.enums === String ? "SPEED" : 1; + object.javaMultipleFiles = false; + object.goPackage = ""; + object.ccGenericServices = false; + object.javaGenericServices = false; + object.pyGenericServices = false; + object.javaGenerateEqualsAndHash = false; + object.deprecated = false; + object.javaStringCheckUtf8 = false; + object.ccEnableArenas = false; + object.objcClassPrefix = ""; + object.csharpNamespace = ""; + } + if (message.javaPackage != null && message.hasOwnProperty("javaPackage")) + object.javaPackage = message.javaPackage; + if (message.javaOuterClassname != null && message.hasOwnProperty("javaOuterClassname")) + object.javaOuterClassname = message.javaOuterClassname; + if (message.optimizeFor != null && message.hasOwnProperty("optimizeFor")) + object.optimizeFor = options.enums === String ? $root.google.protobuf.FileOptions.OptimizeMode[message.optimizeFor] : message.optimizeFor; + if (message.javaMultipleFiles != null && message.hasOwnProperty("javaMultipleFiles")) + object.javaMultipleFiles = message.javaMultipleFiles; + if (message.goPackage != null && message.hasOwnProperty("goPackage")) + object.goPackage = message.goPackage; + if (message.ccGenericServices != null && message.hasOwnProperty("ccGenericServices")) + object.ccGenericServices = message.ccGenericServices; + if (message.javaGenericServices != null && message.hasOwnProperty("javaGenericServices")) + object.javaGenericServices = message.javaGenericServices; + if (message.pyGenericServices != null && message.hasOwnProperty("pyGenericServices")) + object.pyGenericServices = message.pyGenericServices; + if (message.javaGenerateEqualsAndHash != null && message.hasOwnProperty("javaGenerateEqualsAndHash")) + object.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.javaStringCheckUtf8 != null && message.hasOwnProperty("javaStringCheckUtf8")) + object.javaStringCheckUtf8 = message.javaStringCheckUtf8; + if (message.ccEnableArenas != null && message.hasOwnProperty("ccEnableArenas")) + object.ccEnableArenas = message.ccEnableArenas; + if (message.objcClassPrefix != null && message.hasOwnProperty("objcClassPrefix")) + object.objcClassPrefix = message.objcClassPrefix; + if (message.csharpNamespace != null && message.hasOwnProperty("csharpNamespace")) + object.csharpNamespace = message.csharpNamespace; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.api.resourceDefinition"] && message[".google.api.resourceDefinition"].length) { + object[".google.api.resourceDefinition"] = []; + for (var j = 0; j < message[".google.api.resourceDefinition"].length; ++j) + object[".google.api.resourceDefinition"][j] = $root.google.api.ResourceDescriptor.toObject(message[".google.api.resourceDefinition"][j], options); + } + return object; + }; + + /** + * Converts this FileOptions to JSON. + * @function toJSON + * @memberof google.protobuf.FileOptions + * @instance + * @returns {Object.} JSON object + */ + FileOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * OptimizeMode enum. + * @name google.protobuf.FileOptions.OptimizeMode + * @enum {string} + * @property {string} SPEED=SPEED SPEED value + * @property {string} CODE_SIZE=CODE_SIZE CODE_SIZE value + * @property {string} LITE_RUNTIME=LITE_RUNTIME LITE_RUNTIME value + */ + FileOptions.OptimizeMode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "SPEED"] = "SPEED"; + values[valuesById[2] = "CODE_SIZE"] = "CODE_SIZE"; + values[valuesById[3] = "LITE_RUNTIME"] = "LITE_RUNTIME"; + return values; + })(); + + return FileOptions; + })(); + + protobuf.MessageOptions = (function() { + + /** + * Properties of a MessageOptions. + * @memberof google.protobuf + * @interface IMessageOptions + * @property {boolean|null} [messageSetWireFormat] MessageOptions messageSetWireFormat + * @property {boolean|null} [noStandardDescriptorAccessor] MessageOptions noStandardDescriptorAccessor + * @property {boolean|null} [deprecated] MessageOptions deprecated + * @property {boolean|null} [mapEntry] MessageOptions mapEntry + * @property {Array.|null} [uninterpretedOption] MessageOptions uninterpretedOption + * @property {google.api.IResourceDescriptor|null} [".google.api.resource"] MessageOptions .google.api.resource + */ + + /** + * Constructs a new MessageOptions. + * @memberof google.protobuf + * @classdesc Represents a MessageOptions. + * @implements IMessageOptions + * @constructor + * @param {google.protobuf.IMessageOptions=} [properties] Properties to set + */ + function MessageOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MessageOptions messageSetWireFormat. + * @member {boolean} messageSetWireFormat + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.messageSetWireFormat = false; + + /** + * MessageOptions noStandardDescriptorAccessor. + * @member {boolean} noStandardDescriptorAccessor + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.noStandardDescriptorAccessor = false; + + /** + * MessageOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.deprecated = false; + + /** + * MessageOptions mapEntry. + * @member {boolean} mapEntry + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.mapEntry = false; + + /** + * MessageOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * MessageOptions .google.api.resource. + * @member {google.api.IResourceDescriptor|null|undefined} .google.api.resource + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype[".google.api.resource"] = null; + + /** + * Creates a MessageOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MessageOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MessageOptions} MessageOptions + */ + MessageOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MessageOptions) + return object; + var message = new $root.google.protobuf.MessageOptions(); + if (object.messageSetWireFormat != null) + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + if (object.noStandardDescriptorAccessor != null) + message.noStandardDescriptorAccessor = Boolean(object.noStandardDescriptorAccessor); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.mapEntry != null) + message.mapEntry = Boolean(object.mapEntry); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.MessageOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.MessageOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.resource"] != null) { + if (typeof object[".google.api.resource"] !== "object") + throw TypeError(".google.protobuf.MessageOptions..google.api.resource: object expected"); + message[".google.api.resource"] = $root.google.api.ResourceDescriptor.fromObject(object[".google.api.resource"]); + } + return message; + }; + + /** + * Creates a plain object from a MessageOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.MessageOptions} message MessageOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MessageOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) { + object.messageSetWireFormat = false; + object.noStandardDescriptorAccessor = false; + object.deprecated = false; + object.mapEntry = false; + object[".google.api.resource"] = null; + } + if (message.messageSetWireFormat != null && message.hasOwnProperty("messageSetWireFormat")) + object.messageSetWireFormat = message.messageSetWireFormat; + if (message.noStandardDescriptorAccessor != null && message.hasOwnProperty("noStandardDescriptorAccessor")) + object.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.mapEntry != null && message.hasOwnProperty("mapEntry")) + object.mapEntry = message.mapEntry; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.api.resource"] != null && message.hasOwnProperty(".google.api.resource")) + object[".google.api.resource"] = $root.google.api.ResourceDescriptor.toObject(message[".google.api.resource"], options); + return object; + }; + + /** + * Converts this MessageOptions to JSON. + * @function toJSON + * @memberof google.protobuf.MessageOptions + * @instance + * @returns {Object.} JSON object + */ + MessageOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return MessageOptions; + })(); + + protobuf.FieldOptions = (function() { + + /** + * Properties of a FieldOptions. + * @memberof google.protobuf + * @interface IFieldOptions + * @property {google.protobuf.FieldOptions.CType|null} [ctype] FieldOptions ctype + * @property {boolean|null} [packed] FieldOptions packed + * @property {google.protobuf.FieldOptions.JSType|null} [jstype] FieldOptions jstype + * @property {boolean|null} [lazy] FieldOptions lazy + * @property {boolean|null} [deprecated] FieldOptions deprecated + * @property {boolean|null} [weak] FieldOptions weak + * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption + * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior + * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference + */ + + /** + * Constructs a new FieldOptions. + * @memberof google.protobuf + * @classdesc Represents a FieldOptions. + * @implements IFieldOptions + * @constructor + * @param {google.protobuf.IFieldOptions=} [properties] Properties to set + */ + function FieldOptions(properties) { + this.uninterpretedOption = []; + this[".google.api.fieldBehavior"] = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldOptions ctype. + * @member {google.protobuf.FieldOptions.CType} ctype + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.ctype = 0; + + /** + * FieldOptions packed. + * @member {boolean} packed + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.packed = false; + + /** + * FieldOptions jstype. + * @member {google.protobuf.FieldOptions.JSType} jstype + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.jstype = 0; + + /** + * FieldOptions lazy. + * @member {boolean} lazy + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.lazy = false; + + /** + * FieldOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.deprecated = false; + + /** + * FieldOptions weak. + * @member {boolean} weak + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.weak = false; + + /** + * FieldOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * FieldOptions .google.api.fieldBehavior. + * @member {Array.} .google.api.fieldBehavior + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype[".google.api.fieldBehavior"] = $util.emptyArray; + + /** + * FieldOptions .google.api.resourceReference. + * @member {google.api.IResourceReference|null|undefined} .google.api.resourceReference + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype[".google.api.resourceReference"] = null; + + /** + * Creates a FieldOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions} FieldOptions + */ + FieldOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions) + return object; + var message = new $root.google.protobuf.FieldOptions(); + switch (object.ctype) { + case "STRING": + case 0: + message.ctype = 0; + break; + case "CORD": + case 1: + message.ctype = 1; + break; + case "STRING_PIECE": + case 2: + message.ctype = 2; + break; + } + if (object.packed != null) + message.packed = Boolean(object.packed); + switch (object.jstype) { + case "JS_NORMAL": + case 0: + message.jstype = 0; + break; + case "JS_STRING": + case 1: + message.jstype = 1; + break; + case "JS_NUMBER": + case 2: + message.jstype = 2; + break; + } + if (object.lazy != null) + message.lazy = Boolean(object.lazy); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.weak != null) + message.weak = Boolean(object.weak); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.fieldBehavior"]) { + if (!Array.isArray(object[".google.api.fieldBehavior"])) + throw TypeError(".google.protobuf.FieldOptions..google.api.fieldBehavior: array expected"); + message[".google.api.fieldBehavior"] = []; + for (var i = 0; i < object[".google.api.fieldBehavior"].length; ++i) + switch (object[".google.api.fieldBehavior"][i]) { + default: + case "FIELD_BEHAVIOR_UNSPECIFIED": + case 0: + message[".google.api.fieldBehavior"][i] = 0; + break; + case "OPTIONAL": + case 1: + message[".google.api.fieldBehavior"][i] = 1; + break; + case "REQUIRED": + case 2: + message[".google.api.fieldBehavior"][i] = 2; + break; + case "OUTPUT_ONLY": + case 3: + message[".google.api.fieldBehavior"][i] = 3; + break; + case "INPUT_ONLY": + case 4: + message[".google.api.fieldBehavior"][i] = 4; + break; + case "IMMUTABLE": + case 5: + message[".google.api.fieldBehavior"][i] = 5; + break; + } + } + if (object[".google.api.resourceReference"] != null) { + if (typeof object[".google.api.resourceReference"] !== "object") + throw TypeError(".google.protobuf.FieldOptions..google.api.resourceReference: object expected"); + message[".google.api.resourceReference"] = $root.google.api.ResourceReference.fromObject(object[".google.api.resourceReference"]); + } + return message; + }; + + /** + * Creates a plain object from a FieldOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.FieldOptions} message FieldOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.uninterpretedOption = []; + object[".google.api.fieldBehavior"] = []; + } + if (options.defaults) { + object.ctype = options.enums === String ? "STRING" : 0; + object.packed = false; + object.deprecated = false; + object.lazy = false; + object.jstype = options.enums === String ? "JS_NORMAL" : 0; + object.weak = false; + object[".google.api.resourceReference"] = null; + } + if (message.ctype != null && message.hasOwnProperty("ctype")) + object.ctype = options.enums === String ? $root.google.protobuf.FieldOptions.CType[message.ctype] : message.ctype; + if (message.packed != null && message.hasOwnProperty("packed")) + object.packed = message.packed; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.lazy != null && message.hasOwnProperty("lazy")) + object.lazy = message.lazy; + if (message.jstype != null && message.hasOwnProperty("jstype")) + object.jstype = options.enums === String ? $root.google.protobuf.FieldOptions.JSType[message.jstype] : message.jstype; + if (message.weak != null && message.hasOwnProperty("weak")) + object.weak = message.weak; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.api.fieldBehavior"] && message[".google.api.fieldBehavior"].length) { + object[".google.api.fieldBehavior"] = []; + for (var j = 0; j < message[".google.api.fieldBehavior"].length; ++j) + object[".google.api.fieldBehavior"][j] = options.enums === String ? $root.google.api.FieldBehavior[message[".google.api.fieldBehavior"][j]] : message[".google.api.fieldBehavior"][j]; + } + if (message[".google.api.resourceReference"] != null && message.hasOwnProperty(".google.api.resourceReference")) + object[".google.api.resourceReference"] = $root.google.api.ResourceReference.toObject(message[".google.api.resourceReference"], options); + return object; + }; + + /** + * Converts this FieldOptions to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions + * @instance + * @returns {Object.} JSON object + */ + FieldOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * CType enum. + * @name google.protobuf.FieldOptions.CType + * @enum {string} + * @property {string} STRING=STRING STRING value + * @property {string} CORD=CORD CORD value + * @property {string} STRING_PIECE=STRING_PIECE STRING_PIECE value + */ + FieldOptions.CType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STRING"] = "STRING"; + values[valuesById[1] = "CORD"] = "CORD"; + values[valuesById[2] = "STRING_PIECE"] = "STRING_PIECE"; + return values; + })(); + + /** + * JSType enum. + * @name google.protobuf.FieldOptions.JSType + * @enum {string} + * @property {string} JS_NORMAL=JS_NORMAL JS_NORMAL value + * @property {string} JS_STRING=JS_STRING JS_STRING value + * @property {string} JS_NUMBER=JS_NUMBER JS_NUMBER value + */ + FieldOptions.JSType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "JS_NORMAL"] = "JS_NORMAL"; + values[valuesById[1] = "JS_STRING"] = "JS_STRING"; + values[valuesById[2] = "JS_NUMBER"] = "JS_NUMBER"; + return values; + })(); + + return FieldOptions; + })(); + + protobuf.OneofOptions = (function() { + + /** + * Properties of an OneofOptions. + * @memberof google.protobuf + * @interface IOneofOptions + * @property {Array.|null} [uninterpretedOption] OneofOptions uninterpretedOption + */ + + /** + * Constructs a new OneofOptions. + * @memberof google.protobuf + * @classdesc Represents an OneofOptions. + * @implements IOneofOptions + * @constructor + * @param {google.protobuf.IOneofOptions=} [properties] Properties to set + */ + function OneofOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OneofOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.OneofOptions + * @instance + */ + OneofOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * Creates an OneofOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.OneofOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.OneofOptions} OneofOptions + */ + OneofOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.OneofOptions) + return object; + var message = new $root.google.protobuf.OneofOptions(); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.OneofOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.OneofOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an OneofOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.OneofOptions} message OneofOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OneofOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + return object; + }; + + /** + * Converts this OneofOptions to JSON. + * @function toJSON + * @memberof google.protobuf.OneofOptions + * @instance + * @returns {Object.} JSON object + */ + OneofOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return OneofOptions; + })(); + + protobuf.EnumOptions = (function() { + + /** + * Properties of an EnumOptions. + * @memberof google.protobuf + * @interface IEnumOptions + * @property {boolean|null} [allowAlias] EnumOptions allowAlias + * @property {boolean|null} [deprecated] EnumOptions deprecated + * @property {Array.|null} [uninterpretedOption] EnumOptions uninterpretedOption + */ + + /** + * Constructs a new EnumOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumOptions. + * @implements IEnumOptions + * @constructor + * @param {google.protobuf.IEnumOptions=} [properties] Properties to set + */ + function EnumOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumOptions allowAlias. + * @member {boolean} allowAlias + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.allowAlias = false; + + /** + * EnumOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.deprecated = false; + + /** + * EnumOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * Creates an EnumOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumOptions} EnumOptions + */ + EnumOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumOptions) + return object; + var message = new $root.google.protobuf.EnumOptions(); + if (object.allowAlias != null) + message.allowAlias = Boolean(object.allowAlias); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.EnumOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.EnumOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an EnumOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.EnumOptions} message EnumOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) { + object.allowAlias = false; + object.deprecated = false; + } + if (message.allowAlias != null && message.hasOwnProperty("allowAlias")) + object.allowAlias = message.allowAlias; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + return object; + }; + + /** + * Converts this EnumOptions to JSON. + * @function toJSON + * @memberof google.protobuf.EnumOptions + * @instance + * @returns {Object.} JSON object + */ + EnumOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return EnumOptions; + })(); + + protobuf.EnumValueOptions = (function() { + + /** + * Properties of an EnumValueOptions. + * @memberof google.protobuf + * @interface IEnumValueOptions + * @property {boolean|null} [deprecated] EnumValueOptions deprecated + * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption + */ + + /** + * Constructs a new EnumValueOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumValueOptions. + * @implements IEnumValueOptions + * @constructor + * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set + */ + function EnumValueOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumValueOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.deprecated = false; + + /** + * EnumValueOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * Creates an EnumValueOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + */ + EnumValueOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumValueOptions) + return object; + var message = new $root.google.protobuf.EnumValueOptions(); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an EnumValueOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.EnumValueOptions} message EnumValueOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumValueOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) + object.deprecated = false; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + return object; + }; + + /** + * Converts this EnumValueOptions to JSON. + * @function toJSON + * @memberof google.protobuf.EnumValueOptions + * @instance + * @returns {Object.} JSON object + */ + EnumValueOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return EnumValueOptions; + })(); + + protobuf.ServiceOptions = (function() { + + /** + * Properties of a ServiceOptions. + * @memberof google.protobuf + * @interface IServiceOptions + * @property {boolean|null} [deprecated] ServiceOptions deprecated + * @property {Array.|null} [uninterpretedOption] ServiceOptions uninterpretedOption + * @property {string|null} [".google.api.defaultHost"] ServiceOptions .google.api.defaultHost + * @property {string|null} [".google.api.oauthScopes"] ServiceOptions .google.api.oauthScopes + */ + + /** + * Constructs a new ServiceOptions. + * @memberof google.protobuf + * @classdesc Represents a ServiceOptions. + * @implements IServiceOptions + * @constructor + * @param {google.protobuf.IServiceOptions=} [properties] Properties to set + */ + function ServiceOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ServiceOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.deprecated = false; + + /** + * ServiceOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * ServiceOptions .google.api.defaultHost. + * @member {string} .google.api.defaultHost + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype[".google.api.defaultHost"] = ""; + + /** + * ServiceOptions .google.api.oauthScopes. + * @member {string} .google.api.oauthScopes + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype[".google.api.oauthScopes"] = ""; + + /** + * Creates a ServiceOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ServiceOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ServiceOptions} ServiceOptions + */ + ServiceOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ServiceOptions) + return object; + var message = new $root.google.protobuf.ServiceOptions(); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.ServiceOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.ServiceOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.defaultHost"] != null) + message[".google.api.defaultHost"] = String(object[".google.api.defaultHost"]); + if (object[".google.api.oauthScopes"] != null) + message[".google.api.oauthScopes"] = String(object[".google.api.oauthScopes"]); + return message; + }; + + /** + * Creates a plain object from a ServiceOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.ServiceOptions} message ServiceOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServiceOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) { + object.deprecated = false; + object[".google.api.defaultHost"] = ""; + object[".google.api.oauthScopes"] = ""; + } + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.api.defaultHost"] != null && message.hasOwnProperty(".google.api.defaultHost")) + object[".google.api.defaultHost"] = message[".google.api.defaultHost"]; + if (message[".google.api.oauthScopes"] != null && message.hasOwnProperty(".google.api.oauthScopes")) + object[".google.api.oauthScopes"] = message[".google.api.oauthScopes"]; + return object; + }; + + /** + * Converts this ServiceOptions to JSON. + * @function toJSON + * @memberof google.protobuf.ServiceOptions + * @instance + * @returns {Object.} JSON object + */ + ServiceOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ServiceOptions; + })(); + + protobuf.MethodOptions = (function() { + + /** + * Properties of a MethodOptions. + * @memberof google.protobuf + * @interface IMethodOptions + * @property {boolean|null} [deprecated] MethodOptions deprecated + * @property {Array.|null} [uninterpretedOption] MethodOptions uninterpretedOption + * @property {google.api.IHttpRule|null} [".google.api.http"] MethodOptions .google.api.http + * @property {Array.|null} [".google.api.methodSignature"] MethodOptions .google.api.methodSignature + * @property {google.longrunning.IOperationInfo|null} [".google.longrunning.operationInfo"] MethodOptions .google.longrunning.operationInfo + */ + + /** + * Constructs a new MethodOptions. + * @memberof google.protobuf + * @classdesc Represents a MethodOptions. + * @implements IMethodOptions + * @constructor + * @param {google.protobuf.IMethodOptions=} [properties] Properties to set + */ + function MethodOptions(properties) { + this.uninterpretedOption = []; + this[".google.api.methodSignature"] = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MethodOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.deprecated = false; + + /** + * MethodOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * MethodOptions .google.api.http. + * @member {google.api.IHttpRule|null|undefined} .google.api.http + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.api.http"] = null; + + /** + * MethodOptions .google.api.methodSignature. + * @member {Array.} .google.api.methodSignature + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.api.methodSignature"] = $util.emptyArray; + + /** + * MethodOptions .google.longrunning.operationInfo. + * @member {google.longrunning.IOperationInfo|null|undefined} .google.longrunning.operationInfo + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.longrunning.operationInfo"] = null; + + /** + * Creates a MethodOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MethodOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MethodOptions} MethodOptions + */ + MethodOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MethodOptions) + return object; + var message = new $root.google.protobuf.MethodOptions(); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.MethodOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.MethodOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.http"] != null) { + if (typeof object[".google.api.http"] !== "object") + throw TypeError(".google.protobuf.MethodOptions..google.api.http: object expected"); + message[".google.api.http"] = $root.google.api.HttpRule.fromObject(object[".google.api.http"]); + } + if (object[".google.api.methodSignature"]) { + if (!Array.isArray(object[".google.api.methodSignature"])) + throw TypeError(".google.protobuf.MethodOptions..google.api.methodSignature: array expected"); + message[".google.api.methodSignature"] = []; + for (var i = 0; i < object[".google.api.methodSignature"].length; ++i) + message[".google.api.methodSignature"][i] = String(object[".google.api.methodSignature"][i]); + } + if (object[".google.longrunning.operationInfo"] != null) { + if (typeof object[".google.longrunning.operationInfo"] !== "object") + throw TypeError(".google.protobuf.MethodOptions..google.longrunning.operationInfo: object expected"); + message[".google.longrunning.operationInfo"] = $root.google.longrunning.OperationInfo.fromObject(object[".google.longrunning.operationInfo"]); + } + return message; + }; + + /** + * Creates a plain object from a MethodOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.MethodOptions} message MethodOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MethodOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.uninterpretedOption = []; + object[".google.api.methodSignature"] = []; + } + if (options.defaults) { + object.deprecated = false; + object[".google.longrunning.operationInfo"] = null; + object[".google.api.http"] = null; + } + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.longrunning.operationInfo"] != null && message.hasOwnProperty(".google.longrunning.operationInfo")) + object[".google.longrunning.operationInfo"] = $root.google.longrunning.OperationInfo.toObject(message[".google.longrunning.operationInfo"], options); + if (message[".google.api.methodSignature"] && message[".google.api.methodSignature"].length) { + object[".google.api.methodSignature"] = []; + for (var j = 0; j < message[".google.api.methodSignature"].length; ++j) + object[".google.api.methodSignature"][j] = message[".google.api.methodSignature"][j]; + } + if (message[".google.api.http"] != null && message.hasOwnProperty(".google.api.http")) + object[".google.api.http"] = $root.google.api.HttpRule.toObject(message[".google.api.http"], options); + return object; + }; + + /** + * Converts this MethodOptions to JSON. + * @function toJSON + * @memberof google.protobuf.MethodOptions + * @instance + * @returns {Object.} JSON object + */ + MethodOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return MethodOptions; + })(); + + protobuf.UninterpretedOption = (function() { + + /** + * Properties of an UninterpretedOption. + * @memberof google.protobuf + * @interface IUninterpretedOption + * @property {Array.|null} [name] UninterpretedOption name + * @property {string|null} [identifierValue] UninterpretedOption identifierValue + * @property {number|string|null} [positiveIntValue] UninterpretedOption positiveIntValue + * @property {number|string|null} [negativeIntValue] UninterpretedOption negativeIntValue + * @property {number|null} [doubleValue] UninterpretedOption doubleValue + * @property {Uint8Array|null} [stringValue] UninterpretedOption stringValue + * @property {string|null} [aggregateValue] UninterpretedOption aggregateValue + */ + + /** + * Constructs a new UninterpretedOption. + * @memberof google.protobuf + * @classdesc Represents an UninterpretedOption. + * @implements IUninterpretedOption + * @constructor + * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set + */ + function UninterpretedOption(properties) { + this.name = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UninterpretedOption name. + * @member {Array.} name + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.name = $util.emptyArray; + + /** + * UninterpretedOption identifierValue. + * @member {string} identifierValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.identifierValue = ""; + + /** + * UninterpretedOption positiveIntValue. + * @member {number|string} positiveIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.positiveIntValue = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * UninterpretedOption negativeIntValue. + * @member {number|string} negativeIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.negativeIntValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * UninterpretedOption doubleValue. + * @member {number} doubleValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.doubleValue = 0; + + /** + * UninterpretedOption stringValue. + * @member {Uint8Array} stringValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.stringValue = $util.newBuffer([]); + + /** + * UninterpretedOption aggregateValue. + * @member {string} aggregateValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.aggregateValue = ""; + + /** + * Creates an UninterpretedOption message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + */ + UninterpretedOption.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UninterpretedOption) + return object; + var message = new $root.google.protobuf.UninterpretedOption(); + if (object.name) { + if (!Array.isArray(object.name)) + throw TypeError(".google.protobuf.UninterpretedOption.name: array expected"); + message.name = []; + for (var i = 0; i < object.name.length; ++i) { + if (typeof object.name[i] !== "object") + throw TypeError(".google.protobuf.UninterpretedOption.name: object expected"); + message.name[i] = $root.google.protobuf.UninterpretedOption.NamePart.fromObject(object.name[i]); + } + } + if (object.identifierValue != null) + message.identifierValue = String(object.identifierValue); + if (object.positiveIntValue != null) + if ($util.Long) + (message.positiveIntValue = $util.Long.fromValue(object.positiveIntValue)).unsigned = true; + else if (typeof object.positiveIntValue === "string") + message.positiveIntValue = parseInt(object.positiveIntValue, 10); + else if (typeof object.positiveIntValue === "number") + message.positiveIntValue = object.positiveIntValue; + else if (typeof object.positiveIntValue === "object") + message.positiveIntValue = new $util.LongBits(object.positiveIntValue.low >>> 0, object.positiveIntValue.high >>> 0).toNumber(true); + if (object.negativeIntValue != null) + if ($util.Long) + (message.negativeIntValue = $util.Long.fromValue(object.negativeIntValue)).unsigned = false; + else if (typeof object.negativeIntValue === "string") + message.negativeIntValue = parseInt(object.negativeIntValue, 10); + else if (typeof object.negativeIntValue === "number") + message.negativeIntValue = object.negativeIntValue; + else if (typeof object.negativeIntValue === "object") + message.negativeIntValue = new $util.LongBits(object.negativeIntValue.low >>> 0, object.negativeIntValue.high >>> 0).toNumber(); + if (object.doubleValue != null) + message.doubleValue = Number(object.doubleValue); + if (object.stringValue != null) + if (typeof object.stringValue === "string") + $util.base64.decode(object.stringValue, message.stringValue = $util.newBuffer($util.base64.length(object.stringValue)), 0); + else if (object.stringValue.length) + message.stringValue = object.stringValue; + if (object.aggregateValue != null) + message.aggregateValue = String(object.aggregateValue); + return message; + }; + + /** + * Creates a plain object from an UninterpretedOption message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.UninterpretedOption} message UninterpretedOption + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UninterpretedOption.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.name = []; + if (options.defaults) { + object.identifierValue = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.positiveIntValue = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.positiveIntValue = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.negativeIntValue = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.negativeIntValue = options.longs === String ? "0" : 0; + object.doubleValue = 0; + if (options.bytes === String) + object.stringValue = ""; + else { + object.stringValue = []; + if (options.bytes !== Array) + object.stringValue = $util.newBuffer(object.stringValue); + } + object.aggregateValue = ""; + } + if (message.name && message.name.length) { + object.name = []; + for (var j = 0; j < message.name.length; ++j) + object.name[j] = $root.google.protobuf.UninterpretedOption.NamePart.toObject(message.name[j], options); + } + if (message.identifierValue != null && message.hasOwnProperty("identifierValue")) + object.identifierValue = message.identifierValue; + if (message.positiveIntValue != null && message.hasOwnProperty("positiveIntValue")) + if (typeof message.positiveIntValue === "number") + object.positiveIntValue = options.longs === String ? String(message.positiveIntValue) : message.positiveIntValue; + else + object.positiveIntValue = options.longs === String ? $util.Long.prototype.toString.call(message.positiveIntValue) : options.longs === Number ? new $util.LongBits(message.positiveIntValue.low >>> 0, message.positiveIntValue.high >>> 0).toNumber(true) : message.positiveIntValue; + if (message.negativeIntValue != null && message.hasOwnProperty("negativeIntValue")) + if (typeof message.negativeIntValue === "number") + object.negativeIntValue = options.longs === String ? String(message.negativeIntValue) : message.negativeIntValue; + else + object.negativeIntValue = options.longs === String ? $util.Long.prototype.toString.call(message.negativeIntValue) : options.longs === Number ? new $util.LongBits(message.negativeIntValue.low >>> 0, message.negativeIntValue.high >>> 0).toNumber() : message.negativeIntValue; + if (message.doubleValue != null && message.hasOwnProperty("doubleValue")) + object.doubleValue = options.json && !isFinite(message.doubleValue) ? String(message.doubleValue) : message.doubleValue; + if (message.stringValue != null && message.hasOwnProperty("stringValue")) + object.stringValue = options.bytes === String ? $util.base64.encode(message.stringValue, 0, message.stringValue.length) : options.bytes === Array ? Array.prototype.slice.call(message.stringValue) : message.stringValue; + if (message.aggregateValue != null && message.hasOwnProperty("aggregateValue")) + object.aggregateValue = message.aggregateValue; + return object; + }; + + /** + * Converts this UninterpretedOption to JSON. + * @function toJSON + * @memberof google.protobuf.UninterpretedOption + * @instance + * @returns {Object.} JSON object + */ + UninterpretedOption.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + UninterpretedOption.NamePart = (function() { + + /** + * Properties of a NamePart. + * @memberof google.protobuf.UninterpretedOption + * @interface INamePart + * @property {string} namePart NamePart namePart + * @property {boolean} isExtension NamePart isExtension + */ + + /** + * Constructs a new NamePart. + * @memberof google.protobuf.UninterpretedOption + * @classdesc Represents a NamePart. + * @implements INamePart + * @constructor + * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set + */ + function NamePart(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * NamePart namePart. + * @member {string} namePart + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.namePart = ""; + + /** + * NamePart isExtension. + * @member {boolean} isExtension + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.isExtension = false; + + /** + * Creates a NamePart message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + */ + NamePart.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UninterpretedOption.NamePart) + return object; + var message = new $root.google.protobuf.UninterpretedOption.NamePart(); + if (object.namePart != null) + message.namePart = String(object.namePart); + if (object.isExtension != null) + message.isExtension = Boolean(object.isExtension); + return message; + }; + + /** + * Creates a plain object from a NamePart message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.NamePart} message NamePart + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + NamePart.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.namePart = ""; + object.isExtension = false; + } + if (message.namePart != null && message.hasOwnProperty("namePart")) + object.namePart = message.namePart; + if (message.isExtension != null && message.hasOwnProperty("isExtension")) + object.isExtension = message.isExtension; + return object; + }; + + /** + * Converts this NamePart to JSON. + * @function toJSON + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + * @returns {Object.} JSON object + */ + NamePart.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return NamePart; + })(); + + return UninterpretedOption; + })(); + + protobuf.SourceCodeInfo = (function() { + + /** + * Properties of a SourceCodeInfo. + * @memberof google.protobuf + * @interface ISourceCodeInfo + * @property {Array.|null} [location] SourceCodeInfo location + */ + + /** + * Constructs a new SourceCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a SourceCodeInfo. + * @implements ISourceCodeInfo + * @constructor + * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set + */ + function SourceCodeInfo(properties) { + this.location = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SourceCodeInfo location. + * @member {Array.} location + * @memberof google.protobuf.SourceCodeInfo + * @instance + */ + SourceCodeInfo.prototype.location = $util.emptyArray; + + /** + * Creates a SourceCodeInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + */ + SourceCodeInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.SourceCodeInfo) + return object; + var message = new $root.google.protobuf.SourceCodeInfo(); + if (object.location) { + if (!Array.isArray(object.location)) + throw TypeError(".google.protobuf.SourceCodeInfo.location: array expected"); + message.location = []; + for (var i = 0; i < object.location.length; ++i) { + if (typeof object.location[i] !== "object") + throw TypeError(".google.protobuf.SourceCodeInfo.location: object expected"); + message.location[i] = $root.google.protobuf.SourceCodeInfo.Location.fromObject(object.location[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a SourceCodeInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.SourceCodeInfo} message SourceCodeInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SourceCodeInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.location = []; + if (message.location && message.location.length) { + object.location = []; + for (var j = 0; j < message.location.length; ++j) + object.location[j] = $root.google.protobuf.SourceCodeInfo.Location.toObject(message.location[j], options); + } + return object; + }; + + /** + * Converts this SourceCodeInfo to JSON. + * @function toJSON + * @memberof google.protobuf.SourceCodeInfo + * @instance + * @returns {Object.} JSON object + */ + SourceCodeInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + SourceCodeInfo.Location = (function() { + + /** + * Properties of a Location. + * @memberof google.protobuf.SourceCodeInfo + * @interface ILocation + * @property {Array.|null} [path] Location path + * @property {Array.|null} [span] Location span + * @property {string|null} [leadingComments] Location leadingComments + * @property {string|null} [trailingComments] Location trailingComments + * @property {Array.|null} [leadingDetachedComments] Location leadingDetachedComments + */ + + /** + * Constructs a new Location. + * @memberof google.protobuf.SourceCodeInfo + * @classdesc Represents a Location. + * @implements ILocation + * @constructor + * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set + */ + function Location(properties) { + this.path = []; + this.span = []; + this.leadingDetachedComments = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Location path. + * @member {Array.} path + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.path = $util.emptyArray; + + /** + * Location span. + * @member {Array.} span + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.span = $util.emptyArray; + + /** + * Location leadingComments. + * @member {string} leadingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingComments = ""; + + /** + * Location trailingComments. + * @member {string} trailingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.trailingComments = ""; + + /** + * Location leadingDetachedComments. + * @member {Array.} leadingDetachedComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingDetachedComments = $util.emptyArray; + + /** + * Creates a Location message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.SourceCodeInfo.Location} Location + */ + Location.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.SourceCodeInfo.Location) + return object; + var message = new $root.google.protobuf.SourceCodeInfo.Location(); + if (object.path) { + if (!Array.isArray(object.path)) + throw TypeError(".google.protobuf.SourceCodeInfo.Location.path: array expected"); + message.path = []; + for (var i = 0; i < object.path.length; ++i) + message.path[i] = object.path[i] | 0; + } + if (object.span) { + if (!Array.isArray(object.span)) + throw TypeError(".google.protobuf.SourceCodeInfo.Location.span: array expected"); + message.span = []; + for (var i = 0; i < object.span.length; ++i) + message.span[i] = object.span[i] | 0; + } + if (object.leadingComments != null) + message.leadingComments = String(object.leadingComments); + if (object.trailingComments != null) + message.trailingComments = String(object.trailingComments); + if (object.leadingDetachedComments) { + if (!Array.isArray(object.leadingDetachedComments)) + throw TypeError(".google.protobuf.SourceCodeInfo.Location.leadingDetachedComments: array expected"); + message.leadingDetachedComments = []; + for (var i = 0; i < object.leadingDetachedComments.length; ++i) + message.leadingDetachedComments[i] = String(object.leadingDetachedComments[i]); + } + return message; + }; + + /** + * Creates a plain object from a Location message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.Location} message Location + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Location.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.path = []; + object.span = []; + object.leadingDetachedComments = []; + } + if (options.defaults) { + object.leadingComments = ""; + object.trailingComments = ""; + } + if (message.path && message.path.length) { + object.path = []; + for (var j = 0; j < message.path.length; ++j) + object.path[j] = message.path[j]; + } + if (message.span && message.span.length) { + object.span = []; + for (var j = 0; j < message.span.length; ++j) + object.span[j] = message.span[j]; + } + if (message.leadingComments != null && message.hasOwnProperty("leadingComments")) + object.leadingComments = message.leadingComments; + if (message.trailingComments != null && message.hasOwnProperty("trailingComments")) + object.trailingComments = message.trailingComments; + if (message.leadingDetachedComments && message.leadingDetachedComments.length) { + object.leadingDetachedComments = []; + for (var j = 0; j < message.leadingDetachedComments.length; ++j) + object.leadingDetachedComments[j] = message.leadingDetachedComments[j]; + } + return object; + }; + + /** + * Converts this Location to JSON. + * @function toJSON + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + * @returns {Object.} JSON object + */ + Location.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Location; + })(); + + return SourceCodeInfo; + })(); + + protobuf.GeneratedCodeInfo = (function() { + + /** + * Properties of a GeneratedCodeInfo. + * @memberof google.protobuf + * @interface IGeneratedCodeInfo + * @property {Array.|null} [annotation] GeneratedCodeInfo annotation + */ + + /** + * Constructs a new GeneratedCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a GeneratedCodeInfo. + * @implements IGeneratedCodeInfo + * @constructor + * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set + */ + function GeneratedCodeInfo(properties) { + this.annotation = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GeneratedCodeInfo annotation. + * @member {Array.} annotation + * @memberof google.protobuf.GeneratedCodeInfo + * @instance + */ + GeneratedCodeInfo.prototype.annotation = $util.emptyArray; + + /** + * Creates a GeneratedCodeInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + */ + GeneratedCodeInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.GeneratedCodeInfo) + return object; + var message = new $root.google.protobuf.GeneratedCodeInfo(); + if (object.annotation) { + if (!Array.isArray(object.annotation)) + throw TypeError(".google.protobuf.GeneratedCodeInfo.annotation: array expected"); + message.annotation = []; + for (var i = 0; i < object.annotation.length; ++i) { + if (typeof object.annotation[i] !== "object") + throw TypeError(".google.protobuf.GeneratedCodeInfo.annotation: object expected"); + message.annotation[i] = $root.google.protobuf.GeneratedCodeInfo.Annotation.fromObject(object.annotation[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a GeneratedCodeInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.GeneratedCodeInfo} message GeneratedCodeInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GeneratedCodeInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.annotation = []; + if (message.annotation && message.annotation.length) { + object.annotation = []; + for (var j = 0; j < message.annotation.length; ++j) + object.annotation[j] = $root.google.protobuf.GeneratedCodeInfo.Annotation.toObject(message.annotation[j], options); + } + return object; + }; + + /** + * Converts this GeneratedCodeInfo to JSON. + * @function toJSON + * @memberof google.protobuf.GeneratedCodeInfo + * @instance + * @returns {Object.} JSON object + */ + GeneratedCodeInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GeneratedCodeInfo.Annotation = (function() { + + /** + * Properties of an Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @interface IAnnotation + * @property {Array.|null} [path] Annotation path + * @property {string|null} [sourceFile] Annotation sourceFile + * @property {number|null} [begin] Annotation begin + * @property {number|null} [end] Annotation end + */ + + /** + * Constructs a new Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @classdesc Represents an Annotation. + * @implements IAnnotation + * @constructor + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set + */ + function Annotation(properties) { + this.path = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Annotation path. + * @member {Array.} path + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.path = $util.emptyArray; + + /** + * Annotation sourceFile. + * @member {string} sourceFile + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.sourceFile = ""; + + /** + * Annotation begin. + * @member {number} begin + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.begin = 0; + + /** + * Annotation end. + * @member {number} end + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.end = 0; + + /** + * Creates an Annotation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + */ + Annotation.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.GeneratedCodeInfo.Annotation) + return object; + var message = new $root.google.protobuf.GeneratedCodeInfo.Annotation(); + if (object.path) { + if (!Array.isArray(object.path)) + throw TypeError(".google.protobuf.GeneratedCodeInfo.Annotation.path: array expected"); + message.path = []; + for (var i = 0; i < object.path.length; ++i) + message.path[i] = object.path[i] | 0; + } + if (object.sourceFile != null) + message.sourceFile = String(object.sourceFile); + if (object.begin != null) + message.begin = object.begin | 0; + if (object.end != null) + message.end = object.end | 0; + return message; + }; + + /** + * Creates a plain object from an Annotation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.Annotation} message Annotation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Annotation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.path = []; + if (options.defaults) { + object.sourceFile = ""; + object.begin = 0; + object.end = 0; + } + if (message.path && message.path.length) { + object.path = []; + for (var j = 0; j < message.path.length; ++j) + object.path[j] = message.path[j]; + } + if (message.sourceFile != null && message.hasOwnProperty("sourceFile")) + object.sourceFile = message.sourceFile; + if (message.begin != null && message.hasOwnProperty("begin")) + object.begin = message.begin; + if (message.end != null && message.hasOwnProperty("end")) + object.end = message.end; + return object; + }; + + /** + * Converts this Annotation to JSON. + * @function toJSON + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + * @returns {Object.} JSON object + */ + Annotation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Annotation; + })(); + + return GeneratedCodeInfo; + })(); + + protobuf.Empty = (function() { + + /** + * Properties of an Empty. + * @memberof google.protobuf + * @interface IEmpty + */ + + /** + * Constructs a new Empty. + * @memberof google.protobuf + * @classdesc Represents an Empty. + * @implements IEmpty + * @constructor + * @param {google.protobuf.IEmpty=} [properties] Properties to set + */ + function Empty(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates an Empty message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Empty + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Empty} Empty + */ + Empty.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Empty) + return object; + return new $root.google.protobuf.Empty(); + }; + + /** + * Creates a plain object from an Empty message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.Empty} message Empty + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Empty.toObject = function toObject() { + return {}; + }; + + /** + * Converts this Empty to JSON. + * @function toJSON + * @memberof google.protobuf.Empty + * @instance + * @returns {Object.} JSON object + */ + Empty.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Empty; + })(); + + protobuf.FieldMask = (function() { + + /** + * Properties of a FieldMask. + * @memberof google.protobuf + * @interface IFieldMask + * @property {Array.|null} [paths] FieldMask paths + */ + + /** + * Constructs a new FieldMask. + * @memberof google.protobuf + * @classdesc Represents a FieldMask. + * @implements IFieldMask + * @constructor + * @param {google.protobuf.IFieldMask=} [properties] Properties to set + */ + function FieldMask(properties) { + this.paths = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldMask paths. + * @member {Array.} paths + * @memberof google.protobuf.FieldMask + * @instance + */ + FieldMask.prototype.paths = $util.emptyArray; + + /** + * Creates a FieldMask message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldMask + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldMask} FieldMask + */ + FieldMask.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldMask) + return object; + var message = new $root.google.protobuf.FieldMask(); + if (object.paths) { + if (!Array.isArray(object.paths)) + throw TypeError(".google.protobuf.FieldMask.paths: array expected"); + message.paths = []; + for (var i = 0; i < object.paths.length; ++i) + message.paths[i] = String(object.paths[i]); + } + return message; + }; + + /** + * Creates a plain object from a FieldMask message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldMask + * @static + * @param {google.protobuf.FieldMask} message FieldMask + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldMask.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.paths = []; + if (message.paths && message.paths.length) { + object.paths = []; + for (var j = 0; j < message.paths.length; ++j) + object.paths[j] = message.paths[j]; + } + return object; + }; + + /** + * Converts this FieldMask to JSON. + * @function toJSON + * @memberof google.protobuf.FieldMask + * @instance + * @returns {Object.} JSON object + */ + FieldMask.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FieldMask; + })(); + + protobuf.Timestamp = (function() { + + /** + * Properties of a Timestamp. + * @memberof google.protobuf + * @interface ITimestamp + * @property {number|string|null} [seconds] Timestamp seconds + * @property {number|null} [nanos] Timestamp nanos + */ + + /** + * Constructs a new Timestamp. + * @memberof google.protobuf + * @classdesc Represents a Timestamp. + * @implements ITimestamp + * @constructor + * @param {google.protobuf.ITimestamp=} [properties] Properties to set + */ + function Timestamp(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Timestamp seconds. + * @member {number|string} seconds + * @memberof google.protobuf.Timestamp + * @instance + */ + Timestamp.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Timestamp nanos. + * @member {number} nanos + * @memberof google.protobuf.Timestamp + * @instance + */ + Timestamp.prototype.nanos = 0; + + /** + * Creates a Timestamp message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Timestamp + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Timestamp} Timestamp + */ + Timestamp.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Timestamp) + return object; + var message = new $root.google.protobuf.Timestamp(); + if (object.seconds != null) + if ($util.Long) + (message.seconds = $util.Long.fromValue(object.seconds)).unsigned = false; + else if (typeof object.seconds === "string") + message.seconds = parseInt(object.seconds, 10); + else if (typeof object.seconds === "number") + message.seconds = object.seconds; + else if (typeof object.seconds === "object") + message.seconds = new $util.LongBits(object.seconds.low >>> 0, object.seconds.high >>> 0).toNumber(); + if (object.nanos != null) + message.nanos = object.nanos | 0; + return message; + }; + + /** + * Creates a plain object from a Timestamp message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.Timestamp} message Timestamp + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Timestamp.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.seconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.seconds = options.longs === String ? "0" : 0; + object.nanos = 0; + } + if (message.seconds != null && message.hasOwnProperty("seconds")) + if (typeof message.seconds === "number") + object.seconds = options.longs === String ? String(message.seconds) : message.seconds; + else + object.seconds = options.longs === String ? $util.Long.prototype.toString.call(message.seconds) : options.longs === Number ? new $util.LongBits(message.seconds.low >>> 0, message.seconds.high >>> 0).toNumber() : message.seconds; + if (message.nanos != null && message.hasOwnProperty("nanos")) + object.nanos = message.nanos; + return object; + }; + + /** + * Converts this Timestamp to JSON. + * @function toJSON + * @memberof google.protobuf.Timestamp + * @instance + * @returns {Object.} JSON object + */ + Timestamp.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Timestamp; + })(); + + protobuf.Any = (function() { + + /** + * Properties of an Any. + * @memberof google.protobuf + * @interface IAny + * @property {string|null} [type_url] Any type_url + * @property {Uint8Array|null} [value] Any value + */ + + /** + * Constructs a new Any. + * @memberof google.protobuf + * @classdesc Represents an Any. + * @implements IAny + * @constructor + * @param {google.protobuf.IAny=} [properties] Properties to set + */ + function Any(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Any type_url. + * @member {string} type_url + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.type_url = ""; + + /** + * Any value. + * @member {Uint8Array} value + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.value = $util.newBuffer([]); + + /** + * Creates an Any message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Any + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Any} Any + */ + Any.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Any) + return object; + var message = new $root.google.protobuf.Any(); + if (object.type_url != null) + message.type_url = String(object.type_url); + if (object.value != null) + if (typeof object.value === "string") + $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); + else if (object.value.length) + message.value = object.value; + return message; + }; + + /** + * Creates a plain object from an Any message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.Any} message Any + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Any.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.type_url = ""; + if (options.bytes === String) + object.value = ""; + else { + object.value = []; + if (options.bytes !== Array) + object.value = $util.newBuffer(object.value); + } + } + if (message.type_url != null && message.hasOwnProperty("type_url")) + object.type_url = message.type_url; + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; + return object; + }; + + /** + * Converts this Any to JSON. + * @function toJSON + * @memberof google.protobuf.Any + * @instance + * @returns {Object.} JSON object + */ + Any.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Any; + })(); + + protobuf.Struct = (function() { + + /** + * Properties of a Struct. + * @memberof google.protobuf + * @interface IStruct + * @property {Object.|null} [fields] Struct fields + */ + + /** + * Constructs a new Struct. + * @memberof google.protobuf + * @classdesc Represents a Struct. + * @implements IStruct + * @constructor + * @param {google.protobuf.IStruct=} [properties] Properties to set + */ + function Struct(properties) { + this.fields = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Struct fields. + * @member {Object.} fields + * @memberof google.protobuf.Struct + * @instance + */ + Struct.prototype.fields = $util.emptyObject; + + /** + * Creates a Struct message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Struct + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Struct} Struct + */ + Struct.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Struct) + return object; + var message = new $root.google.protobuf.Struct(); + if (object.fields) { + if (typeof object.fields !== "object") + throw TypeError(".google.protobuf.Struct.fields: object expected"); + message.fields = {}; + for (var keys = Object.keys(object.fields), i = 0; i < keys.length; ++i) { + if (typeof object.fields[keys[i]] !== "object") + throw TypeError(".google.protobuf.Struct.fields: object expected"); + message.fields[keys[i]] = $root.google.protobuf.Value.fromObject(object.fields[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from a Struct message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Struct + * @static + * @param {google.protobuf.Struct} message Struct + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Struct.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.fields = {}; + var keys2; + if (message.fields && (keys2 = Object.keys(message.fields)).length) { + object.fields = {}; + for (var j = 0; j < keys2.length; ++j) + object.fields[keys2[j]] = $root.google.protobuf.Value.toObject(message.fields[keys2[j]], options); + } + return object; + }; + + /** + * Converts this Struct to JSON. + * @function toJSON + * @memberof google.protobuf.Struct + * @instance + * @returns {Object.} JSON object + */ + Struct.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Struct; + })(); + + protobuf.Value = (function() { + + /** + * Properties of a Value. + * @memberof google.protobuf + * @interface IValue + * @property {google.protobuf.NullValue|null} [nullValue] Value nullValue + * @property {number|null} [numberValue] Value numberValue + * @property {string|null} [stringValue] Value stringValue + * @property {boolean|null} [boolValue] Value boolValue + * @property {google.protobuf.IStruct|null} [structValue] Value structValue + * @property {google.protobuf.IListValue|null} [listValue] Value listValue + */ + + /** + * Constructs a new Value. + * @memberof google.protobuf + * @classdesc Represents a Value. + * @implements IValue + * @constructor + * @param {google.protobuf.IValue=} [properties] Properties to set + */ + function Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Value nullValue. + * @member {google.protobuf.NullValue} nullValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.nullValue = 0; + + /** + * Value numberValue. + * @member {number} numberValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.numberValue = 0; + + /** + * Value stringValue. + * @member {string} stringValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.stringValue = ""; + + /** + * Value boolValue. + * @member {boolean} boolValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.boolValue = false; + + /** + * Value structValue. + * @member {google.protobuf.IStruct|null|undefined} structValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.structValue = null; + + /** + * Value listValue. + * @member {google.protobuf.IListValue|null|undefined} listValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.listValue = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Value kind. + * @member {"nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"|undefined} kind + * @memberof google.protobuf.Value + * @instance + */ + Object.defineProperty(Value.prototype, "kind", { + get: $util.oneOfGetter($oneOfFields = ["nullValue", "numberValue", "stringValue", "boolValue", "structValue", "listValue"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Value} Value + */ + Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Value) + return object; + var message = new $root.google.protobuf.Value(); + switch (object.nullValue) { + case "NULL_VALUE": + case 0: + message.nullValue = 0; + break; + } + if (object.numberValue != null) + message.numberValue = Number(object.numberValue); + if (object.stringValue != null) + message.stringValue = String(object.stringValue); + if (object.boolValue != null) + message.boolValue = Boolean(object.boolValue); + if (object.structValue != null) { + if (typeof object.structValue !== "object") + throw TypeError(".google.protobuf.Value.structValue: object expected"); + message.structValue = $root.google.protobuf.Struct.fromObject(object.structValue); + } + if (object.listValue != null) { + if (typeof object.listValue !== "object") + throw TypeError(".google.protobuf.Value.listValue: object expected"); + message.listValue = $root.google.protobuf.ListValue.fromObject(object.listValue); + } + return message; + }; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Value + * @static + * @param {google.protobuf.Value} message Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.nullValue != null && message.hasOwnProperty("nullValue")) { + object.nullValue = options.enums === String ? $root.google.protobuf.NullValue[message.nullValue] : message.nullValue; + if (options.oneofs) + object.kind = "nullValue"; + } + if (message.numberValue != null && message.hasOwnProperty("numberValue")) { + object.numberValue = options.json && !isFinite(message.numberValue) ? String(message.numberValue) : message.numberValue; + if (options.oneofs) + object.kind = "numberValue"; + } + if (message.stringValue != null && message.hasOwnProperty("stringValue")) { + object.stringValue = message.stringValue; + if (options.oneofs) + object.kind = "stringValue"; + } + if (message.boolValue != null && message.hasOwnProperty("boolValue")) { + object.boolValue = message.boolValue; + if (options.oneofs) + object.kind = "boolValue"; + } + if (message.structValue != null && message.hasOwnProperty("structValue")) { + object.structValue = $root.google.protobuf.Struct.toObject(message.structValue, options); + if (options.oneofs) + object.kind = "structValue"; + } + if (message.listValue != null && message.hasOwnProperty("listValue")) { + object.listValue = $root.google.protobuf.ListValue.toObject(message.listValue, options); + if (options.oneofs) + object.kind = "listValue"; + } + return object; + }; + + /** + * Converts this Value to JSON. + * @function toJSON + * @memberof google.protobuf.Value + * @instance + * @returns {Object.} JSON object + */ + Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Value; + })(); + /** - * CancelOperationRequest name. - * @member {string} name - * @memberof google.longrunning.CancelOperationRequest - * @instance + * NullValue enum. + * @name google.protobuf.NullValue + * @enum {string} + * @property {string} NULL_VALUE=NULL_VALUE NULL_VALUE value */ - CancelOperationRequest.prototype.name = ""; - - return CancelOperationRequest; + protobuf.NullValue = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "NULL_VALUE"] = "NULL_VALUE"; + return values; + })(); + + protobuf.ListValue = (function() { + + /** + * Properties of a ListValue. + * @memberof google.protobuf + * @interface IListValue + * @property {Array.|null} [values] ListValue values + */ + + /** + * Constructs a new ListValue. + * @memberof google.protobuf + * @classdesc Represents a ListValue. + * @implements IListValue + * @constructor + * @param {google.protobuf.IListValue=} [properties] Properties to set + */ + function ListValue(properties) { + this.values = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListValue values. + * @member {Array.} values + * @memberof google.protobuf.ListValue + * @instance + */ + ListValue.prototype.values = $util.emptyArray; + + /** + * Creates a ListValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ListValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ListValue} ListValue + */ + ListValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ListValue) + return object; + var message = new $root.google.protobuf.ListValue(); + if (object.values) { + if (!Array.isArray(object.values)) + throw TypeError(".google.protobuf.ListValue.values: array expected"); + message.values = []; + for (var i = 0; i < object.values.length; ++i) { + if (typeof object.values[i] !== "object") + throw TypeError(".google.protobuf.ListValue.values: object expected"); + message.values[i] = $root.google.protobuf.Value.fromObject(object.values[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a ListValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ListValue + * @static + * @param {google.protobuf.ListValue} message ListValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.values = []; + if (message.values && message.values.length) { + object.values = []; + for (var j = 0; j < message.values.length; ++j) + object.values[j] = $root.google.protobuf.Value.toObject(message.values[j], options); + } + return object; + }; + + /** + * Converts this ListValue to JSON. + * @function toJSON + * @memberof google.protobuf.ListValue + * @instance + * @returns {Object.} JSON object + */ + ListValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListValue; + })(); + + protobuf.DoubleValue = (function() { + + /** + * Properties of a DoubleValue. + * @memberof google.protobuf + * @interface IDoubleValue + * @property {number|null} [value] DoubleValue value + */ + + /** + * Constructs a new DoubleValue. + * @memberof google.protobuf + * @classdesc Represents a DoubleValue. + * @implements IDoubleValue + * @constructor + * @param {google.protobuf.IDoubleValue=} [properties] Properties to set + */ + function DoubleValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DoubleValue value. + * @member {number} value + * @memberof google.protobuf.DoubleValue + * @instance + */ + DoubleValue.prototype.value = 0; + + /** + * Creates a DoubleValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DoubleValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DoubleValue} DoubleValue + */ + DoubleValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DoubleValue) + return object; + var message = new $root.google.protobuf.DoubleValue(); + if (object.value != null) + message.value = Number(object.value); + return message; + }; + + /** + * Creates a plain object from a DoubleValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DoubleValue + * @static + * @param {google.protobuf.DoubleValue} message DoubleValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DoubleValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = 0; + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.json && !isFinite(message.value) ? String(message.value) : message.value; + return object; + }; + + /** + * Converts this DoubleValue to JSON. + * @function toJSON + * @memberof google.protobuf.DoubleValue + * @instance + * @returns {Object.} JSON object + */ + DoubleValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DoubleValue; + })(); + + protobuf.FloatValue = (function() { + + /** + * Properties of a FloatValue. + * @memberof google.protobuf + * @interface IFloatValue + * @property {number|null} [value] FloatValue value + */ + + /** + * Constructs a new FloatValue. + * @memberof google.protobuf + * @classdesc Represents a FloatValue. + * @implements IFloatValue + * @constructor + * @param {google.protobuf.IFloatValue=} [properties] Properties to set + */ + function FloatValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FloatValue value. + * @member {number} value + * @memberof google.protobuf.FloatValue + * @instance + */ + FloatValue.prototype.value = 0; + + /** + * Creates a FloatValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FloatValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FloatValue} FloatValue + */ + FloatValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FloatValue) + return object; + var message = new $root.google.protobuf.FloatValue(); + if (object.value != null) + message.value = Number(object.value); + return message; + }; + + /** + * Creates a plain object from a FloatValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FloatValue + * @static + * @param {google.protobuf.FloatValue} message FloatValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FloatValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = 0; + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.json && !isFinite(message.value) ? String(message.value) : message.value; + return object; + }; + + /** + * Converts this FloatValue to JSON. + * @function toJSON + * @memberof google.protobuf.FloatValue + * @instance + * @returns {Object.} JSON object + */ + FloatValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FloatValue; + })(); + + protobuf.Int64Value = (function() { + + /** + * Properties of an Int64Value. + * @memberof google.protobuf + * @interface IInt64Value + * @property {number|string|null} [value] Int64Value value + */ + + /** + * Constructs a new Int64Value. + * @memberof google.protobuf + * @classdesc Represents an Int64Value. + * @implements IInt64Value + * @constructor + * @param {google.protobuf.IInt64Value=} [properties] Properties to set + */ + function Int64Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Int64Value value. + * @member {number|string} value + * @memberof google.protobuf.Int64Value + * @instance + */ + Int64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates an Int64Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Int64Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Int64Value} Int64Value + */ + Int64Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Int64Value) + return object; + var message = new $root.google.protobuf.Int64Value(); + if (object.value != null) + if ($util.Long) + (message.value = $util.Long.fromValue(object.value)).unsigned = false; + else if (typeof object.value === "string") + message.value = parseInt(object.value, 10); + else if (typeof object.value === "number") + message.value = object.value; + else if (typeof object.value === "object") + message.value = new $util.LongBits(object.value.low >>> 0, object.value.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from an Int64Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Int64Value + * @static + * @param {google.protobuf.Int64Value} message Int64Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Int64Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.value = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.value = options.longs === String ? "0" : 0; + if (message.value != null && message.hasOwnProperty("value")) + if (typeof message.value === "number") + object.value = options.longs === String ? String(message.value) : message.value; + else + object.value = options.longs === String ? $util.Long.prototype.toString.call(message.value) : options.longs === Number ? new $util.LongBits(message.value.low >>> 0, message.value.high >>> 0).toNumber() : message.value; + return object; + }; + + /** + * Converts this Int64Value to JSON. + * @function toJSON + * @memberof google.protobuf.Int64Value + * @instance + * @returns {Object.} JSON object + */ + Int64Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Int64Value; + })(); + + protobuf.UInt64Value = (function() { + + /** + * Properties of a UInt64Value. + * @memberof google.protobuf + * @interface IUInt64Value + * @property {number|string|null} [value] UInt64Value value + */ + + /** + * Constructs a new UInt64Value. + * @memberof google.protobuf + * @classdesc Represents a UInt64Value. + * @implements IUInt64Value + * @constructor + * @param {google.protobuf.IUInt64Value=} [properties] Properties to set + */ + function UInt64Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UInt64Value value. + * @member {number|string} value + * @memberof google.protobuf.UInt64Value + * @instance + */ + UInt64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Creates a UInt64Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UInt64Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UInt64Value} UInt64Value + */ + UInt64Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UInt64Value) + return object; + var message = new $root.google.protobuf.UInt64Value(); + if (object.value != null) + if ($util.Long) + (message.value = $util.Long.fromValue(object.value)).unsigned = true; + else if (typeof object.value === "string") + message.value = parseInt(object.value, 10); + else if (typeof object.value === "number") + message.value = object.value; + else if (typeof object.value === "object") + message.value = new $util.LongBits(object.value.low >>> 0, object.value.high >>> 0).toNumber(true); + return message; + }; + + /** + * Creates a plain object from a UInt64Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UInt64Value + * @static + * @param {google.protobuf.UInt64Value} message UInt64Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UInt64Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.value = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.value = options.longs === String ? "0" : 0; + if (message.value != null && message.hasOwnProperty("value")) + if (typeof message.value === "number") + object.value = options.longs === String ? String(message.value) : message.value; + else + object.value = options.longs === String ? $util.Long.prototype.toString.call(message.value) : options.longs === Number ? new $util.LongBits(message.value.low >>> 0, message.value.high >>> 0).toNumber(true) : message.value; + return object; + }; + + /** + * Converts this UInt64Value to JSON. + * @function toJSON + * @memberof google.protobuf.UInt64Value + * @instance + * @returns {Object.} JSON object + */ + UInt64Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return UInt64Value; + })(); + + protobuf.Int32Value = (function() { + + /** + * Properties of an Int32Value. + * @memberof google.protobuf + * @interface IInt32Value + * @property {number|null} [value] Int32Value value + */ + + /** + * Constructs a new Int32Value. + * @memberof google.protobuf + * @classdesc Represents an Int32Value. + * @implements IInt32Value + * @constructor + * @param {google.protobuf.IInt32Value=} [properties] Properties to set + */ + function Int32Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Int32Value value. + * @member {number} value + * @memberof google.protobuf.Int32Value + * @instance + */ + Int32Value.prototype.value = 0; + + /** + * Creates an Int32Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Int32Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Int32Value} Int32Value + */ + Int32Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Int32Value) + return object; + var message = new $root.google.protobuf.Int32Value(); + if (object.value != null) + message.value = object.value | 0; + return message; + }; + + /** + * Creates a plain object from an Int32Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Int32Value + * @static + * @param {google.protobuf.Int32Value} message Int32Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Int32Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = 0; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this Int32Value to JSON. + * @function toJSON + * @memberof google.protobuf.Int32Value + * @instance + * @returns {Object.} JSON object + */ + Int32Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Int32Value; + })(); + + protobuf.UInt32Value = (function() { + + /** + * Properties of a UInt32Value. + * @memberof google.protobuf + * @interface IUInt32Value + * @property {number|null} [value] UInt32Value value + */ + + /** + * Constructs a new UInt32Value. + * @memberof google.protobuf + * @classdesc Represents a UInt32Value. + * @implements IUInt32Value + * @constructor + * @param {google.protobuf.IUInt32Value=} [properties] Properties to set + */ + function UInt32Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UInt32Value value. + * @member {number} value + * @memberof google.protobuf.UInt32Value + * @instance + */ + UInt32Value.prototype.value = 0; + + /** + * Creates a UInt32Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UInt32Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UInt32Value} UInt32Value + */ + UInt32Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UInt32Value) + return object; + var message = new $root.google.protobuf.UInt32Value(); + if (object.value != null) + message.value = object.value >>> 0; + return message; + }; + + /** + * Creates a plain object from a UInt32Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UInt32Value + * @static + * @param {google.protobuf.UInt32Value} message UInt32Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UInt32Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = 0; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this UInt32Value to JSON. + * @function toJSON + * @memberof google.protobuf.UInt32Value + * @instance + * @returns {Object.} JSON object + */ + UInt32Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return UInt32Value; + })(); + + protobuf.BoolValue = (function() { + + /** + * Properties of a BoolValue. + * @memberof google.protobuf + * @interface IBoolValue + * @property {boolean|null} [value] BoolValue value + */ + + /** + * Constructs a new BoolValue. + * @memberof google.protobuf + * @classdesc Represents a BoolValue. + * @implements IBoolValue + * @constructor + * @param {google.protobuf.IBoolValue=} [properties] Properties to set + */ + function BoolValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BoolValue value. + * @member {boolean} value + * @memberof google.protobuf.BoolValue + * @instance + */ + BoolValue.prototype.value = false; + + /** + * Creates a BoolValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.BoolValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.BoolValue} BoolValue + */ + BoolValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.BoolValue) + return object; + var message = new $root.google.protobuf.BoolValue(); + if (object.value != null) + message.value = Boolean(object.value); + return message; + }; + + /** + * Creates a plain object from a BoolValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.BoolValue + * @static + * @param {google.protobuf.BoolValue} message BoolValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BoolValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = false; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this BoolValue to JSON. + * @function toJSON + * @memberof google.protobuf.BoolValue + * @instance + * @returns {Object.} JSON object + */ + BoolValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BoolValue; + })(); + + protobuf.StringValue = (function() { + + /** + * Properties of a StringValue. + * @memberof google.protobuf + * @interface IStringValue + * @property {string|null} [value] StringValue value + */ + + /** + * Constructs a new StringValue. + * @memberof google.protobuf + * @classdesc Represents a StringValue. + * @implements IStringValue + * @constructor + * @param {google.protobuf.IStringValue=} [properties] Properties to set + */ + function StringValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StringValue value. + * @member {string} value + * @memberof google.protobuf.StringValue + * @instance + */ + StringValue.prototype.value = ""; + + /** + * Creates a StringValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.StringValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.StringValue} StringValue + */ + StringValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.StringValue) + return object; + var message = new $root.google.protobuf.StringValue(); + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from a StringValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.StringValue + * @static + * @param {google.protobuf.StringValue} message StringValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StringValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = ""; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this StringValue to JSON. + * @function toJSON + * @memberof google.protobuf.StringValue + * @instance + * @returns {Object.} JSON object + */ + StringValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return StringValue; + })(); + + protobuf.BytesValue = (function() { + + /** + * Properties of a BytesValue. + * @memberof google.protobuf + * @interface IBytesValue + * @property {Uint8Array|null} [value] BytesValue value + */ + + /** + * Constructs a new BytesValue. + * @memberof google.protobuf + * @classdesc Represents a BytesValue. + * @implements IBytesValue + * @constructor + * @param {google.protobuf.IBytesValue=} [properties] Properties to set + */ + function BytesValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BytesValue value. + * @member {Uint8Array} value + * @memberof google.protobuf.BytesValue + * @instance + */ + BytesValue.prototype.value = $util.newBuffer([]); + + /** + * Creates a BytesValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.BytesValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.BytesValue} BytesValue + */ + BytesValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.BytesValue) + return object; + var message = new $root.google.protobuf.BytesValue(); + if (object.value != null) + if (typeof object.value === "string") + $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); + else if (object.value.length) + message.value = object.value; + return message; + }; + + /** + * Creates a plain object from a BytesValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.BytesValue + * @static + * @param {google.protobuf.BytesValue} message BytesValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BytesValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.value = ""; + else { + object.value = []; + if (options.bytes !== Array) + object.value = $util.newBuffer(object.value); + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; + return object; + }; + + /** + * Converts this BytesValue to JSON. + * @function toJSON + * @memberof google.protobuf.BytesValue + * @instance + * @returns {Object.} JSON object + */ + BytesValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BytesValue; + })(); + + protobuf.Duration = (function() { + + /** + * Properties of a Duration. + * @memberof google.protobuf + * @interface IDuration + * @property {number|string|null} [seconds] Duration seconds + * @property {number|null} [nanos] Duration nanos + */ + + /** + * Constructs a new Duration. + * @memberof google.protobuf + * @classdesc Represents a Duration. + * @implements IDuration + * @constructor + * @param {google.protobuf.IDuration=} [properties] Properties to set + */ + function Duration(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Duration seconds. + * @member {number|string} seconds + * @memberof google.protobuf.Duration + * @instance + */ + Duration.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Duration nanos. + * @member {number} nanos + * @memberof google.protobuf.Duration + * @instance + */ + Duration.prototype.nanos = 0; + + /** + * Creates a Duration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Duration + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Duration} Duration + */ + Duration.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Duration) + return object; + var message = new $root.google.protobuf.Duration(); + if (object.seconds != null) + if ($util.Long) + (message.seconds = $util.Long.fromValue(object.seconds)).unsigned = false; + else if (typeof object.seconds === "string") + message.seconds = parseInt(object.seconds, 10); + else if (typeof object.seconds === "number") + message.seconds = object.seconds; + else if (typeof object.seconds === "object") + message.seconds = new $util.LongBits(object.seconds.low >>> 0, object.seconds.high >>> 0).toNumber(); + if (object.nanos != null) + message.nanos = object.nanos | 0; + return message; + }; + + /** + * Creates a plain object from a Duration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Duration + * @static + * @param {google.protobuf.Duration} message Duration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Duration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.seconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.seconds = options.longs === String ? "0" : 0; + object.nanos = 0; + } + if (message.seconds != null && message.hasOwnProperty("seconds")) + if (typeof message.seconds === "number") + object.seconds = options.longs === String ? String(message.seconds) : message.seconds; + else + object.seconds = options.longs === String ? $util.Long.prototype.toString.call(message.seconds) : options.longs === Number ? new $util.LongBits(message.seconds.low >>> 0, message.seconds.high >>> 0).toNumber() : message.seconds; + if (message.nanos != null && message.hasOwnProperty("nanos")) + object.nanos = message.nanos; + return object; + }; + + /** + * Converts this Duration to JSON. + * @function toJSON + * @memberof google.protobuf.Duration + * @instance + * @returns {Object.} JSON object + */ + Duration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Duration; + })(); + + return protobuf; })(); - - longrunning.DeleteOperationRequest = (function() { - - /** - * Properties of a DeleteOperationRequest. - * @memberof google.longrunning - * @interface IDeleteOperationRequest - * @property {string|null} [name] DeleteOperationRequest name - */ - - /** - * Constructs a new DeleteOperationRequest. - * @memberof google.longrunning - * @classdesc Represents a DeleteOperationRequest. - * @implements IDeleteOperationRequest - * @constructor - * @param {google.longrunning.IDeleteOperationRequest=} [properties] Properties to set - */ - function DeleteOperationRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - + + google.type = (function() { + /** - * DeleteOperationRequest name. - * @member {string} name - * @memberof google.longrunning.DeleteOperationRequest - * @instance + * Namespace type. + * @memberof google + * @namespace */ - DeleteOperationRequest.prototype.name = ""; - - return DeleteOperationRequest; + var type = {}; + + type.LatLng = (function() { + + /** + * Properties of a LatLng. + * @memberof google.type + * @interface ILatLng + * @property {number|null} [latitude] LatLng latitude + * @property {number|null} [longitude] LatLng longitude + */ + + /** + * Constructs a new LatLng. + * @memberof google.type + * @classdesc Represents a LatLng. + * @implements ILatLng + * @constructor + * @param {google.type.ILatLng=} [properties] Properties to set + */ + function LatLng(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LatLng latitude. + * @member {number} latitude + * @memberof google.type.LatLng + * @instance + */ + LatLng.prototype.latitude = 0; + + /** + * LatLng longitude. + * @member {number} longitude + * @memberof google.type.LatLng + * @instance + */ + LatLng.prototype.longitude = 0; + + /** + * Creates a LatLng message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.type.LatLng + * @static + * @param {Object.} object Plain object + * @returns {google.type.LatLng} LatLng + */ + LatLng.fromObject = function fromObject(object) { + if (object instanceof $root.google.type.LatLng) + return object; + var message = new $root.google.type.LatLng(); + if (object.latitude != null) + message.latitude = Number(object.latitude); + if (object.longitude != null) + message.longitude = Number(object.longitude); + return message; + }; + + /** + * Creates a plain object from a LatLng message. Also converts values to other types if specified. + * @function toObject + * @memberof google.type.LatLng + * @static + * @param {google.type.LatLng} message LatLng + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LatLng.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.latitude = 0; + object.longitude = 0; + } + if (message.latitude != null && message.hasOwnProperty("latitude")) + object.latitude = options.json && !isFinite(message.latitude) ? String(message.latitude) : message.latitude; + if (message.longitude != null && message.hasOwnProperty("longitude")) + object.longitude = options.json && !isFinite(message.longitude) ? String(message.longitude) : message.longitude; + return object; + }; + + /** + * Converts this LatLng to JSON. + * @function toJSON + * @memberof google.type.LatLng + * @instance + * @returns {Object.} JSON object + */ + LatLng.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return LatLng; + })(); + + return type; })(); - - longrunning.WaitOperationRequest = (function() { - - /** - * Properties of a WaitOperationRequest. - * @memberof google.longrunning - * @interface IWaitOperationRequest - * @property {string|null} [name] WaitOperationRequest name - * @property {google.protobuf.IDuration|null} [timeout] WaitOperationRequest timeout - */ - + + google.rpc = (function() { + /** - * Constructs a new WaitOperationRequest. - * @memberof google.longrunning - * @classdesc Represents a WaitOperationRequest. - * @implements IWaitOperationRequest - * @constructor - * @param {google.longrunning.IWaitOperationRequest=} [properties] Properties to set - */ - function WaitOperationRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * WaitOperationRequest name. - * @member {string} name - * @memberof google.longrunning.WaitOperationRequest - * @instance - */ - WaitOperationRequest.prototype.name = ""; - - /** - * WaitOperationRequest timeout. - * @member {google.protobuf.IDuration|null|undefined} timeout - * @memberof google.longrunning.WaitOperationRequest - * @instance + * Namespace rpc. + * @memberof google + * @namespace */ - WaitOperationRequest.prototype.timeout = null; - - return WaitOperationRequest; + var rpc = {}; + + rpc.Status = (function() { + + /** + * Properties of a Status. + * @memberof google.rpc + * @interface IStatus + * @property {number|null} [code] Status code + * @property {string|null} [message] Status message + * @property {Array.|null} [details] Status details + */ + + /** + * Constructs a new Status. + * @memberof google.rpc + * @classdesc Represents a Status. + * @implements IStatus + * @constructor + * @param {google.rpc.IStatus=} [properties] Properties to set + */ + function Status(properties) { + this.details = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Status code. + * @member {number} code + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.code = 0; + + /** + * Status message. + * @member {string} message + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.message = ""; + + /** + * Status details. + * @member {Array.} details + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.details = $util.emptyArray; + + /** + * Creates a Status message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.rpc.Status + * @static + * @param {Object.} object Plain object + * @returns {google.rpc.Status} Status + */ + Status.fromObject = function fromObject(object) { + if (object instanceof $root.google.rpc.Status) + return object; + var message = new $root.google.rpc.Status(); + if (object.code != null) + message.code = object.code | 0; + if (object.message != null) + message.message = String(object.message); + if (object.details) { + if (!Array.isArray(object.details)) + throw TypeError(".google.rpc.Status.details: array expected"); + message.details = []; + for (var i = 0; i < object.details.length; ++i) { + if (typeof object.details[i] !== "object") + throw TypeError(".google.rpc.Status.details: object expected"); + message.details[i] = $root.google.protobuf.Any.fromObject(object.details[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Status message. Also converts values to other types if specified. + * @function toObject + * @memberof google.rpc.Status + * @static + * @param {google.rpc.Status} message Status + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Status.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.details = []; + if (options.defaults) { + object.code = 0; + object.message = ""; + } + if (message.code != null && message.hasOwnProperty("code")) + object.code = message.code; + if (message.message != null && message.hasOwnProperty("message")) + object.message = message.message; + if (message.details && message.details.length) { + object.details = []; + for (var j = 0; j < message.details.length; ++j) + object.details[j] = $root.google.protobuf.Any.toObject(message.details[j], options); + } + return object; + }; + + /** + * Converts this Status to JSON. + * @function toJSON + * @memberof google.rpc.Status + * @instance + * @returns {Object.} JSON object + */ + Status.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Status; + })(); + + return rpc; })(); - - longrunning.OperationInfo = (function() { - - /** - * Properties of an OperationInfo. - * @memberof google.longrunning - * @interface IOperationInfo - * @property {string|null} [responseType] OperationInfo responseType - * @property {string|null} [metadataType] OperationInfo metadataType - */ - - /** - * Constructs a new OperationInfo. - * @memberof google.longrunning - * @classdesc Represents an OperationInfo. - * @implements IOperationInfo - * @constructor - * @param {google.longrunning.IOperationInfo=} [properties] Properties to set - */ - function OperationInfo(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * OperationInfo responseType. - * @member {string} responseType - * @memberof google.longrunning.OperationInfo - * @instance - */ - OperationInfo.prototype.responseType = ""; - + + google.longrunning = (function() { + /** - * OperationInfo metadataType. - * @member {string} metadataType - * @memberof google.longrunning.OperationInfo - * @instance + * Namespace longrunning. + * @memberof google + * @namespace */ - OperationInfo.prototype.metadataType = ""; - - return OperationInfo; + var longrunning = {}; + + longrunning.Operations = (function() { + + /** + * Constructs a new Operations service. + * @memberof google.longrunning + * @classdesc Represents an Operations + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function Operations(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (Operations.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Operations; + + /** + * Callback as used by {@link google.longrunning.Operations#listOperations}. + * @memberof google.longrunning.Operations + * @typedef ListOperationsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.ListOperationsResponse} [response] ListOperationsResponse + */ + + /** + * Calls ListOperations. + * @function listOperations + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object + * @param {google.longrunning.Operations.ListOperationsCallback} callback Node-style callback called with the error, if any, and ListOperationsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.listOperations = function listOperations(request, callback) { + return this.rpcCall(listOperations, $root.google.longrunning.ListOperationsRequest, $root.google.longrunning.ListOperationsResponse, request, callback); + }, "name", { value: "ListOperations" }); + + /** + * Calls ListOperations. + * @function listOperations + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#getOperation}. + * @memberof google.longrunning.Operations + * @typedef GetOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls GetOperation. + * @function getOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object + * @param {google.longrunning.Operations.GetOperationCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.getOperation = function getOperation(request, callback) { + return this.rpcCall(getOperation, $root.google.longrunning.GetOperationRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "GetOperation" }); + + /** + * Calls GetOperation. + * @function getOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#deleteOperation}. + * @memberof google.longrunning.Operations + * @typedef DeleteOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteOperation. + * @function deleteOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object + * @param {google.longrunning.Operations.DeleteOperationCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.deleteOperation = function deleteOperation(request, callback) { + return this.rpcCall(deleteOperation, $root.google.longrunning.DeleteOperationRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteOperation" }); + + /** + * Calls DeleteOperation. + * @function deleteOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#cancelOperation}. + * @memberof google.longrunning.Operations + * @typedef CancelOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls CancelOperation. + * @function cancelOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object + * @param {google.longrunning.Operations.CancelOperationCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.cancelOperation = function cancelOperation(request, callback) { + return this.rpcCall(cancelOperation, $root.google.longrunning.CancelOperationRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "CancelOperation" }); + + /** + * Calls CancelOperation. + * @function cancelOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#waitOperation}. + * @memberof google.longrunning.Operations + * @typedef WaitOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls WaitOperation. + * @function waitOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object + * @param {google.longrunning.Operations.WaitOperationCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.waitOperation = function waitOperation(request, callback) { + return this.rpcCall(waitOperation, $root.google.longrunning.WaitOperationRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "WaitOperation" }); + + /** + * Calls WaitOperation. + * @function waitOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return Operations; + })(); + + longrunning.Operation = (function() { + + /** + * Properties of an Operation. + * @memberof google.longrunning + * @interface IOperation + * @property {string|null} [name] Operation name + * @property {google.protobuf.IAny|null} [metadata] Operation metadata + * @property {boolean|null} [done] Operation done + * @property {google.rpc.IStatus|null} [error] Operation error + * @property {google.protobuf.IAny|null} [response] Operation response + */ + + /** + * Constructs a new Operation. + * @memberof google.longrunning + * @classdesc Represents an Operation. + * @implements IOperation + * @constructor + * @param {google.longrunning.IOperation=} [properties] Properties to set + */ + function Operation(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Operation name. + * @member {string} name + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.name = ""; + + /** + * Operation metadata. + * @member {google.protobuf.IAny|null|undefined} metadata + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.metadata = null; + + /** + * Operation done. + * @member {boolean} done + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.done = false; + + /** + * Operation error. + * @member {google.rpc.IStatus|null|undefined} error + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.error = null; + + /** + * Operation response. + * @member {google.protobuf.IAny|null|undefined} response + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.response = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Operation result. + * @member {"error"|"response"|undefined} result + * @memberof google.longrunning.Operation + * @instance + */ + Object.defineProperty(Operation.prototype, "result", { + get: $util.oneOfGetter($oneOfFields = ["error", "response"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates an Operation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.Operation + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.Operation} Operation + */ + Operation.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.Operation) + return object; + var message = new $root.google.longrunning.Operation(); + if (object.name != null) + message.name = String(object.name); + if (object.metadata != null) { + if (typeof object.metadata !== "object") + throw TypeError(".google.longrunning.Operation.metadata: object expected"); + message.metadata = $root.google.protobuf.Any.fromObject(object.metadata); + } + if (object.done != null) + message.done = Boolean(object.done); + if (object.error != null) { + if (typeof object.error !== "object") + throw TypeError(".google.longrunning.Operation.error: object expected"); + message.error = $root.google.rpc.Status.fromObject(object.error); + } + if (object.response != null) { + if (typeof object.response !== "object") + throw TypeError(".google.longrunning.Operation.response: object expected"); + message.response = $root.google.protobuf.Any.fromObject(object.response); + } + return message; + }; + + /** + * Creates a plain object from an Operation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.Operation + * @static + * @param {google.longrunning.Operation} message Operation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Operation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.metadata = null; + object.done = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.metadata != null && message.hasOwnProperty("metadata")) + object.metadata = $root.google.protobuf.Any.toObject(message.metadata, options); + if (message.done != null && message.hasOwnProperty("done")) + object.done = message.done; + if (message.error != null && message.hasOwnProperty("error")) { + object.error = $root.google.rpc.Status.toObject(message.error, options); + if (options.oneofs) + object.result = "error"; + } + if (message.response != null && message.hasOwnProperty("response")) { + object.response = $root.google.protobuf.Any.toObject(message.response, options); + if (options.oneofs) + object.result = "response"; + } + return object; + }; + + /** + * Converts this Operation to JSON. + * @function toJSON + * @memberof google.longrunning.Operation + * @instance + * @returns {Object.} JSON object + */ + Operation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Operation; + })(); + + longrunning.GetOperationRequest = (function() { + + /** + * Properties of a GetOperationRequest. + * @memberof google.longrunning + * @interface IGetOperationRequest + * @property {string|null} [name] GetOperationRequest name + */ + + /** + * Constructs a new GetOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a GetOperationRequest. + * @implements IGetOperationRequest + * @constructor + * @param {google.longrunning.IGetOperationRequest=} [properties] Properties to set + */ + function GetOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetOperationRequest name. + * @member {string} name + * @memberof google.longrunning.GetOperationRequest + * @instance + */ + GetOperationRequest.prototype.name = ""; + + /** + * Creates a GetOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.GetOperationRequest} GetOperationRequest + */ + GetOperationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.GetOperationRequest) + return object; + var message = new $root.google.longrunning.GetOperationRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {google.longrunning.GetOperationRequest} message GetOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetOperationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.GetOperationRequest + * @instance + * @returns {Object.} JSON object + */ + GetOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetOperationRequest; + })(); + + longrunning.ListOperationsRequest = (function() { + + /** + * Properties of a ListOperationsRequest. + * @memberof google.longrunning + * @interface IListOperationsRequest + * @property {string|null} [name] ListOperationsRequest name + * @property {string|null} [filter] ListOperationsRequest filter + * @property {number|null} [pageSize] ListOperationsRequest pageSize + * @property {string|null} [pageToken] ListOperationsRequest pageToken + */ + + /** + * Constructs a new ListOperationsRequest. + * @memberof google.longrunning + * @classdesc Represents a ListOperationsRequest. + * @implements IListOperationsRequest + * @constructor + * @param {google.longrunning.IListOperationsRequest=} [properties] Properties to set + */ + function ListOperationsRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListOperationsRequest name. + * @member {string} name + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.name = ""; + + /** + * ListOperationsRequest filter. + * @member {string} filter + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.filter = ""; + + /** + * ListOperationsRequest pageSize. + * @member {number} pageSize + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.pageSize = 0; + + /** + * ListOperationsRequest pageToken. + * @member {string} pageToken + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.pageToken = ""; + + /** + * Creates a ListOperationsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.ListOperationsRequest} ListOperationsRequest + */ + ListOperationsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.ListOperationsRequest) + return object; + var message = new $root.google.longrunning.ListOperationsRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.filter != null) + message.filter = String(object.filter); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + return message; + }; + + /** + * Creates a plain object from a ListOperationsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {google.longrunning.ListOperationsRequest} message ListOperationsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListOperationsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.filter = ""; + object.pageSize = 0; + object.pageToken = ""; + object.name = ""; + } + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this ListOperationsRequest to JSON. + * @function toJSON + * @memberof google.longrunning.ListOperationsRequest + * @instance + * @returns {Object.} JSON object + */ + ListOperationsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListOperationsRequest; + })(); + + longrunning.ListOperationsResponse = (function() { + + /** + * Properties of a ListOperationsResponse. + * @memberof google.longrunning + * @interface IListOperationsResponse + * @property {Array.|null} [operations] ListOperationsResponse operations + * @property {string|null} [nextPageToken] ListOperationsResponse nextPageToken + */ + + /** + * Constructs a new ListOperationsResponse. + * @memberof google.longrunning + * @classdesc Represents a ListOperationsResponse. + * @implements IListOperationsResponse + * @constructor + * @param {google.longrunning.IListOperationsResponse=} [properties] Properties to set + */ + function ListOperationsResponse(properties) { + this.operations = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListOperationsResponse operations. + * @member {Array.} operations + * @memberof google.longrunning.ListOperationsResponse + * @instance + */ + ListOperationsResponse.prototype.operations = $util.emptyArray; + + /** + * ListOperationsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.longrunning.ListOperationsResponse + * @instance + */ + ListOperationsResponse.prototype.nextPageToken = ""; + + /** + * Creates a ListOperationsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.ListOperationsResponse} ListOperationsResponse + */ + ListOperationsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.ListOperationsResponse) + return object; + var message = new $root.google.longrunning.ListOperationsResponse(); + if (object.operations) { + if (!Array.isArray(object.operations)) + throw TypeError(".google.longrunning.ListOperationsResponse.operations: array expected"); + message.operations = []; + for (var i = 0; i < object.operations.length; ++i) { + if (typeof object.operations[i] !== "object") + throw TypeError(".google.longrunning.ListOperationsResponse.operations: object expected"); + message.operations[i] = $root.google.longrunning.Operation.fromObject(object.operations[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListOperationsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {google.longrunning.ListOperationsResponse} message ListOperationsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListOperationsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.operations = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.operations && message.operations.length) { + object.operations = []; + for (var j = 0; j < message.operations.length; ++j) + object.operations[j] = $root.google.longrunning.Operation.toObject(message.operations[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListOperationsResponse to JSON. + * @function toJSON + * @memberof google.longrunning.ListOperationsResponse + * @instance + * @returns {Object.} JSON object + */ + ListOperationsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListOperationsResponse; + })(); + + longrunning.CancelOperationRequest = (function() { + + /** + * Properties of a CancelOperationRequest. + * @memberof google.longrunning + * @interface ICancelOperationRequest + * @property {string|null} [name] CancelOperationRequest name + */ + + /** + * Constructs a new CancelOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a CancelOperationRequest. + * @implements ICancelOperationRequest + * @constructor + * @param {google.longrunning.ICancelOperationRequest=} [properties] Properties to set + */ + function CancelOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CancelOperationRequest name. + * @member {string} name + * @memberof google.longrunning.CancelOperationRequest + * @instance + */ + CancelOperationRequest.prototype.name = ""; + + /** + * Creates a CancelOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.CancelOperationRequest} CancelOperationRequest + */ + CancelOperationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.CancelOperationRequest) + return object; + var message = new $root.google.longrunning.CancelOperationRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a CancelOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {google.longrunning.CancelOperationRequest} message CancelOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CancelOperationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this CancelOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.CancelOperationRequest + * @instance + * @returns {Object.} JSON object + */ + CancelOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CancelOperationRequest; + })(); + + longrunning.DeleteOperationRequest = (function() { + + /** + * Properties of a DeleteOperationRequest. + * @memberof google.longrunning + * @interface IDeleteOperationRequest + * @property {string|null} [name] DeleteOperationRequest name + */ + + /** + * Constructs a new DeleteOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a DeleteOperationRequest. + * @implements IDeleteOperationRequest + * @constructor + * @param {google.longrunning.IDeleteOperationRequest=} [properties] Properties to set + */ + function DeleteOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteOperationRequest name. + * @member {string} name + * @memberof google.longrunning.DeleteOperationRequest + * @instance + */ + DeleteOperationRequest.prototype.name = ""; + + /** + * Creates a DeleteOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.DeleteOperationRequest} DeleteOperationRequest + */ + DeleteOperationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.DeleteOperationRequest) + return object; + var message = new $root.google.longrunning.DeleteOperationRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {google.longrunning.DeleteOperationRequest} message DeleteOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteOperationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this DeleteOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.DeleteOperationRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DeleteOperationRequest; + })(); + + longrunning.WaitOperationRequest = (function() { + + /** + * Properties of a WaitOperationRequest. + * @memberof google.longrunning + * @interface IWaitOperationRequest + * @property {string|null} [name] WaitOperationRequest name + * @property {google.protobuf.IDuration|null} [timeout] WaitOperationRequest timeout + */ + + /** + * Constructs a new WaitOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a WaitOperationRequest. + * @implements IWaitOperationRequest + * @constructor + * @param {google.longrunning.IWaitOperationRequest=} [properties] Properties to set + */ + function WaitOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WaitOperationRequest name. + * @member {string} name + * @memberof google.longrunning.WaitOperationRequest + * @instance + */ + WaitOperationRequest.prototype.name = ""; + + /** + * WaitOperationRequest timeout. + * @member {google.protobuf.IDuration|null|undefined} timeout + * @memberof google.longrunning.WaitOperationRequest + * @instance + */ + WaitOperationRequest.prototype.timeout = null; + + /** + * Creates a WaitOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.WaitOperationRequest} WaitOperationRequest + */ + WaitOperationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.WaitOperationRequest) + return object; + var message = new $root.google.longrunning.WaitOperationRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.timeout != null) { + if (typeof object.timeout !== "object") + throw TypeError(".google.longrunning.WaitOperationRequest.timeout: object expected"); + message.timeout = $root.google.protobuf.Duration.fromObject(object.timeout); + } + return message; + }; + + /** + * Creates a plain object from a WaitOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {google.longrunning.WaitOperationRequest} message WaitOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WaitOperationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.timeout = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.timeout != null && message.hasOwnProperty("timeout")) + object.timeout = $root.google.protobuf.Duration.toObject(message.timeout, options); + return object; + }; + + /** + * Converts this WaitOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.WaitOperationRequest + * @instance + * @returns {Object.} JSON object + */ + WaitOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return WaitOperationRequest; + })(); + + longrunning.OperationInfo = (function() { + + /** + * Properties of an OperationInfo. + * @memberof google.longrunning + * @interface IOperationInfo + * @property {string|null} [responseType] OperationInfo responseType + * @property {string|null} [metadataType] OperationInfo metadataType + */ + + /** + * Constructs a new OperationInfo. + * @memberof google.longrunning + * @classdesc Represents an OperationInfo. + * @implements IOperationInfo + * @constructor + * @param {google.longrunning.IOperationInfo=} [properties] Properties to set + */ + function OperationInfo(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OperationInfo responseType. + * @member {string} responseType + * @memberof google.longrunning.OperationInfo + * @instance + */ + OperationInfo.prototype.responseType = ""; + + /** + * OperationInfo metadataType. + * @member {string} metadataType + * @memberof google.longrunning.OperationInfo + * @instance + */ + OperationInfo.prototype.metadataType = ""; + + /** + * Creates an OperationInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.OperationInfo + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.OperationInfo} OperationInfo + */ + OperationInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.OperationInfo) + return object; + var message = new $root.google.longrunning.OperationInfo(); + if (object.responseType != null) + message.responseType = String(object.responseType); + if (object.metadataType != null) + message.metadataType = String(object.metadataType); + return message; + }; + + /** + * Creates a plain object from an OperationInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.OperationInfo + * @static + * @param {google.longrunning.OperationInfo} message OperationInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OperationInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.responseType = ""; + object.metadataType = ""; + } + if (message.responseType != null && message.hasOwnProperty("responseType")) + object.responseType = message.responseType; + if (message.metadataType != null && message.hasOwnProperty("metadataType")) + object.metadataType = message.metadataType; + return object; + }; + + /** + * Converts this OperationInfo to JSON. + * @function toJSON + * @memberof google.longrunning.OperationInfo + * @instance + * @returns {Object.} JSON object + */ + OperationInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return OperationInfo; + })(); + + return longrunning; })(); - - return longrunning; + + return google; })(); - return google; -})(); + return $root; +}); diff --git a/dev/protos/firestore_v1_proto_api.d.ts b/dev/protos/firestore_v1_proto_api.d.ts index 25d163597..0b4afb29c 100644 --- a/dev/protos/firestore_v1_proto_api.d.ts +++ b/dev/protos/firestore_v1_proto_api.d.ts @@ -15,6 +15,306 @@ */ import * as $protobuf from "protobufjs"; +/** Namespace firestore. */ +export namespace firestore { + + /** Properties of a BundledQuery. */ + interface IBundledQuery { + + /** BundledQuery parent */ + parent?: (string|null); + + /** BundledQuery structuredQuery */ + structuredQuery?: (google.firestore.v1.IStructuredQuery|null); + + /** BundledQuery limitType */ + limitType?: (firestore.BundledQuery.LimitType|null); + } + + /** Represents a BundledQuery. */ + class BundledQuery implements IBundledQuery { + + /** + * Constructs a new BundledQuery. + * @param [properties] Properties to set + */ + constructor(properties?: firestore.IBundledQuery); + + /** BundledQuery parent. */ + public parent: string; + + /** BundledQuery structuredQuery. */ + public structuredQuery?: (google.firestore.v1.IStructuredQuery|null); + + /** BundledQuery limitType. */ + public limitType: firestore.BundledQuery.LimitType; + + /** BundledQuery queryType. */ + public queryType?: "structuredQuery"; + + /** + * Creates a BundledQuery message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BundledQuery + */ + public static fromObject(object: { [k: string]: any }): firestore.BundledQuery; + + /** + * Creates a plain object from a BundledQuery message. Also converts values to other types if specified. + * @param message BundledQuery + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: firestore.BundledQuery, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BundledQuery to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace BundledQuery { + + /** LimitType enum. */ + type LimitType = + "FIRST"| "LAST"; + } + + /** Properties of a NamedQuery. */ + interface INamedQuery { + + /** NamedQuery name */ + name?: (string|null); + + /** NamedQuery bundledQuery */ + bundledQuery?: (firestore.IBundledQuery|null); + + /** NamedQuery readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a NamedQuery. */ + class NamedQuery implements INamedQuery { + + /** + * Constructs a new NamedQuery. + * @param [properties] Properties to set + */ + constructor(properties?: firestore.INamedQuery); + + /** NamedQuery name. */ + public name: string; + + /** NamedQuery bundledQuery. */ + public bundledQuery?: (firestore.IBundledQuery|null); + + /** NamedQuery readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a NamedQuery message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns NamedQuery + */ + public static fromObject(object: { [k: string]: any }): firestore.NamedQuery; + + /** + * Creates a plain object from a NamedQuery message. Also converts values to other types if specified. + * @param message NamedQuery + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: firestore.NamedQuery, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this NamedQuery to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BundledDocumentMetadata. */ + interface IBundledDocumentMetadata { + + /** BundledDocumentMetadata name */ + name?: (string|null); + + /** BundledDocumentMetadata readTime */ + readTime?: (google.protobuf.ITimestamp|null); + + /** BundledDocumentMetadata exists */ + exists?: (boolean|null); + } + + /** Represents a BundledDocumentMetadata. */ + class BundledDocumentMetadata implements IBundledDocumentMetadata { + + /** + * Constructs a new BundledDocumentMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: firestore.IBundledDocumentMetadata); + + /** BundledDocumentMetadata name. */ + public name: string; + + /** BundledDocumentMetadata readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** BundledDocumentMetadata exists. */ + public exists: boolean; + + /** + * Creates a BundledDocumentMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BundledDocumentMetadata + */ + public static fromObject(object: { [k: string]: any }): firestore.BundledDocumentMetadata; + + /** + * Creates a plain object from a BundledDocumentMetadata message. Also converts values to other types if specified. + * @param message BundledDocumentMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: firestore.BundledDocumentMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BundledDocumentMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BundleMetadata. */ + interface IBundleMetadata { + + /** BundleMetadata id */ + id?: (string|null); + + /** BundleMetadata createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** BundleMetadata version */ + version?: (number|null); + + /** BundleMetadata totalDocuments */ + totalDocuments?: (number|null); + + /** BundleMetadata totalBytes */ + totalBytes?: (number|string|null); + } + + /** Represents a BundleMetadata. */ + class BundleMetadata implements IBundleMetadata { + + /** + * Constructs a new BundleMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: firestore.IBundleMetadata); + + /** BundleMetadata id. */ + public id: string; + + /** BundleMetadata createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** BundleMetadata version. */ + public version: number; + + /** BundleMetadata totalDocuments. */ + public totalDocuments: number; + + /** BundleMetadata totalBytes. */ + public totalBytes: (number|string); + + /** + * Creates a BundleMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BundleMetadata + */ + public static fromObject(object: { [k: string]: any }): firestore.BundleMetadata; + + /** + * Creates a plain object from a BundleMetadata message. Also converts values to other types if specified. + * @param message BundleMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: firestore.BundleMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BundleMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BundleElement. */ + interface IBundleElement { + + /** BundleElement metadata */ + metadata?: (firestore.IBundleMetadata|null); + + /** BundleElement namedQuery */ + namedQuery?: (firestore.INamedQuery|null); + + /** BundleElement documentMetadata */ + documentMetadata?: (firestore.IBundledDocumentMetadata|null); + + /** BundleElement document */ + document?: (google.firestore.v1.IDocument|null); + } + + /** Represents a BundleElement. */ + class BundleElement implements IBundleElement { + + /** + * Constructs a new BundleElement. + * @param [properties] Properties to set + */ + constructor(properties?: firestore.IBundleElement); + + /** BundleElement metadata. */ + public metadata?: (firestore.IBundleMetadata|null); + + /** BundleElement namedQuery. */ + public namedQuery?: (firestore.INamedQuery|null); + + /** BundleElement documentMetadata. */ + public documentMetadata?: (firestore.IBundledDocumentMetadata|null); + + /** BundleElement document. */ + public document?: (google.firestore.v1.IDocument|null); + + /** BundleElement elementType. */ + public elementType?: ("metadata"|"namedQuery"|"documentMetadata"|"document"); + + /** + * Creates a BundleElement message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BundleElement + */ + public static fromObject(object: { [k: string]: any }): firestore.BundleElement; + + /** + * Creates a plain object from a BundleElement message. Also converts values to other types if specified. + * @param message BundleElement + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: firestore.BundleElement, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BundleElement to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } +} + /** Namespace google. */ export namespace google { @@ -25,7 +325,7 @@ export namespace google { interface ITimestamp { /** Timestamp seconds */ - seconds?: (number|null); + seconds?: (number|string|null); /** Timestamp nanos */ nanos?: (number|null); @@ -41,10 +341,31 @@ export namespace google { constructor(properties?: google.protobuf.ITimestamp); /** Timestamp seconds. */ - public seconds: number; + public seconds: (number|string); /** Timestamp nanos. */ public nanos: number; + + /** + * Creates a Timestamp message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Timestamp + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Timestamp; + + /** + * Creates a plain object from a Timestamp message. Also converts values to other types if specified. + * @param message Timestamp + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Timestamp, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Timestamp to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FileDescriptorSet. */ @@ -65,6 +386,27 @@ export namespace google { /** FileDescriptorSet file. */ public file: google.protobuf.IFileDescriptorProto[]; + + /** + * Creates a FileDescriptorSet message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileDescriptorSet + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileDescriptorSet; + + /** + * Creates a plain object from a FileDescriptorSet message. Also converts values to other types if specified. + * @param message FileDescriptorSet + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileDescriptorSet, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileDescriptorSet to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FileDescriptorProto. */ @@ -151,6 +493,27 @@ export namespace google { /** FileDescriptorProto syntax. */ public syntax: string; + + /** + * Creates a FileDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileDescriptorProto; + + /** + * Creates a plain object from a FileDescriptorProto message. Also converts values to other types if specified. + * @param message FileDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DescriptorProto. */ @@ -225,6 +588,27 @@ export namespace google { /** DescriptorProto reservedName. */ public reservedName: string[]; + + /** + * Creates a DescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto; + + /** + * Creates a plain object from a DescriptorProto message. Also converts values to other types if specified. + * @param message DescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace DescriptorProto { @@ -253,6 +637,27 @@ export namespace google { /** ExtensionRange end. */ public end: number; + + /** + * Creates an ExtensionRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExtensionRange + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto.ExtensionRange; + + /** + * Creates a plain object from an ExtensionRange message. Also converts values to other types if specified. + * @param message ExtensionRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto.ExtensionRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExtensionRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ReservedRange. */ @@ -279,6 +684,27 @@ export namespace google { /** ReservedRange end. */ public end: number; + + /** + * Creates a ReservedRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReservedRange + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto.ReservedRange; + + /** + * Creates a plain object from a ReservedRange message. Also converts values to other types if specified. + * @param message ReservedRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto.ReservedRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReservedRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -354,6 +780,27 @@ export namespace google { /** FieldDescriptorProto options. */ public options?: (google.protobuf.IFieldOptions|null); + + /** + * Creates a FieldDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldDescriptorProto; + + /** + * Creates a plain object from a FieldDescriptorProto message. Also converts values to other types if specified. + * @param message FieldDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace FieldDescriptorProto { @@ -391,6 +838,27 @@ export namespace google { /** OneofDescriptorProto options. */ public options?: (google.protobuf.IOneofOptions|null); + + /** + * Creates an OneofDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OneofDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.OneofDescriptorProto; + + /** + * Creates a plain object from an OneofDescriptorProto message. Also converts values to other types if specified. + * @param message OneofDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.OneofDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OneofDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an EnumDescriptorProto. */ @@ -423,6 +891,27 @@ export namespace google { /** EnumDescriptorProto options. */ public options?: (google.protobuf.IEnumOptions|null); + + /** + * Creates an EnumDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumDescriptorProto; + + /** + * Creates a plain object from an EnumDescriptorProto message. Also converts values to other types if specified. + * @param message EnumDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an EnumValueDescriptorProto. */ @@ -455,6 +944,27 @@ export namespace google { /** EnumValueDescriptorProto options. */ public options?: (google.protobuf.IEnumValueOptions|null); + + /** + * Creates an EnumValueDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumValueDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumValueDescriptorProto; + + /** + * Creates a plain object from an EnumValueDescriptorProto message. Also converts values to other types if specified. + * @param message EnumValueDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumValueDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumValueDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ServiceDescriptorProto. */ @@ -487,6 +997,27 @@ export namespace google { /** ServiceDescriptorProto options. */ public options?: (google.protobuf.IServiceOptions|null); + + /** + * Creates a ServiceDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServiceDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ServiceDescriptorProto; + + /** + * Creates a plain object from a ServiceDescriptorProto message. Also converts values to other types if specified. + * @param message ServiceDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ServiceDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServiceDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a MethodDescriptorProto. */ @@ -537,6 +1068,27 @@ export namespace google { /** MethodDescriptorProto serverStreaming. */ public serverStreaming: boolean; + + /** + * Creates a MethodDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MethodDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MethodDescriptorProto; + + /** + * Creates a plain object from a MethodDescriptorProto message. Also converts values to other types if specified. + * @param message MethodDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MethodDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MethodDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FileOptions. */ @@ -644,6 +1196,27 @@ export namespace google { /** FileOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a FileOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileOptions; + + /** + * Creates a plain object from a FileOptions message. Also converts values to other types if specified. + * @param message FileOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace FileOptions { @@ -698,6 +1271,27 @@ export namespace google { /** MessageOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a MessageOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MessageOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MessageOptions; + + /** + * Creates a plain object from a MessageOptions message. Also converts values to other types if specified. + * @param message MessageOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MessageOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MessageOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FieldOptions. */ @@ -760,6 +1354,27 @@ export namespace google { /** FieldOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a FieldOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions; + + /** + * Creates a plain object from a FieldOptions message. Also converts values to other types if specified. + * @param message FieldOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace FieldOptions { @@ -791,6 +1406,27 @@ export namespace google { /** OneofOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an OneofOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OneofOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.OneofOptions; + + /** + * Creates a plain object from an OneofOptions message. Also converts values to other types if specified. + * @param message OneofOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.OneofOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OneofOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an EnumOptions. */ @@ -823,6 +1459,27 @@ export namespace google { /** EnumOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an EnumOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumOptions; + + /** + * Creates a plain object from an EnumOptions message. Also converts values to other types if specified. + * @param message EnumOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an EnumValueOptions. */ @@ -849,6 +1506,27 @@ export namespace google { /** EnumValueOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an EnumValueOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumValueOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumValueOptions; + + /** + * Creates a plain object from an EnumValueOptions message. Also converts values to other types if specified. + * @param message EnumValueOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumValueOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumValueOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ServiceOptions. */ @@ -881,6 +1559,27 @@ export namespace google { /** ServiceOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a ServiceOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServiceOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ServiceOptions; + + /** + * Creates a plain object from a ServiceOptions message. Also converts values to other types if specified. + * @param message ServiceOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ServiceOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServiceOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a MethodOptions. */ @@ -916,6 +1615,27 @@ export namespace google { /** MethodOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a MethodOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MethodOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MethodOptions; + + /** + * Creates a plain object from a MethodOptions message. Also converts values to other types if specified. + * @param message MethodOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MethodOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MethodOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an UninterpretedOption. */ @@ -928,10 +1648,10 @@ export namespace google { identifierValue?: (string|null); /** UninterpretedOption positiveIntValue */ - positiveIntValue?: (number|null); + positiveIntValue?: (number|string|null); /** UninterpretedOption negativeIntValue */ - negativeIntValue?: (number|null); + negativeIntValue?: (number|string|null); /** UninterpretedOption doubleValue */ doubleValue?: (number|null); @@ -959,10 +1679,10 @@ export namespace google { public identifierValue: string; /** UninterpretedOption positiveIntValue. */ - public positiveIntValue: number; + public positiveIntValue: (number|string); /** UninterpretedOption negativeIntValue. */ - public negativeIntValue: number; + public negativeIntValue: (number|string); /** UninterpretedOption doubleValue. */ public doubleValue: number; @@ -972,6 +1692,27 @@ export namespace google { /** UninterpretedOption aggregateValue. */ public aggregateValue: string; + + /** + * Creates an UninterpretedOption message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UninterpretedOption + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UninterpretedOption; + + /** + * Creates a plain object from an UninterpretedOption message. Also converts values to other types if specified. + * @param message UninterpretedOption + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UninterpretedOption, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UninterpretedOption to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace UninterpretedOption { @@ -1000,6 +1741,27 @@ export namespace google { /** NamePart isExtension. */ public isExtension: boolean; + + /** + * Creates a NamePart message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns NamePart + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UninterpretedOption.NamePart; + + /** + * Creates a plain object from a NamePart message. Also converts values to other types if specified. + * @param message NamePart + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UninterpretedOption.NamePart, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this NamePart to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -1021,6 +1783,27 @@ export namespace google { /** SourceCodeInfo location. */ public location: google.protobuf.SourceCodeInfo.ILocation[]; + + /** + * Creates a SourceCodeInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SourceCodeInfo + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.SourceCodeInfo; + + /** + * Creates a plain object from a SourceCodeInfo message. Also converts values to other types if specified. + * @param message SourceCodeInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.SourceCodeInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SourceCodeInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace SourceCodeInfo { @@ -1067,11 +1850,32 @@ export namespace google { /** Location leadingDetachedComments. */ public leadingDetachedComments: string[]; - } - } - /** Properties of a GeneratedCodeInfo. */ - interface IGeneratedCodeInfo { + /** + * Creates a Location message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Location + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.SourceCodeInfo.Location; + + /** + * Creates a plain object from a Location message. Also converts values to other types if specified. + * @param message Location + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.SourceCodeInfo.Location, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Location to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a GeneratedCodeInfo. */ + interface IGeneratedCodeInfo { /** GeneratedCodeInfo annotation */ annotation?: (google.protobuf.GeneratedCodeInfo.IAnnotation[]|null); @@ -1088,6 +1892,27 @@ export namespace google { /** GeneratedCodeInfo annotation. */ public annotation: google.protobuf.GeneratedCodeInfo.IAnnotation[]; + + /** + * Creates a GeneratedCodeInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GeneratedCodeInfo + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.GeneratedCodeInfo; + + /** + * Creates a plain object from a GeneratedCodeInfo message. Also converts values to other types if specified. + * @param message GeneratedCodeInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.GeneratedCodeInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GeneratedCodeInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace GeneratedCodeInfo { @@ -1128,6 +1953,27 @@ export namespace google { /** Annotation end. */ public end: number; + + /** + * Creates an Annotation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Annotation + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.GeneratedCodeInfo.Annotation; + + /** + * Creates a plain object from an Annotation message. Also converts values to other types if specified. + * @param message Annotation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.GeneratedCodeInfo.Annotation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Annotation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -1149,6 +1995,27 @@ export namespace google { /** Struct fields. */ public fields: { [k: string]: google.protobuf.IValue }; + + /** + * Creates a Struct message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Struct + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Struct; + + /** + * Creates a plain object from a Struct message. Also converts values to other types if specified. + * @param message Struct + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Struct, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Struct to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Value. */ @@ -1202,6 +2069,27 @@ export namespace google { /** Value kind. */ public kind?: ("nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"); + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Value; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @param message Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** NullValue enum. */ @@ -1226,6 +2114,27 @@ export namespace google { /** ListValue values. */ public values: google.protobuf.IValue[]; + + /** + * Creates a ListValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ListValue; + + /** + * Creates a plain object from a ListValue message. Also converts values to other types if specified. + * @param message ListValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ListValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an Empty. */ @@ -1240,6 +2149,27 @@ export namespace google { * @param [properties] Properties to set */ constructor(properties?: google.protobuf.IEmpty); + + /** + * Creates an Empty message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Empty + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Empty; + + /** + * Creates a plain object from an Empty message. Also converts values to other types if specified. + * @param message Empty + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Empty, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Empty to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DoubleValue. */ @@ -1260,6 +2190,27 @@ export namespace google { /** DoubleValue value. */ public value: number; + + /** + * Creates a DoubleValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DoubleValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DoubleValue; + + /** + * Creates a plain object from a DoubleValue message. Also converts values to other types if specified. + * @param message DoubleValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DoubleValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DoubleValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FloatValue. */ @@ -1280,13 +2231,34 @@ export namespace google { /** FloatValue value. */ public value: number; + + /** + * Creates a FloatValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FloatValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FloatValue; + + /** + * Creates a plain object from a FloatValue message. Also converts values to other types if specified. + * @param message FloatValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FloatValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FloatValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an Int64Value. */ interface IInt64Value { /** Int64Value value */ - value?: (number|null); + value?: (number|string|null); } /** Represents an Int64Value. */ @@ -1299,14 +2271,35 @@ export namespace google { constructor(properties?: google.protobuf.IInt64Value); /** Int64Value value. */ - public value: number; + public value: (number|string); + + /** + * Creates an Int64Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Int64Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Int64Value; + + /** + * Creates a plain object from an Int64Value message. Also converts values to other types if specified. + * @param message Int64Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Int64Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Int64Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a UInt64Value. */ interface IUInt64Value { /** UInt64Value value */ - value?: (number|null); + value?: (number|string|null); } /** Represents a UInt64Value. */ @@ -1319,7 +2312,28 @@ export namespace google { constructor(properties?: google.protobuf.IUInt64Value); /** UInt64Value value. */ - public value: number; + public value: (number|string); + + /** + * Creates a UInt64Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UInt64Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UInt64Value; + + /** + * Creates a plain object from a UInt64Value message. Also converts values to other types if specified. + * @param message UInt64Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UInt64Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UInt64Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an Int32Value. */ @@ -1340,6 +2354,27 @@ export namespace google { /** Int32Value value. */ public value: number; + + /** + * Creates an Int32Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Int32Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Int32Value; + + /** + * Creates a plain object from an Int32Value message. Also converts values to other types if specified. + * @param message Int32Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Int32Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Int32Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a UInt32Value. */ @@ -1360,6 +2395,27 @@ export namespace google { /** UInt32Value value. */ public value: number; + + /** + * Creates a UInt32Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UInt32Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UInt32Value; + + /** + * Creates a plain object from a UInt32Value message. Also converts values to other types if specified. + * @param message UInt32Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UInt32Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UInt32Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a BoolValue. */ @@ -1380,6 +2436,27 @@ export namespace google { /** BoolValue value. */ public value: boolean; + + /** + * Creates a BoolValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BoolValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.BoolValue; + + /** + * Creates a plain object from a BoolValue message. Also converts values to other types if specified. + * @param message BoolValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.BoolValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BoolValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a StringValue. */ @@ -1400,6 +2477,27 @@ export namespace google { /** StringValue value. */ public value: string; + + /** + * Creates a StringValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StringValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.StringValue; + + /** + * Creates a plain object from a StringValue message. Also converts values to other types if specified. + * @param message StringValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.StringValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StringValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a BytesValue. */ @@ -1420,6 +2518,27 @@ export namespace google { /** BytesValue value. */ public value: Uint8Array; + + /** + * Creates a BytesValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BytesValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.BytesValue; + + /** + * Creates a plain object from a BytesValue message. Also converts values to other types if specified. + * @param message BytesValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.BytesValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BytesValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an Any. */ @@ -1446,6 +2565,27 @@ export namespace google { /** Any value. */ public value: Uint8Array; + + /** + * Creates an Any message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Any + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Any; + + /** + * Creates a plain object from an Any message. Also converts values to other types if specified. + * @param message Any + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Any, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Any to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FieldMask. */ @@ -1466,13 +2606,34 @@ export namespace google { /** FieldMask paths. */ public paths: string[]; + + /** + * Creates a FieldMask message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldMask + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldMask; + + /** + * Creates a plain object from a FieldMask message. Also converts values to other types if specified. + * @param message FieldMask + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldMask, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldMask to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Duration. */ interface IDuration { /** Duration seconds */ - seconds?: (number|null); + seconds?: (number|string|null); /** Duration nanos */ nanos?: (number|null); @@ -1488,10 +2649,31 @@ export namespace google { constructor(properties?: google.protobuf.IDuration); /** Duration seconds. */ - public seconds: number; + public seconds: (number|string); /** Duration nanos. */ public nanos: number; + + /** + * Creates a Duration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Duration + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Duration; + + /** + * Creates a plain object from a Duration message. Also converts values to other types if specified. + * @param message Duration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Duration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Duration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -1519,6 +2701,27 @@ export namespace google { /** DocumentMask fieldPaths. */ public fieldPaths: string[]; + + /** + * Creates a DocumentMask message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentMask + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.DocumentMask; + + /** + * Creates a plain object from a DocumentMask message. Also converts values to other types if specified. + * @param message DocumentMask + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.DocumentMask, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentMask to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Precondition. */ @@ -1548,6 +2751,27 @@ export namespace google { /** Precondition conditionType. */ public conditionType?: ("exists"|"updateTime"); + + /** + * Creates a Precondition message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Precondition + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.Precondition; + + /** + * Creates a plain object from a Precondition message. Also converts values to other types if specified. + * @param message Precondition + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.Precondition, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Precondition to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a TransactionOptions. */ @@ -1577,6 +2801,27 @@ export namespace google { /** TransactionOptions mode. */ public mode?: ("readOnly"|"readWrite"); + + /** + * Creates a TransactionOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TransactionOptions + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.TransactionOptions; + + /** + * Creates a plain object from a TransactionOptions message. Also converts values to other types if specified. + * @param message TransactionOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.TransactionOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TransactionOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace TransactionOptions { @@ -1599,6 +2844,27 @@ export namespace google { /** ReadWrite retryTransaction. */ public retryTransaction: Uint8Array; + + /** + * Creates a ReadWrite message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReadWrite + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.TransactionOptions.ReadWrite; + + /** + * Creates a plain object from a ReadWrite message. Also converts values to other types if specified. + * @param message ReadWrite + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.TransactionOptions.ReadWrite, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReadWrite to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ReadOnly. */ @@ -1622,6 +2888,27 @@ export namespace google { /** ReadOnly consistencySelector. */ public consistencySelector?: "readTime"; + + /** + * Creates a ReadOnly message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReadOnly + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.TransactionOptions.ReadOnly; + + /** + * Creates a plain object from a ReadOnly message. Also converts values to other types if specified. + * @param message ReadOnly + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.TransactionOptions.ReadOnly, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReadOnly to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -1661,6 +2948,27 @@ export namespace google { /** Document updateTime. */ public updateTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a Document message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Document + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.Document; + + /** + * Creates a plain object from a Document message. Also converts values to other types if specified. + * @param message Document + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.Document, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Document to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Value. */ @@ -1673,7 +2981,7 @@ export namespace google { booleanValue?: (boolean|null); /** Value integerValue */ - integerValue?: (number|null); + integerValue?: (number|string|null); /** Value doubleValue */ doubleValue?: (number|null); @@ -1716,7 +3024,7 @@ export namespace google { public booleanValue: boolean; /** Value integerValue. */ - public integerValue: number; + public integerValue: (number|string); /** Value doubleValue. */ public doubleValue: number; @@ -1744,6 +3052,27 @@ export namespace google { /** Value valueType. */ public valueType?: ("nullValue"|"booleanValue"|"integerValue"|"doubleValue"|"timestampValue"|"stringValue"|"bytesValue"|"referenceValue"|"geoPointValue"|"arrayValue"|"mapValue"); + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Value + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.Value; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @param message Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an ArrayValue. */ @@ -1764,6 +3093,27 @@ export namespace google { /** ArrayValue values. */ public values: google.firestore.v1.IValue[]; + + /** + * Creates an ArrayValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ArrayValue + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.ArrayValue; + + /** + * Creates a plain object from an ArrayValue message. Also converts values to other types if specified. + * @param message ArrayValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.ArrayValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ArrayValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a MapValue. */ @@ -1784,6 +3134,27 @@ export namespace google { /** MapValue fields. */ public fields: { [k: string]: google.firestore.v1.IValue }; + + /** + * Creates a MapValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MapValue + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.MapValue; + + /** + * Creates a plain object from a MapValue message. Also converts values to other types if specified. + * @param message MapValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.MapValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MapValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Represents a Firestore */ @@ -1923,6 +3294,20 @@ export namespace google { */ public runQuery(request: google.firestore.v1.IRunQueryRequest): Promise; + /** + * Calls PartitionQuery. + * @param request PartitionQueryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and PartitionQueryResponse + */ + public partitionQuery(request: google.firestore.v1.IPartitionQueryRequest, callback: google.firestore.v1.Firestore.PartitionQueryCallback): void; + + /** + * Calls PartitionQuery. + * @param request PartitionQueryRequest message or plain object + * @returns Promise + */ + public partitionQuery(request: google.firestore.v1.IPartitionQueryRequest): Promise; + /** * Calls Write. * @param request WriteRequest message or plain object @@ -1978,8 +3363,8 @@ export namespace google { * @returns Promise */ public batchWrite(request: google.firestore.v1.IBatchWriteRequest): Promise; - - /* + + /** * Calls CreateDocument. * @param request CreateDocumentRequest message or plain object * @param callback Node-style callback called with the error, if any, and Document @@ -2059,6 +3444,13 @@ export namespace google { */ type RunQueryCallback = (error: (Error|null), response?: google.firestore.v1.RunQueryResponse) => void; + /** + * Callback as used by {@link google.firestore.v1.Firestore#partitionQuery}. + * @param error Error, if any + * @param [response] PartitionQueryResponse + */ + type PartitionQueryCallback = (error: (Error|null), response?: google.firestore.v1.PartitionQueryResponse) => void; + /** * Callback as used by {@link google.firestore.v1.Firestore#write}. * @param error Error, if any @@ -2086,8 +3478,8 @@ export namespace google { * @param [response] BatchWriteResponse */ type BatchWriteCallback = (error: (Error|null), response?: google.firestore.v1.BatchWriteResponse) => void; - - /* + + /** * Callback as used by {@link google.firestore.v1.Firestore#createDocument}. * @param error Error, if any * @param [response] Document @@ -2134,6 +3526,27 @@ export namespace google { /** GetDocumentRequest consistencySelector. */ public consistencySelector?: ("transaction"|"readTime"); + + /** + * Creates a GetDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.GetDocumentRequest; + + /** + * Creates a plain object from a GetDocumentRequest message. Also converts values to other types if specified. + * @param message GetDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.GetDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetDocumentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListDocumentsRequest. */ @@ -2205,6 +3618,27 @@ export namespace google { /** ListDocumentsRequest consistencySelector. */ public consistencySelector?: ("transaction"|"readTime"); + + /** + * Creates a ListDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListDocumentsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.ListDocumentsRequest; + + /** + * Creates a plain object from a ListDocumentsRequest message. Also converts values to other types if specified. + * @param message ListDocumentsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.ListDocumentsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListDocumentsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListDocumentsResponse. */ @@ -2231,6 +3665,27 @@ export namespace google { /** ListDocumentsResponse nextPageToken. */ public nextPageToken: string; + + /** + * Creates a ListDocumentsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListDocumentsResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.ListDocumentsResponse; + + /** + * Creates a plain object from a ListDocumentsResponse message. Also converts values to other types if specified. + * @param message ListDocumentsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.ListDocumentsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListDocumentsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a CreateDocumentRequest. */ @@ -2275,6 +3730,27 @@ export namespace google { /** CreateDocumentRequest mask. */ public mask?: (google.firestore.v1.IDocumentMask|null); + + /** + * Creates a CreateDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.CreateDocumentRequest; + + /** + * Creates a plain object from a CreateDocumentRequest message. Also converts values to other types if specified. + * @param message CreateDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.CreateDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateDocumentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an UpdateDocumentRequest. */ @@ -2313,6 +3789,27 @@ export namespace google { /** UpdateDocumentRequest currentDocument. */ public currentDocument?: (google.firestore.v1.IPrecondition|null); + + /** + * Creates an UpdateDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.UpdateDocumentRequest; + + /** + * Creates a plain object from an UpdateDocumentRequest message. Also converts values to other types if specified. + * @param message UpdateDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.UpdateDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateDocumentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DeleteDocumentRequest. */ @@ -2339,6 +3836,27 @@ export namespace google { /** DeleteDocumentRequest currentDocument. */ public currentDocument?: (google.firestore.v1.IPrecondition|null); + + /** + * Creates a DeleteDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.DeleteDocumentRequest; + + /** + * Creates a plain object from a DeleteDocumentRequest message. Also converts values to other types if specified. + * @param message DeleteDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.DeleteDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteDocumentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a BatchGetDocumentsRequest. */ @@ -2392,6 +3910,27 @@ export namespace google { /** BatchGetDocumentsRequest consistencySelector. */ public consistencySelector?: ("transaction"|"newTransaction"|"readTime"); + + /** + * Creates a BatchGetDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchGetDocumentsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.BatchGetDocumentsRequest; + + /** + * Creates a plain object from a BatchGetDocumentsRequest message. Also converts values to other types if specified. + * @param message BatchGetDocumentsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.BatchGetDocumentsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchGetDocumentsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a BatchGetDocumentsResponse. */ @@ -2433,6 +3972,27 @@ export namespace google { /** BatchGetDocumentsResponse result. */ public result?: ("found"|"missing"); + + /** + * Creates a BatchGetDocumentsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchGetDocumentsResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.BatchGetDocumentsResponse; + + /** + * Creates a plain object from a BatchGetDocumentsResponse message. Also converts values to other types if specified. + * @param message BatchGetDocumentsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.BatchGetDocumentsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchGetDocumentsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a BeginTransactionRequest. */ @@ -2459,6 +4019,27 @@ export namespace google { /** BeginTransactionRequest options. */ public options?: (google.firestore.v1.ITransactionOptions|null); + + /** + * Creates a BeginTransactionRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BeginTransactionRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.BeginTransactionRequest; + + /** + * Creates a plain object from a BeginTransactionRequest message. Also converts values to other types if specified. + * @param message BeginTransactionRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.BeginTransactionRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BeginTransactionRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a BeginTransactionResponse. */ @@ -2479,6 +4060,27 @@ export namespace google { /** BeginTransactionResponse transaction. */ public transaction: Uint8Array; + + /** + * Creates a BeginTransactionResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BeginTransactionResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.BeginTransactionResponse; + + /** + * Creates a plain object from a BeginTransactionResponse message. Also converts values to other types if specified. + * @param message BeginTransactionResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.BeginTransactionResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BeginTransactionResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a CommitRequest. */ @@ -2511,6 +4113,27 @@ export namespace google { /** CommitRequest transaction. */ public transaction: Uint8Array; + + /** + * Creates a CommitRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CommitRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.CommitRequest; + + /** + * Creates a plain object from a CommitRequest message. Also converts values to other types if specified. + * @param message CommitRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.CommitRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CommitRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a CommitResponse. */ @@ -2537,6 +4160,27 @@ export namespace google { /** CommitResponse commitTime. */ public commitTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a CommitResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CommitResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.CommitResponse; + + /** + * Creates a plain object from a CommitResponse message. Also converts values to other types if specified. + * @param message CommitResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.CommitResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CommitResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a RollbackRequest. */ @@ -2563,6 +4207,27 @@ export namespace google { /** RollbackRequest transaction. */ public transaction: Uint8Array; + + /** + * Creates a RollbackRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RollbackRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.RollbackRequest; + + /** + * Creates a plain object from a RollbackRequest message. Also converts values to other types if specified. + * @param message RollbackRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.RollbackRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RollbackRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a RunQueryRequest. */ @@ -2577,80 +4242,237 @@ export namespace google { /** RunQueryRequest transaction */ transaction?: (Uint8Array|null); - /** RunQueryRequest newTransaction */ - newTransaction?: (google.firestore.v1.ITransactionOptions|null); + /** RunQueryRequest newTransaction */ + newTransaction?: (google.firestore.v1.ITransactionOptions|null); + + /** RunQueryRequest readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a RunQueryRequest. */ + class RunQueryRequest implements IRunQueryRequest { + + /** + * Constructs a new RunQueryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IRunQueryRequest); + + /** RunQueryRequest parent. */ + public parent: string; + + /** RunQueryRequest structuredQuery. */ + public structuredQuery?: (google.firestore.v1.IStructuredQuery|null); + + /** RunQueryRequest transaction. */ + public transaction: Uint8Array; + + /** RunQueryRequest newTransaction. */ + public newTransaction?: (google.firestore.v1.ITransactionOptions|null); + + /** RunQueryRequest readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** RunQueryRequest queryType. */ + public queryType?: "structuredQuery"; + + /** RunQueryRequest consistencySelector. */ + public consistencySelector?: ("transaction"|"newTransaction"|"readTime"); + + /** + * Creates a RunQueryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RunQueryRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.RunQueryRequest; + + /** + * Creates a plain object from a RunQueryRequest message. Also converts values to other types if specified. + * @param message RunQueryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.RunQueryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RunQueryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a RunQueryResponse. */ + interface IRunQueryResponse { + + /** RunQueryResponse transaction */ + transaction?: (Uint8Array|null); + + /** RunQueryResponse document */ + document?: (google.firestore.v1.IDocument|null); + + /** RunQueryResponse readTime */ + readTime?: (google.protobuf.ITimestamp|null); + + /** RunQueryResponse skippedResults */ + skippedResults?: (number|null); + } + + /** Represents a RunQueryResponse. */ + class RunQueryResponse implements IRunQueryResponse { + + /** + * Constructs a new RunQueryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IRunQueryResponse); + + /** RunQueryResponse transaction. */ + public transaction: Uint8Array; + + /** RunQueryResponse document. */ + public document?: (google.firestore.v1.IDocument|null); + + /** RunQueryResponse readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** RunQueryResponse skippedResults. */ + public skippedResults: number; + + /** + * Creates a RunQueryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RunQueryResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.RunQueryResponse; + + /** + * Creates a plain object from a RunQueryResponse message. Also converts values to other types if specified. + * @param message RunQueryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.RunQueryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RunQueryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a PartitionQueryRequest. */ + interface IPartitionQueryRequest { + + /** PartitionQueryRequest parent */ + parent?: (string|null); + + /** PartitionQueryRequest structuredQuery */ + structuredQuery?: (google.firestore.v1.IStructuredQuery|null); + + /** PartitionQueryRequest partitionCount */ + partitionCount?: (number|string|null); - /** RunQueryRequest readTime */ - readTime?: (google.protobuf.ITimestamp|null); + /** PartitionQueryRequest pageToken */ + pageToken?: (string|null); + + /** PartitionQueryRequest pageSize */ + pageSize?: (number|null); } - /** Represents a RunQueryRequest. */ - class RunQueryRequest implements IRunQueryRequest { + /** Represents a PartitionQueryRequest. */ + class PartitionQueryRequest implements IPartitionQueryRequest { /** - * Constructs a new RunQueryRequest. + * Constructs a new PartitionQueryRequest. * @param [properties] Properties to set */ - constructor(properties?: google.firestore.v1.IRunQueryRequest); + constructor(properties?: google.firestore.v1.IPartitionQueryRequest); - /** RunQueryRequest parent. */ + /** PartitionQueryRequest parent. */ public parent: string; - /** RunQueryRequest structuredQuery. */ + /** PartitionQueryRequest structuredQuery. */ public structuredQuery?: (google.firestore.v1.IStructuredQuery|null); - /** RunQueryRequest transaction. */ - public transaction: Uint8Array; + /** PartitionQueryRequest partitionCount. */ + public partitionCount: (number|string); - /** RunQueryRequest newTransaction. */ - public newTransaction?: (google.firestore.v1.ITransactionOptions|null); + /** PartitionQueryRequest pageToken. */ + public pageToken: string; - /** RunQueryRequest readTime. */ - public readTime?: (google.protobuf.ITimestamp|null); + /** PartitionQueryRequest pageSize. */ + public pageSize: number; - /** RunQueryRequest queryType. */ + /** PartitionQueryRequest queryType. */ public queryType?: "structuredQuery"; - /** RunQueryRequest consistencySelector. */ - public consistencySelector?: ("transaction"|"newTransaction"|"readTime"); - } + /** + * Creates a PartitionQueryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PartitionQueryRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.PartitionQueryRequest; - /** Properties of a RunQueryResponse. */ - interface IRunQueryResponse { + /** + * Creates a plain object from a PartitionQueryRequest message. Also converts values to other types if specified. + * @param message PartitionQueryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.PartitionQueryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; - /** RunQueryResponse transaction */ - transaction?: (Uint8Array|null); + /** + * Converts this PartitionQueryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } - /** RunQueryResponse document */ - document?: (google.firestore.v1.IDocument|null); + /** Properties of a PartitionQueryResponse. */ + interface IPartitionQueryResponse { - /** RunQueryResponse readTime */ - readTime?: (google.protobuf.ITimestamp|null); + /** PartitionQueryResponse partitions */ + partitions?: (google.firestore.v1.ICursor[]|null); - /** RunQueryResponse skippedResults */ - skippedResults?: (number|null); + /** PartitionQueryResponse nextPageToken */ + nextPageToken?: (string|null); } - /** Represents a RunQueryResponse. */ - class RunQueryResponse implements IRunQueryResponse { + /** Represents a PartitionQueryResponse. */ + class PartitionQueryResponse implements IPartitionQueryResponse { /** - * Constructs a new RunQueryResponse. + * Constructs a new PartitionQueryResponse. * @param [properties] Properties to set */ - constructor(properties?: google.firestore.v1.IRunQueryResponse); + constructor(properties?: google.firestore.v1.IPartitionQueryResponse); - /** RunQueryResponse transaction. */ - public transaction: Uint8Array; + /** PartitionQueryResponse partitions. */ + public partitions: google.firestore.v1.ICursor[]; - /** RunQueryResponse document. */ - public document?: (google.firestore.v1.IDocument|null); + /** PartitionQueryResponse nextPageToken. */ + public nextPageToken: string; - /** RunQueryResponse readTime. */ - public readTime?: (google.protobuf.ITimestamp|null); + /** + * Creates a PartitionQueryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PartitionQueryResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.PartitionQueryResponse; - /** RunQueryResponse skippedResults. */ - public skippedResults: number; + /** + * Creates a plain object from a PartitionQueryResponse message. Also converts values to other types if specified. + * @param message PartitionQueryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.PartitionQueryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PartitionQueryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a WriteRequest. */ @@ -2695,6 +4517,27 @@ export namespace google { /** WriteRequest labels. */ public labels: { [k: string]: string }; + + /** + * Creates a WriteRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WriteRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.WriteRequest; + + /** + * Creates a plain object from a WriteRequest message. Also converts values to other types if specified. + * @param message WriteRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.WriteRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WriteRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a WriteResponse. */ @@ -2733,6 +4576,27 @@ export namespace google { /** WriteResponse commitTime. */ public commitTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a WriteResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WriteResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.WriteResponse; + + /** + * Creates a plain object from a WriteResponse message. Also converts values to other types if specified. + * @param message WriteResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.WriteResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WriteResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListenRequest. */ @@ -2774,6 +4638,27 @@ export namespace google { /** ListenRequest targetChange. */ public targetChange?: ("addTarget"|"removeTarget"); + + /** + * Creates a ListenRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListenRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.ListenRequest; + + /** + * Creates a plain object from a ListenRequest message. Also converts values to other types if specified. + * @param message ListenRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.ListenRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListenRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListenResponse. */ @@ -2821,6 +4706,27 @@ export namespace google { /** ListenResponse responseType. */ public responseType?: ("targetChange"|"documentChange"|"documentDelete"|"documentRemove"|"filter"); + + /** + * Creates a ListenResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListenResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.ListenResponse; + + /** + * Creates a plain object from a ListenResponse message. Also converts values to other types if specified. + * @param message ListenResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.ListenResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListenResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Target. */ @@ -2877,6 +4783,27 @@ export namespace google { /** Target resumeType. */ public resumeType?: ("resumeToken"|"readTime"); + + /** + * Creates a Target message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Target + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.Target; + + /** + * Creates a plain object from a Target message. Also converts values to other types if specified. + * @param message Target + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.Target, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Target to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace Target { @@ -2899,6 +4826,27 @@ export namespace google { /** DocumentsTarget documents. */ public documents: string[]; + + /** + * Creates a DocumentsTarget message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentsTarget + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.Target.DocumentsTarget; + + /** + * Creates a plain object from a DocumentsTarget message. Also converts values to other types if specified. + * @param message DocumentsTarget + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.Target.DocumentsTarget, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentsTarget to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a QueryTarget. */ @@ -2928,6 +4876,27 @@ export namespace google { /** QueryTarget queryType. */ public queryType?: "structuredQuery"; + + /** + * Creates a QueryTarget message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns QueryTarget + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.Target.QueryTarget; + + /** + * Creates a plain object from a QueryTarget message. Also converts values to other types if specified. + * @param message QueryTarget + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.Target.QueryTarget, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this QueryTarget to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -2973,6 +4942,27 @@ export namespace google { /** TargetChange readTime. */ public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a TargetChange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TargetChange + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.TargetChange; + + /** + * Creates a plain object from a TargetChange message. Also converts values to other types if specified. + * @param message TargetChange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.TargetChange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TargetChange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace TargetChange { @@ -3012,6 +5002,27 @@ export namespace google { /** ListCollectionIdsRequest pageToken. */ public pageToken: string; + + /** + * Creates a ListCollectionIdsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCollectionIdsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.ListCollectionIdsRequest; + + /** + * Creates a plain object from a ListCollectionIdsRequest message. Also converts values to other types if specified. + * @param message ListCollectionIdsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.ListCollectionIdsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCollectionIdsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListCollectionIdsResponse. */ @@ -3038,6 +5049,27 @@ export namespace google { /** ListCollectionIdsResponse nextPageToken. */ public nextPageToken: string; + + /** + * Creates a ListCollectionIdsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCollectionIdsResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.ListCollectionIdsResponse; + + /** + * Creates a plain object from a ListCollectionIdsResponse message. Also converts values to other types if specified. + * @param message ListCollectionIdsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.ListCollectionIdsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCollectionIdsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a BatchWriteRequest. */ @@ -3048,6 +5080,9 @@ export namespace google { /** BatchWriteRequest writes */ writes?: (google.firestore.v1.IWrite[]|null); + + /** BatchWriteRequest labels */ + labels?: ({ [k: string]: string }|null); } /** Represents a BatchWriteRequest. */ @@ -3064,6 +5099,30 @@ export namespace google { /** BatchWriteRequest writes. */ public writes: google.firestore.v1.IWrite[]; + + /** BatchWriteRequest labels. */ + public labels: { [k: string]: string }; + + /** + * Creates a BatchWriteRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchWriteRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.BatchWriteRequest; + + /** + * Creates a plain object from a BatchWriteRequest message. Also converts values to other types if specified. + * @param message BatchWriteRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.BatchWriteRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchWriteRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a BatchWriteResponse. */ @@ -3090,6 +5149,27 @@ export namespace google { /** BatchWriteResponse status. */ public status: google.rpc.IStatus[]; + + /** + * Creates a BatchWriteResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchWriteResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.BatchWriteResponse; + + /** + * Creates a plain object from a BatchWriteResponse message. Also converts values to other types if specified. + * @param message BatchWriteResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.BatchWriteResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchWriteResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a StructuredQuery. */ @@ -3152,6 +5232,27 @@ export namespace google { /** StructuredQuery limit. */ public limit?: (google.protobuf.IInt32Value|null); + + /** + * Creates a StructuredQuery message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StructuredQuery + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery; + + /** + * Creates a plain object from a StructuredQuery message. Also converts values to other types if specified. + * @param message StructuredQuery + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StructuredQuery to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace StructuredQuery { @@ -3180,6 +5281,27 @@ export namespace google { /** CollectionSelector allDescendants. */ public allDescendants: boolean; + + /** + * Creates a CollectionSelector message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CollectionSelector + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.CollectionSelector; + + /** + * Creates a plain object from a CollectionSelector message. Also converts values to other types if specified. + * @param message CollectionSelector + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.CollectionSelector, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CollectionSelector to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Filter. */ @@ -3215,6 +5337,27 @@ export namespace google { /** Filter filterType. */ public filterType?: ("compositeFilter"|"fieldFilter"|"unaryFilter"); + + /** + * Creates a Filter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Filter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.Filter; + + /** + * Creates a plain object from a Filter message. Also converts values to other types if specified. + * @param message Filter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.Filter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Filter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a CompositeFilter. */ @@ -3241,6 +5384,27 @@ export namespace google { /** CompositeFilter filters. */ public filters: google.firestore.v1.StructuredQuery.IFilter[]; + + /** + * Creates a CompositeFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompositeFilter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.CompositeFilter; + + /** + * Creates a plain object from a CompositeFilter message. Also converts values to other types if specified. + * @param message CompositeFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.CompositeFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompositeFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace CompositeFilter { @@ -3280,6 +5444,27 @@ export namespace google { /** FieldFilter value. */ public value?: (google.firestore.v1.IValue|null); + + /** + * Creates a FieldFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldFilter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.FieldFilter; + + /** + * Creates a plain object from a FieldFilter message. Also converts values to other types if specified. + * @param message FieldFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.FieldFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace FieldFilter { @@ -3289,26 +5474,6 @@ export namespace google { "OPERATOR_UNSPECIFIED"| "LESS_THAN"| "LESS_THAN_OR_EQUAL"| "GREATER_THAN"| "GREATER_THAN_OR_EQUAL"| "EQUAL"| "ARRAY_CONTAINS"| "IN"| "ARRAY_CONTAINS_ANY"; } - /** Properties of a Projection. */ - interface IProjection { - - /** Projection fields */ - fields?: (google.firestore.v1.StructuredQuery.IFieldReference[]|null); - } - - /** Represents a Projection. */ - class Projection implements IProjection { - - /** - * Constructs a new Projection. - * @param [properties] Properties to set - */ - constructor(properties?: google.firestore.v1.StructuredQuery.IProjection); - - /** Projection fields. */ - public fields: google.firestore.v1.StructuredQuery.IFieldReference[]; - } - /** Properties of an UnaryFilter. */ interface IUnaryFilter { @@ -3336,6 +5501,27 @@ export namespace google { /** UnaryFilter operandType. */ public operandType?: "field"; + + /** + * Creates an UnaryFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UnaryFilter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.UnaryFilter; + + /** + * Creates a plain object from an UnaryFilter message. Also converts values to other types if specified. + * @param message UnaryFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.UnaryFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UnaryFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace UnaryFilter { @@ -3363,6 +5549,27 @@ export namespace google { /** FieldReference fieldPath. */ public fieldPath: string; + + /** + * Creates a FieldReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldReference + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.FieldReference; + + /** + * Creates a plain object from a FieldReference message. Also converts values to other types if specified. + * @param message FieldReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.FieldReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an Order. */ @@ -3389,6 +5596,68 @@ export namespace google { /** Order direction. */ public direction: google.firestore.v1.StructuredQuery.Direction; + + /** + * Creates an Order message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Order + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.Order; + + /** + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @param message Order + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.Order, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Order to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Projection. */ + interface IProjection { + + /** Projection fields */ + fields?: (google.firestore.v1.StructuredQuery.IFieldReference[]|null); + } + + /** Represents a Projection. */ + class Projection implements IProjection { + + /** + * Constructs a new Projection. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.StructuredQuery.IProjection); + + /** Projection fields. */ + public fields: google.firestore.v1.StructuredQuery.IFieldReference[]; + + /** + * Creates a Projection message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Projection + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.Projection; + + /** + * Creates a plain object from a Projection message. Also converts values to other types if specified. + * @param message Projection + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.Projection, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Projection to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Direction enum. */ @@ -3420,6 +5689,27 @@ export namespace google { /** Cursor before. */ public before: boolean; + + /** + * Creates a Cursor message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Cursor + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.Cursor; + + /** + * Creates a plain object from a Cursor message. Also converts values to other types if specified. + * @param message Cursor + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.Cursor, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Cursor to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Write. */ @@ -3473,6 +5763,27 @@ export namespace google { /** Write operation. */ public operation?: ("update"|"delete"|"transform"); + + /** + * Creates a Write message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Write + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.Write; + + /** + * Creates a plain object from a Write message. Also converts values to other types if specified. + * @param message Write + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.Write, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Write to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DocumentTransform. */ @@ -3499,6 +5810,27 @@ export namespace google { /** DocumentTransform fieldTransforms. */ public fieldTransforms: google.firestore.v1.DocumentTransform.IFieldTransform[]; + + /** + * Creates a DocumentTransform message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentTransform + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.DocumentTransform; + + /** + * Creates a plain object from a DocumentTransform message. Also converts values to other types if specified. + * @param message DocumentTransform + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.DocumentTransform, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentTransform to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace DocumentTransform { @@ -3560,6 +5892,27 @@ export namespace google { /** FieldTransform transformType. */ public transformType?: ("setToServerValue"|"increment"|"maximum"|"minimum"|"appendMissingElements"|"removeAllFromArray"); + + /** + * Creates a FieldTransform message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldTransform + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.DocumentTransform.FieldTransform; + + /** + * Creates a plain object from a FieldTransform message. Also converts values to other types if specified. + * @param message FieldTransform + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.DocumentTransform.FieldTransform, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldTransform to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace FieldTransform { @@ -3594,6 +5947,27 @@ export namespace google { /** WriteResult transformResults. */ public transformResults: google.firestore.v1.IValue[]; + + /** + * Creates a WriteResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WriteResult + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.WriteResult; + + /** + * Creates a plain object from a WriteResult message. Also converts values to other types if specified. + * @param message WriteResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.WriteResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WriteResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DocumentChange. */ @@ -3626,6 +6000,27 @@ export namespace google { /** DocumentChange removedTargetIds. */ public removedTargetIds: number[]; + + /** + * Creates a DocumentChange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentChange + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.DocumentChange; + + /** + * Creates a plain object from a DocumentChange message. Also converts values to other types if specified. + * @param message DocumentChange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.DocumentChange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentChange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DocumentDelete. */ @@ -3658,6 +6053,27 @@ export namespace google { /** DocumentDelete readTime. */ public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a DocumentDelete message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentDelete + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.DocumentDelete; + + /** + * Creates a plain object from a DocumentDelete message. Also converts values to other types if specified. + * @param message DocumentDelete + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.DocumentDelete, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentDelete to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DocumentRemove. */ @@ -3690,6 +6106,27 @@ export namespace google { /** DocumentRemove readTime. */ public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a DocumentRemove message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentRemove + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.DocumentRemove; + + /** + * Creates a plain object from a DocumentRemove message. Also converts values to other types if specified. + * @param message DocumentRemove + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.DocumentRemove, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentRemove to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an ExistenceFilter. */ @@ -3716,6 +6153,27 @@ export namespace google { /** ExistenceFilter count. */ public count: number; + + /** + * Creates an ExistenceFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExistenceFilter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.ExistenceFilter; + + /** + * Creates a plain object from an ExistenceFilter message. Also converts values to other types if specified. + * @param message ExistenceFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.ExistenceFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExistenceFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } } @@ -3741,6 +6199,27 @@ export namespace google { /** Http rules. */ public rules: google.api.IHttpRule[]; + + /** + * Creates a Http message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Http + */ + public static fromObject(object: { [k: string]: any }): google.api.Http; + + /** + * Creates a plain object from a Http message. Also converts values to other types if specified. + * @param message Http + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.Http, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Http to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a HttpRule. */ @@ -3812,6 +6291,27 @@ export namespace google { /** HttpRule pattern. */ public pattern?: ("get"|"put"|"post"|"delete"|"patch"|"custom"); + + /** + * Creates a HttpRule message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns HttpRule + */ + public static fromObject(object: { [k: string]: any }): google.api.HttpRule; + + /** + * Creates a plain object from a HttpRule message. Also converts values to other types if specified. + * @param message HttpRule + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.HttpRule, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this HttpRule to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a CustomHttpPattern. */ @@ -3838,6 +6338,27 @@ export namespace google { /** CustomHttpPattern path. */ public path: string; + + /** + * Creates a CustomHttpPattern message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CustomHttpPattern + */ + public static fromObject(object: { [k: string]: any }): google.api.CustomHttpPattern; + + /** + * Creates a plain object from a CustomHttpPattern message. Also converts values to other types if specified. + * @param message CustomHttpPattern + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.CustomHttpPattern, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CustomHttpPattern to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** FieldBehavior enum. */ @@ -3892,6 +6413,27 @@ export namespace google { /** ResourceDescriptor singular. */ public singular: string; + + /** + * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ResourceDescriptor + */ + public static fromObject(object: { [k: string]: any }): google.api.ResourceDescriptor; + + /** + * Creates a plain object from a ResourceDescriptor message. Also converts values to other types if specified. + * @param message ResourceDescriptor + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.ResourceDescriptor, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ResourceDescriptor to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace ResourceDescriptor { @@ -3925,6 +6467,27 @@ export namespace google { /** ResourceReference childType. */ public childType: string; + + /** + * Creates a ResourceReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ResourceReference + */ + public static fromObject(object: { [k: string]: any }): google.api.ResourceReference; + + /** + * Creates a plain object from a ResourceReference message. Also converts values to other types if specified. + * @param message ResourceReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.ResourceReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ResourceReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -3955,6 +6518,27 @@ export namespace google { /** LatLng longitude. */ public longitude: number; + + /** + * Creates a LatLng message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LatLng + */ + public static fromObject(object: { [k: string]: any }): google.type.LatLng; + + /** + * Creates a plain object from a LatLng message. Also converts values to other types if specified. + * @param message LatLng + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.type.LatLng, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LatLng to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -3991,6 +6575,27 @@ export namespace google { /** Status details. */ public details: google.protobuf.IAny[]; + + /** + * Creates a Status message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Status + */ + public static fromObject(object: { [k: string]: any }): google.rpc.Status; + + /** + * Creates a plain object from a Status message. Also converts values to other types if specified. + * @param message Status + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.rpc.Status, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Status to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -4162,6 +6767,27 @@ export namespace google { /** Operation result. */ public result?: ("error"|"response"); + + /** + * Creates an Operation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Operation + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.Operation; + + /** + * Creates a plain object from an Operation message. Also converts values to other types if specified. + * @param message Operation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.Operation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Operation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a GetOperationRequest. */ @@ -4182,6 +6808,27 @@ export namespace google { /** GetOperationRequest name. */ public name: string; + + /** + * Creates a GetOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.GetOperationRequest; + + /** + * Creates a plain object from a GetOperationRequest message. Also converts values to other types if specified. + * @param message GetOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.GetOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListOperationsRequest. */ @@ -4220,6 +6867,27 @@ export namespace google { /** ListOperationsRequest pageToken. */ public pageToken: string; + + /** + * Creates a ListOperationsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListOperationsRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.ListOperationsRequest; + + /** + * Creates a plain object from a ListOperationsRequest message. Also converts values to other types if specified. + * @param message ListOperationsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.ListOperationsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListOperationsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListOperationsResponse. */ @@ -4246,6 +6914,27 @@ export namespace google { /** ListOperationsResponse nextPageToken. */ public nextPageToken: string; + + /** + * Creates a ListOperationsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListOperationsResponse + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.ListOperationsResponse; + + /** + * Creates a plain object from a ListOperationsResponse message. Also converts values to other types if specified. + * @param message ListOperationsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.ListOperationsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListOperationsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a CancelOperationRequest. */ @@ -4266,6 +6955,27 @@ export namespace google { /** CancelOperationRequest name. */ public name: string; + + /** + * Creates a CancelOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CancelOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.CancelOperationRequest; + + /** + * Creates a plain object from a CancelOperationRequest message. Also converts values to other types if specified. + * @param message CancelOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.CancelOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CancelOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DeleteOperationRequest. */ @@ -4286,6 +6996,27 @@ export namespace google { /** DeleteOperationRequest name. */ public name: string; + + /** + * Creates a DeleteOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.DeleteOperationRequest; + + /** + * Creates a plain object from a DeleteOperationRequest message. Also converts values to other types if specified. + * @param message DeleteOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.DeleteOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a WaitOperationRequest. */ @@ -4312,6 +7043,27 @@ export namespace google { /** WaitOperationRequest timeout. */ public timeout?: (google.protobuf.IDuration|null); + + /** + * Creates a WaitOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WaitOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.WaitOperationRequest; + + /** + * Creates a plain object from a WaitOperationRequest message. Also converts values to other types if specified. + * @param message WaitOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.WaitOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WaitOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an OperationInfo. */ @@ -4338,6 +7090,27 @@ export namespace google { /** OperationInfo metadataType. */ public metadataType: string; + + /** + * Creates an OperationInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OperationInfo + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.OperationInfo; + + /** + * Creates a plain object from an OperationInfo message. Also converts values to other types if specified. + * @param message OperationInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.OperationInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OperationInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } } diff --git a/dev/protos/firestore_v1_proto_api.js b/dev/protos/firestore_v1_proto_api.js index 5fd8fd789..3404fd4af 100644 --- a/dev/protos/firestore_v1_proto_api.js +++ b/dev/protos/firestore_v1_proto_api.js @@ -14,7552 +14,16934 @@ * limitations under the License. */ -// Common aliases -var $util = $protobuf.util; - -// Exported root namespace -var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); - -$root.google = (function() { - - /** - * Namespace google. - * @exports google - * @namespace - */ - var google = {}; - - google.protobuf = (function() { - +/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ +(function(global, factory) { /* global define, require, module */ + + /* AMD */ if (typeof define === 'function' && define.amd) + define(["protobufjs/minimal"], factory); + + /* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports) + module.exports = factory(require("protobufjs/minimal")); + +})(this, function($protobuf) { + "use strict"; + + // Common aliases + var $util = $protobuf.util; + + // Exported root namespace + var $root = $protobuf.roots.firestore_v1 || ($protobuf.roots.firestore_v1 = {}); + + $root.firestore = (function() { + /** - * Namespace protobuf. - * @memberof google + * Namespace firestore. + * @exports firestore * @namespace */ - var protobuf = {}; - - protobuf.Timestamp = (function() { - - /** - * Properties of a Timestamp. - * @memberof google.protobuf - * @interface ITimestamp - * @property {number|null} [seconds] Timestamp seconds - * @property {number|null} [nanos] Timestamp nanos - */ - - /** - * Constructs a new Timestamp. - * @memberof google.protobuf - * @classdesc Represents a Timestamp. - * @implements ITimestamp + var firestore = {}; + + firestore.BundledQuery = (function() { + + /** + * Properties of a BundledQuery. + * @memberof firestore + * @interface IBundledQuery + * @property {string|null} [parent] BundledQuery parent + * @property {google.firestore.v1.IStructuredQuery|null} [structuredQuery] BundledQuery structuredQuery + * @property {firestore.BundledQuery.LimitType|null} [limitType] BundledQuery limitType + */ + + /** + * Constructs a new BundledQuery. + * @memberof firestore + * @classdesc Represents a BundledQuery. + * @implements IBundledQuery * @constructor - * @param {google.protobuf.ITimestamp=} [properties] Properties to set + * @param {firestore.IBundledQuery=} [properties] Properties to set */ - function Timestamp(properties) { + function BundledQuery(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * Timestamp seconds. - * @member {number} seconds - * @memberof google.protobuf.Timestamp + * BundledQuery parent. + * @member {string} parent + * @memberof firestore.BundledQuery * @instance */ - Timestamp.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - + BundledQuery.prototype.parent = ""; + /** - * Timestamp nanos. - * @member {number} nanos - * @memberof google.protobuf.Timestamp + * BundledQuery structuredQuery. + * @member {google.firestore.v1.IStructuredQuery|null|undefined} structuredQuery + * @memberof firestore.BundledQuery * @instance */ - Timestamp.prototype.nanos = 0; - - return Timestamp; - })(); - - protobuf.FileDescriptorSet = (function() { - + BundledQuery.prototype.structuredQuery = null; + /** - * Properties of a FileDescriptorSet. - * @memberof google.protobuf - * @interface IFileDescriptorSet - * @property {Array.|null} [file] FileDescriptorSet file + * BundledQuery limitType. + * @member {firestore.BundledQuery.LimitType} limitType + * @memberof firestore.BundledQuery + * @instance */ - + BundledQuery.prototype.limitType = 0; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * BundledQuery queryType. + * @member {"structuredQuery"|undefined} queryType + * @memberof firestore.BundledQuery + * @instance + */ + Object.defineProperty(BundledQuery.prototype, "queryType", { + get: $util.oneOfGetter($oneOfFields = ["structuredQuery"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a BundledQuery message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof firestore.BundledQuery + * @static + * @param {Object.} object Plain object + * @returns {firestore.BundledQuery} BundledQuery + */ + BundledQuery.fromObject = function fromObject(object) { + if (object instanceof $root.firestore.BundledQuery) + return object; + var message = new $root.firestore.BundledQuery(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.structuredQuery != null) { + if (typeof object.structuredQuery !== "object") + throw TypeError(".firestore.BundledQuery.structuredQuery: object expected"); + message.structuredQuery = $root.google.firestore.v1.StructuredQuery.fromObject(object.structuredQuery); + } + switch (object.limitType) { + case "FIRST": + case 0: + message.limitType = 0; + break; + case "LAST": + case 1: + message.limitType = 1; + break; + } + return message; + }; + + /** + * Creates a plain object from a BundledQuery message. Also converts values to other types if specified. + * @function toObject + * @memberof firestore.BundledQuery + * @static + * @param {firestore.BundledQuery} message BundledQuery + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BundledQuery.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.limitType = options.enums === String ? "FIRST" : 0; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.structuredQuery != null && message.hasOwnProperty("structuredQuery")) { + object.structuredQuery = $root.google.firestore.v1.StructuredQuery.toObject(message.structuredQuery, options); + if (options.oneofs) + object.queryType = "structuredQuery"; + } + if (message.limitType != null && message.hasOwnProperty("limitType")) + object.limitType = options.enums === String ? $root.firestore.BundledQuery.LimitType[message.limitType] : message.limitType; + return object; + }; + + /** + * Converts this BundledQuery to JSON. + * @function toJSON + * @memberof firestore.BundledQuery + * @instance + * @returns {Object.} JSON object + */ + BundledQuery.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + /** - * Constructs a new FileDescriptorSet. - * @memberof google.protobuf - * @classdesc Represents a FileDescriptorSet. - * @implements IFileDescriptorSet + * LimitType enum. + * @name firestore.BundledQuery.LimitType + * @enum {string} + * @property {string} FIRST=FIRST FIRST value + * @property {string} LAST=LAST LAST value + */ + BundledQuery.LimitType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "FIRST"] = "FIRST"; + values[valuesById[1] = "LAST"] = "LAST"; + return values; + })(); + + return BundledQuery; + })(); + + firestore.NamedQuery = (function() { + + /** + * Properties of a NamedQuery. + * @memberof firestore + * @interface INamedQuery + * @property {string|null} [name] NamedQuery name + * @property {firestore.IBundledQuery|null} [bundledQuery] NamedQuery bundledQuery + * @property {google.protobuf.ITimestamp|null} [readTime] NamedQuery readTime + */ + + /** + * Constructs a new NamedQuery. + * @memberof firestore + * @classdesc Represents a NamedQuery. + * @implements INamedQuery * @constructor - * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + * @param {firestore.INamedQuery=} [properties] Properties to set */ - function FileDescriptorSet(properties) { - this.file = []; + function NamedQuery(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * FileDescriptorSet file. - * @member {Array.} file - * @memberof google.protobuf.FileDescriptorSet + * NamedQuery name. + * @member {string} name + * @memberof firestore.NamedQuery * @instance */ - FileDescriptorSet.prototype.file = $util.emptyArray; - - return FileDescriptorSet; - })(); - - protobuf.FileDescriptorProto = (function() { - + NamedQuery.prototype.name = ""; + /** - * Properties of a FileDescriptorProto. - * @memberof google.protobuf - * @interface IFileDescriptorProto - * @property {string|null} [name] FileDescriptorProto name - * @property {string|null} ["package"] FileDescriptorProto package - * @property {Array.|null} [dependency] FileDescriptorProto dependency - * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency - * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency - * @property {Array.|null} [messageType] FileDescriptorProto messageType - * @property {Array.|null} [enumType] FileDescriptorProto enumType - * @property {Array.|null} [service] FileDescriptorProto service - * @property {Array.|null} [extension] FileDescriptorProto extension - * @property {google.protobuf.IFileOptions|null} [options] FileDescriptorProto options - * @property {google.protobuf.ISourceCodeInfo|null} [sourceCodeInfo] FileDescriptorProto sourceCodeInfo - * @property {string|null} [syntax] FileDescriptorProto syntax + * NamedQuery bundledQuery. + * @member {firestore.IBundledQuery|null|undefined} bundledQuery + * @memberof firestore.NamedQuery + * @instance */ - + NamedQuery.prototype.bundledQuery = null; + /** - * Constructs a new FileDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents a FileDescriptorProto. - * @implements IFileDescriptorProto + * NamedQuery readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof firestore.NamedQuery + * @instance + */ + NamedQuery.prototype.readTime = null; + + /** + * Creates a NamedQuery message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof firestore.NamedQuery + * @static + * @param {Object.} object Plain object + * @returns {firestore.NamedQuery} NamedQuery + */ + NamedQuery.fromObject = function fromObject(object) { + if (object instanceof $root.firestore.NamedQuery) + return object; + var message = new $root.firestore.NamedQuery(); + if (object.name != null) + message.name = String(object.name); + if (object.bundledQuery != null) { + if (typeof object.bundledQuery !== "object") + throw TypeError(".firestore.NamedQuery.bundledQuery: object expected"); + message.bundledQuery = $root.firestore.BundledQuery.fromObject(object.bundledQuery); + } + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".firestore.NamedQuery.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a NamedQuery message. Also converts values to other types if specified. + * @function toObject + * @memberof firestore.NamedQuery + * @static + * @param {firestore.NamedQuery} message NamedQuery + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + NamedQuery.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.bundledQuery = null; + object.readTime = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.bundledQuery != null && message.hasOwnProperty("bundledQuery")) + object.bundledQuery = $root.firestore.BundledQuery.toObject(message.bundledQuery, options); + if (message.readTime != null && message.hasOwnProperty("readTime")) + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + return object; + }; + + /** + * Converts this NamedQuery to JSON. + * @function toJSON + * @memberof firestore.NamedQuery + * @instance + * @returns {Object.} JSON object + */ + NamedQuery.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return NamedQuery; + })(); + + firestore.BundledDocumentMetadata = (function() { + + /** + * Properties of a BundledDocumentMetadata. + * @memberof firestore + * @interface IBundledDocumentMetadata + * @property {string|null} [name] BundledDocumentMetadata name + * @property {google.protobuf.ITimestamp|null} [readTime] BundledDocumentMetadata readTime + * @property {boolean|null} [exists] BundledDocumentMetadata exists + */ + + /** + * Constructs a new BundledDocumentMetadata. + * @memberof firestore + * @classdesc Represents a BundledDocumentMetadata. + * @implements IBundledDocumentMetadata * @constructor - * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set + * @param {firestore.IBundledDocumentMetadata=} [properties] Properties to set */ - function FileDescriptorProto(properties) { - this.dependency = []; - this.publicDependency = []; - this.weakDependency = []; - this.messageType = []; - this.enumType = []; - this.service = []; - this.extension = []; + function BundledDocumentMetadata(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * FileDescriptorProto name. + * BundledDocumentMetadata name. * @member {string} name - * @memberof google.protobuf.FileDescriptorProto + * @memberof firestore.BundledDocumentMetadata * @instance */ - FileDescriptorProto.prototype.name = ""; - - /** - * FileDescriptorProto package. - * @member {string} package - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype["package"] = ""; - + BundledDocumentMetadata.prototype.name = ""; + /** - * FileDescriptorProto dependency. - * @member {Array.} dependency - * @memberof google.protobuf.FileDescriptorProto + * BundledDocumentMetadata readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof firestore.BundledDocumentMetadata * @instance */ - FileDescriptorProto.prototype.dependency = $util.emptyArray; - + BundledDocumentMetadata.prototype.readTime = null; + /** - * FileDescriptorProto publicDependency. - * @member {Array.} publicDependency - * @memberof google.protobuf.FileDescriptorProto + * BundledDocumentMetadata exists. + * @member {boolean} exists + * @memberof firestore.BundledDocumentMetadata * @instance */ - FileDescriptorProto.prototype.publicDependency = $util.emptyArray; - - /** - * FileDescriptorProto weakDependency. - * @member {Array.} weakDependency - * @memberof google.protobuf.FileDescriptorProto + BundledDocumentMetadata.prototype.exists = false; + + /** + * Creates a BundledDocumentMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof firestore.BundledDocumentMetadata + * @static + * @param {Object.} object Plain object + * @returns {firestore.BundledDocumentMetadata} BundledDocumentMetadata + */ + BundledDocumentMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.firestore.BundledDocumentMetadata) + return object; + var message = new $root.firestore.BundledDocumentMetadata(); + if (object.name != null) + message.name = String(object.name); + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".firestore.BundledDocumentMetadata.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + if (object.exists != null) + message.exists = Boolean(object.exists); + return message; + }; + + /** + * Creates a plain object from a BundledDocumentMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof firestore.BundledDocumentMetadata + * @static + * @param {firestore.BundledDocumentMetadata} message BundledDocumentMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BundledDocumentMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.readTime = null; + object.exists = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.readTime != null && message.hasOwnProperty("readTime")) + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (message.exists != null && message.hasOwnProperty("exists")) + object.exists = message.exists; + return object; + }; + + /** + * Converts this BundledDocumentMetadata to JSON. + * @function toJSON + * @memberof firestore.BundledDocumentMetadata * @instance + * @returns {Object.} JSON object */ - FileDescriptorProto.prototype.weakDependency = $util.emptyArray; - - /** - * FileDescriptorProto messageType. - * @member {Array.} messageType - * @memberof google.protobuf.FileDescriptorProto - * @instance + BundledDocumentMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BundledDocumentMetadata; + })(); + + firestore.BundleMetadata = (function() { + + /** + * Properties of a BundleMetadata. + * @memberof firestore + * @interface IBundleMetadata + * @property {string|null} [id] BundleMetadata id + * @property {google.protobuf.ITimestamp|null} [createTime] BundleMetadata createTime + * @property {number|null} [version] BundleMetadata version + * @property {number|null} [totalDocuments] BundleMetadata totalDocuments + * @property {number|string|null} [totalBytes] BundleMetadata totalBytes + */ + + /** + * Constructs a new BundleMetadata. + * @memberof firestore + * @classdesc Represents a BundleMetadata. + * @implements IBundleMetadata + * @constructor + * @param {firestore.IBundleMetadata=} [properties] Properties to set */ - FileDescriptorProto.prototype.messageType = $util.emptyArray; - + function BundleMetadata(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + /** - * FileDescriptorProto enumType. - * @member {Array.} enumType - * @memberof google.protobuf.FileDescriptorProto + * BundleMetadata id. + * @member {string} id + * @memberof firestore.BundleMetadata * @instance */ - FileDescriptorProto.prototype.enumType = $util.emptyArray; - + BundleMetadata.prototype.id = ""; + /** - * FileDescriptorProto service. - * @member {Array.} service - * @memberof google.protobuf.FileDescriptorProto + * BundleMetadata createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof firestore.BundleMetadata * @instance */ - FileDescriptorProto.prototype.service = $util.emptyArray; - + BundleMetadata.prototype.createTime = null; + /** - * FileDescriptorProto extension. - * @member {Array.} extension - * @memberof google.protobuf.FileDescriptorProto + * BundleMetadata version. + * @member {number} version + * @memberof firestore.BundleMetadata * @instance */ - FileDescriptorProto.prototype.extension = $util.emptyArray; - + BundleMetadata.prototype.version = 0; + /** - * FileDescriptorProto options. - * @member {google.protobuf.IFileOptions|null|undefined} options - * @memberof google.protobuf.FileDescriptorProto + * BundleMetadata totalDocuments. + * @member {number} totalDocuments + * @memberof firestore.BundleMetadata * @instance */ - FileDescriptorProto.prototype.options = null; - + BundleMetadata.prototype.totalDocuments = 0; + /** - * FileDescriptorProto sourceCodeInfo. - * @member {google.protobuf.ISourceCodeInfo|null|undefined} sourceCodeInfo - * @memberof google.protobuf.FileDescriptorProto + * BundleMetadata totalBytes. + * @member {number|string} totalBytes + * @memberof firestore.BundleMetadata * @instance */ - FileDescriptorProto.prototype.sourceCodeInfo = null; - - /** - * FileDescriptorProto syntax. - * @member {string} syntax - * @memberof google.protobuf.FileDescriptorProto + BundleMetadata.prototype.totalBytes = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Creates a BundleMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof firestore.BundleMetadata + * @static + * @param {Object.} object Plain object + * @returns {firestore.BundleMetadata} BundleMetadata + */ + BundleMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.firestore.BundleMetadata) + return object; + var message = new $root.firestore.BundleMetadata(); + if (object.id != null) + message.id = String(object.id); + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".firestore.BundleMetadata.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.version != null) + message.version = object.version >>> 0; + if (object.totalDocuments != null) + message.totalDocuments = object.totalDocuments >>> 0; + if (object.totalBytes != null) + if ($util.Long) + (message.totalBytes = $util.Long.fromValue(object.totalBytes)).unsigned = true; + else if (typeof object.totalBytes === "string") + message.totalBytes = parseInt(object.totalBytes, 10); + else if (typeof object.totalBytes === "number") + message.totalBytes = object.totalBytes; + else if (typeof object.totalBytes === "object") + message.totalBytes = new $util.LongBits(object.totalBytes.low >>> 0, object.totalBytes.high >>> 0).toNumber(true); + return message; + }; + + /** + * Creates a plain object from a BundleMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof firestore.BundleMetadata + * @static + * @param {firestore.BundleMetadata} message BundleMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BundleMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.id = ""; + object.createTime = null; + object.version = 0; + object.totalDocuments = 0; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.totalBytes = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.totalBytes = options.longs === String ? "0" : 0; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.version != null && message.hasOwnProperty("version")) + object.version = message.version; + if (message.totalDocuments != null && message.hasOwnProperty("totalDocuments")) + object.totalDocuments = message.totalDocuments; + if (message.totalBytes != null && message.hasOwnProperty("totalBytes")) + if (typeof message.totalBytes === "number") + object.totalBytes = options.longs === String ? String(message.totalBytes) : message.totalBytes; + else + object.totalBytes = options.longs === String ? $util.Long.prototype.toString.call(message.totalBytes) : options.longs === Number ? new $util.LongBits(message.totalBytes.low >>> 0, message.totalBytes.high >>> 0).toNumber(true) : message.totalBytes; + return object; + }; + + /** + * Converts this BundleMetadata to JSON. + * @function toJSON + * @memberof firestore.BundleMetadata * @instance + * @returns {Object.} JSON object */ - FileDescriptorProto.prototype.syntax = ""; - - return FileDescriptorProto; + BundleMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BundleMetadata; })(); - - protobuf.DescriptorProto = (function() { - - /** - * Properties of a DescriptorProto. - * @memberof google.protobuf - * @interface IDescriptorProto - * @property {string|null} [name] DescriptorProto name - * @property {Array.|null} [field] DescriptorProto field - * @property {Array.|null} [extension] DescriptorProto extension - * @property {Array.|null} [nestedType] DescriptorProto nestedType - * @property {Array.|null} [enumType] DescriptorProto enumType - * @property {Array.|null} [extensionRange] DescriptorProto extensionRange - * @property {Array.|null} [oneofDecl] DescriptorProto oneofDecl - * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options - * @property {Array.|null} [reservedRange] DescriptorProto reservedRange - * @property {Array.|null} [reservedName] DescriptorProto reservedName - */ - - /** - * Constructs a new DescriptorProto. - * @memberof google.protobuf - * @classdesc Represents a DescriptorProto. - * @implements IDescriptorProto + + firestore.BundleElement = (function() { + + /** + * Properties of a BundleElement. + * @memberof firestore + * @interface IBundleElement + * @property {firestore.IBundleMetadata|null} [metadata] BundleElement metadata + * @property {firestore.INamedQuery|null} [namedQuery] BundleElement namedQuery + * @property {firestore.IBundledDocumentMetadata|null} [documentMetadata] BundleElement documentMetadata + * @property {google.firestore.v1.IDocument|null} [document] BundleElement document + */ + + /** + * Constructs a new BundleElement. + * @memberof firestore + * @classdesc Represents a BundleElement. + * @implements IBundleElement * @constructor - * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set + * @param {firestore.IBundleElement=} [properties] Properties to set */ - function DescriptorProto(properties) { - this.field = []; - this.extension = []; - this.nestedType = []; - this.enumType = []; - this.extensionRange = []; - this.oneofDecl = []; - this.reservedRange = []; - this.reservedName = []; + function BundleElement(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - - /** - * DescriptorProto name. - * @member {string} name - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.name = ""; - - /** - * DescriptorProto field. - * @member {Array.} field - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.field = $util.emptyArray; - - /** - * DescriptorProto extension. - * @member {Array.} extension - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.extension = $util.emptyArray; - + /** - * DescriptorProto nestedType. - * @member {Array.} nestedType - * @memberof google.protobuf.DescriptorProto + * BundleElement metadata. + * @member {firestore.IBundleMetadata|null|undefined} metadata + * @memberof firestore.BundleElement * @instance */ - DescriptorProto.prototype.nestedType = $util.emptyArray; - + BundleElement.prototype.metadata = null; + /** - * DescriptorProto enumType. - * @member {Array.} enumType - * @memberof google.protobuf.DescriptorProto + * BundleElement namedQuery. + * @member {firestore.INamedQuery|null|undefined} namedQuery + * @memberof firestore.BundleElement * @instance */ - DescriptorProto.prototype.enumType = $util.emptyArray; - + BundleElement.prototype.namedQuery = null; + /** - * DescriptorProto extensionRange. - * @member {Array.} extensionRange - * @memberof google.protobuf.DescriptorProto + * BundleElement documentMetadata. + * @member {firestore.IBundledDocumentMetadata|null|undefined} documentMetadata + * @memberof firestore.BundleElement * @instance */ - DescriptorProto.prototype.extensionRange = $util.emptyArray; - + BundleElement.prototype.documentMetadata = null; + /** - * DescriptorProto oneofDecl. - * @member {Array.} oneofDecl - * @memberof google.protobuf.DescriptorProto + * BundleElement document. + * @member {google.firestore.v1.IDocument|null|undefined} document + * @memberof firestore.BundleElement * @instance */ - DescriptorProto.prototype.oneofDecl = $util.emptyArray; - + BundleElement.prototype.document = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + /** - * DescriptorProto options. - * @member {google.protobuf.IMessageOptions|null|undefined} options - * @memberof google.protobuf.DescriptorProto + * BundleElement elementType. + * @member {"metadata"|"namedQuery"|"documentMetadata"|"document"|undefined} elementType + * @memberof firestore.BundleElement * @instance */ - DescriptorProto.prototype.options = null; - + Object.defineProperty(BundleElement.prototype, "elementType", { + get: $util.oneOfGetter($oneOfFields = ["metadata", "namedQuery", "documentMetadata", "document"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a BundleElement message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof firestore.BundleElement + * @static + * @param {Object.} object Plain object + * @returns {firestore.BundleElement} BundleElement + */ + BundleElement.fromObject = function fromObject(object) { + if (object instanceof $root.firestore.BundleElement) + return object; + var message = new $root.firestore.BundleElement(); + if (object.metadata != null) { + if (typeof object.metadata !== "object") + throw TypeError(".firestore.BundleElement.metadata: object expected"); + message.metadata = $root.firestore.BundleMetadata.fromObject(object.metadata); + } + if (object.namedQuery != null) { + if (typeof object.namedQuery !== "object") + throw TypeError(".firestore.BundleElement.namedQuery: object expected"); + message.namedQuery = $root.firestore.NamedQuery.fromObject(object.namedQuery); + } + if (object.documentMetadata != null) { + if (typeof object.documentMetadata !== "object") + throw TypeError(".firestore.BundleElement.documentMetadata: object expected"); + message.documentMetadata = $root.firestore.BundledDocumentMetadata.fromObject(object.documentMetadata); + } + if (object.document != null) { + if (typeof object.document !== "object") + throw TypeError(".firestore.BundleElement.document: object expected"); + message.document = $root.google.firestore.v1.Document.fromObject(object.document); + } + return message; + }; + + /** + * Creates a plain object from a BundleElement message. Also converts values to other types if specified. + * @function toObject + * @memberof firestore.BundleElement + * @static + * @param {firestore.BundleElement} message BundleElement + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BundleElement.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.metadata != null && message.hasOwnProperty("metadata")) { + object.metadata = $root.firestore.BundleMetadata.toObject(message.metadata, options); + if (options.oneofs) + object.elementType = "metadata"; + } + if (message.namedQuery != null && message.hasOwnProperty("namedQuery")) { + object.namedQuery = $root.firestore.NamedQuery.toObject(message.namedQuery, options); + if (options.oneofs) + object.elementType = "namedQuery"; + } + if (message.documentMetadata != null && message.hasOwnProperty("documentMetadata")) { + object.documentMetadata = $root.firestore.BundledDocumentMetadata.toObject(message.documentMetadata, options); + if (options.oneofs) + object.elementType = "documentMetadata"; + } + if (message.document != null && message.hasOwnProperty("document")) { + object.document = $root.google.firestore.v1.Document.toObject(message.document, options); + if (options.oneofs) + object.elementType = "document"; + } + return object; + }; + /** - * DescriptorProto reservedRange. - * @member {Array.} reservedRange - * @memberof google.protobuf.DescriptorProto + * Converts this BundleElement to JSON. + * @function toJSON + * @memberof firestore.BundleElement * @instance + * @returns {Object.} JSON object */ - DescriptorProto.prototype.reservedRange = $util.emptyArray; - + BundleElement.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BundleElement; + })(); + + return firestore; + })(); + + $root.google = (function() { + + /** + * Namespace google. + * @exports google + * @namespace + */ + var google = {}; + + google.protobuf = (function() { + /** - * DescriptorProto reservedName. - * @member {Array.} reservedName - * @memberof google.protobuf.DescriptorProto - * @instance + * Namespace protobuf. + * @memberof google + * @namespace */ - DescriptorProto.prototype.reservedName = $util.emptyArray; - - DescriptorProto.ExtensionRange = (function() { - + var protobuf = {}; + + protobuf.Timestamp = (function() { + /** - * Properties of an ExtensionRange. - * @memberof google.protobuf.DescriptorProto - * @interface IExtensionRange - * @property {number|null} [start] ExtensionRange start - * @property {number|null} [end] ExtensionRange end + * Properties of a Timestamp. + * @memberof google.protobuf + * @interface ITimestamp + * @property {number|string|null} [seconds] Timestamp seconds + * @property {number|null} [nanos] Timestamp nanos */ - + /** - * Constructs a new ExtensionRange. - * @memberof google.protobuf.DescriptorProto - * @classdesc Represents an ExtensionRange. - * @implements IExtensionRange + * Constructs a new Timestamp. + * @memberof google.protobuf + * @classdesc Represents a Timestamp. + * @implements ITimestamp * @constructor - * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set + * @param {google.protobuf.ITimestamp=} [properties] Properties to set */ - function ExtensionRange(properties) { + function Timestamp(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * ExtensionRange start. - * @member {number} start - * @memberof google.protobuf.DescriptorProto.ExtensionRange + * Timestamp seconds. + * @member {number|string} seconds + * @memberof google.protobuf.Timestamp * @instance */ - ExtensionRange.prototype.start = 0; - + Timestamp.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + /** - * ExtensionRange end. - * @member {number} end - * @memberof google.protobuf.DescriptorProto.ExtensionRange + * Timestamp nanos. + * @member {number} nanos + * @memberof google.protobuf.Timestamp * @instance */ - ExtensionRange.prototype.end = 0; - - return ExtensionRange; + Timestamp.prototype.nanos = 0; + + /** + * Creates a Timestamp message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Timestamp + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Timestamp} Timestamp + */ + Timestamp.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Timestamp) + return object; + var message = new $root.google.protobuf.Timestamp(); + if (object.seconds != null) + if ($util.Long) + (message.seconds = $util.Long.fromValue(object.seconds)).unsigned = false; + else if (typeof object.seconds === "string") + message.seconds = parseInt(object.seconds, 10); + else if (typeof object.seconds === "number") + message.seconds = object.seconds; + else if (typeof object.seconds === "object") + message.seconds = new $util.LongBits(object.seconds.low >>> 0, object.seconds.high >>> 0).toNumber(); + if (object.nanos != null) + message.nanos = object.nanos | 0; + return message; + }; + + /** + * Creates a plain object from a Timestamp message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.Timestamp} message Timestamp + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Timestamp.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.seconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.seconds = options.longs === String ? "0" : 0; + object.nanos = 0; + } + if (message.seconds != null && message.hasOwnProperty("seconds")) + if (typeof message.seconds === "number") + object.seconds = options.longs === String ? String(message.seconds) : message.seconds; + else + object.seconds = options.longs === String ? $util.Long.prototype.toString.call(message.seconds) : options.longs === Number ? new $util.LongBits(message.seconds.low >>> 0, message.seconds.high >>> 0).toNumber() : message.seconds; + if (message.nanos != null && message.hasOwnProperty("nanos")) + object.nanos = message.nanos; + return object; + }; + + /** + * Converts this Timestamp to JSON. + * @function toJSON + * @memberof google.protobuf.Timestamp + * @instance + * @returns {Object.} JSON object + */ + Timestamp.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Timestamp; })(); - - DescriptorProto.ReservedRange = (function() { - + + protobuf.FileDescriptorSet = (function() { + /** - * Properties of a ReservedRange. - * @memberof google.protobuf.DescriptorProto - * @interface IReservedRange - * @property {number|null} [start] ReservedRange start - * @property {number|null} [end] ReservedRange end + * Properties of a FileDescriptorSet. + * @memberof google.protobuf + * @interface IFileDescriptorSet + * @property {Array.|null} [file] FileDescriptorSet file */ - + /** - * Constructs a new ReservedRange. - * @memberof google.protobuf.DescriptorProto - * @classdesc Represents a ReservedRange. - * @implements IReservedRange + * Constructs a new FileDescriptorSet. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorSet. + * @implements IFileDescriptorSet * @constructor - * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set */ - function ReservedRange(properties) { + function FileDescriptorSet(properties) { + this.file = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * ReservedRange start. - * @member {number} start - * @memberof google.protobuf.DescriptorProto.ReservedRange + * FileDescriptorSet file. + * @member {Array.} file + * @memberof google.protobuf.FileDescriptorSet * @instance */ - ReservedRange.prototype.start = 0; - + FileDescriptorSet.prototype.file = $util.emptyArray; + + /** + * Creates a FileDescriptorSet message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + */ + FileDescriptorSet.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileDescriptorSet) + return object; + var message = new $root.google.protobuf.FileDescriptorSet(); + if (object.file) { + if (!Array.isArray(object.file)) + throw TypeError(".google.protobuf.FileDescriptorSet.file: array expected"); + message.file = []; + for (var i = 0; i < object.file.length; ++i) { + if (typeof object.file[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorSet.file: object expected"); + message.file[i] = $root.google.protobuf.FileDescriptorProto.fromObject(object.file[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a FileDescriptorSet message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.FileDescriptorSet} message FileDescriptorSet + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileDescriptorSet.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.file = []; + if (message.file && message.file.length) { + object.file = []; + for (var j = 0; j < message.file.length; ++j) + object.file[j] = $root.google.protobuf.FileDescriptorProto.toObject(message.file[j], options); + } + return object; + }; + /** - * ReservedRange end. - * @member {number} end - * @memberof google.protobuf.DescriptorProto.ReservedRange + * Converts this FileDescriptorSet to JSON. + * @function toJSON + * @memberof google.protobuf.FileDescriptorSet * @instance + * @returns {Object.} JSON object */ - ReservedRange.prototype.end = 0; - - return ReservedRange; - })(); - - return DescriptorProto; - })(); - - protobuf.FieldDescriptorProto = (function() { - - /** - * Properties of a FieldDescriptorProto. - * @memberof google.protobuf - * @interface IFieldDescriptorProto - * @property {string|null} [name] FieldDescriptorProto name - * @property {number|null} [number] FieldDescriptorProto number - * @property {google.protobuf.FieldDescriptorProto.Label|null} [label] FieldDescriptorProto label - * @property {google.protobuf.FieldDescriptorProto.Type|null} [type] FieldDescriptorProto type - * @property {string|null} [typeName] FieldDescriptorProto typeName - * @property {string|null} [extendee] FieldDescriptorProto extendee - * @property {string|null} [defaultValue] FieldDescriptorProto defaultValue - * @property {number|null} [oneofIndex] FieldDescriptorProto oneofIndex - * @property {string|null} [jsonName] FieldDescriptorProto jsonName - * @property {google.protobuf.IFieldOptions|null} [options] FieldDescriptorProto options - */ - - /** - * Constructs a new FieldDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents a FieldDescriptorProto. - * @implements IFieldDescriptorProto - * @constructor - * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set - */ - function FieldDescriptorProto(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FieldDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.name = ""; - - /** - * FieldDescriptorProto number. - * @member {number} number - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.number = 0; - - /** - * FieldDescriptorProto label. - * @member {google.protobuf.FieldDescriptorProto.Label} label - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.label = 1; - - /** - * FieldDescriptorProto type. - * @member {google.protobuf.FieldDescriptorProto.Type} type - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.type = 1; - - /** - * FieldDescriptorProto typeName. - * @member {string} typeName - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.typeName = ""; - - /** - * FieldDescriptorProto extendee. - * @member {string} extendee - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.extendee = ""; - - /** - * FieldDescriptorProto defaultValue. - * @member {string} defaultValue - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.defaultValue = ""; - - /** - * FieldDescriptorProto oneofIndex. - * @member {number} oneofIndex - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.oneofIndex = 0; - - /** - * FieldDescriptorProto jsonName. - * @member {string} jsonName - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.jsonName = ""; - - /** - * FieldDescriptorProto options. - * @member {google.protobuf.IFieldOptions|null|undefined} options - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.options = null; - - /** - * Type enum. - * @name google.protobuf.FieldDescriptorProto.Type - * @enum {number} - * @property {string} TYPE_DOUBLE=TYPE_DOUBLE TYPE_DOUBLE value - * @property {string} TYPE_FLOAT=TYPE_FLOAT TYPE_FLOAT value - * @property {string} TYPE_INT64=TYPE_INT64 TYPE_INT64 value - * @property {string} TYPE_UINT64=TYPE_UINT64 TYPE_UINT64 value - * @property {string} TYPE_INT32=TYPE_INT32 TYPE_INT32 value - * @property {string} TYPE_FIXED64=TYPE_FIXED64 TYPE_FIXED64 value - * @property {string} TYPE_FIXED32=TYPE_FIXED32 TYPE_FIXED32 value - * @property {string} TYPE_BOOL=TYPE_BOOL TYPE_BOOL value - * @property {string} TYPE_STRING=TYPE_STRING TYPE_STRING value - * @property {string} TYPE_GROUP=TYPE_GROUP TYPE_GROUP value - * @property {string} TYPE_MESSAGE=TYPE_MESSAGE TYPE_MESSAGE value - * @property {string} TYPE_BYTES=TYPE_BYTES TYPE_BYTES value - * @property {string} TYPE_UINT32=TYPE_UINT32 TYPE_UINT32 value - * @property {string} TYPE_ENUM=TYPE_ENUM TYPE_ENUM value - * @property {string} TYPE_SFIXED32=TYPE_SFIXED32 TYPE_SFIXED32 value - * @property {string} TYPE_SFIXED64=TYPE_SFIXED64 TYPE_SFIXED64 value - * @property {string} TYPE_SINT32=TYPE_SINT32 TYPE_SINT32 value - * @property {string} TYPE_SINT64=TYPE_SINT64 TYPE_SINT64 value - */ - FieldDescriptorProto.Type = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[1] = "TYPE_DOUBLE"] = "TYPE_DOUBLE"; - values[valuesById[2] = "TYPE_FLOAT"] = "TYPE_FLOAT"; - values[valuesById[3] = "TYPE_INT64"] = "TYPE_INT64"; - values[valuesById[4] = "TYPE_UINT64"] = "TYPE_UINT64"; - values[valuesById[5] = "TYPE_INT32"] = "TYPE_INT32"; - values[valuesById[6] = "TYPE_FIXED64"] = "TYPE_FIXED64"; - values[valuesById[7] = "TYPE_FIXED32"] = "TYPE_FIXED32"; - values[valuesById[8] = "TYPE_BOOL"] = "TYPE_BOOL"; - values[valuesById[9] = "TYPE_STRING"] = "TYPE_STRING"; - values[valuesById[10] = "TYPE_GROUP"] = "TYPE_GROUP"; - values[valuesById[11] = "TYPE_MESSAGE"] = "TYPE_MESSAGE"; - values[valuesById[12] = "TYPE_BYTES"] = "TYPE_BYTES"; - values[valuesById[13] = "TYPE_UINT32"] = "TYPE_UINT32"; - values[valuesById[14] = "TYPE_ENUM"] = "TYPE_ENUM"; - values[valuesById[15] = "TYPE_SFIXED32"] = "TYPE_SFIXED32"; - values[valuesById[16] = "TYPE_SFIXED64"] = "TYPE_SFIXED64"; - values[valuesById[17] = "TYPE_SINT32"] = "TYPE_SINT32"; - values[valuesById[18] = "TYPE_SINT64"] = "TYPE_SINT64"; - return values; - })(); - - /** - * Label enum. - * @name google.protobuf.FieldDescriptorProto.Label - * @enum {number} - * @property {string} LABEL_OPTIONAL=LABEL_OPTIONAL LABEL_OPTIONAL value - * @property {string} LABEL_REQUIRED=LABEL_REQUIRED LABEL_REQUIRED value - * @property {string} LABEL_REPEATED=LABEL_REPEATED LABEL_REPEATED value - */ - FieldDescriptorProto.Label = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[1] = "LABEL_OPTIONAL"] = "LABEL_OPTIONAL"; - values[valuesById[2] = "LABEL_REQUIRED"] = "LABEL_REQUIRED"; - values[valuesById[3] = "LABEL_REPEATED"] = "LABEL_REPEATED"; - return values; + FileDescriptorSet.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FileDescriptorSet; })(); - - return FieldDescriptorProto; - })(); - - protobuf.OneofDescriptorProto = (function() { - - /** - * Properties of an OneofDescriptorProto. - * @memberof google.protobuf - * @interface IOneofDescriptorProto - * @property {string|null} [name] OneofDescriptorProto name - * @property {google.protobuf.IOneofOptions|null} [options] OneofDescriptorProto options - */ - - /** - * Constructs a new OneofDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents an OneofDescriptorProto. - * @implements IOneofDescriptorProto - * @constructor - * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set - */ - function OneofDescriptorProto(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * OneofDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.OneofDescriptorProto - * @instance - */ - OneofDescriptorProto.prototype.name = ""; - - /** - * OneofDescriptorProto options. - * @member {google.protobuf.IOneofOptions|null|undefined} options - * @memberof google.protobuf.OneofDescriptorProto - * @instance - */ - OneofDescriptorProto.prototype.options = null; - - return OneofDescriptorProto; - })(); - - protobuf.EnumDescriptorProto = (function() { - - /** - * Properties of an EnumDescriptorProto. - * @memberof google.protobuf - * @interface IEnumDescriptorProto - * @property {string|null} [name] EnumDescriptorProto name - * @property {Array.|null} [value] EnumDescriptorProto value - * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options - */ - - /** - * Constructs a new EnumDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents an EnumDescriptorProto. - * @implements IEnumDescriptorProto - * @constructor - * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set - */ - function EnumDescriptorProto(properties) { - this.value = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EnumDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.EnumDescriptorProto - * @instance - */ - EnumDescriptorProto.prototype.name = ""; - - /** - * EnumDescriptorProto value. - * @member {Array.} value - * @memberof google.protobuf.EnumDescriptorProto - * @instance - */ - EnumDescriptorProto.prototype.value = $util.emptyArray; - - /** - * EnumDescriptorProto options. - * @member {google.protobuf.IEnumOptions|null|undefined} options - * @memberof google.protobuf.EnumDescriptorProto - * @instance - */ - EnumDescriptorProto.prototype.options = null; - - return EnumDescriptorProto; - })(); - - protobuf.EnumValueDescriptorProto = (function() { - - /** - * Properties of an EnumValueDescriptorProto. - * @memberof google.protobuf - * @interface IEnumValueDescriptorProto - * @property {string|null} [name] EnumValueDescriptorProto name - * @property {number|null} [number] EnumValueDescriptorProto number - * @property {google.protobuf.IEnumValueOptions|null} [options] EnumValueDescriptorProto options - */ - - /** - * Constructs a new EnumValueDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents an EnumValueDescriptorProto. - * @implements IEnumValueDescriptorProto - * @constructor - * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set - */ - function EnumValueDescriptorProto(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EnumValueDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.EnumValueDescriptorProto - * @instance - */ - EnumValueDescriptorProto.prototype.name = ""; - - /** - * EnumValueDescriptorProto number. - * @member {number} number - * @memberof google.protobuf.EnumValueDescriptorProto - * @instance - */ - EnumValueDescriptorProto.prototype.number = 0; - - /** - * EnumValueDescriptorProto options. - * @member {google.protobuf.IEnumValueOptions|null|undefined} options - * @memberof google.protobuf.EnumValueDescriptorProto - * @instance - */ - EnumValueDescriptorProto.prototype.options = null; - - return EnumValueDescriptorProto; - })(); - - protobuf.ServiceDescriptorProto = (function() { - - /** - * Properties of a ServiceDescriptorProto. - * @memberof google.protobuf - * @interface IServiceDescriptorProto - * @property {string|null} [name] ServiceDescriptorProto name - * @property {Array.|null} [method] ServiceDescriptorProto method - * @property {google.protobuf.IServiceOptions|null} [options] ServiceDescriptorProto options - */ - - /** - * Constructs a new ServiceDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents a ServiceDescriptorProto. - * @implements IServiceDescriptorProto - * @constructor - * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set - */ - function ServiceDescriptorProto(properties) { - this.method = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ServiceDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.ServiceDescriptorProto - * @instance - */ - ServiceDescriptorProto.prototype.name = ""; - - /** - * ServiceDescriptorProto method. - * @member {Array.} method - * @memberof google.protobuf.ServiceDescriptorProto - * @instance - */ - ServiceDescriptorProto.prototype.method = $util.emptyArray; - - /** - * ServiceDescriptorProto options. - * @member {google.protobuf.IServiceOptions|null|undefined} options - * @memberof google.protobuf.ServiceDescriptorProto - * @instance - */ - ServiceDescriptorProto.prototype.options = null; - - return ServiceDescriptorProto; - })(); - - protobuf.MethodDescriptorProto = (function() { - - /** - * Properties of a MethodDescriptorProto. - * @memberof google.protobuf - * @interface IMethodDescriptorProto - * @property {string|null} [name] MethodDescriptorProto name - * @property {string|null} [inputType] MethodDescriptorProto inputType - * @property {string|null} [outputType] MethodDescriptorProto outputType - * @property {google.protobuf.IMethodOptions|null} [options] MethodDescriptorProto options - * @property {boolean|null} [clientStreaming] MethodDescriptorProto clientStreaming - * @property {boolean|null} [serverStreaming] MethodDescriptorProto serverStreaming - */ - - /** - * Constructs a new MethodDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents a MethodDescriptorProto. - * @implements IMethodDescriptorProto - * @constructor - * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set - */ - function MethodDescriptorProto(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * MethodDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.name = ""; - - /** - * MethodDescriptorProto inputType. - * @member {string} inputType - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.inputType = ""; - - /** - * MethodDescriptorProto outputType. - * @member {string} outputType - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.outputType = ""; - - /** - * MethodDescriptorProto options. - * @member {google.protobuf.IMethodOptions|null|undefined} options - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.options = null; - - /** - * MethodDescriptorProto clientStreaming. - * @member {boolean} clientStreaming - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.clientStreaming = false; - - /** - * MethodDescriptorProto serverStreaming. - * @member {boolean} serverStreaming - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.serverStreaming = false; - - return MethodDescriptorProto; - })(); - - protobuf.FileOptions = (function() { - - /** - * Properties of a FileOptions. - * @memberof google.protobuf - * @interface IFileOptions - * @property {string|null} [javaPackage] FileOptions javaPackage - * @property {string|null} [javaOuterClassname] FileOptions javaOuterClassname - * @property {boolean|null} [javaMultipleFiles] FileOptions javaMultipleFiles - * @property {boolean|null} [javaGenerateEqualsAndHash] FileOptions javaGenerateEqualsAndHash - * @property {boolean|null} [javaStringCheckUtf8] FileOptions javaStringCheckUtf8 - * @property {google.protobuf.FileOptions.OptimizeMode|null} [optimizeFor] FileOptions optimizeFor - * @property {string|null} [goPackage] FileOptions goPackage - * @property {boolean|null} [ccGenericServices] FileOptions ccGenericServices - * @property {boolean|null} [javaGenericServices] FileOptions javaGenericServices - * @property {boolean|null} [pyGenericServices] FileOptions pyGenericServices - * @property {boolean|null} [deprecated] FileOptions deprecated - * @property {boolean|null} [ccEnableArenas] FileOptions ccEnableArenas - * @property {string|null} [objcClassPrefix] FileOptions objcClassPrefix - * @property {string|null} [csharpNamespace] FileOptions csharpNamespace - * @property {Array.|null} [uninterpretedOption] FileOptions uninterpretedOption - * @property {Array.|null} [".google.api.resourceDefinition"] FileOptions .google.api.resourceDefinition - */ - - /** - * Constructs a new FileOptions. - * @memberof google.protobuf - * @classdesc Represents a FileOptions. - * @implements IFileOptions - * @constructor - * @param {google.protobuf.IFileOptions=} [properties] Properties to set - */ - function FileOptions(properties) { - this.uninterpretedOption = []; - this[".google.api.resourceDefinition"] = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FileOptions javaPackage. - * @member {string} javaPackage - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaPackage = ""; - - /** - * FileOptions javaOuterClassname. - * @member {string} javaOuterClassname - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaOuterClassname = ""; - - /** - * FileOptions javaMultipleFiles. - * @member {boolean} javaMultipleFiles - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaMultipleFiles = false; - - /** - * FileOptions javaGenerateEqualsAndHash. - * @member {boolean} javaGenerateEqualsAndHash - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaGenerateEqualsAndHash = false; - - /** - * FileOptions javaStringCheckUtf8. - * @member {boolean} javaStringCheckUtf8 - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaStringCheckUtf8 = false; - - /** - * FileOptions optimizeFor. - * @member {google.protobuf.FileOptions.OptimizeMode} optimizeFor - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.optimizeFor = 1; - - /** - * FileOptions goPackage. - * @member {string} goPackage - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.goPackage = ""; - - /** - * FileOptions ccGenericServices. - * @member {boolean} ccGenericServices - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.ccGenericServices = false; - - /** - * FileOptions javaGenericServices. - * @member {boolean} javaGenericServices - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaGenericServices = false; - - /** - * FileOptions pyGenericServices. - * @member {boolean} pyGenericServices - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.pyGenericServices = false; - - /** - * FileOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.deprecated = false; - - /** - * FileOptions ccEnableArenas. - * @member {boolean} ccEnableArenas - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.ccEnableArenas = false; - - /** - * FileOptions objcClassPrefix. - * @member {string} objcClassPrefix - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.objcClassPrefix = ""; - - /** - * FileOptions csharpNamespace. - * @member {string} csharpNamespace - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.csharpNamespace = ""; - - /** - * FileOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.uninterpretedOption = $util.emptyArray; - - /** - * FileOptions .google.api.resourceDefinition. - * @member {Array.} .google.api.resourceDefinition - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype[".google.api.resourceDefinition"] = $util.emptyArray; - - /** - * OptimizeMode enum. - * @name google.protobuf.FileOptions.OptimizeMode - * @enum {number} - * @property {string} SPEED=SPEED SPEED value - * @property {string} CODE_SIZE=CODE_SIZE CODE_SIZE value - * @property {string} LITE_RUNTIME=LITE_RUNTIME LITE_RUNTIME value - */ - FileOptions.OptimizeMode = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[1] = "SPEED"] = "SPEED"; - values[valuesById[2] = "CODE_SIZE"] = "CODE_SIZE"; - values[valuesById[3] = "LITE_RUNTIME"] = "LITE_RUNTIME"; - return values; - })(); - - return FileOptions; - })(); - - protobuf.MessageOptions = (function() { - - /** - * Properties of a MessageOptions. - * @memberof google.protobuf - * @interface IMessageOptions - * @property {boolean|null} [messageSetWireFormat] MessageOptions messageSetWireFormat - * @property {boolean|null} [noStandardDescriptorAccessor] MessageOptions noStandardDescriptorAccessor - * @property {boolean|null} [deprecated] MessageOptions deprecated - * @property {boolean|null} [mapEntry] MessageOptions mapEntry - * @property {Array.|null} [uninterpretedOption] MessageOptions uninterpretedOption - * @property {google.api.IResourceDescriptor|null} [".google.api.resource"] MessageOptions .google.api.resource - */ - - /** - * Constructs a new MessageOptions. - * @memberof google.protobuf - * @classdesc Represents a MessageOptions. - * @implements IMessageOptions - * @constructor - * @param {google.protobuf.IMessageOptions=} [properties] Properties to set - */ - function MessageOptions(properties) { - this.uninterpretedOption = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * MessageOptions messageSetWireFormat. - * @member {boolean} messageSetWireFormat - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype.messageSetWireFormat = false; - - /** - * MessageOptions noStandardDescriptorAccessor. - * @member {boolean} noStandardDescriptorAccessor - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype.noStandardDescriptorAccessor = false; - - /** - * MessageOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype.deprecated = false; - - /** - * MessageOptions mapEntry. - * @member {boolean} mapEntry - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype.mapEntry = false; - - /** - * MessageOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype.uninterpretedOption = $util.emptyArray; - - /** - * MessageOptions .google.api.resource. - * @member {google.api.IResourceDescriptor|null|undefined} .google.api.resource - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype[".google.api.resource"] = null; - - return MessageOptions; - })(); - - protobuf.FieldOptions = (function() { - - /** - * Properties of a FieldOptions. - * @memberof google.protobuf - * @interface IFieldOptions - * @property {google.protobuf.FieldOptions.CType|null} [ctype] FieldOptions ctype - * @property {boolean|null} [packed] FieldOptions packed - * @property {google.protobuf.FieldOptions.JSType|null} [jstype] FieldOptions jstype - * @property {boolean|null} [lazy] FieldOptions lazy - * @property {boolean|null} [deprecated] FieldOptions deprecated - * @property {boolean|null} [weak] FieldOptions weak - * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption - * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior - * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference - */ - - /** - * Constructs a new FieldOptions. - * @memberof google.protobuf - * @classdesc Represents a FieldOptions. - * @implements IFieldOptions - * @constructor - * @param {google.protobuf.IFieldOptions=} [properties] Properties to set - */ - function FieldOptions(properties) { - this.uninterpretedOption = []; - this[".google.api.fieldBehavior"] = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FieldOptions ctype. - * @member {google.protobuf.FieldOptions.CType} ctype - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.ctype = 0; - - /** - * FieldOptions packed. - * @member {boolean} packed - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.packed = false; - - /** - * FieldOptions jstype. - * @member {google.protobuf.FieldOptions.JSType} jstype - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.jstype = 0; - - /** - * FieldOptions lazy. - * @member {boolean} lazy - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.lazy = false; - - /** - * FieldOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.deprecated = false; - - /** - * FieldOptions weak. - * @member {boolean} weak - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.weak = false; - - /** - * FieldOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.uninterpretedOption = $util.emptyArray; - - /** - * FieldOptions .google.api.fieldBehavior. - * @member {Array.} .google.api.fieldBehavior - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype[".google.api.fieldBehavior"] = $util.emptyArray; - - /** - * FieldOptions .google.api.resourceReference. - * @member {google.api.IResourceReference|null|undefined} .google.api.resourceReference - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype[".google.api.resourceReference"] = null; - - /** - * CType enum. - * @name google.protobuf.FieldOptions.CType - * @enum {number} - * @property {string} STRING=STRING STRING value - * @property {string} CORD=CORD CORD value - * @property {string} STRING_PIECE=STRING_PIECE STRING_PIECE value - */ - FieldOptions.CType = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "STRING"] = "STRING"; - values[valuesById[1] = "CORD"] = "CORD"; - values[valuesById[2] = "STRING_PIECE"] = "STRING_PIECE"; - return values; - })(); - - /** - * JSType enum. - * @name google.protobuf.FieldOptions.JSType - * @enum {number} - * @property {string} JS_NORMAL=JS_NORMAL JS_NORMAL value - * @property {string} JS_STRING=JS_STRING JS_STRING value - * @property {string} JS_NUMBER=JS_NUMBER JS_NUMBER value - */ - FieldOptions.JSType = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "JS_NORMAL"] = "JS_NORMAL"; - values[valuesById[1] = "JS_STRING"] = "JS_STRING"; - values[valuesById[2] = "JS_NUMBER"] = "JS_NUMBER"; - return values; - })(); - - return FieldOptions; - })(); - - protobuf.OneofOptions = (function() { - - /** - * Properties of an OneofOptions. - * @memberof google.protobuf - * @interface IOneofOptions - * @property {Array.|null} [uninterpretedOption] OneofOptions uninterpretedOption - */ - - /** - * Constructs a new OneofOptions. - * @memberof google.protobuf - * @classdesc Represents an OneofOptions. - * @implements IOneofOptions - * @constructor - * @param {google.protobuf.IOneofOptions=} [properties] Properties to set - */ - function OneofOptions(properties) { - this.uninterpretedOption = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * OneofOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.OneofOptions - * @instance - */ - OneofOptions.prototype.uninterpretedOption = $util.emptyArray; - - return OneofOptions; - })(); - - protobuf.EnumOptions = (function() { - - /** - * Properties of an EnumOptions. - * @memberof google.protobuf - * @interface IEnumOptions - * @property {boolean|null} [allowAlias] EnumOptions allowAlias - * @property {boolean|null} [deprecated] EnumOptions deprecated - * @property {Array.|null} [uninterpretedOption] EnumOptions uninterpretedOption - */ - - /** - * Constructs a new EnumOptions. - * @memberof google.protobuf - * @classdesc Represents an EnumOptions. - * @implements IEnumOptions - * @constructor - * @param {google.protobuf.IEnumOptions=} [properties] Properties to set - */ - function EnumOptions(properties) { - this.uninterpretedOption = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EnumOptions allowAlias. - * @member {boolean} allowAlias - * @memberof google.protobuf.EnumOptions - * @instance - */ - EnumOptions.prototype.allowAlias = false; - - /** - * EnumOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.EnumOptions - * @instance - */ - EnumOptions.prototype.deprecated = false; - - /** - * EnumOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.EnumOptions - * @instance - */ - EnumOptions.prototype.uninterpretedOption = $util.emptyArray; - - return EnumOptions; - })(); - - protobuf.EnumValueOptions = (function() { - - /** - * Properties of an EnumValueOptions. - * @memberof google.protobuf - * @interface IEnumValueOptions - * @property {boolean|null} [deprecated] EnumValueOptions deprecated - * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption - */ - - /** - * Constructs a new EnumValueOptions. - * @memberof google.protobuf - * @classdesc Represents an EnumValueOptions. - * @implements IEnumValueOptions - * @constructor - * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set - */ - function EnumValueOptions(properties) { - this.uninterpretedOption = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EnumValueOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.EnumValueOptions - * @instance - */ - EnumValueOptions.prototype.deprecated = false; - - /** - * EnumValueOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.EnumValueOptions - * @instance - */ - EnumValueOptions.prototype.uninterpretedOption = $util.emptyArray; - - return EnumValueOptions; - })(); - - protobuf.ServiceOptions = (function() { - - /** - * Properties of a ServiceOptions. - * @memberof google.protobuf - * @interface IServiceOptions - * @property {boolean|null} [deprecated] ServiceOptions deprecated - * @property {Array.|null} [uninterpretedOption] ServiceOptions uninterpretedOption - * @property {string|null} [".google.api.defaultHost"] ServiceOptions .google.api.defaultHost - * @property {string|null} [".google.api.oauthScopes"] ServiceOptions .google.api.oauthScopes - */ - - /** - * Constructs a new ServiceOptions. - * @memberof google.protobuf - * @classdesc Represents a ServiceOptions. - * @implements IServiceOptions - * @constructor - * @param {google.protobuf.IServiceOptions=} [properties] Properties to set - */ - function ServiceOptions(properties) { - this.uninterpretedOption = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ServiceOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.ServiceOptions - * @instance - */ - ServiceOptions.prototype.deprecated = false; - - /** - * ServiceOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.ServiceOptions - * @instance - */ - ServiceOptions.prototype.uninterpretedOption = $util.emptyArray; - - /** - * ServiceOptions .google.api.defaultHost. - * @member {string} .google.api.defaultHost - * @memberof google.protobuf.ServiceOptions - * @instance - */ - ServiceOptions.prototype[".google.api.defaultHost"] = ""; - - /** - * ServiceOptions .google.api.oauthScopes. - * @member {string} .google.api.oauthScopes - * @memberof google.protobuf.ServiceOptions - * @instance - */ - ServiceOptions.prototype[".google.api.oauthScopes"] = ""; - - return ServiceOptions; - })(); - - protobuf.MethodOptions = (function() { - - /** - * Properties of a MethodOptions. - * @memberof google.protobuf - * @interface IMethodOptions - * @property {boolean|null} [deprecated] MethodOptions deprecated - * @property {Array.|null} [uninterpretedOption] MethodOptions uninterpretedOption - * @property {google.api.IHttpRule|null} [".google.api.http"] MethodOptions .google.api.http - * @property {Array.|null} [".google.api.methodSignature"] MethodOptions .google.api.methodSignature - * @property {google.longrunning.IOperationInfo|null} [".google.longrunning.operationInfo"] MethodOptions .google.longrunning.operationInfo - */ - - /** - * Constructs a new MethodOptions. - * @memberof google.protobuf - * @classdesc Represents a MethodOptions. - * @implements IMethodOptions - * @constructor - * @param {google.protobuf.IMethodOptions=} [properties] Properties to set - */ - function MethodOptions(properties) { - this.uninterpretedOption = []; - this[".google.api.methodSignature"] = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * MethodOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.MethodOptions - * @instance - */ - MethodOptions.prototype.deprecated = false; - - /** - * MethodOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.MethodOptions - * @instance - */ - MethodOptions.prototype.uninterpretedOption = $util.emptyArray; - - /** - * MethodOptions .google.api.http. - * @member {google.api.IHttpRule|null|undefined} .google.api.http - * @memberof google.protobuf.MethodOptions - * @instance - */ - MethodOptions.prototype[".google.api.http"] = null; - - /** - * MethodOptions .google.api.methodSignature. - * @member {Array.} .google.api.methodSignature - * @memberof google.protobuf.MethodOptions - * @instance - */ - MethodOptions.prototype[".google.api.methodSignature"] = $util.emptyArray; - - /** - * MethodOptions .google.longrunning.operationInfo. - * @member {google.longrunning.IOperationInfo|null|undefined} .google.longrunning.operationInfo - * @memberof google.protobuf.MethodOptions - * @instance - */ - MethodOptions.prototype[".google.longrunning.operationInfo"] = null; - - return MethodOptions; - })(); - - protobuf.UninterpretedOption = (function() { - - /** - * Properties of an UninterpretedOption. - * @memberof google.protobuf - * @interface IUninterpretedOption - * @property {Array.|null} [name] UninterpretedOption name - * @property {string|null} [identifierValue] UninterpretedOption identifierValue - * @property {number|null} [positiveIntValue] UninterpretedOption positiveIntValue - * @property {number|null} [negativeIntValue] UninterpretedOption negativeIntValue - * @property {number|null} [doubleValue] UninterpretedOption doubleValue - * @property {Uint8Array|null} [stringValue] UninterpretedOption stringValue - * @property {string|null} [aggregateValue] UninterpretedOption aggregateValue - */ - - /** - * Constructs a new UninterpretedOption. - * @memberof google.protobuf - * @classdesc Represents an UninterpretedOption. - * @implements IUninterpretedOption - * @constructor - * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set - */ - function UninterpretedOption(properties) { - this.name = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * UninterpretedOption name. - * @member {Array.} name - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.name = $util.emptyArray; - - /** - * UninterpretedOption identifierValue. - * @member {string} identifierValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.identifierValue = ""; - - /** - * UninterpretedOption positiveIntValue. - * @member {number} positiveIntValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.positiveIntValue = $util.Long ? $util.Long.fromBits(0,0,true) : 0; - - /** - * UninterpretedOption negativeIntValue. - * @member {number} negativeIntValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.negativeIntValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * UninterpretedOption doubleValue. - * @member {number} doubleValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.doubleValue = 0; - - /** - * UninterpretedOption stringValue. - * @member {Uint8Array} stringValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.stringValue = $util.newBuffer([]); - - /** - * UninterpretedOption aggregateValue. - * @member {string} aggregateValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.aggregateValue = ""; - - UninterpretedOption.NamePart = (function() { - - /** - * Properties of a NamePart. - * @memberof google.protobuf.UninterpretedOption - * @interface INamePart - * @property {string} namePart NamePart namePart - * @property {boolean} isExtension NamePart isExtension - */ - - /** - * Constructs a new NamePart. - * @memberof google.protobuf.UninterpretedOption - * @classdesc Represents a NamePart. - * @implements INamePart - * @constructor - * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set - */ - function NamePart(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * NamePart namePart. - * @member {string} namePart - * @memberof google.protobuf.UninterpretedOption.NamePart - * @instance - */ - NamePart.prototype.namePart = ""; - - /** - * NamePart isExtension. - * @member {boolean} isExtension - * @memberof google.protobuf.UninterpretedOption.NamePart - * @instance - */ - NamePart.prototype.isExtension = false; - - return NamePart; - })(); - - return UninterpretedOption; - })(); - - protobuf.SourceCodeInfo = (function() { - - /** - * Properties of a SourceCodeInfo. - * @memberof google.protobuf - * @interface ISourceCodeInfo - * @property {Array.|null} [location] SourceCodeInfo location - */ - - /** - * Constructs a new SourceCodeInfo. - * @memberof google.protobuf - * @classdesc Represents a SourceCodeInfo. - * @implements ISourceCodeInfo - * @constructor - * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set - */ - function SourceCodeInfo(properties) { - this.location = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * SourceCodeInfo location. - * @member {Array.} location - * @memberof google.protobuf.SourceCodeInfo - * @instance - */ - SourceCodeInfo.prototype.location = $util.emptyArray; - - SourceCodeInfo.Location = (function() { - - /** - * Properties of a Location. - * @memberof google.protobuf.SourceCodeInfo - * @interface ILocation - * @property {Array.|null} [path] Location path - * @property {Array.|null} [span] Location span - * @property {string|null} [leadingComments] Location leadingComments - * @property {string|null} [trailingComments] Location trailingComments - * @property {Array.|null} [leadingDetachedComments] Location leadingDetachedComments - */ - - /** - * Constructs a new Location. - * @memberof google.protobuf.SourceCodeInfo - * @classdesc Represents a Location. - * @implements ILocation - * @constructor - * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set - */ - function Location(properties) { - this.path = []; - this.span = []; - this.leadingDetachedComments = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Location path. - * @member {Array.} path - * @memberof google.protobuf.SourceCodeInfo.Location - * @instance - */ - Location.prototype.path = $util.emptyArray; - - /** - * Location span. - * @member {Array.} span - * @memberof google.protobuf.SourceCodeInfo.Location - * @instance - */ - Location.prototype.span = $util.emptyArray; - - /** - * Location leadingComments. - * @member {string} leadingComments - * @memberof google.protobuf.SourceCodeInfo.Location - * @instance - */ - Location.prototype.leadingComments = ""; - - /** - * Location trailingComments. - * @member {string} trailingComments - * @memberof google.protobuf.SourceCodeInfo.Location - * @instance - */ - Location.prototype.trailingComments = ""; - - /** - * Location leadingDetachedComments. - * @member {Array.} leadingDetachedComments - * @memberof google.protobuf.SourceCodeInfo.Location - * @instance - */ - Location.prototype.leadingDetachedComments = $util.emptyArray; - - return Location; - })(); - - return SourceCodeInfo; - })(); - - protobuf.GeneratedCodeInfo = (function() { - - /** - * Properties of a GeneratedCodeInfo. - * @memberof google.protobuf - * @interface IGeneratedCodeInfo - * @property {Array.|null} [annotation] GeneratedCodeInfo annotation - */ - - /** - * Constructs a new GeneratedCodeInfo. - * @memberof google.protobuf - * @classdesc Represents a GeneratedCodeInfo. - * @implements IGeneratedCodeInfo - * @constructor - * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set - */ - function GeneratedCodeInfo(properties) { - this.annotation = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * GeneratedCodeInfo annotation. - * @member {Array.} annotation - * @memberof google.protobuf.GeneratedCodeInfo - * @instance - */ - GeneratedCodeInfo.prototype.annotation = $util.emptyArray; - - GeneratedCodeInfo.Annotation = (function() { - - /** - * Properties of an Annotation. - * @memberof google.protobuf.GeneratedCodeInfo - * @interface IAnnotation - * @property {Array.|null} [path] Annotation path - * @property {string|null} [sourceFile] Annotation sourceFile - * @property {number|null} [begin] Annotation begin - * @property {number|null} [end] Annotation end - */ - - /** - * Constructs a new Annotation. - * @memberof google.protobuf.GeneratedCodeInfo - * @classdesc Represents an Annotation. - * @implements IAnnotation - * @constructor - * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set - */ - function Annotation(properties) { - this.path = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Annotation path. - * @member {Array.} path - * @memberof google.protobuf.GeneratedCodeInfo.Annotation - * @instance - */ - Annotation.prototype.path = $util.emptyArray; - - /** - * Annotation sourceFile. - * @member {string} sourceFile - * @memberof google.protobuf.GeneratedCodeInfo.Annotation - * @instance - */ - Annotation.prototype.sourceFile = ""; - - /** - * Annotation begin. - * @member {number} begin - * @memberof google.protobuf.GeneratedCodeInfo.Annotation - * @instance - */ - Annotation.prototype.begin = 0; - - /** - * Annotation end. - * @member {number} end - * @memberof google.protobuf.GeneratedCodeInfo.Annotation - * @instance - */ - Annotation.prototype.end = 0; - - return Annotation; - })(); - - return GeneratedCodeInfo; - })(); - - protobuf.Struct = (function() { - - /** - * Properties of a Struct. - * @memberof google.protobuf - * @interface IStruct - * @property {Object.|null} [fields] Struct fields - */ - - /** - * Constructs a new Struct. - * @memberof google.protobuf - * @classdesc Represents a Struct. - * @implements IStruct - * @constructor - * @param {google.protobuf.IStruct=} [properties] Properties to set - */ - function Struct(properties) { - this.fields = {}; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Struct fields. - * @member {Object.} fields - * @memberof google.protobuf.Struct - * @instance - */ - Struct.prototype.fields = $util.emptyObject; - - return Struct; - })(); - - protobuf.Value = (function() { - - /** - * Properties of a Value. - * @memberof google.protobuf - * @interface IValue - * @property {google.protobuf.NullValue|null} [nullValue] Value nullValue - * @property {number|null} [numberValue] Value numberValue - * @property {string|null} [stringValue] Value stringValue - * @property {boolean|null} [boolValue] Value boolValue - * @property {google.protobuf.IStruct|null} [structValue] Value structValue - * @property {google.protobuf.IListValue|null} [listValue] Value listValue - */ - - /** - * Constructs a new Value. - * @memberof google.protobuf - * @classdesc Represents a Value. - * @implements IValue - * @constructor - * @param {google.protobuf.IValue=} [properties] Properties to set - */ - function Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Value nullValue. - * @member {google.protobuf.NullValue} nullValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.nullValue = 0; - - /** - * Value numberValue. - * @member {number} numberValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.numberValue = 0; - - /** - * Value stringValue. - * @member {string} stringValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.stringValue = ""; - - /** - * Value boolValue. - * @member {boolean} boolValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.boolValue = false; - - /** - * Value structValue. - * @member {google.protobuf.IStruct|null|undefined} structValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.structValue = null; - - /** - * Value listValue. - * @member {google.protobuf.IListValue|null|undefined} listValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.listValue = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Value kind. - * @member {"nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"|undefined} kind - * @memberof google.protobuf.Value - * @instance - */ - Object.defineProperty(Value.prototype, "kind", { - get: $util.oneOfGetter($oneOfFields = ["nullValue", "numberValue", "stringValue", "boolValue", "structValue", "listValue"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return Value; - })(); - - /** - * NullValue enum. - * @name google.protobuf.NullValue - * @enum {number} - * @property {string} NULL_VALUE=NULL_VALUE NULL_VALUE value - */ - protobuf.NullValue = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "NULL_VALUE"] = "NULL_VALUE"; - return values; - })(); - - protobuf.ListValue = (function() { - - /** - * Properties of a ListValue. - * @memberof google.protobuf - * @interface IListValue - * @property {Array.|null} [values] ListValue values - */ - - /** - * Constructs a new ListValue. - * @memberof google.protobuf - * @classdesc Represents a ListValue. - * @implements IListValue - * @constructor - * @param {google.protobuf.IListValue=} [properties] Properties to set - */ - function ListValue(properties) { - this.values = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListValue values. - * @member {Array.} values - * @memberof google.protobuf.ListValue - * @instance - */ - ListValue.prototype.values = $util.emptyArray; - - return ListValue; - })(); - - protobuf.Empty = (function() { - - /** - * Properties of an Empty. - * @memberof google.protobuf - * @interface IEmpty - */ - - /** - * Constructs a new Empty. - * @memberof google.protobuf - * @classdesc Represents an Empty. - * @implements IEmpty - * @constructor - * @param {google.protobuf.IEmpty=} [properties] Properties to set - */ - function Empty(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - return Empty; - })(); - - protobuf.DoubleValue = (function() { - - /** - * Properties of a DoubleValue. - * @memberof google.protobuf - * @interface IDoubleValue - * @property {number|null} [value] DoubleValue value - */ - - /** - * Constructs a new DoubleValue. - * @memberof google.protobuf - * @classdesc Represents a DoubleValue. - * @implements IDoubleValue - * @constructor - * @param {google.protobuf.IDoubleValue=} [properties] Properties to set - */ - function DoubleValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DoubleValue value. - * @member {number} value - * @memberof google.protobuf.DoubleValue - * @instance - */ - DoubleValue.prototype.value = 0; - - return DoubleValue; - })(); - - protobuf.FloatValue = (function() { - - /** - * Properties of a FloatValue. - * @memberof google.protobuf - * @interface IFloatValue - * @property {number|null} [value] FloatValue value - */ - - /** - * Constructs a new FloatValue. - * @memberof google.protobuf - * @classdesc Represents a FloatValue. - * @implements IFloatValue - * @constructor - * @param {google.protobuf.IFloatValue=} [properties] Properties to set - */ - function FloatValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FloatValue value. - * @member {number} value - * @memberof google.protobuf.FloatValue - * @instance - */ - FloatValue.prototype.value = 0; - - return FloatValue; - })(); - - protobuf.Int64Value = (function() { - - /** - * Properties of an Int64Value. - * @memberof google.protobuf - * @interface IInt64Value - * @property {number|null} [value] Int64Value value - */ - - /** - * Constructs a new Int64Value. - * @memberof google.protobuf - * @classdesc Represents an Int64Value. - * @implements IInt64Value - * @constructor - * @param {google.protobuf.IInt64Value=} [properties] Properties to set - */ - function Int64Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Int64Value value. - * @member {number} value - * @memberof google.protobuf.Int64Value - * @instance - */ - Int64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - return Int64Value; - })(); - - protobuf.UInt64Value = (function() { - - /** - * Properties of a UInt64Value. - * @memberof google.protobuf - * @interface IUInt64Value - * @property {number|null} [value] UInt64Value value - */ - - /** - * Constructs a new UInt64Value. - * @memberof google.protobuf - * @classdesc Represents a UInt64Value. - * @implements IUInt64Value - * @constructor - * @param {google.protobuf.IUInt64Value=} [properties] Properties to set - */ - function UInt64Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * UInt64Value value. - * @member {number} value - * @memberof google.protobuf.UInt64Value - * @instance - */ - UInt64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,true) : 0; - - return UInt64Value; - })(); - - protobuf.Int32Value = (function() { - - /** - * Properties of an Int32Value. - * @memberof google.protobuf - * @interface IInt32Value - * @property {number|null} [value] Int32Value value - */ - - /** - * Constructs a new Int32Value. - * @memberof google.protobuf - * @classdesc Represents an Int32Value. - * @implements IInt32Value - * @constructor - * @param {google.protobuf.IInt32Value=} [properties] Properties to set - */ - function Int32Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Int32Value value. - * @member {number} value - * @memberof google.protobuf.Int32Value - * @instance - */ - Int32Value.prototype.value = 0; - - return Int32Value; - })(); - - protobuf.UInt32Value = (function() { - - /** - * Properties of a UInt32Value. - * @memberof google.protobuf - * @interface IUInt32Value - * @property {number|null} [value] UInt32Value value - */ - - /** - * Constructs a new UInt32Value. - * @memberof google.protobuf - * @classdesc Represents a UInt32Value. - * @implements IUInt32Value - * @constructor - * @param {google.protobuf.IUInt32Value=} [properties] Properties to set - */ - function UInt32Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * UInt32Value value. - * @member {number} value - * @memberof google.protobuf.UInt32Value - * @instance - */ - UInt32Value.prototype.value = 0; - - return UInt32Value; - })(); - - protobuf.BoolValue = (function() { - - /** - * Properties of a BoolValue. - * @memberof google.protobuf - * @interface IBoolValue - * @property {boolean|null} [value] BoolValue value - */ - - /** - * Constructs a new BoolValue. - * @memberof google.protobuf - * @classdesc Represents a BoolValue. - * @implements IBoolValue - * @constructor - * @param {google.protobuf.IBoolValue=} [properties] Properties to set - */ - function BoolValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BoolValue value. - * @member {boolean} value - * @memberof google.protobuf.BoolValue - * @instance - */ - BoolValue.prototype.value = false; - - return BoolValue; - })(); - - protobuf.StringValue = (function() { - - /** - * Properties of a StringValue. - * @memberof google.protobuf - * @interface IStringValue - * @property {string|null} [value] StringValue value - */ - - /** - * Constructs a new StringValue. - * @memberof google.protobuf - * @classdesc Represents a StringValue. - * @implements IStringValue - * @constructor - * @param {google.protobuf.IStringValue=} [properties] Properties to set - */ - function StringValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * StringValue value. - * @member {string} value - * @memberof google.protobuf.StringValue - * @instance - */ - StringValue.prototype.value = ""; - - return StringValue; - })(); - - protobuf.BytesValue = (function() { - - /** - * Properties of a BytesValue. - * @memberof google.protobuf - * @interface IBytesValue - * @property {Uint8Array|null} [value] BytesValue value - */ - - /** - * Constructs a new BytesValue. - * @memberof google.protobuf - * @classdesc Represents a BytesValue. - * @implements IBytesValue - * @constructor - * @param {google.protobuf.IBytesValue=} [properties] Properties to set - */ - function BytesValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BytesValue value. - * @member {Uint8Array} value - * @memberof google.protobuf.BytesValue - * @instance - */ - BytesValue.prototype.value = $util.newBuffer([]); - - return BytesValue; - })(); - - protobuf.Any = (function() { - - /** - * Properties of an Any. - * @memberof google.protobuf - * @interface IAny - * @property {string|null} [type_url] Any type_url - * @property {Uint8Array|null} [value] Any value - */ - - /** - * Constructs a new Any. - * @memberof google.protobuf - * @classdesc Represents an Any. - * @implements IAny - * @constructor - * @param {google.protobuf.IAny=} [properties] Properties to set - */ - function Any(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Any type_url. - * @member {string} type_url - * @memberof google.protobuf.Any - * @instance - */ - Any.prototype.type_url = ""; - - /** - * Any value. - * @member {Uint8Array} value - * @memberof google.protobuf.Any - * @instance - */ - Any.prototype.value = $util.newBuffer([]); - - return Any; - })(); - - protobuf.FieldMask = (function() { - - /** - * Properties of a FieldMask. - * @memberof google.protobuf - * @interface IFieldMask - * @property {Array.|null} [paths] FieldMask paths - */ - - /** - * Constructs a new FieldMask. - * @memberof google.protobuf - * @classdesc Represents a FieldMask. - * @implements IFieldMask - * @constructor - * @param {google.protobuf.IFieldMask=} [properties] Properties to set - */ - function FieldMask(properties) { - this.paths = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FieldMask paths. - * @member {Array.} paths - * @memberof google.protobuf.FieldMask - * @instance - */ - FieldMask.prototype.paths = $util.emptyArray; - - return FieldMask; - })(); - - protobuf.Duration = (function() { - - /** - * Properties of a Duration. - * @memberof google.protobuf - * @interface IDuration - * @property {number|null} [seconds] Duration seconds - * @property {number|null} [nanos] Duration nanos - */ - - /** - * Constructs a new Duration. - * @memberof google.protobuf - * @classdesc Represents a Duration. - * @implements IDuration - * @constructor - * @param {google.protobuf.IDuration=} [properties] Properties to set - */ - function Duration(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Duration seconds. - * @member {number} seconds - * @memberof google.protobuf.Duration - * @instance - */ - Duration.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Duration nanos. - * @member {number} nanos - * @memberof google.protobuf.Duration - * @instance - */ - Duration.prototype.nanos = 0; - - return Duration; - })(); - - return protobuf; - })(); - - google.firestore = (function() { - - /** - * Namespace firestore. - * @memberof google - * @namespace - */ - var firestore = {}; - - firestore.v1 = (function() { - - /** - * Namespace v1. - * @memberof google.firestore - * @namespace - */ - var v1 = {}; - - v1.DocumentMask = (function() { - - /** - * Properties of a DocumentMask. - * @memberof google.firestore.v1 - * @interface IDocumentMask - * @property {Array.|null} [fieldPaths] DocumentMask fieldPaths - */ - - /** - * Constructs a new DocumentMask. - * @memberof google.firestore.v1 - * @classdesc Represents a DocumentMask. - * @implements IDocumentMask - * @constructor - * @param {google.firestore.v1.IDocumentMask=} [properties] Properties to set - */ - function DocumentMask(properties) { - this.fieldPaths = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DocumentMask fieldPaths. - * @member {Array.} fieldPaths - * @memberof google.firestore.v1.DocumentMask - * @instance - */ - DocumentMask.prototype.fieldPaths = $util.emptyArray; - - return DocumentMask; - })(); - - v1.Precondition = (function() { - - /** - * Properties of a Precondition. - * @memberof google.firestore.v1 - * @interface IPrecondition - * @property {boolean|null} [exists] Precondition exists - * @property {google.protobuf.ITimestamp|null} [updateTime] Precondition updateTime - */ - - /** - * Constructs a new Precondition. - * @memberof google.firestore.v1 - * @classdesc Represents a Precondition. - * @implements IPrecondition - * @constructor - * @param {google.firestore.v1.IPrecondition=} [properties] Properties to set - */ - function Precondition(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Precondition exists. - * @member {boolean} exists - * @memberof google.firestore.v1.Precondition - * @instance - */ - Precondition.prototype.exists = false; - - /** - * Precondition updateTime. - * @member {google.protobuf.ITimestamp|null|undefined} updateTime - * @memberof google.firestore.v1.Precondition - * @instance - */ - Precondition.prototype.updateTime = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Precondition conditionType. - * @member {"exists"|"updateTime"|undefined} conditionType - * @memberof google.firestore.v1.Precondition - * @instance - */ - Object.defineProperty(Precondition.prototype, "conditionType", { - get: $util.oneOfGetter($oneOfFields = ["exists", "updateTime"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return Precondition; - })(); - - v1.TransactionOptions = (function() { - - /** - * Properties of a TransactionOptions. - * @memberof google.firestore.v1 - * @interface ITransactionOptions - * @property {google.firestore.v1.TransactionOptions.IReadOnly|null} [readOnly] TransactionOptions readOnly - * @property {google.firestore.v1.TransactionOptions.IReadWrite|null} [readWrite] TransactionOptions readWrite - */ - - /** - * Constructs a new TransactionOptions. - * @memberof google.firestore.v1 - * @classdesc Represents a TransactionOptions. - * @implements ITransactionOptions - * @constructor - * @param {google.firestore.v1.ITransactionOptions=} [properties] Properties to set - */ - function TransactionOptions(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * TransactionOptions readOnly. - * @member {google.firestore.v1.TransactionOptions.IReadOnly|null|undefined} readOnly - * @memberof google.firestore.v1.TransactionOptions - * @instance - */ - TransactionOptions.prototype.readOnly = null; - - /** - * TransactionOptions readWrite. - * @member {google.firestore.v1.TransactionOptions.IReadWrite|null|undefined} readWrite - * @memberof google.firestore.v1.TransactionOptions - * @instance - */ - TransactionOptions.prototype.readWrite = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * TransactionOptions mode. - * @member {"readOnly"|"readWrite"|undefined} mode - * @memberof google.firestore.v1.TransactionOptions - * @instance - */ - Object.defineProperty(TransactionOptions.prototype, "mode", { - get: $util.oneOfGetter($oneOfFields = ["readOnly", "readWrite"]), - set: $util.oneOfSetter($oneOfFields) - }); - - TransactionOptions.ReadWrite = (function() { - - /** - * Properties of a ReadWrite. - * @memberof google.firestore.v1.TransactionOptions - * @interface IReadWrite - * @property {Uint8Array|null} [retryTransaction] ReadWrite retryTransaction - */ - - /** - * Constructs a new ReadWrite. - * @memberof google.firestore.v1.TransactionOptions - * @classdesc Represents a ReadWrite. - * @implements IReadWrite - * @constructor - * @param {google.firestore.v1.TransactionOptions.IReadWrite=} [properties] Properties to set - */ - function ReadWrite(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ReadWrite retryTransaction. - * @member {Uint8Array} retryTransaction - * @memberof google.firestore.v1.TransactionOptions.ReadWrite - * @instance - */ - ReadWrite.prototype.retryTransaction = $util.newBuffer([]); - - return ReadWrite; - })(); - - TransactionOptions.ReadOnly = (function() { - - /** - * Properties of a ReadOnly. - * @memberof google.firestore.v1.TransactionOptions - * @interface IReadOnly - * @property {google.protobuf.ITimestamp|null} [readTime] ReadOnly readTime - */ - - /** - * Constructs a new ReadOnly. - * @memberof google.firestore.v1.TransactionOptions - * @classdesc Represents a ReadOnly. - * @implements IReadOnly - * @constructor - * @param {google.firestore.v1.TransactionOptions.IReadOnly=} [properties] Properties to set - */ - function ReadOnly(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ReadOnly readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1.TransactionOptions.ReadOnly - * @instance - */ - ReadOnly.prototype.readTime = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * ReadOnly consistencySelector. - * @member {"readTime"|undefined} consistencySelector - * @memberof google.firestore.v1.TransactionOptions.ReadOnly - * @instance - */ - Object.defineProperty(ReadOnly.prototype, "consistencySelector", { - get: $util.oneOfGetter($oneOfFields = ["readTime"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return ReadOnly; - })(); - - return TransactionOptions; - })(); - - v1.Document = (function() { - - /** - * Properties of a Document. - * @memberof google.firestore.v1 - * @interface IDocument - * @property {string|null} [name] Document name - * @property {Object.|null} [fields] Document fields - * @property {google.protobuf.ITimestamp|null} [createTime] Document createTime - * @property {google.protobuf.ITimestamp|null} [updateTime] Document updateTime - */ - - /** - * Constructs a new Document. - * @memberof google.firestore.v1 - * @classdesc Represents a Document. - * @implements IDocument - * @constructor - * @param {google.firestore.v1.IDocument=} [properties] Properties to set - */ - function Document(properties) { - this.fields = {}; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Document name. - * @member {string} name - * @memberof google.firestore.v1.Document - * @instance - */ - Document.prototype.name = ""; - - /** - * Document fields. - * @member {Object.} fields - * @memberof google.firestore.v1.Document - * @instance - */ - Document.prototype.fields = $util.emptyObject; - - /** - * Document createTime. - * @member {google.protobuf.ITimestamp|null|undefined} createTime - * @memberof google.firestore.v1.Document - * @instance - */ - Document.prototype.createTime = null; - - /** - * Document updateTime. - * @member {google.protobuf.ITimestamp|null|undefined} updateTime - * @memberof google.firestore.v1.Document - * @instance - */ - Document.prototype.updateTime = null; - - return Document; - })(); - - v1.Value = (function() { - - /** - * Properties of a Value. - * @memberof google.firestore.v1 - * @interface IValue - * @property {google.protobuf.NullValue|null} [nullValue] Value nullValue - * @property {boolean|null} [booleanValue] Value booleanValue - * @property {number|null} [integerValue] Value integerValue - * @property {number|null} [doubleValue] Value doubleValue - * @property {google.protobuf.ITimestamp|null} [timestampValue] Value timestampValue - * @property {string|null} [stringValue] Value stringValue - * @property {Uint8Array|null} [bytesValue] Value bytesValue - * @property {string|null} [referenceValue] Value referenceValue - * @property {google.type.ILatLng|null} [geoPointValue] Value geoPointValue - * @property {google.firestore.v1.IArrayValue|null} [arrayValue] Value arrayValue - * @property {google.firestore.v1.IMapValue|null} [mapValue] Value mapValue - */ - - /** - * Constructs a new Value. - * @memberof google.firestore.v1 - * @classdesc Represents a Value. - * @implements IValue - * @constructor - * @param {google.firestore.v1.IValue=} [properties] Properties to set - */ - function Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Value nullValue. - * @member {google.protobuf.NullValue} nullValue - * @memberof google.firestore.v1.Value - * @instance - */ - Value.prototype.nullValue = 0; - - /** - * Value booleanValue. - * @member {boolean} booleanValue - * @memberof google.firestore.v1.Value - * @instance - */ - Value.prototype.booleanValue = false; - - /** - * Value integerValue. - * @member {number} integerValue - * @memberof google.firestore.v1.Value - * @instance - */ - Value.prototype.integerValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Value doubleValue. - * @member {number} doubleValue - * @memberof google.firestore.v1.Value - * @instance - */ - Value.prototype.doubleValue = 0; - - /** - * Value timestampValue. - * @member {google.protobuf.ITimestamp|null|undefined} timestampValue - * @memberof google.firestore.v1.Value - * @instance - */ - Value.prototype.timestampValue = null; - - /** - * Value stringValue. - * @member {string} stringValue - * @memberof google.firestore.v1.Value - * @instance - */ - Value.prototype.stringValue = ""; - - /** - * Value bytesValue. - * @member {Uint8Array} bytesValue - * @memberof google.firestore.v1.Value - * @instance - */ - Value.prototype.bytesValue = $util.newBuffer([]); - - /** - * Value referenceValue. - * @member {string} referenceValue - * @memberof google.firestore.v1.Value - * @instance - */ - Value.prototype.referenceValue = ""; - - /** - * Value geoPointValue. - * @member {google.type.ILatLng|null|undefined} geoPointValue - * @memberof google.firestore.v1.Value - * @instance - */ - Value.prototype.geoPointValue = null; - - /** - * Value arrayValue. - * @member {google.firestore.v1.IArrayValue|null|undefined} arrayValue - * @memberof google.firestore.v1.Value - * @instance - */ - Value.prototype.arrayValue = null; - - /** - * Value mapValue. - * @member {google.firestore.v1.IMapValue|null|undefined} mapValue - * @memberof google.firestore.v1.Value - * @instance - */ - Value.prototype.mapValue = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Value valueType. - * @member {"nullValue"|"booleanValue"|"integerValue"|"doubleValue"|"timestampValue"|"stringValue"|"bytesValue"|"referenceValue"|"geoPointValue"|"arrayValue"|"mapValue"|undefined} valueType - * @memberof google.firestore.v1.Value - * @instance - */ - Object.defineProperty(Value.prototype, "valueType", { - get: $util.oneOfGetter($oneOfFields = ["nullValue", "booleanValue", "integerValue", "doubleValue", "timestampValue", "stringValue", "bytesValue", "referenceValue", "geoPointValue", "arrayValue", "mapValue"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return Value; - })(); - - v1.ArrayValue = (function() { - - /** - * Properties of an ArrayValue. - * @memberof google.firestore.v1 - * @interface IArrayValue - * @property {Array.|null} [values] ArrayValue values - */ - - /** - * Constructs a new ArrayValue. - * @memberof google.firestore.v1 - * @classdesc Represents an ArrayValue. - * @implements IArrayValue - * @constructor - * @param {google.firestore.v1.IArrayValue=} [properties] Properties to set - */ - function ArrayValue(properties) { - this.values = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ArrayValue values. - * @member {Array.} values - * @memberof google.firestore.v1.ArrayValue - * @instance - */ - ArrayValue.prototype.values = $util.emptyArray; - - return ArrayValue; - })(); - - v1.MapValue = (function() { - - /** - * Properties of a MapValue. - * @memberof google.firestore.v1 - * @interface IMapValue - * @property {Object.|null} [fields] MapValue fields - */ - - /** - * Constructs a new MapValue. - * @memberof google.firestore.v1 - * @classdesc Represents a MapValue. - * @implements IMapValue - * @constructor - * @param {google.firestore.v1.IMapValue=} [properties] Properties to set - */ - function MapValue(properties) { - this.fields = {}; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * MapValue fields. - * @member {Object.} fields - * @memberof google.firestore.v1.MapValue - * @instance - */ - MapValue.prototype.fields = $util.emptyObject; - - return MapValue; - })(); - - v1.Firestore = (function() { - - /** - * Constructs a new Firestore service. - * @memberof google.firestore.v1 - * @classdesc Represents a Firestore - * @extends $protobuf.rpc.Service - * @constructor - * @param {$protobuf.RPCImpl} rpcImpl RPC implementation - * @param {boolean} [requestDelimited=false] Whether requests are length-delimited - * @param {boolean} [responseDelimited=false] Whether responses are length-delimited - */ - function Firestore(rpcImpl, requestDelimited, responseDelimited) { - $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); - } - - (Firestore.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Firestore; - - /** - * Callback as used by {@link google.firestore.v1.Firestore#getDocument}. - * @memberof google.firestore.v1.Firestore - * @typedef GetDocumentCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1.Document} [response] Document - */ - - /** - * Calls GetDocument. - * @function getDocument - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IGetDocumentRequest} request GetDocumentRequest message or plain object - * @param {google.firestore.v1.Firestore.GetDocumentCallback} callback Node-style callback called with the error, if any, and Document - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Firestore.prototype.getDocument = function getDocument(request, callback) { - return this.rpcCall(getDocument, $root.google.firestore.v1.GetDocumentRequest, $root.google.firestore.v1.Document, request, callback); - }, "name", { value: "GetDocument" }); - - /** - * Calls GetDocument. - * @function getDocument - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IGetDocumentRequest} request GetDocumentRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.v1.Firestore#listDocuments}. - * @memberof google.firestore.v1.Firestore - * @typedef ListDocumentsCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1.ListDocumentsResponse} [response] ListDocumentsResponse - */ - - /** - * Calls ListDocuments. - * @function listDocuments - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IListDocumentsRequest} request ListDocumentsRequest message or plain object - * @param {google.firestore.v1.Firestore.ListDocumentsCallback} callback Node-style callback called with the error, if any, and ListDocumentsResponse - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Firestore.prototype.listDocuments = function listDocuments(request, callback) { - return this.rpcCall(listDocuments, $root.google.firestore.v1.ListDocumentsRequest, $root.google.firestore.v1.ListDocumentsResponse, request, callback); - }, "name", { value: "ListDocuments" }); - - /** - * Calls ListDocuments. - * @function listDocuments - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IListDocumentsRequest} request ListDocumentsRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.v1.Firestore#updateDocument}. - * @memberof google.firestore.v1.Firestore - * @typedef UpdateDocumentCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1.Document} [response] Document - */ - - /** - * Calls UpdateDocument. - * @function updateDocument - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IUpdateDocumentRequest} request UpdateDocumentRequest message or plain object - * @param {google.firestore.v1.Firestore.UpdateDocumentCallback} callback Node-style callback called with the error, if any, and Document - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Firestore.prototype.updateDocument = function updateDocument(request, callback) { - return this.rpcCall(updateDocument, $root.google.firestore.v1.UpdateDocumentRequest, $root.google.firestore.v1.Document, request, callback); - }, "name", { value: "UpdateDocument" }); - - /** - * Calls UpdateDocument. - * @function updateDocument - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IUpdateDocumentRequest} request UpdateDocumentRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.v1.Firestore#deleteDocument}. - * @memberof google.firestore.v1.Firestore - * @typedef DeleteDocumentCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.protobuf.Empty} [response] Empty - */ - - /** - * Calls DeleteDocument. - * @function deleteDocument - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IDeleteDocumentRequest} request DeleteDocumentRequest message or plain object - * @param {google.firestore.v1.Firestore.DeleteDocumentCallback} callback Node-style callback called with the error, if any, and Empty - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Firestore.prototype.deleteDocument = function deleteDocument(request, callback) { - return this.rpcCall(deleteDocument, $root.google.firestore.v1.DeleteDocumentRequest, $root.google.protobuf.Empty, request, callback); - }, "name", { value: "DeleteDocument" }); - - /** - * Calls DeleteDocument. - * @function deleteDocument - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IDeleteDocumentRequest} request DeleteDocumentRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.v1.Firestore#batchGetDocuments}. - * @memberof google.firestore.v1.Firestore - * @typedef BatchGetDocumentsCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1.BatchGetDocumentsResponse} [response] BatchGetDocumentsResponse - */ - - /** - * Calls BatchGetDocuments. - * @function batchGetDocuments - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IBatchGetDocumentsRequest} request BatchGetDocumentsRequest message or plain object - * @param {google.firestore.v1.Firestore.BatchGetDocumentsCallback} callback Node-style callback called with the error, if any, and BatchGetDocumentsResponse - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Firestore.prototype.batchGetDocuments = function batchGetDocuments(request, callback) { - return this.rpcCall(batchGetDocuments, $root.google.firestore.v1.BatchGetDocumentsRequest, $root.google.firestore.v1.BatchGetDocumentsResponse, request, callback); - }, "name", { value: "BatchGetDocuments" }); - - /** - * Calls BatchGetDocuments. - * @function batchGetDocuments - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IBatchGetDocumentsRequest} request BatchGetDocumentsRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.v1.Firestore#beginTransaction}. - * @memberof google.firestore.v1.Firestore - * @typedef BeginTransactionCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1.BeginTransactionResponse} [response] BeginTransactionResponse - */ - - /** - * Calls BeginTransaction. - * @function beginTransaction - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IBeginTransactionRequest} request BeginTransactionRequest message or plain object - * @param {google.firestore.v1.Firestore.BeginTransactionCallback} callback Node-style callback called with the error, if any, and BeginTransactionResponse - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Firestore.prototype.beginTransaction = function beginTransaction(request, callback) { - return this.rpcCall(beginTransaction, $root.google.firestore.v1.BeginTransactionRequest, $root.google.firestore.v1.BeginTransactionResponse, request, callback); - }, "name", { value: "BeginTransaction" }); - - /** - * Calls BeginTransaction. - * @function beginTransaction - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IBeginTransactionRequest} request BeginTransactionRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.v1.Firestore#commit}. - * @memberof google.firestore.v1.Firestore - * @typedef CommitCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1.CommitResponse} [response] CommitResponse - */ - - /** - * Calls Commit. - * @function commit - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.ICommitRequest} request CommitRequest message or plain object - * @param {google.firestore.v1.Firestore.CommitCallback} callback Node-style callback called with the error, if any, and CommitResponse - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Firestore.prototype.commit = function commit(request, callback) { - return this.rpcCall(commit, $root.google.firestore.v1.CommitRequest, $root.google.firestore.v1.CommitResponse, request, callback); - }, "name", { value: "Commit" }); - - /** - * Calls Commit. - * @function commit - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.ICommitRequest} request CommitRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.v1.Firestore#rollback}. - * @memberof google.firestore.v1.Firestore - * @typedef RollbackCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.protobuf.Empty} [response] Empty - */ - - /** - * Calls Rollback. - * @function rollback - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IRollbackRequest} request RollbackRequest message or plain object - * @param {google.firestore.v1.Firestore.RollbackCallback} callback Node-style callback called with the error, if any, and Empty - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Firestore.prototype.rollback = function rollback(request, callback) { - return this.rpcCall(rollback, $root.google.firestore.v1.RollbackRequest, $root.google.protobuf.Empty, request, callback); - }, "name", { value: "Rollback" }); - - /** - * Calls Rollback. - * @function rollback - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IRollbackRequest} request RollbackRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.v1.Firestore#runQuery}. - * @memberof google.firestore.v1.Firestore - * @typedef RunQueryCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1.RunQueryResponse} [response] RunQueryResponse - */ - - /** - * Calls RunQuery. - * @function runQuery - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IRunQueryRequest} request RunQueryRequest message or plain object - * @param {google.firestore.v1.Firestore.RunQueryCallback} callback Node-style callback called with the error, if any, and RunQueryResponse - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Firestore.prototype.runQuery = function runQuery(request, callback) { - return this.rpcCall(runQuery, $root.google.firestore.v1.RunQueryRequest, $root.google.firestore.v1.RunQueryResponse, request, callback); - }, "name", { value: "RunQuery" }); - - /** - * Calls RunQuery. - * @function runQuery - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IRunQueryRequest} request RunQueryRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.v1.Firestore#write}. - * @memberof google.firestore.v1.Firestore - * @typedef WriteCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1.WriteResponse} [response] WriteResponse - */ - - /** - * Calls Write. - * @function write - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IWriteRequest} request WriteRequest message or plain object - * @param {google.firestore.v1.Firestore.WriteCallback} callback Node-style callback called with the error, if any, and WriteResponse - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Firestore.prototype.write = function write(request, callback) { - return this.rpcCall(write, $root.google.firestore.v1.WriteRequest, $root.google.firestore.v1.WriteResponse, request, callback); - }, "name", { value: "Write" }); - - /** - * Calls Write. - * @function write - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IWriteRequest} request WriteRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.v1.Firestore#listen}. - * @memberof google.firestore.v1.Firestore - * @typedef ListenCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1.ListenResponse} [response] ListenResponse - */ - - /** - * Calls Listen. - * @function listen - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IListenRequest} request ListenRequest message or plain object - * @param {google.firestore.v1.Firestore.ListenCallback} callback Node-style callback called with the error, if any, and ListenResponse - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Firestore.prototype.listen = function listen(request, callback) { - return this.rpcCall(listen, $root.google.firestore.v1.ListenRequest, $root.google.firestore.v1.ListenResponse, request, callback); - }, "name", { value: "Listen" }); - - /** - * Calls Listen. - * @function listen - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IListenRequest} request ListenRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.v1.Firestore#listCollectionIds}. - * @memberof google.firestore.v1.Firestore - * @typedef ListCollectionIdsCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1.ListCollectionIdsResponse} [response] ListCollectionIdsResponse - */ - - /** - * Calls ListCollectionIds. - * @function listCollectionIds - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IListCollectionIdsRequest} request ListCollectionIdsRequest message or plain object - * @param {google.firestore.v1.Firestore.ListCollectionIdsCallback} callback Node-style callback called with the error, if any, and ListCollectionIdsResponse - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Firestore.prototype.listCollectionIds = function listCollectionIds(request, callback) { - return this.rpcCall(listCollectionIds, $root.google.firestore.v1.ListCollectionIdsRequest, $root.google.firestore.v1.ListCollectionIdsResponse, request, callback); - }, "name", { value: "ListCollectionIds" }); - - /** - * Calls ListCollectionIds. - * @function listCollectionIds - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IListCollectionIdsRequest} request ListCollectionIdsRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.v1.Firestore#batchWrite}. - * @memberof google.firestore.v1.Firestore - * @typedef BatchWriteCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1.BatchWriteResponse} [response] BatchWriteResponse - */ - - /** - * Calls BatchWrite. - * @function batchWrite - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IBatchWriteRequest} request BatchWriteRequest message or plain object - * @param {google.firestore.v1.Firestore.BatchWriteCallback} callback Node-style callback called with the error, if any, and BatchWriteResponse - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Firestore.prototype.batchWrite = function batchWrite(request, callback) { - return this.rpcCall(batchWrite, $root.google.firestore.v1.BatchWriteRequest, $root.google.firestore.v1.BatchWriteResponse, request, callback); - }, "name", { value: "BatchWrite" }); - - /** - * Calls BatchWrite. - * @function batchWrite - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.IBatchWriteRequest} request BatchWriteRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /* - * Callback as used by {@link google.firestore.v1.Firestore#createDocument}. - * @memberof google.firestore.v1.Firestore - * @typedef CreateDocumentCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1.Document} [response] Document - */ - - /** - * Calls CreateDocument. - * @function createDocument - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object - * @param {google.firestore.v1.Firestore.CreateDocumentCallback} callback Node-style callback called with the error, if any, and Document - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Firestore.prototype.createDocument = function createDocument(request, callback) { - return this.rpcCall(createDocument, $root.google.firestore.v1.CreateDocumentRequest, $root.google.firestore.v1.Document, request, callback); - }, "name", { value: "CreateDocument" }); - - /** - * Calls CreateDocument. - * @function createDocument - * @memberof google.firestore.v1.Firestore - * @instance - * @param {google.firestore.v1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - return Firestore; - })(); - - v1.GetDocumentRequest = (function() { - - /** - * Properties of a GetDocumentRequest. - * @memberof google.firestore.v1 - * @interface IGetDocumentRequest - * @property {string|null} [name] GetDocumentRequest name - * @property {google.firestore.v1.IDocumentMask|null} [mask] GetDocumentRequest mask - * @property {Uint8Array|null} [transaction] GetDocumentRequest transaction - * @property {google.protobuf.ITimestamp|null} [readTime] GetDocumentRequest readTime - */ - - /** - * Constructs a new GetDocumentRequest. - * @memberof google.firestore.v1 - * @classdesc Represents a GetDocumentRequest. - * @implements IGetDocumentRequest - * @constructor - * @param {google.firestore.v1.IGetDocumentRequest=} [properties] Properties to set - */ - function GetDocumentRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * GetDocumentRequest name. - * @member {string} name - * @memberof google.firestore.v1.GetDocumentRequest - * @instance - */ - GetDocumentRequest.prototype.name = ""; - - /** - * GetDocumentRequest mask. - * @member {google.firestore.v1.IDocumentMask|null|undefined} mask - * @memberof google.firestore.v1.GetDocumentRequest - * @instance - */ - GetDocumentRequest.prototype.mask = null; - - /** - * GetDocumentRequest transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1.GetDocumentRequest - * @instance - */ - GetDocumentRequest.prototype.transaction = $util.newBuffer([]); - - /** - * GetDocumentRequest readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1.GetDocumentRequest - * @instance - */ - GetDocumentRequest.prototype.readTime = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * GetDocumentRequest consistencySelector. - * @member {"transaction"|"readTime"|undefined} consistencySelector - * @memberof google.firestore.v1.GetDocumentRequest - * @instance - */ - Object.defineProperty(GetDocumentRequest.prototype, "consistencySelector", { - get: $util.oneOfGetter($oneOfFields = ["transaction", "readTime"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return GetDocumentRequest; - })(); - - v1.ListDocumentsRequest = (function() { - - /** - * Properties of a ListDocumentsRequest. - * @memberof google.firestore.v1 - * @interface IListDocumentsRequest - * @property {string|null} [parent] ListDocumentsRequest parent - * @property {string|null} [collectionId] ListDocumentsRequest collectionId - * @property {number|null} [pageSize] ListDocumentsRequest pageSize - * @property {string|null} [pageToken] ListDocumentsRequest pageToken - * @property {string|null} [orderBy] ListDocumentsRequest orderBy - * @property {google.firestore.v1.IDocumentMask|null} [mask] ListDocumentsRequest mask - * @property {Uint8Array|null} [transaction] ListDocumentsRequest transaction - * @property {google.protobuf.ITimestamp|null} [readTime] ListDocumentsRequest readTime - * @property {boolean|null} [showMissing] ListDocumentsRequest showMissing - */ - - /** - * Constructs a new ListDocumentsRequest. - * @memberof google.firestore.v1 - * @classdesc Represents a ListDocumentsRequest. - * @implements IListDocumentsRequest - * @constructor - * @param {google.firestore.v1.IListDocumentsRequest=} [properties] Properties to set - */ - function ListDocumentsRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListDocumentsRequest parent. - * @member {string} parent - * @memberof google.firestore.v1.ListDocumentsRequest - * @instance - */ - ListDocumentsRequest.prototype.parent = ""; - - /** - * ListDocumentsRequest collectionId. - * @member {string} collectionId - * @memberof google.firestore.v1.ListDocumentsRequest - * @instance - */ - ListDocumentsRequest.prototype.collectionId = ""; - - /** - * ListDocumentsRequest pageSize. - * @member {number} pageSize - * @memberof google.firestore.v1.ListDocumentsRequest - * @instance - */ - ListDocumentsRequest.prototype.pageSize = 0; - - /** - * ListDocumentsRequest pageToken. - * @member {string} pageToken - * @memberof google.firestore.v1.ListDocumentsRequest - * @instance - */ - ListDocumentsRequest.prototype.pageToken = ""; - - /** - * ListDocumentsRequest orderBy. - * @member {string} orderBy - * @memberof google.firestore.v1.ListDocumentsRequest - * @instance - */ - ListDocumentsRequest.prototype.orderBy = ""; - - /** - * ListDocumentsRequest mask. - * @member {google.firestore.v1.IDocumentMask|null|undefined} mask - * @memberof google.firestore.v1.ListDocumentsRequest - * @instance - */ - ListDocumentsRequest.prototype.mask = null; - - /** - * ListDocumentsRequest transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1.ListDocumentsRequest - * @instance - */ - ListDocumentsRequest.prototype.transaction = $util.newBuffer([]); - - /** - * ListDocumentsRequest readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1.ListDocumentsRequest - * @instance - */ - ListDocumentsRequest.prototype.readTime = null; - - /** - * ListDocumentsRequest showMissing. - * @member {boolean} showMissing - * @memberof google.firestore.v1.ListDocumentsRequest - * @instance - */ - ListDocumentsRequest.prototype.showMissing = false; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * ListDocumentsRequest consistencySelector. - * @member {"transaction"|"readTime"|undefined} consistencySelector - * @memberof google.firestore.v1.ListDocumentsRequest - * @instance - */ - Object.defineProperty(ListDocumentsRequest.prototype, "consistencySelector", { - get: $util.oneOfGetter($oneOfFields = ["transaction", "readTime"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return ListDocumentsRequest; - })(); - - v1.ListDocumentsResponse = (function() { - - /** - * Properties of a ListDocumentsResponse. - * @memberof google.firestore.v1 - * @interface IListDocumentsResponse - * @property {Array.|null} [documents] ListDocumentsResponse documents - * @property {string|null} [nextPageToken] ListDocumentsResponse nextPageToken - */ - - /** - * Constructs a new ListDocumentsResponse. - * @memberof google.firestore.v1 - * @classdesc Represents a ListDocumentsResponse. - * @implements IListDocumentsResponse - * @constructor - * @param {google.firestore.v1.IListDocumentsResponse=} [properties] Properties to set - */ - function ListDocumentsResponse(properties) { - this.documents = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListDocumentsResponse documents. - * @member {Array.} documents - * @memberof google.firestore.v1.ListDocumentsResponse - * @instance - */ - ListDocumentsResponse.prototype.documents = $util.emptyArray; - - /** - * ListDocumentsResponse nextPageToken. - * @member {string} nextPageToken - * @memberof google.firestore.v1.ListDocumentsResponse - * @instance - */ - ListDocumentsResponse.prototype.nextPageToken = ""; - - return ListDocumentsResponse; - })(); - - v1.CreateDocumentRequest = (function() { - - /** - * Properties of a CreateDocumentRequest. - * @memberof google.firestore.v1 - * @interface ICreateDocumentRequest - * @property {string|null} [parent] CreateDocumentRequest parent - * @property {string|null} [collectionId] CreateDocumentRequest collectionId - * @property {string|null} [documentId] CreateDocumentRequest documentId - * @property {google.firestore.v1.IDocument|null} [document] CreateDocumentRequest document - * @property {google.firestore.v1.IDocumentMask|null} [mask] CreateDocumentRequest mask - */ - - /** - * Constructs a new CreateDocumentRequest. - * @memberof google.firestore.v1 - * @classdesc Represents a CreateDocumentRequest. - * @implements ICreateDocumentRequest - * @constructor - * @param {google.firestore.v1.ICreateDocumentRequest=} [properties] Properties to set - */ - function CreateDocumentRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * CreateDocumentRequest parent. - * @member {string} parent - * @memberof google.firestore.v1.CreateDocumentRequest - * @instance - */ - CreateDocumentRequest.prototype.parent = ""; - - /** - * CreateDocumentRequest collectionId. - * @member {string} collectionId - * @memberof google.firestore.v1.CreateDocumentRequest - * @instance - */ - CreateDocumentRequest.prototype.collectionId = ""; - - /** - * CreateDocumentRequest documentId. - * @member {string} documentId - * @memberof google.firestore.v1.CreateDocumentRequest - * @instance - */ - CreateDocumentRequest.prototype.documentId = ""; - - /** - * CreateDocumentRequest document. - * @member {google.firestore.v1.IDocument|null|undefined} document - * @memberof google.firestore.v1.CreateDocumentRequest - * @instance - */ - CreateDocumentRequest.prototype.document = null; - - /** - * CreateDocumentRequest mask. - * @member {google.firestore.v1.IDocumentMask|null|undefined} mask - * @memberof google.firestore.v1.CreateDocumentRequest - * @instance - */ - CreateDocumentRequest.prototype.mask = null; - - return CreateDocumentRequest; - })(); - - v1.UpdateDocumentRequest = (function() { - - /** - * Properties of an UpdateDocumentRequest. - * @memberof google.firestore.v1 - * @interface IUpdateDocumentRequest - * @property {google.firestore.v1.IDocument|null} [document] UpdateDocumentRequest document - * @property {google.firestore.v1.IDocumentMask|null} [updateMask] UpdateDocumentRequest updateMask - * @property {google.firestore.v1.IDocumentMask|null} [mask] UpdateDocumentRequest mask - * @property {google.firestore.v1.IPrecondition|null} [currentDocument] UpdateDocumentRequest currentDocument - */ - - /** - * Constructs a new UpdateDocumentRequest. - * @memberof google.firestore.v1 - * @classdesc Represents an UpdateDocumentRequest. - * @implements IUpdateDocumentRequest - * @constructor - * @param {google.firestore.v1.IUpdateDocumentRequest=} [properties] Properties to set - */ - function UpdateDocumentRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * UpdateDocumentRequest document. - * @member {google.firestore.v1.IDocument|null|undefined} document - * @memberof google.firestore.v1.UpdateDocumentRequest - * @instance - */ - UpdateDocumentRequest.prototype.document = null; - - /** - * UpdateDocumentRequest updateMask. - * @member {google.firestore.v1.IDocumentMask|null|undefined} updateMask - * @memberof google.firestore.v1.UpdateDocumentRequest - * @instance - */ - UpdateDocumentRequest.prototype.updateMask = null; - - /** - * UpdateDocumentRequest mask. - * @member {google.firestore.v1.IDocumentMask|null|undefined} mask - * @memberof google.firestore.v1.UpdateDocumentRequest - * @instance - */ - UpdateDocumentRequest.prototype.mask = null; - - /** - * UpdateDocumentRequest currentDocument. - * @member {google.firestore.v1.IPrecondition|null|undefined} currentDocument - * @memberof google.firestore.v1.UpdateDocumentRequest - * @instance - */ - UpdateDocumentRequest.prototype.currentDocument = null; - - return UpdateDocumentRequest; - })(); - - v1.DeleteDocumentRequest = (function() { - - /** - * Properties of a DeleteDocumentRequest. - * @memberof google.firestore.v1 - * @interface IDeleteDocumentRequest - * @property {string|null} [name] DeleteDocumentRequest name - * @property {google.firestore.v1.IPrecondition|null} [currentDocument] DeleteDocumentRequest currentDocument - */ - - /** - * Constructs a new DeleteDocumentRequest. - * @memberof google.firestore.v1 - * @classdesc Represents a DeleteDocumentRequest. - * @implements IDeleteDocumentRequest - * @constructor - * @param {google.firestore.v1.IDeleteDocumentRequest=} [properties] Properties to set - */ - function DeleteDocumentRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DeleteDocumentRequest name. - * @member {string} name - * @memberof google.firestore.v1.DeleteDocumentRequest - * @instance - */ - DeleteDocumentRequest.prototype.name = ""; - - /** - * DeleteDocumentRequest currentDocument. - * @member {google.firestore.v1.IPrecondition|null|undefined} currentDocument - * @memberof google.firestore.v1.DeleteDocumentRequest - * @instance - */ - DeleteDocumentRequest.prototype.currentDocument = null; - - return DeleteDocumentRequest; - })(); - - v1.BatchGetDocumentsRequest = (function() { - - /** - * Properties of a BatchGetDocumentsRequest. - * @memberof google.firestore.v1 - * @interface IBatchGetDocumentsRequest - * @property {string|null} [database] BatchGetDocumentsRequest database - * @property {Array.|null} [documents] BatchGetDocumentsRequest documents - * @property {google.firestore.v1.IDocumentMask|null} [mask] BatchGetDocumentsRequest mask - * @property {Uint8Array|null} [transaction] BatchGetDocumentsRequest transaction - * @property {google.firestore.v1.ITransactionOptions|null} [newTransaction] BatchGetDocumentsRequest newTransaction - * @property {google.protobuf.ITimestamp|null} [readTime] BatchGetDocumentsRequest readTime - */ - - /** - * Constructs a new BatchGetDocumentsRequest. - * @memberof google.firestore.v1 - * @classdesc Represents a BatchGetDocumentsRequest. - * @implements IBatchGetDocumentsRequest - * @constructor - * @param {google.firestore.v1.IBatchGetDocumentsRequest=} [properties] Properties to set - */ - function BatchGetDocumentsRequest(properties) { - this.documents = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BatchGetDocumentsRequest database. - * @member {string} database - * @memberof google.firestore.v1.BatchGetDocumentsRequest - * @instance - */ - BatchGetDocumentsRequest.prototype.database = ""; - - /** - * BatchGetDocumentsRequest documents. - * @member {Array.} documents - * @memberof google.firestore.v1.BatchGetDocumentsRequest - * @instance - */ - BatchGetDocumentsRequest.prototype.documents = $util.emptyArray; - - /** - * BatchGetDocumentsRequest mask. - * @member {google.firestore.v1.IDocumentMask|null|undefined} mask - * @memberof google.firestore.v1.BatchGetDocumentsRequest - * @instance - */ - BatchGetDocumentsRequest.prototype.mask = null; - - /** - * BatchGetDocumentsRequest transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1.BatchGetDocumentsRequest - * @instance - */ - BatchGetDocumentsRequest.prototype.transaction = $util.newBuffer([]); - - /** - * BatchGetDocumentsRequest newTransaction. - * @member {google.firestore.v1.ITransactionOptions|null|undefined} newTransaction - * @memberof google.firestore.v1.BatchGetDocumentsRequest - * @instance - */ - BatchGetDocumentsRequest.prototype.newTransaction = null; - - /** - * BatchGetDocumentsRequest readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1.BatchGetDocumentsRequest - * @instance - */ - BatchGetDocumentsRequest.prototype.readTime = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * BatchGetDocumentsRequest consistencySelector. - * @member {"transaction"|"newTransaction"|"readTime"|undefined} consistencySelector - * @memberof google.firestore.v1.BatchGetDocumentsRequest - * @instance - */ - Object.defineProperty(BatchGetDocumentsRequest.prototype, "consistencySelector", { - get: $util.oneOfGetter($oneOfFields = ["transaction", "newTransaction", "readTime"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return BatchGetDocumentsRequest; - })(); - - v1.BatchGetDocumentsResponse = (function() { - - /** - * Properties of a BatchGetDocumentsResponse. - * @memberof google.firestore.v1 - * @interface IBatchGetDocumentsResponse - * @property {google.firestore.v1.IDocument|null} [found] BatchGetDocumentsResponse found - * @property {string|null} [missing] BatchGetDocumentsResponse missing - * @property {Uint8Array|null} [transaction] BatchGetDocumentsResponse transaction - * @property {google.protobuf.ITimestamp|null} [readTime] BatchGetDocumentsResponse readTime - */ - - /** - * Constructs a new BatchGetDocumentsResponse. - * @memberof google.firestore.v1 - * @classdesc Represents a BatchGetDocumentsResponse. - * @implements IBatchGetDocumentsResponse - * @constructor - * @param {google.firestore.v1.IBatchGetDocumentsResponse=} [properties] Properties to set - */ - function BatchGetDocumentsResponse(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BatchGetDocumentsResponse found. - * @member {google.firestore.v1.IDocument|null|undefined} found - * @memberof google.firestore.v1.BatchGetDocumentsResponse - * @instance - */ - BatchGetDocumentsResponse.prototype.found = null; - - /** - * BatchGetDocumentsResponse missing. - * @member {string} missing - * @memberof google.firestore.v1.BatchGetDocumentsResponse - * @instance - */ - BatchGetDocumentsResponse.prototype.missing = ""; - - /** - * BatchGetDocumentsResponse transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1.BatchGetDocumentsResponse - * @instance - */ - BatchGetDocumentsResponse.prototype.transaction = $util.newBuffer([]); - - /** - * BatchGetDocumentsResponse readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1.BatchGetDocumentsResponse - * @instance - */ - BatchGetDocumentsResponse.prototype.readTime = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * BatchGetDocumentsResponse result. - * @member {"found"|"missing"|undefined} result - * @memberof google.firestore.v1.BatchGetDocumentsResponse - * @instance - */ - Object.defineProperty(BatchGetDocumentsResponse.prototype, "result", { - get: $util.oneOfGetter($oneOfFields = ["found", "missing"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return BatchGetDocumentsResponse; - })(); - - v1.BeginTransactionRequest = (function() { - - /** - * Properties of a BeginTransactionRequest. - * @memberof google.firestore.v1 - * @interface IBeginTransactionRequest - * @property {string|null} [database] BeginTransactionRequest database - * @property {google.firestore.v1.ITransactionOptions|null} [options] BeginTransactionRequest options - */ - - /** - * Constructs a new BeginTransactionRequest. - * @memberof google.firestore.v1 - * @classdesc Represents a BeginTransactionRequest. - * @implements IBeginTransactionRequest - * @constructor - * @param {google.firestore.v1.IBeginTransactionRequest=} [properties] Properties to set - */ - function BeginTransactionRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BeginTransactionRequest database. - * @member {string} database - * @memberof google.firestore.v1.BeginTransactionRequest - * @instance - */ - BeginTransactionRequest.prototype.database = ""; - - /** - * BeginTransactionRequest options. - * @member {google.firestore.v1.ITransactionOptions|null|undefined} options - * @memberof google.firestore.v1.BeginTransactionRequest - * @instance - */ - BeginTransactionRequest.prototype.options = null; - - return BeginTransactionRequest; - })(); - - v1.BeginTransactionResponse = (function() { - - /** - * Properties of a BeginTransactionResponse. - * @memberof google.firestore.v1 - * @interface IBeginTransactionResponse - * @property {Uint8Array|null} [transaction] BeginTransactionResponse transaction - */ - - /** - * Constructs a new BeginTransactionResponse. - * @memberof google.firestore.v1 - * @classdesc Represents a BeginTransactionResponse. - * @implements IBeginTransactionResponse - * @constructor - * @param {google.firestore.v1.IBeginTransactionResponse=} [properties] Properties to set - */ - function BeginTransactionResponse(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BeginTransactionResponse transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1.BeginTransactionResponse - * @instance - */ - BeginTransactionResponse.prototype.transaction = $util.newBuffer([]); - - return BeginTransactionResponse; - })(); - - v1.CommitRequest = (function() { - - /** - * Properties of a CommitRequest. - * @memberof google.firestore.v1 - * @interface ICommitRequest - * @property {string|null} [database] CommitRequest database - * @property {Array.|null} [writes] CommitRequest writes - * @property {Uint8Array|null} [transaction] CommitRequest transaction - */ - - /** - * Constructs a new CommitRequest. - * @memberof google.firestore.v1 - * @classdesc Represents a CommitRequest. - * @implements ICommitRequest - * @constructor - * @param {google.firestore.v1.ICommitRequest=} [properties] Properties to set - */ - function CommitRequest(properties) { - this.writes = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * CommitRequest database. - * @member {string} database - * @memberof google.firestore.v1.CommitRequest - * @instance - */ - CommitRequest.prototype.database = ""; - - /** - * CommitRequest writes. - * @member {Array.} writes - * @memberof google.firestore.v1.CommitRequest - * @instance - */ - CommitRequest.prototype.writes = $util.emptyArray; - - /** - * CommitRequest transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1.CommitRequest - * @instance - */ - CommitRequest.prototype.transaction = $util.newBuffer([]); - - return CommitRequest; - })(); - - v1.CommitResponse = (function() { - - /** - * Properties of a CommitResponse. - * @memberof google.firestore.v1 - * @interface ICommitResponse - * @property {Array.|null} [writeResults] CommitResponse writeResults - * @property {google.protobuf.ITimestamp|null} [commitTime] CommitResponse commitTime - */ - - /** - * Constructs a new CommitResponse. - * @memberof google.firestore.v1 - * @classdesc Represents a CommitResponse. - * @implements ICommitResponse - * @constructor - * @param {google.firestore.v1.ICommitResponse=} [properties] Properties to set - */ - function CommitResponse(properties) { - this.writeResults = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * CommitResponse writeResults. - * @member {Array.} writeResults - * @memberof google.firestore.v1.CommitResponse - * @instance - */ - CommitResponse.prototype.writeResults = $util.emptyArray; - - /** - * CommitResponse commitTime. - * @member {google.protobuf.ITimestamp|null|undefined} commitTime - * @memberof google.firestore.v1.CommitResponse - * @instance - */ - CommitResponse.prototype.commitTime = null; - - return CommitResponse; - })(); - - v1.RollbackRequest = (function() { - - /** - * Properties of a RollbackRequest. - * @memberof google.firestore.v1 - * @interface IRollbackRequest - * @property {string|null} [database] RollbackRequest database - * @property {Uint8Array|null} [transaction] RollbackRequest transaction - */ - - /** - * Constructs a new RollbackRequest. - * @memberof google.firestore.v1 - * @classdesc Represents a RollbackRequest. - * @implements IRollbackRequest - * @constructor - * @param {google.firestore.v1.IRollbackRequest=} [properties] Properties to set - */ - function RollbackRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * RollbackRequest database. - * @member {string} database - * @memberof google.firestore.v1.RollbackRequest - * @instance - */ - RollbackRequest.prototype.database = ""; - - /** - * RollbackRequest transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1.RollbackRequest - * @instance - */ - RollbackRequest.prototype.transaction = $util.newBuffer([]); - - return RollbackRequest; - })(); - - v1.RunQueryRequest = (function() { - - /** - * Properties of a RunQueryRequest. - * @memberof google.firestore.v1 - * @interface IRunQueryRequest - * @property {string|null} [parent] RunQueryRequest parent - * @property {google.firestore.v1.IStructuredQuery|null} [structuredQuery] RunQueryRequest structuredQuery - * @property {Uint8Array|null} [transaction] RunQueryRequest transaction - * @property {google.firestore.v1.ITransactionOptions|null} [newTransaction] RunQueryRequest newTransaction - * @property {google.protobuf.ITimestamp|null} [readTime] RunQueryRequest readTime - */ - - /** - * Constructs a new RunQueryRequest. - * @memberof google.firestore.v1 - * @classdesc Represents a RunQueryRequest. - * @implements IRunQueryRequest - * @constructor - * @param {google.firestore.v1.IRunQueryRequest=} [properties] Properties to set - */ - function RunQueryRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * RunQueryRequest parent. - * @member {string} parent - * @memberof google.firestore.v1.RunQueryRequest - * @instance - */ - RunQueryRequest.prototype.parent = ""; - - /** - * RunQueryRequest structuredQuery. - * @member {google.firestore.v1.IStructuredQuery|null|undefined} structuredQuery - * @memberof google.firestore.v1.RunQueryRequest - * @instance - */ - RunQueryRequest.prototype.structuredQuery = null; - - /** - * RunQueryRequest transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1.RunQueryRequest - * @instance - */ - RunQueryRequest.prototype.transaction = $util.newBuffer([]); - - /** - * RunQueryRequest newTransaction. - * @member {google.firestore.v1.ITransactionOptions|null|undefined} newTransaction - * @memberof google.firestore.v1.RunQueryRequest - * @instance - */ - RunQueryRequest.prototype.newTransaction = null; - - /** - * RunQueryRequest readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1.RunQueryRequest - * @instance - */ - RunQueryRequest.prototype.readTime = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * RunQueryRequest queryType. - * @member {"structuredQuery"|undefined} queryType - * @memberof google.firestore.v1.RunQueryRequest - * @instance - */ - Object.defineProperty(RunQueryRequest.prototype, "queryType", { - get: $util.oneOfGetter($oneOfFields = ["structuredQuery"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * RunQueryRequest consistencySelector. - * @member {"transaction"|"newTransaction"|"readTime"|undefined} consistencySelector - * @memberof google.firestore.v1.RunQueryRequest - * @instance - */ - Object.defineProperty(RunQueryRequest.prototype, "consistencySelector", { - get: $util.oneOfGetter($oneOfFields = ["transaction", "newTransaction", "readTime"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return RunQueryRequest; - })(); - - v1.RunQueryResponse = (function() { - - /** - * Properties of a RunQueryResponse. - * @memberof google.firestore.v1 - * @interface IRunQueryResponse - * @property {Uint8Array|null} [transaction] RunQueryResponse transaction - * @property {google.firestore.v1.IDocument|null} [document] RunQueryResponse document - * @property {google.protobuf.ITimestamp|null} [readTime] RunQueryResponse readTime - * @property {number|null} [skippedResults] RunQueryResponse skippedResults - */ - - /** - * Constructs a new RunQueryResponse. - * @memberof google.firestore.v1 - * @classdesc Represents a RunQueryResponse. - * @implements IRunQueryResponse - * @constructor - * @param {google.firestore.v1.IRunQueryResponse=} [properties] Properties to set - */ - function RunQueryResponse(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * RunQueryResponse transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1.RunQueryResponse - * @instance - */ - RunQueryResponse.prototype.transaction = $util.newBuffer([]); - - /** - * RunQueryResponse document. - * @member {google.firestore.v1.IDocument|null|undefined} document - * @memberof google.firestore.v1.RunQueryResponse - * @instance - */ - RunQueryResponse.prototype.document = null; - - /** - * RunQueryResponse readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1.RunQueryResponse - * @instance - */ - RunQueryResponse.prototype.readTime = null; - - /** - * RunQueryResponse skippedResults. - * @member {number} skippedResults - * @memberof google.firestore.v1.RunQueryResponse - * @instance - */ - RunQueryResponse.prototype.skippedResults = 0; - - return RunQueryResponse; - })(); - - v1.WriteRequest = (function() { - - /** - * Properties of a WriteRequest. - * @memberof google.firestore.v1 - * @interface IWriteRequest - * @property {string|null} [database] WriteRequest database - * @property {string|null} [streamId] WriteRequest streamId - * @property {Array.|null} [writes] WriteRequest writes - * @property {Uint8Array|null} [streamToken] WriteRequest streamToken - * @property {Object.|null} [labels] WriteRequest labels - */ - - /** - * Constructs a new WriteRequest. - * @memberof google.firestore.v1 - * @classdesc Represents a WriteRequest. - * @implements IWriteRequest - * @constructor - * @param {google.firestore.v1.IWriteRequest=} [properties] Properties to set - */ - function WriteRequest(properties) { - this.writes = []; - this.labels = {}; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * WriteRequest database. - * @member {string} database - * @memberof google.firestore.v1.WriteRequest - * @instance - */ - WriteRequest.prototype.database = ""; - - /** - * WriteRequest streamId. - * @member {string} streamId - * @memberof google.firestore.v1.WriteRequest - * @instance - */ - WriteRequest.prototype.streamId = ""; - - /** - * WriteRequest writes. - * @member {Array.} writes - * @memberof google.firestore.v1.WriteRequest - * @instance - */ - WriteRequest.prototype.writes = $util.emptyArray; - - /** - * WriteRequest streamToken. - * @member {Uint8Array} streamToken - * @memberof google.firestore.v1.WriteRequest - * @instance - */ - WriteRequest.prototype.streamToken = $util.newBuffer([]); - - /** - * WriteRequest labels. - * @member {Object.} labels - * @memberof google.firestore.v1.WriteRequest - * @instance - */ - WriteRequest.prototype.labels = $util.emptyObject; - - return WriteRequest; - })(); - - v1.WriteResponse = (function() { - - /** - * Properties of a WriteResponse. - * @memberof google.firestore.v1 - * @interface IWriteResponse - * @property {string|null} [streamId] WriteResponse streamId - * @property {Uint8Array|null} [streamToken] WriteResponse streamToken - * @property {Array.|null} [writeResults] WriteResponse writeResults - * @property {google.protobuf.ITimestamp|null} [commitTime] WriteResponse commitTime - */ - - /** - * Constructs a new WriteResponse. - * @memberof google.firestore.v1 - * @classdesc Represents a WriteResponse. - * @implements IWriteResponse - * @constructor - * @param {google.firestore.v1.IWriteResponse=} [properties] Properties to set - */ - function WriteResponse(properties) { - this.writeResults = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * WriteResponse streamId. - * @member {string} streamId - * @memberof google.firestore.v1.WriteResponse - * @instance - */ - WriteResponse.prototype.streamId = ""; - - /** - * WriteResponse streamToken. - * @member {Uint8Array} streamToken - * @memberof google.firestore.v1.WriteResponse - * @instance - */ - WriteResponse.prototype.streamToken = $util.newBuffer([]); - - /** - * WriteResponse writeResults. - * @member {Array.} writeResults - * @memberof google.firestore.v1.WriteResponse - * @instance - */ - WriteResponse.prototype.writeResults = $util.emptyArray; - - /** - * WriteResponse commitTime. - * @member {google.protobuf.ITimestamp|null|undefined} commitTime - * @memberof google.firestore.v1.WriteResponse - * @instance - */ - WriteResponse.prototype.commitTime = null; - - return WriteResponse; - })(); - - v1.ListenRequest = (function() { - - /** - * Properties of a ListenRequest. - * @memberof google.firestore.v1 - * @interface IListenRequest - * @property {string|null} [database] ListenRequest database - * @property {google.firestore.v1.ITarget|null} [addTarget] ListenRequest addTarget - * @property {number|null} [removeTarget] ListenRequest removeTarget - * @property {Object.|null} [labels] ListenRequest labels - */ - - /** - * Constructs a new ListenRequest. - * @memberof google.firestore.v1 - * @classdesc Represents a ListenRequest. - * @implements IListenRequest - * @constructor - * @param {google.firestore.v1.IListenRequest=} [properties] Properties to set - */ - function ListenRequest(properties) { - this.labels = {}; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListenRequest database. - * @member {string} database - * @memberof google.firestore.v1.ListenRequest - * @instance - */ - ListenRequest.prototype.database = ""; - - /** - * ListenRequest addTarget. - * @member {google.firestore.v1.ITarget|null|undefined} addTarget - * @memberof google.firestore.v1.ListenRequest - * @instance - */ - ListenRequest.prototype.addTarget = null; - - /** - * ListenRequest removeTarget. - * @member {number} removeTarget - * @memberof google.firestore.v1.ListenRequest - * @instance - */ - ListenRequest.prototype.removeTarget = 0; - - /** - * ListenRequest labels. - * @member {Object.} labels - * @memberof google.firestore.v1.ListenRequest - * @instance - */ - ListenRequest.prototype.labels = $util.emptyObject; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * ListenRequest targetChange. - * @member {"addTarget"|"removeTarget"|undefined} targetChange - * @memberof google.firestore.v1.ListenRequest - * @instance - */ - Object.defineProperty(ListenRequest.prototype, "targetChange", { - get: $util.oneOfGetter($oneOfFields = ["addTarget", "removeTarget"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return ListenRequest; - })(); - - v1.ListenResponse = (function() { - - /** - * Properties of a ListenResponse. - * @memberof google.firestore.v1 - * @interface IListenResponse - * @property {google.firestore.v1.ITargetChange|null} [targetChange] ListenResponse targetChange - * @property {google.firestore.v1.IDocumentChange|null} [documentChange] ListenResponse documentChange - * @property {google.firestore.v1.IDocumentDelete|null} [documentDelete] ListenResponse documentDelete - * @property {google.firestore.v1.IDocumentRemove|null} [documentRemove] ListenResponse documentRemove - * @property {google.firestore.v1.IExistenceFilter|null} [filter] ListenResponse filter - */ - - /** - * Constructs a new ListenResponse. - * @memberof google.firestore.v1 - * @classdesc Represents a ListenResponse. - * @implements IListenResponse - * @constructor - * @param {google.firestore.v1.IListenResponse=} [properties] Properties to set - */ - function ListenResponse(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListenResponse targetChange. - * @member {google.firestore.v1.ITargetChange|null|undefined} targetChange - * @memberof google.firestore.v1.ListenResponse - * @instance - */ - ListenResponse.prototype.targetChange = null; - - /** - * ListenResponse documentChange. - * @member {google.firestore.v1.IDocumentChange|null|undefined} documentChange - * @memberof google.firestore.v1.ListenResponse - * @instance - */ - ListenResponse.prototype.documentChange = null; - - /** - * ListenResponse documentDelete. - * @member {google.firestore.v1.IDocumentDelete|null|undefined} documentDelete - * @memberof google.firestore.v1.ListenResponse - * @instance - */ - ListenResponse.prototype.documentDelete = null; - - /** - * ListenResponse documentRemove. - * @member {google.firestore.v1.IDocumentRemove|null|undefined} documentRemove - * @memberof google.firestore.v1.ListenResponse - * @instance - */ - ListenResponse.prototype.documentRemove = null; - - /** - * ListenResponse filter. - * @member {google.firestore.v1.IExistenceFilter|null|undefined} filter - * @memberof google.firestore.v1.ListenResponse - * @instance - */ - ListenResponse.prototype.filter = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * ListenResponse responseType. - * @member {"targetChange"|"documentChange"|"documentDelete"|"documentRemove"|"filter"|undefined} responseType - * @memberof google.firestore.v1.ListenResponse - * @instance - */ - Object.defineProperty(ListenResponse.prototype, "responseType", { - get: $util.oneOfGetter($oneOfFields = ["targetChange", "documentChange", "documentDelete", "documentRemove", "filter"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return ListenResponse; - })(); - - v1.Target = (function() { - - /** - * Properties of a Target. - * @memberof google.firestore.v1 - * @interface ITarget - * @property {google.firestore.v1.Target.IQueryTarget|null} [query] Target query - * @property {google.firestore.v1.Target.IDocumentsTarget|null} [documents] Target documents - * @property {Uint8Array|null} [resumeToken] Target resumeToken - * @property {google.protobuf.ITimestamp|null} [readTime] Target readTime - * @property {number|null} [targetId] Target targetId - * @property {boolean|null} [once] Target once - */ - - /** - * Constructs a new Target. - * @memberof google.firestore.v1 - * @classdesc Represents a Target. - * @implements ITarget - * @constructor - * @param {google.firestore.v1.ITarget=} [properties] Properties to set - */ - function Target(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Target query. - * @member {google.firestore.v1.Target.IQueryTarget|null|undefined} query - * @memberof google.firestore.v1.Target - * @instance - */ - Target.prototype.query = null; - - /** - * Target documents. - * @member {google.firestore.v1.Target.IDocumentsTarget|null|undefined} documents - * @memberof google.firestore.v1.Target - * @instance - */ - Target.prototype.documents = null; - - /** - * Target resumeToken. - * @member {Uint8Array} resumeToken - * @memberof google.firestore.v1.Target - * @instance - */ - Target.prototype.resumeToken = $util.newBuffer([]); - - /** - * Target readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1.Target - * @instance - */ - Target.prototype.readTime = null; - - /** - * Target targetId. - * @member {number} targetId - * @memberof google.firestore.v1.Target - * @instance - */ - Target.prototype.targetId = 0; - - /** - * Target once. - * @member {boolean} once - * @memberof google.firestore.v1.Target - * @instance - */ - Target.prototype.once = false; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Target targetType. - * @member {"query"|"documents"|undefined} targetType - * @memberof google.firestore.v1.Target - * @instance - */ - Object.defineProperty(Target.prototype, "targetType", { - get: $util.oneOfGetter($oneOfFields = ["query", "documents"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * Target resumeType. - * @member {"resumeToken"|"readTime"|undefined} resumeType - * @memberof google.firestore.v1.Target - * @instance - */ - Object.defineProperty(Target.prototype, "resumeType", { - get: $util.oneOfGetter($oneOfFields = ["resumeToken", "readTime"]), - set: $util.oneOfSetter($oneOfFields) - }); - - Target.DocumentsTarget = (function() { - - /** - * Properties of a DocumentsTarget. - * @memberof google.firestore.v1.Target - * @interface IDocumentsTarget - * @property {Array.|null} [documents] DocumentsTarget documents - */ - - /** - * Constructs a new DocumentsTarget. - * @memberof google.firestore.v1.Target - * @classdesc Represents a DocumentsTarget. - * @implements IDocumentsTarget - * @constructor - * @param {google.firestore.v1.Target.IDocumentsTarget=} [properties] Properties to set - */ - function DocumentsTarget(properties) { - this.documents = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DocumentsTarget documents. - * @member {Array.} documents - * @memberof google.firestore.v1.Target.DocumentsTarget - * @instance - */ - DocumentsTarget.prototype.documents = $util.emptyArray; - - return DocumentsTarget; - })(); - - Target.QueryTarget = (function() { - - /** - * Properties of a QueryTarget. - * @memberof google.firestore.v1.Target - * @interface IQueryTarget - * @property {string|null} [parent] QueryTarget parent - * @property {google.firestore.v1.IStructuredQuery|null} [structuredQuery] QueryTarget structuredQuery - */ - - /** - * Constructs a new QueryTarget. - * @memberof google.firestore.v1.Target - * @classdesc Represents a QueryTarget. - * @implements IQueryTarget - * @constructor - * @param {google.firestore.v1.Target.IQueryTarget=} [properties] Properties to set - */ - function QueryTarget(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * QueryTarget parent. - * @member {string} parent - * @memberof google.firestore.v1.Target.QueryTarget - * @instance - */ - QueryTarget.prototype.parent = ""; - - /** - * QueryTarget structuredQuery. - * @member {google.firestore.v1.IStructuredQuery|null|undefined} structuredQuery - * @memberof google.firestore.v1.Target.QueryTarget - * @instance - */ - QueryTarget.prototype.structuredQuery = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * QueryTarget queryType. - * @member {"structuredQuery"|undefined} queryType - * @memberof google.firestore.v1.Target.QueryTarget - * @instance - */ - Object.defineProperty(QueryTarget.prototype, "queryType", { - get: $util.oneOfGetter($oneOfFields = ["structuredQuery"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return QueryTarget; - })(); - - return Target; - })(); - - v1.TargetChange = (function() { - - /** - * Properties of a TargetChange. - * @memberof google.firestore.v1 - * @interface ITargetChange - * @property {google.firestore.v1.TargetChange.TargetChangeType|null} [targetChangeType] TargetChange targetChangeType - * @property {Array.|null} [targetIds] TargetChange targetIds - * @property {google.rpc.IStatus|null} [cause] TargetChange cause - * @property {Uint8Array|null} [resumeToken] TargetChange resumeToken - * @property {google.protobuf.ITimestamp|null} [readTime] TargetChange readTime - */ - - /** - * Constructs a new TargetChange. - * @memberof google.firestore.v1 - * @classdesc Represents a TargetChange. - * @implements ITargetChange - * @constructor - * @param {google.firestore.v1.ITargetChange=} [properties] Properties to set - */ - function TargetChange(properties) { - this.targetIds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * TargetChange targetChangeType. - * @member {google.firestore.v1.TargetChange.TargetChangeType} targetChangeType - * @memberof google.firestore.v1.TargetChange - * @instance - */ - TargetChange.prototype.targetChangeType = 0; - - /** - * TargetChange targetIds. - * @member {Array.} targetIds - * @memberof google.firestore.v1.TargetChange - * @instance - */ - TargetChange.prototype.targetIds = $util.emptyArray; - - /** - * TargetChange cause. - * @member {google.rpc.IStatus|null|undefined} cause - * @memberof google.firestore.v1.TargetChange - * @instance - */ - TargetChange.prototype.cause = null; - - /** - * TargetChange resumeToken. - * @member {Uint8Array} resumeToken - * @memberof google.firestore.v1.TargetChange - * @instance - */ - TargetChange.prototype.resumeToken = $util.newBuffer([]); - - /** - * TargetChange readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1.TargetChange - * @instance - */ - TargetChange.prototype.readTime = null; - - /** - * TargetChangeType enum. - * @name google.firestore.v1.TargetChange.TargetChangeType - * @enum {number} - * @property {string} NO_CHANGE=NO_CHANGE NO_CHANGE value - * @property {string} ADD=ADD ADD value - * @property {string} REMOVE=REMOVE REMOVE value - * @property {string} CURRENT=CURRENT CURRENT value - * @property {string} RESET=RESET RESET value - */ - TargetChange.TargetChangeType = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "NO_CHANGE"] = "NO_CHANGE"; - values[valuesById[1] = "ADD"] = "ADD"; - values[valuesById[2] = "REMOVE"] = "REMOVE"; - values[valuesById[3] = "CURRENT"] = "CURRENT"; - values[valuesById[4] = "RESET"] = "RESET"; - return values; - })(); - - return TargetChange; - })(); - - v1.ListCollectionIdsRequest = (function() { - - /** - * Properties of a ListCollectionIdsRequest. - * @memberof google.firestore.v1 - * @interface IListCollectionIdsRequest - * @property {string|null} [parent] ListCollectionIdsRequest parent - * @property {number|null} [pageSize] ListCollectionIdsRequest pageSize - * @property {string|null} [pageToken] ListCollectionIdsRequest pageToken - */ - - /** - * Constructs a new ListCollectionIdsRequest. - * @memberof google.firestore.v1 - * @classdesc Represents a ListCollectionIdsRequest. - * @implements IListCollectionIdsRequest - * @constructor - * @param {google.firestore.v1.IListCollectionIdsRequest=} [properties] Properties to set - */ - function ListCollectionIdsRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListCollectionIdsRequest parent. - * @member {string} parent - * @memberof google.firestore.v1.ListCollectionIdsRequest - * @instance - */ - ListCollectionIdsRequest.prototype.parent = ""; - - /** - * ListCollectionIdsRequest pageSize. - * @member {number} pageSize - * @memberof google.firestore.v1.ListCollectionIdsRequest - * @instance - */ - ListCollectionIdsRequest.prototype.pageSize = 0; - - /** - * ListCollectionIdsRequest pageToken. - * @member {string} pageToken - * @memberof google.firestore.v1.ListCollectionIdsRequest - * @instance - */ - ListCollectionIdsRequest.prototype.pageToken = ""; - - return ListCollectionIdsRequest; - })(); - - v1.ListCollectionIdsResponse = (function() { - - /** - * Properties of a ListCollectionIdsResponse. - * @memberof google.firestore.v1 - * @interface IListCollectionIdsResponse - * @property {Array.|null} [collectionIds] ListCollectionIdsResponse collectionIds - * @property {string|null} [nextPageToken] ListCollectionIdsResponse nextPageToken - */ - - /** - * Constructs a new ListCollectionIdsResponse. - * @memberof google.firestore.v1 - * @classdesc Represents a ListCollectionIdsResponse. - * @implements IListCollectionIdsResponse - * @constructor - * @param {google.firestore.v1.IListCollectionIdsResponse=} [properties] Properties to set - */ - function ListCollectionIdsResponse(properties) { - this.collectionIds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListCollectionIdsResponse collectionIds. - * @member {Array.} collectionIds - * @memberof google.firestore.v1.ListCollectionIdsResponse - * @instance - */ - ListCollectionIdsResponse.prototype.collectionIds = $util.emptyArray; - - /** - * ListCollectionIdsResponse nextPageToken. - * @member {string} nextPageToken - * @memberof google.firestore.v1.ListCollectionIdsResponse - * @instance - */ - ListCollectionIdsResponse.prototype.nextPageToken = ""; - - return ListCollectionIdsResponse; - })(); - - v1.BatchWriteRequest = (function() { - - /** - * Properties of a BatchWriteRequest. - * @memberof google.firestore.v1 - * @interface IBatchWriteRequest - * @property {string|null} [database] BatchWriteRequest database - * @property {Array.|null} [writes] BatchWriteRequest writes - */ - - /** - * Constructs a new BatchWriteRequest. - * @memberof google.firestore.v1 - * @classdesc Represents a BatchWriteRequest. - * @implements IBatchWriteRequest - * @constructor - * @param {google.firestore.v1.IBatchWriteRequest=} [properties] Properties to set - */ - function BatchWriteRequest(properties) { - this.writes = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BatchWriteRequest database. - * @member {string} database - * @memberof google.firestore.v1.BatchWriteRequest - * @instance - */ - BatchWriteRequest.prototype.database = ""; - - /** - * BatchWriteRequest writes. - * @member {Array.} writes - * @memberof google.firestore.v1.BatchWriteRequest - * @instance - */ - BatchWriteRequest.prototype.writes = $util.emptyArray; - - return BatchWriteRequest; - })(); - - v1.BatchWriteResponse = (function() { - - /** - * Properties of a BatchWriteResponse. - * @memberof google.firestore.v1 - * @interface IBatchWriteResponse - * @property {Array.|null} [writeResults] BatchWriteResponse writeResults - * @property {Array.|null} [status] BatchWriteResponse status - */ - - /** - * Constructs a new BatchWriteResponse. - * @memberof google.firestore.v1 - * @classdesc Represents a BatchWriteResponse. - * @implements IBatchWriteResponse - * @constructor - * @param {google.firestore.v1.IBatchWriteResponse=} [properties] Properties to set - */ - function BatchWriteResponse(properties) { - this.writeResults = []; - this.status = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BatchWriteResponse writeResults. - * @member {Array.} writeResults - * @memberof google.firestore.v1.BatchWriteResponse - * @instance - */ - BatchWriteResponse.prototype.writeResults = $util.emptyArray; - - /** - * BatchWriteResponse status. - * @member {Array.} status - * @memberof google.firestore.v1.BatchWriteResponse - * @instance - */ - BatchWriteResponse.prototype.status = $util.emptyArray; - - return BatchWriteResponse; - })(); - - v1.StructuredQuery = (function() { - - /** - * Properties of a StructuredQuery. - * @memberof google.firestore.v1 - * @interface IStructuredQuery - * @property {google.firestore.v1.StructuredQuery.IProjection|null} [select] StructuredQuery select - * @property {Array.|null} [from] StructuredQuery from - * @property {google.firestore.v1.StructuredQuery.IFilter|null} [where] StructuredQuery where - * @property {Array.|null} [orderBy] StructuredQuery orderBy - * @property {google.firestore.v1.ICursor|null} [startAt] StructuredQuery startAt - * @property {google.firestore.v1.ICursor|null} [endAt] StructuredQuery endAt - * @property {number|null} [offset] StructuredQuery offset - * @property {google.protobuf.IInt32Value|null} [limit] StructuredQuery limit - */ - - /** - * Constructs a new StructuredQuery. - * @memberof google.firestore.v1 - * @classdesc Represents a StructuredQuery. - * @implements IStructuredQuery - * @constructor - * @param {google.firestore.v1.IStructuredQuery=} [properties] Properties to set - */ - function StructuredQuery(properties) { - this.from = []; - this.orderBy = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * StructuredQuery select. - * @member {google.firestore.v1.StructuredQuery.IProjection|null|undefined} select - * @memberof google.firestore.v1.StructuredQuery - * @instance - */ - StructuredQuery.prototype.select = null; - - /** - * StructuredQuery from. - * @member {Array.} from - * @memberof google.firestore.v1.StructuredQuery - * @instance - */ - StructuredQuery.prototype.from = $util.emptyArray; - - /** - * StructuredQuery where. - * @member {google.firestore.v1.StructuredQuery.IFilter|null|undefined} where - * @memberof google.firestore.v1.StructuredQuery - * @instance - */ - StructuredQuery.prototype.where = null; - - /** - * StructuredQuery orderBy. - * @member {Array.} orderBy - * @memberof google.firestore.v1.StructuredQuery - * @instance - */ - StructuredQuery.prototype.orderBy = $util.emptyArray; - - /** - * StructuredQuery startAt. - * @member {google.firestore.v1.ICursor|null|undefined} startAt - * @memberof google.firestore.v1.StructuredQuery - * @instance - */ - StructuredQuery.prototype.startAt = null; - - /** - * StructuredQuery endAt. - * @member {google.firestore.v1.ICursor|null|undefined} endAt - * @memberof google.firestore.v1.StructuredQuery - * @instance - */ - StructuredQuery.prototype.endAt = null; - - /** - * StructuredQuery offset. - * @member {number} offset - * @memberof google.firestore.v1.StructuredQuery - * @instance - */ - StructuredQuery.prototype.offset = 0; - - /** - * StructuredQuery limit. - * @member {google.protobuf.IInt32Value|null|undefined} limit - * @memberof google.firestore.v1.StructuredQuery - * @instance - */ - StructuredQuery.prototype.limit = null; - - StructuredQuery.CollectionSelector = (function() { - - /** - * Properties of a CollectionSelector. - * @memberof google.firestore.v1.StructuredQuery - * @interface ICollectionSelector - * @property {string|null} [collectionId] CollectionSelector collectionId - * @property {boolean|null} [allDescendants] CollectionSelector allDescendants - */ - - /** - * Constructs a new CollectionSelector. - * @memberof google.firestore.v1.StructuredQuery - * @classdesc Represents a CollectionSelector. - * @implements ICollectionSelector - * @constructor - * @param {google.firestore.v1.StructuredQuery.ICollectionSelector=} [properties] Properties to set - */ - function CollectionSelector(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * CollectionSelector collectionId. - * @member {string} collectionId - * @memberof google.firestore.v1.StructuredQuery.CollectionSelector - * @instance - */ - CollectionSelector.prototype.collectionId = ""; - - /** - * CollectionSelector allDescendants. - * @member {boolean} allDescendants - * @memberof google.firestore.v1.StructuredQuery.CollectionSelector - * @instance - */ - CollectionSelector.prototype.allDescendants = false; - - return CollectionSelector; - })(); - - StructuredQuery.Filter = (function() { - - /** - * Properties of a Filter. - * @memberof google.firestore.v1.StructuredQuery - * @interface IFilter - * @property {google.firestore.v1.StructuredQuery.ICompositeFilter|null} [compositeFilter] Filter compositeFilter - * @property {google.firestore.v1.StructuredQuery.IFieldFilter|null} [fieldFilter] Filter fieldFilter - * @property {google.firestore.v1.StructuredQuery.IUnaryFilter|null} [unaryFilter] Filter unaryFilter - */ - - /** - * Constructs a new Filter. - * @memberof google.firestore.v1.StructuredQuery - * @classdesc Represents a Filter. - * @implements IFilter - * @constructor - * @param {google.firestore.v1.StructuredQuery.IFilter=} [properties] Properties to set - */ - function Filter(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Filter compositeFilter. - * @member {google.firestore.v1.StructuredQuery.ICompositeFilter|null|undefined} compositeFilter - * @memberof google.firestore.v1.StructuredQuery.Filter - * @instance - */ - Filter.prototype.compositeFilter = null; - - /** - * Filter fieldFilter. - * @member {google.firestore.v1.StructuredQuery.IFieldFilter|null|undefined} fieldFilter - * @memberof google.firestore.v1.StructuredQuery.Filter - * @instance - */ - Filter.prototype.fieldFilter = null; - - /** - * Filter unaryFilter. - * @member {google.firestore.v1.StructuredQuery.IUnaryFilter|null|undefined} unaryFilter - * @memberof google.firestore.v1.StructuredQuery.Filter - * @instance - */ - Filter.prototype.unaryFilter = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Filter filterType. - * @member {"compositeFilter"|"fieldFilter"|"unaryFilter"|undefined} filterType - * @memberof google.firestore.v1.StructuredQuery.Filter - * @instance - */ - Object.defineProperty(Filter.prototype, "filterType", { - get: $util.oneOfGetter($oneOfFields = ["compositeFilter", "fieldFilter", "unaryFilter"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return Filter; - })(); - - StructuredQuery.CompositeFilter = (function() { - - /** - * Properties of a CompositeFilter. - * @memberof google.firestore.v1.StructuredQuery - * @interface ICompositeFilter - * @property {google.firestore.v1.StructuredQuery.CompositeFilter.Operator|null} [op] CompositeFilter op - * @property {Array.|null} [filters] CompositeFilter filters - */ - - /** - * Constructs a new CompositeFilter. - * @memberof google.firestore.v1.StructuredQuery - * @classdesc Represents a CompositeFilter. - * @implements ICompositeFilter - * @constructor - * @param {google.firestore.v1.StructuredQuery.ICompositeFilter=} [properties] Properties to set - */ - function CompositeFilter(properties) { - this.filters = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * CompositeFilter op. - * @member {google.firestore.v1.StructuredQuery.CompositeFilter.Operator} op - * @memberof google.firestore.v1.StructuredQuery.CompositeFilter - * @instance - */ - CompositeFilter.prototype.op = 0; - - /** - * CompositeFilter filters. - * @member {Array.} filters - * @memberof google.firestore.v1.StructuredQuery.CompositeFilter - * @instance - */ - CompositeFilter.prototype.filters = $util.emptyArray; - - /** - * Operator enum. - * @name google.firestore.v1.StructuredQuery.CompositeFilter.Operator - * @enum {number} - * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value - * @property {string} AND=AND AND value - */ - CompositeFilter.Operator = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; - values[valuesById[1] = "AND"] = "AND"; - return values; - })(); - - return CompositeFilter; - })(); - - StructuredQuery.FieldFilter = (function() { - - /** - * Properties of a FieldFilter. - * @memberof google.firestore.v1.StructuredQuery - * @interface IFieldFilter - * @property {google.firestore.v1.StructuredQuery.IFieldReference|null} [field] FieldFilter field - * @property {google.firestore.v1.StructuredQuery.FieldFilter.Operator|null} [op] FieldFilter op - * @property {google.firestore.v1.IValue|null} [value] FieldFilter value - */ - - /** - * Constructs a new FieldFilter. - * @memberof google.firestore.v1.StructuredQuery - * @classdesc Represents a FieldFilter. - * @implements IFieldFilter - * @constructor - * @param {google.firestore.v1.StructuredQuery.IFieldFilter=} [properties] Properties to set - */ - function FieldFilter(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FieldFilter field. - * @member {google.firestore.v1.StructuredQuery.IFieldReference|null|undefined} field - * @memberof google.firestore.v1.StructuredQuery.FieldFilter - * @instance - */ - FieldFilter.prototype.field = null; - - /** - * FieldFilter op. - * @member {google.firestore.v1.StructuredQuery.FieldFilter.Operator} op - * @memberof google.firestore.v1.StructuredQuery.FieldFilter - * @instance - */ - FieldFilter.prototype.op = 0; - - /** - * FieldFilter value. - * @member {google.firestore.v1.IValue|null|undefined} value - * @memberof google.firestore.v1.StructuredQuery.FieldFilter - * @instance - */ - FieldFilter.prototype.value = null; - - /** - * Operator enum. - * @name google.firestore.v1.StructuredQuery.FieldFilter.Operator - * @enum {number} - * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value - * @property {string} LESS_THAN=LESS_THAN LESS_THAN value - * @property {string} LESS_THAN_OR_EQUAL=LESS_THAN_OR_EQUAL LESS_THAN_OR_EQUAL value - * @property {string} GREATER_THAN=GREATER_THAN GREATER_THAN value - * @property {string} GREATER_THAN_OR_EQUAL=GREATER_THAN_OR_EQUAL GREATER_THAN_OR_EQUAL value - * @property {string} EQUAL=EQUAL EQUAL value - * @property {string} ARRAY_CONTAINS=ARRAY_CONTAINS ARRAY_CONTAINS value - * @property {string} IN=IN IN value - * @property {string} ARRAY_CONTAINS_ANY=ARRAY_CONTAINS_ANY ARRAY_CONTAINS_ANY value - */ - FieldFilter.Operator = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; - values[valuesById[1] = "LESS_THAN"] = "LESS_THAN"; - values[valuesById[2] = "LESS_THAN_OR_EQUAL"] = "LESS_THAN_OR_EQUAL"; - values[valuesById[3] = "GREATER_THAN"] = "GREATER_THAN"; - values[valuesById[4] = "GREATER_THAN_OR_EQUAL"] = "GREATER_THAN_OR_EQUAL"; - values[valuesById[5] = "EQUAL"] = "EQUAL"; - values[valuesById[7] = "ARRAY_CONTAINS"] = "ARRAY_CONTAINS"; - values[valuesById[8] = "IN"] = "IN"; - values[valuesById[9] = "ARRAY_CONTAINS_ANY"] = "ARRAY_CONTAINS_ANY"; - return values; - })(); - - return FieldFilter; - })(); - - StructuredQuery.Projection = (function() { - - /** - * Properties of a Projection. - * @memberof google.firestore.v1.StructuredQuery - * @interface IProjection - * @property {Array.|null} [fields] Projection fields - */ - - /** - * Constructs a new Projection. - * @memberof google.firestore.v1.StructuredQuery - * @classdesc Represents a Projection. - * @implements IProjection - * @constructor - * @param {google.firestore.v1.StructuredQuery.IProjection=} [properties] Properties to set - */ - function Projection(properties) { - this.fields = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Projection fields. - * @member {Array.} fields - * @memberof google.firestore.v1.StructuredQuery.Projection - * @instance - */ - Projection.prototype.fields = $util.emptyArray; - - return Projection; - })(); - - StructuredQuery.UnaryFilter = (function() { - - /** - * Properties of an UnaryFilter. - * @memberof google.firestore.v1.StructuredQuery - * @interface IUnaryFilter - * @property {google.firestore.v1.StructuredQuery.UnaryFilter.Operator|null} [op] UnaryFilter op - * @property {google.firestore.v1.StructuredQuery.IFieldReference|null} [field] UnaryFilter field - */ - - /** - * Constructs a new UnaryFilter. - * @memberof google.firestore.v1.StructuredQuery - * @classdesc Represents an UnaryFilter. - * @implements IUnaryFilter - * @constructor - * @param {google.firestore.v1.StructuredQuery.IUnaryFilter=} [properties] Properties to set - */ - function UnaryFilter(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * UnaryFilter op. - * @member {google.firestore.v1.StructuredQuery.UnaryFilter.Operator} op - * @memberof google.firestore.v1.StructuredQuery.UnaryFilter - * @instance - */ - UnaryFilter.prototype.op = 0; - - /** - * UnaryFilter field. - * @member {google.firestore.v1.StructuredQuery.IFieldReference|null|undefined} field - * @memberof google.firestore.v1.StructuredQuery.UnaryFilter - * @instance - */ - UnaryFilter.prototype.field = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * UnaryFilter operandType. - * @member {"field"|undefined} operandType - * @memberof google.firestore.v1.StructuredQuery.UnaryFilter - * @instance - */ - Object.defineProperty(UnaryFilter.prototype, "operandType", { - get: $util.oneOfGetter($oneOfFields = ["field"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * Operator enum. - * @name google.firestore.v1.StructuredQuery.UnaryFilter.Operator - * @enum {number} - * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value - * @property {string} IS_NAN=IS_NAN IS_NAN value - * @property {string} IS_NULL=IS_NULL IS_NULL value - */ - UnaryFilter.Operator = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; - values[valuesById[2] = "IS_NAN"] = "IS_NAN"; - values[valuesById[3] = "IS_NULL"] = "IS_NULL"; - return values; - })(); - - return UnaryFilter; - })(); - - StructuredQuery.FieldReference = (function() { - - /** - * Properties of a FieldReference. - * @memberof google.firestore.v1.StructuredQuery - * @interface IFieldReference - * @property {string|null} [fieldPath] FieldReference fieldPath - */ - - /** - * Constructs a new FieldReference. - * @memberof google.firestore.v1.StructuredQuery - * @classdesc Represents a FieldReference. - * @implements IFieldReference - * @constructor - * @param {google.firestore.v1.StructuredQuery.IFieldReference=} [properties] Properties to set - */ - function FieldReference(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FieldReference fieldPath. - * @member {string} fieldPath - * @memberof google.firestore.v1.StructuredQuery.FieldReference - * @instance - */ - FieldReference.prototype.fieldPath = ""; - - return FieldReference; - })(); - - StructuredQuery.Order = (function() { - - /** - * Properties of an Order. - * @memberof google.firestore.v1.StructuredQuery - * @interface IOrder - * @property {google.firestore.v1.StructuredQuery.IFieldReference|null} [field] Order field - * @property {google.firestore.v1.StructuredQuery.Direction|null} [direction] Order direction - */ - - /** - * Constructs a new Order. - * @memberof google.firestore.v1.StructuredQuery - * @classdesc Represents an Order. - * @implements IOrder - * @constructor - * @param {google.firestore.v1.StructuredQuery.IOrder=} [properties] Properties to set - */ - function Order(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Order field. - * @member {google.firestore.v1.StructuredQuery.IFieldReference|null|undefined} field - * @memberof google.firestore.v1.StructuredQuery.Order - * @instance - */ - Order.prototype.field = null; - - /** - * Order direction. - * @member {google.firestore.v1.StructuredQuery.Direction} direction - * @memberof google.firestore.v1.StructuredQuery.Order - * @instance - */ - Order.prototype.direction = 0; - - return Order; - })(); - - /** - * Direction enum. - * @name google.firestore.v1.StructuredQuery.Direction - * @enum {number} - * @property {string} DIRECTION_UNSPECIFIED=DIRECTION_UNSPECIFIED DIRECTION_UNSPECIFIED value - * @property {string} ASCENDING=ASCENDING ASCENDING value - * @property {string} DESCENDING=DESCENDING DESCENDING value - */ - StructuredQuery.Direction = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "DIRECTION_UNSPECIFIED"] = "DIRECTION_UNSPECIFIED"; - values[valuesById[1] = "ASCENDING"] = "ASCENDING"; - values[valuesById[2] = "DESCENDING"] = "DESCENDING"; - return values; - })(); - - return StructuredQuery; - })(); - - v1.Cursor = (function() { - - /** - * Properties of a Cursor. - * @memberof google.firestore.v1 - * @interface ICursor - * @property {Array.|null} [values] Cursor values - * @property {boolean|null} [before] Cursor before - */ - - /** - * Constructs a new Cursor. - * @memberof google.firestore.v1 - * @classdesc Represents a Cursor. - * @implements ICursor - * @constructor - * @param {google.firestore.v1.ICursor=} [properties] Properties to set - */ - function Cursor(properties) { - this.values = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Cursor values. - * @member {Array.} values - * @memberof google.firestore.v1.Cursor - * @instance - */ - Cursor.prototype.values = $util.emptyArray; - - /** - * Cursor before. - * @member {boolean} before - * @memberof google.firestore.v1.Cursor - * @instance - */ - Cursor.prototype.before = false; - - return Cursor; - })(); - - v1.Write = (function() { - - /** - * Properties of a Write. - * @memberof google.firestore.v1 - * @interface IWrite - * @property {google.firestore.v1.IDocument|null} [update] Write update - * @property {string|null} ["delete"] Write delete - * @property {google.firestore.v1.IDocumentTransform|null} [transform] Write transform - * @property {google.firestore.v1.IDocumentMask|null} [updateMask] Write updateMask - * @property {Array.|null} [updateTransforms] Write updateTransforms - * @property {google.firestore.v1.IPrecondition|null} [currentDocument] Write currentDocument - */ - - /** - * Constructs a new Write. - * @memberof google.firestore.v1 - * @classdesc Represents a Write. - * @implements IWrite - * @constructor - * @param {google.firestore.v1.IWrite=} [properties] Properties to set - */ - function Write(properties) { - this.updateTransforms = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Write update. - * @member {google.firestore.v1.IDocument|null|undefined} update - * @memberof google.firestore.v1.Write - * @instance - */ - Write.prototype.update = null; - - /** - * Write delete. - * @member {string} delete - * @memberof google.firestore.v1.Write - * @instance - */ - Write.prototype["delete"] = ""; - - /** - * Write transform. - * @member {google.firestore.v1.IDocumentTransform|null|undefined} transform - * @memberof google.firestore.v1.Write - * @instance - */ - Write.prototype.transform = null; - - /** - * Write updateMask. - * @member {google.firestore.v1.IDocumentMask|null|undefined} updateMask - * @memberof google.firestore.v1.Write - * @instance - */ - Write.prototype.updateMask = null; - - /** - * Write updateTransforms. - * @member {Array.} updateTransforms - * @memberof google.firestore.v1.Write - * @instance - */ - Write.prototype.updateTransforms = $util.emptyArray; - - /** - * Write currentDocument. - * @member {google.firestore.v1.IPrecondition|null|undefined} currentDocument - * @memberof google.firestore.v1.Write - * @instance - */ - Write.prototype.currentDocument = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Write operation. - * @member {"update"|"delete"|"transform"|undefined} operation - * @memberof google.firestore.v1.Write - * @instance - */ - Object.defineProperty(Write.prototype, "operation", { - get: $util.oneOfGetter($oneOfFields = ["update", "delete", "transform"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return Write; - })(); - - v1.DocumentTransform = (function() { - - /** - * Properties of a DocumentTransform. - * @memberof google.firestore.v1 - * @interface IDocumentTransform - * @property {string|null} [document] DocumentTransform document - * @property {Array.|null} [fieldTransforms] DocumentTransform fieldTransforms - */ - - /** - * Constructs a new DocumentTransform. - * @memberof google.firestore.v1 - * @classdesc Represents a DocumentTransform. - * @implements IDocumentTransform - * @constructor - * @param {google.firestore.v1.IDocumentTransform=} [properties] Properties to set - */ - function DocumentTransform(properties) { - this.fieldTransforms = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DocumentTransform document. - * @member {string} document - * @memberof google.firestore.v1.DocumentTransform - * @instance - */ - DocumentTransform.prototype.document = ""; - - /** - * DocumentTransform fieldTransforms. - * @member {Array.} fieldTransforms - * @memberof google.firestore.v1.DocumentTransform - * @instance - */ - DocumentTransform.prototype.fieldTransforms = $util.emptyArray; - - DocumentTransform.FieldTransform = (function() { - - /** - * Properties of a FieldTransform. - * @memberof google.firestore.v1.DocumentTransform - * @interface IFieldTransform - * @property {string|null} [fieldPath] FieldTransform fieldPath - * @property {google.firestore.v1.DocumentTransform.FieldTransform.ServerValue|null} [setToServerValue] FieldTransform setToServerValue - * @property {google.firestore.v1.IValue|null} [increment] FieldTransform increment - * @property {google.firestore.v1.IValue|null} [maximum] FieldTransform maximum - * @property {google.firestore.v1.IValue|null} [minimum] FieldTransform minimum - * @property {google.firestore.v1.IArrayValue|null} [appendMissingElements] FieldTransform appendMissingElements - * @property {google.firestore.v1.IArrayValue|null} [removeAllFromArray] FieldTransform removeAllFromArray - */ - - /** - * Constructs a new FieldTransform. - * @memberof google.firestore.v1.DocumentTransform - * @classdesc Represents a FieldTransform. - * @implements IFieldTransform - * @constructor - * @param {google.firestore.v1.DocumentTransform.IFieldTransform=} [properties] Properties to set - */ - function FieldTransform(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FieldTransform fieldPath. - * @member {string} fieldPath - * @memberof google.firestore.v1.DocumentTransform.FieldTransform - * @instance - */ - FieldTransform.prototype.fieldPath = ""; - - /** - * FieldTransform setToServerValue. - * @member {google.firestore.v1.DocumentTransform.FieldTransform.ServerValue} setToServerValue - * @memberof google.firestore.v1.DocumentTransform.FieldTransform - * @instance - */ - FieldTransform.prototype.setToServerValue = 0; - - /** - * FieldTransform increment. - * @member {google.firestore.v1.IValue|null|undefined} increment - * @memberof google.firestore.v1.DocumentTransform.FieldTransform - * @instance - */ - FieldTransform.prototype.increment = null; - - /** - * FieldTransform maximum. - * @member {google.firestore.v1.IValue|null|undefined} maximum - * @memberof google.firestore.v1.DocumentTransform.FieldTransform - * @instance - */ - FieldTransform.prototype.maximum = null; - - /** - * FieldTransform minimum. - * @member {google.firestore.v1.IValue|null|undefined} minimum - * @memberof google.firestore.v1.DocumentTransform.FieldTransform - * @instance - */ - FieldTransform.prototype.minimum = null; - - /** - * FieldTransform appendMissingElements. - * @member {google.firestore.v1.IArrayValue|null|undefined} appendMissingElements - * @memberof google.firestore.v1.DocumentTransform.FieldTransform - * @instance - */ - FieldTransform.prototype.appendMissingElements = null; - - /** - * FieldTransform removeAllFromArray. - * @member {google.firestore.v1.IArrayValue|null|undefined} removeAllFromArray - * @memberof google.firestore.v1.DocumentTransform.FieldTransform - * @instance - */ - FieldTransform.prototype.removeAllFromArray = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * FieldTransform transformType. - * @member {"setToServerValue"|"increment"|"maximum"|"minimum"|"appendMissingElements"|"removeAllFromArray"|undefined} transformType - * @memberof google.firestore.v1.DocumentTransform.FieldTransform - * @instance - */ - Object.defineProperty(FieldTransform.prototype, "transformType", { - get: $util.oneOfGetter($oneOfFields = ["setToServerValue", "increment", "maximum", "minimum", "appendMissingElements", "removeAllFromArray"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * ServerValue enum. - * @name google.firestore.v1.DocumentTransform.FieldTransform.ServerValue - * @enum {number} - * @property {string} SERVER_VALUE_UNSPECIFIED=SERVER_VALUE_UNSPECIFIED SERVER_VALUE_UNSPECIFIED value - * @property {string} REQUEST_TIME=REQUEST_TIME REQUEST_TIME value - */ - FieldTransform.ServerValue = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "SERVER_VALUE_UNSPECIFIED"] = "SERVER_VALUE_UNSPECIFIED"; - values[valuesById[1] = "REQUEST_TIME"] = "REQUEST_TIME"; - return values; - })(); - - return FieldTransform; - })(); - - return DocumentTransform; - })(); - - v1.WriteResult = (function() { - - /** - * Properties of a WriteResult. - * @memberof google.firestore.v1 - * @interface IWriteResult - * @property {google.protobuf.ITimestamp|null} [updateTime] WriteResult updateTime - * @property {Array.|null} [transformResults] WriteResult transformResults - */ - - /** - * Constructs a new WriteResult. - * @memberof google.firestore.v1 - * @classdesc Represents a WriteResult. - * @implements IWriteResult - * @constructor - * @param {google.firestore.v1.IWriteResult=} [properties] Properties to set - */ - function WriteResult(properties) { - this.transformResults = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * WriteResult updateTime. - * @member {google.protobuf.ITimestamp|null|undefined} updateTime - * @memberof google.firestore.v1.WriteResult - * @instance - */ - WriteResult.prototype.updateTime = null; - - /** - * WriteResult transformResults. - * @member {Array.} transformResults - * @memberof google.firestore.v1.WriteResult - * @instance - */ - WriteResult.prototype.transformResults = $util.emptyArray; - - return WriteResult; - })(); - - v1.DocumentChange = (function() { - - /** - * Properties of a DocumentChange. - * @memberof google.firestore.v1 - * @interface IDocumentChange - * @property {google.firestore.v1.IDocument|null} [document] DocumentChange document - * @property {Array.|null} [targetIds] DocumentChange targetIds - * @property {Array.|null} [removedTargetIds] DocumentChange removedTargetIds - */ - - /** - * Constructs a new DocumentChange. - * @memberof google.firestore.v1 - * @classdesc Represents a DocumentChange. - * @implements IDocumentChange - * @constructor - * @param {google.firestore.v1.IDocumentChange=} [properties] Properties to set - */ - function DocumentChange(properties) { - this.targetIds = []; - this.removedTargetIds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DocumentChange document. - * @member {google.firestore.v1.IDocument|null|undefined} document - * @memberof google.firestore.v1.DocumentChange - * @instance - */ - DocumentChange.prototype.document = null; - - /** - * DocumentChange targetIds. - * @member {Array.} targetIds - * @memberof google.firestore.v1.DocumentChange - * @instance - */ - DocumentChange.prototype.targetIds = $util.emptyArray; - - /** - * DocumentChange removedTargetIds. - * @member {Array.} removedTargetIds - * @memberof google.firestore.v1.DocumentChange - * @instance - */ - DocumentChange.prototype.removedTargetIds = $util.emptyArray; - - return DocumentChange; - })(); - - v1.DocumentDelete = (function() { - - /** - * Properties of a DocumentDelete. - * @memberof google.firestore.v1 - * @interface IDocumentDelete - * @property {string|null} [document] DocumentDelete document - * @property {Array.|null} [removedTargetIds] DocumentDelete removedTargetIds - * @property {google.protobuf.ITimestamp|null} [readTime] DocumentDelete readTime - */ - - /** - * Constructs a new DocumentDelete. - * @memberof google.firestore.v1 - * @classdesc Represents a DocumentDelete. - * @implements IDocumentDelete - * @constructor - * @param {google.firestore.v1.IDocumentDelete=} [properties] Properties to set - */ - function DocumentDelete(properties) { - this.removedTargetIds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DocumentDelete document. - * @member {string} document - * @memberof google.firestore.v1.DocumentDelete - * @instance - */ - DocumentDelete.prototype.document = ""; - - /** - * DocumentDelete removedTargetIds. - * @member {Array.} removedTargetIds - * @memberof google.firestore.v1.DocumentDelete - * @instance - */ - DocumentDelete.prototype.removedTargetIds = $util.emptyArray; - - /** - * DocumentDelete readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1.DocumentDelete - * @instance - */ - DocumentDelete.prototype.readTime = null; - - return DocumentDelete; - })(); - - v1.DocumentRemove = (function() { - - /** - * Properties of a DocumentRemove. - * @memberof google.firestore.v1 - * @interface IDocumentRemove - * @property {string|null} [document] DocumentRemove document - * @property {Array.|null} [removedTargetIds] DocumentRemove removedTargetIds - * @property {google.protobuf.ITimestamp|null} [readTime] DocumentRemove readTime - */ - - /** - * Constructs a new DocumentRemove. - * @memberof google.firestore.v1 - * @classdesc Represents a DocumentRemove. - * @implements IDocumentRemove - * @constructor - * @param {google.firestore.v1.IDocumentRemove=} [properties] Properties to set - */ - function DocumentRemove(properties) { - this.removedTargetIds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DocumentRemove document. - * @member {string} document - * @memberof google.firestore.v1.DocumentRemove - * @instance - */ - DocumentRemove.prototype.document = ""; - - /** - * DocumentRemove removedTargetIds. - * @member {Array.} removedTargetIds - * @memberof google.firestore.v1.DocumentRemove - * @instance - */ - DocumentRemove.prototype.removedTargetIds = $util.emptyArray; - - /** - * DocumentRemove readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1.DocumentRemove - * @instance - */ - DocumentRemove.prototype.readTime = null; - - return DocumentRemove; - })(); - - v1.ExistenceFilter = (function() { - - /** - * Properties of an ExistenceFilter. - * @memberof google.firestore.v1 - * @interface IExistenceFilter - * @property {number|null} [targetId] ExistenceFilter targetId - * @property {number|null} [count] ExistenceFilter count - */ - - /** - * Constructs a new ExistenceFilter. - * @memberof google.firestore.v1 - * @classdesc Represents an ExistenceFilter. - * @implements IExistenceFilter - * @constructor - * @param {google.firestore.v1.IExistenceFilter=} [properties] Properties to set - */ - function ExistenceFilter(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ExistenceFilter targetId. - * @member {number} targetId - * @memberof google.firestore.v1.ExistenceFilter - * @instance - */ - ExistenceFilter.prototype.targetId = 0; - - /** - * ExistenceFilter count. - * @member {number} count - * @memberof google.firestore.v1.ExistenceFilter - * @instance - */ - ExistenceFilter.prototype.count = 0; - - return ExistenceFilter; - })(); - - return v1; - })(); - - return firestore; - })(); - - google.api = (function() { - - /** - * Namespace api. - * @memberof google - * @namespace - */ - var api = {}; - - api.Http = (function() { - - /** - * Properties of a Http. - * @memberof google.api - * @interface IHttp - * @property {Array.|null} [rules] Http rules - */ - - /** - * Constructs a new Http. - * @memberof google.api - * @classdesc Represents a Http. - * @implements IHttp - * @constructor - * @param {google.api.IHttp=} [properties] Properties to set - */ - function Http(properties) { - this.rules = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Http rules. - * @member {Array.} rules - * @memberof google.api.Http - * @instance - */ - Http.prototype.rules = $util.emptyArray; - - return Http; - })(); - - api.HttpRule = (function() { - - /** - * Properties of a HttpRule. - * @memberof google.api - * @interface IHttpRule - * @property {string|null} [get] HttpRule get - * @property {string|null} [put] HttpRule put - * @property {string|null} [post] HttpRule post - * @property {string|null} ["delete"] HttpRule delete - * @property {string|null} [patch] HttpRule patch - * @property {google.api.ICustomHttpPattern|null} [custom] HttpRule custom - * @property {string|null} [selector] HttpRule selector - * @property {string|null} [body] HttpRule body - * @property {Array.|null} [additionalBindings] HttpRule additionalBindings - */ - - /** - * Constructs a new HttpRule. - * @memberof google.api - * @classdesc Represents a HttpRule. - * @implements IHttpRule - * @constructor - * @param {google.api.IHttpRule=} [properties] Properties to set - */ - function HttpRule(properties) { - this.additionalBindings = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * HttpRule get. - * @member {string} get - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.get = ""; - - /** - * HttpRule put. - * @member {string} put - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.put = ""; - - /** - * HttpRule post. - * @member {string} post - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.post = ""; - - /** - * HttpRule delete. - * @member {string} delete - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype["delete"] = ""; - - /** - * HttpRule patch. - * @member {string} patch - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.patch = ""; - - /** - * HttpRule custom. - * @member {google.api.ICustomHttpPattern|null|undefined} custom - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.custom = null; - - /** - * HttpRule selector. - * @member {string} selector - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.selector = ""; - - /** - * HttpRule body. - * @member {string} body - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.body = ""; - - /** - * HttpRule additionalBindings. - * @member {Array.} additionalBindings - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.additionalBindings = $util.emptyArray; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * HttpRule pattern. - * @member {"get"|"put"|"post"|"delete"|"patch"|"custom"|undefined} pattern - * @memberof google.api.HttpRule - * @instance - */ - Object.defineProperty(HttpRule.prototype, "pattern", { - get: $util.oneOfGetter($oneOfFields = ["get", "put", "post", "delete", "patch", "custom"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return HttpRule; - })(); - - api.CustomHttpPattern = (function() { - - /** - * Properties of a CustomHttpPattern. - * @memberof google.api - * @interface ICustomHttpPattern - * @property {string|null} [kind] CustomHttpPattern kind - * @property {string|null} [path] CustomHttpPattern path - */ - - /** - * Constructs a new CustomHttpPattern. - * @memberof google.api - * @classdesc Represents a CustomHttpPattern. - * @implements ICustomHttpPattern - * @constructor - * @param {google.api.ICustomHttpPattern=} [properties] Properties to set - */ - function CustomHttpPattern(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * CustomHttpPattern kind. - * @member {string} kind - * @memberof google.api.CustomHttpPattern - * @instance - */ - CustomHttpPattern.prototype.kind = ""; - - /** - * CustomHttpPattern path. - * @member {string} path - * @memberof google.api.CustomHttpPattern - * @instance - */ - CustomHttpPattern.prototype.path = ""; - - return CustomHttpPattern; - })(); - - /** - * FieldBehavior enum. - * @name google.api.FieldBehavior - * @enum {number} - * @property {string} FIELD_BEHAVIOR_UNSPECIFIED=FIELD_BEHAVIOR_UNSPECIFIED FIELD_BEHAVIOR_UNSPECIFIED value - * @property {string} OPTIONAL=OPTIONAL OPTIONAL value - * @property {string} REQUIRED=REQUIRED REQUIRED value - * @property {string} OUTPUT_ONLY=OUTPUT_ONLY OUTPUT_ONLY value - * @property {string} INPUT_ONLY=INPUT_ONLY INPUT_ONLY value - * @property {string} IMMUTABLE=IMMUTABLE IMMUTABLE value - */ - api.FieldBehavior = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "FIELD_BEHAVIOR_UNSPECIFIED"] = "FIELD_BEHAVIOR_UNSPECIFIED"; - values[valuesById[1] = "OPTIONAL"] = "OPTIONAL"; - values[valuesById[2] = "REQUIRED"] = "REQUIRED"; - values[valuesById[3] = "OUTPUT_ONLY"] = "OUTPUT_ONLY"; - values[valuesById[4] = "INPUT_ONLY"] = "INPUT_ONLY"; - values[valuesById[5] = "IMMUTABLE"] = "IMMUTABLE"; - return values; - })(); - - api.ResourceDescriptor = (function() { - - /** - * Properties of a ResourceDescriptor. - * @memberof google.api - * @interface IResourceDescriptor - * @property {string|null} [type] ResourceDescriptor type - * @property {Array.|null} [pattern] ResourceDescriptor pattern - * @property {string|null} [nameField] ResourceDescriptor nameField - * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history - * @property {string|null} [plural] ResourceDescriptor plural - * @property {string|null} [singular] ResourceDescriptor singular - */ - - /** - * Constructs a new ResourceDescriptor. - * @memberof google.api - * @classdesc Represents a ResourceDescriptor. - * @implements IResourceDescriptor - * @constructor - * @param {google.api.IResourceDescriptor=} [properties] Properties to set - */ - function ResourceDescriptor(properties) { - this.pattern = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ResourceDescriptor type. - * @member {string} type - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.type = ""; - - /** - * ResourceDescriptor pattern. - * @member {Array.} pattern - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.pattern = $util.emptyArray; - - /** - * ResourceDescriptor nameField. - * @member {string} nameField - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.nameField = ""; - - /** - * ResourceDescriptor history. - * @member {google.api.ResourceDescriptor.History} history - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.history = 0; - - /** - * ResourceDescriptor plural. - * @member {string} plural - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.plural = ""; - - /** - * ResourceDescriptor singular. - * @member {string} singular - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.singular = ""; - - /** - * History enum. - * @name google.api.ResourceDescriptor.History - * @enum {number} - * @property {string} HISTORY_UNSPECIFIED=HISTORY_UNSPECIFIED HISTORY_UNSPECIFIED value - * @property {string} ORIGINALLY_SINGLE_PATTERN=ORIGINALLY_SINGLE_PATTERN ORIGINALLY_SINGLE_PATTERN value - * @property {string} FUTURE_MULTI_PATTERN=FUTURE_MULTI_PATTERN FUTURE_MULTI_PATTERN value - */ - ResourceDescriptor.History = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "HISTORY_UNSPECIFIED"] = "HISTORY_UNSPECIFIED"; - values[valuesById[1] = "ORIGINALLY_SINGLE_PATTERN"] = "ORIGINALLY_SINGLE_PATTERN"; - values[valuesById[2] = "FUTURE_MULTI_PATTERN"] = "FUTURE_MULTI_PATTERN"; - return values; - })(); - - return ResourceDescriptor; - })(); - - api.ResourceReference = (function() { - - /** - * Properties of a ResourceReference. - * @memberof google.api - * @interface IResourceReference - * @property {string|null} [type] ResourceReference type - * @property {string|null} [childType] ResourceReference childType - */ - - /** - * Constructs a new ResourceReference. - * @memberof google.api - * @classdesc Represents a ResourceReference. - * @implements IResourceReference - * @constructor - * @param {google.api.IResourceReference=} [properties] Properties to set - */ - function ResourceReference(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ResourceReference type. - * @member {string} type - * @memberof google.api.ResourceReference - * @instance - */ - ResourceReference.prototype.type = ""; - - /** - * ResourceReference childType. - * @member {string} childType - * @memberof google.api.ResourceReference - * @instance - */ - ResourceReference.prototype.childType = ""; - - return ResourceReference; - })(); - - return api; - })(); - - google.type = (function() { - - /** - * Namespace type. - * @memberof google - * @namespace - */ - var type = {}; - - type.LatLng = (function() { - - /** - * Properties of a LatLng. - * @memberof google.type - * @interface ILatLng - * @property {number|null} [latitude] LatLng latitude - * @property {number|null} [longitude] LatLng longitude - */ - - /** - * Constructs a new LatLng. - * @memberof google.type - * @classdesc Represents a LatLng. - * @implements ILatLng - * @constructor - * @param {google.type.ILatLng=} [properties] Properties to set - */ - function LatLng(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * LatLng latitude. - * @member {number} latitude - * @memberof google.type.LatLng - * @instance - */ - LatLng.prototype.latitude = 0; - - /** - * LatLng longitude. - * @member {number} longitude - * @memberof google.type.LatLng - * @instance - */ - LatLng.prototype.longitude = 0; - - return LatLng; - })(); - - return type; - })(); - - google.rpc = (function() { - - /** - * Namespace rpc. - * @memberof google - * @namespace - */ - var rpc = {}; - - rpc.Status = (function() { - - /** - * Properties of a Status. - * @memberof google.rpc - * @interface IStatus - * @property {number|null} [code] Status code - * @property {string|null} [message] Status message - * @property {Array.|null} [details] Status details - */ - - /** - * Constructs a new Status. - * @memberof google.rpc - * @classdesc Represents a Status. - * @implements IStatus - * @constructor - * @param {google.rpc.IStatus=} [properties] Properties to set - */ - function Status(properties) { - this.details = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Status code. - * @member {number} code - * @memberof google.rpc.Status - * @instance - */ - Status.prototype.code = 0; - - /** - * Status message. - * @member {string} message - * @memberof google.rpc.Status - * @instance - */ - Status.prototype.message = ""; - - /** - * Status details. - * @member {Array.} details - * @memberof google.rpc.Status - * @instance - */ - Status.prototype.details = $util.emptyArray; - - return Status; - })(); - - return rpc; - })(); - - google.longrunning = (function() { - - /** - * Namespace longrunning. - * @memberof google - * @namespace - */ - var longrunning = {}; - - longrunning.Operations = (function() { - - /** - * Constructs a new Operations service. - * @memberof google.longrunning - * @classdesc Represents an Operations - * @extends $protobuf.rpc.Service - * @constructor - * @param {$protobuf.RPCImpl} rpcImpl RPC implementation - * @param {boolean} [requestDelimited=false] Whether requests are length-delimited - * @param {boolean} [responseDelimited=false] Whether responses are length-delimited - */ - function Operations(rpcImpl, requestDelimited, responseDelimited) { - $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); - } - - (Operations.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Operations; - - /** - * Callback as used by {@link google.longrunning.Operations#listOperations}. - * @memberof google.longrunning.Operations - * @typedef ListOperationsCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.longrunning.ListOperationsResponse} [response] ListOperationsResponse - */ - - /** - * Calls ListOperations. - * @function listOperations - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object - * @param {google.longrunning.Operations.ListOperationsCallback} callback Node-style callback called with the error, if any, and ListOperationsResponse - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Operations.prototype.listOperations = function listOperations(request, callback) { - return this.rpcCall(listOperations, $root.google.longrunning.ListOperationsRequest, $root.google.longrunning.ListOperationsResponse, request, callback); - }, "name", { value: "ListOperations" }); - - /** - * Calls ListOperations. - * @function listOperations - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.longrunning.Operations#getOperation}. - * @memberof google.longrunning.Operations - * @typedef GetOperationCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.longrunning.Operation} [response] Operation - */ - - /** - * Calls GetOperation. - * @function getOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object - * @param {google.longrunning.Operations.GetOperationCallback} callback Node-style callback called with the error, if any, and Operation - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Operations.prototype.getOperation = function getOperation(request, callback) { - return this.rpcCall(getOperation, $root.google.longrunning.GetOperationRequest, $root.google.longrunning.Operation, request, callback); - }, "name", { value: "GetOperation" }); - - /** - * Calls GetOperation. - * @function getOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.longrunning.Operations#deleteOperation}. - * @memberof google.longrunning.Operations - * @typedef DeleteOperationCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.protobuf.Empty} [response] Empty - */ - - /** - * Calls DeleteOperation. - * @function deleteOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object - * @param {google.longrunning.Operations.DeleteOperationCallback} callback Node-style callback called with the error, if any, and Empty - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Operations.prototype.deleteOperation = function deleteOperation(request, callback) { - return this.rpcCall(deleteOperation, $root.google.longrunning.DeleteOperationRequest, $root.google.protobuf.Empty, request, callback); - }, "name", { value: "DeleteOperation" }); - - /** - * Calls DeleteOperation. - * @function deleteOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.longrunning.Operations#cancelOperation}. - * @memberof google.longrunning.Operations - * @typedef CancelOperationCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.protobuf.Empty} [response] Empty - */ - - /** - * Calls CancelOperation. - * @function cancelOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object - * @param {google.longrunning.Operations.CancelOperationCallback} callback Node-style callback called with the error, if any, and Empty - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Operations.prototype.cancelOperation = function cancelOperation(request, callback) { - return this.rpcCall(cancelOperation, $root.google.longrunning.CancelOperationRequest, $root.google.protobuf.Empty, request, callback); - }, "name", { value: "CancelOperation" }); - - /** - * Calls CancelOperation. - * @function cancelOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.longrunning.Operations#waitOperation}. - * @memberof google.longrunning.Operations - * @typedef WaitOperationCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.longrunning.Operation} [response] Operation - */ - - /** - * Calls WaitOperation. - * @function waitOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object - * @param {google.longrunning.Operations.WaitOperationCallback} callback Node-style callback called with the error, if any, and Operation - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Operations.prototype.waitOperation = function waitOperation(request, callback) { - return this.rpcCall(waitOperation, $root.google.longrunning.WaitOperationRequest, $root.google.longrunning.Operation, request, callback); - }, "name", { value: "WaitOperation" }); - - /** - * Calls WaitOperation. - * @function waitOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - return Operations; - })(); - - longrunning.Operation = (function() { - - /** - * Properties of an Operation. - * @memberof google.longrunning - * @interface IOperation - * @property {string|null} [name] Operation name - * @property {google.protobuf.IAny|null} [metadata] Operation metadata - * @property {boolean|null} [done] Operation done - * @property {google.rpc.IStatus|null} [error] Operation error - * @property {google.protobuf.IAny|null} [response] Operation response - */ - - /** - * Constructs a new Operation. - * @memberof google.longrunning - * @classdesc Represents an Operation. - * @implements IOperation - * @constructor - * @param {google.longrunning.IOperation=} [properties] Properties to set - */ - function Operation(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Operation name. - * @member {string} name - * @memberof google.longrunning.Operation - * @instance - */ - Operation.prototype.name = ""; - - /** - * Operation metadata. - * @member {google.protobuf.IAny|null|undefined} metadata - * @memberof google.longrunning.Operation - * @instance - */ - Operation.prototype.metadata = null; - - /** - * Operation done. - * @member {boolean} done - * @memberof google.longrunning.Operation - * @instance - */ - Operation.prototype.done = false; - - /** - * Operation error. - * @member {google.rpc.IStatus|null|undefined} error - * @memberof google.longrunning.Operation - * @instance - */ - Operation.prototype.error = null; - - /** - * Operation response. - * @member {google.protobuf.IAny|null|undefined} response - * @memberof google.longrunning.Operation - * @instance - */ - Operation.prototype.response = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Operation result. - * @member {"error"|"response"|undefined} result - * @memberof google.longrunning.Operation - * @instance - */ - Object.defineProperty(Operation.prototype, "result", { - get: $util.oneOfGetter($oneOfFields = ["error", "response"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return Operation; - })(); - - longrunning.GetOperationRequest = (function() { - - /** - * Properties of a GetOperationRequest. - * @memberof google.longrunning - * @interface IGetOperationRequest - * @property {string|null} [name] GetOperationRequest name - */ - - /** - * Constructs a new GetOperationRequest. - * @memberof google.longrunning - * @classdesc Represents a GetOperationRequest. - * @implements IGetOperationRequest - * @constructor - * @param {google.longrunning.IGetOperationRequest=} [properties] Properties to set - */ - function GetOperationRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * GetOperationRequest name. - * @member {string} name - * @memberof google.longrunning.GetOperationRequest - * @instance - */ - GetOperationRequest.prototype.name = ""; - - return GetOperationRequest; - })(); - - longrunning.ListOperationsRequest = (function() { - - /** - * Properties of a ListOperationsRequest. - * @memberof google.longrunning - * @interface IListOperationsRequest - * @property {string|null} [name] ListOperationsRequest name - * @property {string|null} [filter] ListOperationsRequest filter - * @property {number|null} [pageSize] ListOperationsRequest pageSize - * @property {string|null} [pageToken] ListOperationsRequest pageToken - */ - - /** - * Constructs a new ListOperationsRequest. - * @memberof google.longrunning - * @classdesc Represents a ListOperationsRequest. - * @implements IListOperationsRequest - * @constructor - * @param {google.longrunning.IListOperationsRequest=} [properties] Properties to set - */ - function ListOperationsRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListOperationsRequest name. - * @member {string} name - * @memberof google.longrunning.ListOperationsRequest - * @instance - */ - ListOperationsRequest.prototype.name = ""; - - /** - * ListOperationsRequest filter. - * @member {string} filter - * @memberof google.longrunning.ListOperationsRequest - * @instance - */ - ListOperationsRequest.prototype.filter = ""; - - /** - * ListOperationsRequest pageSize. - * @member {number} pageSize - * @memberof google.longrunning.ListOperationsRequest - * @instance - */ - ListOperationsRequest.prototype.pageSize = 0; - - /** - * ListOperationsRequest pageToken. - * @member {string} pageToken - * @memberof google.longrunning.ListOperationsRequest - * @instance - */ - ListOperationsRequest.prototype.pageToken = ""; - - return ListOperationsRequest; - })(); - - longrunning.ListOperationsResponse = (function() { - - /** - * Properties of a ListOperationsResponse. - * @memberof google.longrunning - * @interface IListOperationsResponse - * @property {Array.|null} [operations] ListOperationsResponse operations - * @property {string|null} [nextPageToken] ListOperationsResponse nextPageToken - */ - - /** - * Constructs a new ListOperationsResponse. - * @memberof google.longrunning - * @classdesc Represents a ListOperationsResponse. - * @implements IListOperationsResponse - * @constructor - * @param {google.longrunning.IListOperationsResponse=} [properties] Properties to set - */ - function ListOperationsResponse(properties) { - this.operations = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListOperationsResponse operations. - * @member {Array.} operations - * @memberof google.longrunning.ListOperationsResponse - * @instance - */ - ListOperationsResponse.prototype.operations = $util.emptyArray; - - /** - * ListOperationsResponse nextPageToken. - * @member {string} nextPageToken - * @memberof google.longrunning.ListOperationsResponse - * @instance - */ - ListOperationsResponse.prototype.nextPageToken = ""; - - return ListOperationsResponse; - })(); - - longrunning.CancelOperationRequest = (function() { - - /** - * Properties of a CancelOperationRequest. - * @memberof google.longrunning - * @interface ICancelOperationRequest - * @property {string|null} [name] CancelOperationRequest name - */ - + + protobuf.FileDescriptorProto = (function() { + + /** + * Properties of a FileDescriptorProto. + * @memberof google.protobuf + * @interface IFileDescriptorProto + * @property {string|null} [name] FileDescriptorProto name + * @property {string|null} ["package"] FileDescriptorProto package + * @property {Array.|null} [dependency] FileDescriptorProto dependency + * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency + * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [messageType] FileDescriptorProto messageType + * @property {Array.|null} [enumType] FileDescriptorProto enumType + * @property {Array.|null} [service] FileDescriptorProto service + * @property {Array.|null} [extension] FileDescriptorProto extension + * @property {google.protobuf.IFileOptions|null} [options] FileDescriptorProto options + * @property {google.protobuf.ISourceCodeInfo|null} [sourceCodeInfo] FileDescriptorProto sourceCodeInfo + * @property {string|null} [syntax] FileDescriptorProto syntax + */ + + /** + * Constructs a new FileDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorProto. + * @implements IFileDescriptorProto + * @constructor + * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set + */ + function FileDescriptorProto(properties) { + this.dependency = []; + this.publicDependency = []; + this.weakDependency = []; + this.messageType = []; + this.enumType = []; + this.service = []; + this.extension = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FileDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.name = ""; + + /** + * FileDescriptorProto package. + * @member {string} package + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype["package"] = ""; + + /** + * FileDescriptorProto dependency. + * @member {Array.} dependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.dependency = $util.emptyArray; + + /** + * FileDescriptorProto publicDependency. + * @member {Array.} publicDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.publicDependency = $util.emptyArray; + + /** + * FileDescriptorProto weakDependency. + * @member {Array.} weakDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + + /** + * FileDescriptorProto messageType. + * @member {Array.} messageType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.messageType = $util.emptyArray; + + /** + * FileDescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.enumType = $util.emptyArray; + + /** + * FileDescriptorProto service. + * @member {Array.} service + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.service = $util.emptyArray; + + /** + * FileDescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.extension = $util.emptyArray; + + /** + * FileDescriptorProto options. + * @member {google.protobuf.IFileOptions|null|undefined} options + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.options = null; + + /** + * FileDescriptorProto sourceCodeInfo. + * @member {google.protobuf.ISourceCodeInfo|null|undefined} sourceCodeInfo + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.sourceCodeInfo = null; + + /** + * FileDescriptorProto syntax. + * @member {string} syntax + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.syntax = ""; + + /** + * Creates a FileDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + */ + FileDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileDescriptorProto) + return object; + var message = new $root.google.protobuf.FileDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object["package"] != null) + message["package"] = String(object["package"]); + if (object.dependency) { + if (!Array.isArray(object.dependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.dependency: array expected"); + message.dependency = []; + for (var i = 0; i < object.dependency.length; ++i) + message.dependency[i] = String(object.dependency[i]); + } + if (object.publicDependency) { + if (!Array.isArray(object.publicDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.publicDependency: array expected"); + message.publicDependency = []; + for (var i = 0; i < object.publicDependency.length; ++i) + message.publicDependency[i] = object.publicDependency[i] | 0; + } + if (object.weakDependency) { + if (!Array.isArray(object.weakDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.weakDependency: array expected"); + message.weakDependency = []; + for (var i = 0; i < object.weakDependency.length; ++i) + message.weakDependency[i] = object.weakDependency[i] | 0; + } + if (object.messageType) { + if (!Array.isArray(object.messageType)) + throw TypeError(".google.protobuf.FileDescriptorProto.messageType: array expected"); + message.messageType = []; + for (var i = 0; i < object.messageType.length; ++i) { + if (typeof object.messageType[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.messageType: object expected"); + message.messageType[i] = $root.google.protobuf.DescriptorProto.fromObject(object.messageType[i]); + } + } + if (object.enumType) { + if (!Array.isArray(object.enumType)) + throw TypeError(".google.protobuf.FileDescriptorProto.enumType: array expected"); + message.enumType = []; + for (var i = 0; i < object.enumType.length; ++i) { + if (typeof object.enumType[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.enumType: object expected"); + message.enumType[i] = $root.google.protobuf.EnumDescriptorProto.fromObject(object.enumType[i]); + } + } + if (object.service) { + if (!Array.isArray(object.service)) + throw TypeError(".google.protobuf.FileDescriptorProto.service: array expected"); + message.service = []; + for (var i = 0; i < object.service.length; ++i) { + if (typeof object.service[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.service: object expected"); + message.service[i] = $root.google.protobuf.ServiceDescriptorProto.fromObject(object.service[i]); + } + } + if (object.extension) { + if (!Array.isArray(object.extension)) + throw TypeError(".google.protobuf.FileDescriptorProto.extension: array expected"); + message.extension = []; + for (var i = 0; i < object.extension.length; ++i) { + if (typeof object.extension[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.extension: object expected"); + message.extension[i] = $root.google.protobuf.FieldDescriptorProto.fromObject(object.extension[i]); + } + } + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.FileOptions.fromObject(object.options); + } + if (object.sourceCodeInfo != null) { + if (typeof object.sourceCodeInfo !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.sourceCodeInfo: object expected"); + message.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.fromObject(object.sourceCodeInfo); + } + if (object.syntax != null) + message.syntax = String(object.syntax); + return message; + }; + + /** + * Creates a plain object from a FileDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.FileDescriptorProto} message FileDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.dependency = []; + object.messageType = []; + object.enumType = []; + object.service = []; + object.extension = []; + object.publicDependency = []; + object.weakDependency = []; + } + if (options.defaults) { + object.name = ""; + object["package"] = ""; + object.options = null; + object.sourceCodeInfo = null; + object.syntax = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message["package"] != null && message.hasOwnProperty("package")) + object["package"] = message["package"]; + if (message.dependency && message.dependency.length) { + object.dependency = []; + for (var j = 0; j < message.dependency.length; ++j) + object.dependency[j] = message.dependency[j]; + } + if (message.messageType && message.messageType.length) { + object.messageType = []; + for (var j = 0; j < message.messageType.length; ++j) + object.messageType[j] = $root.google.protobuf.DescriptorProto.toObject(message.messageType[j], options); + } + if (message.enumType && message.enumType.length) { + object.enumType = []; + for (var j = 0; j < message.enumType.length; ++j) + object.enumType[j] = $root.google.protobuf.EnumDescriptorProto.toObject(message.enumType[j], options); + } + if (message.service && message.service.length) { + object.service = []; + for (var j = 0; j < message.service.length; ++j) + object.service[j] = $root.google.protobuf.ServiceDescriptorProto.toObject(message.service[j], options); + } + if (message.extension && message.extension.length) { + object.extension = []; + for (var j = 0; j < message.extension.length; ++j) + object.extension[j] = $root.google.protobuf.FieldDescriptorProto.toObject(message.extension[j], options); + } + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.FileOptions.toObject(message.options, options); + if (message.sourceCodeInfo != null && message.hasOwnProperty("sourceCodeInfo")) + object.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.toObject(message.sourceCodeInfo, options); + if (message.publicDependency && message.publicDependency.length) { + object.publicDependency = []; + for (var j = 0; j < message.publicDependency.length; ++j) + object.publicDependency[j] = message.publicDependency[j]; + } + if (message.weakDependency && message.weakDependency.length) { + object.weakDependency = []; + for (var j = 0; j < message.weakDependency.length; ++j) + object.weakDependency[j] = message.weakDependency[j]; + } + if (message.syntax != null && message.hasOwnProperty("syntax")) + object.syntax = message.syntax; + return object; + }; + + /** + * Converts this FileDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.FileDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + FileDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FileDescriptorProto; + })(); + + protobuf.DescriptorProto = (function() { + + /** + * Properties of a DescriptorProto. + * @memberof google.protobuf + * @interface IDescriptorProto + * @property {string|null} [name] DescriptorProto name + * @property {Array.|null} [field] DescriptorProto field + * @property {Array.|null} [extension] DescriptorProto extension + * @property {Array.|null} [nestedType] DescriptorProto nestedType + * @property {Array.|null} [enumType] DescriptorProto enumType + * @property {Array.|null} [extensionRange] DescriptorProto extensionRange + * @property {Array.|null} [oneofDecl] DescriptorProto oneofDecl + * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options + * @property {Array.|null} [reservedRange] DescriptorProto reservedRange + * @property {Array.|null} [reservedName] DescriptorProto reservedName + */ + + /** + * Constructs a new DescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a DescriptorProto. + * @implements IDescriptorProto + * @constructor + * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set + */ + function DescriptorProto(properties) { + this.field = []; + this.extension = []; + this.nestedType = []; + this.enumType = []; + this.extensionRange = []; + this.oneofDecl = []; + this.reservedRange = []; + this.reservedName = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DescriptorProto name. + * @member {string} name + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.name = ""; + + /** + * DescriptorProto field. + * @member {Array.} field + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.field = $util.emptyArray; + + /** + * DescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extension = $util.emptyArray; + + /** + * DescriptorProto nestedType. + * @member {Array.} nestedType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.nestedType = $util.emptyArray; + + /** + * DescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.enumType = $util.emptyArray; + + /** + * DescriptorProto extensionRange. + * @member {Array.} extensionRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extensionRange = $util.emptyArray; + + /** + * DescriptorProto oneofDecl. + * @member {Array.} oneofDecl + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.oneofDecl = $util.emptyArray; + + /** + * DescriptorProto options. + * @member {google.protobuf.IMessageOptions|null|undefined} options + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.options = null; + + /** + * DescriptorProto reservedRange. + * @member {Array.} reservedRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedRange = $util.emptyArray; + + /** + * DescriptorProto reservedName. + * @member {Array.} reservedName + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedName = $util.emptyArray; + + /** + * Creates a DescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto} DescriptorProto + */ + DescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DescriptorProto) + return object; + var message = new $root.google.protobuf.DescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.field) { + if (!Array.isArray(object.field)) + throw TypeError(".google.protobuf.DescriptorProto.field: array expected"); + message.field = []; + for (var i = 0; i < object.field.length; ++i) { + if (typeof object.field[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.field: object expected"); + message.field[i] = $root.google.protobuf.FieldDescriptorProto.fromObject(object.field[i]); + } + } + if (object.extension) { + if (!Array.isArray(object.extension)) + throw TypeError(".google.protobuf.DescriptorProto.extension: array expected"); + message.extension = []; + for (var i = 0; i < object.extension.length; ++i) { + if (typeof object.extension[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.extension: object expected"); + message.extension[i] = $root.google.protobuf.FieldDescriptorProto.fromObject(object.extension[i]); + } + } + if (object.nestedType) { + if (!Array.isArray(object.nestedType)) + throw TypeError(".google.protobuf.DescriptorProto.nestedType: array expected"); + message.nestedType = []; + for (var i = 0; i < object.nestedType.length; ++i) { + if (typeof object.nestedType[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.nestedType: object expected"); + message.nestedType[i] = $root.google.protobuf.DescriptorProto.fromObject(object.nestedType[i]); + } + } + if (object.enumType) { + if (!Array.isArray(object.enumType)) + throw TypeError(".google.protobuf.DescriptorProto.enumType: array expected"); + message.enumType = []; + for (var i = 0; i < object.enumType.length; ++i) { + if (typeof object.enumType[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.enumType: object expected"); + message.enumType[i] = $root.google.protobuf.EnumDescriptorProto.fromObject(object.enumType[i]); + } + } + if (object.extensionRange) { + if (!Array.isArray(object.extensionRange)) + throw TypeError(".google.protobuf.DescriptorProto.extensionRange: array expected"); + message.extensionRange = []; + for (var i = 0; i < object.extensionRange.length; ++i) { + if (typeof object.extensionRange[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.extensionRange: object expected"); + message.extensionRange[i] = $root.google.protobuf.DescriptorProto.ExtensionRange.fromObject(object.extensionRange[i]); + } + } + if (object.oneofDecl) { + if (!Array.isArray(object.oneofDecl)) + throw TypeError(".google.protobuf.DescriptorProto.oneofDecl: array expected"); + message.oneofDecl = []; + for (var i = 0; i < object.oneofDecl.length; ++i) { + if (typeof object.oneofDecl[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.oneofDecl: object expected"); + message.oneofDecl[i] = $root.google.protobuf.OneofDescriptorProto.fromObject(object.oneofDecl[i]); + } + } + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.DescriptorProto.options: object expected"); + message.options = $root.google.protobuf.MessageOptions.fromObject(object.options); + } + if (object.reservedRange) { + if (!Array.isArray(object.reservedRange)) + throw TypeError(".google.protobuf.DescriptorProto.reservedRange: array expected"); + message.reservedRange = []; + for (var i = 0; i < object.reservedRange.length; ++i) { + if (typeof object.reservedRange[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.reservedRange: object expected"); + message.reservedRange[i] = $root.google.protobuf.DescriptorProto.ReservedRange.fromObject(object.reservedRange[i]); + } + } + if (object.reservedName) { + if (!Array.isArray(object.reservedName)) + throw TypeError(".google.protobuf.DescriptorProto.reservedName: array expected"); + message.reservedName = []; + for (var i = 0; i < object.reservedName.length; ++i) + message.reservedName[i] = String(object.reservedName[i]); + } + return message; + }; + + /** + * Creates a plain object from a DescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.DescriptorProto} message DescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.field = []; + object.nestedType = []; + object.enumType = []; + object.extensionRange = []; + object.extension = []; + object.oneofDecl = []; + object.reservedRange = []; + object.reservedName = []; + } + if (options.defaults) { + object.name = ""; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.field && message.field.length) { + object.field = []; + for (var j = 0; j < message.field.length; ++j) + object.field[j] = $root.google.protobuf.FieldDescriptorProto.toObject(message.field[j], options); + } + if (message.nestedType && message.nestedType.length) { + object.nestedType = []; + for (var j = 0; j < message.nestedType.length; ++j) + object.nestedType[j] = $root.google.protobuf.DescriptorProto.toObject(message.nestedType[j], options); + } + if (message.enumType && message.enumType.length) { + object.enumType = []; + for (var j = 0; j < message.enumType.length; ++j) + object.enumType[j] = $root.google.protobuf.EnumDescriptorProto.toObject(message.enumType[j], options); + } + if (message.extensionRange && message.extensionRange.length) { + object.extensionRange = []; + for (var j = 0; j < message.extensionRange.length; ++j) + object.extensionRange[j] = $root.google.protobuf.DescriptorProto.ExtensionRange.toObject(message.extensionRange[j], options); + } + if (message.extension && message.extension.length) { + object.extension = []; + for (var j = 0; j < message.extension.length; ++j) + object.extension[j] = $root.google.protobuf.FieldDescriptorProto.toObject(message.extension[j], options); + } + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.MessageOptions.toObject(message.options, options); + if (message.oneofDecl && message.oneofDecl.length) { + object.oneofDecl = []; + for (var j = 0; j < message.oneofDecl.length; ++j) + object.oneofDecl[j] = $root.google.protobuf.OneofDescriptorProto.toObject(message.oneofDecl[j], options); + } + if (message.reservedRange && message.reservedRange.length) { + object.reservedRange = []; + for (var j = 0; j < message.reservedRange.length; ++j) + object.reservedRange[j] = $root.google.protobuf.DescriptorProto.ReservedRange.toObject(message.reservedRange[j], options); + } + if (message.reservedName && message.reservedName.length) { + object.reservedName = []; + for (var j = 0; j < message.reservedName.length; ++j) + object.reservedName[j] = message.reservedName[j]; + } + return object; + }; + + /** + * Converts this DescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto + * @instance + * @returns {Object.} JSON object + */ + DescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + DescriptorProto.ExtensionRange = (function() { + + /** + * Properties of an ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @interface IExtensionRange + * @property {number|null} [start] ExtensionRange start + * @property {number|null} [end] ExtensionRange end + */ + + /** + * Constructs a new ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents an ExtensionRange. + * @implements IExtensionRange + * @constructor + * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set + */ + function ExtensionRange(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExtensionRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.start = 0; + + /** + * ExtensionRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.end = 0; + + /** + * Creates an ExtensionRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + */ + ExtensionRange.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DescriptorProto.ExtensionRange) + return object; + var message = new $root.google.protobuf.DescriptorProto.ExtensionRange(); + if (object.start != null) + message.start = object.start | 0; + if (object.end != null) + message.end = object.end | 0; + return message; + }; + + /** + * Creates a plain object from an ExtensionRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.ExtensionRange} message ExtensionRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExtensionRange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.start = 0; + object.end = 0; + } + if (message.start != null && message.hasOwnProperty("start")) + object.start = message.start; + if (message.end != null && message.hasOwnProperty("end")) + object.end = message.end; + return object; + }; + + /** + * Converts this ExtensionRange to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + * @returns {Object.} JSON object + */ + ExtensionRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ExtensionRange; + })(); + + DescriptorProto.ReservedRange = (function() { + + /** + * Properties of a ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @interface IReservedRange + * @property {number|null} [start] ReservedRange start + * @property {number|null} [end] ReservedRange end + */ + + /** + * Constructs a new ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents a ReservedRange. + * @implements IReservedRange + * @constructor + * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set + */ + function ReservedRange(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReservedRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.start = 0; + + /** + * ReservedRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.end = 0; + + /** + * Creates a ReservedRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + */ + ReservedRange.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DescriptorProto.ReservedRange) + return object; + var message = new $root.google.protobuf.DescriptorProto.ReservedRange(); + if (object.start != null) + message.start = object.start | 0; + if (object.end != null) + message.end = object.end | 0; + return message; + }; + + /** + * Creates a plain object from a ReservedRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.ReservedRange} message ReservedRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReservedRange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.start = 0; + object.end = 0; + } + if (message.start != null && message.hasOwnProperty("start")) + object.start = message.start; + if (message.end != null && message.hasOwnProperty("end")) + object.end = message.end; + return object; + }; + + /** + * Converts this ReservedRange to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + * @returns {Object.} JSON object + */ + ReservedRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ReservedRange; + })(); + + return DescriptorProto; + })(); + + protobuf.FieldDescriptorProto = (function() { + + /** + * Properties of a FieldDescriptorProto. + * @memberof google.protobuf + * @interface IFieldDescriptorProto + * @property {string|null} [name] FieldDescriptorProto name + * @property {number|null} [number] FieldDescriptorProto number + * @property {google.protobuf.FieldDescriptorProto.Label|null} [label] FieldDescriptorProto label + * @property {google.protobuf.FieldDescriptorProto.Type|null} [type] FieldDescriptorProto type + * @property {string|null} [typeName] FieldDescriptorProto typeName + * @property {string|null} [extendee] FieldDescriptorProto extendee + * @property {string|null} [defaultValue] FieldDescriptorProto defaultValue + * @property {number|null} [oneofIndex] FieldDescriptorProto oneofIndex + * @property {string|null} [jsonName] FieldDescriptorProto jsonName + * @property {google.protobuf.IFieldOptions|null} [options] FieldDescriptorProto options + */ + + /** + * Constructs a new FieldDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FieldDescriptorProto. + * @implements IFieldDescriptorProto + * @constructor + * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set + */ + function FieldDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.name = ""; + + /** + * FieldDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.number = 0; + + /** + * FieldDescriptorProto label. + * @member {google.protobuf.FieldDescriptorProto.Label} label + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.label = 1; + + /** + * FieldDescriptorProto type. + * @member {google.protobuf.FieldDescriptorProto.Type} type + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.type = 1; + + /** + * FieldDescriptorProto typeName. + * @member {string} typeName + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.typeName = ""; + + /** + * FieldDescriptorProto extendee. + * @member {string} extendee + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.extendee = ""; + + /** + * FieldDescriptorProto defaultValue. + * @member {string} defaultValue + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.defaultValue = ""; + + /** + * FieldDescriptorProto oneofIndex. + * @member {number} oneofIndex + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.oneofIndex = 0; + + /** + * FieldDescriptorProto jsonName. + * @member {string} jsonName + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.jsonName = ""; + + /** + * FieldDescriptorProto options. + * @member {google.protobuf.IFieldOptions|null|undefined} options + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.options = null; + + /** + * Creates a FieldDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + */ + FieldDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldDescriptorProto) + return object; + var message = new $root.google.protobuf.FieldDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.number != null) + message.number = object.number | 0; + switch (object.label) { + case "LABEL_OPTIONAL": + case 1: + message.label = 1; + break; + case "LABEL_REQUIRED": + case 2: + message.label = 2; + break; + case "LABEL_REPEATED": + case 3: + message.label = 3; + break; + } + switch (object.type) { + case "TYPE_DOUBLE": + case 1: + message.type = 1; + break; + case "TYPE_FLOAT": + case 2: + message.type = 2; + break; + case "TYPE_INT64": + case 3: + message.type = 3; + break; + case "TYPE_UINT64": + case 4: + message.type = 4; + break; + case "TYPE_INT32": + case 5: + message.type = 5; + break; + case "TYPE_FIXED64": + case 6: + message.type = 6; + break; + case "TYPE_FIXED32": + case 7: + message.type = 7; + break; + case "TYPE_BOOL": + case 8: + message.type = 8; + break; + case "TYPE_STRING": + case 9: + message.type = 9; + break; + case "TYPE_GROUP": + case 10: + message.type = 10; + break; + case "TYPE_MESSAGE": + case 11: + message.type = 11; + break; + case "TYPE_BYTES": + case 12: + message.type = 12; + break; + case "TYPE_UINT32": + case 13: + message.type = 13; + break; + case "TYPE_ENUM": + case 14: + message.type = 14; + break; + case "TYPE_SFIXED32": + case 15: + message.type = 15; + break; + case "TYPE_SFIXED64": + case 16: + message.type = 16; + break; + case "TYPE_SINT32": + case 17: + message.type = 17; + break; + case "TYPE_SINT64": + case 18: + message.type = 18; + break; + } + if (object.typeName != null) + message.typeName = String(object.typeName); + if (object.extendee != null) + message.extendee = String(object.extendee); + if (object.defaultValue != null) + message.defaultValue = String(object.defaultValue); + if (object.oneofIndex != null) + message.oneofIndex = object.oneofIndex | 0; + if (object.jsonName != null) + message.jsonName = String(object.jsonName); + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.FieldDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.FieldOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from a FieldDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.FieldDescriptorProto} message FieldDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.extendee = ""; + object.number = 0; + object.label = options.enums === String ? "LABEL_OPTIONAL" : 1; + object.type = options.enums === String ? "TYPE_DOUBLE" : 1; + object.typeName = ""; + object.defaultValue = ""; + object.options = null; + object.oneofIndex = 0; + object.jsonName = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.extendee != null && message.hasOwnProperty("extendee")) + object.extendee = message.extendee; + if (message.number != null && message.hasOwnProperty("number")) + object.number = message.number; + if (message.label != null && message.hasOwnProperty("label")) + object.label = options.enums === String ? $root.google.protobuf.FieldDescriptorProto.Label[message.label] : message.label; + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.google.protobuf.FieldDescriptorProto.Type[message.type] : message.type; + if (message.typeName != null && message.hasOwnProperty("typeName")) + object.typeName = message.typeName; + if (message.defaultValue != null && message.hasOwnProperty("defaultValue")) + object.defaultValue = message.defaultValue; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.FieldOptions.toObject(message.options, options); + if (message.oneofIndex != null && message.hasOwnProperty("oneofIndex")) + object.oneofIndex = message.oneofIndex; + if (message.jsonName != null && message.hasOwnProperty("jsonName")) + object.jsonName = message.jsonName; + return object; + }; + + /** + * Converts this FieldDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.FieldDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + FieldDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Type enum. + * @name google.protobuf.FieldDescriptorProto.Type + * @enum {string} + * @property {string} TYPE_DOUBLE=TYPE_DOUBLE TYPE_DOUBLE value + * @property {string} TYPE_FLOAT=TYPE_FLOAT TYPE_FLOAT value + * @property {string} TYPE_INT64=TYPE_INT64 TYPE_INT64 value + * @property {string} TYPE_UINT64=TYPE_UINT64 TYPE_UINT64 value + * @property {string} TYPE_INT32=TYPE_INT32 TYPE_INT32 value + * @property {string} TYPE_FIXED64=TYPE_FIXED64 TYPE_FIXED64 value + * @property {string} TYPE_FIXED32=TYPE_FIXED32 TYPE_FIXED32 value + * @property {string} TYPE_BOOL=TYPE_BOOL TYPE_BOOL value + * @property {string} TYPE_STRING=TYPE_STRING TYPE_STRING value + * @property {string} TYPE_GROUP=TYPE_GROUP TYPE_GROUP value + * @property {string} TYPE_MESSAGE=TYPE_MESSAGE TYPE_MESSAGE value + * @property {string} TYPE_BYTES=TYPE_BYTES TYPE_BYTES value + * @property {string} TYPE_UINT32=TYPE_UINT32 TYPE_UINT32 value + * @property {string} TYPE_ENUM=TYPE_ENUM TYPE_ENUM value + * @property {string} TYPE_SFIXED32=TYPE_SFIXED32 TYPE_SFIXED32 value + * @property {string} TYPE_SFIXED64=TYPE_SFIXED64 TYPE_SFIXED64 value + * @property {string} TYPE_SINT32=TYPE_SINT32 TYPE_SINT32 value + * @property {string} TYPE_SINT64=TYPE_SINT64 TYPE_SINT64 value + */ + FieldDescriptorProto.Type = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "TYPE_DOUBLE"] = "TYPE_DOUBLE"; + values[valuesById[2] = "TYPE_FLOAT"] = "TYPE_FLOAT"; + values[valuesById[3] = "TYPE_INT64"] = "TYPE_INT64"; + values[valuesById[4] = "TYPE_UINT64"] = "TYPE_UINT64"; + values[valuesById[5] = "TYPE_INT32"] = "TYPE_INT32"; + values[valuesById[6] = "TYPE_FIXED64"] = "TYPE_FIXED64"; + values[valuesById[7] = "TYPE_FIXED32"] = "TYPE_FIXED32"; + values[valuesById[8] = "TYPE_BOOL"] = "TYPE_BOOL"; + values[valuesById[9] = "TYPE_STRING"] = "TYPE_STRING"; + values[valuesById[10] = "TYPE_GROUP"] = "TYPE_GROUP"; + values[valuesById[11] = "TYPE_MESSAGE"] = "TYPE_MESSAGE"; + values[valuesById[12] = "TYPE_BYTES"] = "TYPE_BYTES"; + values[valuesById[13] = "TYPE_UINT32"] = "TYPE_UINT32"; + values[valuesById[14] = "TYPE_ENUM"] = "TYPE_ENUM"; + values[valuesById[15] = "TYPE_SFIXED32"] = "TYPE_SFIXED32"; + values[valuesById[16] = "TYPE_SFIXED64"] = "TYPE_SFIXED64"; + values[valuesById[17] = "TYPE_SINT32"] = "TYPE_SINT32"; + values[valuesById[18] = "TYPE_SINT64"] = "TYPE_SINT64"; + return values; + })(); + + /** + * Label enum. + * @name google.protobuf.FieldDescriptorProto.Label + * @enum {string} + * @property {string} LABEL_OPTIONAL=LABEL_OPTIONAL LABEL_OPTIONAL value + * @property {string} LABEL_REQUIRED=LABEL_REQUIRED LABEL_REQUIRED value + * @property {string} LABEL_REPEATED=LABEL_REPEATED LABEL_REPEATED value + */ + FieldDescriptorProto.Label = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "LABEL_OPTIONAL"] = "LABEL_OPTIONAL"; + values[valuesById[2] = "LABEL_REQUIRED"] = "LABEL_REQUIRED"; + values[valuesById[3] = "LABEL_REPEATED"] = "LABEL_REPEATED"; + return values; + })(); + + return FieldDescriptorProto; + })(); + + protobuf.OneofDescriptorProto = (function() { + + /** + * Properties of an OneofDescriptorProto. + * @memberof google.protobuf + * @interface IOneofDescriptorProto + * @property {string|null} [name] OneofDescriptorProto name + * @property {google.protobuf.IOneofOptions|null} [options] OneofDescriptorProto options + */ + + /** + * Constructs a new OneofDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an OneofDescriptorProto. + * @implements IOneofDescriptorProto + * @constructor + * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set + */ + function OneofDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OneofDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.OneofDescriptorProto + * @instance + */ + OneofDescriptorProto.prototype.name = ""; + + /** + * OneofDescriptorProto options. + * @member {google.protobuf.IOneofOptions|null|undefined} options + * @memberof google.protobuf.OneofDescriptorProto + * @instance + */ + OneofDescriptorProto.prototype.options = null; + + /** + * Creates an OneofDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + */ + OneofDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.OneofDescriptorProto) + return object; + var message = new $root.google.protobuf.OneofDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.OneofDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.OneofOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from an OneofDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.OneofDescriptorProto} message OneofDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OneofDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.OneofOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this OneofDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.OneofDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + OneofDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return OneofDescriptorProto; + })(); + + protobuf.EnumDescriptorProto = (function() { + + /** + * Properties of an EnumDescriptorProto. + * @memberof google.protobuf + * @interface IEnumDescriptorProto + * @property {string|null} [name] EnumDescriptorProto name + * @property {Array.|null} [value] EnumDescriptorProto value + * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options + */ + + /** + * Constructs a new EnumDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumDescriptorProto. + * @implements IEnumDescriptorProto + * @constructor + * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set + */ + function EnumDescriptorProto(properties) { + this.value = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.name = ""; + + /** + * EnumDescriptorProto value. + * @member {Array.} value + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.value = $util.emptyArray; + + /** + * EnumDescriptorProto options. + * @member {google.protobuf.IEnumOptions|null|undefined} options + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.options = null; + + /** + * Creates an EnumDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + */ + EnumDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumDescriptorProto) + return object; + var message = new $root.google.protobuf.EnumDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.value) { + if (!Array.isArray(object.value)) + throw TypeError(".google.protobuf.EnumDescriptorProto.value: array expected"); + message.value = []; + for (var i = 0; i < object.value.length; ++i) { + if (typeof object.value[i] !== "object") + throw TypeError(".google.protobuf.EnumDescriptorProto.value: object expected"); + message.value[i] = $root.google.protobuf.EnumValueDescriptorProto.fromObject(object.value[i]); + } + } + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.EnumDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.EnumOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from an EnumDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.EnumDescriptorProto} message EnumDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.value = []; + if (options.defaults) { + object.name = ""; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.value && message.value.length) { + object.value = []; + for (var j = 0; j < message.value.length; ++j) + object.value[j] = $root.google.protobuf.EnumValueDescriptorProto.toObject(message.value[j], options); + } + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.EnumOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this EnumDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.EnumDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + EnumDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return EnumDescriptorProto; + })(); + + protobuf.EnumValueDescriptorProto = (function() { + + /** + * Properties of an EnumValueDescriptorProto. + * @memberof google.protobuf + * @interface IEnumValueDescriptorProto + * @property {string|null} [name] EnumValueDescriptorProto name + * @property {number|null} [number] EnumValueDescriptorProto number + * @property {google.protobuf.IEnumValueOptions|null} [options] EnumValueDescriptorProto options + */ + + /** + * Constructs a new EnumValueDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumValueDescriptorProto. + * @implements IEnumValueDescriptorProto + * @constructor + * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set + */ + function EnumValueDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumValueDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.name = ""; + + /** + * EnumValueDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.number = 0; + + /** + * EnumValueDescriptorProto options. + * @member {google.protobuf.IEnumValueOptions|null|undefined} options + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.options = null; + + /** + * Creates an EnumValueDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + */ + EnumValueDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumValueDescriptorProto) + return object; + var message = new $root.google.protobuf.EnumValueDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.number != null) + message.number = object.number | 0; + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.EnumValueDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.EnumValueOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from an EnumValueDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.EnumValueDescriptorProto} message EnumValueDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumValueDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.number = 0; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.number != null && message.hasOwnProperty("number")) + object.number = message.number; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.EnumValueOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this EnumValueDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + EnumValueDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return EnumValueDescriptorProto; + })(); + + protobuf.ServiceDescriptorProto = (function() { + + /** + * Properties of a ServiceDescriptorProto. + * @memberof google.protobuf + * @interface IServiceDescriptorProto + * @property {string|null} [name] ServiceDescriptorProto name + * @property {Array.|null} [method] ServiceDescriptorProto method + * @property {google.protobuf.IServiceOptions|null} [options] ServiceDescriptorProto options + */ + + /** + * Constructs a new ServiceDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a ServiceDescriptorProto. + * @implements IServiceDescriptorProto + * @constructor + * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set + */ + function ServiceDescriptorProto(properties) { + this.method = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ServiceDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.name = ""; + + /** + * ServiceDescriptorProto method. + * @member {Array.} method + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.method = $util.emptyArray; + + /** + * ServiceDescriptorProto options. + * @member {google.protobuf.IServiceOptions|null|undefined} options + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.options = null; + + /** + * Creates a ServiceDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + */ + ServiceDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ServiceDescriptorProto) + return object; + var message = new $root.google.protobuf.ServiceDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.method) { + if (!Array.isArray(object.method)) + throw TypeError(".google.protobuf.ServiceDescriptorProto.method: array expected"); + message.method = []; + for (var i = 0; i < object.method.length; ++i) { + if (typeof object.method[i] !== "object") + throw TypeError(".google.protobuf.ServiceDescriptorProto.method: object expected"); + message.method[i] = $root.google.protobuf.MethodDescriptorProto.fromObject(object.method[i]); + } + } + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.ServiceDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.ServiceOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from a ServiceDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.ServiceDescriptorProto} message ServiceDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServiceDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.method = []; + if (options.defaults) { + object.name = ""; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.method && message.method.length) { + object.method = []; + for (var j = 0; j < message.method.length; ++j) + object.method[j] = $root.google.protobuf.MethodDescriptorProto.toObject(message.method[j], options); + } + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.ServiceOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this ServiceDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + ServiceDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ServiceDescriptorProto; + })(); + + protobuf.MethodDescriptorProto = (function() { + + /** + * Properties of a MethodDescriptorProto. + * @memberof google.protobuf + * @interface IMethodDescriptorProto + * @property {string|null} [name] MethodDescriptorProto name + * @property {string|null} [inputType] MethodDescriptorProto inputType + * @property {string|null} [outputType] MethodDescriptorProto outputType + * @property {google.protobuf.IMethodOptions|null} [options] MethodDescriptorProto options + * @property {boolean|null} [clientStreaming] MethodDescriptorProto clientStreaming + * @property {boolean|null} [serverStreaming] MethodDescriptorProto serverStreaming + */ + + /** + * Constructs a new MethodDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a MethodDescriptorProto. + * @implements IMethodDescriptorProto + * @constructor + * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set + */ + function MethodDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MethodDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.name = ""; + + /** + * MethodDescriptorProto inputType. + * @member {string} inputType + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.inputType = ""; + + /** + * MethodDescriptorProto outputType. + * @member {string} outputType + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.outputType = ""; + + /** + * MethodDescriptorProto options. + * @member {google.protobuf.IMethodOptions|null|undefined} options + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.options = null; + + /** + * MethodDescriptorProto clientStreaming. + * @member {boolean} clientStreaming + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.clientStreaming = false; + + /** + * MethodDescriptorProto serverStreaming. + * @member {boolean} serverStreaming + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.serverStreaming = false; + + /** + * Creates a MethodDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto + */ + MethodDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MethodDescriptorProto) + return object; + var message = new $root.google.protobuf.MethodDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.inputType != null) + message.inputType = String(object.inputType); + if (object.outputType != null) + message.outputType = String(object.outputType); + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.MethodDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.MethodOptions.fromObject(object.options); + } + if (object.clientStreaming != null) + message.clientStreaming = Boolean(object.clientStreaming); + if (object.serverStreaming != null) + message.serverStreaming = Boolean(object.serverStreaming); + return message; + }; + + /** + * Creates a plain object from a MethodDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.MethodDescriptorProto} message MethodDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MethodDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.inputType = ""; + object.outputType = ""; + object.options = null; + object.clientStreaming = false; + object.serverStreaming = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.inputType != null && message.hasOwnProperty("inputType")) + object.inputType = message.inputType; + if (message.outputType != null && message.hasOwnProperty("outputType")) + object.outputType = message.outputType; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.MethodOptions.toObject(message.options, options); + if (message.clientStreaming != null && message.hasOwnProperty("clientStreaming")) + object.clientStreaming = message.clientStreaming; + if (message.serverStreaming != null && message.hasOwnProperty("serverStreaming")) + object.serverStreaming = message.serverStreaming; + return object; + }; + + /** + * Converts this MethodDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.MethodDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + MethodDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return MethodDescriptorProto; + })(); + + protobuf.FileOptions = (function() { + + /** + * Properties of a FileOptions. + * @memberof google.protobuf + * @interface IFileOptions + * @property {string|null} [javaPackage] FileOptions javaPackage + * @property {string|null} [javaOuterClassname] FileOptions javaOuterClassname + * @property {boolean|null} [javaMultipleFiles] FileOptions javaMultipleFiles + * @property {boolean|null} [javaGenerateEqualsAndHash] FileOptions javaGenerateEqualsAndHash + * @property {boolean|null} [javaStringCheckUtf8] FileOptions javaStringCheckUtf8 + * @property {google.protobuf.FileOptions.OptimizeMode|null} [optimizeFor] FileOptions optimizeFor + * @property {string|null} [goPackage] FileOptions goPackage + * @property {boolean|null} [ccGenericServices] FileOptions ccGenericServices + * @property {boolean|null} [javaGenericServices] FileOptions javaGenericServices + * @property {boolean|null} [pyGenericServices] FileOptions pyGenericServices + * @property {boolean|null} [deprecated] FileOptions deprecated + * @property {boolean|null} [ccEnableArenas] FileOptions ccEnableArenas + * @property {string|null} [objcClassPrefix] FileOptions objcClassPrefix + * @property {string|null} [csharpNamespace] FileOptions csharpNamespace + * @property {Array.|null} [uninterpretedOption] FileOptions uninterpretedOption + * @property {Array.|null} [".google.api.resourceDefinition"] FileOptions .google.api.resourceDefinition + */ + + /** + * Constructs a new FileOptions. + * @memberof google.protobuf + * @classdesc Represents a FileOptions. + * @implements IFileOptions + * @constructor + * @param {google.protobuf.IFileOptions=} [properties] Properties to set + */ + function FileOptions(properties) { + this.uninterpretedOption = []; + this[".google.api.resourceDefinition"] = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FileOptions javaPackage. + * @member {string} javaPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaPackage = ""; + + /** + * FileOptions javaOuterClassname. + * @member {string} javaOuterClassname + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaOuterClassname = ""; + + /** + * FileOptions javaMultipleFiles. + * @member {boolean} javaMultipleFiles + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaMultipleFiles = false; + + /** + * FileOptions javaGenerateEqualsAndHash. + * @member {boolean} javaGenerateEqualsAndHash + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaGenerateEqualsAndHash = false; + + /** + * FileOptions javaStringCheckUtf8. + * @member {boolean} javaStringCheckUtf8 + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaStringCheckUtf8 = false; + + /** + * FileOptions optimizeFor. + * @member {google.protobuf.FileOptions.OptimizeMode} optimizeFor + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.optimizeFor = 1; + + /** + * FileOptions goPackage. + * @member {string} goPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.goPackage = ""; + + /** + * FileOptions ccGenericServices. + * @member {boolean} ccGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.ccGenericServices = false; + + /** + * FileOptions javaGenericServices. + * @member {boolean} javaGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaGenericServices = false; + + /** + * FileOptions pyGenericServices. + * @member {boolean} pyGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.pyGenericServices = false; + + /** + * FileOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.deprecated = false; + + /** + * FileOptions ccEnableArenas. + * @member {boolean} ccEnableArenas + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.ccEnableArenas = false; + + /** + * FileOptions objcClassPrefix. + * @member {string} objcClassPrefix + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.objcClassPrefix = ""; + + /** + * FileOptions csharpNamespace. + * @member {string} csharpNamespace + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.csharpNamespace = ""; + + /** + * FileOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * FileOptions .google.api.resourceDefinition. + * @member {Array.} .google.api.resourceDefinition + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype[".google.api.resourceDefinition"] = $util.emptyArray; + + /** + * Creates a FileOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileOptions} FileOptions + */ + FileOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileOptions) + return object; + var message = new $root.google.protobuf.FileOptions(); + if (object.javaPackage != null) + message.javaPackage = String(object.javaPackage); + if (object.javaOuterClassname != null) + message.javaOuterClassname = String(object.javaOuterClassname); + if (object.javaMultipleFiles != null) + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + if (object.javaGenerateEqualsAndHash != null) + message.javaGenerateEqualsAndHash = Boolean(object.javaGenerateEqualsAndHash); + if (object.javaStringCheckUtf8 != null) + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + switch (object.optimizeFor) { + case "SPEED": + case 1: + message.optimizeFor = 1; + break; + case "CODE_SIZE": + case 2: + message.optimizeFor = 2; + break; + case "LITE_RUNTIME": + case 3: + message.optimizeFor = 3; + break; + } + if (object.goPackage != null) + message.goPackage = String(object.goPackage); + if (object.ccGenericServices != null) + message.ccGenericServices = Boolean(object.ccGenericServices); + if (object.javaGenericServices != null) + message.javaGenericServices = Boolean(object.javaGenericServices); + if (object.pyGenericServices != null) + message.pyGenericServices = Boolean(object.pyGenericServices); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.ccEnableArenas != null) + message.ccEnableArenas = Boolean(object.ccEnableArenas); + if (object.objcClassPrefix != null) + message.objcClassPrefix = String(object.objcClassPrefix); + if (object.csharpNamespace != null) + message.csharpNamespace = String(object.csharpNamespace); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.FileOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.FileOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.resourceDefinition"]) { + if (!Array.isArray(object[".google.api.resourceDefinition"])) + throw TypeError(".google.protobuf.FileOptions..google.api.resourceDefinition: array expected"); + message[".google.api.resourceDefinition"] = []; + for (var i = 0; i < object[".google.api.resourceDefinition"].length; ++i) { + if (typeof object[".google.api.resourceDefinition"][i] !== "object") + throw TypeError(".google.protobuf.FileOptions..google.api.resourceDefinition: object expected"); + message[".google.api.resourceDefinition"][i] = $root.google.api.ResourceDescriptor.fromObject(object[".google.api.resourceDefinition"][i]); + } + } + return message; + }; + + /** + * Creates a plain object from a FileOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.FileOptions} message FileOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.uninterpretedOption = []; + object[".google.api.resourceDefinition"] = []; + } + if (options.defaults) { + object.javaPackage = ""; + object.javaOuterClassname = ""; + object.optimizeFor = options.enums === String ? "SPEED" : 1; + object.javaMultipleFiles = false; + object.goPackage = ""; + object.ccGenericServices = false; + object.javaGenericServices = false; + object.pyGenericServices = false; + object.javaGenerateEqualsAndHash = false; + object.deprecated = false; + object.javaStringCheckUtf8 = false; + object.ccEnableArenas = false; + object.objcClassPrefix = ""; + object.csharpNamespace = ""; + } + if (message.javaPackage != null && message.hasOwnProperty("javaPackage")) + object.javaPackage = message.javaPackage; + if (message.javaOuterClassname != null && message.hasOwnProperty("javaOuterClassname")) + object.javaOuterClassname = message.javaOuterClassname; + if (message.optimizeFor != null && message.hasOwnProperty("optimizeFor")) + object.optimizeFor = options.enums === String ? $root.google.protobuf.FileOptions.OptimizeMode[message.optimizeFor] : message.optimizeFor; + if (message.javaMultipleFiles != null && message.hasOwnProperty("javaMultipleFiles")) + object.javaMultipleFiles = message.javaMultipleFiles; + if (message.goPackage != null && message.hasOwnProperty("goPackage")) + object.goPackage = message.goPackage; + if (message.ccGenericServices != null && message.hasOwnProperty("ccGenericServices")) + object.ccGenericServices = message.ccGenericServices; + if (message.javaGenericServices != null && message.hasOwnProperty("javaGenericServices")) + object.javaGenericServices = message.javaGenericServices; + if (message.pyGenericServices != null && message.hasOwnProperty("pyGenericServices")) + object.pyGenericServices = message.pyGenericServices; + if (message.javaGenerateEqualsAndHash != null && message.hasOwnProperty("javaGenerateEqualsAndHash")) + object.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.javaStringCheckUtf8 != null && message.hasOwnProperty("javaStringCheckUtf8")) + object.javaStringCheckUtf8 = message.javaStringCheckUtf8; + if (message.ccEnableArenas != null && message.hasOwnProperty("ccEnableArenas")) + object.ccEnableArenas = message.ccEnableArenas; + if (message.objcClassPrefix != null && message.hasOwnProperty("objcClassPrefix")) + object.objcClassPrefix = message.objcClassPrefix; + if (message.csharpNamespace != null && message.hasOwnProperty("csharpNamespace")) + object.csharpNamespace = message.csharpNamespace; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.api.resourceDefinition"] && message[".google.api.resourceDefinition"].length) { + object[".google.api.resourceDefinition"] = []; + for (var j = 0; j < message[".google.api.resourceDefinition"].length; ++j) + object[".google.api.resourceDefinition"][j] = $root.google.api.ResourceDescriptor.toObject(message[".google.api.resourceDefinition"][j], options); + } + return object; + }; + + /** + * Converts this FileOptions to JSON. + * @function toJSON + * @memberof google.protobuf.FileOptions + * @instance + * @returns {Object.} JSON object + */ + FileOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * OptimizeMode enum. + * @name google.protobuf.FileOptions.OptimizeMode + * @enum {string} + * @property {string} SPEED=SPEED SPEED value + * @property {string} CODE_SIZE=CODE_SIZE CODE_SIZE value + * @property {string} LITE_RUNTIME=LITE_RUNTIME LITE_RUNTIME value + */ + FileOptions.OptimizeMode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "SPEED"] = "SPEED"; + values[valuesById[2] = "CODE_SIZE"] = "CODE_SIZE"; + values[valuesById[3] = "LITE_RUNTIME"] = "LITE_RUNTIME"; + return values; + })(); + + return FileOptions; + })(); + + protobuf.MessageOptions = (function() { + + /** + * Properties of a MessageOptions. + * @memberof google.protobuf + * @interface IMessageOptions + * @property {boolean|null} [messageSetWireFormat] MessageOptions messageSetWireFormat + * @property {boolean|null} [noStandardDescriptorAccessor] MessageOptions noStandardDescriptorAccessor + * @property {boolean|null} [deprecated] MessageOptions deprecated + * @property {boolean|null} [mapEntry] MessageOptions mapEntry + * @property {Array.|null} [uninterpretedOption] MessageOptions uninterpretedOption + * @property {google.api.IResourceDescriptor|null} [".google.api.resource"] MessageOptions .google.api.resource + */ + + /** + * Constructs a new MessageOptions. + * @memberof google.protobuf + * @classdesc Represents a MessageOptions. + * @implements IMessageOptions + * @constructor + * @param {google.protobuf.IMessageOptions=} [properties] Properties to set + */ + function MessageOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MessageOptions messageSetWireFormat. + * @member {boolean} messageSetWireFormat + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.messageSetWireFormat = false; + + /** + * MessageOptions noStandardDescriptorAccessor. + * @member {boolean} noStandardDescriptorAccessor + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.noStandardDescriptorAccessor = false; + + /** + * MessageOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.deprecated = false; + + /** + * MessageOptions mapEntry. + * @member {boolean} mapEntry + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.mapEntry = false; + + /** + * MessageOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * MessageOptions .google.api.resource. + * @member {google.api.IResourceDescriptor|null|undefined} .google.api.resource + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype[".google.api.resource"] = null; + + /** + * Creates a MessageOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MessageOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MessageOptions} MessageOptions + */ + MessageOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MessageOptions) + return object; + var message = new $root.google.protobuf.MessageOptions(); + if (object.messageSetWireFormat != null) + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + if (object.noStandardDescriptorAccessor != null) + message.noStandardDescriptorAccessor = Boolean(object.noStandardDescriptorAccessor); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.mapEntry != null) + message.mapEntry = Boolean(object.mapEntry); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.MessageOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.MessageOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.resource"] != null) { + if (typeof object[".google.api.resource"] !== "object") + throw TypeError(".google.protobuf.MessageOptions..google.api.resource: object expected"); + message[".google.api.resource"] = $root.google.api.ResourceDescriptor.fromObject(object[".google.api.resource"]); + } + return message; + }; + + /** + * Creates a plain object from a MessageOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.MessageOptions} message MessageOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MessageOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) { + object.messageSetWireFormat = false; + object.noStandardDescriptorAccessor = false; + object.deprecated = false; + object.mapEntry = false; + object[".google.api.resource"] = null; + } + if (message.messageSetWireFormat != null && message.hasOwnProperty("messageSetWireFormat")) + object.messageSetWireFormat = message.messageSetWireFormat; + if (message.noStandardDescriptorAccessor != null && message.hasOwnProperty("noStandardDescriptorAccessor")) + object.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.mapEntry != null && message.hasOwnProperty("mapEntry")) + object.mapEntry = message.mapEntry; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.api.resource"] != null && message.hasOwnProperty(".google.api.resource")) + object[".google.api.resource"] = $root.google.api.ResourceDescriptor.toObject(message[".google.api.resource"], options); + return object; + }; + + /** + * Converts this MessageOptions to JSON. + * @function toJSON + * @memberof google.protobuf.MessageOptions + * @instance + * @returns {Object.} JSON object + */ + MessageOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return MessageOptions; + })(); + + protobuf.FieldOptions = (function() { + + /** + * Properties of a FieldOptions. + * @memberof google.protobuf + * @interface IFieldOptions + * @property {google.protobuf.FieldOptions.CType|null} [ctype] FieldOptions ctype + * @property {boolean|null} [packed] FieldOptions packed + * @property {google.protobuf.FieldOptions.JSType|null} [jstype] FieldOptions jstype + * @property {boolean|null} [lazy] FieldOptions lazy + * @property {boolean|null} [deprecated] FieldOptions deprecated + * @property {boolean|null} [weak] FieldOptions weak + * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption + * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior + * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference + */ + + /** + * Constructs a new FieldOptions. + * @memberof google.protobuf + * @classdesc Represents a FieldOptions. + * @implements IFieldOptions + * @constructor + * @param {google.protobuf.IFieldOptions=} [properties] Properties to set + */ + function FieldOptions(properties) { + this.uninterpretedOption = []; + this[".google.api.fieldBehavior"] = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldOptions ctype. + * @member {google.protobuf.FieldOptions.CType} ctype + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.ctype = 0; + + /** + * FieldOptions packed. + * @member {boolean} packed + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.packed = false; + + /** + * FieldOptions jstype. + * @member {google.protobuf.FieldOptions.JSType} jstype + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.jstype = 0; + + /** + * FieldOptions lazy. + * @member {boolean} lazy + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.lazy = false; + + /** + * FieldOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.deprecated = false; + + /** + * FieldOptions weak. + * @member {boolean} weak + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.weak = false; + + /** + * FieldOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * FieldOptions .google.api.fieldBehavior. + * @member {Array.} .google.api.fieldBehavior + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype[".google.api.fieldBehavior"] = $util.emptyArray; + + /** + * FieldOptions .google.api.resourceReference. + * @member {google.api.IResourceReference|null|undefined} .google.api.resourceReference + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype[".google.api.resourceReference"] = null; + + /** + * Creates a FieldOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions} FieldOptions + */ + FieldOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions) + return object; + var message = new $root.google.protobuf.FieldOptions(); + switch (object.ctype) { + case "STRING": + case 0: + message.ctype = 0; + break; + case "CORD": + case 1: + message.ctype = 1; + break; + case "STRING_PIECE": + case 2: + message.ctype = 2; + break; + } + if (object.packed != null) + message.packed = Boolean(object.packed); + switch (object.jstype) { + case "JS_NORMAL": + case 0: + message.jstype = 0; + break; + case "JS_STRING": + case 1: + message.jstype = 1; + break; + case "JS_NUMBER": + case 2: + message.jstype = 2; + break; + } + if (object.lazy != null) + message.lazy = Boolean(object.lazy); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.weak != null) + message.weak = Boolean(object.weak); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.fieldBehavior"]) { + if (!Array.isArray(object[".google.api.fieldBehavior"])) + throw TypeError(".google.protobuf.FieldOptions..google.api.fieldBehavior: array expected"); + message[".google.api.fieldBehavior"] = []; + for (var i = 0; i < object[".google.api.fieldBehavior"].length; ++i) + switch (object[".google.api.fieldBehavior"][i]) { + default: + case "FIELD_BEHAVIOR_UNSPECIFIED": + case 0: + message[".google.api.fieldBehavior"][i] = 0; + break; + case "OPTIONAL": + case 1: + message[".google.api.fieldBehavior"][i] = 1; + break; + case "REQUIRED": + case 2: + message[".google.api.fieldBehavior"][i] = 2; + break; + case "OUTPUT_ONLY": + case 3: + message[".google.api.fieldBehavior"][i] = 3; + break; + case "INPUT_ONLY": + case 4: + message[".google.api.fieldBehavior"][i] = 4; + break; + case "IMMUTABLE": + case 5: + message[".google.api.fieldBehavior"][i] = 5; + break; + } + } + if (object[".google.api.resourceReference"] != null) { + if (typeof object[".google.api.resourceReference"] !== "object") + throw TypeError(".google.protobuf.FieldOptions..google.api.resourceReference: object expected"); + message[".google.api.resourceReference"] = $root.google.api.ResourceReference.fromObject(object[".google.api.resourceReference"]); + } + return message; + }; + + /** + * Creates a plain object from a FieldOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.FieldOptions} message FieldOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.uninterpretedOption = []; + object[".google.api.fieldBehavior"] = []; + } + if (options.defaults) { + object.ctype = options.enums === String ? "STRING" : 0; + object.packed = false; + object.deprecated = false; + object.lazy = false; + object.jstype = options.enums === String ? "JS_NORMAL" : 0; + object.weak = false; + object[".google.api.resourceReference"] = null; + } + if (message.ctype != null && message.hasOwnProperty("ctype")) + object.ctype = options.enums === String ? $root.google.protobuf.FieldOptions.CType[message.ctype] : message.ctype; + if (message.packed != null && message.hasOwnProperty("packed")) + object.packed = message.packed; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.lazy != null && message.hasOwnProperty("lazy")) + object.lazy = message.lazy; + if (message.jstype != null && message.hasOwnProperty("jstype")) + object.jstype = options.enums === String ? $root.google.protobuf.FieldOptions.JSType[message.jstype] : message.jstype; + if (message.weak != null && message.hasOwnProperty("weak")) + object.weak = message.weak; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.api.fieldBehavior"] && message[".google.api.fieldBehavior"].length) { + object[".google.api.fieldBehavior"] = []; + for (var j = 0; j < message[".google.api.fieldBehavior"].length; ++j) + object[".google.api.fieldBehavior"][j] = options.enums === String ? $root.google.api.FieldBehavior[message[".google.api.fieldBehavior"][j]] : message[".google.api.fieldBehavior"][j]; + } + if (message[".google.api.resourceReference"] != null && message.hasOwnProperty(".google.api.resourceReference")) + object[".google.api.resourceReference"] = $root.google.api.ResourceReference.toObject(message[".google.api.resourceReference"], options); + return object; + }; + + /** + * Converts this FieldOptions to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions + * @instance + * @returns {Object.} JSON object + */ + FieldOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * CType enum. + * @name google.protobuf.FieldOptions.CType + * @enum {string} + * @property {string} STRING=STRING STRING value + * @property {string} CORD=CORD CORD value + * @property {string} STRING_PIECE=STRING_PIECE STRING_PIECE value + */ + FieldOptions.CType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STRING"] = "STRING"; + values[valuesById[1] = "CORD"] = "CORD"; + values[valuesById[2] = "STRING_PIECE"] = "STRING_PIECE"; + return values; + })(); + + /** + * JSType enum. + * @name google.protobuf.FieldOptions.JSType + * @enum {string} + * @property {string} JS_NORMAL=JS_NORMAL JS_NORMAL value + * @property {string} JS_STRING=JS_STRING JS_STRING value + * @property {string} JS_NUMBER=JS_NUMBER JS_NUMBER value + */ + FieldOptions.JSType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "JS_NORMAL"] = "JS_NORMAL"; + values[valuesById[1] = "JS_STRING"] = "JS_STRING"; + values[valuesById[2] = "JS_NUMBER"] = "JS_NUMBER"; + return values; + })(); + + return FieldOptions; + })(); + + protobuf.OneofOptions = (function() { + + /** + * Properties of an OneofOptions. + * @memberof google.protobuf + * @interface IOneofOptions + * @property {Array.|null} [uninterpretedOption] OneofOptions uninterpretedOption + */ + + /** + * Constructs a new OneofOptions. + * @memberof google.protobuf + * @classdesc Represents an OneofOptions. + * @implements IOneofOptions + * @constructor + * @param {google.protobuf.IOneofOptions=} [properties] Properties to set + */ + function OneofOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OneofOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.OneofOptions + * @instance + */ + OneofOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * Creates an OneofOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.OneofOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.OneofOptions} OneofOptions + */ + OneofOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.OneofOptions) + return object; + var message = new $root.google.protobuf.OneofOptions(); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.OneofOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.OneofOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an OneofOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.OneofOptions} message OneofOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OneofOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + return object; + }; + + /** + * Converts this OneofOptions to JSON. + * @function toJSON + * @memberof google.protobuf.OneofOptions + * @instance + * @returns {Object.} JSON object + */ + OneofOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return OneofOptions; + })(); + + protobuf.EnumOptions = (function() { + + /** + * Properties of an EnumOptions. + * @memberof google.protobuf + * @interface IEnumOptions + * @property {boolean|null} [allowAlias] EnumOptions allowAlias + * @property {boolean|null} [deprecated] EnumOptions deprecated + * @property {Array.|null} [uninterpretedOption] EnumOptions uninterpretedOption + */ + + /** + * Constructs a new EnumOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumOptions. + * @implements IEnumOptions + * @constructor + * @param {google.protobuf.IEnumOptions=} [properties] Properties to set + */ + function EnumOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumOptions allowAlias. + * @member {boolean} allowAlias + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.allowAlias = false; + + /** + * EnumOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.deprecated = false; + + /** + * EnumOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * Creates an EnumOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumOptions} EnumOptions + */ + EnumOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumOptions) + return object; + var message = new $root.google.protobuf.EnumOptions(); + if (object.allowAlias != null) + message.allowAlias = Boolean(object.allowAlias); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.EnumOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.EnumOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an EnumOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.EnumOptions} message EnumOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) { + object.allowAlias = false; + object.deprecated = false; + } + if (message.allowAlias != null && message.hasOwnProperty("allowAlias")) + object.allowAlias = message.allowAlias; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + return object; + }; + + /** + * Converts this EnumOptions to JSON. + * @function toJSON + * @memberof google.protobuf.EnumOptions + * @instance + * @returns {Object.} JSON object + */ + EnumOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return EnumOptions; + })(); + + protobuf.EnumValueOptions = (function() { + + /** + * Properties of an EnumValueOptions. + * @memberof google.protobuf + * @interface IEnumValueOptions + * @property {boolean|null} [deprecated] EnumValueOptions deprecated + * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption + */ + + /** + * Constructs a new EnumValueOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumValueOptions. + * @implements IEnumValueOptions + * @constructor + * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set + */ + function EnumValueOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumValueOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.deprecated = false; + + /** + * EnumValueOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * Creates an EnumValueOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + */ + EnumValueOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumValueOptions) + return object; + var message = new $root.google.protobuf.EnumValueOptions(); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an EnumValueOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.EnumValueOptions} message EnumValueOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumValueOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) + object.deprecated = false; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + return object; + }; + + /** + * Converts this EnumValueOptions to JSON. + * @function toJSON + * @memberof google.protobuf.EnumValueOptions + * @instance + * @returns {Object.} JSON object + */ + EnumValueOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return EnumValueOptions; + })(); + + protobuf.ServiceOptions = (function() { + + /** + * Properties of a ServiceOptions. + * @memberof google.protobuf + * @interface IServiceOptions + * @property {boolean|null} [deprecated] ServiceOptions deprecated + * @property {Array.|null} [uninterpretedOption] ServiceOptions uninterpretedOption + * @property {string|null} [".google.api.defaultHost"] ServiceOptions .google.api.defaultHost + * @property {string|null} [".google.api.oauthScopes"] ServiceOptions .google.api.oauthScopes + */ + + /** + * Constructs a new ServiceOptions. + * @memberof google.protobuf + * @classdesc Represents a ServiceOptions. + * @implements IServiceOptions + * @constructor + * @param {google.protobuf.IServiceOptions=} [properties] Properties to set + */ + function ServiceOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ServiceOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.deprecated = false; + + /** + * ServiceOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * ServiceOptions .google.api.defaultHost. + * @member {string} .google.api.defaultHost + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype[".google.api.defaultHost"] = ""; + + /** + * ServiceOptions .google.api.oauthScopes. + * @member {string} .google.api.oauthScopes + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype[".google.api.oauthScopes"] = ""; + + /** + * Creates a ServiceOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ServiceOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ServiceOptions} ServiceOptions + */ + ServiceOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ServiceOptions) + return object; + var message = new $root.google.protobuf.ServiceOptions(); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.ServiceOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.ServiceOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.defaultHost"] != null) + message[".google.api.defaultHost"] = String(object[".google.api.defaultHost"]); + if (object[".google.api.oauthScopes"] != null) + message[".google.api.oauthScopes"] = String(object[".google.api.oauthScopes"]); + return message; + }; + + /** + * Creates a plain object from a ServiceOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.ServiceOptions} message ServiceOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServiceOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) { + object.deprecated = false; + object[".google.api.defaultHost"] = ""; + object[".google.api.oauthScopes"] = ""; + } + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.api.defaultHost"] != null && message.hasOwnProperty(".google.api.defaultHost")) + object[".google.api.defaultHost"] = message[".google.api.defaultHost"]; + if (message[".google.api.oauthScopes"] != null && message.hasOwnProperty(".google.api.oauthScopes")) + object[".google.api.oauthScopes"] = message[".google.api.oauthScopes"]; + return object; + }; + + /** + * Converts this ServiceOptions to JSON. + * @function toJSON + * @memberof google.protobuf.ServiceOptions + * @instance + * @returns {Object.} JSON object + */ + ServiceOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ServiceOptions; + })(); + + protobuf.MethodOptions = (function() { + + /** + * Properties of a MethodOptions. + * @memberof google.protobuf + * @interface IMethodOptions + * @property {boolean|null} [deprecated] MethodOptions deprecated + * @property {Array.|null} [uninterpretedOption] MethodOptions uninterpretedOption + * @property {google.api.IHttpRule|null} [".google.api.http"] MethodOptions .google.api.http + * @property {Array.|null} [".google.api.methodSignature"] MethodOptions .google.api.methodSignature + * @property {google.longrunning.IOperationInfo|null} [".google.longrunning.operationInfo"] MethodOptions .google.longrunning.operationInfo + */ + + /** + * Constructs a new MethodOptions. + * @memberof google.protobuf + * @classdesc Represents a MethodOptions. + * @implements IMethodOptions + * @constructor + * @param {google.protobuf.IMethodOptions=} [properties] Properties to set + */ + function MethodOptions(properties) { + this.uninterpretedOption = []; + this[".google.api.methodSignature"] = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MethodOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.deprecated = false; + + /** + * MethodOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * MethodOptions .google.api.http. + * @member {google.api.IHttpRule|null|undefined} .google.api.http + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.api.http"] = null; + + /** + * MethodOptions .google.api.methodSignature. + * @member {Array.} .google.api.methodSignature + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.api.methodSignature"] = $util.emptyArray; + + /** + * MethodOptions .google.longrunning.operationInfo. + * @member {google.longrunning.IOperationInfo|null|undefined} .google.longrunning.operationInfo + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.longrunning.operationInfo"] = null; + + /** + * Creates a MethodOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MethodOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MethodOptions} MethodOptions + */ + MethodOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MethodOptions) + return object; + var message = new $root.google.protobuf.MethodOptions(); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.MethodOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.MethodOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.http"] != null) { + if (typeof object[".google.api.http"] !== "object") + throw TypeError(".google.protobuf.MethodOptions..google.api.http: object expected"); + message[".google.api.http"] = $root.google.api.HttpRule.fromObject(object[".google.api.http"]); + } + if (object[".google.api.methodSignature"]) { + if (!Array.isArray(object[".google.api.methodSignature"])) + throw TypeError(".google.protobuf.MethodOptions..google.api.methodSignature: array expected"); + message[".google.api.methodSignature"] = []; + for (var i = 0; i < object[".google.api.methodSignature"].length; ++i) + message[".google.api.methodSignature"][i] = String(object[".google.api.methodSignature"][i]); + } + if (object[".google.longrunning.operationInfo"] != null) { + if (typeof object[".google.longrunning.operationInfo"] !== "object") + throw TypeError(".google.protobuf.MethodOptions..google.longrunning.operationInfo: object expected"); + message[".google.longrunning.operationInfo"] = $root.google.longrunning.OperationInfo.fromObject(object[".google.longrunning.operationInfo"]); + } + return message; + }; + + /** + * Creates a plain object from a MethodOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.MethodOptions} message MethodOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MethodOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.uninterpretedOption = []; + object[".google.api.methodSignature"] = []; + } + if (options.defaults) { + object.deprecated = false; + object[".google.longrunning.operationInfo"] = null; + object[".google.api.http"] = null; + } + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.longrunning.operationInfo"] != null && message.hasOwnProperty(".google.longrunning.operationInfo")) + object[".google.longrunning.operationInfo"] = $root.google.longrunning.OperationInfo.toObject(message[".google.longrunning.operationInfo"], options); + if (message[".google.api.methodSignature"] && message[".google.api.methodSignature"].length) { + object[".google.api.methodSignature"] = []; + for (var j = 0; j < message[".google.api.methodSignature"].length; ++j) + object[".google.api.methodSignature"][j] = message[".google.api.methodSignature"][j]; + } + if (message[".google.api.http"] != null && message.hasOwnProperty(".google.api.http")) + object[".google.api.http"] = $root.google.api.HttpRule.toObject(message[".google.api.http"], options); + return object; + }; + + /** + * Converts this MethodOptions to JSON. + * @function toJSON + * @memberof google.protobuf.MethodOptions + * @instance + * @returns {Object.} JSON object + */ + MethodOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return MethodOptions; + })(); + + protobuf.UninterpretedOption = (function() { + + /** + * Properties of an UninterpretedOption. + * @memberof google.protobuf + * @interface IUninterpretedOption + * @property {Array.|null} [name] UninterpretedOption name + * @property {string|null} [identifierValue] UninterpretedOption identifierValue + * @property {number|string|null} [positiveIntValue] UninterpretedOption positiveIntValue + * @property {number|string|null} [negativeIntValue] UninterpretedOption negativeIntValue + * @property {number|null} [doubleValue] UninterpretedOption doubleValue + * @property {Uint8Array|null} [stringValue] UninterpretedOption stringValue + * @property {string|null} [aggregateValue] UninterpretedOption aggregateValue + */ + + /** + * Constructs a new UninterpretedOption. + * @memberof google.protobuf + * @classdesc Represents an UninterpretedOption. + * @implements IUninterpretedOption + * @constructor + * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set + */ + function UninterpretedOption(properties) { + this.name = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UninterpretedOption name. + * @member {Array.} name + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.name = $util.emptyArray; + + /** + * UninterpretedOption identifierValue. + * @member {string} identifierValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.identifierValue = ""; + + /** + * UninterpretedOption positiveIntValue. + * @member {number|string} positiveIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.positiveIntValue = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * UninterpretedOption negativeIntValue. + * @member {number|string} negativeIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.negativeIntValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * UninterpretedOption doubleValue. + * @member {number} doubleValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.doubleValue = 0; + + /** + * UninterpretedOption stringValue. + * @member {Uint8Array} stringValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.stringValue = $util.newBuffer([]); + + /** + * UninterpretedOption aggregateValue. + * @member {string} aggregateValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.aggregateValue = ""; + + /** + * Creates an UninterpretedOption message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + */ + UninterpretedOption.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UninterpretedOption) + return object; + var message = new $root.google.protobuf.UninterpretedOption(); + if (object.name) { + if (!Array.isArray(object.name)) + throw TypeError(".google.protobuf.UninterpretedOption.name: array expected"); + message.name = []; + for (var i = 0; i < object.name.length; ++i) { + if (typeof object.name[i] !== "object") + throw TypeError(".google.protobuf.UninterpretedOption.name: object expected"); + message.name[i] = $root.google.protobuf.UninterpretedOption.NamePart.fromObject(object.name[i]); + } + } + if (object.identifierValue != null) + message.identifierValue = String(object.identifierValue); + if (object.positiveIntValue != null) + if ($util.Long) + (message.positiveIntValue = $util.Long.fromValue(object.positiveIntValue)).unsigned = true; + else if (typeof object.positiveIntValue === "string") + message.positiveIntValue = parseInt(object.positiveIntValue, 10); + else if (typeof object.positiveIntValue === "number") + message.positiveIntValue = object.positiveIntValue; + else if (typeof object.positiveIntValue === "object") + message.positiveIntValue = new $util.LongBits(object.positiveIntValue.low >>> 0, object.positiveIntValue.high >>> 0).toNumber(true); + if (object.negativeIntValue != null) + if ($util.Long) + (message.negativeIntValue = $util.Long.fromValue(object.negativeIntValue)).unsigned = false; + else if (typeof object.negativeIntValue === "string") + message.negativeIntValue = parseInt(object.negativeIntValue, 10); + else if (typeof object.negativeIntValue === "number") + message.negativeIntValue = object.negativeIntValue; + else if (typeof object.negativeIntValue === "object") + message.negativeIntValue = new $util.LongBits(object.negativeIntValue.low >>> 0, object.negativeIntValue.high >>> 0).toNumber(); + if (object.doubleValue != null) + message.doubleValue = Number(object.doubleValue); + if (object.stringValue != null) + if (typeof object.stringValue === "string") + $util.base64.decode(object.stringValue, message.stringValue = $util.newBuffer($util.base64.length(object.stringValue)), 0); + else if (object.stringValue.length) + message.stringValue = object.stringValue; + if (object.aggregateValue != null) + message.aggregateValue = String(object.aggregateValue); + return message; + }; + + /** + * Creates a plain object from an UninterpretedOption message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.UninterpretedOption} message UninterpretedOption + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UninterpretedOption.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.name = []; + if (options.defaults) { + object.identifierValue = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.positiveIntValue = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.positiveIntValue = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.negativeIntValue = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.negativeIntValue = options.longs === String ? "0" : 0; + object.doubleValue = 0; + if (options.bytes === String) + object.stringValue = ""; + else { + object.stringValue = []; + if (options.bytes !== Array) + object.stringValue = $util.newBuffer(object.stringValue); + } + object.aggregateValue = ""; + } + if (message.name && message.name.length) { + object.name = []; + for (var j = 0; j < message.name.length; ++j) + object.name[j] = $root.google.protobuf.UninterpretedOption.NamePart.toObject(message.name[j], options); + } + if (message.identifierValue != null && message.hasOwnProperty("identifierValue")) + object.identifierValue = message.identifierValue; + if (message.positiveIntValue != null && message.hasOwnProperty("positiveIntValue")) + if (typeof message.positiveIntValue === "number") + object.positiveIntValue = options.longs === String ? String(message.positiveIntValue) : message.positiveIntValue; + else + object.positiveIntValue = options.longs === String ? $util.Long.prototype.toString.call(message.positiveIntValue) : options.longs === Number ? new $util.LongBits(message.positiveIntValue.low >>> 0, message.positiveIntValue.high >>> 0).toNumber(true) : message.positiveIntValue; + if (message.negativeIntValue != null && message.hasOwnProperty("negativeIntValue")) + if (typeof message.negativeIntValue === "number") + object.negativeIntValue = options.longs === String ? String(message.negativeIntValue) : message.negativeIntValue; + else + object.negativeIntValue = options.longs === String ? $util.Long.prototype.toString.call(message.negativeIntValue) : options.longs === Number ? new $util.LongBits(message.negativeIntValue.low >>> 0, message.negativeIntValue.high >>> 0).toNumber() : message.negativeIntValue; + if (message.doubleValue != null && message.hasOwnProperty("doubleValue")) + object.doubleValue = options.json && !isFinite(message.doubleValue) ? String(message.doubleValue) : message.doubleValue; + if (message.stringValue != null && message.hasOwnProperty("stringValue")) + object.stringValue = options.bytes === String ? $util.base64.encode(message.stringValue, 0, message.stringValue.length) : options.bytes === Array ? Array.prototype.slice.call(message.stringValue) : message.stringValue; + if (message.aggregateValue != null && message.hasOwnProperty("aggregateValue")) + object.aggregateValue = message.aggregateValue; + return object; + }; + + /** + * Converts this UninterpretedOption to JSON. + * @function toJSON + * @memberof google.protobuf.UninterpretedOption + * @instance + * @returns {Object.} JSON object + */ + UninterpretedOption.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + UninterpretedOption.NamePart = (function() { + + /** + * Properties of a NamePart. + * @memberof google.protobuf.UninterpretedOption + * @interface INamePart + * @property {string} namePart NamePart namePart + * @property {boolean} isExtension NamePart isExtension + */ + + /** + * Constructs a new NamePart. + * @memberof google.protobuf.UninterpretedOption + * @classdesc Represents a NamePart. + * @implements INamePart + * @constructor + * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set + */ + function NamePart(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * NamePart namePart. + * @member {string} namePart + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.namePart = ""; + + /** + * NamePart isExtension. + * @member {boolean} isExtension + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.isExtension = false; + + /** + * Creates a NamePart message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + */ + NamePart.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UninterpretedOption.NamePart) + return object; + var message = new $root.google.protobuf.UninterpretedOption.NamePart(); + if (object.namePart != null) + message.namePart = String(object.namePart); + if (object.isExtension != null) + message.isExtension = Boolean(object.isExtension); + return message; + }; + + /** + * Creates a plain object from a NamePart message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.NamePart} message NamePart + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + NamePart.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.namePart = ""; + object.isExtension = false; + } + if (message.namePart != null && message.hasOwnProperty("namePart")) + object.namePart = message.namePart; + if (message.isExtension != null && message.hasOwnProperty("isExtension")) + object.isExtension = message.isExtension; + return object; + }; + + /** + * Converts this NamePart to JSON. + * @function toJSON + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + * @returns {Object.} JSON object + */ + NamePart.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return NamePart; + })(); + + return UninterpretedOption; + })(); + + protobuf.SourceCodeInfo = (function() { + + /** + * Properties of a SourceCodeInfo. + * @memberof google.protobuf + * @interface ISourceCodeInfo + * @property {Array.|null} [location] SourceCodeInfo location + */ + + /** + * Constructs a new SourceCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a SourceCodeInfo. + * @implements ISourceCodeInfo + * @constructor + * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set + */ + function SourceCodeInfo(properties) { + this.location = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SourceCodeInfo location. + * @member {Array.} location + * @memberof google.protobuf.SourceCodeInfo + * @instance + */ + SourceCodeInfo.prototype.location = $util.emptyArray; + + /** + * Creates a SourceCodeInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + */ + SourceCodeInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.SourceCodeInfo) + return object; + var message = new $root.google.protobuf.SourceCodeInfo(); + if (object.location) { + if (!Array.isArray(object.location)) + throw TypeError(".google.protobuf.SourceCodeInfo.location: array expected"); + message.location = []; + for (var i = 0; i < object.location.length; ++i) { + if (typeof object.location[i] !== "object") + throw TypeError(".google.protobuf.SourceCodeInfo.location: object expected"); + message.location[i] = $root.google.protobuf.SourceCodeInfo.Location.fromObject(object.location[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a SourceCodeInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.SourceCodeInfo} message SourceCodeInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SourceCodeInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.location = []; + if (message.location && message.location.length) { + object.location = []; + for (var j = 0; j < message.location.length; ++j) + object.location[j] = $root.google.protobuf.SourceCodeInfo.Location.toObject(message.location[j], options); + } + return object; + }; + + /** + * Converts this SourceCodeInfo to JSON. + * @function toJSON + * @memberof google.protobuf.SourceCodeInfo + * @instance + * @returns {Object.} JSON object + */ + SourceCodeInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + SourceCodeInfo.Location = (function() { + + /** + * Properties of a Location. + * @memberof google.protobuf.SourceCodeInfo + * @interface ILocation + * @property {Array.|null} [path] Location path + * @property {Array.|null} [span] Location span + * @property {string|null} [leadingComments] Location leadingComments + * @property {string|null} [trailingComments] Location trailingComments + * @property {Array.|null} [leadingDetachedComments] Location leadingDetachedComments + */ + + /** + * Constructs a new Location. + * @memberof google.protobuf.SourceCodeInfo + * @classdesc Represents a Location. + * @implements ILocation + * @constructor + * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set + */ + function Location(properties) { + this.path = []; + this.span = []; + this.leadingDetachedComments = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Location path. + * @member {Array.} path + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.path = $util.emptyArray; + + /** + * Location span. + * @member {Array.} span + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.span = $util.emptyArray; + + /** + * Location leadingComments. + * @member {string} leadingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingComments = ""; + + /** + * Location trailingComments. + * @member {string} trailingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.trailingComments = ""; + + /** + * Location leadingDetachedComments. + * @member {Array.} leadingDetachedComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingDetachedComments = $util.emptyArray; + + /** + * Creates a Location message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.SourceCodeInfo.Location} Location + */ + Location.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.SourceCodeInfo.Location) + return object; + var message = new $root.google.protobuf.SourceCodeInfo.Location(); + if (object.path) { + if (!Array.isArray(object.path)) + throw TypeError(".google.protobuf.SourceCodeInfo.Location.path: array expected"); + message.path = []; + for (var i = 0; i < object.path.length; ++i) + message.path[i] = object.path[i] | 0; + } + if (object.span) { + if (!Array.isArray(object.span)) + throw TypeError(".google.protobuf.SourceCodeInfo.Location.span: array expected"); + message.span = []; + for (var i = 0; i < object.span.length; ++i) + message.span[i] = object.span[i] | 0; + } + if (object.leadingComments != null) + message.leadingComments = String(object.leadingComments); + if (object.trailingComments != null) + message.trailingComments = String(object.trailingComments); + if (object.leadingDetachedComments) { + if (!Array.isArray(object.leadingDetachedComments)) + throw TypeError(".google.protobuf.SourceCodeInfo.Location.leadingDetachedComments: array expected"); + message.leadingDetachedComments = []; + for (var i = 0; i < object.leadingDetachedComments.length; ++i) + message.leadingDetachedComments[i] = String(object.leadingDetachedComments[i]); + } + return message; + }; + + /** + * Creates a plain object from a Location message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.Location} message Location + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Location.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.path = []; + object.span = []; + object.leadingDetachedComments = []; + } + if (options.defaults) { + object.leadingComments = ""; + object.trailingComments = ""; + } + if (message.path && message.path.length) { + object.path = []; + for (var j = 0; j < message.path.length; ++j) + object.path[j] = message.path[j]; + } + if (message.span && message.span.length) { + object.span = []; + for (var j = 0; j < message.span.length; ++j) + object.span[j] = message.span[j]; + } + if (message.leadingComments != null && message.hasOwnProperty("leadingComments")) + object.leadingComments = message.leadingComments; + if (message.trailingComments != null && message.hasOwnProperty("trailingComments")) + object.trailingComments = message.trailingComments; + if (message.leadingDetachedComments && message.leadingDetachedComments.length) { + object.leadingDetachedComments = []; + for (var j = 0; j < message.leadingDetachedComments.length; ++j) + object.leadingDetachedComments[j] = message.leadingDetachedComments[j]; + } + return object; + }; + + /** + * Converts this Location to JSON. + * @function toJSON + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + * @returns {Object.} JSON object + */ + Location.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Location; + })(); + + return SourceCodeInfo; + })(); + + protobuf.GeneratedCodeInfo = (function() { + + /** + * Properties of a GeneratedCodeInfo. + * @memberof google.protobuf + * @interface IGeneratedCodeInfo + * @property {Array.|null} [annotation] GeneratedCodeInfo annotation + */ + + /** + * Constructs a new GeneratedCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a GeneratedCodeInfo. + * @implements IGeneratedCodeInfo + * @constructor + * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set + */ + function GeneratedCodeInfo(properties) { + this.annotation = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GeneratedCodeInfo annotation. + * @member {Array.} annotation + * @memberof google.protobuf.GeneratedCodeInfo + * @instance + */ + GeneratedCodeInfo.prototype.annotation = $util.emptyArray; + + /** + * Creates a GeneratedCodeInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + */ + GeneratedCodeInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.GeneratedCodeInfo) + return object; + var message = new $root.google.protobuf.GeneratedCodeInfo(); + if (object.annotation) { + if (!Array.isArray(object.annotation)) + throw TypeError(".google.protobuf.GeneratedCodeInfo.annotation: array expected"); + message.annotation = []; + for (var i = 0; i < object.annotation.length; ++i) { + if (typeof object.annotation[i] !== "object") + throw TypeError(".google.protobuf.GeneratedCodeInfo.annotation: object expected"); + message.annotation[i] = $root.google.protobuf.GeneratedCodeInfo.Annotation.fromObject(object.annotation[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a GeneratedCodeInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.GeneratedCodeInfo} message GeneratedCodeInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GeneratedCodeInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.annotation = []; + if (message.annotation && message.annotation.length) { + object.annotation = []; + for (var j = 0; j < message.annotation.length; ++j) + object.annotation[j] = $root.google.protobuf.GeneratedCodeInfo.Annotation.toObject(message.annotation[j], options); + } + return object; + }; + + /** + * Converts this GeneratedCodeInfo to JSON. + * @function toJSON + * @memberof google.protobuf.GeneratedCodeInfo + * @instance + * @returns {Object.} JSON object + */ + GeneratedCodeInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GeneratedCodeInfo.Annotation = (function() { + + /** + * Properties of an Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @interface IAnnotation + * @property {Array.|null} [path] Annotation path + * @property {string|null} [sourceFile] Annotation sourceFile + * @property {number|null} [begin] Annotation begin + * @property {number|null} [end] Annotation end + */ + + /** + * Constructs a new Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @classdesc Represents an Annotation. + * @implements IAnnotation + * @constructor + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set + */ + function Annotation(properties) { + this.path = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Annotation path. + * @member {Array.} path + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.path = $util.emptyArray; + + /** + * Annotation sourceFile. + * @member {string} sourceFile + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.sourceFile = ""; + + /** + * Annotation begin. + * @member {number} begin + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.begin = 0; + + /** + * Annotation end. + * @member {number} end + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.end = 0; + + /** + * Creates an Annotation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + */ + Annotation.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.GeneratedCodeInfo.Annotation) + return object; + var message = new $root.google.protobuf.GeneratedCodeInfo.Annotation(); + if (object.path) { + if (!Array.isArray(object.path)) + throw TypeError(".google.protobuf.GeneratedCodeInfo.Annotation.path: array expected"); + message.path = []; + for (var i = 0; i < object.path.length; ++i) + message.path[i] = object.path[i] | 0; + } + if (object.sourceFile != null) + message.sourceFile = String(object.sourceFile); + if (object.begin != null) + message.begin = object.begin | 0; + if (object.end != null) + message.end = object.end | 0; + return message; + }; + + /** + * Creates a plain object from an Annotation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.Annotation} message Annotation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Annotation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.path = []; + if (options.defaults) { + object.sourceFile = ""; + object.begin = 0; + object.end = 0; + } + if (message.path && message.path.length) { + object.path = []; + for (var j = 0; j < message.path.length; ++j) + object.path[j] = message.path[j]; + } + if (message.sourceFile != null && message.hasOwnProperty("sourceFile")) + object.sourceFile = message.sourceFile; + if (message.begin != null && message.hasOwnProperty("begin")) + object.begin = message.begin; + if (message.end != null && message.hasOwnProperty("end")) + object.end = message.end; + return object; + }; + + /** + * Converts this Annotation to JSON. + * @function toJSON + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + * @returns {Object.} JSON object + */ + Annotation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Annotation; + })(); + + return GeneratedCodeInfo; + })(); + + protobuf.Struct = (function() { + + /** + * Properties of a Struct. + * @memberof google.protobuf + * @interface IStruct + * @property {Object.|null} [fields] Struct fields + */ + + /** + * Constructs a new Struct. + * @memberof google.protobuf + * @classdesc Represents a Struct. + * @implements IStruct + * @constructor + * @param {google.protobuf.IStruct=} [properties] Properties to set + */ + function Struct(properties) { + this.fields = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Struct fields. + * @member {Object.} fields + * @memberof google.protobuf.Struct + * @instance + */ + Struct.prototype.fields = $util.emptyObject; + + /** + * Creates a Struct message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Struct + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Struct} Struct + */ + Struct.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Struct) + return object; + var message = new $root.google.protobuf.Struct(); + if (object.fields) { + if (typeof object.fields !== "object") + throw TypeError(".google.protobuf.Struct.fields: object expected"); + message.fields = {}; + for (var keys = Object.keys(object.fields), i = 0; i < keys.length; ++i) { + if (typeof object.fields[keys[i]] !== "object") + throw TypeError(".google.protobuf.Struct.fields: object expected"); + message.fields[keys[i]] = $root.google.protobuf.Value.fromObject(object.fields[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from a Struct message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Struct + * @static + * @param {google.protobuf.Struct} message Struct + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Struct.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.fields = {}; + var keys2; + if (message.fields && (keys2 = Object.keys(message.fields)).length) { + object.fields = {}; + for (var j = 0; j < keys2.length; ++j) + object.fields[keys2[j]] = $root.google.protobuf.Value.toObject(message.fields[keys2[j]], options); + } + return object; + }; + + /** + * Converts this Struct to JSON. + * @function toJSON + * @memberof google.protobuf.Struct + * @instance + * @returns {Object.} JSON object + */ + Struct.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Struct; + })(); + + protobuf.Value = (function() { + + /** + * Properties of a Value. + * @memberof google.protobuf + * @interface IValue + * @property {google.protobuf.NullValue|null} [nullValue] Value nullValue + * @property {number|null} [numberValue] Value numberValue + * @property {string|null} [stringValue] Value stringValue + * @property {boolean|null} [boolValue] Value boolValue + * @property {google.protobuf.IStruct|null} [structValue] Value structValue + * @property {google.protobuf.IListValue|null} [listValue] Value listValue + */ + + /** + * Constructs a new Value. + * @memberof google.protobuf + * @classdesc Represents a Value. + * @implements IValue + * @constructor + * @param {google.protobuf.IValue=} [properties] Properties to set + */ + function Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Value nullValue. + * @member {google.protobuf.NullValue} nullValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.nullValue = 0; + + /** + * Value numberValue. + * @member {number} numberValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.numberValue = 0; + + /** + * Value stringValue. + * @member {string} stringValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.stringValue = ""; + + /** + * Value boolValue. + * @member {boolean} boolValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.boolValue = false; + + /** + * Value structValue. + * @member {google.protobuf.IStruct|null|undefined} structValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.structValue = null; + + /** + * Value listValue. + * @member {google.protobuf.IListValue|null|undefined} listValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.listValue = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Value kind. + * @member {"nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"|undefined} kind + * @memberof google.protobuf.Value + * @instance + */ + Object.defineProperty(Value.prototype, "kind", { + get: $util.oneOfGetter($oneOfFields = ["nullValue", "numberValue", "stringValue", "boolValue", "structValue", "listValue"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Value} Value + */ + Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Value) + return object; + var message = new $root.google.protobuf.Value(); + switch (object.nullValue) { + case "NULL_VALUE": + case 0: + message.nullValue = 0; + break; + } + if (object.numberValue != null) + message.numberValue = Number(object.numberValue); + if (object.stringValue != null) + message.stringValue = String(object.stringValue); + if (object.boolValue != null) + message.boolValue = Boolean(object.boolValue); + if (object.structValue != null) { + if (typeof object.structValue !== "object") + throw TypeError(".google.protobuf.Value.structValue: object expected"); + message.structValue = $root.google.protobuf.Struct.fromObject(object.structValue); + } + if (object.listValue != null) { + if (typeof object.listValue !== "object") + throw TypeError(".google.protobuf.Value.listValue: object expected"); + message.listValue = $root.google.protobuf.ListValue.fromObject(object.listValue); + } + return message; + }; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Value + * @static + * @param {google.protobuf.Value} message Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.nullValue != null && message.hasOwnProperty("nullValue")) { + object.nullValue = options.enums === String ? $root.google.protobuf.NullValue[message.nullValue] : message.nullValue; + if (options.oneofs) + object.kind = "nullValue"; + } + if (message.numberValue != null && message.hasOwnProperty("numberValue")) { + object.numberValue = options.json && !isFinite(message.numberValue) ? String(message.numberValue) : message.numberValue; + if (options.oneofs) + object.kind = "numberValue"; + } + if (message.stringValue != null && message.hasOwnProperty("stringValue")) { + object.stringValue = message.stringValue; + if (options.oneofs) + object.kind = "stringValue"; + } + if (message.boolValue != null && message.hasOwnProperty("boolValue")) { + object.boolValue = message.boolValue; + if (options.oneofs) + object.kind = "boolValue"; + } + if (message.structValue != null && message.hasOwnProperty("structValue")) { + object.structValue = $root.google.protobuf.Struct.toObject(message.structValue, options); + if (options.oneofs) + object.kind = "structValue"; + } + if (message.listValue != null && message.hasOwnProperty("listValue")) { + object.listValue = $root.google.protobuf.ListValue.toObject(message.listValue, options); + if (options.oneofs) + object.kind = "listValue"; + } + return object; + }; + + /** + * Converts this Value to JSON. + * @function toJSON + * @memberof google.protobuf.Value + * @instance + * @returns {Object.} JSON object + */ + Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Value; + })(); + /** - * Constructs a new CancelOperationRequest. - * @memberof google.longrunning - * @classdesc Represents a CancelOperationRequest. - * @implements ICancelOperationRequest - * @constructor - * @param {google.longrunning.ICancelOperationRequest=} [properties] Properties to set + * NullValue enum. + * @name google.protobuf.NullValue + * @enum {string} + * @property {string} NULL_VALUE=NULL_VALUE NULL_VALUE value */ - function CancelOperationRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - + protobuf.NullValue = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "NULL_VALUE"] = "NULL_VALUE"; + return values; + })(); + + protobuf.ListValue = (function() { + + /** + * Properties of a ListValue. + * @memberof google.protobuf + * @interface IListValue + * @property {Array.|null} [values] ListValue values + */ + + /** + * Constructs a new ListValue. + * @memberof google.protobuf + * @classdesc Represents a ListValue. + * @implements IListValue + * @constructor + * @param {google.protobuf.IListValue=} [properties] Properties to set + */ + function ListValue(properties) { + this.values = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListValue values. + * @member {Array.} values + * @memberof google.protobuf.ListValue + * @instance + */ + ListValue.prototype.values = $util.emptyArray; + + /** + * Creates a ListValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ListValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ListValue} ListValue + */ + ListValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ListValue) + return object; + var message = new $root.google.protobuf.ListValue(); + if (object.values) { + if (!Array.isArray(object.values)) + throw TypeError(".google.protobuf.ListValue.values: array expected"); + message.values = []; + for (var i = 0; i < object.values.length; ++i) { + if (typeof object.values[i] !== "object") + throw TypeError(".google.protobuf.ListValue.values: object expected"); + message.values[i] = $root.google.protobuf.Value.fromObject(object.values[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a ListValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ListValue + * @static + * @param {google.protobuf.ListValue} message ListValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.values = []; + if (message.values && message.values.length) { + object.values = []; + for (var j = 0; j < message.values.length; ++j) + object.values[j] = $root.google.protobuf.Value.toObject(message.values[j], options); + } + return object; + }; + + /** + * Converts this ListValue to JSON. + * @function toJSON + * @memberof google.protobuf.ListValue + * @instance + * @returns {Object.} JSON object + */ + ListValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListValue; + })(); + + protobuf.Empty = (function() { + + /** + * Properties of an Empty. + * @memberof google.protobuf + * @interface IEmpty + */ + + /** + * Constructs a new Empty. + * @memberof google.protobuf + * @classdesc Represents an Empty. + * @implements IEmpty + * @constructor + * @param {google.protobuf.IEmpty=} [properties] Properties to set + */ + function Empty(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates an Empty message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Empty + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Empty} Empty + */ + Empty.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Empty) + return object; + return new $root.google.protobuf.Empty(); + }; + + /** + * Creates a plain object from an Empty message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.Empty} message Empty + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Empty.toObject = function toObject() { + return {}; + }; + + /** + * Converts this Empty to JSON. + * @function toJSON + * @memberof google.protobuf.Empty + * @instance + * @returns {Object.} JSON object + */ + Empty.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Empty; + })(); + + protobuf.DoubleValue = (function() { + + /** + * Properties of a DoubleValue. + * @memberof google.protobuf + * @interface IDoubleValue + * @property {number|null} [value] DoubleValue value + */ + + /** + * Constructs a new DoubleValue. + * @memberof google.protobuf + * @classdesc Represents a DoubleValue. + * @implements IDoubleValue + * @constructor + * @param {google.protobuf.IDoubleValue=} [properties] Properties to set + */ + function DoubleValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DoubleValue value. + * @member {number} value + * @memberof google.protobuf.DoubleValue + * @instance + */ + DoubleValue.prototype.value = 0; + + /** + * Creates a DoubleValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DoubleValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DoubleValue} DoubleValue + */ + DoubleValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DoubleValue) + return object; + var message = new $root.google.protobuf.DoubleValue(); + if (object.value != null) + message.value = Number(object.value); + return message; + }; + + /** + * Creates a plain object from a DoubleValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DoubleValue + * @static + * @param {google.protobuf.DoubleValue} message DoubleValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DoubleValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = 0; + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.json && !isFinite(message.value) ? String(message.value) : message.value; + return object; + }; + + /** + * Converts this DoubleValue to JSON. + * @function toJSON + * @memberof google.protobuf.DoubleValue + * @instance + * @returns {Object.} JSON object + */ + DoubleValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DoubleValue; + })(); + + protobuf.FloatValue = (function() { + + /** + * Properties of a FloatValue. + * @memberof google.protobuf + * @interface IFloatValue + * @property {number|null} [value] FloatValue value + */ + + /** + * Constructs a new FloatValue. + * @memberof google.protobuf + * @classdesc Represents a FloatValue. + * @implements IFloatValue + * @constructor + * @param {google.protobuf.IFloatValue=} [properties] Properties to set + */ + function FloatValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FloatValue value. + * @member {number} value + * @memberof google.protobuf.FloatValue + * @instance + */ + FloatValue.prototype.value = 0; + + /** + * Creates a FloatValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FloatValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FloatValue} FloatValue + */ + FloatValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FloatValue) + return object; + var message = new $root.google.protobuf.FloatValue(); + if (object.value != null) + message.value = Number(object.value); + return message; + }; + + /** + * Creates a plain object from a FloatValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FloatValue + * @static + * @param {google.protobuf.FloatValue} message FloatValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FloatValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = 0; + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.json && !isFinite(message.value) ? String(message.value) : message.value; + return object; + }; + + /** + * Converts this FloatValue to JSON. + * @function toJSON + * @memberof google.protobuf.FloatValue + * @instance + * @returns {Object.} JSON object + */ + FloatValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FloatValue; + })(); + + protobuf.Int64Value = (function() { + + /** + * Properties of an Int64Value. + * @memberof google.protobuf + * @interface IInt64Value + * @property {number|string|null} [value] Int64Value value + */ + + /** + * Constructs a new Int64Value. + * @memberof google.protobuf + * @classdesc Represents an Int64Value. + * @implements IInt64Value + * @constructor + * @param {google.protobuf.IInt64Value=} [properties] Properties to set + */ + function Int64Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Int64Value value. + * @member {number|string} value + * @memberof google.protobuf.Int64Value + * @instance + */ + Int64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates an Int64Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Int64Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Int64Value} Int64Value + */ + Int64Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Int64Value) + return object; + var message = new $root.google.protobuf.Int64Value(); + if (object.value != null) + if ($util.Long) + (message.value = $util.Long.fromValue(object.value)).unsigned = false; + else if (typeof object.value === "string") + message.value = parseInt(object.value, 10); + else if (typeof object.value === "number") + message.value = object.value; + else if (typeof object.value === "object") + message.value = new $util.LongBits(object.value.low >>> 0, object.value.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from an Int64Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Int64Value + * @static + * @param {google.protobuf.Int64Value} message Int64Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Int64Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.value = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.value = options.longs === String ? "0" : 0; + if (message.value != null && message.hasOwnProperty("value")) + if (typeof message.value === "number") + object.value = options.longs === String ? String(message.value) : message.value; + else + object.value = options.longs === String ? $util.Long.prototype.toString.call(message.value) : options.longs === Number ? new $util.LongBits(message.value.low >>> 0, message.value.high >>> 0).toNumber() : message.value; + return object; + }; + + /** + * Converts this Int64Value to JSON. + * @function toJSON + * @memberof google.protobuf.Int64Value + * @instance + * @returns {Object.} JSON object + */ + Int64Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Int64Value; + })(); + + protobuf.UInt64Value = (function() { + + /** + * Properties of a UInt64Value. + * @memberof google.protobuf + * @interface IUInt64Value + * @property {number|string|null} [value] UInt64Value value + */ + + /** + * Constructs a new UInt64Value. + * @memberof google.protobuf + * @classdesc Represents a UInt64Value. + * @implements IUInt64Value + * @constructor + * @param {google.protobuf.IUInt64Value=} [properties] Properties to set + */ + function UInt64Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UInt64Value value. + * @member {number|string} value + * @memberof google.protobuf.UInt64Value + * @instance + */ + UInt64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Creates a UInt64Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UInt64Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UInt64Value} UInt64Value + */ + UInt64Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UInt64Value) + return object; + var message = new $root.google.protobuf.UInt64Value(); + if (object.value != null) + if ($util.Long) + (message.value = $util.Long.fromValue(object.value)).unsigned = true; + else if (typeof object.value === "string") + message.value = parseInt(object.value, 10); + else if (typeof object.value === "number") + message.value = object.value; + else if (typeof object.value === "object") + message.value = new $util.LongBits(object.value.low >>> 0, object.value.high >>> 0).toNumber(true); + return message; + }; + + /** + * Creates a plain object from a UInt64Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UInt64Value + * @static + * @param {google.protobuf.UInt64Value} message UInt64Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UInt64Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.value = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.value = options.longs === String ? "0" : 0; + if (message.value != null && message.hasOwnProperty("value")) + if (typeof message.value === "number") + object.value = options.longs === String ? String(message.value) : message.value; + else + object.value = options.longs === String ? $util.Long.prototype.toString.call(message.value) : options.longs === Number ? new $util.LongBits(message.value.low >>> 0, message.value.high >>> 0).toNumber(true) : message.value; + return object; + }; + + /** + * Converts this UInt64Value to JSON. + * @function toJSON + * @memberof google.protobuf.UInt64Value + * @instance + * @returns {Object.} JSON object + */ + UInt64Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return UInt64Value; + })(); + + protobuf.Int32Value = (function() { + + /** + * Properties of an Int32Value. + * @memberof google.protobuf + * @interface IInt32Value + * @property {number|null} [value] Int32Value value + */ + + /** + * Constructs a new Int32Value. + * @memberof google.protobuf + * @classdesc Represents an Int32Value. + * @implements IInt32Value + * @constructor + * @param {google.protobuf.IInt32Value=} [properties] Properties to set + */ + function Int32Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Int32Value value. + * @member {number} value + * @memberof google.protobuf.Int32Value + * @instance + */ + Int32Value.prototype.value = 0; + + /** + * Creates an Int32Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Int32Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Int32Value} Int32Value + */ + Int32Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Int32Value) + return object; + var message = new $root.google.protobuf.Int32Value(); + if (object.value != null) + message.value = object.value | 0; + return message; + }; + + /** + * Creates a plain object from an Int32Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Int32Value + * @static + * @param {google.protobuf.Int32Value} message Int32Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Int32Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = 0; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this Int32Value to JSON. + * @function toJSON + * @memberof google.protobuf.Int32Value + * @instance + * @returns {Object.} JSON object + */ + Int32Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Int32Value; + })(); + + protobuf.UInt32Value = (function() { + + /** + * Properties of a UInt32Value. + * @memberof google.protobuf + * @interface IUInt32Value + * @property {number|null} [value] UInt32Value value + */ + + /** + * Constructs a new UInt32Value. + * @memberof google.protobuf + * @classdesc Represents a UInt32Value. + * @implements IUInt32Value + * @constructor + * @param {google.protobuf.IUInt32Value=} [properties] Properties to set + */ + function UInt32Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UInt32Value value. + * @member {number} value + * @memberof google.protobuf.UInt32Value + * @instance + */ + UInt32Value.prototype.value = 0; + + /** + * Creates a UInt32Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UInt32Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UInt32Value} UInt32Value + */ + UInt32Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UInt32Value) + return object; + var message = new $root.google.protobuf.UInt32Value(); + if (object.value != null) + message.value = object.value >>> 0; + return message; + }; + + /** + * Creates a plain object from a UInt32Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UInt32Value + * @static + * @param {google.protobuf.UInt32Value} message UInt32Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UInt32Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = 0; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this UInt32Value to JSON. + * @function toJSON + * @memberof google.protobuf.UInt32Value + * @instance + * @returns {Object.} JSON object + */ + UInt32Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return UInt32Value; + })(); + + protobuf.BoolValue = (function() { + + /** + * Properties of a BoolValue. + * @memberof google.protobuf + * @interface IBoolValue + * @property {boolean|null} [value] BoolValue value + */ + + /** + * Constructs a new BoolValue. + * @memberof google.protobuf + * @classdesc Represents a BoolValue. + * @implements IBoolValue + * @constructor + * @param {google.protobuf.IBoolValue=} [properties] Properties to set + */ + function BoolValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BoolValue value. + * @member {boolean} value + * @memberof google.protobuf.BoolValue + * @instance + */ + BoolValue.prototype.value = false; + + /** + * Creates a BoolValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.BoolValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.BoolValue} BoolValue + */ + BoolValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.BoolValue) + return object; + var message = new $root.google.protobuf.BoolValue(); + if (object.value != null) + message.value = Boolean(object.value); + return message; + }; + + /** + * Creates a plain object from a BoolValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.BoolValue + * @static + * @param {google.protobuf.BoolValue} message BoolValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BoolValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = false; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this BoolValue to JSON. + * @function toJSON + * @memberof google.protobuf.BoolValue + * @instance + * @returns {Object.} JSON object + */ + BoolValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BoolValue; + })(); + + protobuf.StringValue = (function() { + + /** + * Properties of a StringValue. + * @memberof google.protobuf + * @interface IStringValue + * @property {string|null} [value] StringValue value + */ + + /** + * Constructs a new StringValue. + * @memberof google.protobuf + * @classdesc Represents a StringValue. + * @implements IStringValue + * @constructor + * @param {google.protobuf.IStringValue=} [properties] Properties to set + */ + function StringValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StringValue value. + * @member {string} value + * @memberof google.protobuf.StringValue + * @instance + */ + StringValue.prototype.value = ""; + + /** + * Creates a StringValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.StringValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.StringValue} StringValue + */ + StringValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.StringValue) + return object; + var message = new $root.google.protobuf.StringValue(); + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from a StringValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.StringValue + * @static + * @param {google.protobuf.StringValue} message StringValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StringValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = ""; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this StringValue to JSON. + * @function toJSON + * @memberof google.protobuf.StringValue + * @instance + * @returns {Object.} JSON object + */ + StringValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return StringValue; + })(); + + protobuf.BytesValue = (function() { + + /** + * Properties of a BytesValue. + * @memberof google.protobuf + * @interface IBytesValue + * @property {Uint8Array|null} [value] BytesValue value + */ + + /** + * Constructs a new BytesValue. + * @memberof google.protobuf + * @classdesc Represents a BytesValue. + * @implements IBytesValue + * @constructor + * @param {google.protobuf.IBytesValue=} [properties] Properties to set + */ + function BytesValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BytesValue value. + * @member {Uint8Array} value + * @memberof google.protobuf.BytesValue + * @instance + */ + BytesValue.prototype.value = $util.newBuffer([]); + + /** + * Creates a BytesValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.BytesValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.BytesValue} BytesValue + */ + BytesValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.BytesValue) + return object; + var message = new $root.google.protobuf.BytesValue(); + if (object.value != null) + if (typeof object.value === "string") + $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); + else if (object.value.length) + message.value = object.value; + return message; + }; + + /** + * Creates a plain object from a BytesValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.BytesValue + * @static + * @param {google.protobuf.BytesValue} message BytesValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BytesValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.value = ""; + else { + object.value = []; + if (options.bytes !== Array) + object.value = $util.newBuffer(object.value); + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; + return object; + }; + + /** + * Converts this BytesValue to JSON. + * @function toJSON + * @memberof google.protobuf.BytesValue + * @instance + * @returns {Object.} JSON object + */ + BytesValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BytesValue; + })(); + + protobuf.Any = (function() { + + /** + * Properties of an Any. + * @memberof google.protobuf + * @interface IAny + * @property {string|null} [type_url] Any type_url + * @property {Uint8Array|null} [value] Any value + */ + + /** + * Constructs a new Any. + * @memberof google.protobuf + * @classdesc Represents an Any. + * @implements IAny + * @constructor + * @param {google.protobuf.IAny=} [properties] Properties to set + */ + function Any(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Any type_url. + * @member {string} type_url + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.type_url = ""; + + /** + * Any value. + * @member {Uint8Array} value + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.value = $util.newBuffer([]); + + /** + * Creates an Any message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Any + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Any} Any + */ + Any.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Any) + return object; + var message = new $root.google.protobuf.Any(); + if (object.type_url != null) + message.type_url = String(object.type_url); + if (object.value != null) + if (typeof object.value === "string") + $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); + else if (object.value.length) + message.value = object.value; + return message; + }; + + /** + * Creates a plain object from an Any message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.Any} message Any + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Any.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.type_url = ""; + if (options.bytes === String) + object.value = ""; + else { + object.value = []; + if (options.bytes !== Array) + object.value = $util.newBuffer(object.value); + } + } + if (message.type_url != null && message.hasOwnProperty("type_url")) + object.type_url = message.type_url; + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; + return object; + }; + + /** + * Converts this Any to JSON. + * @function toJSON + * @memberof google.protobuf.Any + * @instance + * @returns {Object.} JSON object + */ + Any.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Any; + })(); + + protobuf.FieldMask = (function() { + + /** + * Properties of a FieldMask. + * @memberof google.protobuf + * @interface IFieldMask + * @property {Array.|null} [paths] FieldMask paths + */ + + /** + * Constructs a new FieldMask. + * @memberof google.protobuf + * @classdesc Represents a FieldMask. + * @implements IFieldMask + * @constructor + * @param {google.protobuf.IFieldMask=} [properties] Properties to set + */ + function FieldMask(properties) { + this.paths = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldMask paths. + * @member {Array.} paths + * @memberof google.protobuf.FieldMask + * @instance + */ + FieldMask.prototype.paths = $util.emptyArray; + + /** + * Creates a FieldMask message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldMask + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldMask} FieldMask + */ + FieldMask.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldMask) + return object; + var message = new $root.google.protobuf.FieldMask(); + if (object.paths) { + if (!Array.isArray(object.paths)) + throw TypeError(".google.protobuf.FieldMask.paths: array expected"); + message.paths = []; + for (var i = 0; i < object.paths.length; ++i) + message.paths[i] = String(object.paths[i]); + } + return message; + }; + + /** + * Creates a plain object from a FieldMask message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldMask + * @static + * @param {google.protobuf.FieldMask} message FieldMask + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldMask.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.paths = []; + if (message.paths && message.paths.length) { + object.paths = []; + for (var j = 0; j < message.paths.length; ++j) + object.paths[j] = message.paths[j]; + } + return object; + }; + + /** + * Converts this FieldMask to JSON. + * @function toJSON + * @memberof google.protobuf.FieldMask + * @instance + * @returns {Object.} JSON object + */ + FieldMask.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FieldMask; + })(); + + protobuf.Duration = (function() { + + /** + * Properties of a Duration. + * @memberof google.protobuf + * @interface IDuration + * @property {number|string|null} [seconds] Duration seconds + * @property {number|null} [nanos] Duration nanos + */ + + /** + * Constructs a new Duration. + * @memberof google.protobuf + * @classdesc Represents a Duration. + * @implements IDuration + * @constructor + * @param {google.protobuf.IDuration=} [properties] Properties to set + */ + function Duration(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Duration seconds. + * @member {number|string} seconds + * @memberof google.protobuf.Duration + * @instance + */ + Duration.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Duration nanos. + * @member {number} nanos + * @memberof google.protobuf.Duration + * @instance + */ + Duration.prototype.nanos = 0; + + /** + * Creates a Duration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Duration + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Duration} Duration + */ + Duration.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Duration) + return object; + var message = new $root.google.protobuf.Duration(); + if (object.seconds != null) + if ($util.Long) + (message.seconds = $util.Long.fromValue(object.seconds)).unsigned = false; + else if (typeof object.seconds === "string") + message.seconds = parseInt(object.seconds, 10); + else if (typeof object.seconds === "number") + message.seconds = object.seconds; + else if (typeof object.seconds === "object") + message.seconds = new $util.LongBits(object.seconds.low >>> 0, object.seconds.high >>> 0).toNumber(); + if (object.nanos != null) + message.nanos = object.nanos | 0; + return message; + }; + + /** + * Creates a plain object from a Duration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Duration + * @static + * @param {google.protobuf.Duration} message Duration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Duration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.seconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.seconds = options.longs === String ? "0" : 0; + object.nanos = 0; + } + if (message.seconds != null && message.hasOwnProperty("seconds")) + if (typeof message.seconds === "number") + object.seconds = options.longs === String ? String(message.seconds) : message.seconds; + else + object.seconds = options.longs === String ? $util.Long.prototype.toString.call(message.seconds) : options.longs === Number ? new $util.LongBits(message.seconds.low >>> 0, message.seconds.high >>> 0).toNumber() : message.seconds; + if (message.nanos != null && message.hasOwnProperty("nanos")) + object.nanos = message.nanos; + return object; + }; + + /** + * Converts this Duration to JSON. + * @function toJSON + * @memberof google.protobuf.Duration + * @instance + * @returns {Object.} JSON object + */ + Duration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Duration; + })(); + + return protobuf; + })(); + + google.firestore = (function() { + /** - * CancelOperationRequest name. - * @member {string} name - * @memberof google.longrunning.CancelOperationRequest - * @instance + * Namespace firestore. + * @memberof google + * @namespace */ - CancelOperationRequest.prototype.name = ""; - - return CancelOperationRequest; + var firestore = {}; + + firestore.v1 = (function() { + + /** + * Namespace v1. + * @memberof google.firestore + * @namespace + */ + var v1 = {}; + + v1.DocumentMask = (function() { + + /** + * Properties of a DocumentMask. + * @memberof google.firestore.v1 + * @interface IDocumentMask + * @property {Array.|null} [fieldPaths] DocumentMask fieldPaths + */ + + /** + * Constructs a new DocumentMask. + * @memberof google.firestore.v1 + * @classdesc Represents a DocumentMask. + * @implements IDocumentMask + * @constructor + * @param {google.firestore.v1.IDocumentMask=} [properties] Properties to set + */ + function DocumentMask(properties) { + this.fieldPaths = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentMask fieldPaths. + * @member {Array.} fieldPaths + * @memberof google.firestore.v1.DocumentMask + * @instance + */ + DocumentMask.prototype.fieldPaths = $util.emptyArray; + + /** + * Creates a DocumentMask message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.DocumentMask + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.DocumentMask} DocumentMask + */ + DocumentMask.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.DocumentMask) + return object; + var message = new $root.google.firestore.v1.DocumentMask(); + if (object.fieldPaths) { + if (!Array.isArray(object.fieldPaths)) + throw TypeError(".google.firestore.v1.DocumentMask.fieldPaths: array expected"); + message.fieldPaths = []; + for (var i = 0; i < object.fieldPaths.length; ++i) + message.fieldPaths[i] = String(object.fieldPaths[i]); + } + return message; + }; + + /** + * Creates a plain object from a DocumentMask message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.DocumentMask + * @static + * @param {google.firestore.v1.DocumentMask} message DocumentMask + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentMask.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.fieldPaths = []; + if (message.fieldPaths && message.fieldPaths.length) { + object.fieldPaths = []; + for (var j = 0; j < message.fieldPaths.length; ++j) + object.fieldPaths[j] = message.fieldPaths[j]; + } + return object; + }; + + /** + * Converts this DocumentMask to JSON. + * @function toJSON + * @memberof google.firestore.v1.DocumentMask + * @instance + * @returns {Object.} JSON object + */ + DocumentMask.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DocumentMask; + })(); + + v1.Precondition = (function() { + + /** + * Properties of a Precondition. + * @memberof google.firestore.v1 + * @interface IPrecondition + * @property {boolean|null} [exists] Precondition exists + * @property {google.protobuf.ITimestamp|null} [updateTime] Precondition updateTime + */ + + /** + * Constructs a new Precondition. + * @memberof google.firestore.v1 + * @classdesc Represents a Precondition. + * @implements IPrecondition + * @constructor + * @param {google.firestore.v1.IPrecondition=} [properties] Properties to set + */ + function Precondition(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Precondition exists. + * @member {boolean} exists + * @memberof google.firestore.v1.Precondition + * @instance + */ + Precondition.prototype.exists = false; + + /** + * Precondition updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.firestore.v1.Precondition + * @instance + */ + Precondition.prototype.updateTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Precondition conditionType. + * @member {"exists"|"updateTime"|undefined} conditionType + * @memberof google.firestore.v1.Precondition + * @instance + */ + Object.defineProperty(Precondition.prototype, "conditionType", { + get: $util.oneOfGetter($oneOfFields = ["exists", "updateTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a Precondition message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.Precondition + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.Precondition} Precondition + */ + Precondition.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.Precondition) + return object; + var message = new $root.google.firestore.v1.Precondition(); + if (object.exists != null) + message.exists = Boolean(object.exists); + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.firestore.v1.Precondition.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + return message; + }; + + /** + * Creates a plain object from a Precondition message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.Precondition + * @static + * @param {google.firestore.v1.Precondition} message Precondition + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Precondition.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.exists != null && message.hasOwnProperty("exists")) { + object.exists = message.exists; + if (options.oneofs) + object.conditionType = "exists"; + } + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (options.oneofs) + object.conditionType = "updateTime"; + } + return object; + }; + + /** + * Converts this Precondition to JSON. + * @function toJSON + * @memberof google.firestore.v1.Precondition + * @instance + * @returns {Object.} JSON object + */ + Precondition.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Precondition; + })(); + + v1.TransactionOptions = (function() { + + /** + * Properties of a TransactionOptions. + * @memberof google.firestore.v1 + * @interface ITransactionOptions + * @property {google.firestore.v1.TransactionOptions.IReadOnly|null} [readOnly] TransactionOptions readOnly + * @property {google.firestore.v1.TransactionOptions.IReadWrite|null} [readWrite] TransactionOptions readWrite + */ + + /** + * Constructs a new TransactionOptions. + * @memberof google.firestore.v1 + * @classdesc Represents a TransactionOptions. + * @implements ITransactionOptions + * @constructor + * @param {google.firestore.v1.ITransactionOptions=} [properties] Properties to set + */ + function TransactionOptions(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * TransactionOptions readOnly. + * @member {google.firestore.v1.TransactionOptions.IReadOnly|null|undefined} readOnly + * @memberof google.firestore.v1.TransactionOptions + * @instance + */ + TransactionOptions.prototype.readOnly = null; + + /** + * TransactionOptions readWrite. + * @member {google.firestore.v1.TransactionOptions.IReadWrite|null|undefined} readWrite + * @memberof google.firestore.v1.TransactionOptions + * @instance + */ + TransactionOptions.prototype.readWrite = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * TransactionOptions mode. + * @member {"readOnly"|"readWrite"|undefined} mode + * @memberof google.firestore.v1.TransactionOptions + * @instance + */ + Object.defineProperty(TransactionOptions.prototype, "mode", { + get: $util.oneOfGetter($oneOfFields = ["readOnly", "readWrite"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a TransactionOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.TransactionOptions + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.TransactionOptions} TransactionOptions + */ + TransactionOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.TransactionOptions) + return object; + var message = new $root.google.firestore.v1.TransactionOptions(); + if (object.readOnly != null) { + if (typeof object.readOnly !== "object") + throw TypeError(".google.firestore.v1.TransactionOptions.readOnly: object expected"); + message.readOnly = $root.google.firestore.v1.TransactionOptions.ReadOnly.fromObject(object.readOnly); + } + if (object.readWrite != null) { + if (typeof object.readWrite !== "object") + throw TypeError(".google.firestore.v1.TransactionOptions.readWrite: object expected"); + message.readWrite = $root.google.firestore.v1.TransactionOptions.ReadWrite.fromObject(object.readWrite); + } + return message; + }; + + /** + * Creates a plain object from a TransactionOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.TransactionOptions + * @static + * @param {google.firestore.v1.TransactionOptions} message TransactionOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TransactionOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.readOnly != null && message.hasOwnProperty("readOnly")) { + object.readOnly = $root.google.firestore.v1.TransactionOptions.ReadOnly.toObject(message.readOnly, options); + if (options.oneofs) + object.mode = "readOnly"; + } + if (message.readWrite != null && message.hasOwnProperty("readWrite")) { + object.readWrite = $root.google.firestore.v1.TransactionOptions.ReadWrite.toObject(message.readWrite, options); + if (options.oneofs) + object.mode = "readWrite"; + } + return object; + }; + + /** + * Converts this TransactionOptions to JSON. + * @function toJSON + * @memberof google.firestore.v1.TransactionOptions + * @instance + * @returns {Object.} JSON object + */ + TransactionOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + TransactionOptions.ReadWrite = (function() { + + /** + * Properties of a ReadWrite. + * @memberof google.firestore.v1.TransactionOptions + * @interface IReadWrite + * @property {Uint8Array|null} [retryTransaction] ReadWrite retryTransaction + */ + + /** + * Constructs a new ReadWrite. + * @memberof google.firestore.v1.TransactionOptions + * @classdesc Represents a ReadWrite. + * @implements IReadWrite + * @constructor + * @param {google.firestore.v1.TransactionOptions.IReadWrite=} [properties] Properties to set + */ + function ReadWrite(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReadWrite retryTransaction. + * @member {Uint8Array} retryTransaction + * @memberof google.firestore.v1.TransactionOptions.ReadWrite + * @instance + */ + ReadWrite.prototype.retryTransaction = $util.newBuffer([]); + + /** + * Creates a ReadWrite message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.TransactionOptions.ReadWrite + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.TransactionOptions.ReadWrite} ReadWrite + */ + ReadWrite.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.TransactionOptions.ReadWrite) + return object; + var message = new $root.google.firestore.v1.TransactionOptions.ReadWrite(); + if (object.retryTransaction != null) + if (typeof object.retryTransaction === "string") + $util.base64.decode(object.retryTransaction, message.retryTransaction = $util.newBuffer($util.base64.length(object.retryTransaction)), 0); + else if (object.retryTransaction.length) + message.retryTransaction = object.retryTransaction; + return message; + }; + + /** + * Creates a plain object from a ReadWrite message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.TransactionOptions.ReadWrite + * @static + * @param {google.firestore.v1.TransactionOptions.ReadWrite} message ReadWrite + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReadWrite.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.retryTransaction = ""; + else { + object.retryTransaction = []; + if (options.bytes !== Array) + object.retryTransaction = $util.newBuffer(object.retryTransaction); + } + if (message.retryTransaction != null && message.hasOwnProperty("retryTransaction")) + object.retryTransaction = options.bytes === String ? $util.base64.encode(message.retryTransaction, 0, message.retryTransaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.retryTransaction) : message.retryTransaction; + return object; + }; + + /** + * Converts this ReadWrite to JSON. + * @function toJSON + * @memberof google.firestore.v1.TransactionOptions.ReadWrite + * @instance + * @returns {Object.} JSON object + */ + ReadWrite.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ReadWrite; + })(); + + TransactionOptions.ReadOnly = (function() { + + /** + * Properties of a ReadOnly. + * @memberof google.firestore.v1.TransactionOptions + * @interface IReadOnly + * @property {google.protobuf.ITimestamp|null} [readTime] ReadOnly readTime + */ + + /** + * Constructs a new ReadOnly. + * @memberof google.firestore.v1.TransactionOptions + * @classdesc Represents a ReadOnly. + * @implements IReadOnly + * @constructor + * @param {google.firestore.v1.TransactionOptions.IReadOnly=} [properties] Properties to set + */ + function ReadOnly(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReadOnly readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1.TransactionOptions.ReadOnly + * @instance + */ + ReadOnly.prototype.readTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ReadOnly consistencySelector. + * @member {"readTime"|undefined} consistencySelector + * @memberof google.firestore.v1.TransactionOptions.ReadOnly + * @instance + */ + Object.defineProperty(ReadOnly.prototype, "consistencySelector", { + get: $util.oneOfGetter($oneOfFields = ["readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a ReadOnly message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.TransactionOptions.ReadOnly + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.TransactionOptions.ReadOnly} ReadOnly + */ + ReadOnly.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.TransactionOptions.ReadOnly) + return object; + var message = new $root.google.firestore.v1.TransactionOptions.ReadOnly(); + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1.TransactionOptions.ReadOnly.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a ReadOnly message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.TransactionOptions.ReadOnly + * @static + * @param {google.firestore.v1.TransactionOptions.ReadOnly} message ReadOnly + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReadOnly.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.readTime != null && message.hasOwnProperty("readTime")) { + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (options.oneofs) + object.consistencySelector = "readTime"; + } + return object; + }; + + /** + * Converts this ReadOnly to JSON. + * @function toJSON + * @memberof google.firestore.v1.TransactionOptions.ReadOnly + * @instance + * @returns {Object.} JSON object + */ + ReadOnly.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ReadOnly; + })(); + + return TransactionOptions; + })(); + + v1.Document = (function() { + + /** + * Properties of a Document. + * @memberof google.firestore.v1 + * @interface IDocument + * @property {string|null} [name] Document name + * @property {Object.|null} [fields] Document fields + * @property {google.protobuf.ITimestamp|null} [createTime] Document createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] Document updateTime + */ + + /** + * Constructs a new Document. + * @memberof google.firestore.v1 + * @classdesc Represents a Document. + * @implements IDocument + * @constructor + * @param {google.firestore.v1.IDocument=} [properties] Properties to set + */ + function Document(properties) { + this.fields = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Document name. + * @member {string} name + * @memberof google.firestore.v1.Document + * @instance + */ + Document.prototype.name = ""; + + /** + * Document fields. + * @member {Object.} fields + * @memberof google.firestore.v1.Document + * @instance + */ + Document.prototype.fields = $util.emptyObject; + + /** + * Document createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.firestore.v1.Document + * @instance + */ + Document.prototype.createTime = null; + + /** + * Document updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.firestore.v1.Document + * @instance + */ + Document.prototype.updateTime = null; + + /** + * Creates a Document message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.Document + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.Document} Document + */ + Document.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.Document) + return object; + var message = new $root.google.firestore.v1.Document(); + if (object.name != null) + message.name = String(object.name); + if (object.fields) { + if (typeof object.fields !== "object") + throw TypeError(".google.firestore.v1.Document.fields: object expected"); + message.fields = {}; + for (var keys = Object.keys(object.fields), i = 0; i < keys.length; ++i) { + if (typeof object.fields[keys[i]] !== "object") + throw TypeError(".google.firestore.v1.Document.fields: object expected"); + message.fields[keys[i]] = $root.google.firestore.v1.Value.fromObject(object.fields[keys[i]]); + } + } + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.firestore.v1.Document.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.firestore.v1.Document.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + return message; + }; + + /** + * Creates a plain object from a Document message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.Document + * @static + * @param {google.firestore.v1.Document} message Document + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Document.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.fields = {}; + if (options.defaults) { + object.name = ""; + object.createTime = null; + object.updateTime = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + var keys2; + if (message.fields && (keys2 = Object.keys(message.fields)).length) { + object.fields = {}; + for (var j = 0; j < keys2.length; ++j) + object.fields[keys2[j]] = $root.google.firestore.v1.Value.toObject(message.fields[keys2[j]], options); + } + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + return object; + }; + + /** + * Converts this Document to JSON. + * @function toJSON + * @memberof google.firestore.v1.Document + * @instance + * @returns {Object.} JSON object + */ + Document.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Document; + })(); + + v1.Value = (function() { + + /** + * Properties of a Value. + * @memberof google.firestore.v1 + * @interface IValue + * @property {google.protobuf.NullValue|null} [nullValue] Value nullValue + * @property {boolean|null} [booleanValue] Value booleanValue + * @property {number|string|null} [integerValue] Value integerValue + * @property {number|null} [doubleValue] Value doubleValue + * @property {google.protobuf.ITimestamp|null} [timestampValue] Value timestampValue + * @property {string|null} [stringValue] Value stringValue + * @property {Uint8Array|null} [bytesValue] Value bytesValue + * @property {string|null} [referenceValue] Value referenceValue + * @property {google.type.ILatLng|null} [geoPointValue] Value geoPointValue + * @property {google.firestore.v1.IArrayValue|null} [arrayValue] Value arrayValue + * @property {google.firestore.v1.IMapValue|null} [mapValue] Value mapValue + */ + + /** + * Constructs a new Value. + * @memberof google.firestore.v1 + * @classdesc Represents a Value. + * @implements IValue + * @constructor + * @param {google.firestore.v1.IValue=} [properties] Properties to set + */ + function Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Value nullValue. + * @member {google.protobuf.NullValue} nullValue + * @memberof google.firestore.v1.Value + * @instance + */ + Value.prototype.nullValue = 0; + + /** + * Value booleanValue. + * @member {boolean} booleanValue + * @memberof google.firestore.v1.Value + * @instance + */ + Value.prototype.booleanValue = false; + + /** + * Value integerValue. + * @member {number|string} integerValue + * @memberof google.firestore.v1.Value + * @instance + */ + Value.prototype.integerValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Value doubleValue. + * @member {number} doubleValue + * @memberof google.firestore.v1.Value + * @instance + */ + Value.prototype.doubleValue = 0; + + /** + * Value timestampValue. + * @member {google.protobuf.ITimestamp|null|undefined} timestampValue + * @memberof google.firestore.v1.Value + * @instance + */ + Value.prototype.timestampValue = null; + + /** + * Value stringValue. + * @member {string} stringValue + * @memberof google.firestore.v1.Value + * @instance + */ + Value.prototype.stringValue = ""; + + /** + * Value bytesValue. + * @member {Uint8Array} bytesValue + * @memberof google.firestore.v1.Value + * @instance + */ + Value.prototype.bytesValue = $util.newBuffer([]); + + /** + * Value referenceValue. + * @member {string} referenceValue + * @memberof google.firestore.v1.Value + * @instance + */ + Value.prototype.referenceValue = ""; + + /** + * Value geoPointValue. + * @member {google.type.ILatLng|null|undefined} geoPointValue + * @memberof google.firestore.v1.Value + * @instance + */ + Value.prototype.geoPointValue = null; + + /** + * Value arrayValue. + * @member {google.firestore.v1.IArrayValue|null|undefined} arrayValue + * @memberof google.firestore.v1.Value + * @instance + */ + Value.prototype.arrayValue = null; + + /** + * Value mapValue. + * @member {google.firestore.v1.IMapValue|null|undefined} mapValue + * @memberof google.firestore.v1.Value + * @instance + */ + Value.prototype.mapValue = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Value valueType. + * @member {"nullValue"|"booleanValue"|"integerValue"|"doubleValue"|"timestampValue"|"stringValue"|"bytesValue"|"referenceValue"|"geoPointValue"|"arrayValue"|"mapValue"|undefined} valueType + * @memberof google.firestore.v1.Value + * @instance + */ + Object.defineProperty(Value.prototype, "valueType", { + get: $util.oneOfGetter($oneOfFields = ["nullValue", "booleanValue", "integerValue", "doubleValue", "timestampValue", "stringValue", "bytesValue", "referenceValue", "geoPointValue", "arrayValue", "mapValue"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.Value + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.Value} Value + */ + Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.Value) + return object; + var message = new $root.google.firestore.v1.Value(); + switch (object.nullValue) { + case "NULL_VALUE": + case 0: + message.nullValue = 0; + break; + } + if (object.booleanValue != null) + message.booleanValue = Boolean(object.booleanValue); + if (object.integerValue != null) + if ($util.Long) + (message.integerValue = $util.Long.fromValue(object.integerValue)).unsigned = false; + else if (typeof object.integerValue === "string") + message.integerValue = parseInt(object.integerValue, 10); + else if (typeof object.integerValue === "number") + message.integerValue = object.integerValue; + else if (typeof object.integerValue === "object") + message.integerValue = new $util.LongBits(object.integerValue.low >>> 0, object.integerValue.high >>> 0).toNumber(); + if (object.doubleValue != null) + message.doubleValue = Number(object.doubleValue); + if (object.timestampValue != null) { + if (typeof object.timestampValue !== "object") + throw TypeError(".google.firestore.v1.Value.timestampValue: object expected"); + message.timestampValue = $root.google.protobuf.Timestamp.fromObject(object.timestampValue); + } + if (object.stringValue != null) + message.stringValue = String(object.stringValue); + if (object.bytesValue != null) + if (typeof object.bytesValue === "string") + $util.base64.decode(object.bytesValue, message.bytesValue = $util.newBuffer($util.base64.length(object.bytesValue)), 0); + else if (object.bytesValue.length) + message.bytesValue = object.bytesValue; + if (object.referenceValue != null) + message.referenceValue = String(object.referenceValue); + if (object.geoPointValue != null) { + if (typeof object.geoPointValue !== "object") + throw TypeError(".google.firestore.v1.Value.geoPointValue: object expected"); + message.geoPointValue = $root.google.type.LatLng.fromObject(object.geoPointValue); + } + if (object.arrayValue != null) { + if (typeof object.arrayValue !== "object") + throw TypeError(".google.firestore.v1.Value.arrayValue: object expected"); + message.arrayValue = $root.google.firestore.v1.ArrayValue.fromObject(object.arrayValue); + } + if (object.mapValue != null) { + if (typeof object.mapValue !== "object") + throw TypeError(".google.firestore.v1.Value.mapValue: object expected"); + message.mapValue = $root.google.firestore.v1.MapValue.fromObject(object.mapValue); + } + return message; + }; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.Value + * @static + * @param {google.firestore.v1.Value} message Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.booleanValue != null && message.hasOwnProperty("booleanValue")) { + object.booleanValue = message.booleanValue; + if (options.oneofs) + object.valueType = "booleanValue"; + } + if (message.integerValue != null && message.hasOwnProperty("integerValue")) { + if (typeof message.integerValue === "number") + object.integerValue = options.longs === String ? String(message.integerValue) : message.integerValue; + else + object.integerValue = options.longs === String ? $util.Long.prototype.toString.call(message.integerValue) : options.longs === Number ? new $util.LongBits(message.integerValue.low >>> 0, message.integerValue.high >>> 0).toNumber() : message.integerValue; + if (options.oneofs) + object.valueType = "integerValue"; + } + if (message.doubleValue != null && message.hasOwnProperty("doubleValue")) { + object.doubleValue = options.json && !isFinite(message.doubleValue) ? String(message.doubleValue) : message.doubleValue; + if (options.oneofs) + object.valueType = "doubleValue"; + } + if (message.referenceValue != null && message.hasOwnProperty("referenceValue")) { + object.referenceValue = message.referenceValue; + if (options.oneofs) + object.valueType = "referenceValue"; + } + if (message.mapValue != null && message.hasOwnProperty("mapValue")) { + object.mapValue = $root.google.firestore.v1.MapValue.toObject(message.mapValue, options); + if (options.oneofs) + object.valueType = "mapValue"; + } + if (message.geoPointValue != null && message.hasOwnProperty("geoPointValue")) { + object.geoPointValue = $root.google.type.LatLng.toObject(message.geoPointValue, options); + if (options.oneofs) + object.valueType = "geoPointValue"; + } + if (message.arrayValue != null && message.hasOwnProperty("arrayValue")) { + object.arrayValue = $root.google.firestore.v1.ArrayValue.toObject(message.arrayValue, options); + if (options.oneofs) + object.valueType = "arrayValue"; + } + if (message.timestampValue != null && message.hasOwnProperty("timestampValue")) { + object.timestampValue = $root.google.protobuf.Timestamp.toObject(message.timestampValue, options); + if (options.oneofs) + object.valueType = "timestampValue"; + } + if (message.nullValue != null && message.hasOwnProperty("nullValue")) { + object.nullValue = options.enums === String ? $root.google.protobuf.NullValue[message.nullValue] : message.nullValue; + if (options.oneofs) + object.valueType = "nullValue"; + } + if (message.stringValue != null && message.hasOwnProperty("stringValue")) { + object.stringValue = message.stringValue; + if (options.oneofs) + object.valueType = "stringValue"; + } + if (message.bytesValue != null && message.hasOwnProperty("bytesValue")) { + object.bytesValue = options.bytes === String ? $util.base64.encode(message.bytesValue, 0, message.bytesValue.length) : options.bytes === Array ? Array.prototype.slice.call(message.bytesValue) : message.bytesValue; + if (options.oneofs) + object.valueType = "bytesValue"; + } + return object; + }; + + /** + * Converts this Value to JSON. + * @function toJSON + * @memberof google.firestore.v1.Value + * @instance + * @returns {Object.} JSON object + */ + Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Value; + })(); + + v1.ArrayValue = (function() { + + /** + * Properties of an ArrayValue. + * @memberof google.firestore.v1 + * @interface IArrayValue + * @property {Array.|null} [values] ArrayValue values + */ + + /** + * Constructs a new ArrayValue. + * @memberof google.firestore.v1 + * @classdesc Represents an ArrayValue. + * @implements IArrayValue + * @constructor + * @param {google.firestore.v1.IArrayValue=} [properties] Properties to set + */ + function ArrayValue(properties) { + this.values = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ArrayValue values. + * @member {Array.} values + * @memberof google.firestore.v1.ArrayValue + * @instance + */ + ArrayValue.prototype.values = $util.emptyArray; + + /** + * Creates an ArrayValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.ArrayValue + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.ArrayValue} ArrayValue + */ + ArrayValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.ArrayValue) + return object; + var message = new $root.google.firestore.v1.ArrayValue(); + if (object.values) { + if (!Array.isArray(object.values)) + throw TypeError(".google.firestore.v1.ArrayValue.values: array expected"); + message.values = []; + for (var i = 0; i < object.values.length; ++i) { + if (typeof object.values[i] !== "object") + throw TypeError(".google.firestore.v1.ArrayValue.values: object expected"); + message.values[i] = $root.google.firestore.v1.Value.fromObject(object.values[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an ArrayValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.ArrayValue + * @static + * @param {google.firestore.v1.ArrayValue} message ArrayValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ArrayValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.values = []; + if (message.values && message.values.length) { + object.values = []; + for (var j = 0; j < message.values.length; ++j) + object.values[j] = $root.google.firestore.v1.Value.toObject(message.values[j], options); + } + return object; + }; + + /** + * Converts this ArrayValue to JSON. + * @function toJSON + * @memberof google.firestore.v1.ArrayValue + * @instance + * @returns {Object.} JSON object + */ + ArrayValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ArrayValue; + })(); + + v1.MapValue = (function() { + + /** + * Properties of a MapValue. + * @memberof google.firestore.v1 + * @interface IMapValue + * @property {Object.|null} [fields] MapValue fields + */ + + /** + * Constructs a new MapValue. + * @memberof google.firestore.v1 + * @classdesc Represents a MapValue. + * @implements IMapValue + * @constructor + * @param {google.firestore.v1.IMapValue=} [properties] Properties to set + */ + function MapValue(properties) { + this.fields = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MapValue fields. + * @member {Object.} fields + * @memberof google.firestore.v1.MapValue + * @instance + */ + MapValue.prototype.fields = $util.emptyObject; + + /** + * Creates a MapValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.MapValue + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.MapValue} MapValue + */ + MapValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.MapValue) + return object; + var message = new $root.google.firestore.v1.MapValue(); + if (object.fields) { + if (typeof object.fields !== "object") + throw TypeError(".google.firestore.v1.MapValue.fields: object expected"); + message.fields = {}; + for (var keys = Object.keys(object.fields), i = 0; i < keys.length; ++i) { + if (typeof object.fields[keys[i]] !== "object") + throw TypeError(".google.firestore.v1.MapValue.fields: object expected"); + message.fields[keys[i]] = $root.google.firestore.v1.Value.fromObject(object.fields[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from a MapValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.MapValue + * @static + * @param {google.firestore.v1.MapValue} message MapValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MapValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.fields = {}; + var keys2; + if (message.fields && (keys2 = Object.keys(message.fields)).length) { + object.fields = {}; + for (var j = 0; j < keys2.length; ++j) + object.fields[keys2[j]] = $root.google.firestore.v1.Value.toObject(message.fields[keys2[j]], options); + } + return object; + }; + + /** + * Converts this MapValue to JSON. + * @function toJSON + * @memberof google.firestore.v1.MapValue + * @instance + * @returns {Object.} JSON object + */ + MapValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return MapValue; + })(); + + v1.Firestore = (function() { + + /** + * Constructs a new Firestore service. + * @memberof google.firestore.v1 + * @classdesc Represents a Firestore + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function Firestore(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (Firestore.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Firestore; + + /** + * Callback as used by {@link google.firestore.v1.Firestore#getDocument}. + * @memberof google.firestore.v1.Firestore + * @typedef GetDocumentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1.Document} [response] Document + */ + + /** + * Calls GetDocument. + * @function getDocument + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IGetDocumentRequest} request GetDocumentRequest message or plain object + * @param {google.firestore.v1.Firestore.GetDocumentCallback} callback Node-style callback called with the error, if any, and Document + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.getDocument = function getDocument(request, callback) { + return this.rpcCall(getDocument, $root.google.firestore.v1.GetDocumentRequest, $root.google.firestore.v1.Document, request, callback); + }, "name", { value: "GetDocument" }); + + /** + * Calls GetDocument. + * @function getDocument + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IGetDocumentRequest} request GetDocumentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1.Firestore#listDocuments}. + * @memberof google.firestore.v1.Firestore + * @typedef ListDocumentsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1.ListDocumentsResponse} [response] ListDocumentsResponse + */ + + /** + * Calls ListDocuments. + * @function listDocuments + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IListDocumentsRequest} request ListDocumentsRequest message or plain object + * @param {google.firestore.v1.Firestore.ListDocumentsCallback} callback Node-style callback called with the error, if any, and ListDocumentsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.listDocuments = function listDocuments(request, callback) { + return this.rpcCall(listDocuments, $root.google.firestore.v1.ListDocumentsRequest, $root.google.firestore.v1.ListDocumentsResponse, request, callback); + }, "name", { value: "ListDocuments" }); + + /** + * Calls ListDocuments. + * @function listDocuments + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IListDocumentsRequest} request ListDocumentsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1.Firestore#updateDocument}. + * @memberof google.firestore.v1.Firestore + * @typedef UpdateDocumentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1.Document} [response] Document + */ + + /** + * Calls UpdateDocument. + * @function updateDocument + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IUpdateDocumentRequest} request UpdateDocumentRequest message or plain object + * @param {google.firestore.v1.Firestore.UpdateDocumentCallback} callback Node-style callback called with the error, if any, and Document + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.updateDocument = function updateDocument(request, callback) { + return this.rpcCall(updateDocument, $root.google.firestore.v1.UpdateDocumentRequest, $root.google.firestore.v1.Document, request, callback); + }, "name", { value: "UpdateDocument" }); + + /** + * Calls UpdateDocument. + * @function updateDocument + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IUpdateDocumentRequest} request UpdateDocumentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1.Firestore#deleteDocument}. + * @memberof google.firestore.v1.Firestore + * @typedef DeleteDocumentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteDocument. + * @function deleteDocument + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IDeleteDocumentRequest} request DeleteDocumentRequest message or plain object + * @param {google.firestore.v1.Firestore.DeleteDocumentCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.deleteDocument = function deleteDocument(request, callback) { + return this.rpcCall(deleteDocument, $root.google.firestore.v1.DeleteDocumentRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteDocument" }); + + /** + * Calls DeleteDocument. + * @function deleteDocument + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IDeleteDocumentRequest} request DeleteDocumentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1.Firestore#batchGetDocuments}. + * @memberof google.firestore.v1.Firestore + * @typedef BatchGetDocumentsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1.BatchGetDocumentsResponse} [response] BatchGetDocumentsResponse + */ + + /** + * Calls BatchGetDocuments. + * @function batchGetDocuments + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IBatchGetDocumentsRequest} request BatchGetDocumentsRequest message or plain object + * @param {google.firestore.v1.Firestore.BatchGetDocumentsCallback} callback Node-style callback called with the error, if any, and BatchGetDocumentsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.batchGetDocuments = function batchGetDocuments(request, callback) { + return this.rpcCall(batchGetDocuments, $root.google.firestore.v1.BatchGetDocumentsRequest, $root.google.firestore.v1.BatchGetDocumentsResponse, request, callback); + }, "name", { value: "BatchGetDocuments" }); + + /** + * Calls BatchGetDocuments. + * @function batchGetDocuments + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IBatchGetDocumentsRequest} request BatchGetDocumentsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1.Firestore#beginTransaction}. + * @memberof google.firestore.v1.Firestore + * @typedef BeginTransactionCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1.BeginTransactionResponse} [response] BeginTransactionResponse + */ + + /** + * Calls BeginTransaction. + * @function beginTransaction + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IBeginTransactionRequest} request BeginTransactionRequest message or plain object + * @param {google.firestore.v1.Firestore.BeginTransactionCallback} callback Node-style callback called with the error, if any, and BeginTransactionResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.beginTransaction = function beginTransaction(request, callback) { + return this.rpcCall(beginTransaction, $root.google.firestore.v1.BeginTransactionRequest, $root.google.firestore.v1.BeginTransactionResponse, request, callback); + }, "name", { value: "BeginTransaction" }); + + /** + * Calls BeginTransaction. + * @function beginTransaction + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IBeginTransactionRequest} request BeginTransactionRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1.Firestore#commit}. + * @memberof google.firestore.v1.Firestore + * @typedef CommitCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1.CommitResponse} [response] CommitResponse + */ + + /** + * Calls Commit. + * @function commit + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.ICommitRequest} request CommitRequest message or plain object + * @param {google.firestore.v1.Firestore.CommitCallback} callback Node-style callback called with the error, if any, and CommitResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.commit = function commit(request, callback) { + return this.rpcCall(commit, $root.google.firestore.v1.CommitRequest, $root.google.firestore.v1.CommitResponse, request, callback); + }, "name", { value: "Commit" }); + + /** + * Calls Commit. + * @function commit + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.ICommitRequest} request CommitRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1.Firestore#rollback}. + * @memberof google.firestore.v1.Firestore + * @typedef RollbackCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls Rollback. + * @function rollback + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IRollbackRequest} request RollbackRequest message or plain object + * @param {google.firestore.v1.Firestore.RollbackCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.rollback = function rollback(request, callback) { + return this.rpcCall(rollback, $root.google.firestore.v1.RollbackRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "Rollback" }); + + /** + * Calls Rollback. + * @function rollback + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IRollbackRequest} request RollbackRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1.Firestore#runQuery}. + * @memberof google.firestore.v1.Firestore + * @typedef RunQueryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1.RunQueryResponse} [response] RunQueryResponse + */ + + /** + * Calls RunQuery. + * @function runQuery + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IRunQueryRequest} request RunQueryRequest message or plain object + * @param {google.firestore.v1.Firestore.RunQueryCallback} callback Node-style callback called with the error, if any, and RunQueryResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.runQuery = function runQuery(request, callback) { + return this.rpcCall(runQuery, $root.google.firestore.v1.RunQueryRequest, $root.google.firestore.v1.RunQueryResponse, request, callback); + }, "name", { value: "RunQuery" }); + + /** + * Calls RunQuery. + * @function runQuery + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IRunQueryRequest} request RunQueryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1.Firestore#partitionQuery}. + * @memberof google.firestore.v1.Firestore + * @typedef PartitionQueryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1.PartitionQueryResponse} [response] PartitionQueryResponse + */ + + /** + * Calls PartitionQuery. + * @function partitionQuery + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IPartitionQueryRequest} request PartitionQueryRequest message or plain object + * @param {google.firestore.v1.Firestore.PartitionQueryCallback} callback Node-style callback called with the error, if any, and PartitionQueryResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.partitionQuery = function partitionQuery(request, callback) { + return this.rpcCall(partitionQuery, $root.google.firestore.v1.PartitionQueryRequest, $root.google.firestore.v1.PartitionQueryResponse, request, callback); + }, "name", { value: "PartitionQuery" }); + + /** + * Calls PartitionQuery. + * @function partitionQuery + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IPartitionQueryRequest} request PartitionQueryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1.Firestore#write}. + * @memberof google.firestore.v1.Firestore + * @typedef WriteCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1.WriteResponse} [response] WriteResponse + */ + + /** + * Calls Write. + * @function write + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IWriteRequest} request WriteRequest message or plain object + * @param {google.firestore.v1.Firestore.WriteCallback} callback Node-style callback called with the error, if any, and WriteResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.write = function write(request, callback) { + return this.rpcCall(write, $root.google.firestore.v1.WriteRequest, $root.google.firestore.v1.WriteResponse, request, callback); + }, "name", { value: "Write" }); + + /** + * Calls Write. + * @function write + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IWriteRequest} request WriteRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1.Firestore#listen}. + * @memberof google.firestore.v1.Firestore + * @typedef ListenCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1.ListenResponse} [response] ListenResponse + */ + + /** + * Calls Listen. + * @function listen + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IListenRequest} request ListenRequest message or plain object + * @param {google.firestore.v1.Firestore.ListenCallback} callback Node-style callback called with the error, if any, and ListenResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.listen = function listen(request, callback) { + return this.rpcCall(listen, $root.google.firestore.v1.ListenRequest, $root.google.firestore.v1.ListenResponse, request, callback); + }, "name", { value: "Listen" }); + + /** + * Calls Listen. + * @function listen + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IListenRequest} request ListenRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1.Firestore#listCollectionIds}. + * @memberof google.firestore.v1.Firestore + * @typedef ListCollectionIdsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1.ListCollectionIdsResponse} [response] ListCollectionIdsResponse + */ + + /** + * Calls ListCollectionIds. + * @function listCollectionIds + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IListCollectionIdsRequest} request ListCollectionIdsRequest message or plain object + * @param {google.firestore.v1.Firestore.ListCollectionIdsCallback} callback Node-style callback called with the error, if any, and ListCollectionIdsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.listCollectionIds = function listCollectionIds(request, callback) { + return this.rpcCall(listCollectionIds, $root.google.firestore.v1.ListCollectionIdsRequest, $root.google.firestore.v1.ListCollectionIdsResponse, request, callback); + }, "name", { value: "ListCollectionIds" }); + + /** + * Calls ListCollectionIds. + * @function listCollectionIds + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IListCollectionIdsRequest} request ListCollectionIdsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1.Firestore#batchWrite}. + * @memberof google.firestore.v1.Firestore + * @typedef BatchWriteCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1.BatchWriteResponse} [response] BatchWriteResponse + */ + + /** + * Calls BatchWrite. + * @function batchWrite + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IBatchWriteRequest} request BatchWriteRequest message or plain object + * @param {google.firestore.v1.Firestore.BatchWriteCallback} callback Node-style callback called with the error, if any, and BatchWriteResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.batchWrite = function batchWrite(request, callback) { + return this.rpcCall(batchWrite, $root.google.firestore.v1.BatchWriteRequest, $root.google.firestore.v1.BatchWriteResponse, request, callback); + }, "name", { value: "BatchWrite" }); + + /** + * Calls BatchWrite. + * @function batchWrite + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.IBatchWriteRequest} request BatchWriteRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1.Firestore#createDocument}. + * @memberof google.firestore.v1.Firestore + * @typedef CreateDocumentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1.Document} [response] Document + */ + + /** + * Calls CreateDocument. + * @function createDocument + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object + * @param {google.firestore.v1.Firestore.CreateDocumentCallback} callback Node-style callback called with the error, if any, and Document + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.createDocument = function createDocument(request, callback) { + return this.rpcCall(createDocument, $root.google.firestore.v1.CreateDocumentRequest, $root.google.firestore.v1.Document, request, callback); + }, "name", { value: "CreateDocument" }); + + /** + * Calls CreateDocument. + * @function createDocument + * @memberof google.firestore.v1.Firestore + * @instance + * @param {google.firestore.v1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return Firestore; + })(); + + v1.GetDocumentRequest = (function() { + + /** + * Properties of a GetDocumentRequest. + * @memberof google.firestore.v1 + * @interface IGetDocumentRequest + * @property {string|null} [name] GetDocumentRequest name + * @property {google.firestore.v1.IDocumentMask|null} [mask] GetDocumentRequest mask + * @property {Uint8Array|null} [transaction] GetDocumentRequest transaction + * @property {google.protobuf.ITimestamp|null} [readTime] GetDocumentRequest readTime + */ + + /** + * Constructs a new GetDocumentRequest. + * @memberof google.firestore.v1 + * @classdesc Represents a GetDocumentRequest. + * @implements IGetDocumentRequest + * @constructor + * @param {google.firestore.v1.IGetDocumentRequest=} [properties] Properties to set + */ + function GetDocumentRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetDocumentRequest name. + * @member {string} name + * @memberof google.firestore.v1.GetDocumentRequest + * @instance + */ + GetDocumentRequest.prototype.name = ""; + + /** + * GetDocumentRequest mask. + * @member {google.firestore.v1.IDocumentMask|null|undefined} mask + * @memberof google.firestore.v1.GetDocumentRequest + * @instance + */ + GetDocumentRequest.prototype.mask = null; + + /** + * GetDocumentRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1.GetDocumentRequest + * @instance + */ + GetDocumentRequest.prototype.transaction = $util.newBuffer([]); + + /** + * GetDocumentRequest readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1.GetDocumentRequest + * @instance + */ + GetDocumentRequest.prototype.readTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetDocumentRequest consistencySelector. + * @member {"transaction"|"readTime"|undefined} consistencySelector + * @memberof google.firestore.v1.GetDocumentRequest + * @instance + */ + Object.defineProperty(GetDocumentRequest.prototype, "consistencySelector", { + get: $util.oneOfGetter($oneOfFields = ["transaction", "readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a GetDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.GetDocumentRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.GetDocumentRequest} GetDocumentRequest + */ + GetDocumentRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.GetDocumentRequest) + return object; + var message = new $root.google.firestore.v1.GetDocumentRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.mask != null) { + if (typeof object.mask !== "object") + throw TypeError(".google.firestore.v1.GetDocumentRequest.mask: object expected"); + message.mask = $root.google.firestore.v1.DocumentMask.fromObject(object.mask); + } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1.GetDocumentRequest.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a GetDocumentRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.GetDocumentRequest + * @static + * @param {google.firestore.v1.GetDocumentRequest} message GetDocumentRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDocumentRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.mask = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.mask != null && message.hasOwnProperty("mask")) + object.mask = $root.google.firestore.v1.DocumentMask.toObject(message.mask, options); + if (message.transaction != null && message.hasOwnProperty("transaction")) { + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (options.oneofs) + object.consistencySelector = "transaction"; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (options.oneofs) + object.consistencySelector = "readTime"; + } + return object; + }; + + /** + * Converts this GetDocumentRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1.GetDocumentRequest + * @instance + * @returns {Object.} JSON object + */ + GetDocumentRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetDocumentRequest; + })(); + + v1.ListDocumentsRequest = (function() { + + /** + * Properties of a ListDocumentsRequest. + * @memberof google.firestore.v1 + * @interface IListDocumentsRequest + * @property {string|null} [parent] ListDocumentsRequest parent + * @property {string|null} [collectionId] ListDocumentsRequest collectionId + * @property {number|null} [pageSize] ListDocumentsRequest pageSize + * @property {string|null} [pageToken] ListDocumentsRequest pageToken + * @property {string|null} [orderBy] ListDocumentsRequest orderBy + * @property {google.firestore.v1.IDocumentMask|null} [mask] ListDocumentsRequest mask + * @property {Uint8Array|null} [transaction] ListDocumentsRequest transaction + * @property {google.protobuf.ITimestamp|null} [readTime] ListDocumentsRequest readTime + * @property {boolean|null} [showMissing] ListDocumentsRequest showMissing + */ + + /** + * Constructs a new ListDocumentsRequest. + * @memberof google.firestore.v1 + * @classdesc Represents a ListDocumentsRequest. + * @implements IListDocumentsRequest + * @constructor + * @param {google.firestore.v1.IListDocumentsRequest=} [properties] Properties to set + */ + function ListDocumentsRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListDocumentsRequest parent. + * @member {string} parent + * @memberof google.firestore.v1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.parent = ""; + + /** + * ListDocumentsRequest collectionId. + * @member {string} collectionId + * @memberof google.firestore.v1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.collectionId = ""; + + /** + * ListDocumentsRequest pageSize. + * @member {number} pageSize + * @memberof google.firestore.v1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.pageSize = 0; + + /** + * ListDocumentsRequest pageToken. + * @member {string} pageToken + * @memberof google.firestore.v1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.pageToken = ""; + + /** + * ListDocumentsRequest orderBy. + * @member {string} orderBy + * @memberof google.firestore.v1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.orderBy = ""; + + /** + * ListDocumentsRequest mask. + * @member {google.firestore.v1.IDocumentMask|null|undefined} mask + * @memberof google.firestore.v1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.mask = null; + + /** + * ListDocumentsRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.transaction = $util.newBuffer([]); + + /** + * ListDocumentsRequest readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.readTime = null; + + /** + * ListDocumentsRequest showMissing. + * @member {boolean} showMissing + * @memberof google.firestore.v1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.showMissing = false; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ListDocumentsRequest consistencySelector. + * @member {"transaction"|"readTime"|undefined} consistencySelector + * @memberof google.firestore.v1.ListDocumentsRequest + * @instance + */ + Object.defineProperty(ListDocumentsRequest.prototype, "consistencySelector", { + get: $util.oneOfGetter($oneOfFields = ["transaction", "readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a ListDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.ListDocumentsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.ListDocumentsRequest} ListDocumentsRequest + */ + ListDocumentsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.ListDocumentsRequest) + return object; + var message = new $root.google.firestore.v1.ListDocumentsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.collectionId != null) + message.collectionId = String(object.collectionId); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.orderBy != null) + message.orderBy = String(object.orderBy); + if (object.mask != null) { + if (typeof object.mask !== "object") + throw TypeError(".google.firestore.v1.ListDocumentsRequest.mask: object expected"); + message.mask = $root.google.firestore.v1.DocumentMask.fromObject(object.mask); + } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1.ListDocumentsRequest.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + if (object.showMissing != null) + message.showMissing = Boolean(object.showMissing); + return message; + }; + + /** + * Creates a plain object from a ListDocumentsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.ListDocumentsRequest + * @static + * @param {google.firestore.v1.ListDocumentsRequest} message ListDocumentsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListDocumentsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.collectionId = ""; + object.pageSize = 0; + object.pageToken = ""; + object.orderBy = ""; + object.mask = null; + object.showMissing = false; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.collectionId != null && message.hasOwnProperty("collectionId")) + object.collectionId = message.collectionId; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + object.orderBy = message.orderBy; + if (message.mask != null && message.hasOwnProperty("mask")) + object.mask = $root.google.firestore.v1.DocumentMask.toObject(message.mask, options); + if (message.transaction != null && message.hasOwnProperty("transaction")) { + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (options.oneofs) + object.consistencySelector = "transaction"; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (options.oneofs) + object.consistencySelector = "readTime"; + } + if (message.showMissing != null && message.hasOwnProperty("showMissing")) + object.showMissing = message.showMissing; + return object; + }; + + /** + * Converts this ListDocumentsRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1.ListDocumentsRequest + * @instance + * @returns {Object.} JSON object + */ + ListDocumentsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListDocumentsRequest; + })(); + + v1.ListDocumentsResponse = (function() { + + /** + * Properties of a ListDocumentsResponse. + * @memberof google.firestore.v1 + * @interface IListDocumentsResponse + * @property {Array.|null} [documents] ListDocumentsResponse documents + * @property {string|null} [nextPageToken] ListDocumentsResponse nextPageToken + */ + + /** + * Constructs a new ListDocumentsResponse. + * @memberof google.firestore.v1 + * @classdesc Represents a ListDocumentsResponse. + * @implements IListDocumentsResponse + * @constructor + * @param {google.firestore.v1.IListDocumentsResponse=} [properties] Properties to set + */ + function ListDocumentsResponse(properties) { + this.documents = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListDocumentsResponse documents. + * @member {Array.} documents + * @memberof google.firestore.v1.ListDocumentsResponse + * @instance + */ + ListDocumentsResponse.prototype.documents = $util.emptyArray; + + /** + * ListDocumentsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.firestore.v1.ListDocumentsResponse + * @instance + */ + ListDocumentsResponse.prototype.nextPageToken = ""; + + /** + * Creates a ListDocumentsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.ListDocumentsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.ListDocumentsResponse} ListDocumentsResponse + */ + ListDocumentsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.ListDocumentsResponse) + return object; + var message = new $root.google.firestore.v1.ListDocumentsResponse(); + if (object.documents) { + if (!Array.isArray(object.documents)) + throw TypeError(".google.firestore.v1.ListDocumentsResponse.documents: array expected"); + message.documents = []; + for (var i = 0; i < object.documents.length; ++i) { + if (typeof object.documents[i] !== "object") + throw TypeError(".google.firestore.v1.ListDocumentsResponse.documents: object expected"); + message.documents[i] = $root.google.firestore.v1.Document.fromObject(object.documents[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListDocumentsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.ListDocumentsResponse + * @static + * @param {google.firestore.v1.ListDocumentsResponse} message ListDocumentsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListDocumentsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.documents = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.documents && message.documents.length) { + object.documents = []; + for (var j = 0; j < message.documents.length; ++j) + object.documents[j] = $root.google.firestore.v1.Document.toObject(message.documents[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListDocumentsResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1.ListDocumentsResponse + * @instance + * @returns {Object.} JSON object + */ + ListDocumentsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListDocumentsResponse; + })(); + + v1.CreateDocumentRequest = (function() { + + /** + * Properties of a CreateDocumentRequest. + * @memberof google.firestore.v1 + * @interface ICreateDocumentRequest + * @property {string|null} [parent] CreateDocumentRequest parent + * @property {string|null} [collectionId] CreateDocumentRequest collectionId + * @property {string|null} [documentId] CreateDocumentRequest documentId + * @property {google.firestore.v1.IDocument|null} [document] CreateDocumentRequest document + * @property {google.firestore.v1.IDocumentMask|null} [mask] CreateDocumentRequest mask + */ + + /** + * Constructs a new CreateDocumentRequest. + * @memberof google.firestore.v1 + * @classdesc Represents a CreateDocumentRequest. + * @implements ICreateDocumentRequest + * @constructor + * @param {google.firestore.v1.ICreateDocumentRequest=} [properties] Properties to set + */ + function CreateDocumentRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CreateDocumentRequest parent. + * @member {string} parent + * @memberof google.firestore.v1.CreateDocumentRequest + * @instance + */ + CreateDocumentRequest.prototype.parent = ""; + + /** + * CreateDocumentRequest collectionId. + * @member {string} collectionId + * @memberof google.firestore.v1.CreateDocumentRequest + * @instance + */ + CreateDocumentRequest.prototype.collectionId = ""; + + /** + * CreateDocumentRequest documentId. + * @member {string} documentId + * @memberof google.firestore.v1.CreateDocumentRequest + * @instance + */ + CreateDocumentRequest.prototype.documentId = ""; + + /** + * CreateDocumentRequest document. + * @member {google.firestore.v1.IDocument|null|undefined} document + * @memberof google.firestore.v1.CreateDocumentRequest + * @instance + */ + CreateDocumentRequest.prototype.document = null; + + /** + * CreateDocumentRequest mask. + * @member {google.firestore.v1.IDocumentMask|null|undefined} mask + * @memberof google.firestore.v1.CreateDocumentRequest + * @instance + */ + CreateDocumentRequest.prototype.mask = null; + + /** + * Creates a CreateDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.CreateDocumentRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.CreateDocumentRequest} CreateDocumentRequest + */ + CreateDocumentRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.CreateDocumentRequest) + return object; + var message = new $root.google.firestore.v1.CreateDocumentRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.collectionId != null) + message.collectionId = String(object.collectionId); + if (object.documentId != null) + message.documentId = String(object.documentId); + if (object.document != null) { + if (typeof object.document !== "object") + throw TypeError(".google.firestore.v1.CreateDocumentRequest.document: object expected"); + message.document = $root.google.firestore.v1.Document.fromObject(object.document); + } + if (object.mask != null) { + if (typeof object.mask !== "object") + throw TypeError(".google.firestore.v1.CreateDocumentRequest.mask: object expected"); + message.mask = $root.google.firestore.v1.DocumentMask.fromObject(object.mask); + } + return message; + }; + + /** + * Creates a plain object from a CreateDocumentRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.CreateDocumentRequest + * @static + * @param {google.firestore.v1.CreateDocumentRequest} message CreateDocumentRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateDocumentRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.collectionId = ""; + object.documentId = ""; + object.document = null; + object.mask = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.collectionId != null && message.hasOwnProperty("collectionId")) + object.collectionId = message.collectionId; + if (message.documentId != null && message.hasOwnProperty("documentId")) + object.documentId = message.documentId; + if (message.document != null && message.hasOwnProperty("document")) + object.document = $root.google.firestore.v1.Document.toObject(message.document, options); + if (message.mask != null && message.hasOwnProperty("mask")) + object.mask = $root.google.firestore.v1.DocumentMask.toObject(message.mask, options); + return object; + }; + + /** + * Converts this CreateDocumentRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1.CreateDocumentRequest + * @instance + * @returns {Object.} JSON object + */ + CreateDocumentRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CreateDocumentRequest; + })(); + + v1.UpdateDocumentRequest = (function() { + + /** + * Properties of an UpdateDocumentRequest. + * @memberof google.firestore.v1 + * @interface IUpdateDocumentRequest + * @property {google.firestore.v1.IDocument|null} [document] UpdateDocumentRequest document + * @property {google.firestore.v1.IDocumentMask|null} [updateMask] UpdateDocumentRequest updateMask + * @property {google.firestore.v1.IDocumentMask|null} [mask] UpdateDocumentRequest mask + * @property {google.firestore.v1.IPrecondition|null} [currentDocument] UpdateDocumentRequest currentDocument + */ + + /** + * Constructs a new UpdateDocumentRequest. + * @memberof google.firestore.v1 + * @classdesc Represents an UpdateDocumentRequest. + * @implements IUpdateDocumentRequest + * @constructor + * @param {google.firestore.v1.IUpdateDocumentRequest=} [properties] Properties to set + */ + function UpdateDocumentRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UpdateDocumentRequest document. + * @member {google.firestore.v1.IDocument|null|undefined} document + * @memberof google.firestore.v1.UpdateDocumentRequest + * @instance + */ + UpdateDocumentRequest.prototype.document = null; + + /** + * UpdateDocumentRequest updateMask. + * @member {google.firestore.v1.IDocumentMask|null|undefined} updateMask + * @memberof google.firestore.v1.UpdateDocumentRequest + * @instance + */ + UpdateDocumentRequest.prototype.updateMask = null; + + /** + * UpdateDocumentRequest mask. + * @member {google.firestore.v1.IDocumentMask|null|undefined} mask + * @memberof google.firestore.v1.UpdateDocumentRequest + * @instance + */ + UpdateDocumentRequest.prototype.mask = null; + + /** + * UpdateDocumentRequest currentDocument. + * @member {google.firestore.v1.IPrecondition|null|undefined} currentDocument + * @memberof google.firestore.v1.UpdateDocumentRequest + * @instance + */ + UpdateDocumentRequest.prototype.currentDocument = null; + + /** + * Creates an UpdateDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.UpdateDocumentRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.UpdateDocumentRequest} UpdateDocumentRequest + */ + UpdateDocumentRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.UpdateDocumentRequest) + return object; + var message = new $root.google.firestore.v1.UpdateDocumentRequest(); + if (object.document != null) { + if (typeof object.document !== "object") + throw TypeError(".google.firestore.v1.UpdateDocumentRequest.document: object expected"); + message.document = $root.google.firestore.v1.Document.fromObject(object.document); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.firestore.v1.UpdateDocumentRequest.updateMask: object expected"); + message.updateMask = $root.google.firestore.v1.DocumentMask.fromObject(object.updateMask); + } + if (object.mask != null) { + if (typeof object.mask !== "object") + throw TypeError(".google.firestore.v1.UpdateDocumentRequest.mask: object expected"); + message.mask = $root.google.firestore.v1.DocumentMask.fromObject(object.mask); + } + if (object.currentDocument != null) { + if (typeof object.currentDocument !== "object") + throw TypeError(".google.firestore.v1.UpdateDocumentRequest.currentDocument: object expected"); + message.currentDocument = $root.google.firestore.v1.Precondition.fromObject(object.currentDocument); + } + return message; + }; + + /** + * Creates a plain object from an UpdateDocumentRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.UpdateDocumentRequest + * @static + * @param {google.firestore.v1.UpdateDocumentRequest} message UpdateDocumentRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateDocumentRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.document = null; + object.updateMask = null; + object.mask = null; + object.currentDocument = null; + } + if (message.document != null && message.hasOwnProperty("document")) + object.document = $root.google.firestore.v1.Document.toObject(message.document, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.firestore.v1.DocumentMask.toObject(message.updateMask, options); + if (message.mask != null && message.hasOwnProperty("mask")) + object.mask = $root.google.firestore.v1.DocumentMask.toObject(message.mask, options); + if (message.currentDocument != null && message.hasOwnProperty("currentDocument")) + object.currentDocument = $root.google.firestore.v1.Precondition.toObject(message.currentDocument, options); + return object; + }; + + /** + * Converts this UpdateDocumentRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1.UpdateDocumentRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateDocumentRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return UpdateDocumentRequest; + })(); + + v1.DeleteDocumentRequest = (function() { + + /** + * Properties of a DeleteDocumentRequest. + * @memberof google.firestore.v1 + * @interface IDeleteDocumentRequest + * @property {string|null} [name] DeleteDocumentRequest name + * @property {google.firestore.v1.IPrecondition|null} [currentDocument] DeleteDocumentRequest currentDocument + */ + + /** + * Constructs a new DeleteDocumentRequest. + * @memberof google.firestore.v1 + * @classdesc Represents a DeleteDocumentRequest. + * @implements IDeleteDocumentRequest + * @constructor + * @param {google.firestore.v1.IDeleteDocumentRequest=} [properties] Properties to set + */ + function DeleteDocumentRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteDocumentRequest name. + * @member {string} name + * @memberof google.firestore.v1.DeleteDocumentRequest + * @instance + */ + DeleteDocumentRequest.prototype.name = ""; + + /** + * DeleteDocumentRequest currentDocument. + * @member {google.firestore.v1.IPrecondition|null|undefined} currentDocument + * @memberof google.firestore.v1.DeleteDocumentRequest + * @instance + */ + DeleteDocumentRequest.prototype.currentDocument = null; + + /** + * Creates a DeleteDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.DeleteDocumentRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.DeleteDocumentRequest} DeleteDocumentRequest + */ + DeleteDocumentRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.DeleteDocumentRequest) + return object; + var message = new $root.google.firestore.v1.DeleteDocumentRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.currentDocument != null) { + if (typeof object.currentDocument !== "object") + throw TypeError(".google.firestore.v1.DeleteDocumentRequest.currentDocument: object expected"); + message.currentDocument = $root.google.firestore.v1.Precondition.fromObject(object.currentDocument); + } + return message; + }; + + /** + * Creates a plain object from a DeleteDocumentRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.DeleteDocumentRequest + * @static + * @param {google.firestore.v1.DeleteDocumentRequest} message DeleteDocumentRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteDocumentRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.currentDocument = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.currentDocument != null && message.hasOwnProperty("currentDocument")) + object.currentDocument = $root.google.firestore.v1.Precondition.toObject(message.currentDocument, options); + return object; + }; + + /** + * Converts this DeleteDocumentRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1.DeleteDocumentRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteDocumentRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DeleteDocumentRequest; + })(); + + v1.BatchGetDocumentsRequest = (function() { + + /** + * Properties of a BatchGetDocumentsRequest. + * @memberof google.firestore.v1 + * @interface IBatchGetDocumentsRequest + * @property {string|null} [database] BatchGetDocumentsRequest database + * @property {Array.|null} [documents] BatchGetDocumentsRequest documents + * @property {google.firestore.v1.IDocumentMask|null} [mask] BatchGetDocumentsRequest mask + * @property {Uint8Array|null} [transaction] BatchGetDocumentsRequest transaction + * @property {google.firestore.v1.ITransactionOptions|null} [newTransaction] BatchGetDocumentsRequest newTransaction + * @property {google.protobuf.ITimestamp|null} [readTime] BatchGetDocumentsRequest readTime + */ + + /** + * Constructs a new BatchGetDocumentsRequest. + * @memberof google.firestore.v1 + * @classdesc Represents a BatchGetDocumentsRequest. + * @implements IBatchGetDocumentsRequest + * @constructor + * @param {google.firestore.v1.IBatchGetDocumentsRequest=} [properties] Properties to set + */ + function BatchGetDocumentsRequest(properties) { + this.documents = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BatchGetDocumentsRequest database. + * @member {string} database + * @memberof google.firestore.v1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.database = ""; + + /** + * BatchGetDocumentsRequest documents. + * @member {Array.} documents + * @memberof google.firestore.v1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.documents = $util.emptyArray; + + /** + * BatchGetDocumentsRequest mask. + * @member {google.firestore.v1.IDocumentMask|null|undefined} mask + * @memberof google.firestore.v1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.mask = null; + + /** + * BatchGetDocumentsRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.transaction = $util.newBuffer([]); + + /** + * BatchGetDocumentsRequest newTransaction. + * @member {google.firestore.v1.ITransactionOptions|null|undefined} newTransaction + * @memberof google.firestore.v1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.newTransaction = null; + + /** + * BatchGetDocumentsRequest readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.readTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * BatchGetDocumentsRequest consistencySelector. + * @member {"transaction"|"newTransaction"|"readTime"|undefined} consistencySelector + * @memberof google.firestore.v1.BatchGetDocumentsRequest + * @instance + */ + Object.defineProperty(BatchGetDocumentsRequest.prototype, "consistencySelector", { + get: $util.oneOfGetter($oneOfFields = ["transaction", "newTransaction", "readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a BatchGetDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.BatchGetDocumentsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.BatchGetDocumentsRequest} BatchGetDocumentsRequest + */ + BatchGetDocumentsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.BatchGetDocumentsRequest) + return object; + var message = new $root.google.firestore.v1.BatchGetDocumentsRequest(); + if (object.database != null) + message.database = String(object.database); + if (object.documents) { + if (!Array.isArray(object.documents)) + throw TypeError(".google.firestore.v1.BatchGetDocumentsRequest.documents: array expected"); + message.documents = []; + for (var i = 0; i < object.documents.length; ++i) + message.documents[i] = String(object.documents[i]); + } + if (object.mask != null) { + if (typeof object.mask !== "object") + throw TypeError(".google.firestore.v1.BatchGetDocumentsRequest.mask: object expected"); + message.mask = $root.google.firestore.v1.DocumentMask.fromObject(object.mask); + } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + if (object.newTransaction != null) { + if (typeof object.newTransaction !== "object") + throw TypeError(".google.firestore.v1.BatchGetDocumentsRequest.newTransaction: object expected"); + message.newTransaction = $root.google.firestore.v1.TransactionOptions.fromObject(object.newTransaction); + } + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1.BatchGetDocumentsRequest.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a BatchGetDocumentsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.BatchGetDocumentsRequest + * @static + * @param {google.firestore.v1.BatchGetDocumentsRequest} message BatchGetDocumentsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchGetDocumentsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.documents = []; + if (options.defaults) { + object.database = ""; + object.mask = null; + } + if (message.database != null && message.hasOwnProperty("database")) + object.database = message.database; + if (message.documents && message.documents.length) { + object.documents = []; + for (var j = 0; j < message.documents.length; ++j) + object.documents[j] = message.documents[j]; + } + if (message.mask != null && message.hasOwnProperty("mask")) + object.mask = $root.google.firestore.v1.DocumentMask.toObject(message.mask, options); + if (message.transaction != null && message.hasOwnProperty("transaction")) { + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (options.oneofs) + object.consistencySelector = "transaction"; + } + if (message.newTransaction != null && message.hasOwnProperty("newTransaction")) { + object.newTransaction = $root.google.firestore.v1.TransactionOptions.toObject(message.newTransaction, options); + if (options.oneofs) + object.consistencySelector = "newTransaction"; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (options.oneofs) + object.consistencySelector = "readTime"; + } + return object; + }; + + /** + * Converts this BatchGetDocumentsRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1.BatchGetDocumentsRequest + * @instance + * @returns {Object.} JSON object + */ + BatchGetDocumentsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BatchGetDocumentsRequest; + })(); + + v1.BatchGetDocumentsResponse = (function() { + + /** + * Properties of a BatchGetDocumentsResponse. + * @memberof google.firestore.v1 + * @interface IBatchGetDocumentsResponse + * @property {google.firestore.v1.IDocument|null} [found] BatchGetDocumentsResponse found + * @property {string|null} [missing] BatchGetDocumentsResponse missing + * @property {Uint8Array|null} [transaction] BatchGetDocumentsResponse transaction + * @property {google.protobuf.ITimestamp|null} [readTime] BatchGetDocumentsResponse readTime + */ + + /** + * Constructs a new BatchGetDocumentsResponse. + * @memberof google.firestore.v1 + * @classdesc Represents a BatchGetDocumentsResponse. + * @implements IBatchGetDocumentsResponse + * @constructor + * @param {google.firestore.v1.IBatchGetDocumentsResponse=} [properties] Properties to set + */ + function BatchGetDocumentsResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BatchGetDocumentsResponse found. + * @member {google.firestore.v1.IDocument|null|undefined} found + * @memberof google.firestore.v1.BatchGetDocumentsResponse + * @instance + */ + BatchGetDocumentsResponse.prototype.found = null; + + /** + * BatchGetDocumentsResponse missing. + * @member {string} missing + * @memberof google.firestore.v1.BatchGetDocumentsResponse + * @instance + */ + BatchGetDocumentsResponse.prototype.missing = ""; + + /** + * BatchGetDocumentsResponse transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1.BatchGetDocumentsResponse + * @instance + */ + BatchGetDocumentsResponse.prototype.transaction = $util.newBuffer([]); + + /** + * BatchGetDocumentsResponse readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1.BatchGetDocumentsResponse + * @instance + */ + BatchGetDocumentsResponse.prototype.readTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * BatchGetDocumentsResponse result. + * @member {"found"|"missing"|undefined} result + * @memberof google.firestore.v1.BatchGetDocumentsResponse + * @instance + */ + Object.defineProperty(BatchGetDocumentsResponse.prototype, "result", { + get: $util.oneOfGetter($oneOfFields = ["found", "missing"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a BatchGetDocumentsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.BatchGetDocumentsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.BatchGetDocumentsResponse} BatchGetDocumentsResponse + */ + BatchGetDocumentsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.BatchGetDocumentsResponse) + return object; + var message = new $root.google.firestore.v1.BatchGetDocumentsResponse(); + if (object.found != null) { + if (typeof object.found !== "object") + throw TypeError(".google.firestore.v1.BatchGetDocumentsResponse.found: object expected"); + message.found = $root.google.firestore.v1.Document.fromObject(object.found); + } + if (object.missing != null) + message.missing = String(object.missing); + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1.BatchGetDocumentsResponse.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a BatchGetDocumentsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.BatchGetDocumentsResponse + * @static + * @param {google.firestore.v1.BatchGetDocumentsResponse} message BatchGetDocumentsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchGetDocumentsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } + object.readTime = null; + } + if (message.found != null && message.hasOwnProperty("found")) { + object.found = $root.google.firestore.v1.Document.toObject(message.found, options); + if (options.oneofs) + object.result = "found"; + } + if (message.missing != null && message.hasOwnProperty("missing")) { + object.missing = message.missing; + if (options.oneofs) + object.result = "missing"; + } + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (message.readTime != null && message.hasOwnProperty("readTime")) + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + return object; + }; + + /** + * Converts this BatchGetDocumentsResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1.BatchGetDocumentsResponse + * @instance + * @returns {Object.} JSON object + */ + BatchGetDocumentsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BatchGetDocumentsResponse; + })(); + + v1.BeginTransactionRequest = (function() { + + /** + * Properties of a BeginTransactionRequest. + * @memberof google.firestore.v1 + * @interface IBeginTransactionRequest + * @property {string|null} [database] BeginTransactionRequest database + * @property {google.firestore.v1.ITransactionOptions|null} [options] BeginTransactionRequest options + */ + + /** + * Constructs a new BeginTransactionRequest. + * @memberof google.firestore.v1 + * @classdesc Represents a BeginTransactionRequest. + * @implements IBeginTransactionRequest + * @constructor + * @param {google.firestore.v1.IBeginTransactionRequest=} [properties] Properties to set + */ + function BeginTransactionRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BeginTransactionRequest database. + * @member {string} database + * @memberof google.firestore.v1.BeginTransactionRequest + * @instance + */ + BeginTransactionRequest.prototype.database = ""; + + /** + * BeginTransactionRequest options. + * @member {google.firestore.v1.ITransactionOptions|null|undefined} options + * @memberof google.firestore.v1.BeginTransactionRequest + * @instance + */ + BeginTransactionRequest.prototype.options = null; + + /** + * Creates a BeginTransactionRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.BeginTransactionRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.BeginTransactionRequest} BeginTransactionRequest + */ + BeginTransactionRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.BeginTransactionRequest) + return object; + var message = new $root.google.firestore.v1.BeginTransactionRequest(); + if (object.database != null) + message.database = String(object.database); + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.firestore.v1.BeginTransactionRequest.options: object expected"); + message.options = $root.google.firestore.v1.TransactionOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from a BeginTransactionRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.BeginTransactionRequest + * @static + * @param {google.firestore.v1.BeginTransactionRequest} message BeginTransactionRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BeginTransactionRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.database = ""; + object.options = null; + } + if (message.database != null && message.hasOwnProperty("database")) + object.database = message.database; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.firestore.v1.TransactionOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this BeginTransactionRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1.BeginTransactionRequest + * @instance + * @returns {Object.} JSON object + */ + BeginTransactionRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BeginTransactionRequest; + })(); + + v1.BeginTransactionResponse = (function() { + + /** + * Properties of a BeginTransactionResponse. + * @memberof google.firestore.v1 + * @interface IBeginTransactionResponse + * @property {Uint8Array|null} [transaction] BeginTransactionResponse transaction + */ + + /** + * Constructs a new BeginTransactionResponse. + * @memberof google.firestore.v1 + * @classdesc Represents a BeginTransactionResponse. + * @implements IBeginTransactionResponse + * @constructor + * @param {google.firestore.v1.IBeginTransactionResponse=} [properties] Properties to set + */ + function BeginTransactionResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BeginTransactionResponse transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1.BeginTransactionResponse + * @instance + */ + BeginTransactionResponse.prototype.transaction = $util.newBuffer([]); + + /** + * Creates a BeginTransactionResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.BeginTransactionResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.BeginTransactionResponse} BeginTransactionResponse + */ + BeginTransactionResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.BeginTransactionResponse) + return object; + var message = new $root.google.firestore.v1.BeginTransactionResponse(); + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + return message; + }; + + /** + * Creates a plain object from a BeginTransactionResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.BeginTransactionResponse + * @static + * @param {google.firestore.v1.BeginTransactionResponse} message BeginTransactionResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BeginTransactionResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + return object; + }; + + /** + * Converts this BeginTransactionResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1.BeginTransactionResponse + * @instance + * @returns {Object.} JSON object + */ + BeginTransactionResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BeginTransactionResponse; + })(); + + v1.CommitRequest = (function() { + + /** + * Properties of a CommitRequest. + * @memberof google.firestore.v1 + * @interface ICommitRequest + * @property {string|null} [database] CommitRequest database + * @property {Array.|null} [writes] CommitRequest writes + * @property {Uint8Array|null} [transaction] CommitRequest transaction + */ + + /** + * Constructs a new CommitRequest. + * @memberof google.firestore.v1 + * @classdesc Represents a CommitRequest. + * @implements ICommitRequest + * @constructor + * @param {google.firestore.v1.ICommitRequest=} [properties] Properties to set + */ + function CommitRequest(properties) { + this.writes = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CommitRequest database. + * @member {string} database + * @memberof google.firestore.v1.CommitRequest + * @instance + */ + CommitRequest.prototype.database = ""; + + /** + * CommitRequest writes. + * @member {Array.} writes + * @memberof google.firestore.v1.CommitRequest + * @instance + */ + CommitRequest.prototype.writes = $util.emptyArray; + + /** + * CommitRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1.CommitRequest + * @instance + */ + CommitRequest.prototype.transaction = $util.newBuffer([]); + + /** + * Creates a CommitRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.CommitRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.CommitRequest} CommitRequest + */ + CommitRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.CommitRequest) + return object; + var message = new $root.google.firestore.v1.CommitRequest(); + if (object.database != null) + message.database = String(object.database); + if (object.writes) { + if (!Array.isArray(object.writes)) + throw TypeError(".google.firestore.v1.CommitRequest.writes: array expected"); + message.writes = []; + for (var i = 0; i < object.writes.length; ++i) { + if (typeof object.writes[i] !== "object") + throw TypeError(".google.firestore.v1.CommitRequest.writes: object expected"); + message.writes[i] = $root.google.firestore.v1.Write.fromObject(object.writes[i]); + } + } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + return message; + }; + + /** + * Creates a plain object from a CommitRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.CommitRequest + * @static + * @param {google.firestore.v1.CommitRequest} message CommitRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CommitRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.writes = []; + if (options.defaults) { + object.database = ""; + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } + } + if (message.database != null && message.hasOwnProperty("database")) + object.database = message.database; + if (message.writes && message.writes.length) { + object.writes = []; + for (var j = 0; j < message.writes.length; ++j) + object.writes[j] = $root.google.firestore.v1.Write.toObject(message.writes[j], options); + } + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + return object; + }; + + /** + * Converts this CommitRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1.CommitRequest + * @instance + * @returns {Object.} JSON object + */ + CommitRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CommitRequest; + })(); + + v1.CommitResponse = (function() { + + /** + * Properties of a CommitResponse. + * @memberof google.firestore.v1 + * @interface ICommitResponse + * @property {Array.|null} [writeResults] CommitResponse writeResults + * @property {google.protobuf.ITimestamp|null} [commitTime] CommitResponse commitTime + */ + + /** + * Constructs a new CommitResponse. + * @memberof google.firestore.v1 + * @classdesc Represents a CommitResponse. + * @implements ICommitResponse + * @constructor + * @param {google.firestore.v1.ICommitResponse=} [properties] Properties to set + */ + function CommitResponse(properties) { + this.writeResults = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CommitResponse writeResults. + * @member {Array.} writeResults + * @memberof google.firestore.v1.CommitResponse + * @instance + */ + CommitResponse.prototype.writeResults = $util.emptyArray; + + /** + * CommitResponse commitTime. + * @member {google.protobuf.ITimestamp|null|undefined} commitTime + * @memberof google.firestore.v1.CommitResponse + * @instance + */ + CommitResponse.prototype.commitTime = null; + + /** + * Creates a CommitResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.CommitResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.CommitResponse} CommitResponse + */ + CommitResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.CommitResponse) + return object; + var message = new $root.google.firestore.v1.CommitResponse(); + if (object.writeResults) { + if (!Array.isArray(object.writeResults)) + throw TypeError(".google.firestore.v1.CommitResponse.writeResults: array expected"); + message.writeResults = []; + for (var i = 0; i < object.writeResults.length; ++i) { + if (typeof object.writeResults[i] !== "object") + throw TypeError(".google.firestore.v1.CommitResponse.writeResults: object expected"); + message.writeResults[i] = $root.google.firestore.v1.WriteResult.fromObject(object.writeResults[i]); + } + } + if (object.commitTime != null) { + if (typeof object.commitTime !== "object") + throw TypeError(".google.firestore.v1.CommitResponse.commitTime: object expected"); + message.commitTime = $root.google.protobuf.Timestamp.fromObject(object.commitTime); + } + return message; + }; + + /** + * Creates a plain object from a CommitResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.CommitResponse + * @static + * @param {google.firestore.v1.CommitResponse} message CommitResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CommitResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.writeResults = []; + if (options.defaults) + object.commitTime = null; + if (message.writeResults && message.writeResults.length) { + object.writeResults = []; + for (var j = 0; j < message.writeResults.length; ++j) + object.writeResults[j] = $root.google.firestore.v1.WriteResult.toObject(message.writeResults[j], options); + } + if (message.commitTime != null && message.hasOwnProperty("commitTime")) + object.commitTime = $root.google.protobuf.Timestamp.toObject(message.commitTime, options); + return object; + }; + + /** + * Converts this CommitResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1.CommitResponse + * @instance + * @returns {Object.} JSON object + */ + CommitResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CommitResponse; + })(); + + v1.RollbackRequest = (function() { + + /** + * Properties of a RollbackRequest. + * @memberof google.firestore.v1 + * @interface IRollbackRequest + * @property {string|null} [database] RollbackRequest database + * @property {Uint8Array|null} [transaction] RollbackRequest transaction + */ + + /** + * Constructs a new RollbackRequest. + * @memberof google.firestore.v1 + * @classdesc Represents a RollbackRequest. + * @implements IRollbackRequest + * @constructor + * @param {google.firestore.v1.IRollbackRequest=} [properties] Properties to set + */ + function RollbackRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RollbackRequest database. + * @member {string} database + * @memberof google.firestore.v1.RollbackRequest + * @instance + */ + RollbackRequest.prototype.database = ""; + + /** + * RollbackRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1.RollbackRequest + * @instance + */ + RollbackRequest.prototype.transaction = $util.newBuffer([]); + + /** + * Creates a RollbackRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.RollbackRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.RollbackRequest} RollbackRequest + */ + RollbackRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.RollbackRequest) + return object; + var message = new $root.google.firestore.v1.RollbackRequest(); + if (object.database != null) + message.database = String(object.database); + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + return message; + }; + + /** + * Creates a plain object from a RollbackRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.RollbackRequest + * @static + * @param {google.firestore.v1.RollbackRequest} message RollbackRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RollbackRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.database = ""; + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } + } + if (message.database != null && message.hasOwnProperty("database")) + object.database = message.database; + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + return object; + }; + + /** + * Converts this RollbackRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1.RollbackRequest + * @instance + * @returns {Object.} JSON object + */ + RollbackRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return RollbackRequest; + })(); + + v1.RunQueryRequest = (function() { + + /** + * Properties of a RunQueryRequest. + * @memberof google.firestore.v1 + * @interface IRunQueryRequest + * @property {string|null} [parent] RunQueryRequest parent + * @property {google.firestore.v1.IStructuredQuery|null} [structuredQuery] RunQueryRequest structuredQuery + * @property {Uint8Array|null} [transaction] RunQueryRequest transaction + * @property {google.firestore.v1.ITransactionOptions|null} [newTransaction] RunQueryRequest newTransaction + * @property {google.protobuf.ITimestamp|null} [readTime] RunQueryRequest readTime + */ + + /** + * Constructs a new RunQueryRequest. + * @memberof google.firestore.v1 + * @classdesc Represents a RunQueryRequest. + * @implements IRunQueryRequest + * @constructor + * @param {google.firestore.v1.IRunQueryRequest=} [properties] Properties to set + */ + function RunQueryRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RunQueryRequest parent. + * @member {string} parent + * @memberof google.firestore.v1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.parent = ""; + + /** + * RunQueryRequest structuredQuery. + * @member {google.firestore.v1.IStructuredQuery|null|undefined} structuredQuery + * @memberof google.firestore.v1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.structuredQuery = null; + + /** + * RunQueryRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.transaction = $util.newBuffer([]); + + /** + * RunQueryRequest newTransaction. + * @member {google.firestore.v1.ITransactionOptions|null|undefined} newTransaction + * @memberof google.firestore.v1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.newTransaction = null; + + /** + * RunQueryRequest readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.readTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * RunQueryRequest queryType. + * @member {"structuredQuery"|undefined} queryType + * @memberof google.firestore.v1.RunQueryRequest + * @instance + */ + Object.defineProperty(RunQueryRequest.prototype, "queryType", { + get: $util.oneOfGetter($oneOfFields = ["structuredQuery"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * RunQueryRequest consistencySelector. + * @member {"transaction"|"newTransaction"|"readTime"|undefined} consistencySelector + * @memberof google.firestore.v1.RunQueryRequest + * @instance + */ + Object.defineProperty(RunQueryRequest.prototype, "consistencySelector", { + get: $util.oneOfGetter($oneOfFields = ["transaction", "newTransaction", "readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a RunQueryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.RunQueryRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.RunQueryRequest} RunQueryRequest + */ + RunQueryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.RunQueryRequest) + return object; + var message = new $root.google.firestore.v1.RunQueryRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.structuredQuery != null) { + if (typeof object.structuredQuery !== "object") + throw TypeError(".google.firestore.v1.RunQueryRequest.structuredQuery: object expected"); + message.structuredQuery = $root.google.firestore.v1.StructuredQuery.fromObject(object.structuredQuery); + } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + if (object.newTransaction != null) { + if (typeof object.newTransaction !== "object") + throw TypeError(".google.firestore.v1.RunQueryRequest.newTransaction: object expected"); + message.newTransaction = $root.google.firestore.v1.TransactionOptions.fromObject(object.newTransaction); + } + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1.RunQueryRequest.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a RunQueryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.RunQueryRequest + * @static + * @param {google.firestore.v1.RunQueryRequest} message RunQueryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RunQueryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.parent = ""; + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.structuredQuery != null && message.hasOwnProperty("structuredQuery")) { + object.structuredQuery = $root.google.firestore.v1.StructuredQuery.toObject(message.structuredQuery, options); + if (options.oneofs) + object.queryType = "structuredQuery"; + } + if (message.transaction != null && message.hasOwnProperty("transaction")) { + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (options.oneofs) + object.consistencySelector = "transaction"; + } + if (message.newTransaction != null && message.hasOwnProperty("newTransaction")) { + object.newTransaction = $root.google.firestore.v1.TransactionOptions.toObject(message.newTransaction, options); + if (options.oneofs) + object.consistencySelector = "newTransaction"; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (options.oneofs) + object.consistencySelector = "readTime"; + } + return object; + }; + + /** + * Converts this RunQueryRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1.RunQueryRequest + * @instance + * @returns {Object.} JSON object + */ + RunQueryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return RunQueryRequest; + })(); + + v1.RunQueryResponse = (function() { + + /** + * Properties of a RunQueryResponse. + * @memberof google.firestore.v1 + * @interface IRunQueryResponse + * @property {Uint8Array|null} [transaction] RunQueryResponse transaction + * @property {google.firestore.v1.IDocument|null} [document] RunQueryResponse document + * @property {google.protobuf.ITimestamp|null} [readTime] RunQueryResponse readTime + * @property {number|null} [skippedResults] RunQueryResponse skippedResults + */ + + /** + * Constructs a new RunQueryResponse. + * @memberof google.firestore.v1 + * @classdesc Represents a RunQueryResponse. + * @implements IRunQueryResponse + * @constructor + * @param {google.firestore.v1.IRunQueryResponse=} [properties] Properties to set + */ + function RunQueryResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RunQueryResponse transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.transaction = $util.newBuffer([]); + + /** + * RunQueryResponse document. + * @member {google.firestore.v1.IDocument|null|undefined} document + * @memberof google.firestore.v1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.document = null; + + /** + * RunQueryResponse readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.readTime = null; + + /** + * RunQueryResponse skippedResults. + * @member {number} skippedResults + * @memberof google.firestore.v1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.skippedResults = 0; + + /** + * Creates a RunQueryResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.RunQueryResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.RunQueryResponse} RunQueryResponse + */ + RunQueryResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.RunQueryResponse) + return object; + var message = new $root.google.firestore.v1.RunQueryResponse(); + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + if (object.document != null) { + if (typeof object.document !== "object") + throw TypeError(".google.firestore.v1.RunQueryResponse.document: object expected"); + message.document = $root.google.firestore.v1.Document.fromObject(object.document); + } + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1.RunQueryResponse.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + if (object.skippedResults != null) + message.skippedResults = object.skippedResults | 0; + return message; + }; + + /** + * Creates a plain object from a RunQueryResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.RunQueryResponse + * @static + * @param {google.firestore.v1.RunQueryResponse} message RunQueryResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RunQueryResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.document = null; + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } + object.readTime = null; + object.skippedResults = 0; + } + if (message.document != null && message.hasOwnProperty("document")) + object.document = $root.google.firestore.v1.Document.toObject(message.document, options); + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (message.readTime != null && message.hasOwnProperty("readTime")) + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (message.skippedResults != null && message.hasOwnProperty("skippedResults")) + object.skippedResults = message.skippedResults; + return object; + }; + + /** + * Converts this RunQueryResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1.RunQueryResponse + * @instance + * @returns {Object.} JSON object + */ + RunQueryResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return RunQueryResponse; + })(); + + v1.PartitionQueryRequest = (function() { + + /** + * Properties of a PartitionQueryRequest. + * @memberof google.firestore.v1 + * @interface IPartitionQueryRequest + * @property {string|null} [parent] PartitionQueryRequest parent + * @property {google.firestore.v1.IStructuredQuery|null} [structuredQuery] PartitionQueryRequest structuredQuery + * @property {number|string|null} [partitionCount] PartitionQueryRequest partitionCount + * @property {string|null} [pageToken] PartitionQueryRequest pageToken + * @property {number|null} [pageSize] PartitionQueryRequest pageSize + */ + + /** + * Constructs a new PartitionQueryRequest. + * @memberof google.firestore.v1 + * @classdesc Represents a PartitionQueryRequest. + * @implements IPartitionQueryRequest + * @constructor + * @param {google.firestore.v1.IPartitionQueryRequest=} [properties] Properties to set + */ + function PartitionQueryRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PartitionQueryRequest parent. + * @member {string} parent + * @memberof google.firestore.v1.PartitionQueryRequest + * @instance + */ + PartitionQueryRequest.prototype.parent = ""; + + /** + * PartitionQueryRequest structuredQuery. + * @member {google.firestore.v1.IStructuredQuery|null|undefined} structuredQuery + * @memberof google.firestore.v1.PartitionQueryRequest + * @instance + */ + PartitionQueryRequest.prototype.structuredQuery = null; + + /** + * PartitionQueryRequest partitionCount. + * @member {number|string} partitionCount + * @memberof google.firestore.v1.PartitionQueryRequest + * @instance + */ + PartitionQueryRequest.prototype.partitionCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * PartitionQueryRequest pageToken. + * @member {string} pageToken + * @memberof google.firestore.v1.PartitionQueryRequest + * @instance + */ + PartitionQueryRequest.prototype.pageToken = ""; + + /** + * PartitionQueryRequest pageSize. + * @member {number} pageSize + * @memberof google.firestore.v1.PartitionQueryRequest + * @instance + */ + PartitionQueryRequest.prototype.pageSize = 0; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * PartitionQueryRequest queryType. + * @member {"structuredQuery"|undefined} queryType + * @memberof google.firestore.v1.PartitionQueryRequest + * @instance + */ + Object.defineProperty(PartitionQueryRequest.prototype, "queryType", { + get: $util.oneOfGetter($oneOfFields = ["structuredQuery"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a PartitionQueryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.PartitionQueryRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.PartitionQueryRequest} PartitionQueryRequest + */ + PartitionQueryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.PartitionQueryRequest) + return object; + var message = new $root.google.firestore.v1.PartitionQueryRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.structuredQuery != null) { + if (typeof object.structuredQuery !== "object") + throw TypeError(".google.firestore.v1.PartitionQueryRequest.structuredQuery: object expected"); + message.structuredQuery = $root.google.firestore.v1.StructuredQuery.fromObject(object.structuredQuery); + } + if (object.partitionCount != null) + if ($util.Long) + (message.partitionCount = $util.Long.fromValue(object.partitionCount)).unsigned = false; + else if (typeof object.partitionCount === "string") + message.partitionCount = parseInt(object.partitionCount, 10); + else if (typeof object.partitionCount === "number") + message.partitionCount = object.partitionCount; + else if (typeof object.partitionCount === "object") + message.partitionCount = new $util.LongBits(object.partitionCount.low >>> 0, object.partitionCount.high >>> 0).toNumber(); + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + return message; + }; + + /** + * Creates a plain object from a PartitionQueryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.PartitionQueryRequest + * @static + * @param {google.firestore.v1.PartitionQueryRequest} message PartitionQueryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PartitionQueryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.partitionCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.partitionCount = options.longs === String ? "0" : 0; + object.pageToken = ""; + object.pageSize = 0; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.structuredQuery != null && message.hasOwnProperty("structuredQuery")) { + object.structuredQuery = $root.google.firestore.v1.StructuredQuery.toObject(message.structuredQuery, options); + if (options.oneofs) + object.queryType = "structuredQuery"; + } + if (message.partitionCount != null && message.hasOwnProperty("partitionCount")) + if (typeof message.partitionCount === "number") + object.partitionCount = options.longs === String ? String(message.partitionCount) : message.partitionCount; + else + object.partitionCount = options.longs === String ? $util.Long.prototype.toString.call(message.partitionCount) : options.longs === Number ? new $util.LongBits(message.partitionCount.low >>> 0, message.partitionCount.high >>> 0).toNumber() : message.partitionCount; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + return object; + }; + + /** + * Converts this PartitionQueryRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1.PartitionQueryRequest + * @instance + * @returns {Object.} JSON object + */ + PartitionQueryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return PartitionQueryRequest; + })(); + + v1.PartitionQueryResponse = (function() { + + /** + * Properties of a PartitionQueryResponse. + * @memberof google.firestore.v1 + * @interface IPartitionQueryResponse + * @property {Array.|null} [partitions] PartitionQueryResponse partitions + * @property {string|null} [nextPageToken] PartitionQueryResponse nextPageToken + */ + + /** + * Constructs a new PartitionQueryResponse. + * @memberof google.firestore.v1 + * @classdesc Represents a PartitionQueryResponse. + * @implements IPartitionQueryResponse + * @constructor + * @param {google.firestore.v1.IPartitionQueryResponse=} [properties] Properties to set + */ + function PartitionQueryResponse(properties) { + this.partitions = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PartitionQueryResponse partitions. + * @member {Array.} partitions + * @memberof google.firestore.v1.PartitionQueryResponse + * @instance + */ + PartitionQueryResponse.prototype.partitions = $util.emptyArray; + + /** + * PartitionQueryResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.firestore.v1.PartitionQueryResponse + * @instance + */ + PartitionQueryResponse.prototype.nextPageToken = ""; + + /** + * Creates a PartitionQueryResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.PartitionQueryResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.PartitionQueryResponse} PartitionQueryResponse + */ + PartitionQueryResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.PartitionQueryResponse) + return object; + var message = new $root.google.firestore.v1.PartitionQueryResponse(); + if (object.partitions) { + if (!Array.isArray(object.partitions)) + throw TypeError(".google.firestore.v1.PartitionQueryResponse.partitions: array expected"); + message.partitions = []; + for (var i = 0; i < object.partitions.length; ++i) { + if (typeof object.partitions[i] !== "object") + throw TypeError(".google.firestore.v1.PartitionQueryResponse.partitions: object expected"); + message.partitions[i] = $root.google.firestore.v1.Cursor.fromObject(object.partitions[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a PartitionQueryResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.PartitionQueryResponse + * @static + * @param {google.firestore.v1.PartitionQueryResponse} message PartitionQueryResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PartitionQueryResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.partitions = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.partitions && message.partitions.length) { + object.partitions = []; + for (var j = 0; j < message.partitions.length; ++j) + object.partitions[j] = $root.google.firestore.v1.Cursor.toObject(message.partitions[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this PartitionQueryResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1.PartitionQueryResponse + * @instance + * @returns {Object.} JSON object + */ + PartitionQueryResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return PartitionQueryResponse; + })(); + + v1.WriteRequest = (function() { + + /** + * Properties of a WriteRequest. + * @memberof google.firestore.v1 + * @interface IWriteRequest + * @property {string|null} [database] WriteRequest database + * @property {string|null} [streamId] WriteRequest streamId + * @property {Array.|null} [writes] WriteRequest writes + * @property {Uint8Array|null} [streamToken] WriteRequest streamToken + * @property {Object.|null} [labels] WriteRequest labels + */ + + /** + * Constructs a new WriteRequest. + * @memberof google.firestore.v1 + * @classdesc Represents a WriteRequest. + * @implements IWriteRequest + * @constructor + * @param {google.firestore.v1.IWriteRequest=} [properties] Properties to set + */ + function WriteRequest(properties) { + this.writes = []; + this.labels = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WriteRequest database. + * @member {string} database + * @memberof google.firestore.v1.WriteRequest + * @instance + */ + WriteRequest.prototype.database = ""; + + /** + * WriteRequest streamId. + * @member {string} streamId + * @memberof google.firestore.v1.WriteRequest + * @instance + */ + WriteRequest.prototype.streamId = ""; + + /** + * WriteRequest writes. + * @member {Array.} writes + * @memberof google.firestore.v1.WriteRequest + * @instance + */ + WriteRequest.prototype.writes = $util.emptyArray; + + /** + * WriteRequest streamToken. + * @member {Uint8Array} streamToken + * @memberof google.firestore.v1.WriteRequest + * @instance + */ + WriteRequest.prototype.streamToken = $util.newBuffer([]); + + /** + * WriteRequest labels. + * @member {Object.} labels + * @memberof google.firestore.v1.WriteRequest + * @instance + */ + WriteRequest.prototype.labels = $util.emptyObject; + + /** + * Creates a WriteRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.WriteRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.WriteRequest} WriteRequest + */ + WriteRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.WriteRequest) + return object; + var message = new $root.google.firestore.v1.WriteRequest(); + if (object.database != null) + message.database = String(object.database); + if (object.streamId != null) + message.streamId = String(object.streamId); + if (object.writes) { + if (!Array.isArray(object.writes)) + throw TypeError(".google.firestore.v1.WriteRequest.writes: array expected"); + message.writes = []; + for (var i = 0; i < object.writes.length; ++i) { + if (typeof object.writes[i] !== "object") + throw TypeError(".google.firestore.v1.WriteRequest.writes: object expected"); + message.writes[i] = $root.google.firestore.v1.Write.fromObject(object.writes[i]); + } + } + if (object.streamToken != null) + if (typeof object.streamToken === "string") + $util.base64.decode(object.streamToken, message.streamToken = $util.newBuffer($util.base64.length(object.streamToken)), 0); + else if (object.streamToken.length) + message.streamToken = object.streamToken; + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.firestore.v1.WriteRequest.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } + return message; + }; + + /** + * Creates a plain object from a WriteRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.WriteRequest + * @static + * @param {google.firestore.v1.WriteRequest} message WriteRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WriteRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.writes = []; + if (options.objects || options.defaults) + object.labels = {}; + if (options.defaults) { + object.database = ""; + object.streamId = ""; + if (options.bytes === String) + object.streamToken = ""; + else { + object.streamToken = []; + if (options.bytes !== Array) + object.streamToken = $util.newBuffer(object.streamToken); + } + } + if (message.database != null && message.hasOwnProperty("database")) + object.database = message.database; + if (message.streamId != null && message.hasOwnProperty("streamId")) + object.streamId = message.streamId; + if (message.writes && message.writes.length) { + object.writes = []; + for (var j = 0; j < message.writes.length; ++j) + object.writes[j] = $root.google.firestore.v1.Write.toObject(message.writes[j], options); + } + if (message.streamToken != null && message.hasOwnProperty("streamToken")) + object.streamToken = options.bytes === String ? $util.base64.encode(message.streamToken, 0, message.streamToken.length) : options.bytes === Array ? Array.prototype.slice.call(message.streamToken) : message.streamToken; + var keys2; + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } + return object; + }; + + /** + * Converts this WriteRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1.WriteRequest + * @instance + * @returns {Object.} JSON object + */ + WriteRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return WriteRequest; + })(); + + v1.WriteResponse = (function() { + + /** + * Properties of a WriteResponse. + * @memberof google.firestore.v1 + * @interface IWriteResponse + * @property {string|null} [streamId] WriteResponse streamId + * @property {Uint8Array|null} [streamToken] WriteResponse streamToken + * @property {Array.|null} [writeResults] WriteResponse writeResults + * @property {google.protobuf.ITimestamp|null} [commitTime] WriteResponse commitTime + */ + + /** + * Constructs a new WriteResponse. + * @memberof google.firestore.v1 + * @classdesc Represents a WriteResponse. + * @implements IWriteResponse + * @constructor + * @param {google.firestore.v1.IWriteResponse=} [properties] Properties to set + */ + function WriteResponse(properties) { + this.writeResults = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WriteResponse streamId. + * @member {string} streamId + * @memberof google.firestore.v1.WriteResponse + * @instance + */ + WriteResponse.prototype.streamId = ""; + + /** + * WriteResponse streamToken. + * @member {Uint8Array} streamToken + * @memberof google.firestore.v1.WriteResponse + * @instance + */ + WriteResponse.prototype.streamToken = $util.newBuffer([]); + + /** + * WriteResponse writeResults. + * @member {Array.} writeResults + * @memberof google.firestore.v1.WriteResponse + * @instance + */ + WriteResponse.prototype.writeResults = $util.emptyArray; + + /** + * WriteResponse commitTime. + * @member {google.protobuf.ITimestamp|null|undefined} commitTime + * @memberof google.firestore.v1.WriteResponse + * @instance + */ + WriteResponse.prototype.commitTime = null; + + /** + * Creates a WriteResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.WriteResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.WriteResponse} WriteResponse + */ + WriteResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.WriteResponse) + return object; + var message = new $root.google.firestore.v1.WriteResponse(); + if (object.streamId != null) + message.streamId = String(object.streamId); + if (object.streamToken != null) + if (typeof object.streamToken === "string") + $util.base64.decode(object.streamToken, message.streamToken = $util.newBuffer($util.base64.length(object.streamToken)), 0); + else if (object.streamToken.length) + message.streamToken = object.streamToken; + if (object.writeResults) { + if (!Array.isArray(object.writeResults)) + throw TypeError(".google.firestore.v1.WriteResponse.writeResults: array expected"); + message.writeResults = []; + for (var i = 0; i < object.writeResults.length; ++i) { + if (typeof object.writeResults[i] !== "object") + throw TypeError(".google.firestore.v1.WriteResponse.writeResults: object expected"); + message.writeResults[i] = $root.google.firestore.v1.WriteResult.fromObject(object.writeResults[i]); + } + } + if (object.commitTime != null) { + if (typeof object.commitTime !== "object") + throw TypeError(".google.firestore.v1.WriteResponse.commitTime: object expected"); + message.commitTime = $root.google.protobuf.Timestamp.fromObject(object.commitTime); + } + return message; + }; + + /** + * Creates a plain object from a WriteResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.WriteResponse + * @static + * @param {google.firestore.v1.WriteResponse} message WriteResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WriteResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.writeResults = []; + if (options.defaults) { + object.streamId = ""; + if (options.bytes === String) + object.streamToken = ""; + else { + object.streamToken = []; + if (options.bytes !== Array) + object.streamToken = $util.newBuffer(object.streamToken); + } + object.commitTime = null; + } + if (message.streamId != null && message.hasOwnProperty("streamId")) + object.streamId = message.streamId; + if (message.streamToken != null && message.hasOwnProperty("streamToken")) + object.streamToken = options.bytes === String ? $util.base64.encode(message.streamToken, 0, message.streamToken.length) : options.bytes === Array ? Array.prototype.slice.call(message.streamToken) : message.streamToken; + if (message.writeResults && message.writeResults.length) { + object.writeResults = []; + for (var j = 0; j < message.writeResults.length; ++j) + object.writeResults[j] = $root.google.firestore.v1.WriteResult.toObject(message.writeResults[j], options); + } + if (message.commitTime != null && message.hasOwnProperty("commitTime")) + object.commitTime = $root.google.protobuf.Timestamp.toObject(message.commitTime, options); + return object; + }; + + /** + * Converts this WriteResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1.WriteResponse + * @instance + * @returns {Object.} JSON object + */ + WriteResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return WriteResponse; + })(); + + v1.ListenRequest = (function() { + + /** + * Properties of a ListenRequest. + * @memberof google.firestore.v1 + * @interface IListenRequest + * @property {string|null} [database] ListenRequest database + * @property {google.firestore.v1.ITarget|null} [addTarget] ListenRequest addTarget + * @property {number|null} [removeTarget] ListenRequest removeTarget + * @property {Object.|null} [labels] ListenRequest labels + */ + + /** + * Constructs a new ListenRequest. + * @memberof google.firestore.v1 + * @classdesc Represents a ListenRequest. + * @implements IListenRequest + * @constructor + * @param {google.firestore.v1.IListenRequest=} [properties] Properties to set + */ + function ListenRequest(properties) { + this.labels = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListenRequest database. + * @member {string} database + * @memberof google.firestore.v1.ListenRequest + * @instance + */ + ListenRequest.prototype.database = ""; + + /** + * ListenRequest addTarget. + * @member {google.firestore.v1.ITarget|null|undefined} addTarget + * @memberof google.firestore.v1.ListenRequest + * @instance + */ + ListenRequest.prototype.addTarget = null; + + /** + * ListenRequest removeTarget. + * @member {number} removeTarget + * @memberof google.firestore.v1.ListenRequest + * @instance + */ + ListenRequest.prototype.removeTarget = 0; + + /** + * ListenRequest labels. + * @member {Object.} labels + * @memberof google.firestore.v1.ListenRequest + * @instance + */ + ListenRequest.prototype.labels = $util.emptyObject; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ListenRequest targetChange. + * @member {"addTarget"|"removeTarget"|undefined} targetChange + * @memberof google.firestore.v1.ListenRequest + * @instance + */ + Object.defineProperty(ListenRequest.prototype, "targetChange", { + get: $util.oneOfGetter($oneOfFields = ["addTarget", "removeTarget"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a ListenRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.ListenRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.ListenRequest} ListenRequest + */ + ListenRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.ListenRequest) + return object; + var message = new $root.google.firestore.v1.ListenRequest(); + if (object.database != null) + message.database = String(object.database); + if (object.addTarget != null) { + if (typeof object.addTarget !== "object") + throw TypeError(".google.firestore.v1.ListenRequest.addTarget: object expected"); + message.addTarget = $root.google.firestore.v1.Target.fromObject(object.addTarget); + } + if (object.removeTarget != null) + message.removeTarget = object.removeTarget | 0; + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.firestore.v1.ListenRequest.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } + return message; + }; + + /** + * Creates a plain object from a ListenRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.ListenRequest + * @static + * @param {google.firestore.v1.ListenRequest} message ListenRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListenRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.labels = {}; + if (options.defaults) + object.database = ""; + if (message.database != null && message.hasOwnProperty("database")) + object.database = message.database; + if (message.addTarget != null && message.hasOwnProperty("addTarget")) { + object.addTarget = $root.google.firestore.v1.Target.toObject(message.addTarget, options); + if (options.oneofs) + object.targetChange = "addTarget"; + } + if (message.removeTarget != null && message.hasOwnProperty("removeTarget")) { + object.removeTarget = message.removeTarget; + if (options.oneofs) + object.targetChange = "removeTarget"; + } + var keys2; + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } + return object; + }; + + /** + * Converts this ListenRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1.ListenRequest + * @instance + * @returns {Object.} JSON object + */ + ListenRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListenRequest; + })(); + + v1.ListenResponse = (function() { + + /** + * Properties of a ListenResponse. + * @memberof google.firestore.v1 + * @interface IListenResponse + * @property {google.firestore.v1.ITargetChange|null} [targetChange] ListenResponse targetChange + * @property {google.firestore.v1.IDocumentChange|null} [documentChange] ListenResponse documentChange + * @property {google.firestore.v1.IDocumentDelete|null} [documentDelete] ListenResponse documentDelete + * @property {google.firestore.v1.IDocumentRemove|null} [documentRemove] ListenResponse documentRemove + * @property {google.firestore.v1.IExistenceFilter|null} [filter] ListenResponse filter + */ + + /** + * Constructs a new ListenResponse. + * @memberof google.firestore.v1 + * @classdesc Represents a ListenResponse. + * @implements IListenResponse + * @constructor + * @param {google.firestore.v1.IListenResponse=} [properties] Properties to set + */ + function ListenResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListenResponse targetChange. + * @member {google.firestore.v1.ITargetChange|null|undefined} targetChange + * @memberof google.firestore.v1.ListenResponse + * @instance + */ + ListenResponse.prototype.targetChange = null; + + /** + * ListenResponse documentChange. + * @member {google.firestore.v1.IDocumentChange|null|undefined} documentChange + * @memberof google.firestore.v1.ListenResponse + * @instance + */ + ListenResponse.prototype.documentChange = null; + + /** + * ListenResponse documentDelete. + * @member {google.firestore.v1.IDocumentDelete|null|undefined} documentDelete + * @memberof google.firestore.v1.ListenResponse + * @instance + */ + ListenResponse.prototype.documentDelete = null; + + /** + * ListenResponse documentRemove. + * @member {google.firestore.v1.IDocumentRemove|null|undefined} documentRemove + * @memberof google.firestore.v1.ListenResponse + * @instance + */ + ListenResponse.prototype.documentRemove = null; + + /** + * ListenResponse filter. + * @member {google.firestore.v1.IExistenceFilter|null|undefined} filter + * @memberof google.firestore.v1.ListenResponse + * @instance + */ + ListenResponse.prototype.filter = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ListenResponse responseType. + * @member {"targetChange"|"documentChange"|"documentDelete"|"documentRemove"|"filter"|undefined} responseType + * @memberof google.firestore.v1.ListenResponse + * @instance + */ + Object.defineProperty(ListenResponse.prototype, "responseType", { + get: $util.oneOfGetter($oneOfFields = ["targetChange", "documentChange", "documentDelete", "documentRemove", "filter"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a ListenResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.ListenResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.ListenResponse} ListenResponse + */ + ListenResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.ListenResponse) + return object; + var message = new $root.google.firestore.v1.ListenResponse(); + if (object.targetChange != null) { + if (typeof object.targetChange !== "object") + throw TypeError(".google.firestore.v1.ListenResponse.targetChange: object expected"); + message.targetChange = $root.google.firestore.v1.TargetChange.fromObject(object.targetChange); + } + if (object.documentChange != null) { + if (typeof object.documentChange !== "object") + throw TypeError(".google.firestore.v1.ListenResponse.documentChange: object expected"); + message.documentChange = $root.google.firestore.v1.DocumentChange.fromObject(object.documentChange); + } + if (object.documentDelete != null) { + if (typeof object.documentDelete !== "object") + throw TypeError(".google.firestore.v1.ListenResponse.documentDelete: object expected"); + message.documentDelete = $root.google.firestore.v1.DocumentDelete.fromObject(object.documentDelete); + } + if (object.documentRemove != null) { + if (typeof object.documentRemove !== "object") + throw TypeError(".google.firestore.v1.ListenResponse.documentRemove: object expected"); + message.documentRemove = $root.google.firestore.v1.DocumentRemove.fromObject(object.documentRemove); + } + if (object.filter != null) { + if (typeof object.filter !== "object") + throw TypeError(".google.firestore.v1.ListenResponse.filter: object expected"); + message.filter = $root.google.firestore.v1.ExistenceFilter.fromObject(object.filter); + } + return message; + }; + + /** + * Creates a plain object from a ListenResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.ListenResponse + * @static + * @param {google.firestore.v1.ListenResponse} message ListenResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListenResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.targetChange != null && message.hasOwnProperty("targetChange")) { + object.targetChange = $root.google.firestore.v1.TargetChange.toObject(message.targetChange, options); + if (options.oneofs) + object.responseType = "targetChange"; + } + if (message.documentChange != null && message.hasOwnProperty("documentChange")) { + object.documentChange = $root.google.firestore.v1.DocumentChange.toObject(message.documentChange, options); + if (options.oneofs) + object.responseType = "documentChange"; + } + if (message.documentDelete != null && message.hasOwnProperty("documentDelete")) { + object.documentDelete = $root.google.firestore.v1.DocumentDelete.toObject(message.documentDelete, options); + if (options.oneofs) + object.responseType = "documentDelete"; + } + if (message.filter != null && message.hasOwnProperty("filter")) { + object.filter = $root.google.firestore.v1.ExistenceFilter.toObject(message.filter, options); + if (options.oneofs) + object.responseType = "filter"; + } + if (message.documentRemove != null && message.hasOwnProperty("documentRemove")) { + object.documentRemove = $root.google.firestore.v1.DocumentRemove.toObject(message.documentRemove, options); + if (options.oneofs) + object.responseType = "documentRemove"; + } + return object; + }; + + /** + * Converts this ListenResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1.ListenResponse + * @instance + * @returns {Object.} JSON object + */ + ListenResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListenResponse; + })(); + + v1.Target = (function() { + + /** + * Properties of a Target. + * @memberof google.firestore.v1 + * @interface ITarget + * @property {google.firestore.v1.Target.IQueryTarget|null} [query] Target query + * @property {google.firestore.v1.Target.IDocumentsTarget|null} [documents] Target documents + * @property {Uint8Array|null} [resumeToken] Target resumeToken + * @property {google.protobuf.ITimestamp|null} [readTime] Target readTime + * @property {number|null} [targetId] Target targetId + * @property {boolean|null} [once] Target once + */ + + /** + * Constructs a new Target. + * @memberof google.firestore.v1 + * @classdesc Represents a Target. + * @implements ITarget + * @constructor + * @param {google.firestore.v1.ITarget=} [properties] Properties to set + */ + function Target(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Target query. + * @member {google.firestore.v1.Target.IQueryTarget|null|undefined} query + * @memberof google.firestore.v1.Target + * @instance + */ + Target.prototype.query = null; + + /** + * Target documents. + * @member {google.firestore.v1.Target.IDocumentsTarget|null|undefined} documents + * @memberof google.firestore.v1.Target + * @instance + */ + Target.prototype.documents = null; + + /** + * Target resumeToken. + * @member {Uint8Array} resumeToken + * @memberof google.firestore.v1.Target + * @instance + */ + Target.prototype.resumeToken = $util.newBuffer([]); + + /** + * Target readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1.Target + * @instance + */ + Target.prototype.readTime = null; + + /** + * Target targetId. + * @member {number} targetId + * @memberof google.firestore.v1.Target + * @instance + */ + Target.prototype.targetId = 0; + + /** + * Target once. + * @member {boolean} once + * @memberof google.firestore.v1.Target + * @instance + */ + Target.prototype.once = false; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Target targetType. + * @member {"query"|"documents"|undefined} targetType + * @memberof google.firestore.v1.Target + * @instance + */ + Object.defineProperty(Target.prototype, "targetType", { + get: $util.oneOfGetter($oneOfFields = ["query", "documents"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Target resumeType. + * @member {"resumeToken"|"readTime"|undefined} resumeType + * @memberof google.firestore.v1.Target + * @instance + */ + Object.defineProperty(Target.prototype, "resumeType", { + get: $util.oneOfGetter($oneOfFields = ["resumeToken", "readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a Target message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.Target + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.Target} Target + */ + Target.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.Target) + return object; + var message = new $root.google.firestore.v1.Target(); + if (object.query != null) { + if (typeof object.query !== "object") + throw TypeError(".google.firestore.v1.Target.query: object expected"); + message.query = $root.google.firestore.v1.Target.QueryTarget.fromObject(object.query); + } + if (object.documents != null) { + if (typeof object.documents !== "object") + throw TypeError(".google.firestore.v1.Target.documents: object expected"); + message.documents = $root.google.firestore.v1.Target.DocumentsTarget.fromObject(object.documents); + } + if (object.resumeToken != null) + if (typeof object.resumeToken === "string") + $util.base64.decode(object.resumeToken, message.resumeToken = $util.newBuffer($util.base64.length(object.resumeToken)), 0); + else if (object.resumeToken.length) + message.resumeToken = object.resumeToken; + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1.Target.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + if (object.targetId != null) + message.targetId = object.targetId | 0; + if (object.once != null) + message.once = Boolean(object.once); + return message; + }; + + /** + * Creates a plain object from a Target message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.Target + * @static + * @param {google.firestore.v1.Target} message Target + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Target.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.targetId = 0; + object.once = false; + } + if (message.query != null && message.hasOwnProperty("query")) { + object.query = $root.google.firestore.v1.Target.QueryTarget.toObject(message.query, options); + if (options.oneofs) + object.targetType = "query"; + } + if (message.documents != null && message.hasOwnProperty("documents")) { + object.documents = $root.google.firestore.v1.Target.DocumentsTarget.toObject(message.documents, options); + if (options.oneofs) + object.targetType = "documents"; + } + if (message.resumeToken != null && message.hasOwnProperty("resumeToken")) { + object.resumeToken = options.bytes === String ? $util.base64.encode(message.resumeToken, 0, message.resumeToken.length) : options.bytes === Array ? Array.prototype.slice.call(message.resumeToken) : message.resumeToken; + if (options.oneofs) + object.resumeType = "resumeToken"; + } + if (message.targetId != null && message.hasOwnProperty("targetId")) + object.targetId = message.targetId; + if (message.once != null && message.hasOwnProperty("once")) + object.once = message.once; + if (message.readTime != null && message.hasOwnProperty("readTime")) { + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (options.oneofs) + object.resumeType = "readTime"; + } + return object; + }; + + /** + * Converts this Target to JSON. + * @function toJSON + * @memberof google.firestore.v1.Target + * @instance + * @returns {Object.} JSON object + */ + Target.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + Target.DocumentsTarget = (function() { + + /** + * Properties of a DocumentsTarget. + * @memberof google.firestore.v1.Target + * @interface IDocumentsTarget + * @property {Array.|null} [documents] DocumentsTarget documents + */ + + /** + * Constructs a new DocumentsTarget. + * @memberof google.firestore.v1.Target + * @classdesc Represents a DocumentsTarget. + * @implements IDocumentsTarget + * @constructor + * @param {google.firestore.v1.Target.IDocumentsTarget=} [properties] Properties to set + */ + function DocumentsTarget(properties) { + this.documents = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentsTarget documents. + * @member {Array.} documents + * @memberof google.firestore.v1.Target.DocumentsTarget + * @instance + */ + DocumentsTarget.prototype.documents = $util.emptyArray; + + /** + * Creates a DocumentsTarget message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.Target.DocumentsTarget + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.Target.DocumentsTarget} DocumentsTarget + */ + DocumentsTarget.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.Target.DocumentsTarget) + return object; + var message = new $root.google.firestore.v1.Target.DocumentsTarget(); + if (object.documents) { + if (!Array.isArray(object.documents)) + throw TypeError(".google.firestore.v1.Target.DocumentsTarget.documents: array expected"); + message.documents = []; + for (var i = 0; i < object.documents.length; ++i) + message.documents[i] = String(object.documents[i]); + } + return message; + }; + + /** + * Creates a plain object from a DocumentsTarget message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.Target.DocumentsTarget + * @static + * @param {google.firestore.v1.Target.DocumentsTarget} message DocumentsTarget + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentsTarget.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.documents = []; + if (message.documents && message.documents.length) { + object.documents = []; + for (var j = 0; j < message.documents.length; ++j) + object.documents[j] = message.documents[j]; + } + return object; + }; + + /** + * Converts this DocumentsTarget to JSON. + * @function toJSON + * @memberof google.firestore.v1.Target.DocumentsTarget + * @instance + * @returns {Object.} JSON object + */ + DocumentsTarget.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DocumentsTarget; + })(); + + Target.QueryTarget = (function() { + + /** + * Properties of a QueryTarget. + * @memberof google.firestore.v1.Target + * @interface IQueryTarget + * @property {string|null} [parent] QueryTarget parent + * @property {google.firestore.v1.IStructuredQuery|null} [structuredQuery] QueryTarget structuredQuery + */ + + /** + * Constructs a new QueryTarget. + * @memberof google.firestore.v1.Target + * @classdesc Represents a QueryTarget. + * @implements IQueryTarget + * @constructor + * @param {google.firestore.v1.Target.IQueryTarget=} [properties] Properties to set + */ + function QueryTarget(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * QueryTarget parent. + * @member {string} parent + * @memberof google.firestore.v1.Target.QueryTarget + * @instance + */ + QueryTarget.prototype.parent = ""; + + /** + * QueryTarget structuredQuery. + * @member {google.firestore.v1.IStructuredQuery|null|undefined} structuredQuery + * @memberof google.firestore.v1.Target.QueryTarget + * @instance + */ + QueryTarget.prototype.structuredQuery = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * QueryTarget queryType. + * @member {"structuredQuery"|undefined} queryType + * @memberof google.firestore.v1.Target.QueryTarget + * @instance + */ + Object.defineProperty(QueryTarget.prototype, "queryType", { + get: $util.oneOfGetter($oneOfFields = ["structuredQuery"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a QueryTarget message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.Target.QueryTarget + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.Target.QueryTarget} QueryTarget + */ + QueryTarget.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.Target.QueryTarget) + return object; + var message = new $root.google.firestore.v1.Target.QueryTarget(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.structuredQuery != null) { + if (typeof object.structuredQuery !== "object") + throw TypeError(".google.firestore.v1.Target.QueryTarget.structuredQuery: object expected"); + message.structuredQuery = $root.google.firestore.v1.StructuredQuery.fromObject(object.structuredQuery); + } + return message; + }; + + /** + * Creates a plain object from a QueryTarget message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.Target.QueryTarget + * @static + * @param {google.firestore.v1.Target.QueryTarget} message QueryTarget + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + QueryTarget.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.parent = ""; + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.structuredQuery != null && message.hasOwnProperty("structuredQuery")) { + object.structuredQuery = $root.google.firestore.v1.StructuredQuery.toObject(message.structuredQuery, options); + if (options.oneofs) + object.queryType = "structuredQuery"; + } + return object; + }; + + /** + * Converts this QueryTarget to JSON. + * @function toJSON + * @memberof google.firestore.v1.Target.QueryTarget + * @instance + * @returns {Object.} JSON object + */ + QueryTarget.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return QueryTarget; + })(); + + return Target; + })(); + + v1.TargetChange = (function() { + + /** + * Properties of a TargetChange. + * @memberof google.firestore.v1 + * @interface ITargetChange + * @property {google.firestore.v1.TargetChange.TargetChangeType|null} [targetChangeType] TargetChange targetChangeType + * @property {Array.|null} [targetIds] TargetChange targetIds + * @property {google.rpc.IStatus|null} [cause] TargetChange cause + * @property {Uint8Array|null} [resumeToken] TargetChange resumeToken + * @property {google.protobuf.ITimestamp|null} [readTime] TargetChange readTime + */ + + /** + * Constructs a new TargetChange. + * @memberof google.firestore.v1 + * @classdesc Represents a TargetChange. + * @implements ITargetChange + * @constructor + * @param {google.firestore.v1.ITargetChange=} [properties] Properties to set + */ + function TargetChange(properties) { + this.targetIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * TargetChange targetChangeType. + * @member {google.firestore.v1.TargetChange.TargetChangeType} targetChangeType + * @memberof google.firestore.v1.TargetChange + * @instance + */ + TargetChange.prototype.targetChangeType = 0; + + /** + * TargetChange targetIds. + * @member {Array.} targetIds + * @memberof google.firestore.v1.TargetChange + * @instance + */ + TargetChange.prototype.targetIds = $util.emptyArray; + + /** + * TargetChange cause. + * @member {google.rpc.IStatus|null|undefined} cause + * @memberof google.firestore.v1.TargetChange + * @instance + */ + TargetChange.prototype.cause = null; + + /** + * TargetChange resumeToken. + * @member {Uint8Array} resumeToken + * @memberof google.firestore.v1.TargetChange + * @instance + */ + TargetChange.prototype.resumeToken = $util.newBuffer([]); + + /** + * TargetChange readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1.TargetChange + * @instance + */ + TargetChange.prototype.readTime = null; + + /** + * Creates a TargetChange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.TargetChange + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.TargetChange} TargetChange + */ + TargetChange.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.TargetChange) + return object; + var message = new $root.google.firestore.v1.TargetChange(); + switch (object.targetChangeType) { + case "NO_CHANGE": + case 0: + message.targetChangeType = 0; + break; + case "ADD": + case 1: + message.targetChangeType = 1; + break; + case "REMOVE": + case 2: + message.targetChangeType = 2; + break; + case "CURRENT": + case 3: + message.targetChangeType = 3; + break; + case "RESET": + case 4: + message.targetChangeType = 4; + break; + } + if (object.targetIds) { + if (!Array.isArray(object.targetIds)) + throw TypeError(".google.firestore.v1.TargetChange.targetIds: array expected"); + message.targetIds = []; + for (var i = 0; i < object.targetIds.length; ++i) + message.targetIds[i] = object.targetIds[i] | 0; + } + if (object.cause != null) { + if (typeof object.cause !== "object") + throw TypeError(".google.firestore.v1.TargetChange.cause: object expected"); + message.cause = $root.google.rpc.Status.fromObject(object.cause); + } + if (object.resumeToken != null) + if (typeof object.resumeToken === "string") + $util.base64.decode(object.resumeToken, message.resumeToken = $util.newBuffer($util.base64.length(object.resumeToken)), 0); + else if (object.resumeToken.length) + message.resumeToken = object.resumeToken; + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1.TargetChange.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a TargetChange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.TargetChange + * @static + * @param {google.firestore.v1.TargetChange} message TargetChange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TargetChange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.targetIds = []; + if (options.defaults) { + object.targetChangeType = options.enums === String ? "NO_CHANGE" : 0; + object.cause = null; + if (options.bytes === String) + object.resumeToken = ""; + else { + object.resumeToken = []; + if (options.bytes !== Array) + object.resumeToken = $util.newBuffer(object.resumeToken); + } + object.readTime = null; + } + if (message.targetChangeType != null && message.hasOwnProperty("targetChangeType")) + object.targetChangeType = options.enums === String ? $root.google.firestore.v1.TargetChange.TargetChangeType[message.targetChangeType] : message.targetChangeType; + if (message.targetIds && message.targetIds.length) { + object.targetIds = []; + for (var j = 0; j < message.targetIds.length; ++j) + object.targetIds[j] = message.targetIds[j]; + } + if (message.cause != null && message.hasOwnProperty("cause")) + object.cause = $root.google.rpc.Status.toObject(message.cause, options); + if (message.resumeToken != null && message.hasOwnProperty("resumeToken")) + object.resumeToken = options.bytes === String ? $util.base64.encode(message.resumeToken, 0, message.resumeToken.length) : options.bytes === Array ? Array.prototype.slice.call(message.resumeToken) : message.resumeToken; + if (message.readTime != null && message.hasOwnProperty("readTime")) + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + return object; + }; + + /** + * Converts this TargetChange to JSON. + * @function toJSON + * @memberof google.firestore.v1.TargetChange + * @instance + * @returns {Object.} JSON object + */ + TargetChange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * TargetChangeType enum. + * @name google.firestore.v1.TargetChange.TargetChangeType + * @enum {string} + * @property {string} NO_CHANGE=NO_CHANGE NO_CHANGE value + * @property {string} ADD=ADD ADD value + * @property {string} REMOVE=REMOVE REMOVE value + * @property {string} CURRENT=CURRENT CURRENT value + * @property {string} RESET=RESET RESET value + */ + TargetChange.TargetChangeType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "NO_CHANGE"] = "NO_CHANGE"; + values[valuesById[1] = "ADD"] = "ADD"; + values[valuesById[2] = "REMOVE"] = "REMOVE"; + values[valuesById[3] = "CURRENT"] = "CURRENT"; + values[valuesById[4] = "RESET"] = "RESET"; + return values; + })(); + + return TargetChange; + })(); + + v1.ListCollectionIdsRequest = (function() { + + /** + * Properties of a ListCollectionIdsRequest. + * @memberof google.firestore.v1 + * @interface IListCollectionIdsRequest + * @property {string|null} [parent] ListCollectionIdsRequest parent + * @property {number|null} [pageSize] ListCollectionIdsRequest pageSize + * @property {string|null} [pageToken] ListCollectionIdsRequest pageToken + */ + + /** + * Constructs a new ListCollectionIdsRequest. + * @memberof google.firestore.v1 + * @classdesc Represents a ListCollectionIdsRequest. + * @implements IListCollectionIdsRequest + * @constructor + * @param {google.firestore.v1.IListCollectionIdsRequest=} [properties] Properties to set + */ + function ListCollectionIdsRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListCollectionIdsRequest parent. + * @member {string} parent + * @memberof google.firestore.v1.ListCollectionIdsRequest + * @instance + */ + ListCollectionIdsRequest.prototype.parent = ""; + + /** + * ListCollectionIdsRequest pageSize. + * @member {number} pageSize + * @memberof google.firestore.v1.ListCollectionIdsRequest + * @instance + */ + ListCollectionIdsRequest.prototype.pageSize = 0; + + /** + * ListCollectionIdsRequest pageToken. + * @member {string} pageToken + * @memberof google.firestore.v1.ListCollectionIdsRequest + * @instance + */ + ListCollectionIdsRequest.prototype.pageToken = ""; + + /** + * Creates a ListCollectionIdsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.ListCollectionIdsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.ListCollectionIdsRequest} ListCollectionIdsRequest + */ + ListCollectionIdsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.ListCollectionIdsRequest) + return object; + var message = new $root.google.firestore.v1.ListCollectionIdsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + return message; + }; + + /** + * Creates a plain object from a ListCollectionIdsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.ListCollectionIdsRequest + * @static + * @param {google.firestore.v1.ListCollectionIdsRequest} message ListCollectionIdsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListCollectionIdsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + return object; + }; + + /** + * Converts this ListCollectionIdsRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1.ListCollectionIdsRequest + * @instance + * @returns {Object.} JSON object + */ + ListCollectionIdsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListCollectionIdsRequest; + })(); + + v1.ListCollectionIdsResponse = (function() { + + /** + * Properties of a ListCollectionIdsResponse. + * @memberof google.firestore.v1 + * @interface IListCollectionIdsResponse + * @property {Array.|null} [collectionIds] ListCollectionIdsResponse collectionIds + * @property {string|null} [nextPageToken] ListCollectionIdsResponse nextPageToken + */ + + /** + * Constructs a new ListCollectionIdsResponse. + * @memberof google.firestore.v1 + * @classdesc Represents a ListCollectionIdsResponse. + * @implements IListCollectionIdsResponse + * @constructor + * @param {google.firestore.v1.IListCollectionIdsResponse=} [properties] Properties to set + */ + function ListCollectionIdsResponse(properties) { + this.collectionIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListCollectionIdsResponse collectionIds. + * @member {Array.} collectionIds + * @memberof google.firestore.v1.ListCollectionIdsResponse + * @instance + */ + ListCollectionIdsResponse.prototype.collectionIds = $util.emptyArray; + + /** + * ListCollectionIdsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.firestore.v1.ListCollectionIdsResponse + * @instance + */ + ListCollectionIdsResponse.prototype.nextPageToken = ""; + + /** + * Creates a ListCollectionIdsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.ListCollectionIdsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.ListCollectionIdsResponse} ListCollectionIdsResponse + */ + ListCollectionIdsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.ListCollectionIdsResponse) + return object; + var message = new $root.google.firestore.v1.ListCollectionIdsResponse(); + if (object.collectionIds) { + if (!Array.isArray(object.collectionIds)) + throw TypeError(".google.firestore.v1.ListCollectionIdsResponse.collectionIds: array expected"); + message.collectionIds = []; + for (var i = 0; i < object.collectionIds.length; ++i) + message.collectionIds[i] = String(object.collectionIds[i]); + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListCollectionIdsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.ListCollectionIdsResponse + * @static + * @param {google.firestore.v1.ListCollectionIdsResponse} message ListCollectionIdsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListCollectionIdsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.collectionIds = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.collectionIds && message.collectionIds.length) { + object.collectionIds = []; + for (var j = 0; j < message.collectionIds.length; ++j) + object.collectionIds[j] = message.collectionIds[j]; + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListCollectionIdsResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1.ListCollectionIdsResponse + * @instance + * @returns {Object.} JSON object + */ + ListCollectionIdsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListCollectionIdsResponse; + })(); + + v1.BatchWriteRequest = (function() { + + /** + * Properties of a BatchWriteRequest. + * @memberof google.firestore.v1 + * @interface IBatchWriteRequest + * @property {string|null} [database] BatchWriteRequest database + * @property {Array.|null} [writes] BatchWriteRequest writes + * @property {Object.|null} [labels] BatchWriteRequest labels + */ + + /** + * Constructs a new BatchWriteRequest. + * @memberof google.firestore.v1 + * @classdesc Represents a BatchWriteRequest. + * @implements IBatchWriteRequest + * @constructor + * @param {google.firestore.v1.IBatchWriteRequest=} [properties] Properties to set + */ + function BatchWriteRequest(properties) { + this.writes = []; + this.labels = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BatchWriteRequest database. + * @member {string} database + * @memberof google.firestore.v1.BatchWriteRequest + * @instance + */ + BatchWriteRequest.prototype.database = ""; + + /** + * BatchWriteRequest writes. + * @member {Array.} writes + * @memberof google.firestore.v1.BatchWriteRequest + * @instance + */ + BatchWriteRequest.prototype.writes = $util.emptyArray; + + /** + * BatchWriteRequest labels. + * @member {Object.} labels + * @memberof google.firestore.v1.BatchWriteRequest + * @instance + */ + BatchWriteRequest.prototype.labels = $util.emptyObject; + + /** + * Creates a BatchWriteRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.BatchWriteRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.BatchWriteRequest} BatchWriteRequest + */ + BatchWriteRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.BatchWriteRequest) + return object; + var message = new $root.google.firestore.v1.BatchWriteRequest(); + if (object.database != null) + message.database = String(object.database); + if (object.writes) { + if (!Array.isArray(object.writes)) + throw TypeError(".google.firestore.v1.BatchWriteRequest.writes: array expected"); + message.writes = []; + for (var i = 0; i < object.writes.length; ++i) { + if (typeof object.writes[i] !== "object") + throw TypeError(".google.firestore.v1.BatchWriteRequest.writes: object expected"); + message.writes[i] = $root.google.firestore.v1.Write.fromObject(object.writes[i]); + } + } + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.firestore.v1.BatchWriteRequest.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } + return message; + }; + + /** + * Creates a plain object from a BatchWriteRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.BatchWriteRequest + * @static + * @param {google.firestore.v1.BatchWriteRequest} message BatchWriteRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchWriteRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.writes = []; + if (options.objects || options.defaults) + object.labels = {}; + if (options.defaults) + object.database = ""; + if (message.database != null && message.hasOwnProperty("database")) + object.database = message.database; + if (message.writes && message.writes.length) { + object.writes = []; + for (var j = 0; j < message.writes.length; ++j) + object.writes[j] = $root.google.firestore.v1.Write.toObject(message.writes[j], options); + } + var keys2; + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } + return object; + }; + + /** + * Converts this BatchWriteRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1.BatchWriteRequest + * @instance + * @returns {Object.} JSON object + */ + BatchWriteRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BatchWriteRequest; + })(); + + v1.BatchWriteResponse = (function() { + + /** + * Properties of a BatchWriteResponse. + * @memberof google.firestore.v1 + * @interface IBatchWriteResponse + * @property {Array.|null} [writeResults] BatchWriteResponse writeResults + * @property {Array.|null} [status] BatchWriteResponse status + */ + + /** + * Constructs a new BatchWriteResponse. + * @memberof google.firestore.v1 + * @classdesc Represents a BatchWriteResponse. + * @implements IBatchWriteResponse + * @constructor + * @param {google.firestore.v1.IBatchWriteResponse=} [properties] Properties to set + */ + function BatchWriteResponse(properties) { + this.writeResults = []; + this.status = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BatchWriteResponse writeResults. + * @member {Array.} writeResults + * @memberof google.firestore.v1.BatchWriteResponse + * @instance + */ + BatchWriteResponse.prototype.writeResults = $util.emptyArray; + + /** + * BatchWriteResponse status. + * @member {Array.} status + * @memberof google.firestore.v1.BatchWriteResponse + * @instance + */ + BatchWriteResponse.prototype.status = $util.emptyArray; + + /** + * Creates a BatchWriteResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.BatchWriteResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.BatchWriteResponse} BatchWriteResponse + */ + BatchWriteResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.BatchWriteResponse) + return object; + var message = new $root.google.firestore.v1.BatchWriteResponse(); + if (object.writeResults) { + if (!Array.isArray(object.writeResults)) + throw TypeError(".google.firestore.v1.BatchWriteResponse.writeResults: array expected"); + message.writeResults = []; + for (var i = 0; i < object.writeResults.length; ++i) { + if (typeof object.writeResults[i] !== "object") + throw TypeError(".google.firestore.v1.BatchWriteResponse.writeResults: object expected"); + message.writeResults[i] = $root.google.firestore.v1.WriteResult.fromObject(object.writeResults[i]); + } + } + if (object.status) { + if (!Array.isArray(object.status)) + throw TypeError(".google.firestore.v1.BatchWriteResponse.status: array expected"); + message.status = []; + for (var i = 0; i < object.status.length; ++i) { + if (typeof object.status[i] !== "object") + throw TypeError(".google.firestore.v1.BatchWriteResponse.status: object expected"); + message.status[i] = $root.google.rpc.Status.fromObject(object.status[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a BatchWriteResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.BatchWriteResponse + * @static + * @param {google.firestore.v1.BatchWriteResponse} message BatchWriteResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchWriteResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.writeResults = []; + object.status = []; + } + if (message.writeResults && message.writeResults.length) { + object.writeResults = []; + for (var j = 0; j < message.writeResults.length; ++j) + object.writeResults[j] = $root.google.firestore.v1.WriteResult.toObject(message.writeResults[j], options); + } + if (message.status && message.status.length) { + object.status = []; + for (var j = 0; j < message.status.length; ++j) + object.status[j] = $root.google.rpc.Status.toObject(message.status[j], options); + } + return object; + }; + + /** + * Converts this BatchWriteResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1.BatchWriteResponse + * @instance + * @returns {Object.} JSON object + */ + BatchWriteResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BatchWriteResponse; + })(); + + v1.StructuredQuery = (function() { + + /** + * Properties of a StructuredQuery. + * @memberof google.firestore.v1 + * @interface IStructuredQuery + * @property {google.firestore.v1.StructuredQuery.IProjection|null} [select] StructuredQuery select + * @property {Array.|null} [from] StructuredQuery from + * @property {google.firestore.v1.StructuredQuery.IFilter|null} [where] StructuredQuery where + * @property {Array.|null} [orderBy] StructuredQuery orderBy + * @property {google.firestore.v1.ICursor|null} [startAt] StructuredQuery startAt + * @property {google.firestore.v1.ICursor|null} [endAt] StructuredQuery endAt + * @property {number|null} [offset] StructuredQuery offset + * @property {google.protobuf.IInt32Value|null} [limit] StructuredQuery limit + */ + + /** + * Constructs a new StructuredQuery. + * @memberof google.firestore.v1 + * @classdesc Represents a StructuredQuery. + * @implements IStructuredQuery + * @constructor + * @param {google.firestore.v1.IStructuredQuery=} [properties] Properties to set + */ + function StructuredQuery(properties) { + this.from = []; + this.orderBy = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StructuredQuery select. + * @member {google.firestore.v1.StructuredQuery.IProjection|null|undefined} select + * @memberof google.firestore.v1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.select = null; + + /** + * StructuredQuery from. + * @member {Array.} from + * @memberof google.firestore.v1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.from = $util.emptyArray; + + /** + * StructuredQuery where. + * @member {google.firestore.v1.StructuredQuery.IFilter|null|undefined} where + * @memberof google.firestore.v1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.where = null; + + /** + * StructuredQuery orderBy. + * @member {Array.} orderBy + * @memberof google.firestore.v1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.orderBy = $util.emptyArray; + + /** + * StructuredQuery startAt. + * @member {google.firestore.v1.ICursor|null|undefined} startAt + * @memberof google.firestore.v1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.startAt = null; + + /** + * StructuredQuery endAt. + * @member {google.firestore.v1.ICursor|null|undefined} endAt + * @memberof google.firestore.v1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.endAt = null; + + /** + * StructuredQuery offset. + * @member {number} offset + * @memberof google.firestore.v1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.offset = 0; + + /** + * StructuredQuery limit. + * @member {google.protobuf.IInt32Value|null|undefined} limit + * @memberof google.firestore.v1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.limit = null; + + /** + * Creates a StructuredQuery message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.StructuredQuery + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.StructuredQuery} StructuredQuery + */ + StructuredQuery.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.StructuredQuery) + return object; + var message = new $root.google.firestore.v1.StructuredQuery(); + if (object.select != null) { + if (typeof object.select !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.select: object expected"); + message.select = $root.google.firestore.v1.StructuredQuery.Projection.fromObject(object.select); + } + if (object.from) { + if (!Array.isArray(object.from)) + throw TypeError(".google.firestore.v1.StructuredQuery.from: array expected"); + message.from = []; + for (var i = 0; i < object.from.length; ++i) { + if (typeof object.from[i] !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.from: object expected"); + message.from[i] = $root.google.firestore.v1.StructuredQuery.CollectionSelector.fromObject(object.from[i]); + } + } + if (object.where != null) { + if (typeof object.where !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.where: object expected"); + message.where = $root.google.firestore.v1.StructuredQuery.Filter.fromObject(object.where); + } + if (object.orderBy) { + if (!Array.isArray(object.orderBy)) + throw TypeError(".google.firestore.v1.StructuredQuery.orderBy: array expected"); + message.orderBy = []; + for (var i = 0; i < object.orderBy.length; ++i) { + if (typeof object.orderBy[i] !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.orderBy: object expected"); + message.orderBy[i] = $root.google.firestore.v1.StructuredQuery.Order.fromObject(object.orderBy[i]); + } + } + if (object.startAt != null) { + if (typeof object.startAt !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.startAt: object expected"); + message.startAt = $root.google.firestore.v1.Cursor.fromObject(object.startAt); + } + if (object.endAt != null) { + if (typeof object.endAt !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.endAt: object expected"); + message.endAt = $root.google.firestore.v1.Cursor.fromObject(object.endAt); + } + if (object.offset != null) + message.offset = object.offset | 0; + if (object.limit != null) { + if (typeof object.limit !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.limit: object expected"); + message.limit = $root.google.protobuf.Int32Value.fromObject(object.limit); + } + return message; + }; + + /** + * Creates a plain object from a StructuredQuery message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.StructuredQuery + * @static + * @param {google.firestore.v1.StructuredQuery} message StructuredQuery + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StructuredQuery.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.from = []; + object.orderBy = []; + } + if (options.defaults) { + object.select = null; + object.where = null; + object.limit = null; + object.offset = 0; + object.startAt = null; + object.endAt = null; + } + if (message.select != null && message.hasOwnProperty("select")) + object.select = $root.google.firestore.v1.StructuredQuery.Projection.toObject(message.select, options); + if (message.from && message.from.length) { + object.from = []; + for (var j = 0; j < message.from.length; ++j) + object.from[j] = $root.google.firestore.v1.StructuredQuery.CollectionSelector.toObject(message.from[j], options); + } + if (message.where != null && message.hasOwnProperty("where")) + object.where = $root.google.firestore.v1.StructuredQuery.Filter.toObject(message.where, options); + if (message.orderBy && message.orderBy.length) { + object.orderBy = []; + for (var j = 0; j < message.orderBy.length; ++j) + object.orderBy[j] = $root.google.firestore.v1.StructuredQuery.Order.toObject(message.orderBy[j], options); + } + if (message.limit != null && message.hasOwnProperty("limit")) + object.limit = $root.google.protobuf.Int32Value.toObject(message.limit, options); + if (message.offset != null && message.hasOwnProperty("offset")) + object.offset = message.offset; + if (message.startAt != null && message.hasOwnProperty("startAt")) + object.startAt = $root.google.firestore.v1.Cursor.toObject(message.startAt, options); + if (message.endAt != null && message.hasOwnProperty("endAt")) + object.endAt = $root.google.firestore.v1.Cursor.toObject(message.endAt, options); + return object; + }; + + /** + * Converts this StructuredQuery to JSON. + * @function toJSON + * @memberof google.firestore.v1.StructuredQuery + * @instance + * @returns {Object.} JSON object + */ + StructuredQuery.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + StructuredQuery.CollectionSelector = (function() { + + /** + * Properties of a CollectionSelector. + * @memberof google.firestore.v1.StructuredQuery + * @interface ICollectionSelector + * @property {string|null} [collectionId] CollectionSelector collectionId + * @property {boolean|null} [allDescendants] CollectionSelector allDescendants + */ + + /** + * Constructs a new CollectionSelector. + * @memberof google.firestore.v1.StructuredQuery + * @classdesc Represents a CollectionSelector. + * @implements ICollectionSelector + * @constructor + * @param {google.firestore.v1.StructuredQuery.ICollectionSelector=} [properties] Properties to set + */ + function CollectionSelector(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CollectionSelector collectionId. + * @member {string} collectionId + * @memberof google.firestore.v1.StructuredQuery.CollectionSelector + * @instance + */ + CollectionSelector.prototype.collectionId = ""; + + /** + * CollectionSelector allDescendants. + * @member {boolean} allDescendants + * @memberof google.firestore.v1.StructuredQuery.CollectionSelector + * @instance + */ + CollectionSelector.prototype.allDescendants = false; + + /** + * Creates a CollectionSelector message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.StructuredQuery.CollectionSelector + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.StructuredQuery.CollectionSelector} CollectionSelector + */ + CollectionSelector.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.StructuredQuery.CollectionSelector) + return object; + var message = new $root.google.firestore.v1.StructuredQuery.CollectionSelector(); + if (object.collectionId != null) + message.collectionId = String(object.collectionId); + if (object.allDescendants != null) + message.allDescendants = Boolean(object.allDescendants); + return message; + }; + + /** + * Creates a plain object from a CollectionSelector message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.StructuredQuery.CollectionSelector + * @static + * @param {google.firestore.v1.StructuredQuery.CollectionSelector} message CollectionSelector + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CollectionSelector.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.collectionId = ""; + object.allDescendants = false; + } + if (message.collectionId != null && message.hasOwnProperty("collectionId")) + object.collectionId = message.collectionId; + if (message.allDescendants != null && message.hasOwnProperty("allDescendants")) + object.allDescendants = message.allDescendants; + return object; + }; + + /** + * Converts this CollectionSelector to JSON. + * @function toJSON + * @memberof google.firestore.v1.StructuredQuery.CollectionSelector + * @instance + * @returns {Object.} JSON object + */ + CollectionSelector.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CollectionSelector; + })(); + + StructuredQuery.Filter = (function() { + + /** + * Properties of a Filter. + * @memberof google.firestore.v1.StructuredQuery + * @interface IFilter + * @property {google.firestore.v1.StructuredQuery.ICompositeFilter|null} [compositeFilter] Filter compositeFilter + * @property {google.firestore.v1.StructuredQuery.IFieldFilter|null} [fieldFilter] Filter fieldFilter + * @property {google.firestore.v1.StructuredQuery.IUnaryFilter|null} [unaryFilter] Filter unaryFilter + */ + + /** + * Constructs a new Filter. + * @memberof google.firestore.v1.StructuredQuery + * @classdesc Represents a Filter. + * @implements IFilter + * @constructor + * @param {google.firestore.v1.StructuredQuery.IFilter=} [properties] Properties to set + */ + function Filter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Filter compositeFilter. + * @member {google.firestore.v1.StructuredQuery.ICompositeFilter|null|undefined} compositeFilter + * @memberof google.firestore.v1.StructuredQuery.Filter + * @instance + */ + Filter.prototype.compositeFilter = null; + + /** + * Filter fieldFilter. + * @member {google.firestore.v1.StructuredQuery.IFieldFilter|null|undefined} fieldFilter + * @memberof google.firestore.v1.StructuredQuery.Filter + * @instance + */ + Filter.prototype.fieldFilter = null; + + /** + * Filter unaryFilter. + * @member {google.firestore.v1.StructuredQuery.IUnaryFilter|null|undefined} unaryFilter + * @memberof google.firestore.v1.StructuredQuery.Filter + * @instance + */ + Filter.prototype.unaryFilter = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Filter filterType. + * @member {"compositeFilter"|"fieldFilter"|"unaryFilter"|undefined} filterType + * @memberof google.firestore.v1.StructuredQuery.Filter + * @instance + */ + Object.defineProperty(Filter.prototype, "filterType", { + get: $util.oneOfGetter($oneOfFields = ["compositeFilter", "fieldFilter", "unaryFilter"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a Filter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.StructuredQuery.Filter + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.StructuredQuery.Filter} Filter + */ + Filter.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.StructuredQuery.Filter) + return object; + var message = new $root.google.firestore.v1.StructuredQuery.Filter(); + if (object.compositeFilter != null) { + if (typeof object.compositeFilter !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.Filter.compositeFilter: object expected"); + message.compositeFilter = $root.google.firestore.v1.StructuredQuery.CompositeFilter.fromObject(object.compositeFilter); + } + if (object.fieldFilter != null) { + if (typeof object.fieldFilter !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.Filter.fieldFilter: object expected"); + message.fieldFilter = $root.google.firestore.v1.StructuredQuery.FieldFilter.fromObject(object.fieldFilter); + } + if (object.unaryFilter != null) { + if (typeof object.unaryFilter !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.Filter.unaryFilter: object expected"); + message.unaryFilter = $root.google.firestore.v1.StructuredQuery.UnaryFilter.fromObject(object.unaryFilter); + } + return message; + }; + + /** + * Creates a plain object from a Filter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.StructuredQuery.Filter + * @static + * @param {google.firestore.v1.StructuredQuery.Filter} message Filter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Filter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.compositeFilter != null && message.hasOwnProperty("compositeFilter")) { + object.compositeFilter = $root.google.firestore.v1.StructuredQuery.CompositeFilter.toObject(message.compositeFilter, options); + if (options.oneofs) + object.filterType = "compositeFilter"; + } + if (message.fieldFilter != null && message.hasOwnProperty("fieldFilter")) { + object.fieldFilter = $root.google.firestore.v1.StructuredQuery.FieldFilter.toObject(message.fieldFilter, options); + if (options.oneofs) + object.filterType = "fieldFilter"; + } + if (message.unaryFilter != null && message.hasOwnProperty("unaryFilter")) { + object.unaryFilter = $root.google.firestore.v1.StructuredQuery.UnaryFilter.toObject(message.unaryFilter, options); + if (options.oneofs) + object.filterType = "unaryFilter"; + } + return object; + }; + + /** + * Converts this Filter to JSON. + * @function toJSON + * @memberof google.firestore.v1.StructuredQuery.Filter + * @instance + * @returns {Object.} JSON object + */ + Filter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Filter; + })(); + + StructuredQuery.CompositeFilter = (function() { + + /** + * Properties of a CompositeFilter. + * @memberof google.firestore.v1.StructuredQuery + * @interface ICompositeFilter + * @property {google.firestore.v1.StructuredQuery.CompositeFilter.Operator|null} [op] CompositeFilter op + * @property {Array.|null} [filters] CompositeFilter filters + */ + + /** + * Constructs a new CompositeFilter. + * @memberof google.firestore.v1.StructuredQuery + * @classdesc Represents a CompositeFilter. + * @implements ICompositeFilter + * @constructor + * @param {google.firestore.v1.StructuredQuery.ICompositeFilter=} [properties] Properties to set + */ + function CompositeFilter(properties) { + this.filters = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CompositeFilter op. + * @member {google.firestore.v1.StructuredQuery.CompositeFilter.Operator} op + * @memberof google.firestore.v1.StructuredQuery.CompositeFilter + * @instance + */ + CompositeFilter.prototype.op = 0; + + /** + * CompositeFilter filters. + * @member {Array.} filters + * @memberof google.firestore.v1.StructuredQuery.CompositeFilter + * @instance + */ + CompositeFilter.prototype.filters = $util.emptyArray; + + /** + * Creates a CompositeFilter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.StructuredQuery.CompositeFilter + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.StructuredQuery.CompositeFilter} CompositeFilter + */ + CompositeFilter.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.StructuredQuery.CompositeFilter) + return object; + var message = new $root.google.firestore.v1.StructuredQuery.CompositeFilter(); + switch (object.op) { + case "OPERATOR_UNSPECIFIED": + case 0: + message.op = 0; + break; + case "AND": + case 1: + message.op = 1; + break; + } + if (object.filters) { + if (!Array.isArray(object.filters)) + throw TypeError(".google.firestore.v1.StructuredQuery.CompositeFilter.filters: array expected"); + message.filters = []; + for (var i = 0; i < object.filters.length; ++i) { + if (typeof object.filters[i] !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.CompositeFilter.filters: object expected"); + message.filters[i] = $root.google.firestore.v1.StructuredQuery.Filter.fromObject(object.filters[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a CompositeFilter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.StructuredQuery.CompositeFilter + * @static + * @param {google.firestore.v1.StructuredQuery.CompositeFilter} message CompositeFilter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompositeFilter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.filters = []; + if (options.defaults) + object.op = options.enums === String ? "OPERATOR_UNSPECIFIED" : 0; + if (message.op != null && message.hasOwnProperty("op")) + object.op = options.enums === String ? $root.google.firestore.v1.StructuredQuery.CompositeFilter.Operator[message.op] : message.op; + if (message.filters && message.filters.length) { + object.filters = []; + for (var j = 0; j < message.filters.length; ++j) + object.filters[j] = $root.google.firestore.v1.StructuredQuery.Filter.toObject(message.filters[j], options); + } + return object; + }; + + /** + * Converts this CompositeFilter to JSON. + * @function toJSON + * @memberof google.firestore.v1.StructuredQuery.CompositeFilter + * @instance + * @returns {Object.} JSON object + */ + CompositeFilter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Operator enum. + * @name google.firestore.v1.StructuredQuery.CompositeFilter.Operator + * @enum {string} + * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value + * @property {string} AND=AND AND value + */ + CompositeFilter.Operator = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; + values[valuesById[1] = "AND"] = "AND"; + return values; + })(); + + return CompositeFilter; + })(); + + StructuredQuery.FieldFilter = (function() { + + /** + * Properties of a FieldFilter. + * @memberof google.firestore.v1.StructuredQuery + * @interface IFieldFilter + * @property {google.firestore.v1.StructuredQuery.IFieldReference|null} [field] FieldFilter field + * @property {google.firestore.v1.StructuredQuery.FieldFilter.Operator|null} [op] FieldFilter op + * @property {google.firestore.v1.IValue|null} [value] FieldFilter value + */ + + /** + * Constructs a new FieldFilter. + * @memberof google.firestore.v1.StructuredQuery + * @classdesc Represents a FieldFilter. + * @implements IFieldFilter + * @constructor + * @param {google.firestore.v1.StructuredQuery.IFieldFilter=} [properties] Properties to set + */ + function FieldFilter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldFilter field. + * @member {google.firestore.v1.StructuredQuery.IFieldReference|null|undefined} field + * @memberof google.firestore.v1.StructuredQuery.FieldFilter + * @instance + */ + FieldFilter.prototype.field = null; + + /** + * FieldFilter op. + * @member {google.firestore.v1.StructuredQuery.FieldFilter.Operator} op + * @memberof google.firestore.v1.StructuredQuery.FieldFilter + * @instance + */ + FieldFilter.prototype.op = 0; + + /** + * FieldFilter value. + * @member {google.firestore.v1.IValue|null|undefined} value + * @memberof google.firestore.v1.StructuredQuery.FieldFilter + * @instance + */ + FieldFilter.prototype.value = null; + + /** + * Creates a FieldFilter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.StructuredQuery.FieldFilter + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.StructuredQuery.FieldFilter} FieldFilter + */ + FieldFilter.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.StructuredQuery.FieldFilter) + return object; + var message = new $root.google.firestore.v1.StructuredQuery.FieldFilter(); + if (object.field != null) { + if (typeof object.field !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.FieldFilter.field: object expected"); + message.field = $root.google.firestore.v1.StructuredQuery.FieldReference.fromObject(object.field); + } + switch (object.op) { + case "OPERATOR_UNSPECIFIED": + case 0: + message.op = 0; + break; + case "LESS_THAN": + case 1: + message.op = 1; + break; + case "LESS_THAN_OR_EQUAL": + case 2: + message.op = 2; + break; + case "GREATER_THAN": + case 3: + message.op = 3; + break; + case "GREATER_THAN_OR_EQUAL": + case 4: + message.op = 4; + break; + case "EQUAL": + case 5: + message.op = 5; + break; + case "ARRAY_CONTAINS": + case 7: + message.op = 7; + break; + case "IN": + case 8: + message.op = 8; + break; + case "ARRAY_CONTAINS_ANY": + case 9: + message.op = 9; + break; + } + if (object.value != null) { + if (typeof object.value !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.FieldFilter.value: object expected"); + message.value = $root.google.firestore.v1.Value.fromObject(object.value); + } + return message; + }; + + /** + * Creates a plain object from a FieldFilter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.StructuredQuery.FieldFilter + * @static + * @param {google.firestore.v1.StructuredQuery.FieldFilter} message FieldFilter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldFilter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.field = null; + object.op = options.enums === String ? "OPERATOR_UNSPECIFIED" : 0; + object.value = null; + } + if (message.field != null && message.hasOwnProperty("field")) + object.field = $root.google.firestore.v1.StructuredQuery.FieldReference.toObject(message.field, options); + if (message.op != null && message.hasOwnProperty("op")) + object.op = options.enums === String ? $root.google.firestore.v1.StructuredQuery.FieldFilter.Operator[message.op] : message.op; + if (message.value != null && message.hasOwnProperty("value")) + object.value = $root.google.firestore.v1.Value.toObject(message.value, options); + return object; + }; + + /** + * Converts this FieldFilter to JSON. + * @function toJSON + * @memberof google.firestore.v1.StructuredQuery.FieldFilter + * @instance + * @returns {Object.} JSON object + */ + FieldFilter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Operator enum. + * @name google.firestore.v1.StructuredQuery.FieldFilter.Operator + * @enum {string} + * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value + * @property {string} LESS_THAN=LESS_THAN LESS_THAN value + * @property {string} LESS_THAN_OR_EQUAL=LESS_THAN_OR_EQUAL LESS_THAN_OR_EQUAL value + * @property {string} GREATER_THAN=GREATER_THAN GREATER_THAN value + * @property {string} GREATER_THAN_OR_EQUAL=GREATER_THAN_OR_EQUAL GREATER_THAN_OR_EQUAL value + * @property {string} EQUAL=EQUAL EQUAL value + * @property {string} ARRAY_CONTAINS=ARRAY_CONTAINS ARRAY_CONTAINS value + * @property {string} IN=IN IN value + * @property {string} ARRAY_CONTAINS_ANY=ARRAY_CONTAINS_ANY ARRAY_CONTAINS_ANY value + */ + FieldFilter.Operator = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; + values[valuesById[1] = "LESS_THAN"] = "LESS_THAN"; + values[valuesById[2] = "LESS_THAN_OR_EQUAL"] = "LESS_THAN_OR_EQUAL"; + values[valuesById[3] = "GREATER_THAN"] = "GREATER_THAN"; + values[valuesById[4] = "GREATER_THAN_OR_EQUAL"] = "GREATER_THAN_OR_EQUAL"; + values[valuesById[5] = "EQUAL"] = "EQUAL"; + values[valuesById[7] = "ARRAY_CONTAINS"] = "ARRAY_CONTAINS"; + values[valuesById[8] = "IN"] = "IN"; + values[valuesById[9] = "ARRAY_CONTAINS_ANY"] = "ARRAY_CONTAINS_ANY"; + return values; + })(); + + return FieldFilter; + })(); + + StructuredQuery.UnaryFilter = (function() { + + /** + * Properties of an UnaryFilter. + * @memberof google.firestore.v1.StructuredQuery + * @interface IUnaryFilter + * @property {google.firestore.v1.StructuredQuery.UnaryFilter.Operator|null} [op] UnaryFilter op + * @property {google.firestore.v1.StructuredQuery.IFieldReference|null} [field] UnaryFilter field + */ + + /** + * Constructs a new UnaryFilter. + * @memberof google.firestore.v1.StructuredQuery + * @classdesc Represents an UnaryFilter. + * @implements IUnaryFilter + * @constructor + * @param {google.firestore.v1.StructuredQuery.IUnaryFilter=} [properties] Properties to set + */ + function UnaryFilter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UnaryFilter op. + * @member {google.firestore.v1.StructuredQuery.UnaryFilter.Operator} op + * @memberof google.firestore.v1.StructuredQuery.UnaryFilter + * @instance + */ + UnaryFilter.prototype.op = 0; + + /** + * UnaryFilter field. + * @member {google.firestore.v1.StructuredQuery.IFieldReference|null|undefined} field + * @memberof google.firestore.v1.StructuredQuery.UnaryFilter + * @instance + */ + UnaryFilter.prototype.field = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * UnaryFilter operandType. + * @member {"field"|undefined} operandType + * @memberof google.firestore.v1.StructuredQuery.UnaryFilter + * @instance + */ + Object.defineProperty(UnaryFilter.prototype, "operandType", { + get: $util.oneOfGetter($oneOfFields = ["field"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates an UnaryFilter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.StructuredQuery.UnaryFilter + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.StructuredQuery.UnaryFilter} UnaryFilter + */ + UnaryFilter.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.StructuredQuery.UnaryFilter) + return object; + var message = new $root.google.firestore.v1.StructuredQuery.UnaryFilter(); + switch (object.op) { + case "OPERATOR_UNSPECIFIED": + case 0: + message.op = 0; + break; + case "IS_NAN": + case 2: + message.op = 2; + break; + case "IS_NULL": + case 3: + message.op = 3; + break; + } + if (object.field != null) { + if (typeof object.field !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.UnaryFilter.field: object expected"); + message.field = $root.google.firestore.v1.StructuredQuery.FieldReference.fromObject(object.field); + } + return message; + }; + + /** + * Creates a plain object from an UnaryFilter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.StructuredQuery.UnaryFilter + * @static + * @param {google.firestore.v1.StructuredQuery.UnaryFilter} message UnaryFilter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UnaryFilter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.op = options.enums === String ? "OPERATOR_UNSPECIFIED" : 0; + if (message.op != null && message.hasOwnProperty("op")) + object.op = options.enums === String ? $root.google.firestore.v1.StructuredQuery.UnaryFilter.Operator[message.op] : message.op; + if (message.field != null && message.hasOwnProperty("field")) { + object.field = $root.google.firestore.v1.StructuredQuery.FieldReference.toObject(message.field, options); + if (options.oneofs) + object.operandType = "field"; + } + return object; + }; + + /** + * Converts this UnaryFilter to JSON. + * @function toJSON + * @memberof google.firestore.v1.StructuredQuery.UnaryFilter + * @instance + * @returns {Object.} JSON object + */ + UnaryFilter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Operator enum. + * @name google.firestore.v1.StructuredQuery.UnaryFilter.Operator + * @enum {string} + * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value + * @property {string} IS_NAN=IS_NAN IS_NAN value + * @property {string} IS_NULL=IS_NULL IS_NULL value + */ + UnaryFilter.Operator = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; + values[valuesById[2] = "IS_NAN"] = "IS_NAN"; + values[valuesById[3] = "IS_NULL"] = "IS_NULL"; + return values; + })(); + + return UnaryFilter; + })(); + + StructuredQuery.FieldReference = (function() { + + /** + * Properties of a FieldReference. + * @memberof google.firestore.v1.StructuredQuery + * @interface IFieldReference + * @property {string|null} [fieldPath] FieldReference fieldPath + */ + + /** + * Constructs a new FieldReference. + * @memberof google.firestore.v1.StructuredQuery + * @classdesc Represents a FieldReference. + * @implements IFieldReference + * @constructor + * @param {google.firestore.v1.StructuredQuery.IFieldReference=} [properties] Properties to set + */ + function FieldReference(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldReference fieldPath. + * @member {string} fieldPath + * @memberof google.firestore.v1.StructuredQuery.FieldReference + * @instance + */ + FieldReference.prototype.fieldPath = ""; + + /** + * Creates a FieldReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.StructuredQuery.FieldReference + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.StructuredQuery.FieldReference} FieldReference + */ + FieldReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.StructuredQuery.FieldReference) + return object; + var message = new $root.google.firestore.v1.StructuredQuery.FieldReference(); + if (object.fieldPath != null) + message.fieldPath = String(object.fieldPath); + return message; + }; + + /** + * Creates a plain object from a FieldReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.StructuredQuery.FieldReference + * @static + * @param {google.firestore.v1.StructuredQuery.FieldReference} message FieldReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.fieldPath = ""; + if (message.fieldPath != null && message.hasOwnProperty("fieldPath")) + object.fieldPath = message.fieldPath; + return object; + }; + + /** + * Converts this FieldReference to JSON. + * @function toJSON + * @memberof google.firestore.v1.StructuredQuery.FieldReference + * @instance + * @returns {Object.} JSON object + */ + FieldReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FieldReference; + })(); + + StructuredQuery.Order = (function() { + + /** + * Properties of an Order. + * @memberof google.firestore.v1.StructuredQuery + * @interface IOrder + * @property {google.firestore.v1.StructuredQuery.IFieldReference|null} [field] Order field + * @property {google.firestore.v1.StructuredQuery.Direction|null} [direction] Order direction + */ + + /** + * Constructs a new Order. + * @memberof google.firestore.v1.StructuredQuery + * @classdesc Represents an Order. + * @implements IOrder + * @constructor + * @param {google.firestore.v1.StructuredQuery.IOrder=} [properties] Properties to set + */ + function Order(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Order field. + * @member {google.firestore.v1.StructuredQuery.IFieldReference|null|undefined} field + * @memberof google.firestore.v1.StructuredQuery.Order + * @instance + */ + Order.prototype.field = null; + + /** + * Order direction. + * @member {google.firestore.v1.StructuredQuery.Direction} direction + * @memberof google.firestore.v1.StructuredQuery.Order + * @instance + */ + Order.prototype.direction = 0; + + /** + * Creates an Order message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.StructuredQuery.Order + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.StructuredQuery.Order} Order + */ + Order.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.StructuredQuery.Order) + return object; + var message = new $root.google.firestore.v1.StructuredQuery.Order(); + if (object.field != null) { + if (typeof object.field !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.Order.field: object expected"); + message.field = $root.google.firestore.v1.StructuredQuery.FieldReference.fromObject(object.field); + } + switch (object.direction) { + case "DIRECTION_UNSPECIFIED": + case 0: + message.direction = 0; + break; + case "ASCENDING": + case 1: + message.direction = 1; + break; + case "DESCENDING": + case 2: + message.direction = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.StructuredQuery.Order + * @static + * @param {google.firestore.v1.StructuredQuery.Order} message Order + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Order.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.field = null; + object.direction = options.enums === String ? "DIRECTION_UNSPECIFIED" : 0; + } + if (message.field != null && message.hasOwnProperty("field")) + object.field = $root.google.firestore.v1.StructuredQuery.FieldReference.toObject(message.field, options); + if (message.direction != null && message.hasOwnProperty("direction")) + object.direction = options.enums === String ? $root.google.firestore.v1.StructuredQuery.Direction[message.direction] : message.direction; + return object; + }; + + /** + * Converts this Order to JSON. + * @function toJSON + * @memberof google.firestore.v1.StructuredQuery.Order + * @instance + * @returns {Object.} JSON object + */ + Order.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Order; + })(); + + StructuredQuery.Projection = (function() { + + /** + * Properties of a Projection. + * @memberof google.firestore.v1.StructuredQuery + * @interface IProjection + * @property {Array.|null} [fields] Projection fields + */ + + /** + * Constructs a new Projection. + * @memberof google.firestore.v1.StructuredQuery + * @classdesc Represents a Projection. + * @implements IProjection + * @constructor + * @param {google.firestore.v1.StructuredQuery.IProjection=} [properties] Properties to set + */ + function Projection(properties) { + this.fields = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Projection fields. + * @member {Array.} fields + * @memberof google.firestore.v1.StructuredQuery.Projection + * @instance + */ + Projection.prototype.fields = $util.emptyArray; + + /** + * Creates a Projection message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.StructuredQuery.Projection + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.StructuredQuery.Projection} Projection + */ + Projection.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.StructuredQuery.Projection) + return object; + var message = new $root.google.firestore.v1.StructuredQuery.Projection(); + if (object.fields) { + if (!Array.isArray(object.fields)) + throw TypeError(".google.firestore.v1.StructuredQuery.Projection.fields: array expected"); + message.fields = []; + for (var i = 0; i < object.fields.length; ++i) { + if (typeof object.fields[i] !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.Projection.fields: object expected"); + message.fields[i] = $root.google.firestore.v1.StructuredQuery.FieldReference.fromObject(object.fields[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Projection message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.StructuredQuery.Projection + * @static + * @param {google.firestore.v1.StructuredQuery.Projection} message Projection + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Projection.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.fields = []; + if (message.fields && message.fields.length) { + object.fields = []; + for (var j = 0; j < message.fields.length; ++j) + object.fields[j] = $root.google.firestore.v1.StructuredQuery.FieldReference.toObject(message.fields[j], options); + } + return object; + }; + + /** + * Converts this Projection to JSON. + * @function toJSON + * @memberof google.firestore.v1.StructuredQuery.Projection + * @instance + * @returns {Object.} JSON object + */ + Projection.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Projection; + })(); + + /** + * Direction enum. + * @name google.firestore.v1.StructuredQuery.Direction + * @enum {string} + * @property {string} DIRECTION_UNSPECIFIED=DIRECTION_UNSPECIFIED DIRECTION_UNSPECIFIED value + * @property {string} ASCENDING=ASCENDING ASCENDING value + * @property {string} DESCENDING=DESCENDING DESCENDING value + */ + StructuredQuery.Direction = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DIRECTION_UNSPECIFIED"] = "DIRECTION_UNSPECIFIED"; + values[valuesById[1] = "ASCENDING"] = "ASCENDING"; + values[valuesById[2] = "DESCENDING"] = "DESCENDING"; + return values; + })(); + + return StructuredQuery; + })(); + + v1.Cursor = (function() { + + /** + * Properties of a Cursor. + * @memberof google.firestore.v1 + * @interface ICursor + * @property {Array.|null} [values] Cursor values + * @property {boolean|null} [before] Cursor before + */ + + /** + * Constructs a new Cursor. + * @memberof google.firestore.v1 + * @classdesc Represents a Cursor. + * @implements ICursor + * @constructor + * @param {google.firestore.v1.ICursor=} [properties] Properties to set + */ + function Cursor(properties) { + this.values = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Cursor values. + * @member {Array.} values + * @memberof google.firestore.v1.Cursor + * @instance + */ + Cursor.prototype.values = $util.emptyArray; + + /** + * Cursor before. + * @member {boolean} before + * @memberof google.firestore.v1.Cursor + * @instance + */ + Cursor.prototype.before = false; + + /** + * Creates a Cursor message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.Cursor + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.Cursor} Cursor + */ + Cursor.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.Cursor) + return object; + var message = new $root.google.firestore.v1.Cursor(); + if (object.values) { + if (!Array.isArray(object.values)) + throw TypeError(".google.firestore.v1.Cursor.values: array expected"); + message.values = []; + for (var i = 0; i < object.values.length; ++i) { + if (typeof object.values[i] !== "object") + throw TypeError(".google.firestore.v1.Cursor.values: object expected"); + message.values[i] = $root.google.firestore.v1.Value.fromObject(object.values[i]); + } + } + if (object.before != null) + message.before = Boolean(object.before); + return message; + }; + + /** + * Creates a plain object from a Cursor message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.Cursor + * @static + * @param {google.firestore.v1.Cursor} message Cursor + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Cursor.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.values = []; + if (options.defaults) + object.before = false; + if (message.values && message.values.length) { + object.values = []; + for (var j = 0; j < message.values.length; ++j) + object.values[j] = $root.google.firestore.v1.Value.toObject(message.values[j], options); + } + if (message.before != null && message.hasOwnProperty("before")) + object.before = message.before; + return object; + }; + + /** + * Converts this Cursor to JSON. + * @function toJSON + * @memberof google.firestore.v1.Cursor + * @instance + * @returns {Object.} JSON object + */ + Cursor.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Cursor; + })(); + + v1.Write = (function() { + + /** + * Properties of a Write. + * @memberof google.firestore.v1 + * @interface IWrite + * @property {google.firestore.v1.IDocument|null} [update] Write update + * @property {string|null} ["delete"] Write delete + * @property {google.firestore.v1.IDocumentTransform|null} [transform] Write transform + * @property {google.firestore.v1.IDocumentMask|null} [updateMask] Write updateMask + * @property {Array.|null} [updateTransforms] Write updateTransforms + * @property {google.firestore.v1.IPrecondition|null} [currentDocument] Write currentDocument + */ + + /** + * Constructs a new Write. + * @memberof google.firestore.v1 + * @classdesc Represents a Write. + * @implements IWrite + * @constructor + * @param {google.firestore.v1.IWrite=} [properties] Properties to set + */ + function Write(properties) { + this.updateTransforms = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Write update. + * @member {google.firestore.v1.IDocument|null|undefined} update + * @memberof google.firestore.v1.Write + * @instance + */ + Write.prototype.update = null; + + /** + * Write delete. + * @member {string} delete + * @memberof google.firestore.v1.Write + * @instance + */ + Write.prototype["delete"] = ""; + + /** + * Write transform. + * @member {google.firestore.v1.IDocumentTransform|null|undefined} transform + * @memberof google.firestore.v1.Write + * @instance + */ + Write.prototype.transform = null; + + /** + * Write updateMask. + * @member {google.firestore.v1.IDocumentMask|null|undefined} updateMask + * @memberof google.firestore.v1.Write + * @instance + */ + Write.prototype.updateMask = null; + + /** + * Write updateTransforms. + * @member {Array.} updateTransforms + * @memberof google.firestore.v1.Write + * @instance + */ + Write.prototype.updateTransforms = $util.emptyArray; + + /** + * Write currentDocument. + * @member {google.firestore.v1.IPrecondition|null|undefined} currentDocument + * @memberof google.firestore.v1.Write + * @instance + */ + Write.prototype.currentDocument = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Write operation. + * @member {"update"|"delete"|"transform"|undefined} operation + * @memberof google.firestore.v1.Write + * @instance + */ + Object.defineProperty(Write.prototype, "operation", { + get: $util.oneOfGetter($oneOfFields = ["update", "delete", "transform"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a Write message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.Write + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.Write} Write + */ + Write.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.Write) + return object; + var message = new $root.google.firestore.v1.Write(); + if (object.update != null) { + if (typeof object.update !== "object") + throw TypeError(".google.firestore.v1.Write.update: object expected"); + message.update = $root.google.firestore.v1.Document.fromObject(object.update); + } + if (object["delete"] != null) + message["delete"] = String(object["delete"]); + if (object.transform != null) { + if (typeof object.transform !== "object") + throw TypeError(".google.firestore.v1.Write.transform: object expected"); + message.transform = $root.google.firestore.v1.DocumentTransform.fromObject(object.transform); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.firestore.v1.Write.updateMask: object expected"); + message.updateMask = $root.google.firestore.v1.DocumentMask.fromObject(object.updateMask); + } + if (object.updateTransforms) { + if (!Array.isArray(object.updateTransforms)) + throw TypeError(".google.firestore.v1.Write.updateTransforms: array expected"); + message.updateTransforms = []; + for (var i = 0; i < object.updateTransforms.length; ++i) { + if (typeof object.updateTransforms[i] !== "object") + throw TypeError(".google.firestore.v1.Write.updateTransforms: object expected"); + message.updateTransforms[i] = $root.google.firestore.v1.DocumentTransform.FieldTransform.fromObject(object.updateTransforms[i]); + } + } + if (object.currentDocument != null) { + if (typeof object.currentDocument !== "object") + throw TypeError(".google.firestore.v1.Write.currentDocument: object expected"); + message.currentDocument = $root.google.firestore.v1.Precondition.fromObject(object.currentDocument); + } + return message; + }; + + /** + * Creates a plain object from a Write message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.Write + * @static + * @param {google.firestore.v1.Write} message Write + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Write.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.updateTransforms = []; + if (options.defaults) { + object.updateMask = null; + object.currentDocument = null; + } + if (message.update != null && message.hasOwnProperty("update")) { + object.update = $root.google.firestore.v1.Document.toObject(message.update, options); + if (options.oneofs) + object.operation = "update"; + } + if (message["delete"] != null && message.hasOwnProperty("delete")) { + object["delete"] = message["delete"]; + if (options.oneofs) + object.operation = "delete"; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.firestore.v1.DocumentMask.toObject(message.updateMask, options); + if (message.currentDocument != null && message.hasOwnProperty("currentDocument")) + object.currentDocument = $root.google.firestore.v1.Precondition.toObject(message.currentDocument, options); + if (message.transform != null && message.hasOwnProperty("transform")) { + object.transform = $root.google.firestore.v1.DocumentTransform.toObject(message.transform, options); + if (options.oneofs) + object.operation = "transform"; + } + if (message.updateTransforms && message.updateTransforms.length) { + object.updateTransforms = []; + for (var j = 0; j < message.updateTransforms.length; ++j) + object.updateTransforms[j] = $root.google.firestore.v1.DocumentTransform.FieldTransform.toObject(message.updateTransforms[j], options); + } + return object; + }; + + /** + * Converts this Write to JSON. + * @function toJSON + * @memberof google.firestore.v1.Write + * @instance + * @returns {Object.} JSON object + */ + Write.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Write; + })(); + + v1.DocumentTransform = (function() { + + /** + * Properties of a DocumentTransform. + * @memberof google.firestore.v1 + * @interface IDocumentTransform + * @property {string|null} [document] DocumentTransform document + * @property {Array.|null} [fieldTransforms] DocumentTransform fieldTransforms + */ + + /** + * Constructs a new DocumentTransform. + * @memberof google.firestore.v1 + * @classdesc Represents a DocumentTransform. + * @implements IDocumentTransform + * @constructor + * @param {google.firestore.v1.IDocumentTransform=} [properties] Properties to set + */ + function DocumentTransform(properties) { + this.fieldTransforms = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentTransform document. + * @member {string} document + * @memberof google.firestore.v1.DocumentTransform + * @instance + */ + DocumentTransform.prototype.document = ""; + + /** + * DocumentTransform fieldTransforms. + * @member {Array.} fieldTransforms + * @memberof google.firestore.v1.DocumentTransform + * @instance + */ + DocumentTransform.prototype.fieldTransforms = $util.emptyArray; + + /** + * Creates a DocumentTransform message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.DocumentTransform + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.DocumentTransform} DocumentTransform + */ + DocumentTransform.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.DocumentTransform) + return object; + var message = new $root.google.firestore.v1.DocumentTransform(); + if (object.document != null) + message.document = String(object.document); + if (object.fieldTransforms) { + if (!Array.isArray(object.fieldTransforms)) + throw TypeError(".google.firestore.v1.DocumentTransform.fieldTransforms: array expected"); + message.fieldTransforms = []; + for (var i = 0; i < object.fieldTransforms.length; ++i) { + if (typeof object.fieldTransforms[i] !== "object") + throw TypeError(".google.firestore.v1.DocumentTransform.fieldTransforms: object expected"); + message.fieldTransforms[i] = $root.google.firestore.v1.DocumentTransform.FieldTransform.fromObject(object.fieldTransforms[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a DocumentTransform message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.DocumentTransform + * @static + * @param {google.firestore.v1.DocumentTransform} message DocumentTransform + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentTransform.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.fieldTransforms = []; + if (options.defaults) + object.document = ""; + if (message.document != null && message.hasOwnProperty("document")) + object.document = message.document; + if (message.fieldTransforms && message.fieldTransforms.length) { + object.fieldTransforms = []; + for (var j = 0; j < message.fieldTransforms.length; ++j) + object.fieldTransforms[j] = $root.google.firestore.v1.DocumentTransform.FieldTransform.toObject(message.fieldTransforms[j], options); + } + return object; + }; + + /** + * Converts this DocumentTransform to JSON. + * @function toJSON + * @memberof google.firestore.v1.DocumentTransform + * @instance + * @returns {Object.} JSON object + */ + DocumentTransform.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + DocumentTransform.FieldTransform = (function() { + + /** + * Properties of a FieldTransform. + * @memberof google.firestore.v1.DocumentTransform + * @interface IFieldTransform + * @property {string|null} [fieldPath] FieldTransform fieldPath + * @property {google.firestore.v1.DocumentTransform.FieldTransform.ServerValue|null} [setToServerValue] FieldTransform setToServerValue + * @property {google.firestore.v1.IValue|null} [increment] FieldTransform increment + * @property {google.firestore.v1.IValue|null} [maximum] FieldTransform maximum + * @property {google.firestore.v1.IValue|null} [minimum] FieldTransform minimum + * @property {google.firestore.v1.IArrayValue|null} [appendMissingElements] FieldTransform appendMissingElements + * @property {google.firestore.v1.IArrayValue|null} [removeAllFromArray] FieldTransform removeAllFromArray + */ + + /** + * Constructs a new FieldTransform. + * @memberof google.firestore.v1.DocumentTransform + * @classdesc Represents a FieldTransform. + * @implements IFieldTransform + * @constructor + * @param {google.firestore.v1.DocumentTransform.IFieldTransform=} [properties] Properties to set + */ + function FieldTransform(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldTransform fieldPath. + * @member {string} fieldPath + * @memberof google.firestore.v1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.fieldPath = ""; + + /** + * FieldTransform setToServerValue. + * @member {google.firestore.v1.DocumentTransform.FieldTransform.ServerValue} setToServerValue + * @memberof google.firestore.v1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.setToServerValue = 0; + + /** + * FieldTransform increment. + * @member {google.firestore.v1.IValue|null|undefined} increment + * @memberof google.firestore.v1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.increment = null; + + /** + * FieldTransform maximum. + * @member {google.firestore.v1.IValue|null|undefined} maximum + * @memberof google.firestore.v1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.maximum = null; + + /** + * FieldTransform minimum. + * @member {google.firestore.v1.IValue|null|undefined} minimum + * @memberof google.firestore.v1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.minimum = null; + + /** + * FieldTransform appendMissingElements. + * @member {google.firestore.v1.IArrayValue|null|undefined} appendMissingElements + * @memberof google.firestore.v1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.appendMissingElements = null; + + /** + * FieldTransform removeAllFromArray. + * @member {google.firestore.v1.IArrayValue|null|undefined} removeAllFromArray + * @memberof google.firestore.v1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.removeAllFromArray = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * FieldTransform transformType. + * @member {"setToServerValue"|"increment"|"maximum"|"minimum"|"appendMissingElements"|"removeAllFromArray"|undefined} transformType + * @memberof google.firestore.v1.DocumentTransform.FieldTransform + * @instance + */ + Object.defineProperty(FieldTransform.prototype, "transformType", { + get: $util.oneOfGetter($oneOfFields = ["setToServerValue", "increment", "maximum", "minimum", "appendMissingElements", "removeAllFromArray"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a FieldTransform message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.DocumentTransform.FieldTransform + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.DocumentTransform.FieldTransform} FieldTransform + */ + FieldTransform.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.DocumentTransform.FieldTransform) + return object; + var message = new $root.google.firestore.v1.DocumentTransform.FieldTransform(); + if (object.fieldPath != null) + message.fieldPath = String(object.fieldPath); + switch (object.setToServerValue) { + case "SERVER_VALUE_UNSPECIFIED": + case 0: + message.setToServerValue = 0; + break; + case "REQUEST_TIME": + case 1: + message.setToServerValue = 1; + break; + } + if (object.increment != null) { + if (typeof object.increment !== "object") + throw TypeError(".google.firestore.v1.DocumentTransform.FieldTransform.increment: object expected"); + message.increment = $root.google.firestore.v1.Value.fromObject(object.increment); + } + if (object.maximum != null) { + if (typeof object.maximum !== "object") + throw TypeError(".google.firestore.v1.DocumentTransform.FieldTransform.maximum: object expected"); + message.maximum = $root.google.firestore.v1.Value.fromObject(object.maximum); + } + if (object.minimum != null) { + if (typeof object.minimum !== "object") + throw TypeError(".google.firestore.v1.DocumentTransform.FieldTransform.minimum: object expected"); + message.minimum = $root.google.firestore.v1.Value.fromObject(object.minimum); + } + if (object.appendMissingElements != null) { + if (typeof object.appendMissingElements !== "object") + throw TypeError(".google.firestore.v1.DocumentTransform.FieldTransform.appendMissingElements: object expected"); + message.appendMissingElements = $root.google.firestore.v1.ArrayValue.fromObject(object.appendMissingElements); + } + if (object.removeAllFromArray != null) { + if (typeof object.removeAllFromArray !== "object") + throw TypeError(".google.firestore.v1.DocumentTransform.FieldTransform.removeAllFromArray: object expected"); + message.removeAllFromArray = $root.google.firestore.v1.ArrayValue.fromObject(object.removeAllFromArray); + } + return message; + }; + + /** + * Creates a plain object from a FieldTransform message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.DocumentTransform.FieldTransform + * @static + * @param {google.firestore.v1.DocumentTransform.FieldTransform} message FieldTransform + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldTransform.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.fieldPath = ""; + if (message.fieldPath != null && message.hasOwnProperty("fieldPath")) + object.fieldPath = message.fieldPath; + if (message.setToServerValue != null && message.hasOwnProperty("setToServerValue")) { + object.setToServerValue = options.enums === String ? $root.google.firestore.v1.DocumentTransform.FieldTransform.ServerValue[message.setToServerValue] : message.setToServerValue; + if (options.oneofs) + object.transformType = "setToServerValue"; + } + if (message.increment != null && message.hasOwnProperty("increment")) { + object.increment = $root.google.firestore.v1.Value.toObject(message.increment, options); + if (options.oneofs) + object.transformType = "increment"; + } + if (message.maximum != null && message.hasOwnProperty("maximum")) { + object.maximum = $root.google.firestore.v1.Value.toObject(message.maximum, options); + if (options.oneofs) + object.transformType = "maximum"; + } + if (message.minimum != null && message.hasOwnProperty("minimum")) { + object.minimum = $root.google.firestore.v1.Value.toObject(message.minimum, options); + if (options.oneofs) + object.transformType = "minimum"; + } + if (message.appendMissingElements != null && message.hasOwnProperty("appendMissingElements")) { + object.appendMissingElements = $root.google.firestore.v1.ArrayValue.toObject(message.appendMissingElements, options); + if (options.oneofs) + object.transformType = "appendMissingElements"; + } + if (message.removeAllFromArray != null && message.hasOwnProperty("removeAllFromArray")) { + object.removeAllFromArray = $root.google.firestore.v1.ArrayValue.toObject(message.removeAllFromArray, options); + if (options.oneofs) + object.transformType = "removeAllFromArray"; + } + return object; + }; + + /** + * Converts this FieldTransform to JSON. + * @function toJSON + * @memberof google.firestore.v1.DocumentTransform.FieldTransform + * @instance + * @returns {Object.} JSON object + */ + FieldTransform.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * ServerValue enum. + * @name google.firestore.v1.DocumentTransform.FieldTransform.ServerValue + * @enum {string} + * @property {string} SERVER_VALUE_UNSPECIFIED=SERVER_VALUE_UNSPECIFIED SERVER_VALUE_UNSPECIFIED value + * @property {string} REQUEST_TIME=REQUEST_TIME REQUEST_TIME value + */ + FieldTransform.ServerValue = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SERVER_VALUE_UNSPECIFIED"] = "SERVER_VALUE_UNSPECIFIED"; + values[valuesById[1] = "REQUEST_TIME"] = "REQUEST_TIME"; + return values; + })(); + + return FieldTransform; + })(); + + return DocumentTransform; + })(); + + v1.WriteResult = (function() { + + /** + * Properties of a WriteResult. + * @memberof google.firestore.v1 + * @interface IWriteResult + * @property {google.protobuf.ITimestamp|null} [updateTime] WriteResult updateTime + * @property {Array.|null} [transformResults] WriteResult transformResults + */ + + /** + * Constructs a new WriteResult. + * @memberof google.firestore.v1 + * @classdesc Represents a WriteResult. + * @implements IWriteResult + * @constructor + * @param {google.firestore.v1.IWriteResult=} [properties] Properties to set + */ + function WriteResult(properties) { + this.transformResults = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WriteResult updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.firestore.v1.WriteResult + * @instance + */ + WriteResult.prototype.updateTime = null; + + /** + * WriteResult transformResults. + * @member {Array.} transformResults + * @memberof google.firestore.v1.WriteResult + * @instance + */ + WriteResult.prototype.transformResults = $util.emptyArray; + + /** + * Creates a WriteResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.WriteResult + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.WriteResult} WriteResult + */ + WriteResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.WriteResult) + return object; + var message = new $root.google.firestore.v1.WriteResult(); + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.firestore.v1.WriteResult.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.transformResults) { + if (!Array.isArray(object.transformResults)) + throw TypeError(".google.firestore.v1.WriteResult.transformResults: array expected"); + message.transformResults = []; + for (var i = 0; i < object.transformResults.length; ++i) { + if (typeof object.transformResults[i] !== "object") + throw TypeError(".google.firestore.v1.WriteResult.transformResults: object expected"); + message.transformResults[i] = $root.google.firestore.v1.Value.fromObject(object.transformResults[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a WriteResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.WriteResult + * @static + * @param {google.firestore.v1.WriteResult} message WriteResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WriteResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.transformResults = []; + if (options.defaults) + object.updateTime = null; + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.transformResults && message.transformResults.length) { + object.transformResults = []; + for (var j = 0; j < message.transformResults.length; ++j) + object.transformResults[j] = $root.google.firestore.v1.Value.toObject(message.transformResults[j], options); + } + return object; + }; + + /** + * Converts this WriteResult to JSON. + * @function toJSON + * @memberof google.firestore.v1.WriteResult + * @instance + * @returns {Object.} JSON object + */ + WriteResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return WriteResult; + })(); + + v1.DocumentChange = (function() { + + /** + * Properties of a DocumentChange. + * @memberof google.firestore.v1 + * @interface IDocumentChange + * @property {google.firestore.v1.IDocument|null} [document] DocumentChange document + * @property {Array.|null} [targetIds] DocumentChange targetIds + * @property {Array.|null} [removedTargetIds] DocumentChange removedTargetIds + */ + + /** + * Constructs a new DocumentChange. + * @memberof google.firestore.v1 + * @classdesc Represents a DocumentChange. + * @implements IDocumentChange + * @constructor + * @param {google.firestore.v1.IDocumentChange=} [properties] Properties to set + */ + function DocumentChange(properties) { + this.targetIds = []; + this.removedTargetIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentChange document. + * @member {google.firestore.v1.IDocument|null|undefined} document + * @memberof google.firestore.v1.DocumentChange + * @instance + */ + DocumentChange.prototype.document = null; + + /** + * DocumentChange targetIds. + * @member {Array.} targetIds + * @memberof google.firestore.v1.DocumentChange + * @instance + */ + DocumentChange.prototype.targetIds = $util.emptyArray; + + /** + * DocumentChange removedTargetIds. + * @member {Array.} removedTargetIds + * @memberof google.firestore.v1.DocumentChange + * @instance + */ + DocumentChange.prototype.removedTargetIds = $util.emptyArray; + + /** + * Creates a DocumentChange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.DocumentChange + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.DocumentChange} DocumentChange + */ + DocumentChange.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.DocumentChange) + return object; + var message = new $root.google.firestore.v1.DocumentChange(); + if (object.document != null) { + if (typeof object.document !== "object") + throw TypeError(".google.firestore.v1.DocumentChange.document: object expected"); + message.document = $root.google.firestore.v1.Document.fromObject(object.document); + } + if (object.targetIds) { + if (!Array.isArray(object.targetIds)) + throw TypeError(".google.firestore.v1.DocumentChange.targetIds: array expected"); + message.targetIds = []; + for (var i = 0; i < object.targetIds.length; ++i) + message.targetIds[i] = object.targetIds[i] | 0; + } + if (object.removedTargetIds) { + if (!Array.isArray(object.removedTargetIds)) + throw TypeError(".google.firestore.v1.DocumentChange.removedTargetIds: array expected"); + message.removedTargetIds = []; + for (var i = 0; i < object.removedTargetIds.length; ++i) + message.removedTargetIds[i] = object.removedTargetIds[i] | 0; + } + return message; + }; + + /** + * Creates a plain object from a DocumentChange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.DocumentChange + * @static + * @param {google.firestore.v1.DocumentChange} message DocumentChange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentChange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.targetIds = []; + object.removedTargetIds = []; + } + if (options.defaults) + object.document = null; + if (message.document != null && message.hasOwnProperty("document")) + object.document = $root.google.firestore.v1.Document.toObject(message.document, options); + if (message.targetIds && message.targetIds.length) { + object.targetIds = []; + for (var j = 0; j < message.targetIds.length; ++j) + object.targetIds[j] = message.targetIds[j]; + } + if (message.removedTargetIds && message.removedTargetIds.length) { + object.removedTargetIds = []; + for (var j = 0; j < message.removedTargetIds.length; ++j) + object.removedTargetIds[j] = message.removedTargetIds[j]; + } + return object; + }; + + /** + * Converts this DocumentChange to JSON. + * @function toJSON + * @memberof google.firestore.v1.DocumentChange + * @instance + * @returns {Object.} JSON object + */ + DocumentChange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DocumentChange; + })(); + + v1.DocumentDelete = (function() { + + /** + * Properties of a DocumentDelete. + * @memberof google.firestore.v1 + * @interface IDocumentDelete + * @property {string|null} [document] DocumentDelete document + * @property {Array.|null} [removedTargetIds] DocumentDelete removedTargetIds + * @property {google.protobuf.ITimestamp|null} [readTime] DocumentDelete readTime + */ + + /** + * Constructs a new DocumentDelete. + * @memberof google.firestore.v1 + * @classdesc Represents a DocumentDelete. + * @implements IDocumentDelete + * @constructor + * @param {google.firestore.v1.IDocumentDelete=} [properties] Properties to set + */ + function DocumentDelete(properties) { + this.removedTargetIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentDelete document. + * @member {string} document + * @memberof google.firestore.v1.DocumentDelete + * @instance + */ + DocumentDelete.prototype.document = ""; + + /** + * DocumentDelete removedTargetIds. + * @member {Array.} removedTargetIds + * @memberof google.firestore.v1.DocumentDelete + * @instance + */ + DocumentDelete.prototype.removedTargetIds = $util.emptyArray; + + /** + * DocumentDelete readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1.DocumentDelete + * @instance + */ + DocumentDelete.prototype.readTime = null; + + /** + * Creates a DocumentDelete message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.DocumentDelete + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.DocumentDelete} DocumentDelete + */ + DocumentDelete.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.DocumentDelete) + return object; + var message = new $root.google.firestore.v1.DocumentDelete(); + if (object.document != null) + message.document = String(object.document); + if (object.removedTargetIds) { + if (!Array.isArray(object.removedTargetIds)) + throw TypeError(".google.firestore.v1.DocumentDelete.removedTargetIds: array expected"); + message.removedTargetIds = []; + for (var i = 0; i < object.removedTargetIds.length; ++i) + message.removedTargetIds[i] = object.removedTargetIds[i] | 0; + } + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1.DocumentDelete.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a DocumentDelete message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.DocumentDelete + * @static + * @param {google.firestore.v1.DocumentDelete} message DocumentDelete + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentDelete.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.removedTargetIds = []; + if (options.defaults) { + object.document = ""; + object.readTime = null; + } + if (message.document != null && message.hasOwnProperty("document")) + object.document = message.document; + if (message.readTime != null && message.hasOwnProperty("readTime")) + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (message.removedTargetIds && message.removedTargetIds.length) { + object.removedTargetIds = []; + for (var j = 0; j < message.removedTargetIds.length; ++j) + object.removedTargetIds[j] = message.removedTargetIds[j]; + } + return object; + }; + + /** + * Converts this DocumentDelete to JSON. + * @function toJSON + * @memberof google.firestore.v1.DocumentDelete + * @instance + * @returns {Object.} JSON object + */ + DocumentDelete.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DocumentDelete; + })(); + + v1.DocumentRemove = (function() { + + /** + * Properties of a DocumentRemove. + * @memberof google.firestore.v1 + * @interface IDocumentRemove + * @property {string|null} [document] DocumentRemove document + * @property {Array.|null} [removedTargetIds] DocumentRemove removedTargetIds + * @property {google.protobuf.ITimestamp|null} [readTime] DocumentRemove readTime + */ + + /** + * Constructs a new DocumentRemove. + * @memberof google.firestore.v1 + * @classdesc Represents a DocumentRemove. + * @implements IDocumentRemove + * @constructor + * @param {google.firestore.v1.IDocumentRemove=} [properties] Properties to set + */ + function DocumentRemove(properties) { + this.removedTargetIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentRemove document. + * @member {string} document + * @memberof google.firestore.v1.DocumentRemove + * @instance + */ + DocumentRemove.prototype.document = ""; + + /** + * DocumentRemove removedTargetIds. + * @member {Array.} removedTargetIds + * @memberof google.firestore.v1.DocumentRemove + * @instance + */ + DocumentRemove.prototype.removedTargetIds = $util.emptyArray; + + /** + * DocumentRemove readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1.DocumentRemove + * @instance + */ + DocumentRemove.prototype.readTime = null; + + /** + * Creates a DocumentRemove message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.DocumentRemove + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.DocumentRemove} DocumentRemove + */ + DocumentRemove.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.DocumentRemove) + return object; + var message = new $root.google.firestore.v1.DocumentRemove(); + if (object.document != null) + message.document = String(object.document); + if (object.removedTargetIds) { + if (!Array.isArray(object.removedTargetIds)) + throw TypeError(".google.firestore.v1.DocumentRemove.removedTargetIds: array expected"); + message.removedTargetIds = []; + for (var i = 0; i < object.removedTargetIds.length; ++i) + message.removedTargetIds[i] = object.removedTargetIds[i] | 0; + } + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1.DocumentRemove.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a DocumentRemove message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.DocumentRemove + * @static + * @param {google.firestore.v1.DocumentRemove} message DocumentRemove + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentRemove.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.removedTargetIds = []; + if (options.defaults) { + object.document = ""; + object.readTime = null; + } + if (message.document != null && message.hasOwnProperty("document")) + object.document = message.document; + if (message.removedTargetIds && message.removedTargetIds.length) { + object.removedTargetIds = []; + for (var j = 0; j < message.removedTargetIds.length; ++j) + object.removedTargetIds[j] = message.removedTargetIds[j]; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + return object; + }; + + /** + * Converts this DocumentRemove to JSON. + * @function toJSON + * @memberof google.firestore.v1.DocumentRemove + * @instance + * @returns {Object.} JSON object + */ + DocumentRemove.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DocumentRemove; + })(); + + v1.ExistenceFilter = (function() { + + /** + * Properties of an ExistenceFilter. + * @memberof google.firestore.v1 + * @interface IExistenceFilter + * @property {number|null} [targetId] ExistenceFilter targetId + * @property {number|null} [count] ExistenceFilter count + */ + + /** + * Constructs a new ExistenceFilter. + * @memberof google.firestore.v1 + * @classdesc Represents an ExistenceFilter. + * @implements IExistenceFilter + * @constructor + * @param {google.firestore.v1.IExistenceFilter=} [properties] Properties to set + */ + function ExistenceFilter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExistenceFilter targetId. + * @member {number} targetId + * @memberof google.firestore.v1.ExistenceFilter + * @instance + */ + ExistenceFilter.prototype.targetId = 0; + + /** + * ExistenceFilter count. + * @member {number} count + * @memberof google.firestore.v1.ExistenceFilter + * @instance + */ + ExistenceFilter.prototype.count = 0; + + /** + * Creates an ExistenceFilter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.ExistenceFilter + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.ExistenceFilter} ExistenceFilter + */ + ExistenceFilter.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.ExistenceFilter) + return object; + var message = new $root.google.firestore.v1.ExistenceFilter(); + if (object.targetId != null) + message.targetId = object.targetId | 0; + if (object.count != null) + message.count = object.count | 0; + return message; + }; + + /** + * Creates a plain object from an ExistenceFilter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.ExistenceFilter + * @static + * @param {google.firestore.v1.ExistenceFilter} message ExistenceFilter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExistenceFilter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.targetId = 0; + object.count = 0; + } + if (message.targetId != null && message.hasOwnProperty("targetId")) + object.targetId = message.targetId; + if (message.count != null && message.hasOwnProperty("count")) + object.count = message.count; + return object; + }; + + /** + * Converts this ExistenceFilter to JSON. + * @function toJSON + * @memberof google.firestore.v1.ExistenceFilter + * @instance + * @returns {Object.} JSON object + */ + ExistenceFilter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ExistenceFilter; + })(); + + return v1; + })(); + + return firestore; })(); - - longrunning.DeleteOperationRequest = (function() { - - /** - * Properties of a DeleteOperationRequest. - * @memberof google.longrunning - * @interface IDeleteOperationRequest - * @property {string|null} [name] DeleteOperationRequest name - */ - - /** - * Constructs a new DeleteOperationRequest. - * @memberof google.longrunning - * @classdesc Represents a DeleteOperationRequest. - * @implements IDeleteOperationRequest - * @constructor - * @param {google.longrunning.IDeleteOperationRequest=} [properties] Properties to set - */ - function DeleteOperationRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - + + google.api = (function() { + /** - * DeleteOperationRequest name. - * @member {string} name - * @memberof google.longrunning.DeleteOperationRequest - * @instance + * Namespace api. + * @memberof google + * @namespace */ - DeleteOperationRequest.prototype.name = ""; - - return DeleteOperationRequest; + var api = {}; + + api.Http = (function() { + + /** + * Properties of a Http. + * @memberof google.api + * @interface IHttp + * @property {Array.|null} [rules] Http rules + */ + + /** + * Constructs a new Http. + * @memberof google.api + * @classdesc Represents a Http. + * @implements IHttp + * @constructor + * @param {google.api.IHttp=} [properties] Properties to set + */ + function Http(properties) { + this.rules = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Http rules. + * @member {Array.} rules + * @memberof google.api.Http + * @instance + */ + Http.prototype.rules = $util.emptyArray; + + /** + * Creates a Http message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.Http + * @static + * @param {Object.} object Plain object + * @returns {google.api.Http} Http + */ + Http.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.Http) + return object; + var message = new $root.google.api.Http(); + if (object.rules) { + if (!Array.isArray(object.rules)) + throw TypeError(".google.api.Http.rules: array expected"); + message.rules = []; + for (var i = 0; i < object.rules.length; ++i) { + if (typeof object.rules[i] !== "object") + throw TypeError(".google.api.Http.rules: object expected"); + message.rules[i] = $root.google.api.HttpRule.fromObject(object.rules[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Http message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.Http + * @static + * @param {google.api.Http} message Http + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Http.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.rules = []; + if (message.rules && message.rules.length) { + object.rules = []; + for (var j = 0; j < message.rules.length; ++j) + object.rules[j] = $root.google.api.HttpRule.toObject(message.rules[j], options); + } + return object; + }; + + /** + * Converts this Http to JSON. + * @function toJSON + * @memberof google.api.Http + * @instance + * @returns {Object.} JSON object + */ + Http.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Http; + })(); + + api.HttpRule = (function() { + + /** + * Properties of a HttpRule. + * @memberof google.api + * @interface IHttpRule + * @property {string|null} [get] HttpRule get + * @property {string|null} [put] HttpRule put + * @property {string|null} [post] HttpRule post + * @property {string|null} ["delete"] HttpRule delete + * @property {string|null} [patch] HttpRule patch + * @property {google.api.ICustomHttpPattern|null} [custom] HttpRule custom + * @property {string|null} [selector] HttpRule selector + * @property {string|null} [body] HttpRule body + * @property {Array.|null} [additionalBindings] HttpRule additionalBindings + */ + + /** + * Constructs a new HttpRule. + * @memberof google.api + * @classdesc Represents a HttpRule. + * @implements IHttpRule + * @constructor + * @param {google.api.IHttpRule=} [properties] Properties to set + */ + function HttpRule(properties) { + this.additionalBindings = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * HttpRule get. + * @member {string} get + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.get = ""; + + /** + * HttpRule put. + * @member {string} put + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.put = ""; + + /** + * HttpRule post. + * @member {string} post + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.post = ""; + + /** + * HttpRule delete. + * @member {string} delete + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype["delete"] = ""; + + /** + * HttpRule patch. + * @member {string} patch + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.patch = ""; + + /** + * HttpRule custom. + * @member {google.api.ICustomHttpPattern|null|undefined} custom + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.custom = null; + + /** + * HttpRule selector. + * @member {string} selector + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.selector = ""; + + /** + * HttpRule body. + * @member {string} body + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.body = ""; + + /** + * HttpRule additionalBindings. + * @member {Array.} additionalBindings + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.additionalBindings = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * HttpRule pattern. + * @member {"get"|"put"|"post"|"delete"|"patch"|"custom"|undefined} pattern + * @memberof google.api.HttpRule + * @instance + */ + Object.defineProperty(HttpRule.prototype, "pattern", { + get: $util.oneOfGetter($oneOfFields = ["get", "put", "post", "delete", "patch", "custom"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a HttpRule message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.HttpRule + * @static + * @param {Object.} object Plain object + * @returns {google.api.HttpRule} HttpRule + */ + HttpRule.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.HttpRule) + return object; + var message = new $root.google.api.HttpRule(); + if (object.get != null) + message.get = String(object.get); + if (object.put != null) + message.put = String(object.put); + if (object.post != null) + message.post = String(object.post); + if (object["delete"] != null) + message["delete"] = String(object["delete"]); + if (object.patch != null) + message.patch = String(object.patch); + if (object.custom != null) { + if (typeof object.custom !== "object") + throw TypeError(".google.api.HttpRule.custom: object expected"); + message.custom = $root.google.api.CustomHttpPattern.fromObject(object.custom); + } + if (object.selector != null) + message.selector = String(object.selector); + if (object.body != null) + message.body = String(object.body); + if (object.additionalBindings) { + if (!Array.isArray(object.additionalBindings)) + throw TypeError(".google.api.HttpRule.additionalBindings: array expected"); + message.additionalBindings = []; + for (var i = 0; i < object.additionalBindings.length; ++i) { + if (typeof object.additionalBindings[i] !== "object") + throw TypeError(".google.api.HttpRule.additionalBindings: object expected"); + message.additionalBindings[i] = $root.google.api.HttpRule.fromObject(object.additionalBindings[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a HttpRule message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.HttpRule + * @static + * @param {google.api.HttpRule} message HttpRule + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HttpRule.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.additionalBindings = []; + if (options.defaults) { + object.selector = ""; + object.body = ""; + } + if (message.selector != null && message.hasOwnProperty("selector")) + object.selector = message.selector; + if (message.get != null && message.hasOwnProperty("get")) { + object.get = message.get; + if (options.oneofs) + object.pattern = "get"; + } + if (message.put != null && message.hasOwnProperty("put")) { + object.put = message.put; + if (options.oneofs) + object.pattern = "put"; + } + if (message.post != null && message.hasOwnProperty("post")) { + object.post = message.post; + if (options.oneofs) + object.pattern = "post"; + } + if (message["delete"] != null && message.hasOwnProperty("delete")) { + object["delete"] = message["delete"]; + if (options.oneofs) + object.pattern = "delete"; + } + if (message.patch != null && message.hasOwnProperty("patch")) { + object.patch = message.patch; + if (options.oneofs) + object.pattern = "patch"; + } + if (message.body != null && message.hasOwnProperty("body")) + object.body = message.body; + if (message.custom != null && message.hasOwnProperty("custom")) { + object.custom = $root.google.api.CustomHttpPattern.toObject(message.custom, options); + if (options.oneofs) + object.pattern = "custom"; + } + if (message.additionalBindings && message.additionalBindings.length) { + object.additionalBindings = []; + for (var j = 0; j < message.additionalBindings.length; ++j) + object.additionalBindings[j] = $root.google.api.HttpRule.toObject(message.additionalBindings[j], options); + } + return object; + }; + + /** + * Converts this HttpRule to JSON. + * @function toJSON + * @memberof google.api.HttpRule + * @instance + * @returns {Object.} JSON object + */ + HttpRule.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return HttpRule; + })(); + + api.CustomHttpPattern = (function() { + + /** + * Properties of a CustomHttpPattern. + * @memberof google.api + * @interface ICustomHttpPattern + * @property {string|null} [kind] CustomHttpPattern kind + * @property {string|null} [path] CustomHttpPattern path + */ + + /** + * Constructs a new CustomHttpPattern. + * @memberof google.api + * @classdesc Represents a CustomHttpPattern. + * @implements ICustomHttpPattern + * @constructor + * @param {google.api.ICustomHttpPattern=} [properties] Properties to set + */ + function CustomHttpPattern(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CustomHttpPattern kind. + * @member {string} kind + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.kind = ""; + + /** + * CustomHttpPattern path. + * @member {string} path + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.path = ""; + + /** + * Creates a CustomHttpPattern message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.CustomHttpPattern + * @static + * @param {Object.} object Plain object + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + */ + CustomHttpPattern.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.CustomHttpPattern) + return object; + var message = new $root.google.api.CustomHttpPattern(); + if (object.kind != null) + message.kind = String(object.kind); + if (object.path != null) + message.path = String(object.path); + return message; + }; + + /** + * Creates a plain object from a CustomHttpPattern message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.CustomHttpPattern} message CustomHttpPattern + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CustomHttpPattern.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.kind = ""; + object.path = ""; + } + if (message.kind != null && message.hasOwnProperty("kind")) + object.kind = message.kind; + if (message.path != null && message.hasOwnProperty("path")) + object.path = message.path; + return object; + }; + + /** + * Converts this CustomHttpPattern to JSON. + * @function toJSON + * @memberof google.api.CustomHttpPattern + * @instance + * @returns {Object.} JSON object + */ + CustomHttpPattern.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CustomHttpPattern; + })(); + + /** + * FieldBehavior enum. + * @name google.api.FieldBehavior + * @enum {string} + * @property {string} FIELD_BEHAVIOR_UNSPECIFIED=FIELD_BEHAVIOR_UNSPECIFIED FIELD_BEHAVIOR_UNSPECIFIED value + * @property {string} OPTIONAL=OPTIONAL OPTIONAL value + * @property {string} REQUIRED=REQUIRED REQUIRED value + * @property {string} OUTPUT_ONLY=OUTPUT_ONLY OUTPUT_ONLY value + * @property {string} INPUT_ONLY=INPUT_ONLY INPUT_ONLY value + * @property {string} IMMUTABLE=IMMUTABLE IMMUTABLE value + */ + api.FieldBehavior = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "FIELD_BEHAVIOR_UNSPECIFIED"] = "FIELD_BEHAVIOR_UNSPECIFIED"; + values[valuesById[1] = "OPTIONAL"] = "OPTIONAL"; + values[valuesById[2] = "REQUIRED"] = "REQUIRED"; + values[valuesById[3] = "OUTPUT_ONLY"] = "OUTPUT_ONLY"; + values[valuesById[4] = "INPUT_ONLY"] = "INPUT_ONLY"; + values[valuesById[5] = "IMMUTABLE"] = "IMMUTABLE"; + return values; + })(); + + api.ResourceDescriptor = (function() { + + /** + * Properties of a ResourceDescriptor. + * @memberof google.api + * @interface IResourceDescriptor + * @property {string|null} [type] ResourceDescriptor type + * @property {Array.|null} [pattern] ResourceDescriptor pattern + * @property {string|null} [nameField] ResourceDescriptor nameField + * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history + * @property {string|null} [plural] ResourceDescriptor plural + * @property {string|null} [singular] ResourceDescriptor singular + */ + + /** + * Constructs a new ResourceDescriptor. + * @memberof google.api + * @classdesc Represents a ResourceDescriptor. + * @implements IResourceDescriptor + * @constructor + * @param {google.api.IResourceDescriptor=} [properties] Properties to set + */ + function ResourceDescriptor(properties) { + this.pattern = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResourceDescriptor type. + * @member {string} type + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.type = ""; + + /** + * ResourceDescriptor pattern. + * @member {Array.} pattern + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.pattern = $util.emptyArray; + + /** + * ResourceDescriptor nameField. + * @member {string} nameField + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.nameField = ""; + + /** + * ResourceDescriptor history. + * @member {google.api.ResourceDescriptor.History} history + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.history = 0; + + /** + * ResourceDescriptor plural. + * @member {string} plural + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.plural = ""; + + /** + * ResourceDescriptor singular. + * @member {string} singular + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.singular = ""; + + /** + * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.ResourceDescriptor + * @static + * @param {Object.} object Plain object + * @returns {google.api.ResourceDescriptor} ResourceDescriptor + */ + ResourceDescriptor.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.ResourceDescriptor) + return object; + var message = new $root.google.api.ResourceDescriptor(); + if (object.type != null) + message.type = String(object.type); + if (object.pattern) { + if (!Array.isArray(object.pattern)) + throw TypeError(".google.api.ResourceDescriptor.pattern: array expected"); + message.pattern = []; + for (var i = 0; i < object.pattern.length; ++i) + message.pattern[i] = String(object.pattern[i]); + } + if (object.nameField != null) + message.nameField = String(object.nameField); + switch (object.history) { + case "HISTORY_UNSPECIFIED": + case 0: + message.history = 0; + break; + case "ORIGINALLY_SINGLE_PATTERN": + case 1: + message.history = 1; + break; + case "FUTURE_MULTI_PATTERN": + case 2: + message.history = 2; + break; + } + if (object.plural != null) + message.plural = String(object.plural); + if (object.singular != null) + message.singular = String(object.singular); + return message; + }; + + /** + * Creates a plain object from a ResourceDescriptor message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.ResourceDescriptor + * @static + * @param {google.api.ResourceDescriptor} message ResourceDescriptor + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResourceDescriptor.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.pattern = []; + if (options.defaults) { + object.type = ""; + object.nameField = ""; + object.history = options.enums === String ? "HISTORY_UNSPECIFIED" : 0; + object.plural = ""; + object.singular = ""; + } + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.pattern && message.pattern.length) { + object.pattern = []; + for (var j = 0; j < message.pattern.length; ++j) + object.pattern[j] = message.pattern[j]; + } + if (message.nameField != null && message.hasOwnProperty("nameField")) + object.nameField = message.nameField; + if (message.history != null && message.hasOwnProperty("history")) + object.history = options.enums === String ? $root.google.api.ResourceDescriptor.History[message.history] : message.history; + if (message.plural != null && message.hasOwnProperty("plural")) + object.plural = message.plural; + if (message.singular != null && message.hasOwnProperty("singular")) + object.singular = message.singular; + return object; + }; + + /** + * Converts this ResourceDescriptor to JSON. + * @function toJSON + * @memberof google.api.ResourceDescriptor + * @instance + * @returns {Object.} JSON object + */ + ResourceDescriptor.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * History enum. + * @name google.api.ResourceDescriptor.History + * @enum {string} + * @property {string} HISTORY_UNSPECIFIED=HISTORY_UNSPECIFIED HISTORY_UNSPECIFIED value + * @property {string} ORIGINALLY_SINGLE_PATTERN=ORIGINALLY_SINGLE_PATTERN ORIGINALLY_SINGLE_PATTERN value + * @property {string} FUTURE_MULTI_PATTERN=FUTURE_MULTI_PATTERN FUTURE_MULTI_PATTERN value + */ + ResourceDescriptor.History = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "HISTORY_UNSPECIFIED"] = "HISTORY_UNSPECIFIED"; + values[valuesById[1] = "ORIGINALLY_SINGLE_PATTERN"] = "ORIGINALLY_SINGLE_PATTERN"; + values[valuesById[2] = "FUTURE_MULTI_PATTERN"] = "FUTURE_MULTI_PATTERN"; + return values; + })(); + + return ResourceDescriptor; + })(); + + api.ResourceReference = (function() { + + /** + * Properties of a ResourceReference. + * @memberof google.api + * @interface IResourceReference + * @property {string|null} [type] ResourceReference type + * @property {string|null} [childType] ResourceReference childType + */ + + /** + * Constructs a new ResourceReference. + * @memberof google.api + * @classdesc Represents a ResourceReference. + * @implements IResourceReference + * @constructor + * @param {google.api.IResourceReference=} [properties] Properties to set + */ + function ResourceReference(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResourceReference type. + * @member {string} type + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.type = ""; + + /** + * ResourceReference childType. + * @member {string} childType + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.childType = ""; + + /** + * Creates a ResourceReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.ResourceReference + * @static + * @param {Object.} object Plain object + * @returns {google.api.ResourceReference} ResourceReference + */ + ResourceReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.ResourceReference) + return object; + var message = new $root.google.api.ResourceReference(); + if (object.type != null) + message.type = String(object.type); + if (object.childType != null) + message.childType = String(object.childType); + return message; + }; + + /** + * Creates a plain object from a ResourceReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.ResourceReference + * @static + * @param {google.api.ResourceReference} message ResourceReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResourceReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.type = ""; + object.childType = ""; + } + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.childType != null && message.hasOwnProperty("childType")) + object.childType = message.childType; + return object; + }; + + /** + * Converts this ResourceReference to JSON. + * @function toJSON + * @memberof google.api.ResourceReference + * @instance + * @returns {Object.} JSON object + */ + ResourceReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ResourceReference; + })(); + + return api; })(); - - longrunning.WaitOperationRequest = (function() { - - /** - * Properties of a WaitOperationRequest. - * @memberof google.longrunning - * @interface IWaitOperationRequest - * @property {string|null} [name] WaitOperationRequest name - * @property {google.protobuf.IDuration|null} [timeout] WaitOperationRequest timeout - */ - + + google.type = (function() { + /** - * Constructs a new WaitOperationRequest. - * @memberof google.longrunning - * @classdesc Represents a WaitOperationRequest. - * @implements IWaitOperationRequest - * @constructor - * @param {google.longrunning.IWaitOperationRequest=} [properties] Properties to set - */ - function WaitOperationRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * WaitOperationRequest name. - * @member {string} name - * @memberof google.longrunning.WaitOperationRequest - * @instance - */ - WaitOperationRequest.prototype.name = ""; - - /** - * WaitOperationRequest timeout. - * @member {google.protobuf.IDuration|null|undefined} timeout - * @memberof google.longrunning.WaitOperationRequest - * @instance + * Namespace type. + * @memberof google + * @namespace */ - WaitOperationRequest.prototype.timeout = null; - - return WaitOperationRequest; + var type = {}; + + type.LatLng = (function() { + + /** + * Properties of a LatLng. + * @memberof google.type + * @interface ILatLng + * @property {number|null} [latitude] LatLng latitude + * @property {number|null} [longitude] LatLng longitude + */ + + /** + * Constructs a new LatLng. + * @memberof google.type + * @classdesc Represents a LatLng. + * @implements ILatLng + * @constructor + * @param {google.type.ILatLng=} [properties] Properties to set + */ + function LatLng(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LatLng latitude. + * @member {number} latitude + * @memberof google.type.LatLng + * @instance + */ + LatLng.prototype.latitude = 0; + + /** + * LatLng longitude. + * @member {number} longitude + * @memberof google.type.LatLng + * @instance + */ + LatLng.prototype.longitude = 0; + + /** + * Creates a LatLng message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.type.LatLng + * @static + * @param {Object.} object Plain object + * @returns {google.type.LatLng} LatLng + */ + LatLng.fromObject = function fromObject(object) { + if (object instanceof $root.google.type.LatLng) + return object; + var message = new $root.google.type.LatLng(); + if (object.latitude != null) + message.latitude = Number(object.latitude); + if (object.longitude != null) + message.longitude = Number(object.longitude); + return message; + }; + + /** + * Creates a plain object from a LatLng message. Also converts values to other types if specified. + * @function toObject + * @memberof google.type.LatLng + * @static + * @param {google.type.LatLng} message LatLng + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LatLng.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.latitude = 0; + object.longitude = 0; + } + if (message.latitude != null && message.hasOwnProperty("latitude")) + object.latitude = options.json && !isFinite(message.latitude) ? String(message.latitude) : message.latitude; + if (message.longitude != null && message.hasOwnProperty("longitude")) + object.longitude = options.json && !isFinite(message.longitude) ? String(message.longitude) : message.longitude; + return object; + }; + + /** + * Converts this LatLng to JSON. + * @function toJSON + * @memberof google.type.LatLng + * @instance + * @returns {Object.} JSON object + */ + LatLng.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return LatLng; + })(); + + return type; })(); - - longrunning.OperationInfo = (function() { - - /** - * Properties of an OperationInfo. - * @memberof google.longrunning - * @interface IOperationInfo - * @property {string|null} [responseType] OperationInfo responseType - * @property {string|null} [metadataType] OperationInfo metadataType - */ - - /** - * Constructs a new OperationInfo. - * @memberof google.longrunning - * @classdesc Represents an OperationInfo. - * @implements IOperationInfo - * @constructor - * @param {google.longrunning.IOperationInfo=} [properties] Properties to set - */ - function OperationInfo(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - + + google.rpc = (function() { + /** - * OperationInfo responseType. - * @member {string} responseType - * @memberof google.longrunning.OperationInfo - * @instance + * Namespace rpc. + * @memberof google + * @namespace */ - OperationInfo.prototype.responseType = ""; - + var rpc = {}; + + rpc.Status = (function() { + + /** + * Properties of a Status. + * @memberof google.rpc + * @interface IStatus + * @property {number|null} [code] Status code + * @property {string|null} [message] Status message + * @property {Array.|null} [details] Status details + */ + + /** + * Constructs a new Status. + * @memberof google.rpc + * @classdesc Represents a Status. + * @implements IStatus + * @constructor + * @param {google.rpc.IStatus=} [properties] Properties to set + */ + function Status(properties) { + this.details = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Status code. + * @member {number} code + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.code = 0; + + /** + * Status message. + * @member {string} message + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.message = ""; + + /** + * Status details. + * @member {Array.} details + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.details = $util.emptyArray; + + /** + * Creates a Status message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.rpc.Status + * @static + * @param {Object.} object Plain object + * @returns {google.rpc.Status} Status + */ + Status.fromObject = function fromObject(object) { + if (object instanceof $root.google.rpc.Status) + return object; + var message = new $root.google.rpc.Status(); + if (object.code != null) + message.code = object.code | 0; + if (object.message != null) + message.message = String(object.message); + if (object.details) { + if (!Array.isArray(object.details)) + throw TypeError(".google.rpc.Status.details: array expected"); + message.details = []; + for (var i = 0; i < object.details.length; ++i) { + if (typeof object.details[i] !== "object") + throw TypeError(".google.rpc.Status.details: object expected"); + message.details[i] = $root.google.protobuf.Any.fromObject(object.details[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Status message. Also converts values to other types if specified. + * @function toObject + * @memberof google.rpc.Status + * @static + * @param {google.rpc.Status} message Status + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Status.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.details = []; + if (options.defaults) { + object.code = 0; + object.message = ""; + } + if (message.code != null && message.hasOwnProperty("code")) + object.code = message.code; + if (message.message != null && message.hasOwnProperty("message")) + object.message = message.message; + if (message.details && message.details.length) { + object.details = []; + for (var j = 0; j < message.details.length; ++j) + object.details[j] = $root.google.protobuf.Any.toObject(message.details[j], options); + } + return object; + }; + + /** + * Converts this Status to JSON. + * @function toJSON + * @memberof google.rpc.Status + * @instance + * @returns {Object.} JSON object + */ + Status.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Status; + })(); + + return rpc; + })(); + + google.longrunning = (function() { + /** - * OperationInfo metadataType. - * @member {string} metadataType - * @memberof google.longrunning.OperationInfo - * @instance + * Namespace longrunning. + * @memberof google + * @namespace */ - OperationInfo.prototype.metadataType = ""; - - return OperationInfo; + var longrunning = {}; + + longrunning.Operations = (function() { + + /** + * Constructs a new Operations service. + * @memberof google.longrunning + * @classdesc Represents an Operations + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function Operations(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (Operations.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Operations; + + /** + * Callback as used by {@link google.longrunning.Operations#listOperations}. + * @memberof google.longrunning.Operations + * @typedef ListOperationsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.ListOperationsResponse} [response] ListOperationsResponse + */ + + /** + * Calls ListOperations. + * @function listOperations + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object + * @param {google.longrunning.Operations.ListOperationsCallback} callback Node-style callback called with the error, if any, and ListOperationsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.listOperations = function listOperations(request, callback) { + return this.rpcCall(listOperations, $root.google.longrunning.ListOperationsRequest, $root.google.longrunning.ListOperationsResponse, request, callback); + }, "name", { value: "ListOperations" }); + + /** + * Calls ListOperations. + * @function listOperations + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#getOperation}. + * @memberof google.longrunning.Operations + * @typedef GetOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls GetOperation. + * @function getOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object + * @param {google.longrunning.Operations.GetOperationCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.getOperation = function getOperation(request, callback) { + return this.rpcCall(getOperation, $root.google.longrunning.GetOperationRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "GetOperation" }); + + /** + * Calls GetOperation. + * @function getOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#deleteOperation}. + * @memberof google.longrunning.Operations + * @typedef DeleteOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteOperation. + * @function deleteOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object + * @param {google.longrunning.Operations.DeleteOperationCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.deleteOperation = function deleteOperation(request, callback) { + return this.rpcCall(deleteOperation, $root.google.longrunning.DeleteOperationRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteOperation" }); + + /** + * Calls DeleteOperation. + * @function deleteOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#cancelOperation}. + * @memberof google.longrunning.Operations + * @typedef CancelOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls CancelOperation. + * @function cancelOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object + * @param {google.longrunning.Operations.CancelOperationCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.cancelOperation = function cancelOperation(request, callback) { + return this.rpcCall(cancelOperation, $root.google.longrunning.CancelOperationRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "CancelOperation" }); + + /** + * Calls CancelOperation. + * @function cancelOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#waitOperation}. + * @memberof google.longrunning.Operations + * @typedef WaitOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls WaitOperation. + * @function waitOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object + * @param {google.longrunning.Operations.WaitOperationCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.waitOperation = function waitOperation(request, callback) { + return this.rpcCall(waitOperation, $root.google.longrunning.WaitOperationRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "WaitOperation" }); + + /** + * Calls WaitOperation. + * @function waitOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return Operations; + })(); + + longrunning.Operation = (function() { + + /** + * Properties of an Operation. + * @memberof google.longrunning + * @interface IOperation + * @property {string|null} [name] Operation name + * @property {google.protobuf.IAny|null} [metadata] Operation metadata + * @property {boolean|null} [done] Operation done + * @property {google.rpc.IStatus|null} [error] Operation error + * @property {google.protobuf.IAny|null} [response] Operation response + */ + + /** + * Constructs a new Operation. + * @memberof google.longrunning + * @classdesc Represents an Operation. + * @implements IOperation + * @constructor + * @param {google.longrunning.IOperation=} [properties] Properties to set + */ + function Operation(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Operation name. + * @member {string} name + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.name = ""; + + /** + * Operation metadata. + * @member {google.protobuf.IAny|null|undefined} metadata + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.metadata = null; + + /** + * Operation done. + * @member {boolean} done + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.done = false; + + /** + * Operation error. + * @member {google.rpc.IStatus|null|undefined} error + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.error = null; + + /** + * Operation response. + * @member {google.protobuf.IAny|null|undefined} response + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.response = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Operation result. + * @member {"error"|"response"|undefined} result + * @memberof google.longrunning.Operation + * @instance + */ + Object.defineProperty(Operation.prototype, "result", { + get: $util.oneOfGetter($oneOfFields = ["error", "response"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates an Operation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.Operation + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.Operation} Operation + */ + Operation.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.Operation) + return object; + var message = new $root.google.longrunning.Operation(); + if (object.name != null) + message.name = String(object.name); + if (object.metadata != null) { + if (typeof object.metadata !== "object") + throw TypeError(".google.longrunning.Operation.metadata: object expected"); + message.metadata = $root.google.protobuf.Any.fromObject(object.metadata); + } + if (object.done != null) + message.done = Boolean(object.done); + if (object.error != null) { + if (typeof object.error !== "object") + throw TypeError(".google.longrunning.Operation.error: object expected"); + message.error = $root.google.rpc.Status.fromObject(object.error); + } + if (object.response != null) { + if (typeof object.response !== "object") + throw TypeError(".google.longrunning.Operation.response: object expected"); + message.response = $root.google.protobuf.Any.fromObject(object.response); + } + return message; + }; + + /** + * Creates a plain object from an Operation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.Operation + * @static + * @param {google.longrunning.Operation} message Operation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Operation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.metadata = null; + object.done = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.metadata != null && message.hasOwnProperty("metadata")) + object.metadata = $root.google.protobuf.Any.toObject(message.metadata, options); + if (message.done != null && message.hasOwnProperty("done")) + object.done = message.done; + if (message.error != null && message.hasOwnProperty("error")) { + object.error = $root.google.rpc.Status.toObject(message.error, options); + if (options.oneofs) + object.result = "error"; + } + if (message.response != null && message.hasOwnProperty("response")) { + object.response = $root.google.protobuf.Any.toObject(message.response, options); + if (options.oneofs) + object.result = "response"; + } + return object; + }; + + /** + * Converts this Operation to JSON. + * @function toJSON + * @memberof google.longrunning.Operation + * @instance + * @returns {Object.} JSON object + */ + Operation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Operation; + })(); + + longrunning.GetOperationRequest = (function() { + + /** + * Properties of a GetOperationRequest. + * @memberof google.longrunning + * @interface IGetOperationRequest + * @property {string|null} [name] GetOperationRequest name + */ + + /** + * Constructs a new GetOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a GetOperationRequest. + * @implements IGetOperationRequest + * @constructor + * @param {google.longrunning.IGetOperationRequest=} [properties] Properties to set + */ + function GetOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetOperationRequest name. + * @member {string} name + * @memberof google.longrunning.GetOperationRequest + * @instance + */ + GetOperationRequest.prototype.name = ""; + + /** + * Creates a GetOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.GetOperationRequest} GetOperationRequest + */ + GetOperationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.GetOperationRequest) + return object; + var message = new $root.google.longrunning.GetOperationRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {google.longrunning.GetOperationRequest} message GetOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetOperationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.GetOperationRequest + * @instance + * @returns {Object.} JSON object + */ + GetOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetOperationRequest; + })(); + + longrunning.ListOperationsRequest = (function() { + + /** + * Properties of a ListOperationsRequest. + * @memberof google.longrunning + * @interface IListOperationsRequest + * @property {string|null} [name] ListOperationsRequest name + * @property {string|null} [filter] ListOperationsRequest filter + * @property {number|null} [pageSize] ListOperationsRequest pageSize + * @property {string|null} [pageToken] ListOperationsRequest pageToken + */ + + /** + * Constructs a new ListOperationsRequest. + * @memberof google.longrunning + * @classdesc Represents a ListOperationsRequest. + * @implements IListOperationsRequest + * @constructor + * @param {google.longrunning.IListOperationsRequest=} [properties] Properties to set + */ + function ListOperationsRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListOperationsRequest name. + * @member {string} name + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.name = ""; + + /** + * ListOperationsRequest filter. + * @member {string} filter + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.filter = ""; + + /** + * ListOperationsRequest pageSize. + * @member {number} pageSize + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.pageSize = 0; + + /** + * ListOperationsRequest pageToken. + * @member {string} pageToken + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.pageToken = ""; + + /** + * Creates a ListOperationsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.ListOperationsRequest} ListOperationsRequest + */ + ListOperationsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.ListOperationsRequest) + return object; + var message = new $root.google.longrunning.ListOperationsRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.filter != null) + message.filter = String(object.filter); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + return message; + }; + + /** + * Creates a plain object from a ListOperationsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {google.longrunning.ListOperationsRequest} message ListOperationsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListOperationsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.filter = ""; + object.pageSize = 0; + object.pageToken = ""; + object.name = ""; + } + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this ListOperationsRequest to JSON. + * @function toJSON + * @memberof google.longrunning.ListOperationsRequest + * @instance + * @returns {Object.} JSON object + */ + ListOperationsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListOperationsRequest; + })(); + + longrunning.ListOperationsResponse = (function() { + + /** + * Properties of a ListOperationsResponse. + * @memberof google.longrunning + * @interface IListOperationsResponse + * @property {Array.|null} [operations] ListOperationsResponse operations + * @property {string|null} [nextPageToken] ListOperationsResponse nextPageToken + */ + + /** + * Constructs a new ListOperationsResponse. + * @memberof google.longrunning + * @classdesc Represents a ListOperationsResponse. + * @implements IListOperationsResponse + * @constructor + * @param {google.longrunning.IListOperationsResponse=} [properties] Properties to set + */ + function ListOperationsResponse(properties) { + this.operations = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListOperationsResponse operations. + * @member {Array.} operations + * @memberof google.longrunning.ListOperationsResponse + * @instance + */ + ListOperationsResponse.prototype.operations = $util.emptyArray; + + /** + * ListOperationsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.longrunning.ListOperationsResponse + * @instance + */ + ListOperationsResponse.prototype.nextPageToken = ""; + + /** + * Creates a ListOperationsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.ListOperationsResponse} ListOperationsResponse + */ + ListOperationsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.ListOperationsResponse) + return object; + var message = new $root.google.longrunning.ListOperationsResponse(); + if (object.operations) { + if (!Array.isArray(object.operations)) + throw TypeError(".google.longrunning.ListOperationsResponse.operations: array expected"); + message.operations = []; + for (var i = 0; i < object.operations.length; ++i) { + if (typeof object.operations[i] !== "object") + throw TypeError(".google.longrunning.ListOperationsResponse.operations: object expected"); + message.operations[i] = $root.google.longrunning.Operation.fromObject(object.operations[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListOperationsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {google.longrunning.ListOperationsResponse} message ListOperationsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListOperationsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.operations = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.operations && message.operations.length) { + object.operations = []; + for (var j = 0; j < message.operations.length; ++j) + object.operations[j] = $root.google.longrunning.Operation.toObject(message.operations[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListOperationsResponse to JSON. + * @function toJSON + * @memberof google.longrunning.ListOperationsResponse + * @instance + * @returns {Object.} JSON object + */ + ListOperationsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListOperationsResponse; + })(); + + longrunning.CancelOperationRequest = (function() { + + /** + * Properties of a CancelOperationRequest. + * @memberof google.longrunning + * @interface ICancelOperationRequest + * @property {string|null} [name] CancelOperationRequest name + */ + + /** + * Constructs a new CancelOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a CancelOperationRequest. + * @implements ICancelOperationRequest + * @constructor + * @param {google.longrunning.ICancelOperationRequest=} [properties] Properties to set + */ + function CancelOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CancelOperationRequest name. + * @member {string} name + * @memberof google.longrunning.CancelOperationRequest + * @instance + */ + CancelOperationRequest.prototype.name = ""; + + /** + * Creates a CancelOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.CancelOperationRequest} CancelOperationRequest + */ + CancelOperationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.CancelOperationRequest) + return object; + var message = new $root.google.longrunning.CancelOperationRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a CancelOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {google.longrunning.CancelOperationRequest} message CancelOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CancelOperationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this CancelOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.CancelOperationRequest + * @instance + * @returns {Object.} JSON object + */ + CancelOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CancelOperationRequest; + })(); + + longrunning.DeleteOperationRequest = (function() { + + /** + * Properties of a DeleteOperationRequest. + * @memberof google.longrunning + * @interface IDeleteOperationRequest + * @property {string|null} [name] DeleteOperationRequest name + */ + + /** + * Constructs a new DeleteOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a DeleteOperationRequest. + * @implements IDeleteOperationRequest + * @constructor + * @param {google.longrunning.IDeleteOperationRequest=} [properties] Properties to set + */ + function DeleteOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteOperationRequest name. + * @member {string} name + * @memberof google.longrunning.DeleteOperationRequest + * @instance + */ + DeleteOperationRequest.prototype.name = ""; + + /** + * Creates a DeleteOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.DeleteOperationRequest} DeleteOperationRequest + */ + DeleteOperationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.DeleteOperationRequest) + return object; + var message = new $root.google.longrunning.DeleteOperationRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {google.longrunning.DeleteOperationRequest} message DeleteOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteOperationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this DeleteOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.DeleteOperationRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DeleteOperationRequest; + })(); + + longrunning.WaitOperationRequest = (function() { + + /** + * Properties of a WaitOperationRequest. + * @memberof google.longrunning + * @interface IWaitOperationRequest + * @property {string|null} [name] WaitOperationRequest name + * @property {google.protobuf.IDuration|null} [timeout] WaitOperationRequest timeout + */ + + /** + * Constructs a new WaitOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a WaitOperationRequest. + * @implements IWaitOperationRequest + * @constructor + * @param {google.longrunning.IWaitOperationRequest=} [properties] Properties to set + */ + function WaitOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WaitOperationRequest name. + * @member {string} name + * @memberof google.longrunning.WaitOperationRequest + * @instance + */ + WaitOperationRequest.prototype.name = ""; + + /** + * WaitOperationRequest timeout. + * @member {google.protobuf.IDuration|null|undefined} timeout + * @memberof google.longrunning.WaitOperationRequest + * @instance + */ + WaitOperationRequest.prototype.timeout = null; + + /** + * Creates a WaitOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.WaitOperationRequest} WaitOperationRequest + */ + WaitOperationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.WaitOperationRequest) + return object; + var message = new $root.google.longrunning.WaitOperationRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.timeout != null) { + if (typeof object.timeout !== "object") + throw TypeError(".google.longrunning.WaitOperationRequest.timeout: object expected"); + message.timeout = $root.google.protobuf.Duration.fromObject(object.timeout); + } + return message; + }; + + /** + * Creates a plain object from a WaitOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {google.longrunning.WaitOperationRequest} message WaitOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WaitOperationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.timeout = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.timeout != null && message.hasOwnProperty("timeout")) + object.timeout = $root.google.protobuf.Duration.toObject(message.timeout, options); + return object; + }; + + /** + * Converts this WaitOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.WaitOperationRequest + * @instance + * @returns {Object.} JSON object + */ + WaitOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return WaitOperationRequest; + })(); + + longrunning.OperationInfo = (function() { + + /** + * Properties of an OperationInfo. + * @memberof google.longrunning + * @interface IOperationInfo + * @property {string|null} [responseType] OperationInfo responseType + * @property {string|null} [metadataType] OperationInfo metadataType + */ + + /** + * Constructs a new OperationInfo. + * @memberof google.longrunning + * @classdesc Represents an OperationInfo. + * @implements IOperationInfo + * @constructor + * @param {google.longrunning.IOperationInfo=} [properties] Properties to set + */ + function OperationInfo(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OperationInfo responseType. + * @member {string} responseType + * @memberof google.longrunning.OperationInfo + * @instance + */ + OperationInfo.prototype.responseType = ""; + + /** + * OperationInfo metadataType. + * @member {string} metadataType + * @memberof google.longrunning.OperationInfo + * @instance + */ + OperationInfo.prototype.metadataType = ""; + + /** + * Creates an OperationInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.OperationInfo + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.OperationInfo} OperationInfo + */ + OperationInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.OperationInfo) + return object; + var message = new $root.google.longrunning.OperationInfo(); + if (object.responseType != null) + message.responseType = String(object.responseType); + if (object.metadataType != null) + message.metadataType = String(object.metadataType); + return message; + }; + + /** + * Creates a plain object from an OperationInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.OperationInfo + * @static + * @param {google.longrunning.OperationInfo} message OperationInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OperationInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.responseType = ""; + object.metadataType = ""; + } + if (message.responseType != null && message.hasOwnProperty("responseType")) + object.responseType = message.responseType; + if (message.metadataType != null && message.hasOwnProperty("metadataType")) + object.metadataType = message.metadataType; + return object; + }; + + /** + * Converts this OperationInfo to JSON. + * @function toJSON + * @memberof google.longrunning.OperationInfo + * @instance + * @returns {Object.} JSON object + */ + OperationInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return OperationInfo; + })(); + + return longrunning; })(); - - return longrunning; + + return google; })(); - return google; -})(); + return $root; +}); diff --git a/dev/protos/firestore_v1beta1_proto_api.d.ts b/dev/protos/firestore_v1beta1_proto_api.d.ts index e748df35a..467a4eade 100644 --- a/dev/protos/firestore_v1beta1_proto_api.d.ts +++ b/dev/protos/firestore_v1beta1_proto_api.d.ts @@ -25,7 +25,7 @@ export namespace google { interface ITimestamp { /** Timestamp seconds */ - seconds?: (number|null); + seconds?: (number|string|null); /** Timestamp nanos */ nanos?: (number|null); @@ -41,10 +41,31 @@ export namespace google { constructor(properties?: google.protobuf.ITimestamp); /** Timestamp seconds. */ - public seconds: number; + public seconds: (number|string); /** Timestamp nanos. */ public nanos: number; + + /** + * Creates a Timestamp message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Timestamp + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Timestamp; + + /** + * Creates a plain object from a Timestamp message. Also converts values to other types if specified. + * @param message Timestamp + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Timestamp, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Timestamp to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FileDescriptorSet. */ @@ -65,6 +86,27 @@ export namespace google { /** FileDescriptorSet file. */ public file: google.protobuf.IFileDescriptorProto[]; + + /** + * Creates a FileDescriptorSet message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileDescriptorSet + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileDescriptorSet; + + /** + * Creates a plain object from a FileDescriptorSet message. Also converts values to other types if specified. + * @param message FileDescriptorSet + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileDescriptorSet, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileDescriptorSet to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FileDescriptorProto. */ @@ -151,6 +193,27 @@ export namespace google { /** FileDescriptorProto syntax. */ public syntax: string; + + /** + * Creates a FileDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileDescriptorProto; + + /** + * Creates a plain object from a FileDescriptorProto message. Also converts values to other types if specified. + * @param message FileDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DescriptorProto. */ @@ -225,6 +288,27 @@ export namespace google { /** DescriptorProto reservedName. */ public reservedName: string[]; + + /** + * Creates a DescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto; + + /** + * Creates a plain object from a DescriptorProto message. Also converts values to other types if specified. + * @param message DescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace DescriptorProto { @@ -253,6 +337,27 @@ export namespace google { /** ExtensionRange end. */ public end: number; + + /** + * Creates an ExtensionRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExtensionRange + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto.ExtensionRange; + + /** + * Creates a plain object from an ExtensionRange message. Also converts values to other types if specified. + * @param message ExtensionRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto.ExtensionRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExtensionRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ReservedRange. */ @@ -279,6 +384,27 @@ export namespace google { /** ReservedRange end. */ public end: number; + + /** + * Creates a ReservedRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReservedRange + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto.ReservedRange; + + /** + * Creates a plain object from a ReservedRange message. Also converts values to other types if specified. + * @param message ReservedRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto.ReservedRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReservedRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -354,6 +480,27 @@ export namespace google { /** FieldDescriptorProto options. */ public options?: (google.protobuf.IFieldOptions|null); + + /** + * Creates a FieldDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldDescriptorProto; + + /** + * Creates a plain object from a FieldDescriptorProto message. Also converts values to other types if specified. + * @param message FieldDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace FieldDescriptorProto { @@ -391,6 +538,27 @@ export namespace google { /** OneofDescriptorProto options. */ public options?: (google.protobuf.IOneofOptions|null); + + /** + * Creates an OneofDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OneofDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.OneofDescriptorProto; + + /** + * Creates a plain object from an OneofDescriptorProto message. Also converts values to other types if specified. + * @param message OneofDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.OneofDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OneofDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an EnumDescriptorProto. */ @@ -423,6 +591,27 @@ export namespace google { /** EnumDescriptorProto options. */ public options?: (google.protobuf.IEnumOptions|null); + + /** + * Creates an EnumDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumDescriptorProto; + + /** + * Creates a plain object from an EnumDescriptorProto message. Also converts values to other types if specified. + * @param message EnumDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an EnumValueDescriptorProto. */ @@ -455,6 +644,27 @@ export namespace google { /** EnumValueDescriptorProto options. */ public options?: (google.protobuf.IEnumValueOptions|null); + + /** + * Creates an EnumValueDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumValueDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumValueDescriptorProto; + + /** + * Creates a plain object from an EnumValueDescriptorProto message. Also converts values to other types if specified. + * @param message EnumValueDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumValueDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumValueDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ServiceDescriptorProto. */ @@ -487,6 +697,27 @@ export namespace google { /** ServiceDescriptorProto options. */ public options?: (google.protobuf.IServiceOptions|null); + + /** + * Creates a ServiceDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServiceDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ServiceDescriptorProto; + + /** + * Creates a plain object from a ServiceDescriptorProto message. Also converts values to other types if specified. + * @param message ServiceDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ServiceDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServiceDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a MethodDescriptorProto. */ @@ -537,6 +768,27 @@ export namespace google { /** MethodDescriptorProto serverStreaming. */ public serverStreaming: boolean; + + /** + * Creates a MethodDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MethodDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MethodDescriptorProto; + + /** + * Creates a plain object from a MethodDescriptorProto message. Also converts values to other types if specified. + * @param message MethodDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MethodDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MethodDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FileOptions. */ @@ -644,6 +896,27 @@ export namespace google { /** FileOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a FileOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileOptions; + + /** + * Creates a plain object from a FileOptions message. Also converts values to other types if specified. + * @param message FileOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace FileOptions { @@ -698,6 +971,27 @@ export namespace google { /** MessageOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a MessageOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MessageOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MessageOptions; + + /** + * Creates a plain object from a MessageOptions message. Also converts values to other types if specified. + * @param message MessageOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MessageOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MessageOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FieldOptions. */ @@ -760,6 +1054,27 @@ export namespace google { /** FieldOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a FieldOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions; + + /** + * Creates a plain object from a FieldOptions message. Also converts values to other types if specified. + * @param message FieldOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace FieldOptions { @@ -791,6 +1106,27 @@ export namespace google { /** OneofOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an OneofOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OneofOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.OneofOptions; + + /** + * Creates a plain object from an OneofOptions message. Also converts values to other types if specified. + * @param message OneofOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.OneofOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OneofOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an EnumOptions. */ @@ -823,6 +1159,27 @@ export namespace google { /** EnumOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an EnumOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumOptions; + + /** + * Creates a plain object from an EnumOptions message. Also converts values to other types if specified. + * @param message EnumOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an EnumValueOptions. */ @@ -849,6 +1206,27 @@ export namespace google { /** EnumValueOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an EnumValueOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumValueOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumValueOptions; + + /** + * Creates a plain object from an EnumValueOptions message. Also converts values to other types if specified. + * @param message EnumValueOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumValueOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumValueOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ServiceOptions. */ @@ -881,6 +1259,27 @@ export namespace google { /** ServiceOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a ServiceOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServiceOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ServiceOptions; + + /** + * Creates a plain object from a ServiceOptions message. Also converts values to other types if specified. + * @param message ServiceOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ServiceOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServiceOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a MethodOptions. */ @@ -916,6 +1315,27 @@ export namespace google { /** MethodOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a MethodOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MethodOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MethodOptions; + + /** + * Creates a plain object from a MethodOptions message. Also converts values to other types if specified. + * @param message MethodOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MethodOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MethodOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an UninterpretedOption. */ @@ -928,10 +1348,10 @@ export namespace google { identifierValue?: (string|null); /** UninterpretedOption positiveIntValue */ - positiveIntValue?: (number|null); + positiveIntValue?: (number|string|null); /** UninterpretedOption negativeIntValue */ - negativeIntValue?: (number|null); + negativeIntValue?: (number|string|null); /** UninterpretedOption doubleValue */ doubleValue?: (number|null); @@ -959,10 +1379,10 @@ export namespace google { public identifierValue: string; /** UninterpretedOption positiveIntValue. */ - public positiveIntValue: number; + public positiveIntValue: (number|string); /** UninterpretedOption negativeIntValue. */ - public negativeIntValue: number; + public negativeIntValue: (number|string); /** UninterpretedOption doubleValue. */ public doubleValue: number; @@ -972,6 +1392,27 @@ export namespace google { /** UninterpretedOption aggregateValue. */ public aggregateValue: string; + + /** + * Creates an UninterpretedOption message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UninterpretedOption + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UninterpretedOption; + + /** + * Creates a plain object from an UninterpretedOption message. Also converts values to other types if specified. + * @param message UninterpretedOption + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UninterpretedOption, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UninterpretedOption to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace UninterpretedOption { @@ -1000,6 +1441,27 @@ export namespace google { /** NamePart isExtension. */ public isExtension: boolean; + + /** + * Creates a NamePart message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns NamePart + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UninterpretedOption.NamePart; + + /** + * Creates a plain object from a NamePart message. Also converts values to other types if specified. + * @param message NamePart + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UninterpretedOption.NamePart, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this NamePart to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -1021,6 +1483,27 @@ export namespace google { /** SourceCodeInfo location. */ public location: google.protobuf.SourceCodeInfo.ILocation[]; + + /** + * Creates a SourceCodeInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SourceCodeInfo + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.SourceCodeInfo; + + /** + * Creates a plain object from a SourceCodeInfo message. Also converts values to other types if specified. + * @param message SourceCodeInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.SourceCodeInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SourceCodeInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace SourceCodeInfo { @@ -1067,6 +1550,27 @@ export namespace google { /** Location leadingDetachedComments. */ public leadingDetachedComments: string[]; + + /** + * Creates a Location message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Location + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.SourceCodeInfo.Location; + + /** + * Creates a plain object from a Location message. Also converts values to other types if specified. + * @param message Location + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.SourceCodeInfo.Location, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Location to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -1088,6 +1592,27 @@ export namespace google { /** GeneratedCodeInfo annotation. */ public annotation: google.protobuf.GeneratedCodeInfo.IAnnotation[]; + + /** + * Creates a GeneratedCodeInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GeneratedCodeInfo + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.GeneratedCodeInfo; + + /** + * Creates a plain object from a GeneratedCodeInfo message. Also converts values to other types if specified. + * @param message GeneratedCodeInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.GeneratedCodeInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GeneratedCodeInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace GeneratedCodeInfo { @@ -1128,6 +1653,27 @@ export namespace google { /** Annotation end. */ public end: number; + + /** + * Creates an Annotation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Annotation + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.GeneratedCodeInfo.Annotation; + + /** + * Creates a plain object from an Annotation message. Also converts values to other types if specified. + * @param message Annotation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.GeneratedCodeInfo.Annotation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Annotation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -1149,6 +1695,27 @@ export namespace google { /** Struct fields. */ public fields: { [k: string]: google.protobuf.IValue }; + + /** + * Creates a Struct message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Struct + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Struct; + + /** + * Creates a plain object from a Struct message. Also converts values to other types if specified. + * @param message Struct + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Struct, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Struct to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Value. */ @@ -1202,6 +1769,27 @@ export namespace google { /** Value kind. */ public kind?: ("nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"); + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Value; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @param message Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** NullValue enum. */ @@ -1226,11 +1814,32 @@ export namespace google { /** ListValue values. */ public values: google.protobuf.IValue[]; - } - /** Properties of an Empty. */ - interface IEmpty { - } + /** + * Creates a ListValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ListValue; + + /** + * Creates a plain object from a ListValue message. Also converts values to other types if specified. + * @param message ListValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ListValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an Empty. */ + interface IEmpty { + } /** Represents an Empty. */ class Empty implements IEmpty { @@ -1240,6 +1849,27 @@ export namespace google { * @param [properties] Properties to set */ constructor(properties?: google.protobuf.IEmpty); + + /** + * Creates an Empty message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Empty + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Empty; + + /** + * Creates a plain object from an Empty message. Also converts values to other types if specified. + * @param message Empty + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Empty, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Empty to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DoubleValue. */ @@ -1260,6 +1890,27 @@ export namespace google { /** DoubleValue value. */ public value: number; + + /** + * Creates a DoubleValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DoubleValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DoubleValue; + + /** + * Creates a plain object from a DoubleValue message. Also converts values to other types if specified. + * @param message DoubleValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DoubleValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DoubleValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FloatValue. */ @@ -1280,13 +1931,34 @@ export namespace google { /** FloatValue value. */ public value: number; + + /** + * Creates a FloatValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FloatValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FloatValue; + + /** + * Creates a plain object from a FloatValue message. Also converts values to other types if specified. + * @param message FloatValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FloatValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FloatValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an Int64Value. */ interface IInt64Value { /** Int64Value value */ - value?: (number|null); + value?: (number|string|null); } /** Represents an Int64Value. */ @@ -1299,14 +1971,35 @@ export namespace google { constructor(properties?: google.protobuf.IInt64Value); /** Int64Value value. */ - public value: number; + public value: (number|string); + + /** + * Creates an Int64Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Int64Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Int64Value; + + /** + * Creates a plain object from an Int64Value message. Also converts values to other types if specified. + * @param message Int64Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Int64Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Int64Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a UInt64Value. */ interface IUInt64Value { /** UInt64Value value */ - value?: (number|null); + value?: (number|string|null); } /** Represents a UInt64Value. */ @@ -1319,7 +2012,28 @@ export namespace google { constructor(properties?: google.protobuf.IUInt64Value); /** UInt64Value value. */ - public value: number; + public value: (number|string); + + /** + * Creates a UInt64Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UInt64Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UInt64Value; + + /** + * Creates a plain object from a UInt64Value message. Also converts values to other types if specified. + * @param message UInt64Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UInt64Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UInt64Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an Int32Value. */ @@ -1340,6 +2054,27 @@ export namespace google { /** Int32Value value. */ public value: number; + + /** + * Creates an Int32Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Int32Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Int32Value; + + /** + * Creates a plain object from an Int32Value message. Also converts values to other types if specified. + * @param message Int32Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Int32Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Int32Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a UInt32Value. */ @@ -1360,6 +2095,27 @@ export namespace google { /** UInt32Value value. */ public value: number; + + /** + * Creates a UInt32Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UInt32Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UInt32Value; + + /** + * Creates a plain object from a UInt32Value message. Also converts values to other types if specified. + * @param message UInt32Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UInt32Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UInt32Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a BoolValue. */ @@ -1380,6 +2136,27 @@ export namespace google { /** BoolValue value. */ public value: boolean; + + /** + * Creates a BoolValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BoolValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.BoolValue; + + /** + * Creates a plain object from a BoolValue message. Also converts values to other types if specified. + * @param message BoolValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.BoolValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BoolValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a StringValue. */ @@ -1400,6 +2177,27 @@ export namespace google { /** StringValue value. */ public value: string; + + /** + * Creates a StringValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StringValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.StringValue; + + /** + * Creates a plain object from a StringValue message. Also converts values to other types if specified. + * @param message StringValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.StringValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StringValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a BytesValue. */ @@ -1420,6 +2218,27 @@ export namespace google { /** BytesValue value. */ public value: Uint8Array; + + /** + * Creates a BytesValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BytesValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.BytesValue; + + /** + * Creates a plain object from a BytesValue message. Also converts values to other types if specified. + * @param message BytesValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.BytesValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BytesValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an Any. */ @@ -1446,6 +2265,27 @@ export namespace google { /** Any value. */ public value: Uint8Array; + + /** + * Creates an Any message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Any + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Any; + + /** + * Creates a plain object from an Any message. Also converts values to other types if specified. + * @param message Any + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Any, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Any to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FieldMask. */ @@ -1466,13 +2306,34 @@ export namespace google { /** FieldMask paths. */ public paths: string[]; + + /** + * Creates a FieldMask message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldMask + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldMask; + + /** + * Creates a plain object from a FieldMask message. Also converts values to other types if specified. + * @param message FieldMask + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldMask, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldMask to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Duration. */ interface IDuration { /** Duration seconds */ - seconds?: (number|null); + seconds?: (number|string|null); /** Duration nanos */ nanos?: (number|null); @@ -1488,10 +2349,31 @@ export namespace google { constructor(properties?: google.protobuf.IDuration); /** Duration seconds. */ - public seconds: number; + public seconds: (number|string); /** Duration nanos. */ public nanos: number; + + /** + * Creates a Duration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Duration + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Duration; + + /** + * Creates a plain object from a Duration message. Also converts values to other types if specified. + * @param message Duration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Duration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Duration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -1519,6 +2401,27 @@ export namespace google { /** DocumentMask fieldPaths. */ public fieldPaths: string[]; + + /** + * Creates a DocumentMask message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentMask + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.DocumentMask; + + /** + * Creates a plain object from a DocumentMask message. Also converts values to other types if specified. + * @param message DocumentMask + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.DocumentMask, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentMask to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Precondition. */ @@ -1548,6 +2451,27 @@ export namespace google { /** Precondition conditionType. */ public conditionType?: ("exists"|"updateTime"); + + /** + * Creates a Precondition message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Precondition + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.Precondition; + + /** + * Creates a plain object from a Precondition message. Also converts values to other types if specified. + * @param message Precondition + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.Precondition, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Precondition to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a TransactionOptions. */ @@ -1577,6 +2501,27 @@ export namespace google { /** TransactionOptions mode. */ public mode?: ("readOnly"|"readWrite"); + + /** + * Creates a TransactionOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TransactionOptions + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.TransactionOptions; + + /** + * Creates a plain object from a TransactionOptions message. Also converts values to other types if specified. + * @param message TransactionOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.TransactionOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TransactionOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace TransactionOptions { @@ -1599,6 +2544,27 @@ export namespace google { /** ReadWrite retryTransaction. */ public retryTransaction: Uint8Array; + + /** + * Creates a ReadWrite message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReadWrite + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.TransactionOptions.ReadWrite; + + /** + * Creates a plain object from a ReadWrite message. Also converts values to other types if specified. + * @param message ReadWrite + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.TransactionOptions.ReadWrite, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReadWrite to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ReadOnly. */ @@ -1622,6 +2588,27 @@ export namespace google { /** ReadOnly consistencySelector. */ public consistencySelector?: "readTime"; + + /** + * Creates a ReadOnly message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReadOnly + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.TransactionOptions.ReadOnly; + + /** + * Creates a plain object from a ReadOnly message. Also converts values to other types if specified. + * @param message ReadOnly + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.TransactionOptions.ReadOnly, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReadOnly to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -1661,6 +2648,27 @@ export namespace google { /** Document updateTime. */ public updateTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a Document message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Document + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.Document; + + /** + * Creates a plain object from a Document message. Also converts values to other types if specified. + * @param message Document + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.Document, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Document to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Value. */ @@ -1673,7 +2681,7 @@ export namespace google { booleanValue?: (boolean|null); /** Value integerValue */ - integerValue?: (number|null); + integerValue?: (number|string|null); /** Value doubleValue */ doubleValue?: (number|null); @@ -1716,7 +2724,7 @@ export namespace google { public booleanValue: boolean; /** Value integerValue. */ - public integerValue: number; + public integerValue: (number|string); /** Value doubleValue. */ public doubleValue: number; @@ -1744,6 +2752,27 @@ export namespace google { /** Value valueType. */ public valueType?: ("nullValue"|"booleanValue"|"integerValue"|"doubleValue"|"timestampValue"|"stringValue"|"bytesValue"|"referenceValue"|"geoPointValue"|"arrayValue"|"mapValue"); + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Value + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.Value; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @param message Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an ArrayValue. */ @@ -1764,6 +2793,27 @@ export namespace google { /** ArrayValue values. */ public values: google.firestore.v1beta1.IValue[]; + + /** + * Creates an ArrayValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ArrayValue + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.ArrayValue; + + /** + * Creates a plain object from an ArrayValue message. Also converts values to other types if specified. + * @param message ArrayValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.ArrayValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ArrayValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a MapValue. */ @@ -1784,6 +2834,27 @@ export namespace google { /** MapValue fields. */ public fields: { [k: string]: google.firestore.v1beta1.IValue }; + + /** + * Creates a MapValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MapValue + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.MapValue; + + /** + * Creates a plain object from a MapValue message. Also converts values to other types if specified. + * @param message MapValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.MapValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MapValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Represents a Firestore */ @@ -2113,6 +3184,27 @@ export namespace google { /** GetDocumentRequest consistencySelector. */ public consistencySelector?: ("transaction"|"readTime"); + + /** + * Creates a GetDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.GetDocumentRequest; + + /** + * Creates a plain object from a GetDocumentRequest message. Also converts values to other types if specified. + * @param message GetDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.GetDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetDocumentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListDocumentsRequest. */ @@ -2184,6 +3276,27 @@ export namespace google { /** ListDocumentsRequest consistencySelector. */ public consistencySelector?: ("transaction"|"readTime"); + + /** + * Creates a ListDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListDocumentsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.ListDocumentsRequest; + + /** + * Creates a plain object from a ListDocumentsRequest message. Also converts values to other types if specified. + * @param message ListDocumentsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.ListDocumentsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListDocumentsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListDocumentsResponse. */ @@ -2210,6 +3323,27 @@ export namespace google { /** ListDocumentsResponse nextPageToken. */ public nextPageToken: string; + + /** + * Creates a ListDocumentsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListDocumentsResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.ListDocumentsResponse; + + /** + * Creates a plain object from a ListDocumentsResponse message. Also converts values to other types if specified. + * @param message ListDocumentsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.ListDocumentsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListDocumentsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a CreateDocumentRequest. */ @@ -2254,6 +3388,27 @@ export namespace google { /** CreateDocumentRequest mask. */ public mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** + * Creates a CreateDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.CreateDocumentRequest; + + /** + * Creates a plain object from a CreateDocumentRequest message. Also converts values to other types if specified. + * @param message CreateDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.CreateDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateDocumentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an UpdateDocumentRequest. */ @@ -2292,10 +3447,31 @@ export namespace google { /** UpdateDocumentRequest currentDocument. */ public currentDocument?: (google.firestore.v1beta1.IPrecondition|null); - } - /** Properties of a DeleteDocumentRequest. */ - interface IDeleteDocumentRequest { + /** + * Creates an UpdateDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.UpdateDocumentRequest; + + /** + * Creates a plain object from an UpdateDocumentRequest message. Also converts values to other types if specified. + * @param message UpdateDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.UpdateDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateDocumentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DeleteDocumentRequest. */ + interface IDeleteDocumentRequest { /** DeleteDocumentRequest name */ name?: (string|null); @@ -2318,6 +3494,27 @@ export namespace google { /** DeleteDocumentRequest currentDocument. */ public currentDocument?: (google.firestore.v1beta1.IPrecondition|null); + + /** + * Creates a DeleteDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.DeleteDocumentRequest; + + /** + * Creates a plain object from a DeleteDocumentRequest message. Also converts values to other types if specified. + * @param message DeleteDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.DeleteDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteDocumentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a BatchGetDocumentsRequest. */ @@ -2371,6 +3568,27 @@ export namespace google { /** BatchGetDocumentsRequest consistencySelector. */ public consistencySelector?: ("transaction"|"newTransaction"|"readTime"); + + /** + * Creates a BatchGetDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchGetDocumentsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.BatchGetDocumentsRequest; + + /** + * Creates a plain object from a BatchGetDocumentsRequest message. Also converts values to other types if specified. + * @param message BatchGetDocumentsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.BatchGetDocumentsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchGetDocumentsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a BatchGetDocumentsResponse. */ @@ -2412,6 +3630,27 @@ export namespace google { /** BatchGetDocumentsResponse result. */ public result?: ("found"|"missing"); + + /** + * Creates a BatchGetDocumentsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchGetDocumentsResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.BatchGetDocumentsResponse; + + /** + * Creates a plain object from a BatchGetDocumentsResponse message. Also converts values to other types if specified. + * @param message BatchGetDocumentsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.BatchGetDocumentsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchGetDocumentsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a BeginTransactionRequest. */ @@ -2438,6 +3677,27 @@ export namespace google { /** BeginTransactionRequest options. */ public options?: (google.firestore.v1beta1.ITransactionOptions|null); + + /** + * Creates a BeginTransactionRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BeginTransactionRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.BeginTransactionRequest; + + /** + * Creates a plain object from a BeginTransactionRequest message. Also converts values to other types if specified. + * @param message BeginTransactionRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.BeginTransactionRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BeginTransactionRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a BeginTransactionResponse. */ @@ -2458,6 +3718,27 @@ export namespace google { /** BeginTransactionResponse transaction. */ public transaction: Uint8Array; + + /** + * Creates a BeginTransactionResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BeginTransactionResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.BeginTransactionResponse; + + /** + * Creates a plain object from a BeginTransactionResponse message. Also converts values to other types if specified. + * @param message BeginTransactionResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.BeginTransactionResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BeginTransactionResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a CommitRequest. */ @@ -2490,6 +3771,27 @@ export namespace google { /** CommitRequest transaction. */ public transaction: Uint8Array; + + /** + * Creates a CommitRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CommitRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.CommitRequest; + + /** + * Creates a plain object from a CommitRequest message. Also converts values to other types if specified. + * @param message CommitRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.CommitRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CommitRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a CommitResponse. */ @@ -2516,6 +3818,27 @@ export namespace google { /** CommitResponse commitTime. */ public commitTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a CommitResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CommitResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.CommitResponse; + + /** + * Creates a plain object from a CommitResponse message. Also converts values to other types if specified. + * @param message CommitResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.CommitResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CommitResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a RollbackRequest. */ @@ -2542,6 +3865,27 @@ export namespace google { /** RollbackRequest transaction. */ public transaction: Uint8Array; + + /** + * Creates a RollbackRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RollbackRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.RollbackRequest; + + /** + * Creates a plain object from a RollbackRequest message. Also converts values to other types if specified. + * @param message RollbackRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.RollbackRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RollbackRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a RunQueryRequest. */ @@ -2592,6 +3936,27 @@ export namespace google { /** RunQueryRequest consistencySelector. */ public consistencySelector?: ("transaction"|"newTransaction"|"readTime"); + + /** + * Creates a RunQueryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RunQueryRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.RunQueryRequest; + + /** + * Creates a plain object from a RunQueryRequest message. Also converts values to other types if specified. + * @param message RunQueryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.RunQueryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RunQueryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a RunQueryResponse. */ @@ -2630,6 +3995,27 @@ export namespace google { /** RunQueryResponse skippedResults. */ public skippedResults: number; + + /** + * Creates a RunQueryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RunQueryResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.RunQueryResponse; + + /** + * Creates a plain object from a RunQueryResponse message. Also converts values to other types if specified. + * @param message RunQueryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.RunQueryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RunQueryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a WriteRequest. */ @@ -2674,6 +4060,27 @@ export namespace google { /** WriteRequest labels. */ public labels: { [k: string]: string }; + + /** + * Creates a WriteRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WriteRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.WriteRequest; + + /** + * Creates a plain object from a WriteRequest message. Also converts values to other types if specified. + * @param message WriteRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.WriteRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WriteRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a WriteResponse. */ @@ -2712,6 +4119,27 @@ export namespace google { /** WriteResponse commitTime. */ public commitTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a WriteResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WriteResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.WriteResponse; + + /** + * Creates a plain object from a WriteResponse message. Also converts values to other types if specified. + * @param message WriteResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.WriteResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WriteResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListenRequest. */ @@ -2753,6 +4181,27 @@ export namespace google { /** ListenRequest targetChange. */ public targetChange?: ("addTarget"|"removeTarget"); + + /** + * Creates a ListenRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListenRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.ListenRequest; + + /** + * Creates a plain object from a ListenRequest message. Also converts values to other types if specified. + * @param message ListenRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.ListenRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListenRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListenResponse. */ @@ -2800,6 +4249,27 @@ export namespace google { /** ListenResponse responseType. */ public responseType?: ("targetChange"|"documentChange"|"documentDelete"|"documentRemove"|"filter"); + + /** + * Creates a ListenResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListenResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.ListenResponse; + + /** + * Creates a plain object from a ListenResponse message. Also converts values to other types if specified. + * @param message ListenResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.ListenResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListenResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Target. */ @@ -2856,6 +4326,27 @@ export namespace google { /** Target resumeType. */ public resumeType?: ("resumeToken"|"readTime"); + + /** + * Creates a Target message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Target + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.Target; + + /** + * Creates a plain object from a Target message. Also converts values to other types if specified. + * @param message Target + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.Target, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Target to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace Target { @@ -2878,6 +4369,27 @@ export namespace google { /** DocumentsTarget documents. */ public documents: string[]; + + /** + * Creates a DocumentsTarget message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentsTarget + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.Target.DocumentsTarget; + + /** + * Creates a plain object from a DocumentsTarget message. Also converts values to other types if specified. + * @param message DocumentsTarget + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.Target.DocumentsTarget, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentsTarget to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a QueryTarget. */ @@ -2907,6 +4419,27 @@ export namespace google { /** QueryTarget queryType. */ public queryType?: "structuredQuery"; + + /** + * Creates a QueryTarget message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns QueryTarget + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.Target.QueryTarget; + + /** + * Creates a plain object from a QueryTarget message. Also converts values to other types if specified. + * @param message QueryTarget + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.Target.QueryTarget, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this QueryTarget to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -2952,6 +4485,27 @@ export namespace google { /** TargetChange readTime. */ public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a TargetChange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TargetChange + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.TargetChange; + + /** + * Creates a plain object from a TargetChange message. Also converts values to other types if specified. + * @param message TargetChange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.TargetChange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TargetChange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace TargetChange { @@ -2991,6 +4545,27 @@ export namespace google { /** ListCollectionIdsRequest pageToken. */ public pageToken: string; + + /** + * Creates a ListCollectionIdsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCollectionIdsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.ListCollectionIdsRequest; + + /** + * Creates a plain object from a ListCollectionIdsRequest message. Also converts values to other types if specified. + * @param message ListCollectionIdsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.ListCollectionIdsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCollectionIdsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListCollectionIdsResponse. */ @@ -3017,6 +4592,27 @@ export namespace google { /** ListCollectionIdsResponse nextPageToken. */ public nextPageToken: string; + + /** + * Creates a ListCollectionIdsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCollectionIdsResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.ListCollectionIdsResponse; + + /** + * Creates a plain object from a ListCollectionIdsResponse message. Also converts values to other types if specified. + * @param message ListCollectionIdsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.ListCollectionIdsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCollectionIdsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a StructuredQuery. */ @@ -3079,6 +4675,27 @@ export namespace google { /** StructuredQuery limit. */ public limit?: (google.protobuf.IInt32Value|null); + + /** + * Creates a StructuredQuery message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StructuredQuery + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery; + + /** + * Creates a plain object from a StructuredQuery message. Also converts values to other types if specified. + * @param message StructuredQuery + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StructuredQuery to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace StructuredQuery { @@ -3107,6 +4724,27 @@ export namespace google { /** CollectionSelector allDescendants. */ public allDescendants: boolean; + + /** + * Creates a CollectionSelector message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CollectionSelector + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.CollectionSelector; + + /** + * Creates a plain object from a CollectionSelector message. Also converts values to other types if specified. + * @param message CollectionSelector + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery.CollectionSelector, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CollectionSelector to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Filter. */ @@ -3142,6 +4780,27 @@ export namespace google { /** Filter filterType. */ public filterType?: ("compositeFilter"|"fieldFilter"|"unaryFilter"); + + /** + * Creates a Filter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Filter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.Filter; + + /** + * Creates a plain object from a Filter message. Also converts values to other types if specified. + * @param message Filter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery.Filter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Filter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a CompositeFilter. */ @@ -3168,6 +4827,27 @@ export namespace google { /** CompositeFilter filters. */ public filters: google.firestore.v1beta1.StructuredQuery.IFilter[]; + + /** + * Creates a CompositeFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompositeFilter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.CompositeFilter; + + /** + * Creates a plain object from a CompositeFilter message. Also converts values to other types if specified. + * @param message CompositeFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery.CompositeFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompositeFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace CompositeFilter { @@ -3207,6 +4887,27 @@ export namespace google { /** FieldFilter value. */ public value?: (google.firestore.v1beta1.IValue|null); + + /** + * Creates a FieldFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldFilter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.FieldFilter; + + /** + * Creates a plain object from a FieldFilter message. Also converts values to other types if specified. + * @param message FieldFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery.FieldFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace FieldFilter { @@ -3243,6 +4944,27 @@ export namespace google { /** UnaryFilter operandType. */ public operandType?: "field"; + + /** + * Creates an UnaryFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UnaryFilter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.UnaryFilter; + + /** + * Creates a plain object from an UnaryFilter message. Also converts values to other types if specified. + * @param message UnaryFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery.UnaryFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UnaryFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace UnaryFilter { @@ -3276,6 +4998,27 @@ export namespace google { /** Order direction. */ public direction: google.firestore.v1beta1.StructuredQuery.Direction; + + /** + * Creates an Order message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Order + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.Order; + + /** + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @param message Order + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery.Order, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Order to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FieldReference. */ @@ -3296,6 +5039,27 @@ export namespace google { /** FieldReference fieldPath. */ public fieldPath: string; + + /** + * Creates a FieldReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldReference + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.FieldReference; + + /** + * Creates a plain object from a FieldReference message. Also converts values to other types if specified. + * @param message FieldReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery.FieldReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Projection. */ @@ -3316,6 +5080,27 @@ export namespace google { /** Projection fields. */ public fields: google.firestore.v1beta1.StructuredQuery.IFieldReference[]; + + /** + * Creates a Projection message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Projection + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.Projection; + + /** + * Creates a plain object from a Projection message. Also converts values to other types if specified. + * @param message Projection + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery.Projection, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Projection to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Direction enum. */ @@ -3347,6 +5132,27 @@ export namespace google { /** Cursor before. */ public before: boolean; + + /** + * Creates a Cursor message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Cursor + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.Cursor; + + /** + * Creates a plain object from a Cursor message. Also converts values to other types if specified. + * @param message Cursor + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.Cursor, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Cursor to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a Write. */ @@ -3394,6 +5200,27 @@ export namespace google { /** Write operation. */ public operation?: ("update"|"delete"|"transform"); + + /** + * Creates a Write message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Write + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.Write; + + /** + * Creates a plain object from a Write message. Also converts values to other types if specified. + * @param message Write + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.Write, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Write to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DocumentTransform. */ @@ -3420,6 +5247,27 @@ export namespace google { /** DocumentTransform fieldTransforms. */ public fieldTransforms: google.firestore.v1beta1.DocumentTransform.IFieldTransform[]; + + /** + * Creates a DocumentTransform message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentTransform + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.DocumentTransform; + + /** + * Creates a plain object from a DocumentTransform message. Also converts values to other types if specified. + * @param message DocumentTransform + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.DocumentTransform, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentTransform to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace DocumentTransform { @@ -3481,6 +5329,27 @@ export namespace google { /** FieldTransform transformType. */ public transformType?: ("setToServerValue"|"increment"|"maximum"|"minimum"|"appendMissingElements"|"removeAllFromArray"); + + /** + * Creates a FieldTransform message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldTransform + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.DocumentTransform.FieldTransform; + + /** + * Creates a plain object from a FieldTransform message. Also converts values to other types if specified. + * @param message FieldTransform + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.DocumentTransform.FieldTransform, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldTransform to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace FieldTransform { @@ -3515,6 +5384,27 @@ export namespace google { /** WriteResult transformResults. */ public transformResults: google.firestore.v1beta1.IValue[]; + + /** + * Creates a WriteResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WriteResult + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.WriteResult; + + /** + * Creates a plain object from a WriteResult message. Also converts values to other types if specified. + * @param message WriteResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.WriteResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WriteResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DocumentChange. */ @@ -3547,6 +5437,27 @@ export namespace google { /** DocumentChange removedTargetIds. */ public removedTargetIds: number[]; + + /** + * Creates a DocumentChange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentChange + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.DocumentChange; + + /** + * Creates a plain object from a DocumentChange message. Also converts values to other types if specified. + * @param message DocumentChange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.DocumentChange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentChange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DocumentDelete. */ @@ -3579,6 +5490,27 @@ export namespace google { /** DocumentDelete readTime. */ public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a DocumentDelete message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentDelete + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.DocumentDelete; + + /** + * Creates a plain object from a DocumentDelete message. Also converts values to other types if specified. + * @param message DocumentDelete + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.DocumentDelete, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentDelete to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DocumentRemove. */ @@ -3611,6 +5543,27 @@ export namespace google { /** DocumentRemove readTime. */ public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a DocumentRemove message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentRemove + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.DocumentRemove; + + /** + * Creates a plain object from a DocumentRemove message. Also converts values to other types if specified. + * @param message DocumentRemove + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.DocumentRemove, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentRemove to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an ExistenceFilter. */ @@ -3637,6 +5590,27 @@ export namespace google { /** ExistenceFilter count. */ public count: number; + + /** + * Creates an ExistenceFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExistenceFilter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.ExistenceFilter; + + /** + * Creates a plain object from an ExistenceFilter message. Also converts values to other types if specified. + * @param message ExistenceFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.ExistenceFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExistenceFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } } @@ -3662,6 +5636,27 @@ export namespace google { /** Http rules. */ public rules: google.api.IHttpRule[]; + + /** + * Creates a Http message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Http + */ + public static fromObject(object: { [k: string]: any }): google.api.Http; + + /** + * Creates a plain object from a Http message. Also converts values to other types if specified. + * @param message Http + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.Http, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Http to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a HttpRule. */ @@ -3733,6 +5728,27 @@ export namespace google { /** HttpRule pattern. */ public pattern?: ("get"|"put"|"post"|"delete"|"patch"|"custom"); + + /** + * Creates a HttpRule message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns HttpRule + */ + public static fromObject(object: { [k: string]: any }): google.api.HttpRule; + + /** + * Creates a plain object from a HttpRule message. Also converts values to other types if specified. + * @param message HttpRule + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.HttpRule, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this HttpRule to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a CustomHttpPattern. */ @@ -3759,6 +5775,27 @@ export namespace google { /** CustomHttpPattern path. */ public path: string; + + /** + * Creates a CustomHttpPattern message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CustomHttpPattern + */ + public static fromObject(object: { [k: string]: any }): google.api.CustomHttpPattern; + + /** + * Creates a plain object from a CustomHttpPattern message. Also converts values to other types if specified. + * @param message CustomHttpPattern + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.CustomHttpPattern, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CustomHttpPattern to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** FieldBehavior enum. */ @@ -3813,6 +5850,27 @@ export namespace google { /** ResourceDescriptor singular. */ public singular: string; + + /** + * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ResourceDescriptor + */ + public static fromObject(object: { [k: string]: any }): google.api.ResourceDescriptor; + + /** + * Creates a plain object from a ResourceDescriptor message. Also converts values to other types if specified. + * @param message ResourceDescriptor + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.ResourceDescriptor, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ResourceDescriptor to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } namespace ResourceDescriptor { @@ -3846,6 +5904,27 @@ export namespace google { /** ResourceReference childType. */ public childType: string; + + /** + * Creates a ResourceReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ResourceReference + */ + public static fromObject(object: { [k: string]: any }): google.api.ResourceReference; + + /** + * Creates a plain object from a ResourceReference message. Also converts values to other types if specified. + * @param message ResourceReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.ResourceReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ResourceReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -3876,6 +5955,27 @@ export namespace google { /** LatLng longitude. */ public longitude: number; + + /** + * Creates a LatLng message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LatLng + */ + public static fromObject(object: { [k: string]: any }): google.type.LatLng; + + /** + * Creates a plain object from a LatLng message. Also converts values to other types if specified. + * @param message LatLng + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.type.LatLng, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LatLng to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -3912,6 +6012,27 @@ export namespace google { /** Status details. */ public details: google.protobuf.IAny[]; + + /** + * Creates a Status message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Status + */ + public static fromObject(object: { [k: string]: any }): google.rpc.Status; + + /** + * Creates a plain object from a Status message. Also converts values to other types if specified. + * @param message Status + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.rpc.Status, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Status to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } @@ -4083,6 +6204,27 @@ export namespace google { /** Operation result. */ public result?: ("error"|"response"); + + /** + * Creates an Operation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Operation + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.Operation; + + /** + * Creates a plain object from an Operation message. Also converts values to other types if specified. + * @param message Operation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.Operation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Operation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a GetOperationRequest. */ @@ -4103,6 +6245,27 @@ export namespace google { /** GetOperationRequest name. */ public name: string; + + /** + * Creates a GetOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.GetOperationRequest; + + /** + * Creates a plain object from a GetOperationRequest message. Also converts values to other types if specified. + * @param message GetOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.GetOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListOperationsRequest. */ @@ -4141,6 +6304,27 @@ export namespace google { /** ListOperationsRequest pageToken. */ public pageToken: string; + + /** + * Creates a ListOperationsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListOperationsRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.ListOperationsRequest; + + /** + * Creates a plain object from a ListOperationsRequest message. Also converts values to other types if specified. + * @param message ListOperationsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.ListOperationsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListOperationsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a ListOperationsResponse. */ @@ -4167,6 +6351,27 @@ export namespace google { /** ListOperationsResponse nextPageToken. */ public nextPageToken: string; + + /** + * Creates a ListOperationsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListOperationsResponse + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.ListOperationsResponse; + + /** + * Creates a plain object from a ListOperationsResponse message. Also converts values to other types if specified. + * @param message ListOperationsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.ListOperationsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListOperationsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a CancelOperationRequest. */ @@ -4187,6 +6392,27 @@ export namespace google { /** CancelOperationRequest name. */ public name: string; + + /** + * Creates a CancelOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CancelOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.CancelOperationRequest; + + /** + * Creates a plain object from a CancelOperationRequest message. Also converts values to other types if specified. + * @param message CancelOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.CancelOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CancelOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a DeleteOperationRequest. */ @@ -4207,6 +6433,27 @@ export namespace google { /** DeleteOperationRequest name. */ public name: string; + + /** + * Creates a DeleteOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.DeleteOperationRequest; + + /** + * Creates a plain object from a DeleteOperationRequest message. Also converts values to other types if specified. + * @param message DeleteOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.DeleteOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a WaitOperationRequest. */ @@ -4233,6 +6480,27 @@ export namespace google { /** WaitOperationRequest timeout. */ public timeout?: (google.protobuf.IDuration|null); + + /** + * Creates a WaitOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WaitOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.WaitOperationRequest; + + /** + * Creates a plain object from a WaitOperationRequest message. Also converts values to other types if specified. + * @param message WaitOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.WaitOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WaitOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of an OperationInfo. */ @@ -4259,6 +6527,27 @@ export namespace google { /** OperationInfo metadataType. */ public metadataType: string; + + /** + * Creates an OperationInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OperationInfo + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.OperationInfo; + + /** + * Creates a plain object from an OperationInfo message. Also converts values to other types if specified. + * @param message OperationInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.OperationInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OperationInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } } } diff --git a/dev/protos/firestore_v1beta1_proto_api.js b/dev/protos/firestore_v1beta1_proto_api.js index 02dcd65a2..35a0681fa 100644 --- a/dev/protos/firestore_v1beta1_proto_api.js +++ b/dev/protos/firestore_v1beta1_proto_api.js @@ -14,7418 +14,15588 @@ * limitations under the License. */ -// Common aliases -var $util = $protobuf.util; - -// Exported root namespace -var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); - -$root.google = (function() { - - /** - * Namespace google. - * @exports google - * @namespace - */ - var google = {}; - - google.protobuf = (function() { - +/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ +(function(global, factory) { /* global define, require, module */ + + /* AMD */ if (typeof define === 'function' && define.amd) + define(["protobufjs/minimal"], factory); + + /* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports) + module.exports = factory(require("protobufjs/minimal")); + +})(this, function($protobuf) { + "use strict"; + + // Common aliases + var $util = $protobuf.util; + + // Exported root namespace + var $root = $protobuf.roots.firestore_v1beta1 || ($protobuf.roots.firestore_v1beta1 = {}); + + $root.google = (function() { + /** - * Namespace protobuf. - * @memberof google + * Namespace google. + * @exports google * @namespace */ - var protobuf = {}; - - protobuf.Timestamp = (function() { - - /** - * Properties of a Timestamp. - * @memberof google.protobuf - * @interface ITimestamp - * @property {number|null} [seconds] Timestamp seconds - * @property {number|null} [nanos] Timestamp nanos - */ - - /** - * Constructs a new Timestamp. - * @memberof google.protobuf - * @classdesc Represents a Timestamp. - * @implements ITimestamp - * @constructor - * @param {google.protobuf.ITimestamp=} [properties] Properties to set - */ - function Timestamp(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Timestamp seconds. - * @member {number} seconds - * @memberof google.protobuf.Timestamp - * @instance - */ - Timestamp.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Timestamp nanos. - * @member {number} nanos - * @memberof google.protobuf.Timestamp - * @instance - */ - Timestamp.prototype.nanos = 0; - - return Timestamp; - })(); - - protobuf.FileDescriptorSet = (function() { - - /** - * Properties of a FileDescriptorSet. - * @memberof google.protobuf - * @interface IFileDescriptorSet - * @property {Array.|null} [file] FileDescriptorSet file - */ - - /** - * Constructs a new FileDescriptorSet. - * @memberof google.protobuf - * @classdesc Represents a FileDescriptorSet. - * @implements IFileDescriptorSet - * @constructor - * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set - */ - function FileDescriptorSet(properties) { - this.file = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FileDescriptorSet file. - * @member {Array.} file - * @memberof google.protobuf.FileDescriptorSet - * @instance - */ - FileDescriptorSet.prototype.file = $util.emptyArray; - - return FileDescriptorSet; - })(); - - protobuf.FileDescriptorProto = (function() { - - /** - * Properties of a FileDescriptorProto. - * @memberof google.protobuf - * @interface IFileDescriptorProto - * @property {string|null} [name] FileDescriptorProto name - * @property {string|null} ["package"] FileDescriptorProto package - * @property {Array.|null} [dependency] FileDescriptorProto dependency - * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency - * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency - * @property {Array.|null} [messageType] FileDescriptorProto messageType - * @property {Array.|null} [enumType] FileDescriptorProto enumType - * @property {Array.|null} [service] FileDescriptorProto service - * @property {Array.|null} [extension] FileDescriptorProto extension - * @property {google.protobuf.IFileOptions|null} [options] FileDescriptorProto options - * @property {google.protobuf.ISourceCodeInfo|null} [sourceCodeInfo] FileDescriptorProto sourceCodeInfo - * @property {string|null} [syntax] FileDescriptorProto syntax - */ - - /** - * Constructs a new FileDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents a FileDescriptorProto. - * @implements IFileDescriptorProto - * @constructor - * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set - */ - function FileDescriptorProto(properties) { - this.dependency = []; - this.publicDependency = []; - this.weakDependency = []; - this.messageType = []; - this.enumType = []; - this.service = []; - this.extension = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FileDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.name = ""; - - /** - * FileDescriptorProto package. - * @member {string} package - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype["package"] = ""; - - /** - * FileDescriptorProto dependency. - * @member {Array.} dependency - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.dependency = $util.emptyArray; - - /** - * FileDescriptorProto publicDependency. - * @member {Array.} publicDependency - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.publicDependency = $util.emptyArray; - - /** - * FileDescriptorProto weakDependency. - * @member {Array.} weakDependency - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.weakDependency = $util.emptyArray; - - /** - * FileDescriptorProto messageType. - * @member {Array.} messageType - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.messageType = $util.emptyArray; - - /** - * FileDescriptorProto enumType. - * @member {Array.} enumType - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.enumType = $util.emptyArray; - - /** - * FileDescriptorProto service. - * @member {Array.} service - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.service = $util.emptyArray; - + var google = {}; + + google.protobuf = (function() { + /** - * FileDescriptorProto extension. - * @member {Array.} extension - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.extension = $util.emptyArray; - - /** - * FileDescriptorProto options. - * @member {google.protobuf.IFileOptions|null|undefined} options - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.options = null; - - /** - * FileDescriptorProto sourceCodeInfo. - * @member {google.protobuf.ISourceCodeInfo|null|undefined} sourceCodeInfo - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.sourceCodeInfo = null; - - /** - * FileDescriptorProto syntax. - * @member {string} syntax - * @memberof google.protobuf.FileDescriptorProto - * @instance - */ - FileDescriptorProto.prototype.syntax = ""; - - return FileDescriptorProto; - })(); - - protobuf.DescriptorProto = (function() { - - /** - * Properties of a DescriptorProto. - * @memberof google.protobuf - * @interface IDescriptorProto - * @property {string|null} [name] DescriptorProto name - * @property {Array.|null} [field] DescriptorProto field - * @property {Array.|null} [extension] DescriptorProto extension - * @property {Array.|null} [nestedType] DescriptorProto nestedType - * @property {Array.|null} [enumType] DescriptorProto enumType - * @property {Array.|null} [extensionRange] DescriptorProto extensionRange - * @property {Array.|null} [oneofDecl] DescriptorProto oneofDecl - * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options - * @property {Array.|null} [reservedRange] DescriptorProto reservedRange - * @property {Array.|null} [reservedName] DescriptorProto reservedName - */ - - /** - * Constructs a new DescriptorProto. - * @memberof google.protobuf - * @classdesc Represents a DescriptorProto. - * @implements IDescriptorProto - * @constructor - * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set - */ - function DescriptorProto(properties) { - this.field = []; - this.extension = []; - this.nestedType = []; - this.enumType = []; - this.extensionRange = []; - this.oneofDecl = []; - this.reservedRange = []; - this.reservedName = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DescriptorProto name. - * @member {string} name - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.name = ""; - - /** - * DescriptorProto field. - * @member {Array.} field - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.field = $util.emptyArray; - - /** - * DescriptorProto extension. - * @member {Array.} extension - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.extension = $util.emptyArray; - - /** - * DescriptorProto nestedType. - * @member {Array.} nestedType - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.nestedType = $util.emptyArray; - - /** - * DescriptorProto enumType. - * @member {Array.} enumType - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.enumType = $util.emptyArray; - - /** - * DescriptorProto extensionRange. - * @member {Array.} extensionRange - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.extensionRange = $util.emptyArray; - - /** - * DescriptorProto oneofDecl. - * @member {Array.} oneofDecl - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.oneofDecl = $util.emptyArray; - - /** - * DescriptorProto options. - * @member {google.protobuf.IMessageOptions|null|undefined} options - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.options = null; - - /** - * DescriptorProto reservedRange. - * @member {Array.} reservedRange - * @memberof google.protobuf.DescriptorProto - * @instance - */ - DescriptorProto.prototype.reservedRange = $util.emptyArray; - - /** - * DescriptorProto reservedName. - * @member {Array.} reservedName - * @memberof google.protobuf.DescriptorProto - * @instance + * Namespace protobuf. + * @memberof google + * @namespace */ - DescriptorProto.prototype.reservedName = $util.emptyArray; - - DescriptorProto.ExtensionRange = (function() { - + var protobuf = {}; + + protobuf.Timestamp = (function() { + /** - * Properties of an ExtensionRange. - * @memberof google.protobuf.DescriptorProto - * @interface IExtensionRange - * @property {number|null} [start] ExtensionRange start - * @property {number|null} [end] ExtensionRange end + * Properties of a Timestamp. + * @memberof google.protobuf + * @interface ITimestamp + * @property {number|string|null} [seconds] Timestamp seconds + * @property {number|null} [nanos] Timestamp nanos */ - + /** - * Constructs a new ExtensionRange. - * @memberof google.protobuf.DescriptorProto - * @classdesc Represents an ExtensionRange. - * @implements IExtensionRange + * Constructs a new Timestamp. + * @memberof google.protobuf + * @classdesc Represents a Timestamp. + * @implements ITimestamp * @constructor - * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set + * @param {google.protobuf.ITimestamp=} [properties] Properties to set */ - function ExtensionRange(properties) { + function Timestamp(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + + /** + * Timestamp seconds. + * @member {number|string} seconds + * @memberof google.protobuf.Timestamp + * @instance + */ + Timestamp.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Timestamp nanos. + * @member {number} nanos + * @memberof google.protobuf.Timestamp + * @instance + */ + Timestamp.prototype.nanos = 0; + + /** + * Creates a Timestamp message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Timestamp + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Timestamp} Timestamp + */ + Timestamp.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Timestamp) + return object; + var message = new $root.google.protobuf.Timestamp(); + if (object.seconds != null) + if ($util.Long) + (message.seconds = $util.Long.fromValue(object.seconds)).unsigned = false; + else if (typeof object.seconds === "string") + message.seconds = parseInt(object.seconds, 10); + else if (typeof object.seconds === "number") + message.seconds = object.seconds; + else if (typeof object.seconds === "object") + message.seconds = new $util.LongBits(object.seconds.low >>> 0, object.seconds.high >>> 0).toNumber(); + if (object.nanos != null) + message.nanos = object.nanos | 0; + return message; + }; + + /** + * Creates a plain object from a Timestamp message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.Timestamp} message Timestamp + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Timestamp.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.seconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.seconds = options.longs === String ? "0" : 0; + object.nanos = 0; + } + if (message.seconds != null && message.hasOwnProperty("seconds")) + if (typeof message.seconds === "number") + object.seconds = options.longs === String ? String(message.seconds) : message.seconds; + else + object.seconds = options.longs === String ? $util.Long.prototype.toString.call(message.seconds) : options.longs === Number ? new $util.LongBits(message.seconds.low >>> 0, message.seconds.high >>> 0).toNumber() : message.seconds; + if (message.nanos != null && message.hasOwnProperty("nanos")) + object.nanos = message.nanos; + return object; + }; + + /** + * Converts this Timestamp to JSON. + * @function toJSON + * @memberof google.protobuf.Timestamp + * @instance + * @returns {Object.} JSON object + */ + Timestamp.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Timestamp; + })(); + + protobuf.FileDescriptorSet = (function() { + /** - * ExtensionRange start. - * @member {number} start - * @memberof google.protobuf.DescriptorProto.ExtensionRange - * @instance + * Properties of a FileDescriptorSet. + * @memberof google.protobuf + * @interface IFileDescriptorSet + * @property {Array.|null} [file] FileDescriptorSet file */ - ExtensionRange.prototype.start = 0; - + + /** + * Constructs a new FileDescriptorSet. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorSet. + * @implements IFileDescriptorSet + * @constructor + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + */ + function FileDescriptorSet(properties) { + this.file = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FileDescriptorSet file. + * @member {Array.} file + * @memberof google.protobuf.FileDescriptorSet + * @instance + */ + FileDescriptorSet.prototype.file = $util.emptyArray; + + /** + * Creates a FileDescriptorSet message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + */ + FileDescriptorSet.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileDescriptorSet) + return object; + var message = new $root.google.protobuf.FileDescriptorSet(); + if (object.file) { + if (!Array.isArray(object.file)) + throw TypeError(".google.protobuf.FileDescriptorSet.file: array expected"); + message.file = []; + for (var i = 0; i < object.file.length; ++i) { + if (typeof object.file[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorSet.file: object expected"); + message.file[i] = $root.google.protobuf.FileDescriptorProto.fromObject(object.file[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a FileDescriptorSet message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.FileDescriptorSet} message FileDescriptorSet + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileDescriptorSet.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.file = []; + if (message.file && message.file.length) { + object.file = []; + for (var j = 0; j < message.file.length; ++j) + object.file[j] = $root.google.protobuf.FileDescriptorProto.toObject(message.file[j], options); + } + return object; + }; + /** - * ExtensionRange end. - * @member {number} end - * @memberof google.protobuf.DescriptorProto.ExtensionRange + * Converts this FileDescriptorSet to JSON. + * @function toJSON + * @memberof google.protobuf.FileDescriptorSet * @instance + * @returns {Object.} JSON object */ - ExtensionRange.prototype.end = 0; - - return ExtensionRange; + FileDescriptorSet.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FileDescriptorSet; })(); - - DescriptorProto.ReservedRange = (function() { - + + protobuf.FileDescriptorProto = (function() { + + /** + * Properties of a FileDescriptorProto. + * @memberof google.protobuf + * @interface IFileDescriptorProto + * @property {string|null} [name] FileDescriptorProto name + * @property {string|null} ["package"] FileDescriptorProto package + * @property {Array.|null} [dependency] FileDescriptorProto dependency + * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency + * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [messageType] FileDescriptorProto messageType + * @property {Array.|null} [enumType] FileDescriptorProto enumType + * @property {Array.|null} [service] FileDescriptorProto service + * @property {Array.|null} [extension] FileDescriptorProto extension + * @property {google.protobuf.IFileOptions|null} [options] FileDescriptorProto options + * @property {google.protobuf.ISourceCodeInfo|null} [sourceCodeInfo] FileDescriptorProto sourceCodeInfo + * @property {string|null} [syntax] FileDescriptorProto syntax + */ + + /** + * Constructs a new FileDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorProto. + * @implements IFileDescriptorProto + * @constructor + * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set + */ + function FileDescriptorProto(properties) { + this.dependency = []; + this.publicDependency = []; + this.weakDependency = []; + this.messageType = []; + this.enumType = []; + this.service = []; + this.extension = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + /** - * Properties of a ReservedRange. - * @memberof google.protobuf.DescriptorProto - * @interface IReservedRange - * @property {number|null} [start] ReservedRange start - * @property {number|null} [end] ReservedRange end + * FileDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FileDescriptorProto + * @instance */ - + FileDescriptorProto.prototype.name = ""; + /** - * Constructs a new ReservedRange. - * @memberof google.protobuf.DescriptorProto - * @classdesc Represents a ReservedRange. - * @implements IReservedRange - * @constructor - * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set + * FileDescriptorProto package. + * @member {string} package + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype["package"] = ""; + + /** + * FileDescriptorProto dependency. + * @member {Array.} dependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.dependency = $util.emptyArray; + + /** + * FileDescriptorProto publicDependency. + * @member {Array.} publicDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.publicDependency = $util.emptyArray; + + /** + * FileDescriptorProto weakDependency. + * @member {Array.} weakDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + + /** + * FileDescriptorProto messageType. + * @member {Array.} messageType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.messageType = $util.emptyArray; + + /** + * FileDescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.enumType = $util.emptyArray; + + /** + * FileDescriptorProto service. + * @member {Array.} service + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.service = $util.emptyArray; + + /** + * FileDescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.extension = $util.emptyArray; + + /** + * FileDescriptorProto options. + * @member {google.protobuf.IFileOptions|null|undefined} options + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.options = null; + + /** + * FileDescriptorProto sourceCodeInfo. + * @member {google.protobuf.ISourceCodeInfo|null|undefined} sourceCodeInfo + * @memberof google.protobuf.FileDescriptorProto + * @instance */ - function ReservedRange(properties) { + FileDescriptorProto.prototype.sourceCodeInfo = null; + + /** + * FileDescriptorProto syntax. + * @member {string} syntax + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.syntax = ""; + + /** + * Creates a FileDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + */ + FileDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileDescriptorProto) + return object; + var message = new $root.google.protobuf.FileDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object["package"] != null) + message["package"] = String(object["package"]); + if (object.dependency) { + if (!Array.isArray(object.dependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.dependency: array expected"); + message.dependency = []; + for (var i = 0; i < object.dependency.length; ++i) + message.dependency[i] = String(object.dependency[i]); + } + if (object.publicDependency) { + if (!Array.isArray(object.publicDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.publicDependency: array expected"); + message.publicDependency = []; + for (var i = 0; i < object.publicDependency.length; ++i) + message.publicDependency[i] = object.publicDependency[i] | 0; + } + if (object.weakDependency) { + if (!Array.isArray(object.weakDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.weakDependency: array expected"); + message.weakDependency = []; + for (var i = 0; i < object.weakDependency.length; ++i) + message.weakDependency[i] = object.weakDependency[i] | 0; + } + if (object.messageType) { + if (!Array.isArray(object.messageType)) + throw TypeError(".google.protobuf.FileDescriptorProto.messageType: array expected"); + message.messageType = []; + for (var i = 0; i < object.messageType.length; ++i) { + if (typeof object.messageType[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.messageType: object expected"); + message.messageType[i] = $root.google.protobuf.DescriptorProto.fromObject(object.messageType[i]); + } + } + if (object.enumType) { + if (!Array.isArray(object.enumType)) + throw TypeError(".google.protobuf.FileDescriptorProto.enumType: array expected"); + message.enumType = []; + for (var i = 0; i < object.enumType.length; ++i) { + if (typeof object.enumType[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.enumType: object expected"); + message.enumType[i] = $root.google.protobuf.EnumDescriptorProto.fromObject(object.enumType[i]); + } + } + if (object.service) { + if (!Array.isArray(object.service)) + throw TypeError(".google.protobuf.FileDescriptorProto.service: array expected"); + message.service = []; + for (var i = 0; i < object.service.length; ++i) { + if (typeof object.service[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.service: object expected"); + message.service[i] = $root.google.protobuf.ServiceDescriptorProto.fromObject(object.service[i]); + } + } + if (object.extension) { + if (!Array.isArray(object.extension)) + throw TypeError(".google.protobuf.FileDescriptorProto.extension: array expected"); + message.extension = []; + for (var i = 0; i < object.extension.length; ++i) { + if (typeof object.extension[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.extension: object expected"); + message.extension[i] = $root.google.protobuf.FieldDescriptorProto.fromObject(object.extension[i]); + } + } + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.FileOptions.fromObject(object.options); + } + if (object.sourceCodeInfo != null) { + if (typeof object.sourceCodeInfo !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.sourceCodeInfo: object expected"); + message.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.fromObject(object.sourceCodeInfo); + } + if (object.syntax != null) + message.syntax = String(object.syntax); + return message; + }; + + /** + * Creates a plain object from a FileDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.FileDescriptorProto} message FileDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.dependency = []; + object.messageType = []; + object.enumType = []; + object.service = []; + object.extension = []; + object.publicDependency = []; + object.weakDependency = []; + } + if (options.defaults) { + object.name = ""; + object["package"] = ""; + object.options = null; + object.sourceCodeInfo = null; + object.syntax = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message["package"] != null && message.hasOwnProperty("package")) + object["package"] = message["package"]; + if (message.dependency && message.dependency.length) { + object.dependency = []; + for (var j = 0; j < message.dependency.length; ++j) + object.dependency[j] = message.dependency[j]; + } + if (message.messageType && message.messageType.length) { + object.messageType = []; + for (var j = 0; j < message.messageType.length; ++j) + object.messageType[j] = $root.google.protobuf.DescriptorProto.toObject(message.messageType[j], options); + } + if (message.enumType && message.enumType.length) { + object.enumType = []; + for (var j = 0; j < message.enumType.length; ++j) + object.enumType[j] = $root.google.protobuf.EnumDescriptorProto.toObject(message.enumType[j], options); + } + if (message.service && message.service.length) { + object.service = []; + for (var j = 0; j < message.service.length; ++j) + object.service[j] = $root.google.protobuf.ServiceDescriptorProto.toObject(message.service[j], options); + } + if (message.extension && message.extension.length) { + object.extension = []; + for (var j = 0; j < message.extension.length; ++j) + object.extension[j] = $root.google.protobuf.FieldDescriptorProto.toObject(message.extension[j], options); + } + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.FileOptions.toObject(message.options, options); + if (message.sourceCodeInfo != null && message.hasOwnProperty("sourceCodeInfo")) + object.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.toObject(message.sourceCodeInfo, options); + if (message.publicDependency && message.publicDependency.length) { + object.publicDependency = []; + for (var j = 0; j < message.publicDependency.length; ++j) + object.publicDependency[j] = message.publicDependency[j]; + } + if (message.weakDependency && message.weakDependency.length) { + object.weakDependency = []; + for (var j = 0; j < message.weakDependency.length; ++j) + object.weakDependency[j] = message.weakDependency[j]; + } + if (message.syntax != null && message.hasOwnProperty("syntax")) + object.syntax = message.syntax; + return object; + }; + + /** + * Converts this FileDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.FileDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + FileDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FileDescriptorProto; + })(); + + protobuf.DescriptorProto = (function() { + + /** + * Properties of a DescriptorProto. + * @memberof google.protobuf + * @interface IDescriptorProto + * @property {string|null} [name] DescriptorProto name + * @property {Array.|null} [field] DescriptorProto field + * @property {Array.|null} [extension] DescriptorProto extension + * @property {Array.|null} [nestedType] DescriptorProto nestedType + * @property {Array.|null} [enumType] DescriptorProto enumType + * @property {Array.|null} [extensionRange] DescriptorProto extensionRange + * @property {Array.|null} [oneofDecl] DescriptorProto oneofDecl + * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options + * @property {Array.|null} [reservedRange] DescriptorProto reservedRange + * @property {Array.|null} [reservedName] DescriptorProto reservedName + */ + + /** + * Constructs a new DescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a DescriptorProto. + * @implements IDescriptorProto + * @constructor + * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set + */ + function DescriptorProto(properties) { + this.field = []; + this.extension = []; + this.nestedType = []; + this.enumType = []; + this.extensionRange = []; + this.oneofDecl = []; + this.reservedRange = []; + this.reservedName = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * ReservedRange start. - * @member {number} start - * @memberof google.protobuf.DescriptorProto.ReservedRange + * DescriptorProto name. + * @member {string} name + * @memberof google.protobuf.DescriptorProto * @instance */ - ReservedRange.prototype.start = 0; - + DescriptorProto.prototype.name = ""; + /** - * ReservedRange end. - * @member {number} end - * @memberof google.protobuf.DescriptorProto.ReservedRange + * DescriptorProto field. + * @member {Array.} field + * @memberof google.protobuf.DescriptorProto * @instance */ - ReservedRange.prototype.end = 0; - - return ReservedRange; - })(); - - return DescriptorProto; - })(); - - protobuf.FieldDescriptorProto = (function() { - - /** - * Properties of a FieldDescriptorProto. - * @memberof google.protobuf - * @interface IFieldDescriptorProto - * @property {string|null} [name] FieldDescriptorProto name - * @property {number|null} [number] FieldDescriptorProto number - * @property {google.protobuf.FieldDescriptorProto.Label|null} [label] FieldDescriptorProto label - * @property {google.protobuf.FieldDescriptorProto.Type|null} [type] FieldDescriptorProto type - * @property {string|null} [typeName] FieldDescriptorProto typeName - * @property {string|null} [extendee] FieldDescriptorProto extendee - * @property {string|null} [defaultValue] FieldDescriptorProto defaultValue - * @property {number|null} [oneofIndex] FieldDescriptorProto oneofIndex - * @property {string|null} [jsonName] FieldDescriptorProto jsonName - * @property {google.protobuf.IFieldOptions|null} [options] FieldDescriptorProto options - */ - - /** - * Constructs a new FieldDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents a FieldDescriptorProto. - * @implements IFieldDescriptorProto - * @constructor - * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set - */ - function FieldDescriptorProto(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FieldDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.name = ""; - - /** - * FieldDescriptorProto number. - * @member {number} number - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.number = 0; - - /** - * FieldDescriptorProto label. - * @member {google.protobuf.FieldDescriptorProto.Label} label - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.label = 1; - - /** - * FieldDescriptorProto type. - * @member {google.protobuf.FieldDescriptorProto.Type} type - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.type = 1; - - /** - * FieldDescriptorProto typeName. - * @member {string} typeName - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.typeName = ""; - - /** - * FieldDescriptorProto extendee. - * @member {string} extendee - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.extendee = ""; - - /** - * FieldDescriptorProto defaultValue. - * @member {string} defaultValue - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.defaultValue = ""; - - /** - * FieldDescriptorProto oneofIndex. - * @member {number} oneofIndex - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.oneofIndex = 0; - - /** - * FieldDescriptorProto jsonName. - * @member {string} jsonName - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.jsonName = ""; - - /** - * FieldDescriptorProto options. - * @member {google.protobuf.IFieldOptions|null|undefined} options - * @memberof google.protobuf.FieldDescriptorProto - * @instance - */ - FieldDescriptorProto.prototype.options = null; - - /** - * Type enum. - * @name google.protobuf.FieldDescriptorProto.Type - * @enum {number} - * @property {string} TYPE_DOUBLE=TYPE_DOUBLE TYPE_DOUBLE value - * @property {string} TYPE_FLOAT=TYPE_FLOAT TYPE_FLOAT value - * @property {string} TYPE_INT64=TYPE_INT64 TYPE_INT64 value - * @property {string} TYPE_UINT64=TYPE_UINT64 TYPE_UINT64 value - * @property {string} TYPE_INT32=TYPE_INT32 TYPE_INT32 value - * @property {string} TYPE_FIXED64=TYPE_FIXED64 TYPE_FIXED64 value - * @property {string} TYPE_FIXED32=TYPE_FIXED32 TYPE_FIXED32 value - * @property {string} TYPE_BOOL=TYPE_BOOL TYPE_BOOL value - * @property {string} TYPE_STRING=TYPE_STRING TYPE_STRING value - * @property {string} TYPE_GROUP=TYPE_GROUP TYPE_GROUP value - * @property {string} TYPE_MESSAGE=TYPE_MESSAGE TYPE_MESSAGE value - * @property {string} TYPE_BYTES=TYPE_BYTES TYPE_BYTES value - * @property {string} TYPE_UINT32=TYPE_UINT32 TYPE_UINT32 value - * @property {string} TYPE_ENUM=TYPE_ENUM TYPE_ENUM value - * @property {string} TYPE_SFIXED32=TYPE_SFIXED32 TYPE_SFIXED32 value - * @property {string} TYPE_SFIXED64=TYPE_SFIXED64 TYPE_SFIXED64 value - * @property {string} TYPE_SINT32=TYPE_SINT32 TYPE_SINT32 value - * @property {string} TYPE_SINT64=TYPE_SINT64 TYPE_SINT64 value - */ - FieldDescriptorProto.Type = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[1] = "TYPE_DOUBLE"] = "TYPE_DOUBLE"; - values[valuesById[2] = "TYPE_FLOAT"] = "TYPE_FLOAT"; - values[valuesById[3] = "TYPE_INT64"] = "TYPE_INT64"; - values[valuesById[4] = "TYPE_UINT64"] = "TYPE_UINT64"; - values[valuesById[5] = "TYPE_INT32"] = "TYPE_INT32"; - values[valuesById[6] = "TYPE_FIXED64"] = "TYPE_FIXED64"; - values[valuesById[7] = "TYPE_FIXED32"] = "TYPE_FIXED32"; - values[valuesById[8] = "TYPE_BOOL"] = "TYPE_BOOL"; - values[valuesById[9] = "TYPE_STRING"] = "TYPE_STRING"; - values[valuesById[10] = "TYPE_GROUP"] = "TYPE_GROUP"; - values[valuesById[11] = "TYPE_MESSAGE"] = "TYPE_MESSAGE"; - values[valuesById[12] = "TYPE_BYTES"] = "TYPE_BYTES"; - values[valuesById[13] = "TYPE_UINT32"] = "TYPE_UINT32"; - values[valuesById[14] = "TYPE_ENUM"] = "TYPE_ENUM"; - values[valuesById[15] = "TYPE_SFIXED32"] = "TYPE_SFIXED32"; - values[valuesById[16] = "TYPE_SFIXED64"] = "TYPE_SFIXED64"; - values[valuesById[17] = "TYPE_SINT32"] = "TYPE_SINT32"; - values[valuesById[18] = "TYPE_SINT64"] = "TYPE_SINT64"; - return values; - })(); - - /** - * Label enum. - * @name google.protobuf.FieldDescriptorProto.Label - * @enum {number} - * @property {string} LABEL_OPTIONAL=LABEL_OPTIONAL LABEL_OPTIONAL value - * @property {string} LABEL_REQUIRED=LABEL_REQUIRED LABEL_REQUIRED value - * @property {string} LABEL_REPEATED=LABEL_REPEATED LABEL_REPEATED value - */ - FieldDescriptorProto.Label = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[1] = "LABEL_OPTIONAL"] = "LABEL_OPTIONAL"; - values[valuesById[2] = "LABEL_REQUIRED"] = "LABEL_REQUIRED"; - values[valuesById[3] = "LABEL_REPEATED"] = "LABEL_REPEATED"; - return values; + DescriptorProto.prototype.field = $util.emptyArray; + + /** + * DescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extension = $util.emptyArray; + + /** + * DescriptorProto nestedType. + * @member {Array.} nestedType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.nestedType = $util.emptyArray; + + /** + * DescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.enumType = $util.emptyArray; + + /** + * DescriptorProto extensionRange. + * @member {Array.} extensionRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extensionRange = $util.emptyArray; + + /** + * DescriptorProto oneofDecl. + * @member {Array.} oneofDecl + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.oneofDecl = $util.emptyArray; + + /** + * DescriptorProto options. + * @member {google.protobuf.IMessageOptions|null|undefined} options + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.options = null; + + /** + * DescriptorProto reservedRange. + * @member {Array.} reservedRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedRange = $util.emptyArray; + + /** + * DescriptorProto reservedName. + * @member {Array.} reservedName + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedName = $util.emptyArray; + + /** + * Creates a DescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto} DescriptorProto + */ + DescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DescriptorProto) + return object; + var message = new $root.google.protobuf.DescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.field) { + if (!Array.isArray(object.field)) + throw TypeError(".google.protobuf.DescriptorProto.field: array expected"); + message.field = []; + for (var i = 0; i < object.field.length; ++i) { + if (typeof object.field[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.field: object expected"); + message.field[i] = $root.google.protobuf.FieldDescriptorProto.fromObject(object.field[i]); + } + } + if (object.extension) { + if (!Array.isArray(object.extension)) + throw TypeError(".google.protobuf.DescriptorProto.extension: array expected"); + message.extension = []; + for (var i = 0; i < object.extension.length; ++i) { + if (typeof object.extension[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.extension: object expected"); + message.extension[i] = $root.google.protobuf.FieldDescriptorProto.fromObject(object.extension[i]); + } + } + if (object.nestedType) { + if (!Array.isArray(object.nestedType)) + throw TypeError(".google.protobuf.DescriptorProto.nestedType: array expected"); + message.nestedType = []; + for (var i = 0; i < object.nestedType.length; ++i) { + if (typeof object.nestedType[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.nestedType: object expected"); + message.nestedType[i] = $root.google.protobuf.DescriptorProto.fromObject(object.nestedType[i]); + } + } + if (object.enumType) { + if (!Array.isArray(object.enumType)) + throw TypeError(".google.protobuf.DescriptorProto.enumType: array expected"); + message.enumType = []; + for (var i = 0; i < object.enumType.length; ++i) { + if (typeof object.enumType[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.enumType: object expected"); + message.enumType[i] = $root.google.protobuf.EnumDescriptorProto.fromObject(object.enumType[i]); + } + } + if (object.extensionRange) { + if (!Array.isArray(object.extensionRange)) + throw TypeError(".google.protobuf.DescriptorProto.extensionRange: array expected"); + message.extensionRange = []; + for (var i = 0; i < object.extensionRange.length; ++i) { + if (typeof object.extensionRange[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.extensionRange: object expected"); + message.extensionRange[i] = $root.google.protobuf.DescriptorProto.ExtensionRange.fromObject(object.extensionRange[i]); + } + } + if (object.oneofDecl) { + if (!Array.isArray(object.oneofDecl)) + throw TypeError(".google.protobuf.DescriptorProto.oneofDecl: array expected"); + message.oneofDecl = []; + for (var i = 0; i < object.oneofDecl.length; ++i) { + if (typeof object.oneofDecl[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.oneofDecl: object expected"); + message.oneofDecl[i] = $root.google.protobuf.OneofDescriptorProto.fromObject(object.oneofDecl[i]); + } + } + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.DescriptorProto.options: object expected"); + message.options = $root.google.protobuf.MessageOptions.fromObject(object.options); + } + if (object.reservedRange) { + if (!Array.isArray(object.reservedRange)) + throw TypeError(".google.protobuf.DescriptorProto.reservedRange: array expected"); + message.reservedRange = []; + for (var i = 0; i < object.reservedRange.length; ++i) { + if (typeof object.reservedRange[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.reservedRange: object expected"); + message.reservedRange[i] = $root.google.protobuf.DescriptorProto.ReservedRange.fromObject(object.reservedRange[i]); + } + } + if (object.reservedName) { + if (!Array.isArray(object.reservedName)) + throw TypeError(".google.protobuf.DescriptorProto.reservedName: array expected"); + message.reservedName = []; + for (var i = 0; i < object.reservedName.length; ++i) + message.reservedName[i] = String(object.reservedName[i]); + } + return message; + }; + + /** + * Creates a plain object from a DescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.DescriptorProto} message DescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.field = []; + object.nestedType = []; + object.enumType = []; + object.extensionRange = []; + object.extension = []; + object.oneofDecl = []; + object.reservedRange = []; + object.reservedName = []; + } + if (options.defaults) { + object.name = ""; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.field && message.field.length) { + object.field = []; + for (var j = 0; j < message.field.length; ++j) + object.field[j] = $root.google.protobuf.FieldDescriptorProto.toObject(message.field[j], options); + } + if (message.nestedType && message.nestedType.length) { + object.nestedType = []; + for (var j = 0; j < message.nestedType.length; ++j) + object.nestedType[j] = $root.google.protobuf.DescriptorProto.toObject(message.nestedType[j], options); + } + if (message.enumType && message.enumType.length) { + object.enumType = []; + for (var j = 0; j < message.enumType.length; ++j) + object.enumType[j] = $root.google.protobuf.EnumDescriptorProto.toObject(message.enumType[j], options); + } + if (message.extensionRange && message.extensionRange.length) { + object.extensionRange = []; + for (var j = 0; j < message.extensionRange.length; ++j) + object.extensionRange[j] = $root.google.protobuf.DescriptorProto.ExtensionRange.toObject(message.extensionRange[j], options); + } + if (message.extension && message.extension.length) { + object.extension = []; + for (var j = 0; j < message.extension.length; ++j) + object.extension[j] = $root.google.protobuf.FieldDescriptorProto.toObject(message.extension[j], options); + } + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.MessageOptions.toObject(message.options, options); + if (message.oneofDecl && message.oneofDecl.length) { + object.oneofDecl = []; + for (var j = 0; j < message.oneofDecl.length; ++j) + object.oneofDecl[j] = $root.google.protobuf.OneofDescriptorProto.toObject(message.oneofDecl[j], options); + } + if (message.reservedRange && message.reservedRange.length) { + object.reservedRange = []; + for (var j = 0; j < message.reservedRange.length; ++j) + object.reservedRange[j] = $root.google.protobuf.DescriptorProto.ReservedRange.toObject(message.reservedRange[j], options); + } + if (message.reservedName && message.reservedName.length) { + object.reservedName = []; + for (var j = 0; j < message.reservedName.length; ++j) + object.reservedName[j] = message.reservedName[j]; + } + return object; + }; + + /** + * Converts this DescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto + * @instance + * @returns {Object.} JSON object + */ + DescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + DescriptorProto.ExtensionRange = (function() { + + /** + * Properties of an ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @interface IExtensionRange + * @property {number|null} [start] ExtensionRange start + * @property {number|null} [end] ExtensionRange end + */ + + /** + * Constructs a new ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents an ExtensionRange. + * @implements IExtensionRange + * @constructor + * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set + */ + function ExtensionRange(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExtensionRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.start = 0; + + /** + * ExtensionRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.end = 0; + + /** + * Creates an ExtensionRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + */ + ExtensionRange.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DescriptorProto.ExtensionRange) + return object; + var message = new $root.google.protobuf.DescriptorProto.ExtensionRange(); + if (object.start != null) + message.start = object.start | 0; + if (object.end != null) + message.end = object.end | 0; + return message; + }; + + /** + * Creates a plain object from an ExtensionRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.ExtensionRange} message ExtensionRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExtensionRange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.start = 0; + object.end = 0; + } + if (message.start != null && message.hasOwnProperty("start")) + object.start = message.start; + if (message.end != null && message.hasOwnProperty("end")) + object.end = message.end; + return object; + }; + + /** + * Converts this ExtensionRange to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + * @returns {Object.} JSON object + */ + ExtensionRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ExtensionRange; + })(); + + DescriptorProto.ReservedRange = (function() { + + /** + * Properties of a ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @interface IReservedRange + * @property {number|null} [start] ReservedRange start + * @property {number|null} [end] ReservedRange end + */ + + /** + * Constructs a new ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents a ReservedRange. + * @implements IReservedRange + * @constructor + * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set + */ + function ReservedRange(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReservedRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.start = 0; + + /** + * ReservedRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.end = 0; + + /** + * Creates a ReservedRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + */ + ReservedRange.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DescriptorProto.ReservedRange) + return object; + var message = new $root.google.protobuf.DescriptorProto.ReservedRange(); + if (object.start != null) + message.start = object.start | 0; + if (object.end != null) + message.end = object.end | 0; + return message; + }; + + /** + * Creates a plain object from a ReservedRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.ReservedRange} message ReservedRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReservedRange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.start = 0; + object.end = 0; + } + if (message.start != null && message.hasOwnProperty("start")) + object.start = message.start; + if (message.end != null && message.hasOwnProperty("end")) + object.end = message.end; + return object; + }; + + /** + * Converts this ReservedRange to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + * @returns {Object.} JSON object + */ + ReservedRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ReservedRange; + })(); + + return DescriptorProto; })(); - - return FieldDescriptorProto; - })(); - - protobuf.OneofDescriptorProto = (function() { - - /** - * Properties of an OneofDescriptorProto. - * @memberof google.protobuf - * @interface IOneofDescriptorProto - * @property {string|null} [name] OneofDescriptorProto name - * @property {google.protobuf.IOneofOptions|null} [options] OneofDescriptorProto options - */ - - /** - * Constructs a new OneofDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents an OneofDescriptorProto. - * @implements IOneofDescriptorProto - * @constructor - * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set - */ - function OneofDescriptorProto(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * OneofDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.OneofDescriptorProto - * @instance - */ - OneofDescriptorProto.prototype.name = ""; - - /** - * OneofDescriptorProto options. - * @member {google.protobuf.IOneofOptions|null|undefined} options - * @memberof google.protobuf.OneofDescriptorProto - * @instance - */ - OneofDescriptorProto.prototype.options = null; - - return OneofDescriptorProto; - })(); - - protobuf.EnumDescriptorProto = (function() { - - /** - * Properties of an EnumDescriptorProto. - * @memberof google.protobuf - * @interface IEnumDescriptorProto - * @property {string|null} [name] EnumDescriptorProto name - * @property {Array.|null} [value] EnumDescriptorProto value - * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options - */ - - /** - * Constructs a new EnumDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents an EnumDescriptorProto. - * @implements IEnumDescriptorProto - * @constructor - * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set - */ - function EnumDescriptorProto(properties) { - this.value = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EnumDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.EnumDescriptorProto - * @instance - */ - EnumDescriptorProto.prototype.name = ""; - - /** - * EnumDescriptorProto value. - * @member {Array.} value - * @memberof google.protobuf.EnumDescriptorProto - * @instance - */ - EnumDescriptorProto.prototype.value = $util.emptyArray; - - /** - * EnumDescriptorProto options. - * @member {google.protobuf.IEnumOptions|null|undefined} options - * @memberof google.protobuf.EnumDescriptorProto - * @instance - */ - EnumDescriptorProto.prototype.options = null; - - return EnumDescriptorProto; - })(); - - protobuf.EnumValueDescriptorProto = (function() { - - /** - * Properties of an EnumValueDescriptorProto. - * @memberof google.protobuf - * @interface IEnumValueDescriptorProto - * @property {string|null} [name] EnumValueDescriptorProto name - * @property {number|null} [number] EnumValueDescriptorProto number - * @property {google.protobuf.IEnumValueOptions|null} [options] EnumValueDescriptorProto options - */ - - /** - * Constructs a new EnumValueDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents an EnumValueDescriptorProto. - * @implements IEnumValueDescriptorProto - * @constructor - * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set - */ - function EnumValueDescriptorProto(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EnumValueDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.EnumValueDescriptorProto - * @instance - */ - EnumValueDescriptorProto.prototype.name = ""; - - /** - * EnumValueDescriptorProto number. - * @member {number} number - * @memberof google.protobuf.EnumValueDescriptorProto - * @instance - */ - EnumValueDescriptorProto.prototype.number = 0; - - /** - * EnumValueDescriptorProto options. - * @member {google.protobuf.IEnumValueOptions|null|undefined} options - * @memberof google.protobuf.EnumValueDescriptorProto - * @instance - */ - EnumValueDescriptorProto.prototype.options = null; - - return EnumValueDescriptorProto; - })(); - - protobuf.ServiceDescriptorProto = (function() { - - /** - * Properties of a ServiceDescriptorProto. - * @memberof google.protobuf - * @interface IServiceDescriptorProto - * @property {string|null} [name] ServiceDescriptorProto name - * @property {Array.|null} [method] ServiceDescriptorProto method - * @property {google.protobuf.IServiceOptions|null} [options] ServiceDescriptorProto options - */ - - /** - * Constructs a new ServiceDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents a ServiceDescriptorProto. - * @implements IServiceDescriptorProto - * @constructor - * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set - */ - function ServiceDescriptorProto(properties) { - this.method = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ServiceDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.ServiceDescriptorProto - * @instance - */ - ServiceDescriptorProto.prototype.name = ""; - - /** - * ServiceDescriptorProto method. - * @member {Array.} method - * @memberof google.protobuf.ServiceDescriptorProto - * @instance - */ - ServiceDescriptorProto.prototype.method = $util.emptyArray; - - /** - * ServiceDescriptorProto options. - * @member {google.protobuf.IServiceOptions|null|undefined} options - * @memberof google.protobuf.ServiceDescriptorProto - * @instance - */ - ServiceDescriptorProto.prototype.options = null; - - return ServiceDescriptorProto; - })(); - - protobuf.MethodDescriptorProto = (function() { - - /** - * Properties of a MethodDescriptorProto. - * @memberof google.protobuf - * @interface IMethodDescriptorProto - * @property {string|null} [name] MethodDescriptorProto name - * @property {string|null} [inputType] MethodDescriptorProto inputType - * @property {string|null} [outputType] MethodDescriptorProto outputType - * @property {google.protobuf.IMethodOptions|null} [options] MethodDescriptorProto options - * @property {boolean|null} [clientStreaming] MethodDescriptorProto clientStreaming - * @property {boolean|null} [serverStreaming] MethodDescriptorProto serverStreaming - */ - - /** - * Constructs a new MethodDescriptorProto. - * @memberof google.protobuf - * @classdesc Represents a MethodDescriptorProto. - * @implements IMethodDescriptorProto - * @constructor - * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set - */ - function MethodDescriptorProto(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * MethodDescriptorProto name. - * @member {string} name - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.name = ""; - - /** - * MethodDescriptorProto inputType. - * @member {string} inputType - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.inputType = ""; - - /** - * MethodDescriptorProto outputType. - * @member {string} outputType - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.outputType = ""; - - /** - * MethodDescriptorProto options. - * @member {google.protobuf.IMethodOptions|null|undefined} options - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.options = null; - - /** - * MethodDescriptorProto clientStreaming. - * @member {boolean} clientStreaming - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.clientStreaming = false; - - /** - * MethodDescriptorProto serverStreaming. - * @member {boolean} serverStreaming - * @memberof google.protobuf.MethodDescriptorProto - * @instance - */ - MethodDescriptorProto.prototype.serverStreaming = false; - - return MethodDescriptorProto; - })(); - - protobuf.FileOptions = (function() { - - /** - * Properties of a FileOptions. - * @memberof google.protobuf - * @interface IFileOptions - * @property {string|null} [javaPackage] FileOptions javaPackage - * @property {string|null} [javaOuterClassname] FileOptions javaOuterClassname - * @property {boolean|null} [javaMultipleFiles] FileOptions javaMultipleFiles - * @property {boolean|null} [javaGenerateEqualsAndHash] FileOptions javaGenerateEqualsAndHash - * @property {boolean|null} [javaStringCheckUtf8] FileOptions javaStringCheckUtf8 - * @property {google.protobuf.FileOptions.OptimizeMode|null} [optimizeFor] FileOptions optimizeFor - * @property {string|null} [goPackage] FileOptions goPackage - * @property {boolean|null} [ccGenericServices] FileOptions ccGenericServices - * @property {boolean|null} [javaGenericServices] FileOptions javaGenericServices - * @property {boolean|null} [pyGenericServices] FileOptions pyGenericServices - * @property {boolean|null} [deprecated] FileOptions deprecated - * @property {boolean|null} [ccEnableArenas] FileOptions ccEnableArenas - * @property {string|null} [objcClassPrefix] FileOptions objcClassPrefix - * @property {string|null} [csharpNamespace] FileOptions csharpNamespace - * @property {Array.|null} [uninterpretedOption] FileOptions uninterpretedOption - * @property {Array.|null} [".google.api.resourceDefinition"] FileOptions .google.api.resourceDefinition - */ - - /** - * Constructs a new FileOptions. - * @memberof google.protobuf - * @classdesc Represents a FileOptions. - * @implements IFileOptions - * @constructor - * @param {google.protobuf.IFileOptions=} [properties] Properties to set - */ - function FileOptions(properties) { - this.uninterpretedOption = []; - this[".google.api.resourceDefinition"] = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FileOptions javaPackage. - * @member {string} javaPackage - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaPackage = ""; - - /** - * FileOptions javaOuterClassname. - * @member {string} javaOuterClassname - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaOuterClassname = ""; - - /** - * FileOptions javaMultipleFiles. - * @member {boolean} javaMultipleFiles - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaMultipleFiles = false; - - /** - * FileOptions javaGenerateEqualsAndHash. - * @member {boolean} javaGenerateEqualsAndHash - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaGenerateEqualsAndHash = false; - - /** - * FileOptions javaStringCheckUtf8. - * @member {boolean} javaStringCheckUtf8 - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaStringCheckUtf8 = false; - - /** - * FileOptions optimizeFor. - * @member {google.protobuf.FileOptions.OptimizeMode} optimizeFor - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.optimizeFor = 1; - - /** - * FileOptions goPackage. - * @member {string} goPackage - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.goPackage = ""; - - /** - * FileOptions ccGenericServices. - * @member {boolean} ccGenericServices - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.ccGenericServices = false; - - /** - * FileOptions javaGenericServices. - * @member {boolean} javaGenericServices - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.javaGenericServices = false; - - /** - * FileOptions pyGenericServices. - * @member {boolean} pyGenericServices - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.pyGenericServices = false; - - /** - * FileOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.deprecated = false; - - /** - * FileOptions ccEnableArenas. - * @member {boolean} ccEnableArenas - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.ccEnableArenas = false; - - /** - * FileOptions objcClassPrefix. - * @member {string} objcClassPrefix - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.objcClassPrefix = ""; - - /** - * FileOptions csharpNamespace. - * @member {string} csharpNamespace - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.csharpNamespace = ""; - - /** - * FileOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype.uninterpretedOption = $util.emptyArray; - - /** - * FileOptions .google.api.resourceDefinition. - * @member {Array.} .google.api.resourceDefinition - * @memberof google.protobuf.FileOptions - * @instance - */ - FileOptions.prototype[".google.api.resourceDefinition"] = $util.emptyArray; - - /** - * OptimizeMode enum. - * @name google.protobuf.FileOptions.OptimizeMode - * @enum {number} - * @property {string} SPEED=SPEED SPEED value - * @property {string} CODE_SIZE=CODE_SIZE CODE_SIZE value - * @property {string} LITE_RUNTIME=LITE_RUNTIME LITE_RUNTIME value - */ - FileOptions.OptimizeMode = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[1] = "SPEED"] = "SPEED"; - values[valuesById[2] = "CODE_SIZE"] = "CODE_SIZE"; - values[valuesById[3] = "LITE_RUNTIME"] = "LITE_RUNTIME"; - return values; - })(); - - return FileOptions; - })(); - - protobuf.MessageOptions = (function() { - - /** - * Properties of a MessageOptions. - * @memberof google.protobuf - * @interface IMessageOptions - * @property {boolean|null} [messageSetWireFormat] MessageOptions messageSetWireFormat - * @property {boolean|null} [noStandardDescriptorAccessor] MessageOptions noStandardDescriptorAccessor - * @property {boolean|null} [deprecated] MessageOptions deprecated - * @property {boolean|null} [mapEntry] MessageOptions mapEntry - * @property {Array.|null} [uninterpretedOption] MessageOptions uninterpretedOption - * @property {google.api.IResourceDescriptor|null} [".google.api.resource"] MessageOptions .google.api.resource - */ - - /** - * Constructs a new MessageOptions. - * @memberof google.protobuf - * @classdesc Represents a MessageOptions. - * @implements IMessageOptions - * @constructor - * @param {google.protobuf.IMessageOptions=} [properties] Properties to set - */ - function MessageOptions(properties) { - this.uninterpretedOption = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * MessageOptions messageSetWireFormat. - * @member {boolean} messageSetWireFormat - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype.messageSetWireFormat = false; - - /** - * MessageOptions noStandardDescriptorAccessor. - * @member {boolean} noStandardDescriptorAccessor - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype.noStandardDescriptorAccessor = false; - - /** - * MessageOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype.deprecated = false; - - /** - * MessageOptions mapEntry. - * @member {boolean} mapEntry - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype.mapEntry = false; - - /** - * MessageOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype.uninterpretedOption = $util.emptyArray; - - /** - * MessageOptions .google.api.resource. - * @member {google.api.IResourceDescriptor|null|undefined} .google.api.resource - * @memberof google.protobuf.MessageOptions - * @instance - */ - MessageOptions.prototype[".google.api.resource"] = null; - - return MessageOptions; - })(); - - protobuf.FieldOptions = (function() { - - /** - * Properties of a FieldOptions. - * @memberof google.protobuf - * @interface IFieldOptions - * @property {google.protobuf.FieldOptions.CType|null} [ctype] FieldOptions ctype - * @property {boolean|null} [packed] FieldOptions packed - * @property {google.protobuf.FieldOptions.JSType|null} [jstype] FieldOptions jstype - * @property {boolean|null} [lazy] FieldOptions lazy - * @property {boolean|null} [deprecated] FieldOptions deprecated - * @property {boolean|null} [weak] FieldOptions weak - * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption - * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior - * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference - */ - - /** - * Constructs a new FieldOptions. - * @memberof google.protobuf - * @classdesc Represents a FieldOptions. - * @implements IFieldOptions - * @constructor - * @param {google.protobuf.IFieldOptions=} [properties] Properties to set - */ - function FieldOptions(properties) { - this.uninterpretedOption = []; - this[".google.api.fieldBehavior"] = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FieldOptions ctype. - * @member {google.protobuf.FieldOptions.CType} ctype - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.ctype = 0; - - /** - * FieldOptions packed. - * @member {boolean} packed - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.packed = false; - - /** - * FieldOptions jstype. - * @member {google.protobuf.FieldOptions.JSType} jstype - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.jstype = 0; - - /** - * FieldOptions lazy. - * @member {boolean} lazy - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.lazy = false; - - /** - * FieldOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.deprecated = false; - - /** - * FieldOptions weak. - * @member {boolean} weak - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.weak = false; - - /** - * FieldOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.uninterpretedOption = $util.emptyArray; - - /** - * FieldOptions .google.api.fieldBehavior. - * @member {Array.} .google.api.fieldBehavior - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype[".google.api.fieldBehavior"] = $util.emptyArray; - - /** - * FieldOptions .google.api.resourceReference. - * @member {google.api.IResourceReference|null|undefined} .google.api.resourceReference - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype[".google.api.resourceReference"] = null; - - /** - * CType enum. - * @name google.protobuf.FieldOptions.CType - * @enum {number} - * @property {string} STRING=STRING STRING value - * @property {string} CORD=CORD CORD value - * @property {string} STRING_PIECE=STRING_PIECE STRING_PIECE value - */ - FieldOptions.CType = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "STRING"] = "STRING"; - values[valuesById[1] = "CORD"] = "CORD"; - values[valuesById[2] = "STRING_PIECE"] = "STRING_PIECE"; - return values; - })(); - - /** - * JSType enum. - * @name google.protobuf.FieldOptions.JSType - * @enum {number} - * @property {string} JS_NORMAL=JS_NORMAL JS_NORMAL value - * @property {string} JS_STRING=JS_STRING JS_STRING value - * @property {string} JS_NUMBER=JS_NUMBER JS_NUMBER value - */ - FieldOptions.JSType = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "JS_NORMAL"] = "JS_NORMAL"; - values[valuesById[1] = "JS_STRING"] = "JS_STRING"; - values[valuesById[2] = "JS_NUMBER"] = "JS_NUMBER"; - return values; - })(); - - return FieldOptions; - })(); - - protobuf.OneofOptions = (function() { - - /** - * Properties of an OneofOptions. - * @memberof google.protobuf - * @interface IOneofOptions - * @property {Array.|null} [uninterpretedOption] OneofOptions uninterpretedOption - */ - - /** - * Constructs a new OneofOptions. - * @memberof google.protobuf - * @classdesc Represents an OneofOptions. - * @implements IOneofOptions - * @constructor - * @param {google.protobuf.IOneofOptions=} [properties] Properties to set - */ - function OneofOptions(properties) { - this.uninterpretedOption = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * OneofOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.OneofOptions - * @instance - */ - OneofOptions.prototype.uninterpretedOption = $util.emptyArray; - - return OneofOptions; - })(); - - protobuf.EnumOptions = (function() { - - /** - * Properties of an EnumOptions. - * @memberof google.protobuf - * @interface IEnumOptions - * @property {boolean|null} [allowAlias] EnumOptions allowAlias - * @property {boolean|null} [deprecated] EnumOptions deprecated - * @property {Array.|null} [uninterpretedOption] EnumOptions uninterpretedOption - */ - - /** - * Constructs a new EnumOptions. - * @memberof google.protobuf - * @classdesc Represents an EnumOptions. - * @implements IEnumOptions - * @constructor - * @param {google.protobuf.IEnumOptions=} [properties] Properties to set - */ - function EnumOptions(properties) { - this.uninterpretedOption = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EnumOptions allowAlias. - * @member {boolean} allowAlias - * @memberof google.protobuf.EnumOptions - * @instance - */ - EnumOptions.prototype.allowAlias = false; - - /** - * EnumOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.EnumOptions - * @instance - */ - EnumOptions.prototype.deprecated = false; - - /** - * EnumOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.EnumOptions - * @instance - */ - EnumOptions.prototype.uninterpretedOption = $util.emptyArray; - - return EnumOptions; - })(); - - protobuf.EnumValueOptions = (function() { - - /** - * Properties of an EnumValueOptions. - * @memberof google.protobuf - * @interface IEnumValueOptions - * @property {boolean|null} [deprecated] EnumValueOptions deprecated - * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption - */ - - /** - * Constructs a new EnumValueOptions. - * @memberof google.protobuf - * @classdesc Represents an EnumValueOptions. - * @implements IEnumValueOptions - * @constructor - * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set - */ - function EnumValueOptions(properties) { - this.uninterpretedOption = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EnumValueOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.EnumValueOptions - * @instance - */ - EnumValueOptions.prototype.deprecated = false; - - /** - * EnumValueOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.EnumValueOptions - * @instance - */ - EnumValueOptions.prototype.uninterpretedOption = $util.emptyArray; - - return EnumValueOptions; - })(); - - protobuf.ServiceOptions = (function() { - - /** - * Properties of a ServiceOptions. - * @memberof google.protobuf - * @interface IServiceOptions - * @property {boolean|null} [deprecated] ServiceOptions deprecated - * @property {Array.|null} [uninterpretedOption] ServiceOptions uninterpretedOption - * @property {string|null} [".google.api.defaultHost"] ServiceOptions .google.api.defaultHost - * @property {string|null} [".google.api.oauthScopes"] ServiceOptions .google.api.oauthScopes - */ - - /** - * Constructs a new ServiceOptions. - * @memberof google.protobuf - * @classdesc Represents a ServiceOptions. - * @implements IServiceOptions - * @constructor - * @param {google.protobuf.IServiceOptions=} [properties] Properties to set - */ - function ServiceOptions(properties) { - this.uninterpretedOption = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ServiceOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.ServiceOptions - * @instance - */ - ServiceOptions.prototype.deprecated = false; - - /** - * ServiceOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.ServiceOptions - * @instance - */ - ServiceOptions.prototype.uninterpretedOption = $util.emptyArray; - - /** - * ServiceOptions .google.api.defaultHost. - * @member {string} .google.api.defaultHost - * @memberof google.protobuf.ServiceOptions - * @instance - */ - ServiceOptions.prototype[".google.api.defaultHost"] = ""; - - /** - * ServiceOptions .google.api.oauthScopes. - * @member {string} .google.api.oauthScopes - * @memberof google.protobuf.ServiceOptions - * @instance - */ - ServiceOptions.prototype[".google.api.oauthScopes"] = ""; - - return ServiceOptions; - })(); - - protobuf.MethodOptions = (function() { - - /** - * Properties of a MethodOptions. - * @memberof google.protobuf - * @interface IMethodOptions - * @property {boolean|null} [deprecated] MethodOptions deprecated - * @property {Array.|null} [uninterpretedOption] MethodOptions uninterpretedOption - * @property {google.api.IHttpRule|null} [".google.api.http"] MethodOptions .google.api.http - * @property {Array.|null} [".google.api.methodSignature"] MethodOptions .google.api.methodSignature - * @property {google.longrunning.IOperationInfo|null} [".google.longrunning.operationInfo"] MethodOptions .google.longrunning.operationInfo - */ - - /** - * Constructs a new MethodOptions. - * @memberof google.protobuf - * @classdesc Represents a MethodOptions. - * @implements IMethodOptions - * @constructor - * @param {google.protobuf.IMethodOptions=} [properties] Properties to set - */ - function MethodOptions(properties) { - this.uninterpretedOption = []; - this[".google.api.methodSignature"] = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * MethodOptions deprecated. - * @member {boolean} deprecated - * @memberof google.protobuf.MethodOptions - * @instance - */ - MethodOptions.prototype.deprecated = false; - - /** - * MethodOptions uninterpretedOption. - * @member {Array.} uninterpretedOption - * @memberof google.protobuf.MethodOptions - * @instance - */ - MethodOptions.prototype.uninterpretedOption = $util.emptyArray; - - /** - * MethodOptions .google.api.http. - * @member {google.api.IHttpRule|null|undefined} .google.api.http - * @memberof google.protobuf.MethodOptions - * @instance - */ - MethodOptions.prototype[".google.api.http"] = null; - - /** - * MethodOptions .google.api.methodSignature. - * @member {Array.} .google.api.methodSignature - * @memberof google.protobuf.MethodOptions - * @instance - */ - MethodOptions.prototype[".google.api.methodSignature"] = $util.emptyArray; - - /** - * MethodOptions .google.longrunning.operationInfo. - * @member {google.longrunning.IOperationInfo|null|undefined} .google.longrunning.operationInfo - * @memberof google.protobuf.MethodOptions - * @instance - */ - MethodOptions.prototype[".google.longrunning.operationInfo"] = null; - - return MethodOptions; - })(); - - protobuf.UninterpretedOption = (function() { - - /** - * Properties of an UninterpretedOption. - * @memberof google.protobuf - * @interface IUninterpretedOption - * @property {Array.|null} [name] UninterpretedOption name - * @property {string|null} [identifierValue] UninterpretedOption identifierValue - * @property {number|null} [positiveIntValue] UninterpretedOption positiveIntValue - * @property {number|null} [negativeIntValue] UninterpretedOption negativeIntValue - * @property {number|null} [doubleValue] UninterpretedOption doubleValue - * @property {Uint8Array|null} [stringValue] UninterpretedOption stringValue - * @property {string|null} [aggregateValue] UninterpretedOption aggregateValue - */ - - /** - * Constructs a new UninterpretedOption. - * @memberof google.protobuf - * @classdesc Represents an UninterpretedOption. - * @implements IUninterpretedOption - * @constructor - * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set - */ - function UninterpretedOption(properties) { - this.name = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * UninterpretedOption name. - * @member {Array.} name - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.name = $util.emptyArray; - - /** - * UninterpretedOption identifierValue. - * @member {string} identifierValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.identifierValue = ""; - - /** - * UninterpretedOption positiveIntValue. - * @member {number} positiveIntValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.positiveIntValue = $util.Long ? $util.Long.fromBits(0,0,true) : 0; - - /** - * UninterpretedOption negativeIntValue. - * @member {number} negativeIntValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.negativeIntValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * UninterpretedOption doubleValue. - * @member {number} doubleValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.doubleValue = 0; - - /** - * UninterpretedOption stringValue. - * @member {Uint8Array} stringValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.stringValue = $util.newBuffer([]); - - /** - * UninterpretedOption aggregateValue. - * @member {string} aggregateValue - * @memberof google.protobuf.UninterpretedOption - * @instance - */ - UninterpretedOption.prototype.aggregateValue = ""; - - UninterpretedOption.NamePart = (function() { - - /** - * Properties of a NamePart. - * @memberof google.protobuf.UninterpretedOption - * @interface INamePart - * @property {string} namePart NamePart namePart - * @property {boolean} isExtension NamePart isExtension - */ - - /** - * Constructs a new NamePart. - * @memberof google.protobuf.UninterpretedOption - * @classdesc Represents a NamePart. - * @implements INamePart + + protobuf.FieldDescriptorProto = (function() { + + /** + * Properties of a FieldDescriptorProto. + * @memberof google.protobuf + * @interface IFieldDescriptorProto + * @property {string|null} [name] FieldDescriptorProto name + * @property {number|null} [number] FieldDescriptorProto number + * @property {google.protobuf.FieldDescriptorProto.Label|null} [label] FieldDescriptorProto label + * @property {google.protobuf.FieldDescriptorProto.Type|null} [type] FieldDescriptorProto type + * @property {string|null} [typeName] FieldDescriptorProto typeName + * @property {string|null} [extendee] FieldDescriptorProto extendee + * @property {string|null} [defaultValue] FieldDescriptorProto defaultValue + * @property {number|null} [oneofIndex] FieldDescriptorProto oneofIndex + * @property {string|null} [jsonName] FieldDescriptorProto jsonName + * @property {google.protobuf.IFieldOptions|null} [options] FieldDescriptorProto options + */ + + /** + * Constructs a new FieldDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FieldDescriptorProto. + * @implements IFieldDescriptorProto * @constructor - * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set + * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set */ - function NamePart(properties) { + function FieldDescriptorProto(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * NamePart namePart. - * @member {string} namePart - * @memberof google.protobuf.UninterpretedOption.NamePart + * FieldDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FieldDescriptorProto * @instance */ - NamePart.prototype.namePart = ""; - + FieldDescriptorProto.prototype.name = ""; + /** - * NamePart isExtension. - * @member {boolean} isExtension - * @memberof google.protobuf.UninterpretedOption.NamePart + * FieldDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.FieldDescriptorProto * @instance */ - NamePart.prototype.isExtension = false; - - return NamePart; - })(); - - return UninterpretedOption; - })(); - - protobuf.SourceCodeInfo = (function() { - - /** - * Properties of a SourceCodeInfo. - * @memberof google.protobuf - * @interface ISourceCodeInfo - * @property {Array.|null} [location] SourceCodeInfo location - */ - - /** - * Constructs a new SourceCodeInfo. - * @memberof google.protobuf - * @classdesc Represents a SourceCodeInfo. - * @implements ISourceCodeInfo - * @constructor - * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set - */ - function SourceCodeInfo(properties) { - this.location = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * SourceCodeInfo location. - * @member {Array.} location - * @memberof google.protobuf.SourceCodeInfo - * @instance - */ - SourceCodeInfo.prototype.location = $util.emptyArray; - - SourceCodeInfo.Location = (function() { - + FieldDescriptorProto.prototype.number = 0; + /** - * Properties of a Location. - * @memberof google.protobuf.SourceCodeInfo - * @interface ILocation - * @property {Array.|null} [path] Location path - * @property {Array.|null} [span] Location span - * @property {string|null} [leadingComments] Location leadingComments - * @property {string|null} [trailingComments] Location trailingComments - * @property {Array.|null} [leadingDetachedComments] Location leadingDetachedComments + * FieldDescriptorProto label. + * @member {google.protobuf.FieldDescriptorProto.Label} label + * @memberof google.protobuf.FieldDescriptorProto + * @instance */ - + FieldDescriptorProto.prototype.label = 1; + /** - * Constructs a new Location. - * @memberof google.protobuf.SourceCodeInfo - * @classdesc Represents a Location. - * @implements ILocation - * @constructor - * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set + * FieldDescriptorProto type. + * @member {google.protobuf.FieldDescriptorProto.Type} type + * @memberof google.protobuf.FieldDescriptorProto + * @instance */ - function Location(properties) { - this.path = []; - this.span = []; - this.leadingDetachedComments = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - + FieldDescriptorProto.prototype.type = 1; + /** - * Location path. - * @member {Array.} path - * @memberof google.protobuf.SourceCodeInfo.Location + * FieldDescriptorProto typeName. + * @member {string} typeName + * @memberof google.protobuf.FieldDescriptorProto * @instance */ - Location.prototype.path = $util.emptyArray; - + FieldDescriptorProto.prototype.typeName = ""; + /** - * Location span. - * @member {Array.} span - * @memberof google.protobuf.SourceCodeInfo.Location + * FieldDescriptorProto extendee. + * @member {string} extendee + * @memberof google.protobuf.FieldDescriptorProto * @instance */ - Location.prototype.span = $util.emptyArray; - + FieldDescriptorProto.prototype.extendee = ""; + /** - * Location leadingComments. - * @member {string} leadingComments - * @memberof google.protobuf.SourceCodeInfo.Location + * FieldDescriptorProto defaultValue. + * @member {string} defaultValue + * @memberof google.protobuf.FieldDescriptorProto * @instance */ - Location.prototype.leadingComments = ""; - + FieldDescriptorProto.prototype.defaultValue = ""; + /** - * Location trailingComments. - * @member {string} trailingComments - * @memberof google.protobuf.SourceCodeInfo.Location + * FieldDescriptorProto oneofIndex. + * @member {number} oneofIndex + * @memberof google.protobuf.FieldDescriptorProto * @instance */ - Location.prototype.trailingComments = ""; - + FieldDescriptorProto.prototype.oneofIndex = 0; + /** - * Location leadingDetachedComments. - * @member {Array.} leadingDetachedComments - * @memberof google.protobuf.SourceCodeInfo.Location + * FieldDescriptorProto jsonName. + * @member {string} jsonName + * @memberof google.protobuf.FieldDescriptorProto * @instance */ - Location.prototype.leadingDetachedComments = $util.emptyArray; - - return Location; - })(); - - return SourceCodeInfo; - })(); - - protobuf.GeneratedCodeInfo = (function() { - - /** - * Properties of a GeneratedCodeInfo. - * @memberof google.protobuf - * @interface IGeneratedCodeInfo - * @property {Array.|null} [annotation] GeneratedCodeInfo annotation - */ - - /** - * Constructs a new GeneratedCodeInfo. - * @memberof google.protobuf - * @classdesc Represents a GeneratedCodeInfo. - * @implements IGeneratedCodeInfo - * @constructor - * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set - */ - function GeneratedCodeInfo(properties) { - this.annotation = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * GeneratedCodeInfo annotation. - * @member {Array.} annotation - * @memberof google.protobuf.GeneratedCodeInfo - * @instance - */ - GeneratedCodeInfo.prototype.annotation = $util.emptyArray; - - GeneratedCodeInfo.Annotation = (function() { - + FieldDescriptorProto.prototype.jsonName = ""; + /** - * Properties of an Annotation. - * @memberof google.protobuf.GeneratedCodeInfo - * @interface IAnnotation - * @property {Array.|null} [path] Annotation path - * @property {string|null} [sourceFile] Annotation sourceFile - * @property {number|null} [begin] Annotation begin - * @property {number|null} [end] Annotation end + * FieldDescriptorProto options. + * @member {google.protobuf.IFieldOptions|null|undefined} options + * @memberof google.protobuf.FieldDescriptorProto + * @instance */ - + FieldDescriptorProto.prototype.options = null; + /** - * Constructs a new Annotation. - * @memberof google.protobuf.GeneratedCodeInfo - * @classdesc Represents an Annotation. - * @implements IAnnotation + * Creates a FieldDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + */ + FieldDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldDescriptorProto) + return object; + var message = new $root.google.protobuf.FieldDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.number != null) + message.number = object.number | 0; + switch (object.label) { + case "LABEL_OPTIONAL": + case 1: + message.label = 1; + break; + case "LABEL_REQUIRED": + case 2: + message.label = 2; + break; + case "LABEL_REPEATED": + case 3: + message.label = 3; + break; + } + switch (object.type) { + case "TYPE_DOUBLE": + case 1: + message.type = 1; + break; + case "TYPE_FLOAT": + case 2: + message.type = 2; + break; + case "TYPE_INT64": + case 3: + message.type = 3; + break; + case "TYPE_UINT64": + case 4: + message.type = 4; + break; + case "TYPE_INT32": + case 5: + message.type = 5; + break; + case "TYPE_FIXED64": + case 6: + message.type = 6; + break; + case "TYPE_FIXED32": + case 7: + message.type = 7; + break; + case "TYPE_BOOL": + case 8: + message.type = 8; + break; + case "TYPE_STRING": + case 9: + message.type = 9; + break; + case "TYPE_GROUP": + case 10: + message.type = 10; + break; + case "TYPE_MESSAGE": + case 11: + message.type = 11; + break; + case "TYPE_BYTES": + case 12: + message.type = 12; + break; + case "TYPE_UINT32": + case 13: + message.type = 13; + break; + case "TYPE_ENUM": + case 14: + message.type = 14; + break; + case "TYPE_SFIXED32": + case 15: + message.type = 15; + break; + case "TYPE_SFIXED64": + case 16: + message.type = 16; + break; + case "TYPE_SINT32": + case 17: + message.type = 17; + break; + case "TYPE_SINT64": + case 18: + message.type = 18; + break; + } + if (object.typeName != null) + message.typeName = String(object.typeName); + if (object.extendee != null) + message.extendee = String(object.extendee); + if (object.defaultValue != null) + message.defaultValue = String(object.defaultValue); + if (object.oneofIndex != null) + message.oneofIndex = object.oneofIndex | 0; + if (object.jsonName != null) + message.jsonName = String(object.jsonName); + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.FieldDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.FieldOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from a FieldDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.FieldDescriptorProto} message FieldDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.extendee = ""; + object.number = 0; + object.label = options.enums === String ? "LABEL_OPTIONAL" : 1; + object.type = options.enums === String ? "TYPE_DOUBLE" : 1; + object.typeName = ""; + object.defaultValue = ""; + object.options = null; + object.oneofIndex = 0; + object.jsonName = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.extendee != null && message.hasOwnProperty("extendee")) + object.extendee = message.extendee; + if (message.number != null && message.hasOwnProperty("number")) + object.number = message.number; + if (message.label != null && message.hasOwnProperty("label")) + object.label = options.enums === String ? $root.google.protobuf.FieldDescriptorProto.Label[message.label] : message.label; + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.google.protobuf.FieldDescriptorProto.Type[message.type] : message.type; + if (message.typeName != null && message.hasOwnProperty("typeName")) + object.typeName = message.typeName; + if (message.defaultValue != null && message.hasOwnProperty("defaultValue")) + object.defaultValue = message.defaultValue; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.FieldOptions.toObject(message.options, options); + if (message.oneofIndex != null && message.hasOwnProperty("oneofIndex")) + object.oneofIndex = message.oneofIndex; + if (message.jsonName != null && message.hasOwnProperty("jsonName")) + object.jsonName = message.jsonName; + return object; + }; + + /** + * Converts this FieldDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.FieldDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + FieldDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Type enum. + * @name google.protobuf.FieldDescriptorProto.Type + * @enum {string} + * @property {string} TYPE_DOUBLE=TYPE_DOUBLE TYPE_DOUBLE value + * @property {string} TYPE_FLOAT=TYPE_FLOAT TYPE_FLOAT value + * @property {string} TYPE_INT64=TYPE_INT64 TYPE_INT64 value + * @property {string} TYPE_UINT64=TYPE_UINT64 TYPE_UINT64 value + * @property {string} TYPE_INT32=TYPE_INT32 TYPE_INT32 value + * @property {string} TYPE_FIXED64=TYPE_FIXED64 TYPE_FIXED64 value + * @property {string} TYPE_FIXED32=TYPE_FIXED32 TYPE_FIXED32 value + * @property {string} TYPE_BOOL=TYPE_BOOL TYPE_BOOL value + * @property {string} TYPE_STRING=TYPE_STRING TYPE_STRING value + * @property {string} TYPE_GROUP=TYPE_GROUP TYPE_GROUP value + * @property {string} TYPE_MESSAGE=TYPE_MESSAGE TYPE_MESSAGE value + * @property {string} TYPE_BYTES=TYPE_BYTES TYPE_BYTES value + * @property {string} TYPE_UINT32=TYPE_UINT32 TYPE_UINT32 value + * @property {string} TYPE_ENUM=TYPE_ENUM TYPE_ENUM value + * @property {string} TYPE_SFIXED32=TYPE_SFIXED32 TYPE_SFIXED32 value + * @property {string} TYPE_SFIXED64=TYPE_SFIXED64 TYPE_SFIXED64 value + * @property {string} TYPE_SINT32=TYPE_SINT32 TYPE_SINT32 value + * @property {string} TYPE_SINT64=TYPE_SINT64 TYPE_SINT64 value + */ + FieldDescriptorProto.Type = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "TYPE_DOUBLE"] = "TYPE_DOUBLE"; + values[valuesById[2] = "TYPE_FLOAT"] = "TYPE_FLOAT"; + values[valuesById[3] = "TYPE_INT64"] = "TYPE_INT64"; + values[valuesById[4] = "TYPE_UINT64"] = "TYPE_UINT64"; + values[valuesById[5] = "TYPE_INT32"] = "TYPE_INT32"; + values[valuesById[6] = "TYPE_FIXED64"] = "TYPE_FIXED64"; + values[valuesById[7] = "TYPE_FIXED32"] = "TYPE_FIXED32"; + values[valuesById[8] = "TYPE_BOOL"] = "TYPE_BOOL"; + values[valuesById[9] = "TYPE_STRING"] = "TYPE_STRING"; + values[valuesById[10] = "TYPE_GROUP"] = "TYPE_GROUP"; + values[valuesById[11] = "TYPE_MESSAGE"] = "TYPE_MESSAGE"; + values[valuesById[12] = "TYPE_BYTES"] = "TYPE_BYTES"; + values[valuesById[13] = "TYPE_UINT32"] = "TYPE_UINT32"; + values[valuesById[14] = "TYPE_ENUM"] = "TYPE_ENUM"; + values[valuesById[15] = "TYPE_SFIXED32"] = "TYPE_SFIXED32"; + values[valuesById[16] = "TYPE_SFIXED64"] = "TYPE_SFIXED64"; + values[valuesById[17] = "TYPE_SINT32"] = "TYPE_SINT32"; + values[valuesById[18] = "TYPE_SINT64"] = "TYPE_SINT64"; + return values; + })(); + + /** + * Label enum. + * @name google.protobuf.FieldDescriptorProto.Label + * @enum {string} + * @property {string} LABEL_OPTIONAL=LABEL_OPTIONAL LABEL_OPTIONAL value + * @property {string} LABEL_REQUIRED=LABEL_REQUIRED LABEL_REQUIRED value + * @property {string} LABEL_REPEATED=LABEL_REPEATED LABEL_REPEATED value + */ + FieldDescriptorProto.Label = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "LABEL_OPTIONAL"] = "LABEL_OPTIONAL"; + values[valuesById[2] = "LABEL_REQUIRED"] = "LABEL_REQUIRED"; + values[valuesById[3] = "LABEL_REPEATED"] = "LABEL_REPEATED"; + return values; + })(); + + return FieldDescriptorProto; + })(); + + protobuf.OneofDescriptorProto = (function() { + + /** + * Properties of an OneofDescriptorProto. + * @memberof google.protobuf + * @interface IOneofDescriptorProto + * @property {string|null} [name] OneofDescriptorProto name + * @property {google.protobuf.IOneofOptions|null} [options] OneofDescriptorProto options + */ + + /** + * Constructs a new OneofDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an OneofDescriptorProto. + * @implements IOneofDescriptorProto * @constructor - * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set + * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set */ - function Annotation(properties) { - this.path = []; + function OneofDescriptorProto(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * Annotation path. - * @member {Array.} path - * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * OneofDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.OneofDescriptorProto * @instance */ - Annotation.prototype.path = $util.emptyArray; - + OneofDescriptorProto.prototype.name = ""; + /** - * Annotation sourceFile. - * @member {string} sourceFile - * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * OneofDescriptorProto options. + * @member {google.protobuf.IOneofOptions|null|undefined} options + * @memberof google.protobuf.OneofDescriptorProto * @instance */ - Annotation.prototype.sourceFile = ""; - + OneofDescriptorProto.prototype.options = null; + /** - * Annotation begin. - * @member {number} begin - * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * Creates an OneofDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + */ + OneofDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.OneofDescriptorProto) + return object; + var message = new $root.google.protobuf.OneofDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.OneofDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.OneofOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from an OneofDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.OneofDescriptorProto} message OneofDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OneofDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.OneofOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this OneofDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.OneofDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + OneofDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return OneofDescriptorProto; + })(); + + protobuf.EnumDescriptorProto = (function() { + + /** + * Properties of an EnumDescriptorProto. + * @memberof google.protobuf + * @interface IEnumDescriptorProto + * @property {string|null} [name] EnumDescriptorProto name + * @property {Array.|null} [value] EnumDescriptorProto value + * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options + */ + + /** + * Constructs a new EnumDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumDescriptorProto. + * @implements IEnumDescriptorProto + * @constructor + * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set + */ + function EnumDescriptorProto(properties) { + this.value = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.name = ""; + + /** + * EnumDescriptorProto value. + * @member {Array.} value + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.value = $util.emptyArray; + + /** + * EnumDescriptorProto options. + * @member {google.protobuf.IEnumOptions|null|undefined} options + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.options = null; + + /** + * Creates an EnumDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + */ + EnumDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumDescriptorProto) + return object; + var message = new $root.google.protobuf.EnumDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.value) { + if (!Array.isArray(object.value)) + throw TypeError(".google.protobuf.EnumDescriptorProto.value: array expected"); + message.value = []; + for (var i = 0; i < object.value.length; ++i) { + if (typeof object.value[i] !== "object") + throw TypeError(".google.protobuf.EnumDescriptorProto.value: object expected"); + message.value[i] = $root.google.protobuf.EnumValueDescriptorProto.fromObject(object.value[i]); + } + } + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.EnumDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.EnumOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from an EnumDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.EnumDescriptorProto} message EnumDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.value = []; + if (options.defaults) { + object.name = ""; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.value && message.value.length) { + object.value = []; + for (var j = 0; j < message.value.length; ++j) + object.value[j] = $root.google.protobuf.EnumValueDescriptorProto.toObject(message.value[j], options); + } + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.EnumOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this EnumDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.EnumDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + EnumDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return EnumDescriptorProto; + })(); + + protobuf.EnumValueDescriptorProto = (function() { + + /** + * Properties of an EnumValueDescriptorProto. + * @memberof google.protobuf + * @interface IEnumValueDescriptorProto + * @property {string|null} [name] EnumValueDescriptorProto name + * @property {number|null} [number] EnumValueDescriptorProto number + * @property {google.protobuf.IEnumValueOptions|null} [options] EnumValueDescriptorProto options + */ + + /** + * Constructs a new EnumValueDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumValueDescriptorProto. + * @implements IEnumValueDescriptorProto + * @constructor + * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set + */ + function EnumValueDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumValueDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumValueDescriptorProto * @instance */ - Annotation.prototype.begin = 0; - + EnumValueDescriptorProto.prototype.name = ""; + /** - * Annotation end. - * @member {number} end - * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * EnumValueDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.EnumValueDescriptorProto * @instance */ - Annotation.prototype.end = 0; - - return Annotation; + EnumValueDescriptorProto.prototype.number = 0; + + /** + * EnumValueDescriptorProto options. + * @member {google.protobuf.IEnumValueOptions|null|undefined} options + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.options = null; + + /** + * Creates an EnumValueDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + */ + EnumValueDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumValueDescriptorProto) + return object; + var message = new $root.google.protobuf.EnumValueDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.number != null) + message.number = object.number | 0; + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.EnumValueDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.EnumValueOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from an EnumValueDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.EnumValueDescriptorProto} message EnumValueDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumValueDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.number = 0; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.number != null && message.hasOwnProperty("number")) + object.number = message.number; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.EnumValueOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this EnumValueDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + EnumValueDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return EnumValueDescriptorProto; })(); - - return GeneratedCodeInfo; - })(); - - protobuf.Struct = (function() { - - /** - * Properties of a Struct. - * @memberof google.protobuf - * @interface IStruct - * @property {Object.|null} [fields] Struct fields - */ - - /** - * Constructs a new Struct. - * @memberof google.protobuf - * @classdesc Represents a Struct. - * @implements IStruct - * @constructor - * @param {google.protobuf.IStruct=} [properties] Properties to set - */ - function Struct(properties) { - this.fields = {}; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Struct fields. - * @member {Object.} fields - * @memberof google.protobuf.Struct - * @instance - */ - Struct.prototype.fields = $util.emptyObject; - - return Struct; - })(); - - protobuf.Value = (function() { - - /** - * Properties of a Value. - * @memberof google.protobuf - * @interface IValue - * @property {google.protobuf.NullValue|null} [nullValue] Value nullValue - * @property {number|null} [numberValue] Value numberValue - * @property {string|null} [stringValue] Value stringValue - * @property {boolean|null} [boolValue] Value boolValue - * @property {google.protobuf.IStruct|null} [structValue] Value structValue - * @property {google.protobuf.IListValue|null} [listValue] Value listValue - */ - - /** - * Constructs a new Value. - * @memberof google.protobuf - * @classdesc Represents a Value. - * @implements IValue - * @constructor - * @param {google.protobuf.IValue=} [properties] Properties to set - */ - function Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Value nullValue. - * @member {google.protobuf.NullValue} nullValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.nullValue = 0; - - /** - * Value numberValue. - * @member {number} numberValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.numberValue = 0; - - /** - * Value stringValue. - * @member {string} stringValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.stringValue = ""; - - /** - * Value boolValue. - * @member {boolean} boolValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.boolValue = false; - - /** - * Value structValue. - * @member {google.protobuf.IStruct|null|undefined} structValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.structValue = null; - - /** - * Value listValue. - * @member {google.protobuf.IListValue|null|undefined} listValue - * @memberof google.protobuf.Value - * @instance - */ - Value.prototype.listValue = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Value kind. - * @member {"nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"|undefined} kind - * @memberof google.protobuf.Value - * @instance - */ - Object.defineProperty(Value.prototype, "kind", { - get: $util.oneOfGetter($oneOfFields = ["nullValue", "numberValue", "stringValue", "boolValue", "structValue", "listValue"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return Value; - })(); - - /** - * NullValue enum. - * @name google.protobuf.NullValue - * @enum {number} - * @property {string} NULL_VALUE=NULL_VALUE NULL_VALUE value - */ - protobuf.NullValue = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "NULL_VALUE"] = "NULL_VALUE"; - return values; - })(); - - protobuf.ListValue = (function() { - - /** - * Properties of a ListValue. - * @memberof google.protobuf - * @interface IListValue - * @property {Array.|null} [values] ListValue values - */ - - /** - * Constructs a new ListValue. - * @memberof google.protobuf - * @classdesc Represents a ListValue. - * @implements IListValue - * @constructor - * @param {google.protobuf.IListValue=} [properties] Properties to set - */ - function ListValue(properties) { - this.values = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListValue values. - * @member {Array.} values - * @memberof google.protobuf.ListValue - * @instance - */ - ListValue.prototype.values = $util.emptyArray; - - return ListValue; - })(); - - protobuf.Empty = (function() { - - /** - * Properties of an Empty. - * @memberof google.protobuf - * @interface IEmpty - */ - - /** - * Constructs a new Empty. - * @memberof google.protobuf - * @classdesc Represents an Empty. - * @implements IEmpty - * @constructor - * @param {google.protobuf.IEmpty=} [properties] Properties to set - */ - function Empty(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - return Empty; - })(); - - protobuf.DoubleValue = (function() { - - /** - * Properties of a DoubleValue. - * @memberof google.protobuf - * @interface IDoubleValue - * @property {number|null} [value] DoubleValue value - */ - - /** - * Constructs a new DoubleValue. - * @memberof google.protobuf - * @classdesc Represents a DoubleValue. - * @implements IDoubleValue - * @constructor - * @param {google.protobuf.IDoubleValue=} [properties] Properties to set - */ - function DoubleValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DoubleValue value. - * @member {number} value - * @memberof google.protobuf.DoubleValue - * @instance - */ - DoubleValue.prototype.value = 0; - - return DoubleValue; - })(); - - protobuf.FloatValue = (function() { - - /** - * Properties of a FloatValue. - * @memberof google.protobuf - * @interface IFloatValue - * @property {number|null} [value] FloatValue value - */ - - /** - * Constructs a new FloatValue. - * @memberof google.protobuf - * @classdesc Represents a FloatValue. - * @implements IFloatValue - * @constructor - * @param {google.protobuf.IFloatValue=} [properties] Properties to set - */ - function FloatValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FloatValue value. - * @member {number} value - * @memberof google.protobuf.FloatValue - * @instance - */ - FloatValue.prototype.value = 0; - - return FloatValue; - })(); - - protobuf.Int64Value = (function() { - - /** - * Properties of an Int64Value. - * @memberof google.protobuf - * @interface IInt64Value - * @property {number|null} [value] Int64Value value - */ - - /** - * Constructs a new Int64Value. - * @memberof google.protobuf - * @classdesc Represents an Int64Value. - * @implements IInt64Value - * @constructor - * @param {google.protobuf.IInt64Value=} [properties] Properties to set - */ - function Int64Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Int64Value value. - * @member {number} value - * @memberof google.protobuf.Int64Value - * @instance - */ - Int64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - return Int64Value; - })(); - - protobuf.UInt64Value = (function() { - - /** - * Properties of a UInt64Value. - * @memberof google.protobuf - * @interface IUInt64Value - * @property {number|null} [value] UInt64Value value - */ - - /** - * Constructs a new UInt64Value. - * @memberof google.protobuf - * @classdesc Represents a UInt64Value. - * @implements IUInt64Value - * @constructor - * @param {google.protobuf.IUInt64Value=} [properties] Properties to set - */ - function UInt64Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * UInt64Value value. - * @member {number} value - * @memberof google.protobuf.UInt64Value - * @instance - */ - UInt64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,true) : 0; - - return UInt64Value; - })(); - - protobuf.Int32Value = (function() { - - /** - * Properties of an Int32Value. - * @memberof google.protobuf - * @interface IInt32Value - * @property {number|null} [value] Int32Value value - */ - - /** - * Constructs a new Int32Value. - * @memberof google.protobuf - * @classdesc Represents an Int32Value. - * @implements IInt32Value - * @constructor - * @param {google.protobuf.IInt32Value=} [properties] Properties to set - */ - function Int32Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Int32Value value. - * @member {number} value - * @memberof google.protobuf.Int32Value - * @instance - */ - Int32Value.prototype.value = 0; - - return Int32Value; - })(); - - protobuf.UInt32Value = (function() { - - /** - * Properties of a UInt32Value. - * @memberof google.protobuf - * @interface IUInt32Value - * @property {number|null} [value] UInt32Value value - */ - - /** - * Constructs a new UInt32Value. - * @memberof google.protobuf - * @classdesc Represents a UInt32Value. - * @implements IUInt32Value - * @constructor - * @param {google.protobuf.IUInt32Value=} [properties] Properties to set - */ - function UInt32Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * UInt32Value value. - * @member {number} value - * @memberof google.protobuf.UInt32Value - * @instance - */ - UInt32Value.prototype.value = 0; - - return UInt32Value; - })(); - - protobuf.BoolValue = (function() { - - /** - * Properties of a BoolValue. - * @memberof google.protobuf - * @interface IBoolValue - * @property {boolean|null} [value] BoolValue value - */ - - /** - * Constructs a new BoolValue. - * @memberof google.protobuf - * @classdesc Represents a BoolValue. - * @implements IBoolValue - * @constructor - * @param {google.protobuf.IBoolValue=} [properties] Properties to set - */ - function BoolValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BoolValue value. - * @member {boolean} value - * @memberof google.protobuf.BoolValue - * @instance - */ - BoolValue.prototype.value = false; - - return BoolValue; - })(); - - protobuf.StringValue = (function() { - - /** - * Properties of a StringValue. - * @memberof google.protobuf - * @interface IStringValue - * @property {string|null} [value] StringValue value - */ - - /** - * Constructs a new StringValue. - * @memberof google.protobuf - * @classdesc Represents a StringValue. - * @implements IStringValue - * @constructor - * @param {google.protobuf.IStringValue=} [properties] Properties to set - */ - function StringValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * StringValue value. - * @member {string} value - * @memberof google.protobuf.StringValue - * @instance - */ - StringValue.prototype.value = ""; - - return StringValue; - })(); - - protobuf.BytesValue = (function() { - - /** - * Properties of a BytesValue. - * @memberof google.protobuf - * @interface IBytesValue - * @property {Uint8Array|null} [value] BytesValue value - */ - - /** - * Constructs a new BytesValue. - * @memberof google.protobuf - * @classdesc Represents a BytesValue. - * @implements IBytesValue - * @constructor - * @param {google.protobuf.IBytesValue=} [properties] Properties to set - */ - function BytesValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BytesValue value. - * @member {Uint8Array} value - * @memberof google.protobuf.BytesValue - * @instance - */ - BytesValue.prototype.value = $util.newBuffer([]); - - return BytesValue; - })(); - - protobuf.Any = (function() { - - /** - * Properties of an Any. - * @memberof google.protobuf - * @interface IAny - * @property {string|null} [type_url] Any type_url - * @property {Uint8Array|null} [value] Any value - */ - - /** - * Constructs a new Any. - * @memberof google.protobuf - * @classdesc Represents an Any. - * @implements IAny - * @constructor - * @param {google.protobuf.IAny=} [properties] Properties to set - */ - function Any(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Any type_url. - * @member {string} type_url - * @memberof google.protobuf.Any - * @instance - */ - Any.prototype.type_url = ""; - - /** - * Any value. - * @member {Uint8Array} value - * @memberof google.protobuf.Any - * @instance - */ - Any.prototype.value = $util.newBuffer([]); - - return Any; - })(); - - protobuf.FieldMask = (function() { - - /** - * Properties of a FieldMask. - * @memberof google.protobuf - * @interface IFieldMask - * @property {Array.|null} [paths] FieldMask paths - */ - - /** - * Constructs a new FieldMask. - * @memberof google.protobuf - * @classdesc Represents a FieldMask. - * @implements IFieldMask - * @constructor - * @param {google.protobuf.IFieldMask=} [properties] Properties to set - */ - function FieldMask(properties) { - this.paths = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FieldMask paths. - * @member {Array.} paths - * @memberof google.protobuf.FieldMask - * @instance - */ - FieldMask.prototype.paths = $util.emptyArray; - - return FieldMask; - })(); - - protobuf.Duration = (function() { - - /** - * Properties of a Duration. - * @memberof google.protobuf - * @interface IDuration - * @property {number|null} [seconds] Duration seconds - * @property {number|null} [nanos] Duration nanos - */ - - /** - * Constructs a new Duration. - * @memberof google.protobuf - * @classdesc Represents a Duration. - * @implements IDuration - * @constructor - * @param {google.protobuf.IDuration=} [properties] Properties to set - */ - function Duration(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Duration seconds. - * @member {number} seconds - * @memberof google.protobuf.Duration - * @instance - */ - Duration.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Duration nanos. - * @member {number} nanos - * @memberof google.protobuf.Duration - * @instance - */ - Duration.prototype.nanos = 0; - - return Duration; - })(); - - return protobuf; - })(); - - google.firestore = (function() { - - /** - * Namespace firestore. - * @memberof google - * @namespace - */ - var firestore = {}; - - firestore.v1beta1 = (function() { - - /** - * Namespace v1beta1. - * @memberof google.firestore - * @namespace - */ - var v1beta1 = {}; - - v1beta1.DocumentMask = (function() { - - /** - * Properties of a DocumentMask. - * @memberof google.firestore.v1beta1 - * @interface IDocumentMask - * @property {Array.|null} [fieldPaths] DocumentMask fieldPaths - */ - - /** - * Constructs a new DocumentMask. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a DocumentMask. - * @implements IDocumentMask + + protobuf.ServiceDescriptorProto = (function() { + + /** + * Properties of a ServiceDescriptorProto. + * @memberof google.protobuf + * @interface IServiceDescriptorProto + * @property {string|null} [name] ServiceDescriptorProto name + * @property {Array.|null} [method] ServiceDescriptorProto method + * @property {google.protobuf.IServiceOptions|null} [options] ServiceDescriptorProto options + */ + + /** + * Constructs a new ServiceDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a ServiceDescriptorProto. + * @implements IServiceDescriptorProto * @constructor - * @param {google.firestore.v1beta1.IDocumentMask=} [properties] Properties to set + * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set */ - function DocumentMask(properties) { - this.fieldPaths = []; + function ServiceDescriptorProto(properties) { + this.method = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * DocumentMask fieldPaths. - * @member {Array.} fieldPaths - * @memberof google.firestore.v1beta1.DocumentMask - * @instance - */ - DocumentMask.prototype.fieldPaths = $util.emptyArray; - - return DocumentMask; + * ServiceDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.name = ""; + + /** + * ServiceDescriptorProto method. + * @member {Array.} method + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.method = $util.emptyArray; + + /** + * ServiceDescriptorProto options. + * @member {google.protobuf.IServiceOptions|null|undefined} options + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.options = null; + + /** + * Creates a ServiceDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + */ + ServiceDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ServiceDescriptorProto) + return object; + var message = new $root.google.protobuf.ServiceDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.method) { + if (!Array.isArray(object.method)) + throw TypeError(".google.protobuf.ServiceDescriptorProto.method: array expected"); + message.method = []; + for (var i = 0; i < object.method.length; ++i) { + if (typeof object.method[i] !== "object") + throw TypeError(".google.protobuf.ServiceDescriptorProto.method: object expected"); + message.method[i] = $root.google.protobuf.MethodDescriptorProto.fromObject(object.method[i]); + } + } + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.ServiceDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.ServiceOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from a ServiceDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.ServiceDescriptorProto} message ServiceDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServiceDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.method = []; + if (options.defaults) { + object.name = ""; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.method && message.method.length) { + object.method = []; + for (var j = 0; j < message.method.length; ++j) + object.method[j] = $root.google.protobuf.MethodDescriptorProto.toObject(message.method[j], options); + } + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.ServiceOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this ServiceDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + ServiceDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ServiceDescriptorProto; })(); - - v1beta1.Precondition = (function() { - - /** - * Properties of a Precondition. - * @memberof google.firestore.v1beta1 - * @interface IPrecondition - * @property {boolean|null} [exists] Precondition exists - * @property {google.protobuf.ITimestamp|null} [updateTime] Precondition updateTime - */ - - /** - * Constructs a new Precondition. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a Precondition. - * @implements IPrecondition + + protobuf.MethodDescriptorProto = (function() { + + /** + * Properties of a MethodDescriptorProto. + * @memberof google.protobuf + * @interface IMethodDescriptorProto + * @property {string|null} [name] MethodDescriptorProto name + * @property {string|null} [inputType] MethodDescriptorProto inputType + * @property {string|null} [outputType] MethodDescriptorProto outputType + * @property {google.protobuf.IMethodOptions|null} [options] MethodDescriptorProto options + * @property {boolean|null} [clientStreaming] MethodDescriptorProto clientStreaming + * @property {boolean|null} [serverStreaming] MethodDescriptorProto serverStreaming + */ + + /** + * Constructs a new MethodDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a MethodDescriptorProto. + * @implements IMethodDescriptorProto * @constructor - * @param {google.firestore.v1beta1.IPrecondition=} [properties] Properties to set + * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set */ - function Precondition(properties) { + function MethodDescriptorProto(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * Precondition exists. - * @member {boolean} exists - * @memberof google.firestore.v1beta1.Precondition + * MethodDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.MethodDescriptorProto * @instance */ - Precondition.prototype.exists = false; - + MethodDescriptorProto.prototype.name = ""; + /** - * Precondition updateTime. - * @member {google.protobuf.ITimestamp|null|undefined} updateTime - * @memberof google.firestore.v1beta1.Precondition + * MethodDescriptorProto inputType. + * @member {string} inputType + * @memberof google.protobuf.MethodDescriptorProto * @instance */ - Precondition.prototype.updateTime = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - + MethodDescriptorProto.prototype.inputType = ""; + /** - * Precondition conditionType. - * @member {"exists"|"updateTime"|undefined} conditionType - * @memberof google.firestore.v1beta1.Precondition + * MethodDescriptorProto outputType. + * @member {string} outputType + * @memberof google.protobuf.MethodDescriptorProto * @instance */ - Object.defineProperty(Precondition.prototype, "conditionType", { - get: $util.oneOfGetter($oneOfFields = ["exists", "updateTime"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return Precondition; - })(); - - v1beta1.TransactionOptions = (function() { - - /** - * Properties of a TransactionOptions. - * @memberof google.firestore.v1beta1 - * @interface ITransactionOptions - * @property {google.firestore.v1beta1.TransactionOptions.IReadOnly|null} [readOnly] TransactionOptions readOnly - * @property {google.firestore.v1beta1.TransactionOptions.IReadWrite|null} [readWrite] TransactionOptions readWrite - */ - + MethodDescriptorProto.prototype.outputType = ""; + /** - * Constructs a new TransactionOptions. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a TransactionOptions. - * @implements ITransactionOptions - * @constructor - * @param {google.firestore.v1beta1.ITransactionOptions=} [properties] Properties to set + * MethodDescriptorProto options. + * @member {google.protobuf.IMethodOptions|null|undefined} options + * @memberof google.protobuf.MethodDescriptorProto + * @instance */ - function TransactionOptions(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - + MethodDescriptorProto.prototype.options = null; + /** - * TransactionOptions readOnly. - * @member {google.firestore.v1beta1.TransactionOptions.IReadOnly|null|undefined} readOnly - * @memberof google.firestore.v1beta1.TransactionOptions + * MethodDescriptorProto clientStreaming. + * @member {boolean} clientStreaming + * @memberof google.protobuf.MethodDescriptorProto * @instance */ - TransactionOptions.prototype.readOnly = null; - + MethodDescriptorProto.prototype.clientStreaming = false; + /** - * TransactionOptions readWrite. - * @member {google.firestore.v1beta1.TransactionOptions.IReadWrite|null|undefined} readWrite - * @memberof google.firestore.v1beta1.TransactionOptions + * MethodDescriptorProto serverStreaming. + * @member {boolean} serverStreaming + * @memberof google.protobuf.MethodDescriptorProto * @instance */ - TransactionOptions.prototype.readWrite = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - + MethodDescriptorProto.prototype.serverStreaming = false; + /** - * TransactionOptions mode. - * @member {"readOnly"|"readWrite"|undefined} mode - * @memberof google.firestore.v1beta1.TransactionOptions - * @instance + * Creates a MethodDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto */ - Object.defineProperty(TransactionOptions.prototype, "mode", { - get: $util.oneOfGetter($oneOfFields = ["readOnly", "readWrite"]), - set: $util.oneOfSetter($oneOfFields) - }); - - TransactionOptions.ReadWrite = (function() { - - /** - * Properties of a ReadWrite. - * @memberof google.firestore.v1beta1.TransactionOptions - * @interface IReadWrite - * @property {Uint8Array|null} [retryTransaction] ReadWrite retryTransaction - */ - - /** - * Constructs a new ReadWrite. - * @memberof google.firestore.v1beta1.TransactionOptions - * @classdesc Represents a ReadWrite. - * @implements IReadWrite - * @constructor - * @param {google.firestore.v1beta1.TransactionOptions.IReadWrite=} [properties] Properties to set - */ - function ReadWrite(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; + MethodDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MethodDescriptorProto) + return object; + var message = new $root.google.protobuf.MethodDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.inputType != null) + message.inputType = String(object.inputType); + if (object.outputType != null) + message.outputType = String(object.outputType); + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.MethodDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.MethodOptions.fromObject(object.options); } - - /** - * ReadWrite retryTransaction. - * @member {Uint8Array} retryTransaction - * @memberof google.firestore.v1beta1.TransactionOptions.ReadWrite - * @instance - */ - ReadWrite.prototype.retryTransaction = $util.newBuffer([]); - - return ReadWrite; - })(); - - TransactionOptions.ReadOnly = (function() { - - /** - * Properties of a ReadOnly. - * @memberof google.firestore.v1beta1.TransactionOptions - * @interface IReadOnly - * @property {google.protobuf.ITimestamp|null} [readTime] ReadOnly readTime - */ - - /** - * Constructs a new ReadOnly. - * @memberof google.firestore.v1beta1.TransactionOptions - * @classdesc Represents a ReadOnly. - * @implements IReadOnly - * @constructor - * @param {google.firestore.v1beta1.TransactionOptions.IReadOnly=} [properties] Properties to set - */ - function ReadOnly(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; + if (object.clientStreaming != null) + message.clientStreaming = Boolean(object.clientStreaming); + if (object.serverStreaming != null) + message.serverStreaming = Boolean(object.serverStreaming); + return message; + }; + + /** + * Creates a plain object from a MethodDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.MethodDescriptorProto} message MethodDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MethodDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.inputType = ""; + object.outputType = ""; + object.options = null; + object.clientStreaming = false; + object.serverStreaming = false; } - - /** - * ReadOnly readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1beta1.TransactionOptions.ReadOnly - * @instance - */ - ReadOnly.prototype.readTime = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * ReadOnly consistencySelector. - * @member {"readTime"|undefined} consistencySelector - * @memberof google.firestore.v1beta1.TransactionOptions.ReadOnly - * @instance - */ - Object.defineProperty(ReadOnly.prototype, "consistencySelector", { - get: $util.oneOfGetter($oneOfFields = ["readTime"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return ReadOnly; - })(); - - return TransactionOptions; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.inputType != null && message.hasOwnProperty("inputType")) + object.inputType = message.inputType; + if (message.outputType != null && message.hasOwnProperty("outputType")) + object.outputType = message.outputType; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.MethodOptions.toObject(message.options, options); + if (message.clientStreaming != null && message.hasOwnProperty("clientStreaming")) + object.clientStreaming = message.clientStreaming; + if (message.serverStreaming != null && message.hasOwnProperty("serverStreaming")) + object.serverStreaming = message.serverStreaming; + return object; + }; + + /** + * Converts this MethodDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.MethodDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + MethodDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return MethodDescriptorProto; })(); - - v1beta1.Document = (function() { - - /** - * Properties of a Document. - * @memberof google.firestore.v1beta1 - * @interface IDocument - * @property {string|null} [name] Document name - * @property {Object.|null} [fields] Document fields - * @property {google.protobuf.ITimestamp|null} [createTime] Document createTime - * @property {google.protobuf.ITimestamp|null} [updateTime] Document updateTime - */ - - /** - * Constructs a new Document. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a Document. - * @implements IDocument + + protobuf.FileOptions = (function() { + + /** + * Properties of a FileOptions. + * @memberof google.protobuf + * @interface IFileOptions + * @property {string|null} [javaPackage] FileOptions javaPackage + * @property {string|null} [javaOuterClassname] FileOptions javaOuterClassname + * @property {boolean|null} [javaMultipleFiles] FileOptions javaMultipleFiles + * @property {boolean|null} [javaGenerateEqualsAndHash] FileOptions javaGenerateEqualsAndHash + * @property {boolean|null} [javaStringCheckUtf8] FileOptions javaStringCheckUtf8 + * @property {google.protobuf.FileOptions.OptimizeMode|null} [optimizeFor] FileOptions optimizeFor + * @property {string|null} [goPackage] FileOptions goPackage + * @property {boolean|null} [ccGenericServices] FileOptions ccGenericServices + * @property {boolean|null} [javaGenericServices] FileOptions javaGenericServices + * @property {boolean|null} [pyGenericServices] FileOptions pyGenericServices + * @property {boolean|null} [deprecated] FileOptions deprecated + * @property {boolean|null} [ccEnableArenas] FileOptions ccEnableArenas + * @property {string|null} [objcClassPrefix] FileOptions objcClassPrefix + * @property {string|null} [csharpNamespace] FileOptions csharpNamespace + * @property {Array.|null} [uninterpretedOption] FileOptions uninterpretedOption + * @property {Array.|null} [".google.api.resourceDefinition"] FileOptions .google.api.resourceDefinition + */ + + /** + * Constructs a new FileOptions. + * @memberof google.protobuf + * @classdesc Represents a FileOptions. + * @implements IFileOptions * @constructor - * @param {google.firestore.v1beta1.IDocument=} [properties] Properties to set + * @param {google.protobuf.IFileOptions=} [properties] Properties to set */ - function Document(properties) { - this.fields = {}; + function FileOptions(properties) { + this.uninterpretedOption = []; + this[".google.api.resourceDefinition"] = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * Document name. - * @member {string} name - * @memberof google.firestore.v1beta1.Document + * FileOptions javaPackage. + * @member {string} javaPackage + * @memberof google.protobuf.FileOptions * @instance */ - Document.prototype.name = ""; - + FileOptions.prototype.javaPackage = ""; + /** - * Document fields. - * @member {Object.} fields - * @memberof google.firestore.v1beta1.Document + * FileOptions javaOuterClassname. + * @member {string} javaOuterClassname + * @memberof google.protobuf.FileOptions * @instance */ - Document.prototype.fields = $util.emptyObject; - + FileOptions.prototype.javaOuterClassname = ""; + /** - * Document createTime. - * @member {google.protobuf.ITimestamp|null|undefined} createTime - * @memberof google.firestore.v1beta1.Document + * FileOptions javaMultipleFiles. + * @member {boolean} javaMultipleFiles + * @memberof google.protobuf.FileOptions * @instance */ - Document.prototype.createTime = null; - + FileOptions.prototype.javaMultipleFiles = false; + /** - * Document updateTime. - * @member {google.protobuf.ITimestamp|null|undefined} updateTime - * @memberof google.firestore.v1beta1.Document + * FileOptions javaGenerateEqualsAndHash. + * @member {boolean} javaGenerateEqualsAndHash + * @memberof google.protobuf.FileOptions * @instance */ - Document.prototype.updateTime = null; - - return Document; - })(); - - v1beta1.Value = (function() { - + FileOptions.prototype.javaGenerateEqualsAndHash = false; + /** - * Properties of a Value. - * @memberof google.firestore.v1beta1 - * @interface IValue - * @property {google.protobuf.NullValue|null} [nullValue] Value nullValue - * @property {boolean|null} [booleanValue] Value booleanValue - * @property {number|null} [integerValue] Value integerValue - * @property {number|null} [doubleValue] Value doubleValue - * @property {google.protobuf.ITimestamp|null} [timestampValue] Value timestampValue - * @property {string|null} [stringValue] Value stringValue - * @property {Uint8Array|null} [bytesValue] Value bytesValue - * @property {string|null} [referenceValue] Value referenceValue - * @property {google.type.ILatLng|null} [geoPointValue] Value geoPointValue - * @property {google.firestore.v1beta1.IArrayValue|null} [arrayValue] Value arrayValue - * @property {google.firestore.v1beta1.IMapValue|null} [mapValue] Value mapValue + * FileOptions javaStringCheckUtf8. + * @member {boolean} javaStringCheckUtf8 + * @memberof google.protobuf.FileOptions + * @instance */ - + FileOptions.prototype.javaStringCheckUtf8 = false; + /** - * Constructs a new Value. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a Value. - * @implements IValue - * @constructor - * @param {google.firestore.v1beta1.IValue=} [properties] Properties to set + * FileOptions optimizeFor. + * @member {google.protobuf.FileOptions.OptimizeMode} optimizeFor + * @memberof google.protobuf.FileOptions + * @instance */ - function Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - + FileOptions.prototype.optimizeFor = 1; + /** - * Value nullValue. - * @member {google.protobuf.NullValue} nullValue - * @memberof google.firestore.v1beta1.Value + * FileOptions goPackage. + * @member {string} goPackage + * @memberof google.protobuf.FileOptions * @instance */ - Value.prototype.nullValue = 0; - + FileOptions.prototype.goPackage = ""; + /** - * Value booleanValue. - * @member {boolean} booleanValue - * @memberof google.firestore.v1beta1.Value + * FileOptions ccGenericServices. + * @member {boolean} ccGenericServices + * @memberof google.protobuf.FileOptions * @instance */ - Value.prototype.booleanValue = false; - + FileOptions.prototype.ccGenericServices = false; + /** - * Value integerValue. - * @member {number} integerValue - * @memberof google.firestore.v1beta1.Value + * FileOptions javaGenericServices. + * @member {boolean} javaGenericServices + * @memberof google.protobuf.FileOptions * @instance */ - Value.prototype.integerValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - + FileOptions.prototype.javaGenericServices = false; + /** - * Value doubleValue. - * @member {number} doubleValue - * @memberof google.firestore.v1beta1.Value + * FileOptions pyGenericServices. + * @member {boolean} pyGenericServices + * @memberof google.protobuf.FileOptions * @instance */ - Value.prototype.doubleValue = 0; - + FileOptions.prototype.pyGenericServices = false; + /** - * Value timestampValue. - * @member {google.protobuf.ITimestamp|null|undefined} timestampValue - * @memberof google.firestore.v1beta1.Value + * FileOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FileOptions * @instance */ - Value.prototype.timestampValue = null; - + FileOptions.prototype.deprecated = false; + /** - * Value stringValue. - * @member {string} stringValue - * @memberof google.firestore.v1beta1.Value + * FileOptions ccEnableArenas. + * @member {boolean} ccEnableArenas + * @memberof google.protobuf.FileOptions * @instance */ - Value.prototype.stringValue = ""; - + FileOptions.prototype.ccEnableArenas = false; + /** - * Value bytesValue. - * @member {Uint8Array} bytesValue - * @memberof google.firestore.v1beta1.Value + * FileOptions objcClassPrefix. + * @member {string} objcClassPrefix + * @memberof google.protobuf.FileOptions * @instance */ - Value.prototype.bytesValue = $util.newBuffer([]); - + FileOptions.prototype.objcClassPrefix = ""; + /** - * Value referenceValue. - * @member {string} referenceValue - * @memberof google.firestore.v1beta1.Value + * FileOptions csharpNamespace. + * @member {string} csharpNamespace + * @memberof google.protobuf.FileOptions * @instance */ - Value.prototype.referenceValue = ""; - + FileOptions.prototype.csharpNamespace = ""; + /** - * Value geoPointValue. - * @member {google.type.ILatLng|null|undefined} geoPointValue - * @memberof google.firestore.v1beta1.Value + * FileOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FileOptions * @instance */ - Value.prototype.geoPointValue = null; - + FileOptions.prototype.uninterpretedOption = $util.emptyArray; + /** - * Value arrayValue. - * @member {google.firestore.v1beta1.IArrayValue|null|undefined} arrayValue - * @memberof google.firestore.v1beta1.Value + * FileOptions .google.api.resourceDefinition. + * @member {Array.} .google.api.resourceDefinition + * @memberof google.protobuf.FileOptions * @instance */ - Value.prototype.arrayValue = null; - + FileOptions.prototype[".google.api.resourceDefinition"] = $util.emptyArray; + /** - * Value mapValue. - * @member {google.firestore.v1beta1.IMapValue|null|undefined} mapValue - * @memberof google.firestore.v1beta1.Value - * @instance + * Creates a FileOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileOptions} FileOptions */ - Value.prototype.mapValue = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - + FileOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileOptions) + return object; + var message = new $root.google.protobuf.FileOptions(); + if (object.javaPackage != null) + message.javaPackage = String(object.javaPackage); + if (object.javaOuterClassname != null) + message.javaOuterClassname = String(object.javaOuterClassname); + if (object.javaMultipleFiles != null) + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + if (object.javaGenerateEqualsAndHash != null) + message.javaGenerateEqualsAndHash = Boolean(object.javaGenerateEqualsAndHash); + if (object.javaStringCheckUtf8 != null) + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + switch (object.optimizeFor) { + case "SPEED": + case 1: + message.optimizeFor = 1; + break; + case "CODE_SIZE": + case 2: + message.optimizeFor = 2; + break; + case "LITE_RUNTIME": + case 3: + message.optimizeFor = 3; + break; + } + if (object.goPackage != null) + message.goPackage = String(object.goPackage); + if (object.ccGenericServices != null) + message.ccGenericServices = Boolean(object.ccGenericServices); + if (object.javaGenericServices != null) + message.javaGenericServices = Boolean(object.javaGenericServices); + if (object.pyGenericServices != null) + message.pyGenericServices = Boolean(object.pyGenericServices); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.ccEnableArenas != null) + message.ccEnableArenas = Boolean(object.ccEnableArenas); + if (object.objcClassPrefix != null) + message.objcClassPrefix = String(object.objcClassPrefix); + if (object.csharpNamespace != null) + message.csharpNamespace = String(object.csharpNamespace); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.FileOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.FileOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.resourceDefinition"]) { + if (!Array.isArray(object[".google.api.resourceDefinition"])) + throw TypeError(".google.protobuf.FileOptions..google.api.resourceDefinition: array expected"); + message[".google.api.resourceDefinition"] = []; + for (var i = 0; i < object[".google.api.resourceDefinition"].length; ++i) { + if (typeof object[".google.api.resourceDefinition"][i] !== "object") + throw TypeError(".google.protobuf.FileOptions..google.api.resourceDefinition: object expected"); + message[".google.api.resourceDefinition"][i] = $root.google.api.ResourceDescriptor.fromObject(object[".google.api.resourceDefinition"][i]); + } + } + return message; + }; + + /** + * Creates a plain object from a FileOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.FileOptions} message FileOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.uninterpretedOption = []; + object[".google.api.resourceDefinition"] = []; + } + if (options.defaults) { + object.javaPackage = ""; + object.javaOuterClassname = ""; + object.optimizeFor = options.enums === String ? "SPEED" : 1; + object.javaMultipleFiles = false; + object.goPackage = ""; + object.ccGenericServices = false; + object.javaGenericServices = false; + object.pyGenericServices = false; + object.javaGenerateEqualsAndHash = false; + object.deprecated = false; + object.javaStringCheckUtf8 = false; + object.ccEnableArenas = false; + object.objcClassPrefix = ""; + object.csharpNamespace = ""; + } + if (message.javaPackage != null && message.hasOwnProperty("javaPackage")) + object.javaPackage = message.javaPackage; + if (message.javaOuterClassname != null && message.hasOwnProperty("javaOuterClassname")) + object.javaOuterClassname = message.javaOuterClassname; + if (message.optimizeFor != null && message.hasOwnProperty("optimizeFor")) + object.optimizeFor = options.enums === String ? $root.google.protobuf.FileOptions.OptimizeMode[message.optimizeFor] : message.optimizeFor; + if (message.javaMultipleFiles != null && message.hasOwnProperty("javaMultipleFiles")) + object.javaMultipleFiles = message.javaMultipleFiles; + if (message.goPackage != null && message.hasOwnProperty("goPackage")) + object.goPackage = message.goPackage; + if (message.ccGenericServices != null && message.hasOwnProperty("ccGenericServices")) + object.ccGenericServices = message.ccGenericServices; + if (message.javaGenericServices != null && message.hasOwnProperty("javaGenericServices")) + object.javaGenericServices = message.javaGenericServices; + if (message.pyGenericServices != null && message.hasOwnProperty("pyGenericServices")) + object.pyGenericServices = message.pyGenericServices; + if (message.javaGenerateEqualsAndHash != null && message.hasOwnProperty("javaGenerateEqualsAndHash")) + object.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.javaStringCheckUtf8 != null && message.hasOwnProperty("javaStringCheckUtf8")) + object.javaStringCheckUtf8 = message.javaStringCheckUtf8; + if (message.ccEnableArenas != null && message.hasOwnProperty("ccEnableArenas")) + object.ccEnableArenas = message.ccEnableArenas; + if (message.objcClassPrefix != null && message.hasOwnProperty("objcClassPrefix")) + object.objcClassPrefix = message.objcClassPrefix; + if (message.csharpNamespace != null && message.hasOwnProperty("csharpNamespace")) + object.csharpNamespace = message.csharpNamespace; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.api.resourceDefinition"] && message[".google.api.resourceDefinition"].length) { + object[".google.api.resourceDefinition"] = []; + for (var j = 0; j < message[".google.api.resourceDefinition"].length; ++j) + object[".google.api.resourceDefinition"][j] = $root.google.api.ResourceDescriptor.toObject(message[".google.api.resourceDefinition"][j], options); + } + return object; + }; + /** - * Value valueType. - * @member {"nullValue"|"booleanValue"|"integerValue"|"doubleValue"|"timestampValue"|"stringValue"|"bytesValue"|"referenceValue"|"geoPointValue"|"arrayValue"|"mapValue"|undefined} valueType - * @memberof google.firestore.v1beta1.Value + * Converts this FileOptions to JSON. + * @function toJSON + * @memberof google.protobuf.FileOptions * @instance + * @returns {Object.} JSON object */ - Object.defineProperty(Value.prototype, "valueType", { - get: $util.oneOfGetter($oneOfFields = ["nullValue", "booleanValue", "integerValue", "doubleValue", "timestampValue", "stringValue", "bytesValue", "referenceValue", "geoPointValue", "arrayValue", "mapValue"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return Value; - })(); - - v1beta1.ArrayValue = (function() { - + FileOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + /** - * Properties of an ArrayValue. - * @memberof google.firestore.v1beta1 - * @interface IArrayValue - * @property {Array.|null} [values] ArrayValue values + * OptimizeMode enum. + * @name google.protobuf.FileOptions.OptimizeMode + * @enum {string} + * @property {string} SPEED=SPEED SPEED value + * @property {string} CODE_SIZE=CODE_SIZE CODE_SIZE value + * @property {string} LITE_RUNTIME=LITE_RUNTIME LITE_RUNTIME value */ - - /** - * Constructs a new ArrayValue. - * @memberof google.firestore.v1beta1 - * @classdesc Represents an ArrayValue. - * @implements IArrayValue + FileOptions.OptimizeMode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "SPEED"] = "SPEED"; + values[valuesById[2] = "CODE_SIZE"] = "CODE_SIZE"; + values[valuesById[3] = "LITE_RUNTIME"] = "LITE_RUNTIME"; + return values; + })(); + + return FileOptions; + })(); + + protobuf.MessageOptions = (function() { + + /** + * Properties of a MessageOptions. + * @memberof google.protobuf + * @interface IMessageOptions + * @property {boolean|null} [messageSetWireFormat] MessageOptions messageSetWireFormat + * @property {boolean|null} [noStandardDescriptorAccessor] MessageOptions noStandardDescriptorAccessor + * @property {boolean|null} [deprecated] MessageOptions deprecated + * @property {boolean|null} [mapEntry] MessageOptions mapEntry + * @property {Array.|null} [uninterpretedOption] MessageOptions uninterpretedOption + * @property {google.api.IResourceDescriptor|null} [".google.api.resource"] MessageOptions .google.api.resource + */ + + /** + * Constructs a new MessageOptions. + * @memberof google.protobuf + * @classdesc Represents a MessageOptions. + * @implements IMessageOptions * @constructor - * @param {google.firestore.v1beta1.IArrayValue=} [properties] Properties to set + * @param {google.protobuf.IMessageOptions=} [properties] Properties to set */ - function ArrayValue(properties) { - this.values = []; + function MessageOptions(properties) { + this.uninterpretedOption = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * ArrayValue values. - * @member {Array.} values - * @memberof google.firestore.v1beta1.ArrayValue + * MessageOptions messageSetWireFormat. + * @member {boolean} messageSetWireFormat + * @memberof google.protobuf.MessageOptions * @instance */ - ArrayValue.prototype.values = $util.emptyArray; - - return ArrayValue; - })(); - - v1beta1.MapValue = (function() { - + MessageOptions.prototype.messageSetWireFormat = false; + /** - * Properties of a MapValue. - * @memberof google.firestore.v1beta1 - * @interface IMapValue - * @property {Object.|null} [fields] MapValue fields + * MessageOptions noStandardDescriptorAccessor. + * @member {boolean} noStandardDescriptorAccessor + * @memberof google.protobuf.MessageOptions + * @instance */ - + MessageOptions.prototype.noStandardDescriptorAccessor = false; + + /** + * MessageOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.deprecated = false; + + /** + * MessageOptions mapEntry. + * @member {boolean} mapEntry + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.mapEntry = false; + + /** + * MessageOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * MessageOptions .google.api.resource. + * @member {google.api.IResourceDescriptor|null|undefined} .google.api.resource + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype[".google.api.resource"] = null; + /** - * Constructs a new MapValue. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a MapValue. - * @implements IMapValue + * Creates a MessageOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MessageOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MessageOptions} MessageOptions + */ + MessageOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MessageOptions) + return object; + var message = new $root.google.protobuf.MessageOptions(); + if (object.messageSetWireFormat != null) + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + if (object.noStandardDescriptorAccessor != null) + message.noStandardDescriptorAccessor = Boolean(object.noStandardDescriptorAccessor); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.mapEntry != null) + message.mapEntry = Boolean(object.mapEntry); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.MessageOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.MessageOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.resource"] != null) { + if (typeof object[".google.api.resource"] !== "object") + throw TypeError(".google.protobuf.MessageOptions..google.api.resource: object expected"); + message[".google.api.resource"] = $root.google.api.ResourceDescriptor.fromObject(object[".google.api.resource"]); + } + return message; + }; + + /** + * Creates a plain object from a MessageOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.MessageOptions} message MessageOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MessageOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) { + object.messageSetWireFormat = false; + object.noStandardDescriptorAccessor = false; + object.deprecated = false; + object.mapEntry = false; + object[".google.api.resource"] = null; + } + if (message.messageSetWireFormat != null && message.hasOwnProperty("messageSetWireFormat")) + object.messageSetWireFormat = message.messageSetWireFormat; + if (message.noStandardDescriptorAccessor != null && message.hasOwnProperty("noStandardDescriptorAccessor")) + object.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.mapEntry != null && message.hasOwnProperty("mapEntry")) + object.mapEntry = message.mapEntry; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.api.resource"] != null && message.hasOwnProperty(".google.api.resource")) + object[".google.api.resource"] = $root.google.api.ResourceDescriptor.toObject(message[".google.api.resource"], options); + return object; + }; + + /** + * Converts this MessageOptions to JSON. + * @function toJSON + * @memberof google.protobuf.MessageOptions + * @instance + * @returns {Object.} JSON object + */ + MessageOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return MessageOptions; + })(); + + protobuf.FieldOptions = (function() { + + /** + * Properties of a FieldOptions. + * @memberof google.protobuf + * @interface IFieldOptions + * @property {google.protobuf.FieldOptions.CType|null} [ctype] FieldOptions ctype + * @property {boolean|null} [packed] FieldOptions packed + * @property {google.protobuf.FieldOptions.JSType|null} [jstype] FieldOptions jstype + * @property {boolean|null} [lazy] FieldOptions lazy + * @property {boolean|null} [deprecated] FieldOptions deprecated + * @property {boolean|null} [weak] FieldOptions weak + * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption + * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior + * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference + */ + + /** + * Constructs a new FieldOptions. + * @memberof google.protobuf + * @classdesc Represents a FieldOptions. + * @implements IFieldOptions * @constructor - * @param {google.firestore.v1beta1.IMapValue=} [properties] Properties to set + * @param {google.protobuf.IFieldOptions=} [properties] Properties to set */ - function MapValue(properties) { - this.fields = {}; + function FieldOptions(properties) { + this.uninterpretedOption = []; + this[".google.api.fieldBehavior"] = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * MapValue fields. - * @member {Object.} fields - * @memberof google.firestore.v1beta1.MapValue + * FieldOptions ctype. + * @member {google.protobuf.FieldOptions.CType} ctype + * @memberof google.protobuf.FieldOptions * @instance */ - MapValue.prototype.fields = $util.emptyObject; - - return MapValue; - })(); - - v1beta1.Firestore = (function() { - + FieldOptions.prototype.ctype = 0; + /** - * Constructs a new Firestore service. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a Firestore - * @extends $protobuf.rpc.Service - * @constructor - * @param {$protobuf.RPCImpl} rpcImpl RPC implementation - * @param {boolean} [requestDelimited=false] Whether requests are length-delimited - * @param {boolean} [responseDelimited=false] Whether responses are length-delimited - */ - function Firestore(rpcImpl, requestDelimited, responseDelimited) { - $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); - } - - (Firestore.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Firestore; - - /** - * Callback as used by {@link google.firestore.v1beta1.Firestore#getDocument}. - * @memberof google.firestore.v1beta1.Firestore - * @typedef GetDocumentCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1beta1.Document} [response] Document - */ - - /** - * Calls GetDocument. - * @function getDocument - * @memberof google.firestore.v1beta1.Firestore + * FieldOptions packed. + * @member {boolean} packed + * @memberof google.protobuf.FieldOptions * @instance - * @param {google.firestore.v1beta1.IGetDocumentRequest} request GetDocumentRequest message or plain object - * @param {google.firestore.v1beta1.Firestore.GetDocumentCallback} callback Node-style callback called with the error, if any, and Document - * @returns {undefined} - * @variation 1 */ - Object.defineProperty(Firestore.prototype.getDocument = function getDocument(request, callback) { - return this.rpcCall(getDocument, $root.google.firestore.v1beta1.GetDocumentRequest, $root.google.firestore.v1beta1.Document, request, callback); - }, "name", { value: "GetDocument" }); - + FieldOptions.prototype.packed = false; + /** - * Calls GetDocument. - * @function getDocument - * @memberof google.firestore.v1beta1.Firestore + * FieldOptions jstype. + * @member {google.protobuf.FieldOptions.JSType} jstype + * @memberof google.protobuf.FieldOptions * @instance - * @param {google.firestore.v1beta1.IGetDocumentRequest} request GetDocumentRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.v1beta1.Firestore#listDocuments}. - * @memberof google.firestore.v1beta1.Firestore - * @typedef ListDocumentsCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1beta1.ListDocumentsResponse} [response] ListDocumentsResponse */ - + FieldOptions.prototype.jstype = 0; + /** - * Calls ListDocuments. - * @function listDocuments - * @memberof google.firestore.v1beta1.Firestore + * FieldOptions lazy. + * @member {boolean} lazy + * @memberof google.protobuf.FieldOptions * @instance - * @param {google.firestore.v1beta1.IListDocumentsRequest} request ListDocumentsRequest message or plain object - * @param {google.firestore.v1beta1.Firestore.ListDocumentsCallback} callback Node-style callback called with the error, if any, and ListDocumentsResponse - * @returns {undefined} - * @variation 1 */ - Object.defineProperty(Firestore.prototype.listDocuments = function listDocuments(request, callback) { - return this.rpcCall(listDocuments, $root.google.firestore.v1beta1.ListDocumentsRequest, $root.google.firestore.v1beta1.ListDocumentsResponse, request, callback); - }, "name", { value: "ListDocuments" }); - + FieldOptions.prototype.lazy = false; + /** - * Calls ListDocuments. - * @function listDocuments - * @memberof google.firestore.v1beta1.Firestore + * FieldOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FieldOptions * @instance - * @param {google.firestore.v1beta1.IListDocumentsRequest} request ListDocumentsRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.firestore.v1beta1.Firestore#createDocument}. - * @memberof google.firestore.v1beta1.Firestore - * @typedef CreateDocumentCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1beta1.Document} [response] Document */ - + FieldOptions.prototype.deprecated = false; + /** - * Calls CreateDocument. - * @function createDocument - * @memberof google.firestore.v1beta1.Firestore + * FieldOptions weak. + * @member {boolean} weak + * @memberof google.protobuf.FieldOptions * @instance - * @param {google.firestore.v1beta1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object - * @param {google.firestore.v1beta1.Firestore.CreateDocumentCallback} callback Node-style callback called with the error, if any, and Document - * @returns {undefined} - * @variation 1 */ - Object.defineProperty(Firestore.prototype.createDocument = function createDocument(request, callback) { - return this.rpcCall(createDocument, $root.google.firestore.v1beta1.CreateDocumentRequest, $root.google.firestore.v1beta1.Document, request, callback); - }, "name", { value: "CreateDocument" }); - + FieldOptions.prototype.weak = false; + /** - * Calls CreateDocument. - * @function createDocument - * @memberof google.firestore.v1beta1.Firestore + * FieldOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FieldOptions * @instance - * @param {google.firestore.v1beta1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object - * @returns {Promise} Promise - * @variation 2 */ - - /** - * Callback as used by {@link google.firestore.v1beta1.Firestore#updateDocument}. - * @memberof google.firestore.v1beta1.Firestore - * @typedef UpdateDocumentCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1beta1.Document} [response] Document - */ - + FieldOptions.prototype.uninterpretedOption = $util.emptyArray; + /** - * Calls UpdateDocument. - * @function updateDocument - * @memberof google.firestore.v1beta1.Firestore + * FieldOptions .google.api.fieldBehavior. + * @member {Array.} .google.api.fieldBehavior + * @memberof google.protobuf.FieldOptions * @instance - * @param {google.firestore.v1beta1.IUpdateDocumentRequest} request UpdateDocumentRequest message or plain object - * @param {google.firestore.v1beta1.Firestore.UpdateDocumentCallback} callback Node-style callback called with the error, if any, and Document - * @returns {undefined} - * @variation 1 */ - Object.defineProperty(Firestore.prototype.updateDocument = function updateDocument(request, callback) { - return this.rpcCall(updateDocument, $root.google.firestore.v1beta1.UpdateDocumentRequest, $root.google.firestore.v1beta1.Document, request, callback); - }, "name", { value: "UpdateDocument" }); - + FieldOptions.prototype[".google.api.fieldBehavior"] = $util.emptyArray; + /** - * Calls UpdateDocument. - * @function updateDocument - * @memberof google.firestore.v1beta1.Firestore + * FieldOptions .google.api.resourceReference. + * @member {google.api.IResourceReference|null|undefined} .google.api.resourceReference + * @memberof google.protobuf.FieldOptions * @instance - * @param {google.firestore.v1beta1.IUpdateDocumentRequest} request UpdateDocumentRequest message or plain object - * @returns {Promise} Promise - * @variation 2 */ - + FieldOptions.prototype[".google.api.resourceReference"] = null; + /** - * Callback as used by {@link google.firestore.v1beta1.Firestore#deleteDocument}. - * @memberof google.firestore.v1beta1.Firestore - * @typedef DeleteDocumentCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.protobuf.Empty} [response] Empty + * Creates a FieldOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions} FieldOptions */ - + FieldOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions) + return object; + var message = new $root.google.protobuf.FieldOptions(); + switch (object.ctype) { + case "STRING": + case 0: + message.ctype = 0; + break; + case "CORD": + case 1: + message.ctype = 1; + break; + case "STRING_PIECE": + case 2: + message.ctype = 2; + break; + } + if (object.packed != null) + message.packed = Boolean(object.packed); + switch (object.jstype) { + case "JS_NORMAL": + case 0: + message.jstype = 0; + break; + case "JS_STRING": + case 1: + message.jstype = 1; + break; + case "JS_NUMBER": + case 2: + message.jstype = 2; + break; + } + if (object.lazy != null) + message.lazy = Boolean(object.lazy); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.weak != null) + message.weak = Boolean(object.weak); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.fieldBehavior"]) { + if (!Array.isArray(object[".google.api.fieldBehavior"])) + throw TypeError(".google.protobuf.FieldOptions..google.api.fieldBehavior: array expected"); + message[".google.api.fieldBehavior"] = []; + for (var i = 0; i < object[".google.api.fieldBehavior"].length; ++i) + switch (object[".google.api.fieldBehavior"][i]) { + default: + case "FIELD_BEHAVIOR_UNSPECIFIED": + case 0: + message[".google.api.fieldBehavior"][i] = 0; + break; + case "OPTIONAL": + case 1: + message[".google.api.fieldBehavior"][i] = 1; + break; + case "REQUIRED": + case 2: + message[".google.api.fieldBehavior"][i] = 2; + break; + case "OUTPUT_ONLY": + case 3: + message[".google.api.fieldBehavior"][i] = 3; + break; + case "INPUT_ONLY": + case 4: + message[".google.api.fieldBehavior"][i] = 4; + break; + case "IMMUTABLE": + case 5: + message[".google.api.fieldBehavior"][i] = 5; + break; + } + } + if (object[".google.api.resourceReference"] != null) { + if (typeof object[".google.api.resourceReference"] !== "object") + throw TypeError(".google.protobuf.FieldOptions..google.api.resourceReference: object expected"); + message[".google.api.resourceReference"] = $root.google.api.ResourceReference.fromObject(object[".google.api.resourceReference"]); + } + return message; + }; + + /** + * Creates a plain object from a FieldOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.FieldOptions} message FieldOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.uninterpretedOption = []; + object[".google.api.fieldBehavior"] = []; + } + if (options.defaults) { + object.ctype = options.enums === String ? "STRING" : 0; + object.packed = false; + object.deprecated = false; + object.lazy = false; + object.jstype = options.enums === String ? "JS_NORMAL" : 0; + object.weak = false; + object[".google.api.resourceReference"] = null; + } + if (message.ctype != null && message.hasOwnProperty("ctype")) + object.ctype = options.enums === String ? $root.google.protobuf.FieldOptions.CType[message.ctype] : message.ctype; + if (message.packed != null && message.hasOwnProperty("packed")) + object.packed = message.packed; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.lazy != null && message.hasOwnProperty("lazy")) + object.lazy = message.lazy; + if (message.jstype != null && message.hasOwnProperty("jstype")) + object.jstype = options.enums === String ? $root.google.protobuf.FieldOptions.JSType[message.jstype] : message.jstype; + if (message.weak != null && message.hasOwnProperty("weak")) + object.weak = message.weak; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.api.fieldBehavior"] && message[".google.api.fieldBehavior"].length) { + object[".google.api.fieldBehavior"] = []; + for (var j = 0; j < message[".google.api.fieldBehavior"].length; ++j) + object[".google.api.fieldBehavior"][j] = options.enums === String ? $root.google.api.FieldBehavior[message[".google.api.fieldBehavior"][j]] : message[".google.api.fieldBehavior"][j]; + } + if (message[".google.api.resourceReference"] != null && message.hasOwnProperty(".google.api.resourceReference")) + object[".google.api.resourceReference"] = $root.google.api.ResourceReference.toObject(message[".google.api.resourceReference"], options); + return object; + }; + + /** + * Converts this FieldOptions to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions + * @instance + * @returns {Object.} JSON object + */ + FieldOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * CType enum. + * @name google.protobuf.FieldOptions.CType + * @enum {string} + * @property {string} STRING=STRING STRING value + * @property {string} CORD=CORD CORD value + * @property {string} STRING_PIECE=STRING_PIECE STRING_PIECE value + */ + FieldOptions.CType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STRING"] = "STRING"; + values[valuesById[1] = "CORD"] = "CORD"; + values[valuesById[2] = "STRING_PIECE"] = "STRING_PIECE"; + return values; + })(); + /** - * Calls DeleteDocument. - * @function deleteDocument - * @memberof google.firestore.v1beta1.Firestore - * @instance - * @param {google.firestore.v1beta1.IDeleteDocumentRequest} request DeleteDocumentRequest message or plain object - * @param {google.firestore.v1beta1.Firestore.DeleteDocumentCallback} callback Node-style callback called with the error, if any, and Empty - * @returns {undefined} - * @variation 1 + * JSType enum. + * @name google.protobuf.FieldOptions.JSType + * @enum {string} + * @property {string} JS_NORMAL=JS_NORMAL JS_NORMAL value + * @property {string} JS_STRING=JS_STRING JS_STRING value + * @property {string} JS_NUMBER=JS_NUMBER JS_NUMBER value */ - Object.defineProperty(Firestore.prototype.deleteDocument = function deleteDocument(request, callback) { - return this.rpcCall(deleteDocument, $root.google.firestore.v1beta1.DeleteDocumentRequest, $root.google.protobuf.Empty, request, callback); - }, "name", { value: "DeleteDocument" }); - + FieldOptions.JSType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "JS_NORMAL"] = "JS_NORMAL"; + values[valuesById[1] = "JS_STRING"] = "JS_STRING"; + values[valuesById[2] = "JS_NUMBER"] = "JS_NUMBER"; + return values; + })(); + + return FieldOptions; + })(); + + protobuf.OneofOptions = (function() { + /** - * Calls DeleteDocument. - * @function deleteDocument - * @memberof google.firestore.v1beta1.Firestore - * @instance - * @param {google.firestore.v1beta1.IDeleteDocumentRequest} request DeleteDocumentRequest message or plain object - * @returns {Promise} Promise - * @variation 2 + * Properties of an OneofOptions. + * @memberof google.protobuf + * @interface IOneofOptions + * @property {Array.|null} [uninterpretedOption] OneofOptions uninterpretedOption */ - + /** - * Callback as used by {@link google.firestore.v1beta1.Firestore#batchGetDocuments}. - * @memberof google.firestore.v1beta1.Firestore - * @typedef BatchGetDocumentsCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1beta1.BatchGetDocumentsResponse} [response] BatchGetDocumentsResponse + * Constructs a new OneofOptions. + * @memberof google.protobuf + * @classdesc Represents an OneofOptions. + * @implements IOneofOptions + * @constructor + * @param {google.protobuf.IOneofOptions=} [properties] Properties to set */ - + function OneofOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OneofOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.OneofOptions + * @instance + */ + OneofOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * Creates an OneofOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.OneofOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.OneofOptions} OneofOptions + */ + OneofOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.OneofOptions) + return object; + var message = new $root.google.protobuf.OneofOptions(); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.OneofOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.OneofOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an OneofOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.OneofOptions} message OneofOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OneofOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + return object; + }; + /** - * Calls BatchGetDocuments. - * @function batchGetDocuments - * @memberof google.firestore.v1beta1.Firestore + * Converts this OneofOptions to JSON. + * @function toJSON + * @memberof google.protobuf.OneofOptions * @instance - * @param {google.firestore.v1beta1.IBatchGetDocumentsRequest} request BatchGetDocumentsRequest message or plain object - * @param {google.firestore.v1beta1.Firestore.BatchGetDocumentsCallback} callback Node-style callback called with the error, if any, and BatchGetDocumentsResponse - * @returns {undefined} - * @variation 1 + * @returns {Object.} JSON object */ - Object.defineProperty(Firestore.prototype.batchGetDocuments = function batchGetDocuments(request, callback) { - return this.rpcCall(batchGetDocuments, $root.google.firestore.v1beta1.BatchGetDocumentsRequest, $root.google.firestore.v1beta1.BatchGetDocumentsResponse, request, callback); - }, "name", { value: "BatchGetDocuments" }); - + OneofOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return OneofOptions; + })(); + + protobuf.EnumOptions = (function() { + + /** + * Properties of an EnumOptions. + * @memberof google.protobuf + * @interface IEnumOptions + * @property {boolean|null} [allowAlias] EnumOptions allowAlias + * @property {boolean|null} [deprecated] EnumOptions deprecated + * @property {Array.|null} [uninterpretedOption] EnumOptions uninterpretedOption + */ + + /** + * Constructs a new EnumOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumOptions. + * @implements IEnumOptions + * @constructor + * @param {google.protobuf.IEnumOptions=} [properties] Properties to set + */ + function EnumOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumOptions allowAlias. + * @member {boolean} allowAlias + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.allowAlias = false; + + /** + * EnumOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.deprecated = false; + + /** + * EnumOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * Creates an EnumOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumOptions} EnumOptions + */ + EnumOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumOptions) + return object; + var message = new $root.google.protobuf.EnumOptions(); + if (object.allowAlias != null) + message.allowAlias = Boolean(object.allowAlias); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.EnumOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.EnumOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an EnumOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.EnumOptions} message EnumOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) { + object.allowAlias = false; + object.deprecated = false; + } + if (message.allowAlias != null && message.hasOwnProperty("allowAlias")) + object.allowAlias = message.allowAlias; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + return object; + }; + /** - * Calls BatchGetDocuments. - * @function batchGetDocuments - * @memberof google.firestore.v1beta1.Firestore + * Converts this EnumOptions to JSON. + * @function toJSON + * @memberof google.protobuf.EnumOptions * @instance - * @param {google.firestore.v1beta1.IBatchGetDocumentsRequest} request BatchGetDocumentsRequest message or plain object - * @returns {Promise} Promise - * @variation 2 + * @returns {Object.} JSON object */ - - /** - * Callback as used by {@link google.firestore.v1beta1.Firestore#beginTransaction}. - * @memberof google.firestore.v1beta1.Firestore - * @typedef BeginTransactionCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1beta1.BeginTransactionResponse} [response] BeginTransactionResponse + EnumOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return EnumOptions; + })(); + + protobuf.EnumValueOptions = (function() { + + /** + * Properties of an EnumValueOptions. + * @memberof google.protobuf + * @interface IEnumValueOptions + * @property {boolean|null} [deprecated] EnumValueOptions deprecated + * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption + */ + + /** + * Constructs a new EnumValueOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumValueOptions. + * @implements IEnumValueOptions + * @constructor + * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set */ - + function EnumValueOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumValueOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.deprecated = false; + + /** + * EnumValueOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * Creates an EnumValueOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + */ + EnumValueOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumValueOptions) + return object; + var message = new $root.google.protobuf.EnumValueOptions(); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an EnumValueOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.EnumValueOptions} message EnumValueOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumValueOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) + object.deprecated = false; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + return object; + }; + /** - * Calls BeginTransaction. - * @function beginTransaction - * @memberof google.firestore.v1beta1.Firestore + * Converts this EnumValueOptions to JSON. + * @function toJSON + * @memberof google.protobuf.EnumValueOptions * @instance - * @param {google.firestore.v1beta1.IBeginTransactionRequest} request BeginTransactionRequest message or plain object - * @param {google.firestore.v1beta1.Firestore.BeginTransactionCallback} callback Node-style callback called with the error, if any, and BeginTransactionResponse - * @returns {undefined} - * @variation 1 + * @returns {Object.} JSON object */ - Object.defineProperty(Firestore.prototype.beginTransaction = function beginTransaction(request, callback) { - return this.rpcCall(beginTransaction, $root.google.firestore.v1beta1.BeginTransactionRequest, $root.google.firestore.v1beta1.BeginTransactionResponse, request, callback); - }, "name", { value: "BeginTransaction" }); - + EnumValueOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return EnumValueOptions; + })(); + + protobuf.ServiceOptions = (function() { + + /** + * Properties of a ServiceOptions. + * @memberof google.protobuf + * @interface IServiceOptions + * @property {boolean|null} [deprecated] ServiceOptions deprecated + * @property {Array.|null} [uninterpretedOption] ServiceOptions uninterpretedOption + * @property {string|null} [".google.api.defaultHost"] ServiceOptions .google.api.defaultHost + * @property {string|null} [".google.api.oauthScopes"] ServiceOptions .google.api.oauthScopes + */ + + /** + * Constructs a new ServiceOptions. + * @memberof google.protobuf + * @classdesc Represents a ServiceOptions. + * @implements IServiceOptions + * @constructor + * @param {google.protobuf.IServiceOptions=} [properties] Properties to set + */ + function ServiceOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + /** - * Calls BeginTransaction. - * @function beginTransaction - * @memberof google.firestore.v1beta1.Firestore + * ServiceOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.ServiceOptions * @instance - * @param {google.firestore.v1beta1.IBeginTransactionRequest} request BeginTransactionRequest message or plain object - * @returns {Promise} Promise - * @variation 2 */ - + ServiceOptions.prototype.deprecated = false; + /** - * Callback as used by {@link google.firestore.v1beta1.Firestore#commit}. - * @memberof google.firestore.v1beta1.Firestore - * @typedef CommitCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1beta1.CommitResponse} [response] CommitResponse + * ServiceOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.ServiceOptions + * @instance */ - + ServiceOptions.prototype.uninterpretedOption = $util.emptyArray; + /** - * Calls Commit. - * @function commit - * @memberof google.firestore.v1beta1.Firestore + * ServiceOptions .google.api.defaultHost. + * @member {string} .google.api.defaultHost + * @memberof google.protobuf.ServiceOptions * @instance - * @param {google.firestore.v1beta1.ICommitRequest} request CommitRequest message or plain object - * @param {google.firestore.v1beta1.Firestore.CommitCallback} callback Node-style callback called with the error, if any, and CommitResponse - * @returns {undefined} - * @variation 1 */ - Object.defineProperty(Firestore.prototype.commit = function commit(request, callback) { - return this.rpcCall(commit, $root.google.firestore.v1beta1.CommitRequest, $root.google.firestore.v1beta1.CommitResponse, request, callback); - }, "name", { value: "Commit" }); - + ServiceOptions.prototype[".google.api.defaultHost"] = ""; + /** - * Calls Commit. - * @function commit - * @memberof google.firestore.v1beta1.Firestore + * ServiceOptions .google.api.oauthScopes. + * @member {string} .google.api.oauthScopes + * @memberof google.protobuf.ServiceOptions * @instance - * @param {google.firestore.v1beta1.ICommitRequest} request CommitRequest message or plain object - * @returns {Promise} Promise - * @variation 2 */ - + ServiceOptions.prototype[".google.api.oauthScopes"] = ""; + /** - * Callback as used by {@link google.firestore.v1beta1.Firestore#rollback}. - * @memberof google.firestore.v1beta1.Firestore - * @typedef RollbackCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.protobuf.Empty} [response] Empty + * Creates a ServiceOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ServiceOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ServiceOptions} ServiceOptions */ - + ServiceOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ServiceOptions) + return object; + var message = new $root.google.protobuf.ServiceOptions(); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.ServiceOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.ServiceOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.defaultHost"] != null) + message[".google.api.defaultHost"] = String(object[".google.api.defaultHost"]); + if (object[".google.api.oauthScopes"] != null) + message[".google.api.oauthScopes"] = String(object[".google.api.oauthScopes"]); + return message; + }; + + /** + * Creates a plain object from a ServiceOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.ServiceOptions} message ServiceOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServiceOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) { + object.deprecated = false; + object[".google.api.defaultHost"] = ""; + object[".google.api.oauthScopes"] = ""; + } + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.api.defaultHost"] != null && message.hasOwnProperty(".google.api.defaultHost")) + object[".google.api.defaultHost"] = message[".google.api.defaultHost"]; + if (message[".google.api.oauthScopes"] != null && message.hasOwnProperty(".google.api.oauthScopes")) + object[".google.api.oauthScopes"] = message[".google.api.oauthScopes"]; + return object; + }; + + /** + * Converts this ServiceOptions to JSON. + * @function toJSON + * @memberof google.protobuf.ServiceOptions + * @instance + * @returns {Object.} JSON object + */ + ServiceOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ServiceOptions; + })(); + + protobuf.MethodOptions = (function() { + + /** + * Properties of a MethodOptions. + * @memberof google.protobuf + * @interface IMethodOptions + * @property {boolean|null} [deprecated] MethodOptions deprecated + * @property {Array.|null} [uninterpretedOption] MethodOptions uninterpretedOption + * @property {google.api.IHttpRule|null} [".google.api.http"] MethodOptions .google.api.http + * @property {Array.|null} [".google.api.methodSignature"] MethodOptions .google.api.methodSignature + * @property {google.longrunning.IOperationInfo|null} [".google.longrunning.operationInfo"] MethodOptions .google.longrunning.operationInfo + */ + + /** + * Constructs a new MethodOptions. + * @memberof google.protobuf + * @classdesc Represents a MethodOptions. + * @implements IMethodOptions + * @constructor + * @param {google.protobuf.IMethodOptions=} [properties] Properties to set + */ + function MethodOptions(properties) { + this.uninterpretedOption = []; + this[".google.api.methodSignature"] = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + /** - * Calls Rollback. - * @function rollback - * @memberof google.firestore.v1beta1.Firestore + * MethodOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MethodOptions * @instance - * @param {google.firestore.v1beta1.IRollbackRequest} request RollbackRequest message or plain object - * @param {google.firestore.v1beta1.Firestore.RollbackCallback} callback Node-style callback called with the error, if any, and Empty - * @returns {undefined} - * @variation 1 */ - Object.defineProperty(Firestore.prototype.rollback = function rollback(request, callback) { - return this.rpcCall(rollback, $root.google.firestore.v1beta1.RollbackRequest, $root.google.protobuf.Empty, request, callback); - }, "name", { value: "Rollback" }); - + MethodOptions.prototype.deprecated = false; + /** - * Calls Rollback. - * @function rollback - * @memberof google.firestore.v1beta1.Firestore + * MethodOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MethodOptions * @instance - * @param {google.firestore.v1beta1.IRollbackRequest} request RollbackRequest message or plain object - * @returns {Promise} Promise - * @variation 2 */ - + MethodOptions.prototype.uninterpretedOption = $util.emptyArray; + /** - * Callback as used by {@link google.firestore.v1beta1.Firestore#runQuery}. - * @memberof google.firestore.v1beta1.Firestore - * @typedef RunQueryCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1beta1.RunQueryResponse} [response] RunQueryResponse + * MethodOptions .google.api.http. + * @member {google.api.IHttpRule|null|undefined} .google.api.http + * @memberof google.protobuf.MethodOptions + * @instance */ - + MethodOptions.prototype[".google.api.http"] = null; + /** - * Calls RunQuery. - * @function runQuery - * @memberof google.firestore.v1beta1.Firestore + * MethodOptions .google.api.methodSignature. + * @member {Array.} .google.api.methodSignature + * @memberof google.protobuf.MethodOptions * @instance - * @param {google.firestore.v1beta1.IRunQueryRequest} request RunQueryRequest message or plain object - * @param {google.firestore.v1beta1.Firestore.RunQueryCallback} callback Node-style callback called with the error, if any, and RunQueryResponse - * @returns {undefined} - * @variation 1 */ - Object.defineProperty(Firestore.prototype.runQuery = function runQuery(request, callback) { - return this.rpcCall(runQuery, $root.google.firestore.v1beta1.RunQueryRequest, $root.google.firestore.v1beta1.RunQueryResponse, request, callback); - }, "name", { value: "RunQuery" }); - + MethodOptions.prototype[".google.api.methodSignature"] = $util.emptyArray; + /** - * Calls RunQuery. - * @function runQuery - * @memberof google.firestore.v1beta1.Firestore + * MethodOptions .google.longrunning.operationInfo. + * @member {google.longrunning.IOperationInfo|null|undefined} .google.longrunning.operationInfo + * @memberof google.protobuf.MethodOptions * @instance - * @param {google.firestore.v1beta1.IRunQueryRequest} request RunQueryRequest message or plain object - * @returns {Promise} Promise - * @variation 2 */ - + MethodOptions.prototype[".google.longrunning.operationInfo"] = null; + /** - * Callback as used by {@link google.firestore.v1beta1.Firestore#write}. - * @memberof google.firestore.v1beta1.Firestore - * @typedef WriteCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1beta1.WriteResponse} [response] WriteResponse + * Creates a MethodOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MethodOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MethodOptions} MethodOptions */ - + MethodOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MethodOptions) + return object; + var message = new $root.google.protobuf.MethodOptions(); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.MethodOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.MethodOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.http"] != null) { + if (typeof object[".google.api.http"] !== "object") + throw TypeError(".google.protobuf.MethodOptions..google.api.http: object expected"); + message[".google.api.http"] = $root.google.api.HttpRule.fromObject(object[".google.api.http"]); + } + if (object[".google.api.methodSignature"]) { + if (!Array.isArray(object[".google.api.methodSignature"])) + throw TypeError(".google.protobuf.MethodOptions..google.api.methodSignature: array expected"); + message[".google.api.methodSignature"] = []; + for (var i = 0; i < object[".google.api.methodSignature"].length; ++i) + message[".google.api.methodSignature"][i] = String(object[".google.api.methodSignature"][i]); + } + if (object[".google.longrunning.operationInfo"] != null) { + if (typeof object[".google.longrunning.operationInfo"] !== "object") + throw TypeError(".google.protobuf.MethodOptions..google.longrunning.operationInfo: object expected"); + message[".google.longrunning.operationInfo"] = $root.google.longrunning.OperationInfo.fromObject(object[".google.longrunning.operationInfo"]); + } + return message; + }; + + /** + * Creates a plain object from a MethodOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.MethodOptions} message MethodOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MethodOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.uninterpretedOption = []; + object[".google.api.methodSignature"] = []; + } + if (options.defaults) { + object.deprecated = false; + object[".google.longrunning.operationInfo"] = null; + object[".google.api.http"] = null; + } + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.longrunning.operationInfo"] != null && message.hasOwnProperty(".google.longrunning.operationInfo")) + object[".google.longrunning.operationInfo"] = $root.google.longrunning.OperationInfo.toObject(message[".google.longrunning.operationInfo"], options); + if (message[".google.api.methodSignature"] && message[".google.api.methodSignature"].length) { + object[".google.api.methodSignature"] = []; + for (var j = 0; j < message[".google.api.methodSignature"].length; ++j) + object[".google.api.methodSignature"][j] = message[".google.api.methodSignature"][j]; + } + if (message[".google.api.http"] != null && message.hasOwnProperty(".google.api.http")) + object[".google.api.http"] = $root.google.api.HttpRule.toObject(message[".google.api.http"], options); + return object; + }; + + /** + * Converts this MethodOptions to JSON. + * @function toJSON + * @memberof google.protobuf.MethodOptions + * @instance + * @returns {Object.} JSON object + */ + MethodOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return MethodOptions; + })(); + + protobuf.UninterpretedOption = (function() { + + /** + * Properties of an UninterpretedOption. + * @memberof google.protobuf + * @interface IUninterpretedOption + * @property {Array.|null} [name] UninterpretedOption name + * @property {string|null} [identifierValue] UninterpretedOption identifierValue + * @property {number|string|null} [positiveIntValue] UninterpretedOption positiveIntValue + * @property {number|string|null} [negativeIntValue] UninterpretedOption negativeIntValue + * @property {number|null} [doubleValue] UninterpretedOption doubleValue + * @property {Uint8Array|null} [stringValue] UninterpretedOption stringValue + * @property {string|null} [aggregateValue] UninterpretedOption aggregateValue + */ + + /** + * Constructs a new UninterpretedOption. + * @memberof google.protobuf + * @classdesc Represents an UninterpretedOption. + * @implements IUninterpretedOption + * @constructor + * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set + */ + function UninterpretedOption(properties) { + this.name = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + /** - * Calls Write. - * @function write - * @memberof google.firestore.v1beta1.Firestore + * UninterpretedOption name. + * @member {Array.} name + * @memberof google.protobuf.UninterpretedOption * @instance - * @param {google.firestore.v1beta1.IWriteRequest} request WriteRequest message or plain object - * @param {google.firestore.v1beta1.Firestore.WriteCallback} callback Node-style callback called with the error, if any, and WriteResponse - * @returns {undefined} - * @variation 1 */ - Object.defineProperty(Firestore.prototype.write = function write(request, callback) { - return this.rpcCall(write, $root.google.firestore.v1beta1.WriteRequest, $root.google.firestore.v1beta1.WriteResponse, request, callback); - }, "name", { value: "Write" }); - + UninterpretedOption.prototype.name = $util.emptyArray; + /** - * Calls Write. - * @function write - * @memberof google.firestore.v1beta1.Firestore + * UninterpretedOption identifierValue. + * @member {string} identifierValue + * @memberof google.protobuf.UninterpretedOption * @instance - * @param {google.firestore.v1beta1.IWriteRequest} request WriteRequest message or plain object - * @returns {Promise} Promise - * @variation 2 */ - + UninterpretedOption.prototype.identifierValue = ""; + /** - * Callback as used by {@link google.firestore.v1beta1.Firestore#listen}. - * @memberof google.firestore.v1beta1.Firestore - * @typedef ListenCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1beta1.ListenResponse} [response] ListenResponse + * UninterpretedOption positiveIntValue. + * @member {number|string} positiveIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance */ - + UninterpretedOption.prototype.positiveIntValue = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + /** - * Calls Listen. - * @function listen - * @memberof google.firestore.v1beta1.Firestore + * UninterpretedOption negativeIntValue. + * @member {number|string} negativeIntValue + * @memberof google.protobuf.UninterpretedOption * @instance - * @param {google.firestore.v1beta1.IListenRequest} request ListenRequest message or plain object - * @param {google.firestore.v1beta1.Firestore.ListenCallback} callback Node-style callback called with the error, if any, and ListenResponse - * @returns {undefined} - * @variation 1 */ - Object.defineProperty(Firestore.prototype.listen = function listen(request, callback) { - return this.rpcCall(listen, $root.google.firestore.v1beta1.ListenRequest, $root.google.firestore.v1beta1.ListenResponse, request, callback); - }, "name", { value: "Listen" }); - + UninterpretedOption.prototype.negativeIntValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + /** - * Calls Listen. - * @function listen - * @memberof google.firestore.v1beta1.Firestore + * UninterpretedOption doubleValue. + * @member {number} doubleValue + * @memberof google.protobuf.UninterpretedOption * @instance - * @param {google.firestore.v1beta1.IListenRequest} request ListenRequest message or plain object - * @returns {Promise} Promise - * @variation 2 */ - + UninterpretedOption.prototype.doubleValue = 0; + /** - * Callback as used by {@link google.firestore.v1beta1.Firestore#listCollectionIds}. - * @memberof google.firestore.v1beta1.Firestore - * @typedef ListCollectionIdsCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1beta1.ListCollectionIdsResponse} [response] ListCollectionIdsResponse + * UninterpretedOption stringValue. + * @member {Uint8Array} stringValue + * @memberof google.protobuf.UninterpretedOption + * @instance */ - + UninterpretedOption.prototype.stringValue = $util.newBuffer([]); + /** - * Calls ListCollectionIds. - * @function listCollectionIds - * @memberof google.firestore.v1beta1.Firestore + * UninterpretedOption aggregateValue. + * @member {string} aggregateValue + * @memberof google.protobuf.UninterpretedOption * @instance - * @param {google.firestore.v1beta1.IListCollectionIdsRequest} request ListCollectionIdsRequest message or plain object - * @param {google.firestore.v1beta1.Firestore.ListCollectionIdsCallback} callback Node-style callback called with the error, if any, and ListCollectionIdsResponse - * @returns {undefined} - * @variation 1 */ - Object.defineProperty(Firestore.prototype.listCollectionIds = function listCollectionIds(request, callback) { - return this.rpcCall(listCollectionIds, $root.google.firestore.v1beta1.ListCollectionIdsRequest, $root.google.firestore.v1beta1.ListCollectionIdsResponse, request, callback); - }, "name", { value: "ListCollectionIds" }); - + UninterpretedOption.prototype.aggregateValue = ""; + /** - * Calls ListCollectionIds. - * @function listCollectionIds - * @memberof google.firestore.v1beta1.Firestore + * Creates an UninterpretedOption message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + */ + UninterpretedOption.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UninterpretedOption) + return object; + var message = new $root.google.protobuf.UninterpretedOption(); + if (object.name) { + if (!Array.isArray(object.name)) + throw TypeError(".google.protobuf.UninterpretedOption.name: array expected"); + message.name = []; + for (var i = 0; i < object.name.length; ++i) { + if (typeof object.name[i] !== "object") + throw TypeError(".google.protobuf.UninterpretedOption.name: object expected"); + message.name[i] = $root.google.protobuf.UninterpretedOption.NamePart.fromObject(object.name[i]); + } + } + if (object.identifierValue != null) + message.identifierValue = String(object.identifierValue); + if (object.positiveIntValue != null) + if ($util.Long) + (message.positiveIntValue = $util.Long.fromValue(object.positiveIntValue)).unsigned = true; + else if (typeof object.positiveIntValue === "string") + message.positiveIntValue = parseInt(object.positiveIntValue, 10); + else if (typeof object.positiveIntValue === "number") + message.positiveIntValue = object.positiveIntValue; + else if (typeof object.positiveIntValue === "object") + message.positiveIntValue = new $util.LongBits(object.positiveIntValue.low >>> 0, object.positiveIntValue.high >>> 0).toNumber(true); + if (object.negativeIntValue != null) + if ($util.Long) + (message.negativeIntValue = $util.Long.fromValue(object.negativeIntValue)).unsigned = false; + else if (typeof object.negativeIntValue === "string") + message.negativeIntValue = parseInt(object.negativeIntValue, 10); + else if (typeof object.negativeIntValue === "number") + message.negativeIntValue = object.negativeIntValue; + else if (typeof object.negativeIntValue === "object") + message.negativeIntValue = new $util.LongBits(object.negativeIntValue.low >>> 0, object.negativeIntValue.high >>> 0).toNumber(); + if (object.doubleValue != null) + message.doubleValue = Number(object.doubleValue); + if (object.stringValue != null) + if (typeof object.stringValue === "string") + $util.base64.decode(object.stringValue, message.stringValue = $util.newBuffer($util.base64.length(object.stringValue)), 0); + else if (object.stringValue.length) + message.stringValue = object.stringValue; + if (object.aggregateValue != null) + message.aggregateValue = String(object.aggregateValue); + return message; + }; + + /** + * Creates a plain object from an UninterpretedOption message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.UninterpretedOption} message UninterpretedOption + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UninterpretedOption.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.name = []; + if (options.defaults) { + object.identifierValue = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.positiveIntValue = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.positiveIntValue = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.negativeIntValue = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.negativeIntValue = options.longs === String ? "0" : 0; + object.doubleValue = 0; + if (options.bytes === String) + object.stringValue = ""; + else { + object.stringValue = []; + if (options.bytes !== Array) + object.stringValue = $util.newBuffer(object.stringValue); + } + object.aggregateValue = ""; + } + if (message.name && message.name.length) { + object.name = []; + for (var j = 0; j < message.name.length; ++j) + object.name[j] = $root.google.protobuf.UninterpretedOption.NamePart.toObject(message.name[j], options); + } + if (message.identifierValue != null && message.hasOwnProperty("identifierValue")) + object.identifierValue = message.identifierValue; + if (message.positiveIntValue != null && message.hasOwnProperty("positiveIntValue")) + if (typeof message.positiveIntValue === "number") + object.positiveIntValue = options.longs === String ? String(message.positiveIntValue) : message.positiveIntValue; + else + object.positiveIntValue = options.longs === String ? $util.Long.prototype.toString.call(message.positiveIntValue) : options.longs === Number ? new $util.LongBits(message.positiveIntValue.low >>> 0, message.positiveIntValue.high >>> 0).toNumber(true) : message.positiveIntValue; + if (message.negativeIntValue != null && message.hasOwnProperty("negativeIntValue")) + if (typeof message.negativeIntValue === "number") + object.negativeIntValue = options.longs === String ? String(message.negativeIntValue) : message.negativeIntValue; + else + object.negativeIntValue = options.longs === String ? $util.Long.prototype.toString.call(message.negativeIntValue) : options.longs === Number ? new $util.LongBits(message.negativeIntValue.low >>> 0, message.negativeIntValue.high >>> 0).toNumber() : message.negativeIntValue; + if (message.doubleValue != null && message.hasOwnProperty("doubleValue")) + object.doubleValue = options.json && !isFinite(message.doubleValue) ? String(message.doubleValue) : message.doubleValue; + if (message.stringValue != null && message.hasOwnProperty("stringValue")) + object.stringValue = options.bytes === String ? $util.base64.encode(message.stringValue, 0, message.stringValue.length) : options.bytes === Array ? Array.prototype.slice.call(message.stringValue) : message.stringValue; + if (message.aggregateValue != null && message.hasOwnProperty("aggregateValue")) + object.aggregateValue = message.aggregateValue; + return object; + }; + + /** + * Converts this UninterpretedOption to JSON. + * @function toJSON + * @memberof google.protobuf.UninterpretedOption * @instance - * @param {google.firestore.v1beta1.IListCollectionIdsRequest} request ListCollectionIdsRequest message or plain object - * @returns {Promise} Promise - * @variation 2 + * @returns {Object.} JSON object */ - - return Firestore; + UninterpretedOption.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + UninterpretedOption.NamePart = (function() { + + /** + * Properties of a NamePart. + * @memberof google.protobuf.UninterpretedOption + * @interface INamePart + * @property {string} namePart NamePart namePart + * @property {boolean} isExtension NamePart isExtension + */ + + /** + * Constructs a new NamePart. + * @memberof google.protobuf.UninterpretedOption + * @classdesc Represents a NamePart. + * @implements INamePart + * @constructor + * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set + */ + function NamePart(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * NamePart namePart. + * @member {string} namePart + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.namePart = ""; + + /** + * NamePart isExtension. + * @member {boolean} isExtension + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.isExtension = false; + + /** + * Creates a NamePart message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + */ + NamePart.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UninterpretedOption.NamePart) + return object; + var message = new $root.google.protobuf.UninterpretedOption.NamePart(); + if (object.namePart != null) + message.namePart = String(object.namePart); + if (object.isExtension != null) + message.isExtension = Boolean(object.isExtension); + return message; + }; + + /** + * Creates a plain object from a NamePart message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.NamePart} message NamePart + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + NamePart.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.namePart = ""; + object.isExtension = false; + } + if (message.namePart != null && message.hasOwnProperty("namePart")) + object.namePart = message.namePart; + if (message.isExtension != null && message.hasOwnProperty("isExtension")) + object.isExtension = message.isExtension; + return object; + }; + + /** + * Converts this NamePart to JSON. + * @function toJSON + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + * @returns {Object.} JSON object + */ + NamePart.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return NamePart; + })(); + + return UninterpretedOption; })(); - - v1beta1.GetDocumentRequest = (function() { - + + protobuf.SourceCodeInfo = (function() { + /** - * Properties of a GetDocumentRequest. - * @memberof google.firestore.v1beta1 - * @interface IGetDocumentRequest - * @property {string|null} [name] GetDocumentRequest name - * @property {google.firestore.v1beta1.IDocumentMask|null} [mask] GetDocumentRequest mask - * @property {Uint8Array|null} [transaction] GetDocumentRequest transaction - * @property {google.protobuf.ITimestamp|null} [readTime] GetDocumentRequest readTime + * Properties of a SourceCodeInfo. + * @memberof google.protobuf + * @interface ISourceCodeInfo + * @property {Array.|null} [location] SourceCodeInfo location */ - + /** - * Constructs a new GetDocumentRequest. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a GetDocumentRequest. - * @implements IGetDocumentRequest + * Constructs a new SourceCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a SourceCodeInfo. + * @implements ISourceCodeInfo * @constructor - * @param {google.firestore.v1beta1.IGetDocumentRequest=} [properties] Properties to set + * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set */ - function GetDocumentRequest(properties) { + function SourceCodeInfo(properties) { + this.location = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * GetDocumentRequest name. - * @member {string} name - * @memberof google.firestore.v1beta1.GetDocumentRequest + * SourceCodeInfo location. + * @member {Array.} location + * @memberof google.protobuf.SourceCodeInfo * @instance */ - GetDocumentRequest.prototype.name = ""; - + SourceCodeInfo.prototype.location = $util.emptyArray; + + /** + * Creates a SourceCodeInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + */ + SourceCodeInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.SourceCodeInfo) + return object; + var message = new $root.google.protobuf.SourceCodeInfo(); + if (object.location) { + if (!Array.isArray(object.location)) + throw TypeError(".google.protobuf.SourceCodeInfo.location: array expected"); + message.location = []; + for (var i = 0; i < object.location.length; ++i) { + if (typeof object.location[i] !== "object") + throw TypeError(".google.protobuf.SourceCodeInfo.location: object expected"); + message.location[i] = $root.google.protobuf.SourceCodeInfo.Location.fromObject(object.location[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a SourceCodeInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.SourceCodeInfo} message SourceCodeInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SourceCodeInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.location = []; + if (message.location && message.location.length) { + object.location = []; + for (var j = 0; j < message.location.length; ++j) + object.location[j] = $root.google.protobuf.SourceCodeInfo.Location.toObject(message.location[j], options); + } + return object; + }; + /** - * GetDocumentRequest mask. - * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} mask - * @memberof google.firestore.v1beta1.GetDocumentRequest + * Converts this SourceCodeInfo to JSON. + * @function toJSON + * @memberof google.protobuf.SourceCodeInfo * @instance + * @returns {Object.} JSON object */ - GetDocumentRequest.prototype.mask = null; - + SourceCodeInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + SourceCodeInfo.Location = (function() { + + /** + * Properties of a Location. + * @memberof google.protobuf.SourceCodeInfo + * @interface ILocation + * @property {Array.|null} [path] Location path + * @property {Array.|null} [span] Location span + * @property {string|null} [leadingComments] Location leadingComments + * @property {string|null} [trailingComments] Location trailingComments + * @property {Array.|null} [leadingDetachedComments] Location leadingDetachedComments + */ + + /** + * Constructs a new Location. + * @memberof google.protobuf.SourceCodeInfo + * @classdesc Represents a Location. + * @implements ILocation + * @constructor + * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set + */ + function Location(properties) { + this.path = []; + this.span = []; + this.leadingDetachedComments = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Location path. + * @member {Array.} path + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.path = $util.emptyArray; + + /** + * Location span. + * @member {Array.} span + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.span = $util.emptyArray; + + /** + * Location leadingComments. + * @member {string} leadingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingComments = ""; + + /** + * Location trailingComments. + * @member {string} trailingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.trailingComments = ""; + + /** + * Location leadingDetachedComments. + * @member {Array.} leadingDetachedComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingDetachedComments = $util.emptyArray; + + /** + * Creates a Location message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.SourceCodeInfo.Location} Location + */ + Location.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.SourceCodeInfo.Location) + return object; + var message = new $root.google.protobuf.SourceCodeInfo.Location(); + if (object.path) { + if (!Array.isArray(object.path)) + throw TypeError(".google.protobuf.SourceCodeInfo.Location.path: array expected"); + message.path = []; + for (var i = 0; i < object.path.length; ++i) + message.path[i] = object.path[i] | 0; + } + if (object.span) { + if (!Array.isArray(object.span)) + throw TypeError(".google.protobuf.SourceCodeInfo.Location.span: array expected"); + message.span = []; + for (var i = 0; i < object.span.length; ++i) + message.span[i] = object.span[i] | 0; + } + if (object.leadingComments != null) + message.leadingComments = String(object.leadingComments); + if (object.trailingComments != null) + message.trailingComments = String(object.trailingComments); + if (object.leadingDetachedComments) { + if (!Array.isArray(object.leadingDetachedComments)) + throw TypeError(".google.protobuf.SourceCodeInfo.Location.leadingDetachedComments: array expected"); + message.leadingDetachedComments = []; + for (var i = 0; i < object.leadingDetachedComments.length; ++i) + message.leadingDetachedComments[i] = String(object.leadingDetachedComments[i]); + } + return message; + }; + + /** + * Creates a plain object from a Location message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.Location} message Location + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Location.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.path = []; + object.span = []; + object.leadingDetachedComments = []; + } + if (options.defaults) { + object.leadingComments = ""; + object.trailingComments = ""; + } + if (message.path && message.path.length) { + object.path = []; + for (var j = 0; j < message.path.length; ++j) + object.path[j] = message.path[j]; + } + if (message.span && message.span.length) { + object.span = []; + for (var j = 0; j < message.span.length; ++j) + object.span[j] = message.span[j]; + } + if (message.leadingComments != null && message.hasOwnProperty("leadingComments")) + object.leadingComments = message.leadingComments; + if (message.trailingComments != null && message.hasOwnProperty("trailingComments")) + object.trailingComments = message.trailingComments; + if (message.leadingDetachedComments && message.leadingDetachedComments.length) { + object.leadingDetachedComments = []; + for (var j = 0; j < message.leadingDetachedComments.length; ++j) + object.leadingDetachedComments[j] = message.leadingDetachedComments[j]; + } + return object; + }; + + /** + * Converts this Location to JSON. + * @function toJSON + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + * @returns {Object.} JSON object + */ + Location.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Location; + })(); + + return SourceCodeInfo; + })(); + + protobuf.GeneratedCodeInfo = (function() { + /** - * GetDocumentRequest transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1beta1.GetDocumentRequest - * @instance + * Properties of a GeneratedCodeInfo. + * @memberof google.protobuf + * @interface IGeneratedCodeInfo + * @property {Array.|null} [annotation] GeneratedCodeInfo annotation */ - GetDocumentRequest.prototype.transaction = $util.newBuffer([]); - + + /** + * Constructs a new GeneratedCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a GeneratedCodeInfo. + * @implements IGeneratedCodeInfo + * @constructor + * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set + */ + function GeneratedCodeInfo(properties) { + this.annotation = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + /** - * GetDocumentRequest readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1beta1.GetDocumentRequest + * GeneratedCodeInfo annotation. + * @member {Array.} annotation + * @memberof google.protobuf.GeneratedCodeInfo * @instance */ - GetDocumentRequest.prototype.readTime = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - + GeneratedCodeInfo.prototype.annotation = $util.emptyArray; + + /** + * Creates a GeneratedCodeInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + */ + GeneratedCodeInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.GeneratedCodeInfo) + return object; + var message = new $root.google.protobuf.GeneratedCodeInfo(); + if (object.annotation) { + if (!Array.isArray(object.annotation)) + throw TypeError(".google.protobuf.GeneratedCodeInfo.annotation: array expected"); + message.annotation = []; + for (var i = 0; i < object.annotation.length; ++i) { + if (typeof object.annotation[i] !== "object") + throw TypeError(".google.protobuf.GeneratedCodeInfo.annotation: object expected"); + message.annotation[i] = $root.google.protobuf.GeneratedCodeInfo.Annotation.fromObject(object.annotation[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a GeneratedCodeInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.GeneratedCodeInfo} message GeneratedCodeInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GeneratedCodeInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.annotation = []; + if (message.annotation && message.annotation.length) { + object.annotation = []; + for (var j = 0; j < message.annotation.length; ++j) + object.annotation[j] = $root.google.protobuf.GeneratedCodeInfo.Annotation.toObject(message.annotation[j], options); + } + return object; + }; + /** - * GetDocumentRequest consistencySelector. - * @member {"transaction"|"readTime"|undefined} consistencySelector - * @memberof google.firestore.v1beta1.GetDocumentRequest + * Converts this GeneratedCodeInfo to JSON. + * @function toJSON + * @memberof google.protobuf.GeneratedCodeInfo * @instance + * @returns {Object.} JSON object */ - Object.defineProperty(GetDocumentRequest.prototype, "consistencySelector", { - get: $util.oneOfGetter($oneOfFields = ["transaction", "readTime"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return GetDocumentRequest; + GeneratedCodeInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + GeneratedCodeInfo.Annotation = (function() { + + /** + * Properties of an Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @interface IAnnotation + * @property {Array.|null} [path] Annotation path + * @property {string|null} [sourceFile] Annotation sourceFile + * @property {number|null} [begin] Annotation begin + * @property {number|null} [end] Annotation end + */ + + /** + * Constructs a new Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @classdesc Represents an Annotation. + * @implements IAnnotation + * @constructor + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set + */ + function Annotation(properties) { + this.path = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Annotation path. + * @member {Array.} path + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.path = $util.emptyArray; + + /** + * Annotation sourceFile. + * @member {string} sourceFile + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.sourceFile = ""; + + /** + * Annotation begin. + * @member {number} begin + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.begin = 0; + + /** + * Annotation end. + * @member {number} end + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.end = 0; + + /** + * Creates an Annotation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + */ + Annotation.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.GeneratedCodeInfo.Annotation) + return object; + var message = new $root.google.protobuf.GeneratedCodeInfo.Annotation(); + if (object.path) { + if (!Array.isArray(object.path)) + throw TypeError(".google.protobuf.GeneratedCodeInfo.Annotation.path: array expected"); + message.path = []; + for (var i = 0; i < object.path.length; ++i) + message.path[i] = object.path[i] | 0; + } + if (object.sourceFile != null) + message.sourceFile = String(object.sourceFile); + if (object.begin != null) + message.begin = object.begin | 0; + if (object.end != null) + message.end = object.end | 0; + return message; + }; + + /** + * Creates a plain object from an Annotation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.Annotation} message Annotation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Annotation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.path = []; + if (options.defaults) { + object.sourceFile = ""; + object.begin = 0; + object.end = 0; + } + if (message.path && message.path.length) { + object.path = []; + for (var j = 0; j < message.path.length; ++j) + object.path[j] = message.path[j]; + } + if (message.sourceFile != null && message.hasOwnProperty("sourceFile")) + object.sourceFile = message.sourceFile; + if (message.begin != null && message.hasOwnProperty("begin")) + object.begin = message.begin; + if (message.end != null && message.hasOwnProperty("end")) + object.end = message.end; + return object; + }; + + /** + * Converts this Annotation to JSON. + * @function toJSON + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + * @returns {Object.} JSON object + */ + Annotation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Annotation; + })(); + + return GeneratedCodeInfo; })(); - - v1beta1.ListDocumentsRequest = (function() { - + + protobuf.Struct = (function() { + /** - * Properties of a ListDocumentsRequest. - * @memberof google.firestore.v1beta1 - * @interface IListDocumentsRequest - * @property {string|null} [parent] ListDocumentsRequest parent - * @property {string|null} [collectionId] ListDocumentsRequest collectionId - * @property {number|null} [pageSize] ListDocumentsRequest pageSize - * @property {string|null} [pageToken] ListDocumentsRequest pageToken - * @property {string|null} [orderBy] ListDocumentsRequest orderBy - * @property {google.firestore.v1beta1.IDocumentMask|null} [mask] ListDocumentsRequest mask - * @property {Uint8Array|null} [transaction] ListDocumentsRequest transaction - * @property {google.protobuf.ITimestamp|null} [readTime] ListDocumentsRequest readTime - * @property {boolean|null} [showMissing] ListDocumentsRequest showMissing + * Properties of a Struct. + * @memberof google.protobuf + * @interface IStruct + * @property {Object.|null} [fields] Struct fields */ - + /** - * Constructs a new ListDocumentsRequest. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a ListDocumentsRequest. - * @implements IListDocumentsRequest + * Constructs a new Struct. + * @memberof google.protobuf + * @classdesc Represents a Struct. + * @implements IStruct * @constructor - * @param {google.firestore.v1beta1.IListDocumentsRequest=} [properties] Properties to set + * @param {google.protobuf.IStruct=} [properties] Properties to set */ - function ListDocumentsRequest(properties) { + function Struct(properties) { + this.fields = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + + /** + * Struct fields. + * @member {Object.} fields + * @memberof google.protobuf.Struct + * @instance + */ + Struct.prototype.fields = $util.emptyObject; + + /** + * Creates a Struct message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Struct + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Struct} Struct + */ + Struct.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Struct) + return object; + var message = new $root.google.protobuf.Struct(); + if (object.fields) { + if (typeof object.fields !== "object") + throw TypeError(".google.protobuf.Struct.fields: object expected"); + message.fields = {}; + for (var keys = Object.keys(object.fields), i = 0; i < keys.length; ++i) { + if (typeof object.fields[keys[i]] !== "object") + throw TypeError(".google.protobuf.Struct.fields: object expected"); + message.fields[keys[i]] = $root.google.protobuf.Value.fromObject(object.fields[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from a Struct message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Struct + * @static + * @param {google.protobuf.Struct} message Struct + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Struct.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.fields = {}; + var keys2; + if (message.fields && (keys2 = Object.keys(message.fields)).length) { + object.fields = {}; + for (var j = 0; j < keys2.length; ++j) + object.fields[keys2[j]] = $root.google.protobuf.Value.toObject(message.fields[keys2[j]], options); + } + return object; + }; + /** - * ListDocumentsRequest parent. - * @member {string} parent - * @memberof google.firestore.v1beta1.ListDocumentsRequest + * Converts this Struct to JSON. + * @function toJSON + * @memberof google.protobuf.Struct * @instance + * @returns {Object.} JSON object */ - ListDocumentsRequest.prototype.parent = ""; - + Struct.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Struct; + })(); + + protobuf.Value = (function() { + /** - * ListDocumentsRequest collectionId. - * @member {string} collectionId - * @memberof google.firestore.v1beta1.ListDocumentsRequest - * @instance + * Properties of a Value. + * @memberof google.protobuf + * @interface IValue + * @property {google.protobuf.NullValue|null} [nullValue] Value nullValue + * @property {number|null} [numberValue] Value numberValue + * @property {string|null} [stringValue] Value stringValue + * @property {boolean|null} [boolValue] Value boolValue + * @property {google.protobuf.IStruct|null} [structValue] Value structValue + * @property {google.protobuf.IListValue|null} [listValue] Value listValue */ - ListDocumentsRequest.prototype.collectionId = ""; - + /** - * ListDocumentsRequest pageSize. - * @member {number} pageSize - * @memberof google.firestore.v1beta1.ListDocumentsRequest - * @instance + * Constructs a new Value. + * @memberof google.protobuf + * @classdesc Represents a Value. + * @implements IValue + * @constructor + * @param {google.protobuf.IValue=} [properties] Properties to set */ - ListDocumentsRequest.prototype.pageSize = 0; - + function Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + /** - * ListDocumentsRequest pageToken. - * @member {string} pageToken - * @memberof google.firestore.v1beta1.ListDocumentsRequest + * Value nullValue. + * @member {google.protobuf.NullValue} nullValue + * @memberof google.protobuf.Value * @instance */ - ListDocumentsRequest.prototype.pageToken = ""; - + Value.prototype.nullValue = 0; + /** - * ListDocumentsRequest orderBy. - * @member {string} orderBy - * @memberof google.firestore.v1beta1.ListDocumentsRequest + * Value numberValue. + * @member {number} numberValue + * @memberof google.protobuf.Value * @instance */ - ListDocumentsRequest.prototype.orderBy = ""; - + Value.prototype.numberValue = 0; + /** - * ListDocumentsRequest mask. - * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} mask - * @memberof google.firestore.v1beta1.ListDocumentsRequest + * Value stringValue. + * @member {string} stringValue + * @memberof google.protobuf.Value * @instance */ - ListDocumentsRequest.prototype.mask = null; - + Value.prototype.stringValue = ""; + /** - * ListDocumentsRequest transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1beta1.ListDocumentsRequest + * Value boolValue. + * @member {boolean} boolValue + * @memberof google.protobuf.Value * @instance */ - ListDocumentsRequest.prototype.transaction = $util.newBuffer([]); - + Value.prototype.boolValue = false; + /** - * ListDocumentsRequest readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1beta1.ListDocumentsRequest + * Value structValue. + * @member {google.protobuf.IStruct|null|undefined} structValue + * @memberof google.protobuf.Value * @instance */ - ListDocumentsRequest.prototype.readTime = null; - + Value.prototype.structValue = null; + /** - * ListDocumentsRequest showMissing. - * @member {boolean} showMissing - * @memberof google.firestore.v1beta1.ListDocumentsRequest + * Value listValue. + * @member {google.protobuf.IListValue|null|undefined} listValue + * @memberof google.protobuf.Value * @instance */ - ListDocumentsRequest.prototype.showMissing = false; - + Value.prototype.listValue = null; + // OneOf field names bound to virtual getters and setters var $oneOfFields; - + /** - * ListDocumentsRequest consistencySelector. - * @member {"transaction"|"readTime"|undefined} consistencySelector - * @memberof google.firestore.v1beta1.ListDocumentsRequest + * Value kind. + * @member {"nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"|undefined} kind + * @memberof google.protobuf.Value * @instance */ - Object.defineProperty(ListDocumentsRequest.prototype, "consistencySelector", { - get: $util.oneOfGetter($oneOfFields = ["transaction", "readTime"]), + Object.defineProperty(Value.prototype, "kind", { + get: $util.oneOfGetter($oneOfFields = ["nullValue", "numberValue", "stringValue", "boolValue", "structValue", "listValue"]), set: $util.oneOfSetter($oneOfFields) }); - - return ListDocumentsRequest; + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Value} Value + */ + Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Value) + return object; + var message = new $root.google.protobuf.Value(); + switch (object.nullValue) { + case "NULL_VALUE": + case 0: + message.nullValue = 0; + break; + } + if (object.numberValue != null) + message.numberValue = Number(object.numberValue); + if (object.stringValue != null) + message.stringValue = String(object.stringValue); + if (object.boolValue != null) + message.boolValue = Boolean(object.boolValue); + if (object.structValue != null) { + if (typeof object.structValue !== "object") + throw TypeError(".google.protobuf.Value.structValue: object expected"); + message.structValue = $root.google.protobuf.Struct.fromObject(object.structValue); + } + if (object.listValue != null) { + if (typeof object.listValue !== "object") + throw TypeError(".google.protobuf.Value.listValue: object expected"); + message.listValue = $root.google.protobuf.ListValue.fromObject(object.listValue); + } + return message; + }; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Value + * @static + * @param {google.protobuf.Value} message Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.nullValue != null && message.hasOwnProperty("nullValue")) { + object.nullValue = options.enums === String ? $root.google.protobuf.NullValue[message.nullValue] : message.nullValue; + if (options.oneofs) + object.kind = "nullValue"; + } + if (message.numberValue != null && message.hasOwnProperty("numberValue")) { + object.numberValue = options.json && !isFinite(message.numberValue) ? String(message.numberValue) : message.numberValue; + if (options.oneofs) + object.kind = "numberValue"; + } + if (message.stringValue != null && message.hasOwnProperty("stringValue")) { + object.stringValue = message.stringValue; + if (options.oneofs) + object.kind = "stringValue"; + } + if (message.boolValue != null && message.hasOwnProperty("boolValue")) { + object.boolValue = message.boolValue; + if (options.oneofs) + object.kind = "boolValue"; + } + if (message.structValue != null && message.hasOwnProperty("structValue")) { + object.structValue = $root.google.protobuf.Struct.toObject(message.structValue, options); + if (options.oneofs) + object.kind = "structValue"; + } + if (message.listValue != null && message.hasOwnProperty("listValue")) { + object.listValue = $root.google.protobuf.ListValue.toObject(message.listValue, options); + if (options.oneofs) + object.kind = "listValue"; + } + return object; + }; + + /** + * Converts this Value to JSON. + * @function toJSON + * @memberof google.protobuf.Value + * @instance + * @returns {Object.} JSON object + */ + Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Value; })(); - - v1beta1.ListDocumentsResponse = (function() { - + + /** + * NullValue enum. + * @name google.protobuf.NullValue + * @enum {string} + * @property {string} NULL_VALUE=NULL_VALUE NULL_VALUE value + */ + protobuf.NullValue = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "NULL_VALUE"] = "NULL_VALUE"; + return values; + })(); + + protobuf.ListValue = (function() { + /** - * Properties of a ListDocumentsResponse. - * @memberof google.firestore.v1beta1 - * @interface IListDocumentsResponse - * @property {Array.|null} [documents] ListDocumentsResponse documents - * @property {string|null} [nextPageToken] ListDocumentsResponse nextPageToken + * Properties of a ListValue. + * @memberof google.protobuf + * @interface IListValue + * @property {Array.|null} [values] ListValue values */ - + /** - * Constructs a new ListDocumentsResponse. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a ListDocumentsResponse. - * @implements IListDocumentsResponse + * Constructs a new ListValue. + * @memberof google.protobuf + * @classdesc Represents a ListValue. + * @implements IListValue * @constructor - * @param {google.firestore.v1beta1.IListDocumentsResponse=} [properties] Properties to set + * @param {google.protobuf.IListValue=} [properties] Properties to set */ - function ListDocumentsResponse(properties) { - this.documents = []; + function ListValue(properties) { + this.values = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - - /** - * ListDocumentsResponse documents. - * @member {Array.} documents - * @memberof google.firestore.v1beta1.ListDocumentsResponse - * @instance - */ - ListDocumentsResponse.prototype.documents = $util.emptyArray; - + + /** + * ListValue values. + * @member {Array.} values + * @memberof google.protobuf.ListValue + * @instance + */ + ListValue.prototype.values = $util.emptyArray; + + /** + * Creates a ListValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ListValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ListValue} ListValue + */ + ListValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ListValue) + return object; + var message = new $root.google.protobuf.ListValue(); + if (object.values) { + if (!Array.isArray(object.values)) + throw TypeError(".google.protobuf.ListValue.values: array expected"); + message.values = []; + for (var i = 0; i < object.values.length; ++i) { + if (typeof object.values[i] !== "object") + throw TypeError(".google.protobuf.ListValue.values: object expected"); + message.values[i] = $root.google.protobuf.Value.fromObject(object.values[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a ListValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ListValue + * @static + * @param {google.protobuf.ListValue} message ListValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.values = []; + if (message.values && message.values.length) { + object.values = []; + for (var j = 0; j < message.values.length; ++j) + object.values[j] = $root.google.protobuf.Value.toObject(message.values[j], options); + } + return object; + }; + /** - * ListDocumentsResponse nextPageToken. - * @member {string} nextPageToken - * @memberof google.firestore.v1beta1.ListDocumentsResponse + * Converts this ListValue to JSON. + * @function toJSON + * @memberof google.protobuf.ListValue * @instance + * @returns {Object.} JSON object */ - ListDocumentsResponse.prototype.nextPageToken = ""; - - return ListDocumentsResponse; + ListValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListValue; })(); - - v1beta1.CreateDocumentRequest = (function() { - + + protobuf.Empty = (function() { + /** - * Properties of a CreateDocumentRequest. - * @memberof google.firestore.v1beta1 - * @interface ICreateDocumentRequest - * @property {string|null} [parent] CreateDocumentRequest parent - * @property {string|null} [collectionId] CreateDocumentRequest collectionId - * @property {string|null} [documentId] CreateDocumentRequest documentId - * @property {google.firestore.v1beta1.IDocument|null} [document] CreateDocumentRequest document - * @property {google.firestore.v1beta1.IDocumentMask|null} [mask] CreateDocumentRequest mask + * Properties of an Empty. + * @memberof google.protobuf + * @interface IEmpty */ - + /** - * Constructs a new CreateDocumentRequest. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a CreateDocumentRequest. - * @implements ICreateDocumentRequest + * Constructs a new Empty. + * @memberof google.protobuf + * @classdesc Represents an Empty. + * @implements IEmpty * @constructor - * @param {google.firestore.v1beta1.ICreateDocumentRequest=} [properties] Properties to set + * @param {google.protobuf.IEmpty=} [properties] Properties to set */ - function CreateDocumentRequest(properties) { + function Empty(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - - /** - * CreateDocumentRequest parent. - * @member {string} parent - * @memberof google.firestore.v1beta1.CreateDocumentRequest - * @instance - */ - CreateDocumentRequest.prototype.parent = ""; - + + /** + * Creates an Empty message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Empty + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Empty} Empty + */ + Empty.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Empty) + return object; + return new $root.google.protobuf.Empty(); + }; + + /** + * Creates a plain object from an Empty message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.Empty} message Empty + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Empty.toObject = function toObject() { + return {}; + }; + + /** + * Converts this Empty to JSON. + * @function toJSON + * @memberof google.protobuf.Empty + * @instance + * @returns {Object.} JSON object + */ + Empty.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Empty; + })(); + + protobuf.DoubleValue = (function() { + /** - * CreateDocumentRequest collectionId. - * @member {string} collectionId - * @memberof google.firestore.v1beta1.CreateDocumentRequest - * @instance + * Properties of a DoubleValue. + * @memberof google.protobuf + * @interface IDoubleValue + * @property {number|null} [value] DoubleValue value */ - CreateDocumentRequest.prototype.collectionId = ""; - + /** - * CreateDocumentRequest documentId. - * @member {string} documentId - * @memberof google.firestore.v1beta1.CreateDocumentRequest - * @instance + * Constructs a new DoubleValue. + * @memberof google.protobuf + * @classdesc Represents a DoubleValue. + * @implements IDoubleValue + * @constructor + * @param {google.protobuf.IDoubleValue=} [properties] Properties to set */ - CreateDocumentRequest.prototype.documentId = ""; - + function DoubleValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DoubleValue value. + * @member {number} value + * @memberof google.protobuf.DoubleValue + * @instance + */ + DoubleValue.prototype.value = 0; + + /** + * Creates a DoubleValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DoubleValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DoubleValue} DoubleValue + */ + DoubleValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DoubleValue) + return object; + var message = new $root.google.protobuf.DoubleValue(); + if (object.value != null) + message.value = Number(object.value); + return message; + }; + + /** + * Creates a plain object from a DoubleValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DoubleValue + * @static + * @param {google.protobuf.DoubleValue} message DoubleValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DoubleValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = 0; + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.json && !isFinite(message.value) ? String(message.value) : message.value; + return object; + }; + + /** + * Converts this DoubleValue to JSON. + * @function toJSON + * @memberof google.protobuf.DoubleValue + * @instance + * @returns {Object.} JSON object + */ + DoubleValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DoubleValue; + })(); + + protobuf.FloatValue = (function() { + /** - * CreateDocumentRequest document. - * @member {google.firestore.v1beta1.IDocument|null|undefined} document - * @memberof google.firestore.v1beta1.CreateDocumentRequest - * @instance + * Properties of a FloatValue. + * @memberof google.protobuf + * @interface IFloatValue + * @property {number|null} [value] FloatValue value */ - CreateDocumentRequest.prototype.document = null; - + /** - * CreateDocumentRequest mask. - * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} mask - * @memberof google.firestore.v1beta1.CreateDocumentRequest - * @instance + * Constructs a new FloatValue. + * @memberof google.protobuf + * @classdesc Represents a FloatValue. + * @implements IFloatValue + * @constructor + * @param {google.protobuf.IFloatValue=} [properties] Properties to set */ - CreateDocumentRequest.prototype.mask = null; - - return CreateDocumentRequest; + function FloatValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FloatValue value. + * @member {number} value + * @memberof google.protobuf.FloatValue + * @instance + */ + FloatValue.prototype.value = 0; + + /** + * Creates a FloatValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FloatValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FloatValue} FloatValue + */ + FloatValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FloatValue) + return object; + var message = new $root.google.protobuf.FloatValue(); + if (object.value != null) + message.value = Number(object.value); + return message; + }; + + /** + * Creates a plain object from a FloatValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FloatValue + * @static + * @param {google.protobuf.FloatValue} message FloatValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FloatValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = 0; + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.json && !isFinite(message.value) ? String(message.value) : message.value; + return object; + }; + + /** + * Converts this FloatValue to JSON. + * @function toJSON + * @memberof google.protobuf.FloatValue + * @instance + * @returns {Object.} JSON object + */ + FloatValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FloatValue; })(); - - v1beta1.UpdateDocumentRequest = (function() { - + + protobuf.Int64Value = (function() { + /** - * Properties of an UpdateDocumentRequest. - * @memberof google.firestore.v1beta1 - * @interface IUpdateDocumentRequest - * @property {google.firestore.v1beta1.IDocument|null} [document] UpdateDocumentRequest document - * @property {google.firestore.v1beta1.IDocumentMask|null} [updateMask] UpdateDocumentRequest updateMask - * @property {google.firestore.v1beta1.IDocumentMask|null} [mask] UpdateDocumentRequest mask - * @property {google.firestore.v1beta1.IPrecondition|null} [currentDocument] UpdateDocumentRequest currentDocument + * Properties of an Int64Value. + * @memberof google.protobuf + * @interface IInt64Value + * @property {number|string|null} [value] Int64Value value */ - + /** - * Constructs a new UpdateDocumentRequest. - * @memberof google.firestore.v1beta1 - * @classdesc Represents an UpdateDocumentRequest. - * @implements IUpdateDocumentRequest + * Constructs a new Int64Value. + * @memberof google.protobuf + * @classdesc Represents an Int64Value. + * @implements IInt64Value * @constructor - * @param {google.firestore.v1beta1.IUpdateDocumentRequest=} [properties] Properties to set + * @param {google.protobuf.IInt64Value=} [properties] Properties to set */ - function UpdateDocumentRequest(properties) { + function Int64Value(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + + /** + * Int64Value value. + * @member {number|string} value + * @memberof google.protobuf.Int64Value + * @instance + */ + Int64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates an Int64Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Int64Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Int64Value} Int64Value + */ + Int64Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Int64Value) + return object; + var message = new $root.google.protobuf.Int64Value(); + if (object.value != null) + if ($util.Long) + (message.value = $util.Long.fromValue(object.value)).unsigned = false; + else if (typeof object.value === "string") + message.value = parseInt(object.value, 10); + else if (typeof object.value === "number") + message.value = object.value; + else if (typeof object.value === "object") + message.value = new $util.LongBits(object.value.low >>> 0, object.value.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from an Int64Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Int64Value + * @static + * @param {google.protobuf.Int64Value} message Int64Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Int64Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.value = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.value = options.longs === String ? "0" : 0; + if (message.value != null && message.hasOwnProperty("value")) + if (typeof message.value === "number") + object.value = options.longs === String ? String(message.value) : message.value; + else + object.value = options.longs === String ? $util.Long.prototype.toString.call(message.value) : options.longs === Number ? new $util.LongBits(message.value.low >>> 0, message.value.high >>> 0).toNumber() : message.value; + return object; + }; + + /** + * Converts this Int64Value to JSON. + * @function toJSON + * @memberof google.protobuf.Int64Value + * @instance + * @returns {Object.} JSON object + */ + Int64Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Int64Value; + })(); + + protobuf.UInt64Value = (function() { + /** - * UpdateDocumentRequest document. - * @member {google.firestore.v1beta1.IDocument|null|undefined} document - * @memberof google.firestore.v1beta1.UpdateDocumentRequest - * @instance + * Properties of a UInt64Value. + * @memberof google.protobuf + * @interface IUInt64Value + * @property {number|string|null} [value] UInt64Value value */ - UpdateDocumentRequest.prototype.document = null; - + /** - * UpdateDocumentRequest updateMask. - * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} updateMask - * @memberof google.firestore.v1beta1.UpdateDocumentRequest - * @instance + * Constructs a new UInt64Value. + * @memberof google.protobuf + * @classdesc Represents a UInt64Value. + * @implements IUInt64Value + * @constructor + * @param {google.protobuf.IUInt64Value=} [properties] Properties to set */ - UpdateDocumentRequest.prototype.updateMask = null; - + function UInt64Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UInt64Value value. + * @member {number|string} value + * @memberof google.protobuf.UInt64Value + * @instance + */ + UInt64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Creates a UInt64Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UInt64Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UInt64Value} UInt64Value + */ + UInt64Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UInt64Value) + return object; + var message = new $root.google.protobuf.UInt64Value(); + if (object.value != null) + if ($util.Long) + (message.value = $util.Long.fromValue(object.value)).unsigned = true; + else if (typeof object.value === "string") + message.value = parseInt(object.value, 10); + else if (typeof object.value === "number") + message.value = object.value; + else if (typeof object.value === "object") + message.value = new $util.LongBits(object.value.low >>> 0, object.value.high >>> 0).toNumber(true); + return message; + }; + + /** + * Creates a plain object from a UInt64Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UInt64Value + * @static + * @param {google.protobuf.UInt64Value} message UInt64Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UInt64Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.value = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.value = options.longs === String ? "0" : 0; + if (message.value != null && message.hasOwnProperty("value")) + if (typeof message.value === "number") + object.value = options.longs === String ? String(message.value) : message.value; + else + object.value = options.longs === String ? $util.Long.prototype.toString.call(message.value) : options.longs === Number ? new $util.LongBits(message.value.low >>> 0, message.value.high >>> 0).toNumber(true) : message.value; + return object; + }; + + /** + * Converts this UInt64Value to JSON. + * @function toJSON + * @memberof google.protobuf.UInt64Value + * @instance + * @returns {Object.} JSON object + */ + UInt64Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return UInt64Value; + })(); + + protobuf.Int32Value = (function() { + /** - * UpdateDocumentRequest mask. - * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} mask - * @memberof google.firestore.v1beta1.UpdateDocumentRequest - * @instance + * Properties of an Int32Value. + * @memberof google.protobuf + * @interface IInt32Value + * @property {number|null} [value] Int32Value value */ - UpdateDocumentRequest.prototype.mask = null; - + /** - * UpdateDocumentRequest currentDocument. - * @member {google.firestore.v1beta1.IPrecondition|null|undefined} currentDocument - * @memberof google.firestore.v1beta1.UpdateDocumentRequest - * @instance + * Constructs a new Int32Value. + * @memberof google.protobuf + * @classdesc Represents an Int32Value. + * @implements IInt32Value + * @constructor + * @param {google.protobuf.IInt32Value=} [properties] Properties to set */ - UpdateDocumentRequest.prototype.currentDocument = null; - - return UpdateDocumentRequest; + function Int32Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Int32Value value. + * @member {number} value + * @memberof google.protobuf.Int32Value + * @instance + */ + Int32Value.prototype.value = 0; + + /** + * Creates an Int32Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Int32Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Int32Value} Int32Value + */ + Int32Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Int32Value) + return object; + var message = new $root.google.protobuf.Int32Value(); + if (object.value != null) + message.value = object.value | 0; + return message; + }; + + /** + * Creates a plain object from an Int32Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Int32Value + * @static + * @param {google.protobuf.Int32Value} message Int32Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Int32Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = 0; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this Int32Value to JSON. + * @function toJSON + * @memberof google.protobuf.Int32Value + * @instance + * @returns {Object.} JSON object + */ + Int32Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Int32Value; })(); - - v1beta1.DeleteDocumentRequest = (function() { - + + protobuf.UInt32Value = (function() { + /** - * Properties of a DeleteDocumentRequest. - * @memberof google.firestore.v1beta1 - * @interface IDeleteDocumentRequest - * @property {string|null} [name] DeleteDocumentRequest name - * @property {google.firestore.v1beta1.IPrecondition|null} [currentDocument] DeleteDocumentRequest currentDocument + * Properties of a UInt32Value. + * @memberof google.protobuf + * @interface IUInt32Value + * @property {number|null} [value] UInt32Value value */ - + /** - * Constructs a new DeleteDocumentRequest. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a DeleteDocumentRequest. - * @implements IDeleteDocumentRequest + * Constructs a new UInt32Value. + * @memberof google.protobuf + * @classdesc Represents a UInt32Value. + * @implements IUInt32Value * @constructor - * @param {google.firestore.v1beta1.IDeleteDocumentRequest=} [properties] Properties to set + * @param {google.protobuf.IUInt32Value=} [properties] Properties to set */ - function DeleteDocumentRequest(properties) { + function UInt32Value(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + + /** + * UInt32Value value. + * @member {number} value + * @memberof google.protobuf.UInt32Value + * @instance + */ + UInt32Value.prototype.value = 0; + + /** + * Creates a UInt32Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UInt32Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UInt32Value} UInt32Value + */ + UInt32Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UInt32Value) + return object; + var message = new $root.google.protobuf.UInt32Value(); + if (object.value != null) + message.value = object.value >>> 0; + return message; + }; + + /** + * Creates a plain object from a UInt32Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UInt32Value + * @static + * @param {google.protobuf.UInt32Value} message UInt32Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UInt32Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = 0; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this UInt32Value to JSON. + * @function toJSON + * @memberof google.protobuf.UInt32Value + * @instance + * @returns {Object.} JSON object + */ + UInt32Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return UInt32Value; + })(); + + protobuf.BoolValue = (function() { + /** - * DeleteDocumentRequest name. - * @member {string} name - * @memberof google.firestore.v1beta1.DeleteDocumentRequest - * @instance + * Properties of a BoolValue. + * @memberof google.protobuf + * @interface IBoolValue + * @property {boolean|null} [value] BoolValue value */ - DeleteDocumentRequest.prototype.name = ""; - + /** - * DeleteDocumentRequest currentDocument. - * @member {google.firestore.v1beta1.IPrecondition|null|undefined} currentDocument - * @memberof google.firestore.v1beta1.DeleteDocumentRequest - * @instance + * Constructs a new BoolValue. + * @memberof google.protobuf + * @classdesc Represents a BoolValue. + * @implements IBoolValue + * @constructor + * @param {google.protobuf.IBoolValue=} [properties] Properties to set */ - DeleteDocumentRequest.prototype.currentDocument = null; - - return DeleteDocumentRequest; + function BoolValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BoolValue value. + * @member {boolean} value + * @memberof google.protobuf.BoolValue + * @instance + */ + BoolValue.prototype.value = false; + + /** + * Creates a BoolValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.BoolValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.BoolValue} BoolValue + */ + BoolValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.BoolValue) + return object; + var message = new $root.google.protobuf.BoolValue(); + if (object.value != null) + message.value = Boolean(object.value); + return message; + }; + + /** + * Creates a plain object from a BoolValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.BoolValue + * @static + * @param {google.protobuf.BoolValue} message BoolValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BoolValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = false; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this BoolValue to JSON. + * @function toJSON + * @memberof google.protobuf.BoolValue + * @instance + * @returns {Object.} JSON object + */ + BoolValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BoolValue; })(); - - v1beta1.BatchGetDocumentsRequest = (function() { - + + protobuf.StringValue = (function() { + /** - * Properties of a BatchGetDocumentsRequest. - * @memberof google.firestore.v1beta1 - * @interface IBatchGetDocumentsRequest - * @property {string|null} [database] BatchGetDocumentsRequest database - * @property {Array.|null} [documents] BatchGetDocumentsRequest documents - * @property {google.firestore.v1beta1.IDocumentMask|null} [mask] BatchGetDocumentsRequest mask - * @property {Uint8Array|null} [transaction] BatchGetDocumentsRequest transaction - * @property {google.firestore.v1beta1.ITransactionOptions|null} [newTransaction] BatchGetDocumentsRequest newTransaction - * @property {google.protobuf.ITimestamp|null} [readTime] BatchGetDocumentsRequest readTime + * Properties of a StringValue. + * @memberof google.protobuf + * @interface IStringValue + * @property {string|null} [value] StringValue value */ - + /** - * Constructs a new BatchGetDocumentsRequest. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a BatchGetDocumentsRequest. - * @implements IBatchGetDocumentsRequest + * Constructs a new StringValue. + * @memberof google.protobuf + * @classdesc Represents a StringValue. + * @implements IStringValue * @constructor - * @param {google.firestore.v1beta1.IBatchGetDocumentsRequest=} [properties] Properties to set + * @param {google.protobuf.IStringValue=} [properties] Properties to set */ - function BatchGetDocumentsRequest(properties) { - this.documents = []; + function StringValue(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + + /** + * StringValue value. + * @member {string} value + * @memberof google.protobuf.StringValue + * @instance + */ + StringValue.prototype.value = ""; + + /** + * Creates a StringValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.StringValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.StringValue} StringValue + */ + StringValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.StringValue) + return object; + var message = new $root.google.protobuf.StringValue(); + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from a StringValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.StringValue + * @static + * @param {google.protobuf.StringValue} message StringValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StringValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = ""; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this StringValue to JSON. + * @function toJSON + * @memberof google.protobuf.StringValue + * @instance + * @returns {Object.} JSON object + */ + StringValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return StringValue; + })(); + + protobuf.BytesValue = (function() { + /** - * BatchGetDocumentsRequest database. - * @member {string} database - * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest - * @instance + * Properties of a BytesValue. + * @memberof google.protobuf + * @interface IBytesValue + * @property {Uint8Array|null} [value] BytesValue value */ - BatchGetDocumentsRequest.prototype.database = ""; - + /** - * BatchGetDocumentsRequest documents. - * @member {Array.} documents - * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest - * @instance + * Constructs a new BytesValue. + * @memberof google.protobuf + * @classdesc Represents a BytesValue. + * @implements IBytesValue + * @constructor + * @param {google.protobuf.IBytesValue=} [properties] Properties to set */ - BatchGetDocumentsRequest.prototype.documents = $util.emptyArray; - - /** - * BatchGetDocumentsRequest mask. - * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} mask - * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest - * @instance - */ - BatchGetDocumentsRequest.prototype.mask = null; - - /** - * BatchGetDocumentsRequest transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest - * @instance - */ - BatchGetDocumentsRequest.prototype.transaction = $util.newBuffer([]); - - /** - * BatchGetDocumentsRequest newTransaction. - * @member {google.firestore.v1beta1.ITransactionOptions|null|undefined} newTransaction - * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest - * @instance - */ - BatchGetDocumentsRequest.prototype.newTransaction = null; - - /** - * BatchGetDocumentsRequest readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest - * @instance - */ - BatchGetDocumentsRequest.prototype.readTime = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * BatchGetDocumentsRequest consistencySelector. - * @member {"transaction"|"newTransaction"|"readTime"|undefined} consistencySelector - * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest - * @instance - */ - Object.defineProperty(BatchGetDocumentsRequest.prototype, "consistencySelector", { - get: $util.oneOfGetter($oneOfFields = ["transaction", "newTransaction", "readTime"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return BatchGetDocumentsRequest; - })(); - - v1beta1.BatchGetDocumentsResponse = (function() { - - /** - * Properties of a BatchGetDocumentsResponse. - * @memberof google.firestore.v1beta1 - * @interface IBatchGetDocumentsResponse - * @property {google.firestore.v1beta1.IDocument|null} [found] BatchGetDocumentsResponse found - * @property {string|null} [missing] BatchGetDocumentsResponse missing - * @property {Uint8Array|null} [transaction] BatchGetDocumentsResponse transaction - * @property {google.protobuf.ITimestamp|null} [readTime] BatchGetDocumentsResponse readTime - */ - - /** - * Constructs a new BatchGetDocumentsResponse. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a BatchGetDocumentsResponse. - * @implements IBatchGetDocumentsResponse - * @constructor - * @param {google.firestore.v1beta1.IBatchGetDocumentsResponse=} [properties] Properties to set - */ - function BatchGetDocumentsResponse(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BatchGetDocumentsResponse found. - * @member {google.firestore.v1beta1.IDocument|null|undefined} found - * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse - * @instance - */ - BatchGetDocumentsResponse.prototype.found = null; - - /** - * BatchGetDocumentsResponse missing. - * @member {string} missing - * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse - * @instance - */ - BatchGetDocumentsResponse.prototype.missing = ""; - - /** - * BatchGetDocumentsResponse transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse - * @instance - */ - BatchGetDocumentsResponse.prototype.transaction = $util.newBuffer([]); - - /** - * BatchGetDocumentsResponse readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse - * @instance - */ - BatchGetDocumentsResponse.prototype.readTime = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * BatchGetDocumentsResponse result. - * @member {"found"|"missing"|undefined} result - * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse - * @instance - */ - Object.defineProperty(BatchGetDocumentsResponse.prototype, "result", { - get: $util.oneOfGetter($oneOfFields = ["found", "missing"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return BatchGetDocumentsResponse; - })(); - - v1beta1.BeginTransactionRequest = (function() { - - /** - * Properties of a BeginTransactionRequest. - * @memberof google.firestore.v1beta1 - * @interface IBeginTransactionRequest - * @property {string|null} [database] BeginTransactionRequest database - * @property {google.firestore.v1beta1.ITransactionOptions|null} [options] BeginTransactionRequest options - */ - - /** - * Constructs a new BeginTransactionRequest. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a BeginTransactionRequest. - * @implements IBeginTransactionRequest - * @constructor - * @param {google.firestore.v1beta1.IBeginTransactionRequest=} [properties] Properties to set - */ - function BeginTransactionRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BeginTransactionRequest database. - * @member {string} database - * @memberof google.firestore.v1beta1.BeginTransactionRequest - * @instance - */ - BeginTransactionRequest.prototype.database = ""; - - /** - * BeginTransactionRequest options. - * @member {google.firestore.v1beta1.ITransactionOptions|null|undefined} options - * @memberof google.firestore.v1beta1.BeginTransactionRequest - * @instance - */ - BeginTransactionRequest.prototype.options = null; - - return BeginTransactionRequest; - })(); - - v1beta1.BeginTransactionResponse = (function() { - - /** - * Properties of a BeginTransactionResponse. - * @memberof google.firestore.v1beta1 - * @interface IBeginTransactionResponse - * @property {Uint8Array|null} [transaction] BeginTransactionResponse transaction - */ - - /** - * Constructs a new BeginTransactionResponse. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a BeginTransactionResponse. - * @implements IBeginTransactionResponse - * @constructor - * @param {google.firestore.v1beta1.IBeginTransactionResponse=} [properties] Properties to set - */ - function BeginTransactionResponse(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BeginTransactionResponse transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1beta1.BeginTransactionResponse - * @instance - */ - BeginTransactionResponse.prototype.transaction = $util.newBuffer([]); - - return BeginTransactionResponse; - })(); - - v1beta1.CommitRequest = (function() { - - /** - * Properties of a CommitRequest. - * @memberof google.firestore.v1beta1 - * @interface ICommitRequest - * @property {string|null} [database] CommitRequest database - * @property {Array.|null} [writes] CommitRequest writes - * @property {Uint8Array|null} [transaction] CommitRequest transaction - */ - - /** - * Constructs a new CommitRequest. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a CommitRequest. - * @implements ICommitRequest - * @constructor - * @param {google.firestore.v1beta1.ICommitRequest=} [properties] Properties to set - */ - function CommitRequest(properties) { - this.writes = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * CommitRequest database. - * @member {string} database - * @memberof google.firestore.v1beta1.CommitRequest - * @instance - */ - CommitRequest.prototype.database = ""; - - /** - * CommitRequest writes. - * @member {Array.} writes - * @memberof google.firestore.v1beta1.CommitRequest - * @instance - */ - CommitRequest.prototype.writes = $util.emptyArray; - - /** - * CommitRequest transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1beta1.CommitRequest - * @instance - */ - CommitRequest.prototype.transaction = $util.newBuffer([]); - - return CommitRequest; - })(); - - v1beta1.CommitResponse = (function() { - - /** - * Properties of a CommitResponse. - * @memberof google.firestore.v1beta1 - * @interface ICommitResponse - * @property {Array.|null} [writeResults] CommitResponse writeResults - * @property {google.protobuf.ITimestamp|null} [commitTime] CommitResponse commitTime - */ - - /** - * Constructs a new CommitResponse. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a CommitResponse. - * @implements ICommitResponse - * @constructor - * @param {google.firestore.v1beta1.ICommitResponse=} [properties] Properties to set - */ - function CommitResponse(properties) { - this.writeResults = []; + function BytesValue(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - - /** - * CommitResponse writeResults. - * @member {Array.} writeResults - * @memberof google.firestore.v1beta1.CommitResponse - * @instance - */ - CommitResponse.prototype.writeResults = $util.emptyArray; - - /** - * CommitResponse commitTime. - * @member {google.protobuf.ITimestamp|null|undefined} commitTime - * @memberof google.firestore.v1beta1.CommitResponse - * @instance - */ - CommitResponse.prototype.commitTime = null; - - return CommitResponse; + + /** + * BytesValue value. + * @member {Uint8Array} value + * @memberof google.protobuf.BytesValue + * @instance + */ + BytesValue.prototype.value = $util.newBuffer([]); + + /** + * Creates a BytesValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.BytesValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.BytesValue} BytesValue + */ + BytesValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.BytesValue) + return object; + var message = new $root.google.protobuf.BytesValue(); + if (object.value != null) + if (typeof object.value === "string") + $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); + else if (object.value.length) + message.value = object.value; + return message; + }; + + /** + * Creates a plain object from a BytesValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.BytesValue + * @static + * @param {google.protobuf.BytesValue} message BytesValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BytesValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.value = ""; + else { + object.value = []; + if (options.bytes !== Array) + object.value = $util.newBuffer(object.value); + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; + return object; + }; + + /** + * Converts this BytesValue to JSON. + * @function toJSON + * @memberof google.protobuf.BytesValue + * @instance + * @returns {Object.} JSON object + */ + BytesValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BytesValue; })(); - - v1beta1.RollbackRequest = (function() { - - /** - * Properties of a RollbackRequest. - * @memberof google.firestore.v1beta1 - * @interface IRollbackRequest - * @property {string|null} [database] RollbackRequest database - * @property {Uint8Array|null} [transaction] RollbackRequest transaction - */ - - /** - * Constructs a new RollbackRequest. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a RollbackRequest. - * @implements IRollbackRequest + + protobuf.Any = (function() { + + /** + * Properties of an Any. + * @memberof google.protobuf + * @interface IAny + * @property {string|null} [type_url] Any type_url + * @property {Uint8Array|null} [value] Any value + */ + + /** + * Constructs a new Any. + * @memberof google.protobuf + * @classdesc Represents an Any. + * @implements IAny * @constructor - * @param {google.firestore.v1beta1.IRollbackRequest=} [properties] Properties to set + * @param {google.protobuf.IAny=} [properties] Properties to set */ - function RollbackRequest(properties) { + function Any(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - - /** - * RollbackRequest database. - * @member {string} database - * @memberof google.firestore.v1beta1.RollbackRequest - * @instance - */ - RollbackRequest.prototype.database = ""; - - /** - * RollbackRequest transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1beta1.RollbackRequest - * @instance - */ - RollbackRequest.prototype.transaction = $util.newBuffer([]); - - return RollbackRequest; + + /** + * Any type_url. + * @member {string} type_url + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.type_url = ""; + + /** + * Any value. + * @member {Uint8Array} value + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.value = $util.newBuffer([]); + + /** + * Creates an Any message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Any + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Any} Any + */ + Any.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Any) + return object; + var message = new $root.google.protobuf.Any(); + if (object.type_url != null) + message.type_url = String(object.type_url); + if (object.value != null) + if (typeof object.value === "string") + $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); + else if (object.value.length) + message.value = object.value; + return message; + }; + + /** + * Creates a plain object from an Any message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.Any} message Any + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Any.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.type_url = ""; + if (options.bytes === String) + object.value = ""; + else { + object.value = []; + if (options.bytes !== Array) + object.value = $util.newBuffer(object.value); + } + } + if (message.type_url != null && message.hasOwnProperty("type_url")) + object.type_url = message.type_url; + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; + return object; + }; + + /** + * Converts this Any to JSON. + * @function toJSON + * @memberof google.protobuf.Any + * @instance + * @returns {Object.} JSON object + */ + Any.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Any; })(); - - v1beta1.RunQueryRequest = (function() { - + + protobuf.FieldMask = (function() { + /** - * Properties of a RunQueryRequest. - * @memberof google.firestore.v1beta1 - * @interface IRunQueryRequest - * @property {string|null} [parent] RunQueryRequest parent - * @property {google.firestore.v1beta1.IStructuredQuery|null} [structuredQuery] RunQueryRequest structuredQuery - * @property {Uint8Array|null} [transaction] RunQueryRequest transaction - * @property {google.firestore.v1beta1.ITransactionOptions|null} [newTransaction] RunQueryRequest newTransaction - * @property {google.protobuf.ITimestamp|null} [readTime] RunQueryRequest readTime + * Properties of a FieldMask. + * @memberof google.protobuf + * @interface IFieldMask + * @property {Array.|null} [paths] FieldMask paths */ - + /** - * Constructs a new RunQueryRequest. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a RunQueryRequest. - * @implements IRunQueryRequest + * Constructs a new FieldMask. + * @memberof google.protobuf + * @classdesc Represents a FieldMask. + * @implements IFieldMask * @constructor - * @param {google.firestore.v1beta1.IRunQueryRequest=} [properties] Properties to set + * @param {google.protobuf.IFieldMask=} [properties] Properties to set */ - function RunQueryRequest(properties) { + function FieldMask(properties) { + this.paths = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - - /** - * RunQueryRequest parent. - * @member {string} parent - * @memberof google.firestore.v1beta1.RunQueryRequest - * @instance - */ - RunQueryRequest.prototype.parent = ""; - - /** - * RunQueryRequest structuredQuery. - * @member {google.firestore.v1beta1.IStructuredQuery|null|undefined} structuredQuery - * @memberof google.firestore.v1beta1.RunQueryRequest - * @instance - */ - RunQueryRequest.prototype.structuredQuery = null; - - /** - * RunQueryRequest transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1beta1.RunQueryRequest - * @instance - */ - RunQueryRequest.prototype.transaction = $util.newBuffer([]); - - /** - * RunQueryRequest newTransaction. - * @member {google.firestore.v1beta1.ITransactionOptions|null|undefined} newTransaction - * @memberof google.firestore.v1beta1.RunQueryRequest - * @instance - */ - RunQueryRequest.prototype.newTransaction = null; - - /** - * RunQueryRequest readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1beta1.RunQueryRequest - * @instance - */ - RunQueryRequest.prototype.readTime = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * RunQueryRequest queryType. - * @member {"structuredQuery"|undefined} queryType - * @memberof google.firestore.v1beta1.RunQueryRequest - * @instance - */ - Object.defineProperty(RunQueryRequest.prototype, "queryType", { - get: $util.oneOfGetter($oneOfFields = ["structuredQuery"]), - set: $util.oneOfSetter($oneOfFields) - }); - + + /** + * FieldMask paths. + * @member {Array.} paths + * @memberof google.protobuf.FieldMask + * @instance + */ + FieldMask.prototype.paths = $util.emptyArray; + + /** + * Creates a FieldMask message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldMask + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldMask} FieldMask + */ + FieldMask.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldMask) + return object; + var message = new $root.google.protobuf.FieldMask(); + if (object.paths) { + if (!Array.isArray(object.paths)) + throw TypeError(".google.protobuf.FieldMask.paths: array expected"); + message.paths = []; + for (var i = 0; i < object.paths.length; ++i) + message.paths[i] = String(object.paths[i]); + } + return message; + }; + + /** + * Creates a plain object from a FieldMask message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldMask + * @static + * @param {google.protobuf.FieldMask} message FieldMask + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldMask.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.paths = []; + if (message.paths && message.paths.length) { + object.paths = []; + for (var j = 0; j < message.paths.length; ++j) + object.paths[j] = message.paths[j]; + } + return object; + }; + /** - * RunQueryRequest consistencySelector. - * @member {"transaction"|"newTransaction"|"readTime"|undefined} consistencySelector - * @memberof google.firestore.v1beta1.RunQueryRequest + * Converts this FieldMask to JSON. + * @function toJSON + * @memberof google.protobuf.FieldMask * @instance + * @returns {Object.} JSON object */ - Object.defineProperty(RunQueryRequest.prototype, "consistencySelector", { - get: $util.oneOfGetter($oneOfFields = ["transaction", "newTransaction", "readTime"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return RunQueryRequest; + FieldMask.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FieldMask; })(); - - v1beta1.RunQueryResponse = (function() { - - /** - * Properties of a RunQueryResponse. - * @memberof google.firestore.v1beta1 - * @interface IRunQueryResponse - * @property {Uint8Array|null} [transaction] RunQueryResponse transaction - * @property {google.firestore.v1beta1.IDocument|null} [document] RunQueryResponse document - * @property {google.protobuf.ITimestamp|null} [readTime] RunQueryResponse readTime - * @property {number|null} [skippedResults] RunQueryResponse skippedResults - */ - - /** - * Constructs a new RunQueryResponse. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a RunQueryResponse. - * @implements IRunQueryResponse + + protobuf.Duration = (function() { + + /** + * Properties of a Duration. + * @memberof google.protobuf + * @interface IDuration + * @property {number|string|null} [seconds] Duration seconds + * @property {number|null} [nanos] Duration nanos + */ + + /** + * Constructs a new Duration. + * @memberof google.protobuf + * @classdesc Represents a Duration. + * @implements IDuration * @constructor - * @param {google.firestore.v1beta1.IRunQueryResponse=} [properties] Properties to set + * @param {google.protobuf.IDuration=} [properties] Properties to set */ - function RunQueryResponse(properties) { + function Duration(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - - /** - * RunQueryResponse transaction. - * @member {Uint8Array} transaction - * @memberof google.firestore.v1beta1.RunQueryResponse - * @instance - */ - RunQueryResponse.prototype.transaction = $util.newBuffer([]); - - /** - * RunQueryResponse document. - * @member {google.firestore.v1beta1.IDocument|null|undefined} document - * @memberof google.firestore.v1beta1.RunQueryResponse - * @instance - */ - RunQueryResponse.prototype.document = null; - - /** - * RunQueryResponse readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1beta1.RunQueryResponse - * @instance - */ - RunQueryResponse.prototype.readTime = null; - - /** - * RunQueryResponse skippedResults. - * @member {number} skippedResults - * @memberof google.firestore.v1beta1.RunQueryResponse - * @instance - */ - RunQueryResponse.prototype.skippedResults = 0; - - return RunQueryResponse; + + /** + * Duration seconds. + * @member {number|string} seconds + * @memberof google.protobuf.Duration + * @instance + */ + Duration.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Duration nanos. + * @member {number} nanos + * @memberof google.protobuf.Duration + * @instance + */ + Duration.prototype.nanos = 0; + + /** + * Creates a Duration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Duration + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Duration} Duration + */ + Duration.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Duration) + return object; + var message = new $root.google.protobuf.Duration(); + if (object.seconds != null) + if ($util.Long) + (message.seconds = $util.Long.fromValue(object.seconds)).unsigned = false; + else if (typeof object.seconds === "string") + message.seconds = parseInt(object.seconds, 10); + else if (typeof object.seconds === "number") + message.seconds = object.seconds; + else if (typeof object.seconds === "object") + message.seconds = new $util.LongBits(object.seconds.low >>> 0, object.seconds.high >>> 0).toNumber(); + if (object.nanos != null) + message.nanos = object.nanos | 0; + return message; + }; + + /** + * Creates a plain object from a Duration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Duration + * @static + * @param {google.protobuf.Duration} message Duration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Duration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.seconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.seconds = options.longs === String ? "0" : 0; + object.nanos = 0; + } + if (message.seconds != null && message.hasOwnProperty("seconds")) + if (typeof message.seconds === "number") + object.seconds = options.longs === String ? String(message.seconds) : message.seconds; + else + object.seconds = options.longs === String ? $util.Long.prototype.toString.call(message.seconds) : options.longs === Number ? new $util.LongBits(message.seconds.low >>> 0, message.seconds.high >>> 0).toNumber() : message.seconds; + if (message.nanos != null && message.hasOwnProperty("nanos")) + object.nanos = message.nanos; + return object; + }; + + /** + * Converts this Duration to JSON. + * @function toJSON + * @memberof google.protobuf.Duration + * @instance + * @returns {Object.} JSON object + */ + Duration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Duration; })(); - - v1beta1.WriteRequest = (function() { - - /** - * Properties of a WriteRequest. - * @memberof google.firestore.v1beta1 - * @interface IWriteRequest - * @property {string|null} [database] WriteRequest database - * @property {string|null} [streamId] WriteRequest streamId - * @property {Array.|null} [writes] WriteRequest writes - * @property {Uint8Array|null} [streamToken] WriteRequest streamToken - * @property {Object.|null} [labels] WriteRequest labels - */ - - /** - * Constructs a new WriteRequest. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a WriteRequest. - * @implements IWriteRequest - * @constructor - * @param {google.firestore.v1beta1.IWriteRequest=} [properties] Properties to set - */ - function WriteRequest(properties) { - this.writes = []; - this.labels = {}; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * WriteRequest database. - * @member {string} database - * @memberof google.firestore.v1beta1.WriteRequest - * @instance - */ - WriteRequest.prototype.database = ""; - - /** - * WriteRequest streamId. - * @member {string} streamId - * @memberof google.firestore.v1beta1.WriteRequest - * @instance - */ - WriteRequest.prototype.streamId = ""; - + + return protobuf; + })(); + + google.firestore = (function() { + + /** + * Namespace firestore. + * @memberof google + * @namespace + */ + var firestore = {}; + + firestore.v1beta1 = (function() { + /** - * WriteRequest writes. - * @member {Array.} writes - * @memberof google.firestore.v1beta1.WriteRequest - * @instance + * Namespace v1beta1. + * @memberof google.firestore + * @namespace */ - WriteRequest.prototype.writes = $util.emptyArray; - - /** - * WriteRequest streamToken. - * @member {Uint8Array} streamToken - * @memberof google.firestore.v1beta1.WriteRequest - * @instance - */ - WriteRequest.prototype.streamToken = $util.newBuffer([]); - - /** - * WriteRequest labels. - * @member {Object.} labels - * @memberof google.firestore.v1beta1.WriteRequest - * @instance - */ - WriteRequest.prototype.labels = $util.emptyObject; - - return WriteRequest; - })(); - - v1beta1.WriteResponse = (function() { - - /** - * Properties of a WriteResponse. - * @memberof google.firestore.v1beta1 - * @interface IWriteResponse - * @property {string|null} [streamId] WriteResponse streamId - * @property {Uint8Array|null} [streamToken] WriteResponse streamToken - * @property {Array.|null} [writeResults] WriteResponse writeResults - * @property {google.protobuf.ITimestamp|null} [commitTime] WriteResponse commitTime - */ - - /** - * Constructs a new WriteResponse. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a WriteResponse. - * @implements IWriteResponse - * @constructor - * @param {google.firestore.v1beta1.IWriteResponse=} [properties] Properties to set - */ - function WriteResponse(properties) { - this.writeResults = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * WriteResponse streamId. - * @member {string} streamId - * @memberof google.firestore.v1beta1.WriteResponse - * @instance - */ - WriteResponse.prototype.streamId = ""; - - /** - * WriteResponse streamToken. - * @member {Uint8Array} streamToken - * @memberof google.firestore.v1beta1.WriteResponse - * @instance - */ - WriteResponse.prototype.streamToken = $util.newBuffer([]); - - /** - * WriteResponse writeResults. - * @member {Array.} writeResults - * @memberof google.firestore.v1beta1.WriteResponse - * @instance - */ - WriteResponse.prototype.writeResults = $util.emptyArray; - - /** - * WriteResponse commitTime. - * @member {google.protobuf.ITimestamp|null|undefined} commitTime - * @memberof google.firestore.v1beta1.WriteResponse - * @instance - */ - WriteResponse.prototype.commitTime = null; - - return WriteResponse; - })(); - - v1beta1.ListenRequest = (function() { - - /** - * Properties of a ListenRequest. - * @memberof google.firestore.v1beta1 - * @interface IListenRequest - * @property {string|null} [database] ListenRequest database - * @property {google.firestore.v1beta1.ITarget|null} [addTarget] ListenRequest addTarget - * @property {number|null} [removeTarget] ListenRequest removeTarget - * @property {Object.|null} [labels] ListenRequest labels - */ - - /** - * Constructs a new ListenRequest. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a ListenRequest. - * @implements IListenRequest - * @constructor - * @param {google.firestore.v1beta1.IListenRequest=} [properties] Properties to set - */ - function ListenRequest(properties) { - this.labels = {}; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListenRequest database. - * @member {string} database - * @memberof google.firestore.v1beta1.ListenRequest - * @instance - */ - ListenRequest.prototype.database = ""; - - /** - * ListenRequest addTarget. - * @member {google.firestore.v1beta1.ITarget|null|undefined} addTarget - * @memberof google.firestore.v1beta1.ListenRequest - * @instance - */ - ListenRequest.prototype.addTarget = null; - - /** - * ListenRequest removeTarget. - * @member {number} removeTarget - * @memberof google.firestore.v1beta1.ListenRequest - * @instance - */ - ListenRequest.prototype.removeTarget = 0; - - /** - * ListenRequest labels. - * @member {Object.} labels - * @memberof google.firestore.v1beta1.ListenRequest - * @instance - */ - ListenRequest.prototype.labels = $util.emptyObject; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * ListenRequest targetChange. - * @member {"addTarget"|"removeTarget"|undefined} targetChange - * @memberof google.firestore.v1beta1.ListenRequest - * @instance - */ - Object.defineProperty(ListenRequest.prototype, "targetChange", { - get: $util.oneOfGetter($oneOfFields = ["addTarget", "removeTarget"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return ListenRequest; - })(); - - v1beta1.ListenResponse = (function() { - - /** - * Properties of a ListenResponse. - * @memberof google.firestore.v1beta1 - * @interface IListenResponse - * @property {google.firestore.v1beta1.ITargetChange|null} [targetChange] ListenResponse targetChange - * @property {google.firestore.v1beta1.IDocumentChange|null} [documentChange] ListenResponse documentChange - * @property {google.firestore.v1beta1.IDocumentDelete|null} [documentDelete] ListenResponse documentDelete - * @property {google.firestore.v1beta1.IDocumentRemove|null} [documentRemove] ListenResponse documentRemove - * @property {google.firestore.v1beta1.IExistenceFilter|null} [filter] ListenResponse filter - */ - - /** - * Constructs a new ListenResponse. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a ListenResponse. - * @implements IListenResponse - * @constructor - * @param {google.firestore.v1beta1.IListenResponse=} [properties] Properties to set - */ - function ListenResponse(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListenResponse targetChange. - * @member {google.firestore.v1beta1.ITargetChange|null|undefined} targetChange - * @memberof google.firestore.v1beta1.ListenResponse - * @instance - */ - ListenResponse.prototype.targetChange = null; - - /** - * ListenResponse documentChange. - * @member {google.firestore.v1beta1.IDocumentChange|null|undefined} documentChange - * @memberof google.firestore.v1beta1.ListenResponse - * @instance - */ - ListenResponse.prototype.documentChange = null; - - /** - * ListenResponse documentDelete. - * @member {google.firestore.v1beta1.IDocumentDelete|null|undefined} documentDelete - * @memberof google.firestore.v1beta1.ListenResponse - * @instance - */ - ListenResponse.prototype.documentDelete = null; - - /** - * ListenResponse documentRemove. - * @member {google.firestore.v1beta1.IDocumentRemove|null|undefined} documentRemove - * @memberof google.firestore.v1beta1.ListenResponse - * @instance - */ - ListenResponse.prototype.documentRemove = null; - - /** - * ListenResponse filter. - * @member {google.firestore.v1beta1.IExistenceFilter|null|undefined} filter - * @memberof google.firestore.v1beta1.ListenResponse - * @instance - */ - ListenResponse.prototype.filter = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * ListenResponse responseType. - * @member {"targetChange"|"documentChange"|"documentDelete"|"documentRemove"|"filter"|undefined} responseType - * @memberof google.firestore.v1beta1.ListenResponse - * @instance - */ - Object.defineProperty(ListenResponse.prototype, "responseType", { - get: $util.oneOfGetter($oneOfFields = ["targetChange", "documentChange", "documentDelete", "documentRemove", "filter"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return ListenResponse; - })(); - - v1beta1.Target = (function() { - - /** - * Properties of a Target. - * @memberof google.firestore.v1beta1 - * @interface ITarget - * @property {google.firestore.v1beta1.Target.IQueryTarget|null} [query] Target query - * @property {google.firestore.v1beta1.Target.IDocumentsTarget|null} [documents] Target documents - * @property {Uint8Array|null} [resumeToken] Target resumeToken - * @property {google.protobuf.ITimestamp|null} [readTime] Target readTime - * @property {number|null} [targetId] Target targetId - * @property {boolean|null} [once] Target once - */ - - /** - * Constructs a new Target. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a Target. - * @implements ITarget - * @constructor - * @param {google.firestore.v1beta1.ITarget=} [properties] Properties to set - */ - function Target(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Target query. - * @member {google.firestore.v1beta1.Target.IQueryTarget|null|undefined} query - * @memberof google.firestore.v1beta1.Target - * @instance - */ - Target.prototype.query = null; - - /** - * Target documents. - * @member {google.firestore.v1beta1.Target.IDocumentsTarget|null|undefined} documents - * @memberof google.firestore.v1beta1.Target - * @instance - */ - Target.prototype.documents = null; - - /** - * Target resumeToken. - * @member {Uint8Array} resumeToken - * @memberof google.firestore.v1beta1.Target - * @instance - */ - Target.prototype.resumeToken = $util.newBuffer([]); - - /** - * Target readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1beta1.Target - * @instance - */ - Target.prototype.readTime = null; - - /** - * Target targetId. - * @member {number} targetId - * @memberof google.firestore.v1beta1.Target - * @instance - */ - Target.prototype.targetId = 0; - - /** - * Target once. - * @member {boolean} once - * @memberof google.firestore.v1beta1.Target - * @instance - */ - Target.prototype.once = false; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Target targetType. - * @member {"query"|"documents"|undefined} targetType - * @memberof google.firestore.v1beta1.Target - * @instance - */ - Object.defineProperty(Target.prototype, "targetType", { - get: $util.oneOfGetter($oneOfFields = ["query", "documents"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * Target resumeType. - * @member {"resumeToken"|"readTime"|undefined} resumeType - * @memberof google.firestore.v1beta1.Target - * @instance - */ - Object.defineProperty(Target.prototype, "resumeType", { - get: $util.oneOfGetter($oneOfFields = ["resumeToken", "readTime"]), - set: $util.oneOfSetter($oneOfFields) - }); - - Target.DocumentsTarget = (function() { - + var v1beta1 = {}; + + v1beta1.DocumentMask = (function() { + /** - * Properties of a DocumentsTarget. - * @memberof google.firestore.v1beta1.Target - * @interface IDocumentsTarget - * @property {Array.|null} [documents] DocumentsTarget documents + * Properties of a DocumentMask. + * @memberof google.firestore.v1beta1 + * @interface IDocumentMask + * @property {Array.|null} [fieldPaths] DocumentMask fieldPaths */ - + /** - * Constructs a new DocumentsTarget. - * @memberof google.firestore.v1beta1.Target - * @classdesc Represents a DocumentsTarget. - * @implements IDocumentsTarget + * Constructs a new DocumentMask. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a DocumentMask. + * @implements IDocumentMask * @constructor - * @param {google.firestore.v1beta1.Target.IDocumentsTarget=} [properties] Properties to set + * @param {google.firestore.v1beta1.IDocumentMask=} [properties] Properties to set */ - function DocumentsTarget(properties) { - this.documents = []; + function DocumentMask(properties) { + this.fieldPaths = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * DocumentsTarget documents. - * @member {Array.} documents - * @memberof google.firestore.v1beta1.Target.DocumentsTarget + * DocumentMask fieldPaths. + * @member {Array.} fieldPaths + * @memberof google.firestore.v1beta1.DocumentMask * @instance */ - DocumentsTarget.prototype.documents = $util.emptyArray; - - return DocumentsTarget; + DocumentMask.prototype.fieldPaths = $util.emptyArray; + + /** + * Creates a DocumentMask message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.DocumentMask + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.DocumentMask} DocumentMask + */ + DocumentMask.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.DocumentMask) + return object; + var message = new $root.google.firestore.v1beta1.DocumentMask(); + if (object.fieldPaths) { + if (!Array.isArray(object.fieldPaths)) + throw TypeError(".google.firestore.v1beta1.DocumentMask.fieldPaths: array expected"); + message.fieldPaths = []; + for (var i = 0; i < object.fieldPaths.length; ++i) + message.fieldPaths[i] = String(object.fieldPaths[i]); + } + return message; + }; + + /** + * Creates a plain object from a DocumentMask message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.DocumentMask + * @static + * @param {google.firestore.v1beta1.DocumentMask} message DocumentMask + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentMask.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.fieldPaths = []; + if (message.fieldPaths && message.fieldPaths.length) { + object.fieldPaths = []; + for (var j = 0; j < message.fieldPaths.length; ++j) + object.fieldPaths[j] = message.fieldPaths[j]; + } + return object; + }; + + /** + * Converts this DocumentMask to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.DocumentMask + * @instance + * @returns {Object.} JSON object + */ + DocumentMask.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DocumentMask; })(); - - Target.QueryTarget = (function() { - + + v1beta1.Precondition = (function() { + /** - * Properties of a QueryTarget. - * @memberof google.firestore.v1beta1.Target - * @interface IQueryTarget - * @property {string|null} [parent] QueryTarget parent - * @property {google.firestore.v1beta1.IStructuredQuery|null} [structuredQuery] QueryTarget structuredQuery + * Properties of a Precondition. + * @memberof google.firestore.v1beta1 + * @interface IPrecondition + * @property {boolean|null} [exists] Precondition exists + * @property {google.protobuf.ITimestamp|null} [updateTime] Precondition updateTime */ - + /** - * Constructs a new QueryTarget. - * @memberof google.firestore.v1beta1.Target - * @classdesc Represents a QueryTarget. - * @implements IQueryTarget + * Constructs a new Precondition. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a Precondition. + * @implements IPrecondition * @constructor - * @param {google.firestore.v1beta1.Target.IQueryTarget=} [properties] Properties to set + * @param {google.firestore.v1beta1.IPrecondition=} [properties] Properties to set */ - function QueryTarget(properties) { + function Precondition(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * QueryTarget parent. - * @member {string} parent - * @memberof google.firestore.v1beta1.Target.QueryTarget + * Precondition exists. + * @member {boolean} exists + * @memberof google.firestore.v1beta1.Precondition * @instance */ - QueryTarget.prototype.parent = ""; - + Precondition.prototype.exists = false; + /** - * QueryTarget structuredQuery. - * @member {google.firestore.v1beta1.IStructuredQuery|null|undefined} structuredQuery - * @memberof google.firestore.v1beta1.Target.QueryTarget + * Precondition updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.firestore.v1beta1.Precondition * @instance */ - QueryTarget.prototype.structuredQuery = null; - + Precondition.prototype.updateTime = null; + // OneOf field names bound to virtual getters and setters var $oneOfFields; - + /** - * QueryTarget queryType. - * @member {"structuredQuery"|undefined} queryType - * @memberof google.firestore.v1beta1.Target.QueryTarget + * Precondition conditionType. + * @member {"exists"|"updateTime"|undefined} conditionType + * @memberof google.firestore.v1beta1.Precondition * @instance */ - Object.defineProperty(QueryTarget.prototype, "queryType", { - get: $util.oneOfGetter($oneOfFields = ["structuredQuery"]), + Object.defineProperty(Precondition.prototype, "conditionType", { + get: $util.oneOfGetter($oneOfFields = ["exists", "updateTime"]), set: $util.oneOfSetter($oneOfFields) }); - - return QueryTarget; - })(); - - return Target; - })(); - - v1beta1.TargetChange = (function() { - - /** - * Properties of a TargetChange. - * @memberof google.firestore.v1beta1 - * @interface ITargetChange - * @property {google.firestore.v1beta1.TargetChange.TargetChangeType|null} [targetChangeType] TargetChange targetChangeType - * @property {Array.|null} [targetIds] TargetChange targetIds - * @property {google.rpc.IStatus|null} [cause] TargetChange cause - * @property {Uint8Array|null} [resumeToken] TargetChange resumeToken - * @property {google.protobuf.ITimestamp|null} [readTime] TargetChange readTime - */ - - /** - * Constructs a new TargetChange. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a TargetChange. - * @implements ITargetChange - * @constructor - * @param {google.firestore.v1beta1.ITargetChange=} [properties] Properties to set - */ - function TargetChange(properties) { - this.targetIds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * TargetChange targetChangeType. - * @member {google.firestore.v1beta1.TargetChange.TargetChangeType} targetChangeType - * @memberof google.firestore.v1beta1.TargetChange - * @instance - */ - TargetChange.prototype.targetChangeType = 0; - - /** - * TargetChange targetIds. - * @member {Array.} targetIds - * @memberof google.firestore.v1beta1.TargetChange - * @instance - */ - TargetChange.prototype.targetIds = $util.emptyArray; - - /** - * TargetChange cause. - * @member {google.rpc.IStatus|null|undefined} cause - * @memberof google.firestore.v1beta1.TargetChange - * @instance - */ - TargetChange.prototype.cause = null; - - /** - * TargetChange resumeToken. - * @member {Uint8Array} resumeToken - * @memberof google.firestore.v1beta1.TargetChange - * @instance - */ - TargetChange.prototype.resumeToken = $util.newBuffer([]); - - /** - * TargetChange readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1beta1.TargetChange - * @instance - */ - TargetChange.prototype.readTime = null; - - /** - * TargetChangeType enum. - * @name google.firestore.v1beta1.TargetChange.TargetChangeType - * @enum {number} - * @property {string} NO_CHANGE=NO_CHANGE NO_CHANGE value - * @property {string} ADD=ADD ADD value - * @property {string} REMOVE=REMOVE REMOVE value - * @property {string} CURRENT=CURRENT CURRENT value - * @property {string} RESET=RESET RESET value - */ - TargetChange.TargetChangeType = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "NO_CHANGE"] = "NO_CHANGE"; - values[valuesById[1] = "ADD"] = "ADD"; - values[valuesById[2] = "REMOVE"] = "REMOVE"; - values[valuesById[3] = "CURRENT"] = "CURRENT"; - values[valuesById[4] = "RESET"] = "RESET"; - return values; + + /** + * Creates a Precondition message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.Precondition + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.Precondition} Precondition + */ + Precondition.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.Precondition) + return object; + var message = new $root.google.firestore.v1beta1.Precondition(); + if (object.exists != null) + message.exists = Boolean(object.exists); + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.firestore.v1beta1.Precondition.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + return message; + }; + + /** + * Creates a plain object from a Precondition message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.Precondition + * @static + * @param {google.firestore.v1beta1.Precondition} message Precondition + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Precondition.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.exists != null && message.hasOwnProperty("exists")) { + object.exists = message.exists; + if (options.oneofs) + object.conditionType = "exists"; + } + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (options.oneofs) + object.conditionType = "updateTime"; + } + return object; + }; + + /** + * Converts this Precondition to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.Precondition + * @instance + * @returns {Object.} JSON object + */ + Precondition.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Precondition; })(); - - return TargetChange; - })(); - - v1beta1.ListCollectionIdsRequest = (function() { - - /** - * Properties of a ListCollectionIdsRequest. - * @memberof google.firestore.v1beta1 - * @interface IListCollectionIdsRequest - * @property {string|null} [parent] ListCollectionIdsRequest parent - * @property {number|null} [pageSize] ListCollectionIdsRequest pageSize - * @property {string|null} [pageToken] ListCollectionIdsRequest pageToken - */ - - /** - * Constructs a new ListCollectionIdsRequest. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a ListCollectionIdsRequest. - * @implements IListCollectionIdsRequest - * @constructor - * @param {google.firestore.v1beta1.IListCollectionIdsRequest=} [properties] Properties to set - */ - function ListCollectionIdsRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListCollectionIdsRequest parent. - * @member {string} parent - * @memberof google.firestore.v1beta1.ListCollectionIdsRequest - * @instance - */ - ListCollectionIdsRequest.prototype.parent = ""; - - /** - * ListCollectionIdsRequest pageSize. - * @member {number} pageSize - * @memberof google.firestore.v1beta1.ListCollectionIdsRequest - * @instance - */ - ListCollectionIdsRequest.prototype.pageSize = 0; - - /** - * ListCollectionIdsRequest pageToken. - * @member {string} pageToken - * @memberof google.firestore.v1beta1.ListCollectionIdsRequest - * @instance - */ - ListCollectionIdsRequest.prototype.pageToken = ""; - - return ListCollectionIdsRequest; - })(); - - v1beta1.ListCollectionIdsResponse = (function() { - - /** - * Properties of a ListCollectionIdsResponse. - * @memberof google.firestore.v1beta1 - * @interface IListCollectionIdsResponse - * @property {Array.|null} [collectionIds] ListCollectionIdsResponse collectionIds - * @property {string|null} [nextPageToken] ListCollectionIdsResponse nextPageToken - */ - - /** - * Constructs a new ListCollectionIdsResponse. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a ListCollectionIdsResponse. - * @implements IListCollectionIdsResponse - * @constructor - * @param {google.firestore.v1beta1.IListCollectionIdsResponse=} [properties] Properties to set - */ - function ListCollectionIdsResponse(properties) { - this.collectionIds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListCollectionIdsResponse collectionIds. - * @member {Array.} collectionIds - * @memberof google.firestore.v1beta1.ListCollectionIdsResponse - * @instance - */ - ListCollectionIdsResponse.prototype.collectionIds = $util.emptyArray; - - /** - * ListCollectionIdsResponse nextPageToken. - * @member {string} nextPageToken - * @memberof google.firestore.v1beta1.ListCollectionIdsResponse - * @instance - */ - ListCollectionIdsResponse.prototype.nextPageToken = ""; - - return ListCollectionIdsResponse; - })(); - - v1beta1.StructuredQuery = (function() { - - /** - * Properties of a StructuredQuery. - * @memberof google.firestore.v1beta1 - * @interface IStructuredQuery - * @property {google.firestore.v1beta1.StructuredQuery.IProjection|null} [select] StructuredQuery select - * @property {Array.|null} [from] StructuredQuery from - * @property {google.firestore.v1beta1.StructuredQuery.IFilter|null} [where] StructuredQuery where - * @property {Array.|null} [orderBy] StructuredQuery orderBy - * @property {google.firestore.v1beta1.ICursor|null} [startAt] StructuredQuery startAt - * @property {google.firestore.v1beta1.ICursor|null} [endAt] StructuredQuery endAt - * @property {number|null} [offset] StructuredQuery offset - * @property {google.protobuf.IInt32Value|null} [limit] StructuredQuery limit - */ - - /** - * Constructs a new StructuredQuery. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a StructuredQuery. - * @implements IStructuredQuery - * @constructor - * @param {google.firestore.v1beta1.IStructuredQuery=} [properties] Properties to set - */ - function StructuredQuery(properties) { - this.from = []; - this.orderBy = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * StructuredQuery select. - * @member {google.firestore.v1beta1.StructuredQuery.IProjection|null|undefined} select - * @memberof google.firestore.v1beta1.StructuredQuery - * @instance - */ - StructuredQuery.prototype.select = null; - - /** - * StructuredQuery from. - * @member {Array.} from - * @memberof google.firestore.v1beta1.StructuredQuery - * @instance - */ - StructuredQuery.prototype.from = $util.emptyArray; - - /** - * StructuredQuery where. - * @member {google.firestore.v1beta1.StructuredQuery.IFilter|null|undefined} where - * @memberof google.firestore.v1beta1.StructuredQuery - * @instance - */ - StructuredQuery.prototype.where = null; - - /** - * StructuredQuery orderBy. - * @member {Array.} orderBy - * @memberof google.firestore.v1beta1.StructuredQuery - * @instance - */ - StructuredQuery.prototype.orderBy = $util.emptyArray; - - /** - * StructuredQuery startAt. - * @member {google.firestore.v1beta1.ICursor|null|undefined} startAt - * @memberof google.firestore.v1beta1.StructuredQuery - * @instance - */ - StructuredQuery.prototype.startAt = null; - - /** - * StructuredQuery endAt. - * @member {google.firestore.v1beta1.ICursor|null|undefined} endAt - * @memberof google.firestore.v1beta1.StructuredQuery - * @instance - */ - StructuredQuery.prototype.endAt = null; - - /** - * StructuredQuery offset. - * @member {number} offset - * @memberof google.firestore.v1beta1.StructuredQuery - * @instance - */ - StructuredQuery.prototype.offset = 0; - - /** - * StructuredQuery limit. - * @member {google.protobuf.IInt32Value|null|undefined} limit - * @memberof google.firestore.v1beta1.StructuredQuery - * @instance - */ - StructuredQuery.prototype.limit = null; - - StructuredQuery.CollectionSelector = (function() { - + + v1beta1.TransactionOptions = (function() { + /** - * Properties of a CollectionSelector. - * @memberof google.firestore.v1beta1.StructuredQuery - * @interface ICollectionSelector - * @property {string|null} [collectionId] CollectionSelector collectionId - * @property {boolean|null} [allDescendants] CollectionSelector allDescendants + * Properties of a TransactionOptions. + * @memberof google.firestore.v1beta1 + * @interface ITransactionOptions + * @property {google.firestore.v1beta1.TransactionOptions.IReadOnly|null} [readOnly] TransactionOptions readOnly + * @property {google.firestore.v1beta1.TransactionOptions.IReadWrite|null} [readWrite] TransactionOptions readWrite */ - + /** - * Constructs a new CollectionSelector. - * @memberof google.firestore.v1beta1.StructuredQuery - * @classdesc Represents a CollectionSelector. - * @implements ICollectionSelector + * Constructs a new TransactionOptions. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a TransactionOptions. + * @implements ITransactionOptions * @constructor - * @param {google.firestore.v1beta1.StructuredQuery.ICollectionSelector=} [properties] Properties to set + * @param {google.firestore.v1beta1.ITransactionOptions=} [properties] Properties to set */ - function CollectionSelector(properties) { + function TransactionOptions(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * CollectionSelector collectionId. - * @member {string} collectionId - * @memberof google.firestore.v1beta1.StructuredQuery.CollectionSelector + * TransactionOptions readOnly. + * @member {google.firestore.v1beta1.TransactionOptions.IReadOnly|null|undefined} readOnly + * @memberof google.firestore.v1beta1.TransactionOptions * @instance */ - CollectionSelector.prototype.collectionId = ""; - + TransactionOptions.prototype.readOnly = null; + /** - * CollectionSelector allDescendants. - * @member {boolean} allDescendants - * @memberof google.firestore.v1beta1.StructuredQuery.CollectionSelector + * TransactionOptions readWrite. + * @member {google.firestore.v1beta1.TransactionOptions.IReadWrite|null|undefined} readWrite + * @memberof google.firestore.v1beta1.TransactionOptions * @instance */ - CollectionSelector.prototype.allDescendants = false; - - return CollectionSelector; + TransactionOptions.prototype.readWrite = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * TransactionOptions mode. + * @member {"readOnly"|"readWrite"|undefined} mode + * @memberof google.firestore.v1beta1.TransactionOptions + * @instance + */ + Object.defineProperty(TransactionOptions.prototype, "mode", { + get: $util.oneOfGetter($oneOfFields = ["readOnly", "readWrite"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a TransactionOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.TransactionOptions + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.TransactionOptions} TransactionOptions + */ + TransactionOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.TransactionOptions) + return object; + var message = new $root.google.firestore.v1beta1.TransactionOptions(); + if (object.readOnly != null) { + if (typeof object.readOnly !== "object") + throw TypeError(".google.firestore.v1beta1.TransactionOptions.readOnly: object expected"); + message.readOnly = $root.google.firestore.v1beta1.TransactionOptions.ReadOnly.fromObject(object.readOnly); + } + if (object.readWrite != null) { + if (typeof object.readWrite !== "object") + throw TypeError(".google.firestore.v1beta1.TransactionOptions.readWrite: object expected"); + message.readWrite = $root.google.firestore.v1beta1.TransactionOptions.ReadWrite.fromObject(object.readWrite); + } + return message; + }; + + /** + * Creates a plain object from a TransactionOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.TransactionOptions + * @static + * @param {google.firestore.v1beta1.TransactionOptions} message TransactionOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TransactionOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.readOnly != null && message.hasOwnProperty("readOnly")) { + object.readOnly = $root.google.firestore.v1beta1.TransactionOptions.ReadOnly.toObject(message.readOnly, options); + if (options.oneofs) + object.mode = "readOnly"; + } + if (message.readWrite != null && message.hasOwnProperty("readWrite")) { + object.readWrite = $root.google.firestore.v1beta1.TransactionOptions.ReadWrite.toObject(message.readWrite, options); + if (options.oneofs) + object.mode = "readWrite"; + } + return object; + }; + + /** + * Converts this TransactionOptions to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.TransactionOptions + * @instance + * @returns {Object.} JSON object + */ + TransactionOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + TransactionOptions.ReadWrite = (function() { + + /** + * Properties of a ReadWrite. + * @memberof google.firestore.v1beta1.TransactionOptions + * @interface IReadWrite + * @property {Uint8Array|null} [retryTransaction] ReadWrite retryTransaction + */ + + /** + * Constructs a new ReadWrite. + * @memberof google.firestore.v1beta1.TransactionOptions + * @classdesc Represents a ReadWrite. + * @implements IReadWrite + * @constructor + * @param {google.firestore.v1beta1.TransactionOptions.IReadWrite=} [properties] Properties to set + */ + function ReadWrite(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReadWrite retryTransaction. + * @member {Uint8Array} retryTransaction + * @memberof google.firestore.v1beta1.TransactionOptions.ReadWrite + * @instance + */ + ReadWrite.prototype.retryTransaction = $util.newBuffer([]); + + /** + * Creates a ReadWrite message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.TransactionOptions.ReadWrite + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.TransactionOptions.ReadWrite} ReadWrite + */ + ReadWrite.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.TransactionOptions.ReadWrite) + return object; + var message = new $root.google.firestore.v1beta1.TransactionOptions.ReadWrite(); + if (object.retryTransaction != null) + if (typeof object.retryTransaction === "string") + $util.base64.decode(object.retryTransaction, message.retryTransaction = $util.newBuffer($util.base64.length(object.retryTransaction)), 0); + else if (object.retryTransaction.length) + message.retryTransaction = object.retryTransaction; + return message; + }; + + /** + * Creates a plain object from a ReadWrite message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.TransactionOptions.ReadWrite + * @static + * @param {google.firestore.v1beta1.TransactionOptions.ReadWrite} message ReadWrite + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReadWrite.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.retryTransaction = ""; + else { + object.retryTransaction = []; + if (options.bytes !== Array) + object.retryTransaction = $util.newBuffer(object.retryTransaction); + } + if (message.retryTransaction != null && message.hasOwnProperty("retryTransaction")) + object.retryTransaction = options.bytes === String ? $util.base64.encode(message.retryTransaction, 0, message.retryTransaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.retryTransaction) : message.retryTransaction; + return object; + }; + + /** + * Converts this ReadWrite to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.TransactionOptions.ReadWrite + * @instance + * @returns {Object.} JSON object + */ + ReadWrite.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ReadWrite; + })(); + + TransactionOptions.ReadOnly = (function() { + + /** + * Properties of a ReadOnly. + * @memberof google.firestore.v1beta1.TransactionOptions + * @interface IReadOnly + * @property {google.protobuf.ITimestamp|null} [readTime] ReadOnly readTime + */ + + /** + * Constructs a new ReadOnly. + * @memberof google.firestore.v1beta1.TransactionOptions + * @classdesc Represents a ReadOnly. + * @implements IReadOnly + * @constructor + * @param {google.firestore.v1beta1.TransactionOptions.IReadOnly=} [properties] Properties to set + */ + function ReadOnly(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReadOnly readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.TransactionOptions.ReadOnly + * @instance + */ + ReadOnly.prototype.readTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ReadOnly consistencySelector. + * @member {"readTime"|undefined} consistencySelector + * @memberof google.firestore.v1beta1.TransactionOptions.ReadOnly + * @instance + */ + Object.defineProperty(ReadOnly.prototype, "consistencySelector", { + get: $util.oneOfGetter($oneOfFields = ["readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a ReadOnly message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.TransactionOptions.ReadOnly + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.TransactionOptions.ReadOnly} ReadOnly + */ + ReadOnly.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.TransactionOptions.ReadOnly) + return object; + var message = new $root.google.firestore.v1beta1.TransactionOptions.ReadOnly(); + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1beta1.TransactionOptions.ReadOnly.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a ReadOnly message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.TransactionOptions.ReadOnly + * @static + * @param {google.firestore.v1beta1.TransactionOptions.ReadOnly} message ReadOnly + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReadOnly.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.readTime != null && message.hasOwnProperty("readTime")) { + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (options.oneofs) + object.consistencySelector = "readTime"; + } + return object; + }; + + /** + * Converts this ReadOnly to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.TransactionOptions.ReadOnly + * @instance + * @returns {Object.} JSON object + */ + ReadOnly.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ReadOnly; + })(); + + return TransactionOptions; })(); - - StructuredQuery.Filter = (function() { - + + v1beta1.Document = (function() { + /** - * Properties of a Filter. - * @memberof google.firestore.v1beta1.StructuredQuery - * @interface IFilter - * @property {google.firestore.v1beta1.StructuredQuery.ICompositeFilter|null} [compositeFilter] Filter compositeFilter - * @property {google.firestore.v1beta1.StructuredQuery.IFieldFilter|null} [fieldFilter] Filter fieldFilter - * @property {google.firestore.v1beta1.StructuredQuery.IUnaryFilter|null} [unaryFilter] Filter unaryFilter + * Properties of a Document. + * @memberof google.firestore.v1beta1 + * @interface IDocument + * @property {string|null} [name] Document name + * @property {Object.|null} [fields] Document fields + * @property {google.protobuf.ITimestamp|null} [createTime] Document createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] Document updateTime */ - + /** - * Constructs a new Filter. - * @memberof google.firestore.v1beta1.StructuredQuery - * @classdesc Represents a Filter. - * @implements IFilter + * Constructs a new Document. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a Document. + * @implements IDocument * @constructor - * @param {google.firestore.v1beta1.StructuredQuery.IFilter=} [properties] Properties to set + * @param {google.firestore.v1beta1.IDocument=} [properties] Properties to set */ - function Filter(properties) { + function Document(properties) { + this.fields = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * Filter compositeFilter. - * @member {google.firestore.v1beta1.StructuredQuery.ICompositeFilter|null|undefined} compositeFilter - * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * Document name. + * @member {string} name + * @memberof google.firestore.v1beta1.Document * @instance */ - Filter.prototype.compositeFilter = null; - + Document.prototype.name = ""; + /** - * Filter fieldFilter. - * @member {google.firestore.v1beta1.StructuredQuery.IFieldFilter|null|undefined} fieldFilter - * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * Document fields. + * @member {Object.} fields + * @memberof google.firestore.v1beta1.Document * @instance */ - Filter.prototype.fieldFilter = null; - + Document.prototype.fields = $util.emptyObject; + /** - * Filter unaryFilter. - * @member {google.firestore.v1beta1.StructuredQuery.IUnaryFilter|null|undefined} unaryFilter - * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * Document createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.firestore.v1beta1.Document * @instance */ - Filter.prototype.unaryFilter = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - + Document.prototype.createTime = null; + /** - * Filter filterType. - * @member {"compositeFilter"|"fieldFilter"|"unaryFilter"|undefined} filterType - * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * Document updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.firestore.v1beta1.Document * @instance */ - Object.defineProperty(Filter.prototype, "filterType", { - get: $util.oneOfGetter($oneOfFields = ["compositeFilter", "fieldFilter", "unaryFilter"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return Filter; + Document.prototype.updateTime = null; + + /** + * Creates a Document message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.Document + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.Document} Document + */ + Document.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.Document) + return object; + var message = new $root.google.firestore.v1beta1.Document(); + if (object.name != null) + message.name = String(object.name); + if (object.fields) { + if (typeof object.fields !== "object") + throw TypeError(".google.firestore.v1beta1.Document.fields: object expected"); + message.fields = {}; + for (var keys = Object.keys(object.fields), i = 0; i < keys.length; ++i) { + if (typeof object.fields[keys[i]] !== "object") + throw TypeError(".google.firestore.v1beta1.Document.fields: object expected"); + message.fields[keys[i]] = $root.google.firestore.v1beta1.Value.fromObject(object.fields[keys[i]]); + } + } + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.firestore.v1beta1.Document.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.firestore.v1beta1.Document.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + return message; + }; + + /** + * Creates a plain object from a Document message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.Document + * @static + * @param {google.firestore.v1beta1.Document} message Document + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Document.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.fields = {}; + if (options.defaults) { + object.name = ""; + object.createTime = null; + object.updateTime = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + var keys2; + if (message.fields && (keys2 = Object.keys(message.fields)).length) { + object.fields = {}; + for (var j = 0; j < keys2.length; ++j) + object.fields[keys2[j]] = $root.google.firestore.v1beta1.Value.toObject(message.fields[keys2[j]], options); + } + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + return object; + }; + + /** + * Converts this Document to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.Document + * @instance + * @returns {Object.} JSON object + */ + Document.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Document; })(); - - StructuredQuery.CompositeFilter = (function() { - + + v1beta1.Value = (function() { + /** - * Properties of a CompositeFilter. - * @memberof google.firestore.v1beta1.StructuredQuery - * @interface ICompositeFilter - * @property {google.firestore.v1beta1.StructuredQuery.CompositeFilter.Operator|null} [op] CompositeFilter op - * @property {Array.|null} [filters] CompositeFilter filters + * Properties of a Value. + * @memberof google.firestore.v1beta1 + * @interface IValue + * @property {google.protobuf.NullValue|null} [nullValue] Value nullValue + * @property {boolean|null} [booleanValue] Value booleanValue + * @property {number|string|null} [integerValue] Value integerValue + * @property {number|null} [doubleValue] Value doubleValue + * @property {google.protobuf.ITimestamp|null} [timestampValue] Value timestampValue + * @property {string|null} [stringValue] Value stringValue + * @property {Uint8Array|null} [bytesValue] Value bytesValue + * @property {string|null} [referenceValue] Value referenceValue + * @property {google.type.ILatLng|null} [geoPointValue] Value geoPointValue + * @property {google.firestore.v1beta1.IArrayValue|null} [arrayValue] Value arrayValue + * @property {google.firestore.v1beta1.IMapValue|null} [mapValue] Value mapValue */ - + /** - * Constructs a new CompositeFilter. - * @memberof google.firestore.v1beta1.StructuredQuery - * @classdesc Represents a CompositeFilter. - * @implements ICompositeFilter + * Constructs a new Value. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a Value. + * @implements IValue * @constructor - * @param {google.firestore.v1beta1.StructuredQuery.ICompositeFilter=} [properties] Properties to set + * @param {google.firestore.v1beta1.IValue=} [properties] Properties to set */ - function CompositeFilter(properties) { - this.filters = []; + function Value(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * CompositeFilter op. - * @member {google.firestore.v1beta1.StructuredQuery.CompositeFilter.Operator} op - * @memberof google.firestore.v1beta1.StructuredQuery.CompositeFilter + * Value nullValue. + * @member {google.protobuf.NullValue} nullValue + * @memberof google.firestore.v1beta1.Value * @instance */ - CompositeFilter.prototype.op = 0; - + Value.prototype.nullValue = 0; + /** - * CompositeFilter filters. - * @member {Array.} filters - * @memberof google.firestore.v1beta1.StructuredQuery.CompositeFilter + * Value booleanValue. + * @member {boolean} booleanValue + * @memberof google.firestore.v1beta1.Value * @instance */ - CompositeFilter.prototype.filters = $util.emptyArray; - - /** - * Operator enum. - * @name google.firestore.v1beta1.StructuredQuery.CompositeFilter.Operator - * @enum {number} - * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value - * @property {string} AND=AND AND value - */ - CompositeFilter.Operator = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; - values[valuesById[1] = "AND"] = "AND"; - return values; - })(); - - return CompositeFilter; - })(); - - StructuredQuery.FieldFilter = (function() { - + Value.prototype.booleanValue = false; + /** - * Properties of a FieldFilter. - * @memberof google.firestore.v1beta1.StructuredQuery - * @interface IFieldFilter - * @property {google.firestore.v1beta1.StructuredQuery.IFieldReference|null} [field] FieldFilter field - * @property {google.firestore.v1beta1.StructuredQuery.FieldFilter.Operator|null} [op] FieldFilter op - * @property {google.firestore.v1beta1.IValue|null} [value] FieldFilter value + * Value integerValue. + * @member {number|string} integerValue + * @memberof google.firestore.v1beta1.Value + * @instance */ - + Value.prototype.integerValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + /** - * Constructs a new FieldFilter. - * @memberof google.firestore.v1beta1.StructuredQuery - * @classdesc Represents a FieldFilter. - * @implements IFieldFilter - * @constructor - * @param {google.firestore.v1beta1.StructuredQuery.IFieldFilter=} [properties] Properties to set + * Value doubleValue. + * @member {number} doubleValue + * @memberof google.firestore.v1beta1.Value + * @instance */ - function FieldFilter(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - + Value.prototype.doubleValue = 0; + /** - * FieldFilter field. - * @member {google.firestore.v1beta1.StructuredQuery.IFieldReference|null|undefined} field - * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * Value timestampValue. + * @member {google.protobuf.ITimestamp|null|undefined} timestampValue + * @memberof google.firestore.v1beta1.Value * @instance */ - FieldFilter.prototype.field = null; - + Value.prototype.timestampValue = null; + /** - * FieldFilter op. - * @member {google.firestore.v1beta1.StructuredQuery.FieldFilter.Operator} op - * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * Value stringValue. + * @member {string} stringValue + * @memberof google.firestore.v1beta1.Value * @instance */ - FieldFilter.prototype.op = 0; - + Value.prototype.stringValue = ""; + /** - * FieldFilter value. - * @member {google.firestore.v1beta1.IValue|null|undefined} value - * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * Value bytesValue. + * @member {Uint8Array} bytesValue + * @memberof google.firestore.v1beta1.Value * @instance */ - FieldFilter.prototype.value = null; - - /** - * Operator enum. - * @name google.firestore.v1beta1.StructuredQuery.FieldFilter.Operator - * @enum {number} - * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value - * @property {string} LESS_THAN=LESS_THAN LESS_THAN value - * @property {string} LESS_THAN_OR_EQUAL=LESS_THAN_OR_EQUAL LESS_THAN_OR_EQUAL value - * @property {string} GREATER_THAN=GREATER_THAN GREATER_THAN value - * @property {string} GREATER_THAN_OR_EQUAL=GREATER_THAN_OR_EQUAL GREATER_THAN_OR_EQUAL value - * @property {string} EQUAL=EQUAL EQUAL value - * @property {string} ARRAY_CONTAINS=ARRAY_CONTAINS ARRAY_CONTAINS value - * @property {string} IN=IN IN value - * @property {string} ARRAY_CONTAINS_ANY=ARRAY_CONTAINS_ANY ARRAY_CONTAINS_ANY value - */ - FieldFilter.Operator = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; - values[valuesById[1] = "LESS_THAN"] = "LESS_THAN"; - values[valuesById[2] = "LESS_THAN_OR_EQUAL"] = "LESS_THAN_OR_EQUAL"; - values[valuesById[3] = "GREATER_THAN"] = "GREATER_THAN"; - values[valuesById[4] = "GREATER_THAN_OR_EQUAL"] = "GREATER_THAN_OR_EQUAL"; - values[valuesById[5] = "EQUAL"] = "EQUAL"; - values[valuesById[7] = "ARRAY_CONTAINS"] = "ARRAY_CONTAINS"; - values[valuesById[8] = "IN"] = "IN"; - values[valuesById[9] = "ARRAY_CONTAINS_ANY"] = "ARRAY_CONTAINS_ANY"; - return values; - })(); - - return FieldFilter; - })(); - - StructuredQuery.UnaryFilter = (function() { - + Value.prototype.bytesValue = $util.newBuffer([]); + /** - * Properties of an UnaryFilter. - * @memberof google.firestore.v1beta1.StructuredQuery - * @interface IUnaryFilter - * @property {google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator|null} [op] UnaryFilter op - * @property {google.firestore.v1beta1.StructuredQuery.IFieldReference|null} [field] UnaryFilter field + * Value referenceValue. + * @member {string} referenceValue + * @memberof google.firestore.v1beta1.Value + * @instance */ - + Value.prototype.referenceValue = ""; + /** - * Constructs a new UnaryFilter. - * @memberof google.firestore.v1beta1.StructuredQuery - * @classdesc Represents an UnaryFilter. - * @implements IUnaryFilter - * @constructor - * @param {google.firestore.v1beta1.StructuredQuery.IUnaryFilter=} [properties] Properties to set + * Value geoPointValue. + * @member {google.type.ILatLng|null|undefined} geoPointValue + * @memberof google.firestore.v1beta1.Value + * @instance */ - function UnaryFilter(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - + Value.prototype.geoPointValue = null; + /** - * UnaryFilter op. - * @member {google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator} op - * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * Value arrayValue. + * @member {google.firestore.v1beta1.IArrayValue|null|undefined} arrayValue + * @memberof google.firestore.v1beta1.Value * @instance */ - UnaryFilter.prototype.op = 0; - + Value.prototype.arrayValue = null; + /** - * UnaryFilter field. - * @member {google.firestore.v1beta1.StructuredQuery.IFieldReference|null|undefined} field - * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * Value mapValue. + * @member {google.firestore.v1beta1.IMapValue|null|undefined} mapValue + * @memberof google.firestore.v1beta1.Value * @instance */ - UnaryFilter.prototype.field = null; - + Value.prototype.mapValue = null; + // OneOf field names bound to virtual getters and setters var $oneOfFields; - + /** - * UnaryFilter operandType. - * @member {"field"|undefined} operandType - * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * Value valueType. + * @member {"nullValue"|"booleanValue"|"integerValue"|"doubleValue"|"timestampValue"|"stringValue"|"bytesValue"|"referenceValue"|"geoPointValue"|"arrayValue"|"mapValue"|undefined} valueType + * @memberof google.firestore.v1beta1.Value * @instance */ - Object.defineProperty(UnaryFilter.prototype, "operandType", { - get: $util.oneOfGetter($oneOfFields = ["field"]), + Object.defineProperty(Value.prototype, "valueType", { + get: $util.oneOfGetter($oneOfFields = ["nullValue", "booleanValue", "integerValue", "doubleValue", "timestampValue", "stringValue", "bytesValue", "referenceValue", "geoPointValue", "arrayValue", "mapValue"]), set: $util.oneOfSetter($oneOfFields) }); - + /** - * Operator enum. - * @name google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator - * @enum {number} - * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value - * @property {string} IS_NAN=IS_NAN IS_NAN value - * @property {string} IS_NULL=IS_NULL IS_NULL value + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.Value + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.Value} Value */ - UnaryFilter.Operator = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; - values[valuesById[2] = "IS_NAN"] = "IS_NAN"; - values[valuesById[3] = "IS_NULL"] = "IS_NULL"; - return values; - })(); - - return UnaryFilter; + Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.Value) + return object; + var message = new $root.google.firestore.v1beta1.Value(); + switch (object.nullValue) { + case "NULL_VALUE": + case 0: + message.nullValue = 0; + break; + } + if (object.booleanValue != null) + message.booleanValue = Boolean(object.booleanValue); + if (object.integerValue != null) + if ($util.Long) + (message.integerValue = $util.Long.fromValue(object.integerValue)).unsigned = false; + else if (typeof object.integerValue === "string") + message.integerValue = parseInt(object.integerValue, 10); + else if (typeof object.integerValue === "number") + message.integerValue = object.integerValue; + else if (typeof object.integerValue === "object") + message.integerValue = new $util.LongBits(object.integerValue.low >>> 0, object.integerValue.high >>> 0).toNumber(); + if (object.doubleValue != null) + message.doubleValue = Number(object.doubleValue); + if (object.timestampValue != null) { + if (typeof object.timestampValue !== "object") + throw TypeError(".google.firestore.v1beta1.Value.timestampValue: object expected"); + message.timestampValue = $root.google.protobuf.Timestamp.fromObject(object.timestampValue); + } + if (object.stringValue != null) + message.stringValue = String(object.stringValue); + if (object.bytesValue != null) + if (typeof object.bytesValue === "string") + $util.base64.decode(object.bytesValue, message.bytesValue = $util.newBuffer($util.base64.length(object.bytesValue)), 0); + else if (object.bytesValue.length) + message.bytesValue = object.bytesValue; + if (object.referenceValue != null) + message.referenceValue = String(object.referenceValue); + if (object.geoPointValue != null) { + if (typeof object.geoPointValue !== "object") + throw TypeError(".google.firestore.v1beta1.Value.geoPointValue: object expected"); + message.geoPointValue = $root.google.type.LatLng.fromObject(object.geoPointValue); + } + if (object.arrayValue != null) { + if (typeof object.arrayValue !== "object") + throw TypeError(".google.firestore.v1beta1.Value.arrayValue: object expected"); + message.arrayValue = $root.google.firestore.v1beta1.ArrayValue.fromObject(object.arrayValue); + } + if (object.mapValue != null) { + if (typeof object.mapValue !== "object") + throw TypeError(".google.firestore.v1beta1.Value.mapValue: object expected"); + message.mapValue = $root.google.firestore.v1beta1.MapValue.fromObject(object.mapValue); + } + return message; + }; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.Value + * @static + * @param {google.firestore.v1beta1.Value} message Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.booleanValue != null && message.hasOwnProperty("booleanValue")) { + object.booleanValue = message.booleanValue; + if (options.oneofs) + object.valueType = "booleanValue"; + } + if (message.integerValue != null && message.hasOwnProperty("integerValue")) { + if (typeof message.integerValue === "number") + object.integerValue = options.longs === String ? String(message.integerValue) : message.integerValue; + else + object.integerValue = options.longs === String ? $util.Long.prototype.toString.call(message.integerValue) : options.longs === Number ? new $util.LongBits(message.integerValue.low >>> 0, message.integerValue.high >>> 0).toNumber() : message.integerValue; + if (options.oneofs) + object.valueType = "integerValue"; + } + if (message.doubleValue != null && message.hasOwnProperty("doubleValue")) { + object.doubleValue = options.json && !isFinite(message.doubleValue) ? String(message.doubleValue) : message.doubleValue; + if (options.oneofs) + object.valueType = "doubleValue"; + } + if (message.referenceValue != null && message.hasOwnProperty("referenceValue")) { + object.referenceValue = message.referenceValue; + if (options.oneofs) + object.valueType = "referenceValue"; + } + if (message.mapValue != null && message.hasOwnProperty("mapValue")) { + object.mapValue = $root.google.firestore.v1beta1.MapValue.toObject(message.mapValue, options); + if (options.oneofs) + object.valueType = "mapValue"; + } + if (message.geoPointValue != null && message.hasOwnProperty("geoPointValue")) { + object.geoPointValue = $root.google.type.LatLng.toObject(message.geoPointValue, options); + if (options.oneofs) + object.valueType = "geoPointValue"; + } + if (message.arrayValue != null && message.hasOwnProperty("arrayValue")) { + object.arrayValue = $root.google.firestore.v1beta1.ArrayValue.toObject(message.arrayValue, options); + if (options.oneofs) + object.valueType = "arrayValue"; + } + if (message.timestampValue != null && message.hasOwnProperty("timestampValue")) { + object.timestampValue = $root.google.protobuf.Timestamp.toObject(message.timestampValue, options); + if (options.oneofs) + object.valueType = "timestampValue"; + } + if (message.nullValue != null && message.hasOwnProperty("nullValue")) { + object.nullValue = options.enums === String ? $root.google.protobuf.NullValue[message.nullValue] : message.nullValue; + if (options.oneofs) + object.valueType = "nullValue"; + } + if (message.stringValue != null && message.hasOwnProperty("stringValue")) { + object.stringValue = message.stringValue; + if (options.oneofs) + object.valueType = "stringValue"; + } + if (message.bytesValue != null && message.hasOwnProperty("bytesValue")) { + object.bytesValue = options.bytes === String ? $util.base64.encode(message.bytesValue, 0, message.bytesValue.length) : options.bytes === Array ? Array.prototype.slice.call(message.bytesValue) : message.bytesValue; + if (options.oneofs) + object.valueType = "bytesValue"; + } + return object; + }; + + /** + * Converts this Value to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.Value + * @instance + * @returns {Object.} JSON object + */ + Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Value; })(); - - StructuredQuery.Order = (function() { - + + v1beta1.ArrayValue = (function() { + /** - * Properties of an Order. - * @memberof google.firestore.v1beta1.StructuredQuery - * @interface IOrder - * @property {google.firestore.v1beta1.StructuredQuery.IFieldReference|null} [field] Order field - * @property {google.firestore.v1beta1.StructuredQuery.Direction|null} [direction] Order direction + * Properties of an ArrayValue. + * @memberof google.firestore.v1beta1 + * @interface IArrayValue + * @property {Array.|null} [values] ArrayValue values */ - + /** - * Constructs a new Order. - * @memberof google.firestore.v1beta1.StructuredQuery - * @classdesc Represents an Order. - * @implements IOrder + * Constructs a new ArrayValue. + * @memberof google.firestore.v1beta1 + * @classdesc Represents an ArrayValue. + * @implements IArrayValue * @constructor - * @param {google.firestore.v1beta1.StructuredQuery.IOrder=} [properties] Properties to set + * @param {google.firestore.v1beta1.IArrayValue=} [properties] Properties to set */ - function Order(properties) { + function ArrayValue(properties) { + this.values = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * Order field. - * @member {google.firestore.v1beta1.StructuredQuery.IFieldReference|null|undefined} field - * @memberof google.firestore.v1beta1.StructuredQuery.Order + * ArrayValue values. + * @member {Array.} values + * @memberof google.firestore.v1beta1.ArrayValue * @instance */ - Order.prototype.field = null; - + ArrayValue.prototype.values = $util.emptyArray; + /** - * Order direction. - * @member {google.firestore.v1beta1.StructuredQuery.Direction} direction - * @memberof google.firestore.v1beta1.StructuredQuery.Order + * Creates an ArrayValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.ArrayValue + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.ArrayValue} ArrayValue + */ + ArrayValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.ArrayValue) + return object; + var message = new $root.google.firestore.v1beta1.ArrayValue(); + if (object.values) { + if (!Array.isArray(object.values)) + throw TypeError(".google.firestore.v1beta1.ArrayValue.values: array expected"); + message.values = []; + for (var i = 0; i < object.values.length; ++i) { + if (typeof object.values[i] !== "object") + throw TypeError(".google.firestore.v1beta1.ArrayValue.values: object expected"); + message.values[i] = $root.google.firestore.v1beta1.Value.fromObject(object.values[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an ArrayValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.ArrayValue + * @static + * @param {google.firestore.v1beta1.ArrayValue} message ArrayValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ArrayValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.values = []; + if (message.values && message.values.length) { + object.values = []; + for (var j = 0; j < message.values.length; ++j) + object.values[j] = $root.google.firestore.v1beta1.Value.toObject(message.values[j], options); + } + return object; + }; + + /** + * Converts this ArrayValue to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.ArrayValue * @instance + * @returns {Object.} JSON object */ - Order.prototype.direction = 0; - - return Order; + ArrayValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ArrayValue; })(); - - StructuredQuery.FieldReference = (function() { - + + v1beta1.MapValue = (function() { + /** - * Properties of a FieldReference. - * @memberof google.firestore.v1beta1.StructuredQuery - * @interface IFieldReference - * @property {string|null} [fieldPath] FieldReference fieldPath + * Properties of a MapValue. + * @memberof google.firestore.v1beta1 + * @interface IMapValue + * @property {Object.|null} [fields] MapValue fields */ - + /** - * Constructs a new FieldReference. - * @memberof google.firestore.v1beta1.StructuredQuery - * @classdesc Represents a FieldReference. - * @implements IFieldReference + * Constructs a new MapValue. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a MapValue. + * @implements IMapValue * @constructor - * @param {google.firestore.v1beta1.StructuredQuery.IFieldReference=} [properties] Properties to set + * @param {google.firestore.v1beta1.IMapValue=} [properties] Properties to set */ - function FieldReference(properties) { + function MapValue(properties) { + this.fields = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + /** - * FieldReference fieldPath. - * @member {string} fieldPath - * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference + * MapValue fields. + * @member {Object.} fields + * @memberof google.firestore.v1beta1.MapValue * @instance */ - FieldReference.prototype.fieldPath = ""; - - return FieldReference; - })(); - - StructuredQuery.Projection = (function() { - + MapValue.prototype.fields = $util.emptyObject; + /** - * Properties of a Projection. - * @memberof google.firestore.v1beta1.StructuredQuery - * @interface IProjection - * @property {Array.|null} [fields] Projection fields + * Creates a MapValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.MapValue + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.MapValue} MapValue */ - + MapValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.MapValue) + return object; + var message = new $root.google.firestore.v1beta1.MapValue(); + if (object.fields) { + if (typeof object.fields !== "object") + throw TypeError(".google.firestore.v1beta1.MapValue.fields: object expected"); + message.fields = {}; + for (var keys = Object.keys(object.fields), i = 0; i < keys.length; ++i) { + if (typeof object.fields[keys[i]] !== "object") + throw TypeError(".google.firestore.v1beta1.MapValue.fields: object expected"); + message.fields[keys[i]] = $root.google.firestore.v1beta1.Value.fromObject(object.fields[keys[i]]); + } + } + return message; + }; + /** - * Constructs a new Projection. - * @memberof google.firestore.v1beta1.StructuredQuery - * @classdesc Represents a Projection. - * @implements IProjection + * Creates a plain object from a MapValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.MapValue + * @static + * @param {google.firestore.v1beta1.MapValue} message MapValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MapValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.fields = {}; + var keys2; + if (message.fields && (keys2 = Object.keys(message.fields)).length) { + object.fields = {}; + for (var j = 0; j < keys2.length; ++j) + object.fields[keys2[j]] = $root.google.firestore.v1beta1.Value.toObject(message.fields[keys2[j]], options); + } + return object; + }; + + /** + * Converts this MapValue to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.MapValue + * @instance + * @returns {Object.} JSON object + */ + MapValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return MapValue; + })(); + + v1beta1.Firestore = (function() { + + /** + * Constructs a new Firestore service. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a Firestore + * @extends $protobuf.rpc.Service * @constructor - * @param {google.firestore.v1beta1.StructuredQuery.IProjection=} [properties] Properties to set + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited */ - function Projection(properties) { - this.fields = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; + function Firestore(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); } - + + (Firestore.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Firestore; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#getDocument}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef GetDocumentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.Document} [response] Document + */ + /** - * Projection fields. - * @member {Array.} fields - * @memberof google.firestore.v1beta1.StructuredQuery.Projection + * Calls GetDocument. + * @function getDocument + * @memberof google.firestore.v1beta1.Firestore * @instance + * @param {google.firestore.v1beta1.IGetDocumentRequest} request GetDocumentRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.GetDocumentCallback} callback Node-style callback called with the error, if any, and Document + * @returns {undefined} + * @variation 1 */ - Projection.prototype.fields = $util.emptyArray; - - return Projection; + Object.defineProperty(Firestore.prototype.getDocument = function getDocument(request, callback) { + return this.rpcCall(getDocument, $root.google.firestore.v1beta1.GetDocumentRequest, $root.google.firestore.v1beta1.Document, request, callback); + }, "name", { value: "GetDocument" }); + + /** + * Calls GetDocument. + * @function getDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IGetDocumentRequest} request GetDocumentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#listDocuments}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef ListDocumentsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.ListDocumentsResponse} [response] ListDocumentsResponse + */ + + /** + * Calls ListDocuments. + * @function listDocuments + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IListDocumentsRequest} request ListDocumentsRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.ListDocumentsCallback} callback Node-style callback called with the error, if any, and ListDocumentsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.listDocuments = function listDocuments(request, callback) { + return this.rpcCall(listDocuments, $root.google.firestore.v1beta1.ListDocumentsRequest, $root.google.firestore.v1beta1.ListDocumentsResponse, request, callback); + }, "name", { value: "ListDocuments" }); + + /** + * Calls ListDocuments. + * @function listDocuments + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IListDocumentsRequest} request ListDocumentsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#createDocument}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef CreateDocumentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.Document} [response] Document + */ + + /** + * Calls CreateDocument. + * @function createDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.CreateDocumentCallback} callback Node-style callback called with the error, if any, and Document + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.createDocument = function createDocument(request, callback) { + return this.rpcCall(createDocument, $root.google.firestore.v1beta1.CreateDocumentRequest, $root.google.firestore.v1beta1.Document, request, callback); + }, "name", { value: "CreateDocument" }); + + /** + * Calls CreateDocument. + * @function createDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#updateDocument}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef UpdateDocumentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.Document} [response] Document + */ + + /** + * Calls UpdateDocument. + * @function updateDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IUpdateDocumentRequest} request UpdateDocumentRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.UpdateDocumentCallback} callback Node-style callback called with the error, if any, and Document + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.updateDocument = function updateDocument(request, callback) { + return this.rpcCall(updateDocument, $root.google.firestore.v1beta1.UpdateDocumentRequest, $root.google.firestore.v1beta1.Document, request, callback); + }, "name", { value: "UpdateDocument" }); + + /** + * Calls UpdateDocument. + * @function updateDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IUpdateDocumentRequest} request UpdateDocumentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#deleteDocument}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef DeleteDocumentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteDocument. + * @function deleteDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IDeleteDocumentRequest} request DeleteDocumentRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.DeleteDocumentCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.deleteDocument = function deleteDocument(request, callback) { + return this.rpcCall(deleteDocument, $root.google.firestore.v1beta1.DeleteDocumentRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteDocument" }); + + /** + * Calls DeleteDocument. + * @function deleteDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IDeleteDocumentRequest} request DeleteDocumentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#batchGetDocuments}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef BatchGetDocumentsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.BatchGetDocumentsResponse} [response] BatchGetDocumentsResponse + */ + + /** + * Calls BatchGetDocuments. + * @function batchGetDocuments + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IBatchGetDocumentsRequest} request BatchGetDocumentsRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.BatchGetDocumentsCallback} callback Node-style callback called with the error, if any, and BatchGetDocumentsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.batchGetDocuments = function batchGetDocuments(request, callback) { + return this.rpcCall(batchGetDocuments, $root.google.firestore.v1beta1.BatchGetDocumentsRequest, $root.google.firestore.v1beta1.BatchGetDocumentsResponse, request, callback); + }, "name", { value: "BatchGetDocuments" }); + + /** + * Calls BatchGetDocuments. + * @function batchGetDocuments + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IBatchGetDocumentsRequest} request BatchGetDocumentsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#beginTransaction}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef BeginTransactionCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.BeginTransactionResponse} [response] BeginTransactionResponse + */ + + /** + * Calls BeginTransaction. + * @function beginTransaction + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IBeginTransactionRequest} request BeginTransactionRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.BeginTransactionCallback} callback Node-style callback called with the error, if any, and BeginTransactionResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.beginTransaction = function beginTransaction(request, callback) { + return this.rpcCall(beginTransaction, $root.google.firestore.v1beta1.BeginTransactionRequest, $root.google.firestore.v1beta1.BeginTransactionResponse, request, callback); + }, "name", { value: "BeginTransaction" }); + + /** + * Calls BeginTransaction. + * @function beginTransaction + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IBeginTransactionRequest} request BeginTransactionRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#commit}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef CommitCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.CommitResponse} [response] CommitResponse + */ + + /** + * Calls Commit. + * @function commit + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.ICommitRequest} request CommitRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.CommitCallback} callback Node-style callback called with the error, if any, and CommitResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.commit = function commit(request, callback) { + return this.rpcCall(commit, $root.google.firestore.v1beta1.CommitRequest, $root.google.firestore.v1beta1.CommitResponse, request, callback); + }, "name", { value: "Commit" }); + + /** + * Calls Commit. + * @function commit + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.ICommitRequest} request CommitRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#rollback}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef RollbackCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls Rollback. + * @function rollback + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IRollbackRequest} request RollbackRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.RollbackCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.rollback = function rollback(request, callback) { + return this.rpcCall(rollback, $root.google.firestore.v1beta1.RollbackRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "Rollback" }); + + /** + * Calls Rollback. + * @function rollback + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IRollbackRequest} request RollbackRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#runQuery}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef RunQueryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.RunQueryResponse} [response] RunQueryResponse + */ + + /** + * Calls RunQuery. + * @function runQuery + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IRunQueryRequest} request RunQueryRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.RunQueryCallback} callback Node-style callback called with the error, if any, and RunQueryResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.runQuery = function runQuery(request, callback) { + return this.rpcCall(runQuery, $root.google.firestore.v1beta1.RunQueryRequest, $root.google.firestore.v1beta1.RunQueryResponse, request, callback); + }, "name", { value: "RunQuery" }); + + /** + * Calls RunQuery. + * @function runQuery + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IRunQueryRequest} request RunQueryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#write}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef WriteCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.WriteResponse} [response] WriteResponse + */ + + /** + * Calls Write. + * @function write + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IWriteRequest} request WriteRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.WriteCallback} callback Node-style callback called with the error, if any, and WriteResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.write = function write(request, callback) { + return this.rpcCall(write, $root.google.firestore.v1beta1.WriteRequest, $root.google.firestore.v1beta1.WriteResponse, request, callback); + }, "name", { value: "Write" }); + + /** + * Calls Write. + * @function write + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IWriteRequest} request WriteRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#listen}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef ListenCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.ListenResponse} [response] ListenResponse + */ + + /** + * Calls Listen. + * @function listen + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IListenRequest} request ListenRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.ListenCallback} callback Node-style callback called with the error, if any, and ListenResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.listen = function listen(request, callback) { + return this.rpcCall(listen, $root.google.firestore.v1beta1.ListenRequest, $root.google.firestore.v1beta1.ListenResponse, request, callback); + }, "name", { value: "Listen" }); + + /** + * Calls Listen. + * @function listen + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IListenRequest} request ListenRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#listCollectionIds}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef ListCollectionIdsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.ListCollectionIdsResponse} [response] ListCollectionIdsResponse + */ + + /** + * Calls ListCollectionIds. + * @function listCollectionIds + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IListCollectionIdsRequest} request ListCollectionIdsRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.ListCollectionIdsCallback} callback Node-style callback called with the error, if any, and ListCollectionIdsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.listCollectionIds = function listCollectionIds(request, callback) { + return this.rpcCall(listCollectionIds, $root.google.firestore.v1beta1.ListCollectionIdsRequest, $root.google.firestore.v1beta1.ListCollectionIdsResponse, request, callback); + }, "name", { value: "ListCollectionIds" }); + + /** + * Calls ListCollectionIds. + * @function listCollectionIds + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IListCollectionIdsRequest} request ListCollectionIdsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return Firestore; })(); - - /** - * Direction enum. - * @name google.firestore.v1beta1.StructuredQuery.Direction - * @enum {number} - * @property {string} DIRECTION_UNSPECIFIED=DIRECTION_UNSPECIFIED DIRECTION_UNSPECIFIED value - * @property {string} ASCENDING=ASCENDING ASCENDING value - * @property {string} DESCENDING=DESCENDING DESCENDING value - */ - StructuredQuery.Direction = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "DIRECTION_UNSPECIFIED"] = "DIRECTION_UNSPECIFIED"; - values[valuesById[1] = "ASCENDING"] = "ASCENDING"; - values[valuesById[2] = "DESCENDING"] = "DESCENDING"; - return values; + + v1beta1.GetDocumentRequest = (function() { + + /** + * Properties of a GetDocumentRequest. + * @memberof google.firestore.v1beta1 + * @interface IGetDocumentRequest + * @property {string|null} [name] GetDocumentRequest name + * @property {google.firestore.v1beta1.IDocumentMask|null} [mask] GetDocumentRequest mask + * @property {Uint8Array|null} [transaction] GetDocumentRequest transaction + * @property {google.protobuf.ITimestamp|null} [readTime] GetDocumentRequest readTime + */ + + /** + * Constructs a new GetDocumentRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a GetDocumentRequest. + * @implements IGetDocumentRequest + * @constructor + * @param {google.firestore.v1beta1.IGetDocumentRequest=} [properties] Properties to set + */ + function GetDocumentRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetDocumentRequest name. + * @member {string} name + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @instance + */ + GetDocumentRequest.prototype.name = ""; + + /** + * GetDocumentRequest mask. + * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} mask + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @instance + */ + GetDocumentRequest.prototype.mask = null; + + /** + * GetDocumentRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @instance + */ + GetDocumentRequest.prototype.transaction = $util.newBuffer([]); + + /** + * GetDocumentRequest readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @instance + */ + GetDocumentRequest.prototype.readTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GetDocumentRequest consistencySelector. + * @member {"transaction"|"readTime"|undefined} consistencySelector + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @instance + */ + Object.defineProperty(GetDocumentRequest.prototype, "consistencySelector", { + get: $util.oneOfGetter($oneOfFields = ["transaction", "readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a GetDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.GetDocumentRequest} GetDocumentRequest + */ + GetDocumentRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.GetDocumentRequest) + return object; + var message = new $root.google.firestore.v1beta1.GetDocumentRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.mask != null) { + if (typeof object.mask !== "object") + throw TypeError(".google.firestore.v1beta1.GetDocumentRequest.mask: object expected"); + message.mask = $root.google.firestore.v1beta1.DocumentMask.fromObject(object.mask); + } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1beta1.GetDocumentRequest.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a GetDocumentRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @static + * @param {google.firestore.v1beta1.GetDocumentRequest} message GetDocumentRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDocumentRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.mask = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.mask != null && message.hasOwnProperty("mask")) + object.mask = $root.google.firestore.v1beta1.DocumentMask.toObject(message.mask, options); + if (message.transaction != null && message.hasOwnProperty("transaction")) { + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (options.oneofs) + object.consistencySelector = "transaction"; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (options.oneofs) + object.consistencySelector = "readTime"; + } + return object; + }; + + /** + * Converts this GetDocumentRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.GetDocumentRequest + * @instance + * @returns {Object.} JSON object + */ + GetDocumentRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetDocumentRequest; })(); - - return StructuredQuery; - })(); - - v1beta1.Cursor = (function() { - - /** - * Properties of a Cursor. - * @memberof google.firestore.v1beta1 - * @interface ICursor - * @property {Array.|null} [values] Cursor values - * @property {boolean|null} [before] Cursor before - */ - - /** - * Constructs a new Cursor. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a Cursor. - * @implements ICursor - * @constructor - * @param {google.firestore.v1beta1.ICursor=} [properties] Properties to set - */ - function Cursor(properties) { - this.values = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Cursor values. - * @member {Array.} values - * @memberof google.firestore.v1beta1.Cursor - * @instance - */ - Cursor.prototype.values = $util.emptyArray; - - /** - * Cursor before. - * @member {boolean} before - * @memberof google.firestore.v1beta1.Cursor - * @instance - */ - Cursor.prototype.before = false; - - return Cursor; - })(); - - v1beta1.Write = (function() { - - /** - * Properties of a Write. - * @memberof google.firestore.v1beta1 - * @interface IWrite - * @property {google.firestore.v1beta1.IDocument|null} [update] Write update - * @property {string|null} ["delete"] Write delete - * @property {google.firestore.v1beta1.IDocumentTransform|null} [transform] Write transform - * @property {google.firestore.v1beta1.IDocumentMask|null} [updateMask] Write updateMask - * @property {google.firestore.v1beta1.IPrecondition|null} [currentDocument] Write currentDocument - */ - - /** - * Constructs a new Write. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a Write. - * @implements IWrite - * @constructor - * @param {google.firestore.v1beta1.IWrite=} [properties] Properties to set - */ - function Write(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Write update. - * @member {google.firestore.v1beta1.IDocument|null|undefined} update - * @memberof google.firestore.v1beta1.Write - * @instance - */ - Write.prototype.update = null; - - /** - * Write delete. - * @member {string} delete - * @memberof google.firestore.v1beta1.Write - * @instance - */ - Write.prototype["delete"] = ""; - - /** - * Write transform. - * @member {google.firestore.v1beta1.IDocumentTransform|null|undefined} transform - * @memberof google.firestore.v1beta1.Write - * @instance - */ - Write.prototype.transform = null; - - /** - * Write updateMask. - * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} updateMask - * @memberof google.firestore.v1beta1.Write - * @instance - */ - Write.prototype.updateMask = null; - - /** - * Write currentDocument. - * @member {google.firestore.v1beta1.IPrecondition|null|undefined} currentDocument - * @memberof google.firestore.v1beta1.Write - * @instance - */ - Write.prototype.currentDocument = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Write operation. - * @member {"update"|"delete"|"transform"|undefined} operation - * @memberof google.firestore.v1beta1.Write - * @instance - */ - Object.defineProperty(Write.prototype, "operation", { - get: $util.oneOfGetter($oneOfFields = ["update", "delete", "transform"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return Write; - })(); - - v1beta1.DocumentTransform = (function() { - - /** - * Properties of a DocumentTransform. - * @memberof google.firestore.v1beta1 - * @interface IDocumentTransform - * @property {string|null} [document] DocumentTransform document - * @property {Array.|null} [fieldTransforms] DocumentTransform fieldTransforms - */ - - /** - * Constructs a new DocumentTransform. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a DocumentTransform. - * @implements IDocumentTransform - * @constructor - * @param {google.firestore.v1beta1.IDocumentTransform=} [properties] Properties to set - */ - function DocumentTransform(properties) { - this.fieldTransforms = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DocumentTransform document. - * @member {string} document - * @memberof google.firestore.v1beta1.DocumentTransform - * @instance - */ - DocumentTransform.prototype.document = ""; - - /** - * DocumentTransform fieldTransforms. - * @member {Array.} fieldTransforms - * @memberof google.firestore.v1beta1.DocumentTransform - * @instance - */ - DocumentTransform.prototype.fieldTransforms = $util.emptyArray; - - DocumentTransform.FieldTransform = (function() { - + + v1beta1.ListDocumentsRequest = (function() { + /** - * Properties of a FieldTransform. - * @memberof google.firestore.v1beta1.DocumentTransform - * @interface IFieldTransform - * @property {string|null} [fieldPath] FieldTransform fieldPath - * @property {google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue|null} [setToServerValue] FieldTransform setToServerValue - * @property {google.firestore.v1beta1.IValue|null} [increment] FieldTransform increment - * @property {google.firestore.v1beta1.IValue|null} [maximum] FieldTransform maximum - * @property {google.firestore.v1beta1.IValue|null} [minimum] FieldTransform minimum - * @property {google.firestore.v1beta1.IArrayValue|null} [appendMissingElements] FieldTransform appendMissingElements - * @property {google.firestore.v1beta1.IArrayValue|null} [removeAllFromArray] FieldTransform removeAllFromArray + * Properties of a ListDocumentsRequest. + * @memberof google.firestore.v1beta1 + * @interface IListDocumentsRequest + * @property {string|null} [parent] ListDocumentsRequest parent + * @property {string|null} [collectionId] ListDocumentsRequest collectionId + * @property {number|null} [pageSize] ListDocumentsRequest pageSize + * @property {string|null} [pageToken] ListDocumentsRequest pageToken + * @property {string|null} [orderBy] ListDocumentsRequest orderBy + * @property {google.firestore.v1beta1.IDocumentMask|null} [mask] ListDocumentsRequest mask + * @property {Uint8Array|null} [transaction] ListDocumentsRequest transaction + * @property {google.protobuf.ITimestamp|null} [readTime] ListDocumentsRequest readTime + * @property {boolean|null} [showMissing] ListDocumentsRequest showMissing */ - + /** - * Constructs a new FieldTransform. - * @memberof google.firestore.v1beta1.DocumentTransform - * @classdesc Represents a FieldTransform. - * @implements IFieldTransform + * Constructs a new ListDocumentsRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a ListDocumentsRequest. + * @implements IListDocumentsRequest * @constructor - * @param {google.firestore.v1beta1.DocumentTransform.IFieldTransform=} [properties] Properties to set + * @param {google.firestore.v1beta1.IListDocumentsRequest=} [properties] Properties to set */ - function FieldTransform(properties) { + function ListDocumentsRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; } - + + /** + * ListDocumentsRequest parent. + * @member {string} parent + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.parent = ""; + /** - * FieldTransform fieldPath. - * @member {string} fieldPath - * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * ListDocumentsRequest collectionId. + * @member {string} collectionId + * @memberof google.firestore.v1beta1.ListDocumentsRequest * @instance */ - FieldTransform.prototype.fieldPath = ""; - + ListDocumentsRequest.prototype.collectionId = ""; + /** - * FieldTransform setToServerValue. - * @member {google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue} setToServerValue - * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * ListDocumentsRequest pageSize. + * @member {number} pageSize + * @memberof google.firestore.v1beta1.ListDocumentsRequest * @instance */ - FieldTransform.prototype.setToServerValue = 0; - + ListDocumentsRequest.prototype.pageSize = 0; + /** - * FieldTransform increment. - * @member {google.firestore.v1beta1.IValue|null|undefined} increment - * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * ListDocumentsRequest pageToken. + * @member {string} pageToken + * @memberof google.firestore.v1beta1.ListDocumentsRequest * @instance */ - FieldTransform.prototype.increment = null; - + ListDocumentsRequest.prototype.pageToken = ""; + /** - * FieldTransform maximum. - * @member {google.firestore.v1beta1.IValue|null|undefined} maximum - * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * ListDocumentsRequest orderBy. + * @member {string} orderBy + * @memberof google.firestore.v1beta1.ListDocumentsRequest * @instance */ - FieldTransform.prototype.maximum = null; - + ListDocumentsRequest.prototype.orderBy = ""; + /** - * FieldTransform minimum. - * @member {google.firestore.v1beta1.IValue|null|undefined} minimum - * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * ListDocumentsRequest mask. + * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} mask + * @memberof google.firestore.v1beta1.ListDocumentsRequest * @instance */ - FieldTransform.prototype.minimum = null; - + ListDocumentsRequest.prototype.mask = null; + /** - * FieldTransform appendMissingElements. - * @member {google.firestore.v1beta1.IArrayValue|null|undefined} appendMissingElements - * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * ListDocumentsRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.ListDocumentsRequest * @instance */ - FieldTransform.prototype.appendMissingElements = null; - + ListDocumentsRequest.prototype.transaction = $util.newBuffer([]); + /** - * FieldTransform removeAllFromArray. - * @member {google.firestore.v1beta1.IArrayValue|null|undefined} removeAllFromArray - * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * ListDocumentsRequest readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.ListDocumentsRequest * @instance */ - FieldTransform.prototype.removeAllFromArray = null; - + ListDocumentsRequest.prototype.readTime = null; + + /** + * ListDocumentsRequest showMissing. + * @member {boolean} showMissing + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @instance + */ + ListDocumentsRequest.prototype.showMissing = false; + // OneOf field names bound to virtual getters and setters var $oneOfFields; - + /** - * FieldTransform transformType. - * @member {"setToServerValue"|"increment"|"maximum"|"minimum"|"appendMissingElements"|"removeAllFromArray"|undefined} transformType - * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * ListDocumentsRequest consistencySelector. + * @member {"transaction"|"readTime"|undefined} consistencySelector + * @memberof google.firestore.v1beta1.ListDocumentsRequest * @instance */ - Object.defineProperty(FieldTransform.prototype, "transformType", { - get: $util.oneOfGetter($oneOfFields = ["setToServerValue", "increment", "maximum", "minimum", "appendMissingElements", "removeAllFromArray"]), + Object.defineProperty(ListDocumentsRequest.prototype, "consistencySelector", { + get: $util.oneOfGetter($oneOfFields = ["transaction", "readTime"]), set: $util.oneOfSetter($oneOfFields) }); - + /** - * ServerValue enum. - * @name google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue - * @enum {number} - * @property {string} SERVER_VALUE_UNSPECIFIED=SERVER_VALUE_UNSPECIFIED SERVER_VALUE_UNSPECIFIED value - * @property {string} REQUEST_TIME=REQUEST_TIME REQUEST_TIME value + * Creates a ListDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.ListDocumentsRequest} ListDocumentsRequest */ - FieldTransform.ServerValue = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "SERVER_VALUE_UNSPECIFIED"] = "SERVER_VALUE_UNSPECIFIED"; - values[valuesById[1] = "REQUEST_TIME"] = "REQUEST_TIME"; - return values; - })(); - - return FieldTransform; + ListDocumentsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.ListDocumentsRequest) + return object; + var message = new $root.google.firestore.v1beta1.ListDocumentsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.collectionId != null) + message.collectionId = String(object.collectionId); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.orderBy != null) + message.orderBy = String(object.orderBy); + if (object.mask != null) { + if (typeof object.mask !== "object") + throw TypeError(".google.firestore.v1beta1.ListDocumentsRequest.mask: object expected"); + message.mask = $root.google.firestore.v1beta1.DocumentMask.fromObject(object.mask); + } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1beta1.ListDocumentsRequest.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + if (object.showMissing != null) + message.showMissing = Boolean(object.showMissing); + return message; + }; + + /** + * Creates a plain object from a ListDocumentsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @static + * @param {google.firestore.v1beta1.ListDocumentsRequest} message ListDocumentsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListDocumentsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.collectionId = ""; + object.pageSize = 0; + object.pageToken = ""; + object.orderBy = ""; + object.mask = null; + object.showMissing = false; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.collectionId != null && message.hasOwnProperty("collectionId")) + object.collectionId = message.collectionId; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + object.orderBy = message.orderBy; + if (message.mask != null && message.hasOwnProperty("mask")) + object.mask = $root.google.firestore.v1beta1.DocumentMask.toObject(message.mask, options); + if (message.transaction != null && message.hasOwnProperty("transaction")) { + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (options.oneofs) + object.consistencySelector = "transaction"; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (options.oneofs) + object.consistencySelector = "readTime"; + } + if (message.showMissing != null && message.hasOwnProperty("showMissing")) + object.showMissing = message.showMissing; + return object; + }; + + /** + * Converts this ListDocumentsRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.ListDocumentsRequest + * @instance + * @returns {Object.} JSON object + */ + ListDocumentsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListDocumentsRequest; })(); - - return DocumentTransform; - })(); - - v1beta1.WriteResult = (function() { - - /** - * Properties of a WriteResult. - * @memberof google.firestore.v1beta1 - * @interface IWriteResult - * @property {google.protobuf.ITimestamp|null} [updateTime] WriteResult updateTime - * @property {Array.|null} [transformResults] WriteResult transformResults - */ - - /** - * Constructs a new WriteResult. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a WriteResult. - * @implements IWriteResult - * @constructor - * @param {google.firestore.v1beta1.IWriteResult=} [properties] Properties to set - */ - function WriteResult(properties) { - this.transformResults = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * WriteResult updateTime. - * @member {google.protobuf.ITimestamp|null|undefined} updateTime - * @memberof google.firestore.v1beta1.WriteResult - * @instance - */ - WriteResult.prototype.updateTime = null; - - /** - * WriteResult transformResults. - * @member {Array.} transformResults - * @memberof google.firestore.v1beta1.WriteResult - * @instance - */ - WriteResult.prototype.transformResults = $util.emptyArray; - - return WriteResult; - })(); - - v1beta1.DocumentChange = (function() { - - /** - * Properties of a DocumentChange. - * @memberof google.firestore.v1beta1 - * @interface IDocumentChange - * @property {google.firestore.v1beta1.IDocument|null} [document] DocumentChange document - * @property {Array.|null} [targetIds] DocumentChange targetIds - * @property {Array.|null} [removedTargetIds] DocumentChange removedTargetIds - */ - - /** - * Constructs a new DocumentChange. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a DocumentChange. - * @implements IDocumentChange - * @constructor - * @param {google.firestore.v1beta1.IDocumentChange=} [properties] Properties to set - */ - function DocumentChange(properties) { - this.targetIds = []; - this.removedTargetIds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DocumentChange document. - * @member {google.firestore.v1beta1.IDocument|null|undefined} document - * @memberof google.firestore.v1beta1.DocumentChange - * @instance - */ - DocumentChange.prototype.document = null; - - /** - * DocumentChange targetIds. - * @member {Array.} targetIds - * @memberof google.firestore.v1beta1.DocumentChange - * @instance - */ - DocumentChange.prototype.targetIds = $util.emptyArray; - - /** - * DocumentChange removedTargetIds. - * @member {Array.} removedTargetIds - * @memberof google.firestore.v1beta1.DocumentChange - * @instance - */ - DocumentChange.prototype.removedTargetIds = $util.emptyArray; - - return DocumentChange; - })(); - - v1beta1.DocumentDelete = (function() { - - /** - * Properties of a DocumentDelete. - * @memberof google.firestore.v1beta1 - * @interface IDocumentDelete - * @property {string|null} [document] DocumentDelete document - * @property {Array.|null} [removedTargetIds] DocumentDelete removedTargetIds - * @property {google.protobuf.ITimestamp|null} [readTime] DocumentDelete readTime - */ - - /** - * Constructs a new DocumentDelete. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a DocumentDelete. - * @implements IDocumentDelete - * @constructor - * @param {google.firestore.v1beta1.IDocumentDelete=} [properties] Properties to set - */ - function DocumentDelete(properties) { - this.removedTargetIds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DocumentDelete document. - * @member {string} document - * @memberof google.firestore.v1beta1.DocumentDelete - * @instance - */ - DocumentDelete.prototype.document = ""; - - /** - * DocumentDelete removedTargetIds. - * @member {Array.} removedTargetIds - * @memberof google.firestore.v1beta1.DocumentDelete - * @instance - */ - DocumentDelete.prototype.removedTargetIds = $util.emptyArray; - - /** - * DocumentDelete readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1beta1.DocumentDelete - * @instance - */ - DocumentDelete.prototype.readTime = null; - - return DocumentDelete; - })(); - - v1beta1.DocumentRemove = (function() { - - /** - * Properties of a DocumentRemove. - * @memberof google.firestore.v1beta1 - * @interface IDocumentRemove - * @property {string|null} [document] DocumentRemove document - * @property {Array.|null} [removedTargetIds] DocumentRemove removedTargetIds - * @property {google.protobuf.ITimestamp|null} [readTime] DocumentRemove readTime - */ - - /** - * Constructs a new DocumentRemove. - * @memberof google.firestore.v1beta1 - * @classdesc Represents a DocumentRemove. - * @implements IDocumentRemove - * @constructor - * @param {google.firestore.v1beta1.IDocumentRemove=} [properties] Properties to set - */ - function DocumentRemove(properties) { - this.removedTargetIds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DocumentRemove document. - * @member {string} document - * @memberof google.firestore.v1beta1.DocumentRemove - * @instance - */ - DocumentRemove.prototype.document = ""; - - /** - * DocumentRemove removedTargetIds. - * @member {Array.} removedTargetIds - * @memberof google.firestore.v1beta1.DocumentRemove - * @instance - */ - DocumentRemove.prototype.removedTargetIds = $util.emptyArray; - - /** - * DocumentRemove readTime. - * @member {google.protobuf.ITimestamp|null|undefined} readTime - * @memberof google.firestore.v1beta1.DocumentRemove - * @instance - */ - DocumentRemove.prototype.readTime = null; - - return DocumentRemove; - })(); - - v1beta1.ExistenceFilter = (function() { - - /** - * Properties of an ExistenceFilter. - * @memberof google.firestore.v1beta1 - * @interface IExistenceFilter - * @property {number|null} [targetId] ExistenceFilter targetId - * @property {number|null} [count] ExistenceFilter count - */ - - /** - * Constructs a new ExistenceFilter. - * @memberof google.firestore.v1beta1 - * @classdesc Represents an ExistenceFilter. - * @implements IExistenceFilter - * @constructor - * @param {google.firestore.v1beta1.IExistenceFilter=} [properties] Properties to set - */ - function ExistenceFilter(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ExistenceFilter targetId. - * @member {number} targetId - * @memberof google.firestore.v1beta1.ExistenceFilter - * @instance - */ - ExistenceFilter.prototype.targetId = 0; - - /** - * ExistenceFilter count. - * @member {number} count - * @memberof google.firestore.v1beta1.ExistenceFilter - * @instance - */ - ExistenceFilter.prototype.count = 0; - - return ExistenceFilter; - })(); - - return v1beta1; - })(); - - return firestore; - })(); - - google.api = (function() { - - /** - * Namespace api. - * @memberof google - * @namespace - */ - var api = {}; - - api.Http = (function() { - - /** - * Properties of a Http. - * @memberof google.api - * @interface IHttp - * @property {Array.|null} [rules] Http rules - */ - - /** - * Constructs a new Http. - * @memberof google.api - * @classdesc Represents a Http. - * @implements IHttp - * @constructor - * @param {google.api.IHttp=} [properties] Properties to set - */ - function Http(properties) { - this.rules = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Http rules. - * @member {Array.} rules - * @memberof google.api.Http - * @instance - */ - Http.prototype.rules = $util.emptyArray; - - return Http; - })(); - - api.HttpRule = (function() { - - /** - * Properties of a HttpRule. - * @memberof google.api - * @interface IHttpRule - * @property {string|null} [get] HttpRule get - * @property {string|null} [put] HttpRule put - * @property {string|null} [post] HttpRule post - * @property {string|null} ["delete"] HttpRule delete - * @property {string|null} [patch] HttpRule patch - * @property {google.api.ICustomHttpPattern|null} [custom] HttpRule custom - * @property {string|null} [selector] HttpRule selector - * @property {string|null} [body] HttpRule body - * @property {Array.|null} [additionalBindings] HttpRule additionalBindings - */ - - /** - * Constructs a new HttpRule. - * @memberof google.api - * @classdesc Represents a HttpRule. - * @implements IHttpRule - * @constructor - * @param {google.api.IHttpRule=} [properties] Properties to set - */ - function HttpRule(properties) { - this.additionalBindings = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * HttpRule get. - * @member {string} get - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.get = ""; - - /** - * HttpRule put. - * @member {string} put - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.put = ""; - - /** - * HttpRule post. - * @member {string} post - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.post = ""; - - /** - * HttpRule delete. - * @member {string} delete - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype["delete"] = ""; - - /** - * HttpRule patch. - * @member {string} patch - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.patch = ""; - - /** - * HttpRule custom. - * @member {google.api.ICustomHttpPattern|null|undefined} custom - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.custom = null; - - /** - * HttpRule selector. - * @member {string} selector - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.selector = ""; - - /** - * HttpRule body. - * @member {string} body - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.body = ""; - - /** - * HttpRule additionalBindings. - * @member {Array.} additionalBindings - * @memberof google.api.HttpRule - * @instance - */ - HttpRule.prototype.additionalBindings = $util.emptyArray; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * HttpRule pattern. - * @member {"get"|"put"|"post"|"delete"|"patch"|"custom"|undefined} pattern - * @memberof google.api.HttpRule - * @instance - */ - Object.defineProperty(HttpRule.prototype, "pattern", { - get: $util.oneOfGetter($oneOfFields = ["get", "put", "post", "delete", "patch", "custom"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return HttpRule; - })(); - - api.CustomHttpPattern = (function() { - - /** - * Properties of a CustomHttpPattern. - * @memberof google.api - * @interface ICustomHttpPattern - * @property {string|null} [kind] CustomHttpPattern kind - * @property {string|null} [path] CustomHttpPattern path - */ - - /** - * Constructs a new CustomHttpPattern. - * @memberof google.api - * @classdesc Represents a CustomHttpPattern. - * @implements ICustomHttpPattern - * @constructor - * @param {google.api.ICustomHttpPattern=} [properties] Properties to set - */ - function CustomHttpPattern(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * CustomHttpPattern kind. - * @member {string} kind - * @memberof google.api.CustomHttpPattern - * @instance - */ - CustomHttpPattern.prototype.kind = ""; - - /** - * CustomHttpPattern path. - * @member {string} path - * @memberof google.api.CustomHttpPattern - * @instance - */ - CustomHttpPattern.prototype.path = ""; - - return CustomHttpPattern; - })(); - - /** - * FieldBehavior enum. - * @name google.api.FieldBehavior - * @enum {number} - * @property {string} FIELD_BEHAVIOR_UNSPECIFIED=FIELD_BEHAVIOR_UNSPECIFIED FIELD_BEHAVIOR_UNSPECIFIED value - * @property {string} OPTIONAL=OPTIONAL OPTIONAL value - * @property {string} REQUIRED=REQUIRED REQUIRED value - * @property {string} OUTPUT_ONLY=OUTPUT_ONLY OUTPUT_ONLY value - * @property {string} INPUT_ONLY=INPUT_ONLY INPUT_ONLY value - * @property {string} IMMUTABLE=IMMUTABLE IMMUTABLE value - */ - api.FieldBehavior = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "FIELD_BEHAVIOR_UNSPECIFIED"] = "FIELD_BEHAVIOR_UNSPECIFIED"; - values[valuesById[1] = "OPTIONAL"] = "OPTIONAL"; - values[valuesById[2] = "REQUIRED"] = "REQUIRED"; - values[valuesById[3] = "OUTPUT_ONLY"] = "OUTPUT_ONLY"; - values[valuesById[4] = "INPUT_ONLY"] = "INPUT_ONLY"; - values[valuesById[5] = "IMMUTABLE"] = "IMMUTABLE"; - return values; - })(); - - api.ResourceDescriptor = (function() { - - /** - * Properties of a ResourceDescriptor. - * @memberof google.api - * @interface IResourceDescriptor - * @property {string|null} [type] ResourceDescriptor type - * @property {Array.|null} [pattern] ResourceDescriptor pattern - * @property {string|null} [nameField] ResourceDescriptor nameField - * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history - * @property {string|null} [plural] ResourceDescriptor plural - * @property {string|null} [singular] ResourceDescriptor singular - */ - - /** - * Constructs a new ResourceDescriptor. - * @memberof google.api - * @classdesc Represents a ResourceDescriptor. - * @implements IResourceDescriptor - * @constructor - * @param {google.api.IResourceDescriptor=} [properties] Properties to set - */ - function ResourceDescriptor(properties) { - this.pattern = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ResourceDescriptor type. - * @member {string} type - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.type = ""; - - /** - * ResourceDescriptor pattern. - * @member {Array.} pattern - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.pattern = $util.emptyArray; - - /** - * ResourceDescriptor nameField. - * @member {string} nameField - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.nameField = ""; - - /** - * ResourceDescriptor history. - * @member {google.api.ResourceDescriptor.History} history - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.history = 0; - - /** - * ResourceDescriptor plural. - * @member {string} plural - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.plural = ""; - - /** - * ResourceDescriptor singular. - * @member {string} singular - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.singular = ""; - - /** - * History enum. - * @name google.api.ResourceDescriptor.History - * @enum {number} - * @property {string} HISTORY_UNSPECIFIED=HISTORY_UNSPECIFIED HISTORY_UNSPECIFIED value - * @property {string} ORIGINALLY_SINGLE_PATTERN=ORIGINALLY_SINGLE_PATTERN ORIGINALLY_SINGLE_PATTERN value - * @property {string} FUTURE_MULTI_PATTERN=FUTURE_MULTI_PATTERN FUTURE_MULTI_PATTERN value - */ - ResourceDescriptor.History = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "HISTORY_UNSPECIFIED"] = "HISTORY_UNSPECIFIED"; - values[valuesById[1] = "ORIGINALLY_SINGLE_PATTERN"] = "ORIGINALLY_SINGLE_PATTERN"; - values[valuesById[2] = "FUTURE_MULTI_PATTERN"] = "FUTURE_MULTI_PATTERN"; - return values; - })(); - - return ResourceDescriptor; - })(); - - api.ResourceReference = (function() { - - /** - * Properties of a ResourceReference. - * @memberof google.api - * @interface IResourceReference - * @property {string|null} [type] ResourceReference type - * @property {string|null} [childType] ResourceReference childType - */ - - /** - * Constructs a new ResourceReference. - * @memberof google.api - * @classdesc Represents a ResourceReference. - * @implements IResourceReference - * @constructor - * @param {google.api.IResourceReference=} [properties] Properties to set - */ - function ResourceReference(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ResourceReference type. - * @member {string} type - * @memberof google.api.ResourceReference - * @instance - */ - ResourceReference.prototype.type = ""; - - /** - * ResourceReference childType. - * @member {string} childType - * @memberof google.api.ResourceReference - * @instance - */ - ResourceReference.prototype.childType = ""; - - return ResourceReference; - })(); - - return api; - })(); - - google.type = (function() { - - /** - * Namespace type. - * @memberof google - * @namespace - */ - var type = {}; - - type.LatLng = (function() { - - /** - * Properties of a LatLng. - * @memberof google.type - * @interface ILatLng - * @property {number|null} [latitude] LatLng latitude - * @property {number|null} [longitude] LatLng longitude - */ - - /** - * Constructs a new LatLng. - * @memberof google.type - * @classdesc Represents a LatLng. - * @implements ILatLng - * @constructor - * @param {google.type.ILatLng=} [properties] Properties to set - */ - function LatLng(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * LatLng latitude. - * @member {number} latitude - * @memberof google.type.LatLng - * @instance - */ - LatLng.prototype.latitude = 0; - - /** - * LatLng longitude. - * @member {number} longitude - * @memberof google.type.LatLng - * @instance - */ - LatLng.prototype.longitude = 0; - - return LatLng; - })(); - - return type; - })(); - - google.rpc = (function() { - - /** - * Namespace rpc. - * @memberof google - * @namespace - */ - var rpc = {}; - - rpc.Status = (function() { - - /** - * Properties of a Status. - * @memberof google.rpc - * @interface IStatus - * @property {number|null} [code] Status code - * @property {string|null} [message] Status message - * @property {Array.|null} [details] Status details - */ - - /** - * Constructs a new Status. - * @memberof google.rpc - * @classdesc Represents a Status. - * @implements IStatus - * @constructor - * @param {google.rpc.IStatus=} [properties] Properties to set - */ - function Status(properties) { - this.details = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Status code. - * @member {number} code - * @memberof google.rpc.Status - * @instance - */ - Status.prototype.code = 0; - - /** - * Status message. - * @member {string} message - * @memberof google.rpc.Status - * @instance - */ - Status.prototype.message = ""; - - /** - * Status details. - * @member {Array.} details - * @memberof google.rpc.Status - * @instance - */ - Status.prototype.details = $util.emptyArray; - - return Status; - })(); - - return rpc; - })(); - - google.longrunning = (function() { - - /** - * Namespace longrunning. - * @memberof google - * @namespace - */ - var longrunning = {}; - - longrunning.Operations = (function() { - - /** - * Constructs a new Operations service. - * @memberof google.longrunning - * @classdesc Represents an Operations - * @extends $protobuf.rpc.Service - * @constructor - * @param {$protobuf.RPCImpl} rpcImpl RPC implementation - * @param {boolean} [requestDelimited=false] Whether requests are length-delimited - * @param {boolean} [responseDelimited=false] Whether responses are length-delimited - */ - function Operations(rpcImpl, requestDelimited, responseDelimited) { - $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); - } - - (Operations.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Operations; - - /** - * Callback as used by {@link google.longrunning.Operations#listOperations}. - * @memberof google.longrunning.Operations - * @typedef ListOperationsCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.longrunning.ListOperationsResponse} [response] ListOperationsResponse - */ - - /** - * Calls ListOperations. - * @function listOperations - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object - * @param {google.longrunning.Operations.ListOperationsCallback} callback Node-style callback called with the error, if any, and ListOperationsResponse - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Operations.prototype.listOperations = function listOperations(request, callback) { - return this.rpcCall(listOperations, $root.google.longrunning.ListOperationsRequest, $root.google.longrunning.ListOperationsResponse, request, callback); - }, "name", { value: "ListOperations" }); - - /** - * Calls ListOperations. - * @function listOperations - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.longrunning.Operations#getOperation}. - * @memberof google.longrunning.Operations - * @typedef GetOperationCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.longrunning.Operation} [response] Operation - */ - - /** - * Calls GetOperation. - * @function getOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object - * @param {google.longrunning.Operations.GetOperationCallback} callback Node-style callback called with the error, if any, and Operation - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Operations.prototype.getOperation = function getOperation(request, callback) { - return this.rpcCall(getOperation, $root.google.longrunning.GetOperationRequest, $root.google.longrunning.Operation, request, callback); - }, "name", { value: "GetOperation" }); - - /** - * Calls GetOperation. - * @function getOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.longrunning.Operations#deleteOperation}. - * @memberof google.longrunning.Operations - * @typedef DeleteOperationCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.protobuf.Empty} [response] Empty - */ - - /** - * Calls DeleteOperation. - * @function deleteOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object - * @param {google.longrunning.Operations.DeleteOperationCallback} callback Node-style callback called with the error, if any, and Empty - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Operations.prototype.deleteOperation = function deleteOperation(request, callback) { - return this.rpcCall(deleteOperation, $root.google.longrunning.DeleteOperationRequest, $root.google.protobuf.Empty, request, callback); - }, "name", { value: "DeleteOperation" }); - - /** - * Calls DeleteOperation. - * @function deleteOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.longrunning.Operations#cancelOperation}. - * @memberof google.longrunning.Operations - * @typedef CancelOperationCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.protobuf.Empty} [response] Empty - */ - - /** - * Calls CancelOperation. - * @function cancelOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object - * @param {google.longrunning.Operations.CancelOperationCallback} callback Node-style callback called with the error, if any, and Empty - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Operations.prototype.cancelOperation = function cancelOperation(request, callback) { - return this.rpcCall(cancelOperation, $root.google.longrunning.CancelOperationRequest, $root.google.protobuf.Empty, request, callback); - }, "name", { value: "CancelOperation" }); - - /** - * Calls CancelOperation. - * @function cancelOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link google.longrunning.Operations#waitOperation}. - * @memberof google.longrunning.Operations - * @typedef WaitOperationCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.longrunning.Operation} [response] Operation - */ - - /** - * Calls WaitOperation. - * @function waitOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object - * @param {google.longrunning.Operations.WaitOperationCallback} callback Node-style callback called with the error, if any, and Operation - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Operations.prototype.waitOperation = function waitOperation(request, callback) { - return this.rpcCall(waitOperation, $root.google.longrunning.WaitOperationRequest, $root.google.longrunning.Operation, request, callback); - }, "name", { value: "WaitOperation" }); - - /** - * Calls WaitOperation. - * @function waitOperation - * @memberof google.longrunning.Operations - * @instance - * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - return Operations; - })(); - - longrunning.Operation = (function() { - - /** - * Properties of an Operation. - * @memberof google.longrunning - * @interface IOperation - * @property {string|null} [name] Operation name - * @property {google.protobuf.IAny|null} [metadata] Operation metadata - * @property {boolean|null} [done] Operation done - * @property {google.rpc.IStatus|null} [error] Operation error - * @property {google.protobuf.IAny|null} [response] Operation response - */ - - /** - * Constructs a new Operation. - * @memberof google.longrunning - * @classdesc Represents an Operation. - * @implements IOperation - * @constructor - * @param {google.longrunning.IOperation=} [properties] Properties to set - */ - function Operation(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Operation name. - * @member {string} name - * @memberof google.longrunning.Operation - * @instance - */ - Operation.prototype.name = ""; - - /** - * Operation metadata. - * @member {google.protobuf.IAny|null|undefined} metadata - * @memberof google.longrunning.Operation - * @instance - */ - Operation.prototype.metadata = null; - - /** - * Operation done. - * @member {boolean} done - * @memberof google.longrunning.Operation - * @instance - */ - Operation.prototype.done = false; - - /** - * Operation error. - * @member {google.rpc.IStatus|null|undefined} error - * @memberof google.longrunning.Operation - * @instance - */ - Operation.prototype.error = null; - - /** - * Operation response. - * @member {google.protobuf.IAny|null|undefined} response - * @memberof google.longrunning.Operation - * @instance - */ - Operation.prototype.response = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Operation result. - * @member {"error"|"response"|undefined} result - * @memberof google.longrunning.Operation - * @instance - */ - Object.defineProperty(Operation.prototype, "result", { - get: $util.oneOfGetter($oneOfFields = ["error", "response"]), - set: $util.oneOfSetter($oneOfFields) - }); - - return Operation; - })(); - - longrunning.GetOperationRequest = (function() { - - /** - * Properties of a GetOperationRequest. - * @memberof google.longrunning - * @interface IGetOperationRequest - * @property {string|null} [name] GetOperationRequest name - */ - - /** - * Constructs a new GetOperationRequest. - * @memberof google.longrunning - * @classdesc Represents a GetOperationRequest. - * @implements IGetOperationRequest - * @constructor - * @param {google.longrunning.IGetOperationRequest=} [properties] Properties to set - */ - function GetOperationRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * GetOperationRequest name. - * @member {string} name - * @memberof google.longrunning.GetOperationRequest - * @instance - */ - GetOperationRequest.prototype.name = ""; - - return GetOperationRequest; - })(); - - longrunning.ListOperationsRequest = (function() { - - /** - * Properties of a ListOperationsRequest. - * @memberof google.longrunning - * @interface IListOperationsRequest - * @property {string|null} [name] ListOperationsRequest name - * @property {string|null} [filter] ListOperationsRequest filter - * @property {number|null} [pageSize] ListOperationsRequest pageSize - * @property {string|null} [pageToken] ListOperationsRequest pageToken - */ - - /** - * Constructs a new ListOperationsRequest. - * @memberof google.longrunning - * @classdesc Represents a ListOperationsRequest. - * @implements IListOperationsRequest - * @constructor - * @param {google.longrunning.IListOperationsRequest=} [properties] Properties to set - */ - function ListOperationsRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListOperationsRequest name. - * @member {string} name - * @memberof google.longrunning.ListOperationsRequest - * @instance - */ - ListOperationsRequest.prototype.name = ""; - - /** - * ListOperationsRequest filter. - * @member {string} filter - * @memberof google.longrunning.ListOperationsRequest - * @instance - */ - ListOperationsRequest.prototype.filter = ""; - - /** - * ListOperationsRequest pageSize. - * @member {number} pageSize - * @memberof google.longrunning.ListOperationsRequest - * @instance - */ - ListOperationsRequest.prototype.pageSize = 0; - - /** - * ListOperationsRequest pageToken. - * @member {string} pageToken - * @memberof google.longrunning.ListOperationsRequest - * @instance - */ - ListOperationsRequest.prototype.pageToken = ""; - - return ListOperationsRequest; - })(); - - longrunning.ListOperationsResponse = (function() { - - /** - * Properties of a ListOperationsResponse. - * @memberof google.longrunning - * @interface IListOperationsResponse - * @property {Array.|null} [operations] ListOperationsResponse operations - * @property {string|null} [nextPageToken] ListOperationsResponse nextPageToken - */ - - /** - * Constructs a new ListOperationsResponse. - * @memberof google.longrunning - * @classdesc Represents a ListOperationsResponse. - * @implements IListOperationsResponse - * @constructor - * @param {google.longrunning.IListOperationsResponse=} [properties] Properties to set - */ - function ListOperationsResponse(properties) { - this.operations = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListOperationsResponse operations. - * @member {Array.} operations - * @memberof google.longrunning.ListOperationsResponse - * @instance - */ - ListOperationsResponse.prototype.operations = $util.emptyArray; - - /** - * ListOperationsResponse nextPageToken. - * @member {string} nextPageToken - * @memberof google.longrunning.ListOperationsResponse - * @instance - */ - ListOperationsResponse.prototype.nextPageToken = ""; - - return ListOperationsResponse; - })(); - - longrunning.CancelOperationRequest = (function() { - - /** - * Properties of a CancelOperationRequest. - * @memberof google.longrunning - * @interface ICancelOperationRequest - * @property {string|null} [name] CancelOperationRequest name - */ - - /** - * Constructs a new CancelOperationRequest. - * @memberof google.longrunning - * @classdesc Represents a CancelOperationRequest. - * @implements ICancelOperationRequest - * @constructor - * @param {google.longrunning.ICancelOperationRequest=} [properties] Properties to set - */ - function CancelOperationRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * CancelOperationRequest name. - * @member {string} name - * @memberof google.longrunning.CancelOperationRequest - * @instance - */ - CancelOperationRequest.prototype.name = ""; - - return CancelOperationRequest; + + v1beta1.ListDocumentsResponse = (function() { + + /** + * Properties of a ListDocumentsResponse. + * @memberof google.firestore.v1beta1 + * @interface IListDocumentsResponse + * @property {Array.|null} [documents] ListDocumentsResponse documents + * @property {string|null} [nextPageToken] ListDocumentsResponse nextPageToken + */ + + /** + * Constructs a new ListDocumentsResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a ListDocumentsResponse. + * @implements IListDocumentsResponse + * @constructor + * @param {google.firestore.v1beta1.IListDocumentsResponse=} [properties] Properties to set + */ + function ListDocumentsResponse(properties) { + this.documents = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListDocumentsResponse documents. + * @member {Array.} documents + * @memberof google.firestore.v1beta1.ListDocumentsResponse + * @instance + */ + ListDocumentsResponse.prototype.documents = $util.emptyArray; + + /** + * ListDocumentsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.firestore.v1beta1.ListDocumentsResponse + * @instance + */ + ListDocumentsResponse.prototype.nextPageToken = ""; + + /** + * Creates a ListDocumentsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.ListDocumentsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.ListDocumentsResponse} ListDocumentsResponse + */ + ListDocumentsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.ListDocumentsResponse) + return object; + var message = new $root.google.firestore.v1beta1.ListDocumentsResponse(); + if (object.documents) { + if (!Array.isArray(object.documents)) + throw TypeError(".google.firestore.v1beta1.ListDocumentsResponse.documents: array expected"); + message.documents = []; + for (var i = 0; i < object.documents.length; ++i) { + if (typeof object.documents[i] !== "object") + throw TypeError(".google.firestore.v1beta1.ListDocumentsResponse.documents: object expected"); + message.documents[i] = $root.google.firestore.v1beta1.Document.fromObject(object.documents[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListDocumentsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.ListDocumentsResponse + * @static + * @param {google.firestore.v1beta1.ListDocumentsResponse} message ListDocumentsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListDocumentsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.documents = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.documents && message.documents.length) { + object.documents = []; + for (var j = 0; j < message.documents.length; ++j) + object.documents[j] = $root.google.firestore.v1beta1.Document.toObject(message.documents[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListDocumentsResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.ListDocumentsResponse + * @instance + * @returns {Object.} JSON object + */ + ListDocumentsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListDocumentsResponse; + })(); + + v1beta1.CreateDocumentRequest = (function() { + + /** + * Properties of a CreateDocumentRequest. + * @memberof google.firestore.v1beta1 + * @interface ICreateDocumentRequest + * @property {string|null} [parent] CreateDocumentRequest parent + * @property {string|null} [collectionId] CreateDocumentRequest collectionId + * @property {string|null} [documentId] CreateDocumentRequest documentId + * @property {google.firestore.v1beta1.IDocument|null} [document] CreateDocumentRequest document + * @property {google.firestore.v1beta1.IDocumentMask|null} [mask] CreateDocumentRequest mask + */ + + /** + * Constructs a new CreateDocumentRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a CreateDocumentRequest. + * @implements ICreateDocumentRequest + * @constructor + * @param {google.firestore.v1beta1.ICreateDocumentRequest=} [properties] Properties to set + */ + function CreateDocumentRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CreateDocumentRequest parent. + * @member {string} parent + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @instance + */ + CreateDocumentRequest.prototype.parent = ""; + + /** + * CreateDocumentRequest collectionId. + * @member {string} collectionId + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @instance + */ + CreateDocumentRequest.prototype.collectionId = ""; + + /** + * CreateDocumentRequest documentId. + * @member {string} documentId + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @instance + */ + CreateDocumentRequest.prototype.documentId = ""; + + /** + * CreateDocumentRequest document. + * @member {google.firestore.v1beta1.IDocument|null|undefined} document + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @instance + */ + CreateDocumentRequest.prototype.document = null; + + /** + * CreateDocumentRequest mask. + * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} mask + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @instance + */ + CreateDocumentRequest.prototype.mask = null; + + /** + * Creates a CreateDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.CreateDocumentRequest} CreateDocumentRequest + */ + CreateDocumentRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.CreateDocumentRequest) + return object; + var message = new $root.google.firestore.v1beta1.CreateDocumentRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.collectionId != null) + message.collectionId = String(object.collectionId); + if (object.documentId != null) + message.documentId = String(object.documentId); + if (object.document != null) { + if (typeof object.document !== "object") + throw TypeError(".google.firestore.v1beta1.CreateDocumentRequest.document: object expected"); + message.document = $root.google.firestore.v1beta1.Document.fromObject(object.document); + } + if (object.mask != null) { + if (typeof object.mask !== "object") + throw TypeError(".google.firestore.v1beta1.CreateDocumentRequest.mask: object expected"); + message.mask = $root.google.firestore.v1beta1.DocumentMask.fromObject(object.mask); + } + return message; + }; + + /** + * Creates a plain object from a CreateDocumentRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @static + * @param {google.firestore.v1beta1.CreateDocumentRequest} message CreateDocumentRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateDocumentRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.collectionId = ""; + object.documentId = ""; + object.document = null; + object.mask = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.collectionId != null && message.hasOwnProperty("collectionId")) + object.collectionId = message.collectionId; + if (message.documentId != null && message.hasOwnProperty("documentId")) + object.documentId = message.documentId; + if (message.document != null && message.hasOwnProperty("document")) + object.document = $root.google.firestore.v1beta1.Document.toObject(message.document, options); + if (message.mask != null && message.hasOwnProperty("mask")) + object.mask = $root.google.firestore.v1beta1.DocumentMask.toObject(message.mask, options); + return object; + }; + + /** + * Converts this CreateDocumentRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.CreateDocumentRequest + * @instance + * @returns {Object.} JSON object + */ + CreateDocumentRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CreateDocumentRequest; + })(); + + v1beta1.UpdateDocumentRequest = (function() { + + /** + * Properties of an UpdateDocumentRequest. + * @memberof google.firestore.v1beta1 + * @interface IUpdateDocumentRequest + * @property {google.firestore.v1beta1.IDocument|null} [document] UpdateDocumentRequest document + * @property {google.firestore.v1beta1.IDocumentMask|null} [updateMask] UpdateDocumentRequest updateMask + * @property {google.firestore.v1beta1.IDocumentMask|null} [mask] UpdateDocumentRequest mask + * @property {google.firestore.v1beta1.IPrecondition|null} [currentDocument] UpdateDocumentRequest currentDocument + */ + + /** + * Constructs a new UpdateDocumentRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents an UpdateDocumentRequest. + * @implements IUpdateDocumentRequest + * @constructor + * @param {google.firestore.v1beta1.IUpdateDocumentRequest=} [properties] Properties to set + */ + function UpdateDocumentRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UpdateDocumentRequest document. + * @member {google.firestore.v1beta1.IDocument|null|undefined} document + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @instance + */ + UpdateDocumentRequest.prototype.document = null; + + /** + * UpdateDocumentRequest updateMask. + * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} updateMask + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @instance + */ + UpdateDocumentRequest.prototype.updateMask = null; + + /** + * UpdateDocumentRequest mask. + * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} mask + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @instance + */ + UpdateDocumentRequest.prototype.mask = null; + + /** + * UpdateDocumentRequest currentDocument. + * @member {google.firestore.v1beta1.IPrecondition|null|undefined} currentDocument + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @instance + */ + UpdateDocumentRequest.prototype.currentDocument = null; + + /** + * Creates an UpdateDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.UpdateDocumentRequest} UpdateDocumentRequest + */ + UpdateDocumentRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.UpdateDocumentRequest) + return object; + var message = new $root.google.firestore.v1beta1.UpdateDocumentRequest(); + if (object.document != null) { + if (typeof object.document !== "object") + throw TypeError(".google.firestore.v1beta1.UpdateDocumentRequest.document: object expected"); + message.document = $root.google.firestore.v1beta1.Document.fromObject(object.document); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.firestore.v1beta1.UpdateDocumentRequest.updateMask: object expected"); + message.updateMask = $root.google.firestore.v1beta1.DocumentMask.fromObject(object.updateMask); + } + if (object.mask != null) { + if (typeof object.mask !== "object") + throw TypeError(".google.firestore.v1beta1.UpdateDocumentRequest.mask: object expected"); + message.mask = $root.google.firestore.v1beta1.DocumentMask.fromObject(object.mask); + } + if (object.currentDocument != null) { + if (typeof object.currentDocument !== "object") + throw TypeError(".google.firestore.v1beta1.UpdateDocumentRequest.currentDocument: object expected"); + message.currentDocument = $root.google.firestore.v1beta1.Precondition.fromObject(object.currentDocument); + } + return message; + }; + + /** + * Creates a plain object from an UpdateDocumentRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @static + * @param {google.firestore.v1beta1.UpdateDocumentRequest} message UpdateDocumentRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateDocumentRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.document = null; + object.updateMask = null; + object.mask = null; + object.currentDocument = null; + } + if (message.document != null && message.hasOwnProperty("document")) + object.document = $root.google.firestore.v1beta1.Document.toObject(message.document, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.firestore.v1beta1.DocumentMask.toObject(message.updateMask, options); + if (message.mask != null && message.hasOwnProperty("mask")) + object.mask = $root.google.firestore.v1beta1.DocumentMask.toObject(message.mask, options); + if (message.currentDocument != null && message.hasOwnProperty("currentDocument")) + object.currentDocument = $root.google.firestore.v1beta1.Precondition.toObject(message.currentDocument, options); + return object; + }; + + /** + * Converts this UpdateDocumentRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.UpdateDocumentRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateDocumentRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return UpdateDocumentRequest; + })(); + + v1beta1.DeleteDocumentRequest = (function() { + + /** + * Properties of a DeleteDocumentRequest. + * @memberof google.firestore.v1beta1 + * @interface IDeleteDocumentRequest + * @property {string|null} [name] DeleteDocumentRequest name + * @property {google.firestore.v1beta1.IPrecondition|null} [currentDocument] DeleteDocumentRequest currentDocument + */ + + /** + * Constructs a new DeleteDocumentRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a DeleteDocumentRequest. + * @implements IDeleteDocumentRequest + * @constructor + * @param {google.firestore.v1beta1.IDeleteDocumentRequest=} [properties] Properties to set + */ + function DeleteDocumentRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteDocumentRequest name. + * @member {string} name + * @memberof google.firestore.v1beta1.DeleteDocumentRequest + * @instance + */ + DeleteDocumentRequest.prototype.name = ""; + + /** + * DeleteDocumentRequest currentDocument. + * @member {google.firestore.v1beta1.IPrecondition|null|undefined} currentDocument + * @memberof google.firestore.v1beta1.DeleteDocumentRequest + * @instance + */ + DeleteDocumentRequest.prototype.currentDocument = null; + + /** + * Creates a DeleteDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.DeleteDocumentRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.DeleteDocumentRequest} DeleteDocumentRequest + */ + DeleteDocumentRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.DeleteDocumentRequest) + return object; + var message = new $root.google.firestore.v1beta1.DeleteDocumentRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.currentDocument != null) { + if (typeof object.currentDocument !== "object") + throw TypeError(".google.firestore.v1beta1.DeleteDocumentRequest.currentDocument: object expected"); + message.currentDocument = $root.google.firestore.v1beta1.Precondition.fromObject(object.currentDocument); + } + return message; + }; + + /** + * Creates a plain object from a DeleteDocumentRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.DeleteDocumentRequest + * @static + * @param {google.firestore.v1beta1.DeleteDocumentRequest} message DeleteDocumentRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteDocumentRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.currentDocument = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.currentDocument != null && message.hasOwnProperty("currentDocument")) + object.currentDocument = $root.google.firestore.v1beta1.Precondition.toObject(message.currentDocument, options); + return object; + }; + + /** + * Converts this DeleteDocumentRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.DeleteDocumentRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteDocumentRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DeleteDocumentRequest; + })(); + + v1beta1.BatchGetDocumentsRequest = (function() { + + /** + * Properties of a BatchGetDocumentsRequest. + * @memberof google.firestore.v1beta1 + * @interface IBatchGetDocumentsRequest + * @property {string|null} [database] BatchGetDocumentsRequest database + * @property {Array.|null} [documents] BatchGetDocumentsRequest documents + * @property {google.firestore.v1beta1.IDocumentMask|null} [mask] BatchGetDocumentsRequest mask + * @property {Uint8Array|null} [transaction] BatchGetDocumentsRequest transaction + * @property {google.firestore.v1beta1.ITransactionOptions|null} [newTransaction] BatchGetDocumentsRequest newTransaction + * @property {google.protobuf.ITimestamp|null} [readTime] BatchGetDocumentsRequest readTime + */ + + /** + * Constructs a new BatchGetDocumentsRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a BatchGetDocumentsRequest. + * @implements IBatchGetDocumentsRequest + * @constructor + * @param {google.firestore.v1beta1.IBatchGetDocumentsRequest=} [properties] Properties to set + */ + function BatchGetDocumentsRequest(properties) { + this.documents = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BatchGetDocumentsRequest database. + * @member {string} database + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.database = ""; + + /** + * BatchGetDocumentsRequest documents. + * @member {Array.} documents + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.documents = $util.emptyArray; + + /** + * BatchGetDocumentsRequest mask. + * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} mask + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.mask = null; + + /** + * BatchGetDocumentsRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.transaction = $util.newBuffer([]); + + /** + * BatchGetDocumentsRequest newTransaction. + * @member {google.firestore.v1beta1.ITransactionOptions|null|undefined} newTransaction + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.newTransaction = null; + + /** + * BatchGetDocumentsRequest readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @instance + */ + BatchGetDocumentsRequest.prototype.readTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * BatchGetDocumentsRequest consistencySelector. + * @member {"transaction"|"newTransaction"|"readTime"|undefined} consistencySelector + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @instance + */ + Object.defineProperty(BatchGetDocumentsRequest.prototype, "consistencySelector", { + get: $util.oneOfGetter($oneOfFields = ["transaction", "newTransaction", "readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a BatchGetDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.BatchGetDocumentsRequest} BatchGetDocumentsRequest + */ + BatchGetDocumentsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.BatchGetDocumentsRequest) + return object; + var message = new $root.google.firestore.v1beta1.BatchGetDocumentsRequest(); + if (object.database != null) + message.database = String(object.database); + if (object.documents) { + if (!Array.isArray(object.documents)) + throw TypeError(".google.firestore.v1beta1.BatchGetDocumentsRequest.documents: array expected"); + message.documents = []; + for (var i = 0; i < object.documents.length; ++i) + message.documents[i] = String(object.documents[i]); + } + if (object.mask != null) { + if (typeof object.mask !== "object") + throw TypeError(".google.firestore.v1beta1.BatchGetDocumentsRequest.mask: object expected"); + message.mask = $root.google.firestore.v1beta1.DocumentMask.fromObject(object.mask); + } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + if (object.newTransaction != null) { + if (typeof object.newTransaction !== "object") + throw TypeError(".google.firestore.v1beta1.BatchGetDocumentsRequest.newTransaction: object expected"); + message.newTransaction = $root.google.firestore.v1beta1.TransactionOptions.fromObject(object.newTransaction); + } + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1beta1.BatchGetDocumentsRequest.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a BatchGetDocumentsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @static + * @param {google.firestore.v1beta1.BatchGetDocumentsRequest} message BatchGetDocumentsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchGetDocumentsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.documents = []; + if (options.defaults) { + object.database = ""; + object.mask = null; + } + if (message.database != null && message.hasOwnProperty("database")) + object.database = message.database; + if (message.documents && message.documents.length) { + object.documents = []; + for (var j = 0; j < message.documents.length; ++j) + object.documents[j] = message.documents[j]; + } + if (message.mask != null && message.hasOwnProperty("mask")) + object.mask = $root.google.firestore.v1beta1.DocumentMask.toObject(message.mask, options); + if (message.transaction != null && message.hasOwnProperty("transaction")) { + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (options.oneofs) + object.consistencySelector = "transaction"; + } + if (message.newTransaction != null && message.hasOwnProperty("newTransaction")) { + object.newTransaction = $root.google.firestore.v1beta1.TransactionOptions.toObject(message.newTransaction, options); + if (options.oneofs) + object.consistencySelector = "newTransaction"; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (options.oneofs) + object.consistencySelector = "readTime"; + } + return object; + }; + + /** + * Converts this BatchGetDocumentsRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest + * @instance + * @returns {Object.} JSON object + */ + BatchGetDocumentsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BatchGetDocumentsRequest; + })(); + + v1beta1.BatchGetDocumentsResponse = (function() { + + /** + * Properties of a BatchGetDocumentsResponse. + * @memberof google.firestore.v1beta1 + * @interface IBatchGetDocumentsResponse + * @property {google.firestore.v1beta1.IDocument|null} [found] BatchGetDocumentsResponse found + * @property {string|null} [missing] BatchGetDocumentsResponse missing + * @property {Uint8Array|null} [transaction] BatchGetDocumentsResponse transaction + * @property {google.protobuf.ITimestamp|null} [readTime] BatchGetDocumentsResponse readTime + */ + + /** + * Constructs a new BatchGetDocumentsResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a BatchGetDocumentsResponse. + * @implements IBatchGetDocumentsResponse + * @constructor + * @param {google.firestore.v1beta1.IBatchGetDocumentsResponse=} [properties] Properties to set + */ + function BatchGetDocumentsResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BatchGetDocumentsResponse found. + * @member {google.firestore.v1beta1.IDocument|null|undefined} found + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @instance + */ + BatchGetDocumentsResponse.prototype.found = null; + + /** + * BatchGetDocumentsResponse missing. + * @member {string} missing + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @instance + */ + BatchGetDocumentsResponse.prototype.missing = ""; + + /** + * BatchGetDocumentsResponse transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @instance + */ + BatchGetDocumentsResponse.prototype.transaction = $util.newBuffer([]); + + /** + * BatchGetDocumentsResponse readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @instance + */ + BatchGetDocumentsResponse.prototype.readTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * BatchGetDocumentsResponse result. + * @member {"found"|"missing"|undefined} result + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @instance + */ + Object.defineProperty(BatchGetDocumentsResponse.prototype, "result", { + get: $util.oneOfGetter($oneOfFields = ["found", "missing"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a BatchGetDocumentsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.BatchGetDocumentsResponse} BatchGetDocumentsResponse + */ + BatchGetDocumentsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.BatchGetDocumentsResponse) + return object; + var message = new $root.google.firestore.v1beta1.BatchGetDocumentsResponse(); + if (object.found != null) { + if (typeof object.found !== "object") + throw TypeError(".google.firestore.v1beta1.BatchGetDocumentsResponse.found: object expected"); + message.found = $root.google.firestore.v1beta1.Document.fromObject(object.found); + } + if (object.missing != null) + message.missing = String(object.missing); + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1beta1.BatchGetDocumentsResponse.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a BatchGetDocumentsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @static + * @param {google.firestore.v1beta1.BatchGetDocumentsResponse} message BatchGetDocumentsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchGetDocumentsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } + object.readTime = null; + } + if (message.found != null && message.hasOwnProperty("found")) { + object.found = $root.google.firestore.v1beta1.Document.toObject(message.found, options); + if (options.oneofs) + object.result = "found"; + } + if (message.missing != null && message.hasOwnProperty("missing")) { + object.missing = message.missing; + if (options.oneofs) + object.result = "missing"; + } + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (message.readTime != null && message.hasOwnProperty("readTime")) + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + return object; + }; + + /** + * Converts this BatchGetDocumentsResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse + * @instance + * @returns {Object.} JSON object + */ + BatchGetDocumentsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BatchGetDocumentsResponse; + })(); + + v1beta1.BeginTransactionRequest = (function() { + + /** + * Properties of a BeginTransactionRequest. + * @memberof google.firestore.v1beta1 + * @interface IBeginTransactionRequest + * @property {string|null} [database] BeginTransactionRequest database + * @property {google.firestore.v1beta1.ITransactionOptions|null} [options] BeginTransactionRequest options + */ + + /** + * Constructs a new BeginTransactionRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a BeginTransactionRequest. + * @implements IBeginTransactionRequest + * @constructor + * @param {google.firestore.v1beta1.IBeginTransactionRequest=} [properties] Properties to set + */ + function BeginTransactionRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BeginTransactionRequest database. + * @member {string} database + * @memberof google.firestore.v1beta1.BeginTransactionRequest + * @instance + */ + BeginTransactionRequest.prototype.database = ""; + + /** + * BeginTransactionRequest options. + * @member {google.firestore.v1beta1.ITransactionOptions|null|undefined} options + * @memberof google.firestore.v1beta1.BeginTransactionRequest + * @instance + */ + BeginTransactionRequest.prototype.options = null; + + /** + * Creates a BeginTransactionRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.BeginTransactionRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.BeginTransactionRequest} BeginTransactionRequest + */ + BeginTransactionRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.BeginTransactionRequest) + return object; + var message = new $root.google.firestore.v1beta1.BeginTransactionRequest(); + if (object.database != null) + message.database = String(object.database); + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.firestore.v1beta1.BeginTransactionRequest.options: object expected"); + message.options = $root.google.firestore.v1beta1.TransactionOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from a BeginTransactionRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.BeginTransactionRequest + * @static + * @param {google.firestore.v1beta1.BeginTransactionRequest} message BeginTransactionRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BeginTransactionRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.database = ""; + object.options = null; + } + if (message.database != null && message.hasOwnProperty("database")) + object.database = message.database; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.firestore.v1beta1.TransactionOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this BeginTransactionRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.BeginTransactionRequest + * @instance + * @returns {Object.} JSON object + */ + BeginTransactionRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BeginTransactionRequest; + })(); + + v1beta1.BeginTransactionResponse = (function() { + + /** + * Properties of a BeginTransactionResponse. + * @memberof google.firestore.v1beta1 + * @interface IBeginTransactionResponse + * @property {Uint8Array|null} [transaction] BeginTransactionResponse transaction + */ + + /** + * Constructs a new BeginTransactionResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a BeginTransactionResponse. + * @implements IBeginTransactionResponse + * @constructor + * @param {google.firestore.v1beta1.IBeginTransactionResponse=} [properties] Properties to set + */ + function BeginTransactionResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BeginTransactionResponse transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.BeginTransactionResponse + * @instance + */ + BeginTransactionResponse.prototype.transaction = $util.newBuffer([]); + + /** + * Creates a BeginTransactionResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.BeginTransactionResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.BeginTransactionResponse} BeginTransactionResponse + */ + BeginTransactionResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.BeginTransactionResponse) + return object; + var message = new $root.google.firestore.v1beta1.BeginTransactionResponse(); + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + return message; + }; + + /** + * Creates a plain object from a BeginTransactionResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.BeginTransactionResponse + * @static + * @param {google.firestore.v1beta1.BeginTransactionResponse} message BeginTransactionResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BeginTransactionResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + return object; + }; + + /** + * Converts this BeginTransactionResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.BeginTransactionResponse + * @instance + * @returns {Object.} JSON object + */ + BeginTransactionResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BeginTransactionResponse; + })(); + + v1beta1.CommitRequest = (function() { + + /** + * Properties of a CommitRequest. + * @memberof google.firestore.v1beta1 + * @interface ICommitRequest + * @property {string|null} [database] CommitRequest database + * @property {Array.|null} [writes] CommitRequest writes + * @property {Uint8Array|null} [transaction] CommitRequest transaction + */ + + /** + * Constructs a new CommitRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a CommitRequest. + * @implements ICommitRequest + * @constructor + * @param {google.firestore.v1beta1.ICommitRequest=} [properties] Properties to set + */ + function CommitRequest(properties) { + this.writes = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CommitRequest database. + * @member {string} database + * @memberof google.firestore.v1beta1.CommitRequest + * @instance + */ + CommitRequest.prototype.database = ""; + + /** + * CommitRequest writes. + * @member {Array.} writes + * @memberof google.firestore.v1beta1.CommitRequest + * @instance + */ + CommitRequest.prototype.writes = $util.emptyArray; + + /** + * CommitRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.CommitRequest + * @instance + */ + CommitRequest.prototype.transaction = $util.newBuffer([]); + + /** + * Creates a CommitRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.CommitRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.CommitRequest} CommitRequest + */ + CommitRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.CommitRequest) + return object; + var message = new $root.google.firestore.v1beta1.CommitRequest(); + if (object.database != null) + message.database = String(object.database); + if (object.writes) { + if (!Array.isArray(object.writes)) + throw TypeError(".google.firestore.v1beta1.CommitRequest.writes: array expected"); + message.writes = []; + for (var i = 0; i < object.writes.length; ++i) { + if (typeof object.writes[i] !== "object") + throw TypeError(".google.firestore.v1beta1.CommitRequest.writes: object expected"); + message.writes[i] = $root.google.firestore.v1beta1.Write.fromObject(object.writes[i]); + } + } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + return message; + }; + + /** + * Creates a plain object from a CommitRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.CommitRequest + * @static + * @param {google.firestore.v1beta1.CommitRequest} message CommitRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CommitRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.writes = []; + if (options.defaults) { + object.database = ""; + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } + } + if (message.database != null && message.hasOwnProperty("database")) + object.database = message.database; + if (message.writes && message.writes.length) { + object.writes = []; + for (var j = 0; j < message.writes.length; ++j) + object.writes[j] = $root.google.firestore.v1beta1.Write.toObject(message.writes[j], options); + } + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + return object; + }; + + /** + * Converts this CommitRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.CommitRequest + * @instance + * @returns {Object.} JSON object + */ + CommitRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CommitRequest; + })(); + + v1beta1.CommitResponse = (function() { + + /** + * Properties of a CommitResponse. + * @memberof google.firestore.v1beta1 + * @interface ICommitResponse + * @property {Array.|null} [writeResults] CommitResponse writeResults + * @property {google.protobuf.ITimestamp|null} [commitTime] CommitResponse commitTime + */ + + /** + * Constructs a new CommitResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a CommitResponse. + * @implements ICommitResponse + * @constructor + * @param {google.firestore.v1beta1.ICommitResponse=} [properties] Properties to set + */ + function CommitResponse(properties) { + this.writeResults = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CommitResponse writeResults. + * @member {Array.} writeResults + * @memberof google.firestore.v1beta1.CommitResponse + * @instance + */ + CommitResponse.prototype.writeResults = $util.emptyArray; + + /** + * CommitResponse commitTime. + * @member {google.protobuf.ITimestamp|null|undefined} commitTime + * @memberof google.firestore.v1beta1.CommitResponse + * @instance + */ + CommitResponse.prototype.commitTime = null; + + /** + * Creates a CommitResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.CommitResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.CommitResponse} CommitResponse + */ + CommitResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.CommitResponse) + return object; + var message = new $root.google.firestore.v1beta1.CommitResponse(); + if (object.writeResults) { + if (!Array.isArray(object.writeResults)) + throw TypeError(".google.firestore.v1beta1.CommitResponse.writeResults: array expected"); + message.writeResults = []; + for (var i = 0; i < object.writeResults.length; ++i) { + if (typeof object.writeResults[i] !== "object") + throw TypeError(".google.firestore.v1beta1.CommitResponse.writeResults: object expected"); + message.writeResults[i] = $root.google.firestore.v1beta1.WriteResult.fromObject(object.writeResults[i]); + } + } + if (object.commitTime != null) { + if (typeof object.commitTime !== "object") + throw TypeError(".google.firestore.v1beta1.CommitResponse.commitTime: object expected"); + message.commitTime = $root.google.protobuf.Timestamp.fromObject(object.commitTime); + } + return message; + }; + + /** + * Creates a plain object from a CommitResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.CommitResponse + * @static + * @param {google.firestore.v1beta1.CommitResponse} message CommitResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CommitResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.writeResults = []; + if (options.defaults) + object.commitTime = null; + if (message.writeResults && message.writeResults.length) { + object.writeResults = []; + for (var j = 0; j < message.writeResults.length; ++j) + object.writeResults[j] = $root.google.firestore.v1beta1.WriteResult.toObject(message.writeResults[j], options); + } + if (message.commitTime != null && message.hasOwnProperty("commitTime")) + object.commitTime = $root.google.protobuf.Timestamp.toObject(message.commitTime, options); + return object; + }; + + /** + * Converts this CommitResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.CommitResponse + * @instance + * @returns {Object.} JSON object + */ + CommitResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CommitResponse; + })(); + + v1beta1.RollbackRequest = (function() { + + /** + * Properties of a RollbackRequest. + * @memberof google.firestore.v1beta1 + * @interface IRollbackRequest + * @property {string|null} [database] RollbackRequest database + * @property {Uint8Array|null} [transaction] RollbackRequest transaction + */ + + /** + * Constructs a new RollbackRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a RollbackRequest. + * @implements IRollbackRequest + * @constructor + * @param {google.firestore.v1beta1.IRollbackRequest=} [properties] Properties to set + */ + function RollbackRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RollbackRequest database. + * @member {string} database + * @memberof google.firestore.v1beta1.RollbackRequest + * @instance + */ + RollbackRequest.prototype.database = ""; + + /** + * RollbackRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.RollbackRequest + * @instance + */ + RollbackRequest.prototype.transaction = $util.newBuffer([]); + + /** + * Creates a RollbackRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.RollbackRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.RollbackRequest} RollbackRequest + */ + RollbackRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.RollbackRequest) + return object; + var message = new $root.google.firestore.v1beta1.RollbackRequest(); + if (object.database != null) + message.database = String(object.database); + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + return message; + }; + + /** + * Creates a plain object from a RollbackRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.RollbackRequest + * @static + * @param {google.firestore.v1beta1.RollbackRequest} message RollbackRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RollbackRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.database = ""; + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } + } + if (message.database != null && message.hasOwnProperty("database")) + object.database = message.database; + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + return object; + }; + + /** + * Converts this RollbackRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.RollbackRequest + * @instance + * @returns {Object.} JSON object + */ + RollbackRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return RollbackRequest; + })(); + + v1beta1.RunQueryRequest = (function() { + + /** + * Properties of a RunQueryRequest. + * @memberof google.firestore.v1beta1 + * @interface IRunQueryRequest + * @property {string|null} [parent] RunQueryRequest parent + * @property {google.firestore.v1beta1.IStructuredQuery|null} [structuredQuery] RunQueryRequest structuredQuery + * @property {Uint8Array|null} [transaction] RunQueryRequest transaction + * @property {google.firestore.v1beta1.ITransactionOptions|null} [newTransaction] RunQueryRequest newTransaction + * @property {google.protobuf.ITimestamp|null} [readTime] RunQueryRequest readTime + */ + + /** + * Constructs a new RunQueryRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a RunQueryRequest. + * @implements IRunQueryRequest + * @constructor + * @param {google.firestore.v1beta1.IRunQueryRequest=} [properties] Properties to set + */ + function RunQueryRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RunQueryRequest parent. + * @member {string} parent + * @memberof google.firestore.v1beta1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.parent = ""; + + /** + * RunQueryRequest structuredQuery. + * @member {google.firestore.v1beta1.IStructuredQuery|null|undefined} structuredQuery + * @memberof google.firestore.v1beta1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.structuredQuery = null; + + /** + * RunQueryRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.transaction = $util.newBuffer([]); + + /** + * RunQueryRequest newTransaction. + * @member {google.firestore.v1beta1.ITransactionOptions|null|undefined} newTransaction + * @memberof google.firestore.v1beta1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.newTransaction = null; + + /** + * RunQueryRequest readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.readTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * RunQueryRequest queryType. + * @member {"structuredQuery"|undefined} queryType + * @memberof google.firestore.v1beta1.RunQueryRequest + * @instance + */ + Object.defineProperty(RunQueryRequest.prototype, "queryType", { + get: $util.oneOfGetter($oneOfFields = ["structuredQuery"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * RunQueryRequest consistencySelector. + * @member {"transaction"|"newTransaction"|"readTime"|undefined} consistencySelector + * @memberof google.firestore.v1beta1.RunQueryRequest + * @instance + */ + Object.defineProperty(RunQueryRequest.prototype, "consistencySelector", { + get: $util.oneOfGetter($oneOfFields = ["transaction", "newTransaction", "readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a RunQueryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.RunQueryRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.RunQueryRequest} RunQueryRequest + */ + RunQueryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.RunQueryRequest) + return object; + var message = new $root.google.firestore.v1beta1.RunQueryRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.structuredQuery != null) { + if (typeof object.structuredQuery !== "object") + throw TypeError(".google.firestore.v1beta1.RunQueryRequest.structuredQuery: object expected"); + message.structuredQuery = $root.google.firestore.v1beta1.StructuredQuery.fromObject(object.structuredQuery); + } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + if (object.newTransaction != null) { + if (typeof object.newTransaction !== "object") + throw TypeError(".google.firestore.v1beta1.RunQueryRequest.newTransaction: object expected"); + message.newTransaction = $root.google.firestore.v1beta1.TransactionOptions.fromObject(object.newTransaction); + } + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1beta1.RunQueryRequest.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a RunQueryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.RunQueryRequest + * @static + * @param {google.firestore.v1beta1.RunQueryRequest} message RunQueryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RunQueryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.parent = ""; + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.structuredQuery != null && message.hasOwnProperty("structuredQuery")) { + object.structuredQuery = $root.google.firestore.v1beta1.StructuredQuery.toObject(message.structuredQuery, options); + if (options.oneofs) + object.queryType = "structuredQuery"; + } + if (message.transaction != null && message.hasOwnProperty("transaction")) { + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (options.oneofs) + object.consistencySelector = "transaction"; + } + if (message.newTransaction != null && message.hasOwnProperty("newTransaction")) { + object.newTransaction = $root.google.firestore.v1beta1.TransactionOptions.toObject(message.newTransaction, options); + if (options.oneofs) + object.consistencySelector = "newTransaction"; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (options.oneofs) + object.consistencySelector = "readTime"; + } + return object; + }; + + /** + * Converts this RunQueryRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.RunQueryRequest + * @instance + * @returns {Object.} JSON object + */ + RunQueryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return RunQueryRequest; + })(); + + v1beta1.RunQueryResponse = (function() { + + /** + * Properties of a RunQueryResponse. + * @memberof google.firestore.v1beta1 + * @interface IRunQueryResponse + * @property {Uint8Array|null} [transaction] RunQueryResponse transaction + * @property {google.firestore.v1beta1.IDocument|null} [document] RunQueryResponse document + * @property {google.protobuf.ITimestamp|null} [readTime] RunQueryResponse readTime + * @property {number|null} [skippedResults] RunQueryResponse skippedResults + */ + + /** + * Constructs a new RunQueryResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a RunQueryResponse. + * @implements IRunQueryResponse + * @constructor + * @param {google.firestore.v1beta1.IRunQueryResponse=} [properties] Properties to set + */ + function RunQueryResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RunQueryResponse transaction. + * @member {Uint8Array} transaction + * @memberof google.firestore.v1beta1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.transaction = $util.newBuffer([]); + + /** + * RunQueryResponse document. + * @member {google.firestore.v1beta1.IDocument|null|undefined} document + * @memberof google.firestore.v1beta1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.document = null; + + /** + * RunQueryResponse readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.readTime = null; + + /** + * RunQueryResponse skippedResults. + * @member {number} skippedResults + * @memberof google.firestore.v1beta1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.skippedResults = 0; + + /** + * Creates a RunQueryResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.RunQueryResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.RunQueryResponse} RunQueryResponse + */ + RunQueryResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.RunQueryResponse) + return object; + var message = new $root.google.firestore.v1beta1.RunQueryResponse(); + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length) + message.transaction = object.transaction; + if (object.document != null) { + if (typeof object.document !== "object") + throw TypeError(".google.firestore.v1beta1.RunQueryResponse.document: object expected"); + message.document = $root.google.firestore.v1beta1.Document.fromObject(object.document); + } + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1beta1.RunQueryResponse.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + if (object.skippedResults != null) + message.skippedResults = object.skippedResults | 0; + return message; + }; + + /** + * Creates a plain object from a RunQueryResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.RunQueryResponse + * @static + * @param {google.firestore.v1beta1.RunQueryResponse} message RunQueryResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RunQueryResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.document = null; + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } + object.readTime = null; + object.skippedResults = 0; + } + if (message.document != null && message.hasOwnProperty("document")) + object.document = $root.google.firestore.v1beta1.Document.toObject(message.document, options); + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (message.readTime != null && message.hasOwnProperty("readTime")) + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (message.skippedResults != null && message.hasOwnProperty("skippedResults")) + object.skippedResults = message.skippedResults; + return object; + }; + + /** + * Converts this RunQueryResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.RunQueryResponse + * @instance + * @returns {Object.} JSON object + */ + RunQueryResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return RunQueryResponse; + })(); + + v1beta1.WriteRequest = (function() { + + /** + * Properties of a WriteRequest. + * @memberof google.firestore.v1beta1 + * @interface IWriteRequest + * @property {string|null} [database] WriteRequest database + * @property {string|null} [streamId] WriteRequest streamId + * @property {Array.|null} [writes] WriteRequest writes + * @property {Uint8Array|null} [streamToken] WriteRequest streamToken + * @property {Object.|null} [labels] WriteRequest labels + */ + + /** + * Constructs a new WriteRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a WriteRequest. + * @implements IWriteRequest + * @constructor + * @param {google.firestore.v1beta1.IWriteRequest=} [properties] Properties to set + */ + function WriteRequest(properties) { + this.writes = []; + this.labels = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WriteRequest database. + * @member {string} database + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + */ + WriteRequest.prototype.database = ""; + + /** + * WriteRequest streamId. + * @member {string} streamId + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + */ + WriteRequest.prototype.streamId = ""; + + /** + * WriteRequest writes. + * @member {Array.} writes + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + */ + WriteRequest.prototype.writes = $util.emptyArray; + + /** + * WriteRequest streamToken. + * @member {Uint8Array} streamToken + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + */ + WriteRequest.prototype.streamToken = $util.newBuffer([]); + + /** + * WriteRequest labels. + * @member {Object.} labels + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + */ + WriteRequest.prototype.labels = $util.emptyObject; + + /** + * Creates a WriteRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.WriteRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.WriteRequest} WriteRequest + */ + WriteRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.WriteRequest) + return object; + var message = new $root.google.firestore.v1beta1.WriteRequest(); + if (object.database != null) + message.database = String(object.database); + if (object.streamId != null) + message.streamId = String(object.streamId); + if (object.writes) { + if (!Array.isArray(object.writes)) + throw TypeError(".google.firestore.v1beta1.WriteRequest.writes: array expected"); + message.writes = []; + for (var i = 0; i < object.writes.length; ++i) { + if (typeof object.writes[i] !== "object") + throw TypeError(".google.firestore.v1beta1.WriteRequest.writes: object expected"); + message.writes[i] = $root.google.firestore.v1beta1.Write.fromObject(object.writes[i]); + } + } + if (object.streamToken != null) + if (typeof object.streamToken === "string") + $util.base64.decode(object.streamToken, message.streamToken = $util.newBuffer($util.base64.length(object.streamToken)), 0); + else if (object.streamToken.length) + message.streamToken = object.streamToken; + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.firestore.v1beta1.WriteRequest.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } + return message; + }; + + /** + * Creates a plain object from a WriteRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.WriteRequest + * @static + * @param {google.firestore.v1beta1.WriteRequest} message WriteRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WriteRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.writes = []; + if (options.objects || options.defaults) + object.labels = {}; + if (options.defaults) { + object.database = ""; + object.streamId = ""; + if (options.bytes === String) + object.streamToken = ""; + else { + object.streamToken = []; + if (options.bytes !== Array) + object.streamToken = $util.newBuffer(object.streamToken); + } + } + if (message.database != null && message.hasOwnProperty("database")) + object.database = message.database; + if (message.streamId != null && message.hasOwnProperty("streamId")) + object.streamId = message.streamId; + if (message.writes && message.writes.length) { + object.writes = []; + for (var j = 0; j < message.writes.length; ++j) + object.writes[j] = $root.google.firestore.v1beta1.Write.toObject(message.writes[j], options); + } + if (message.streamToken != null && message.hasOwnProperty("streamToken")) + object.streamToken = options.bytes === String ? $util.base64.encode(message.streamToken, 0, message.streamToken.length) : options.bytes === Array ? Array.prototype.slice.call(message.streamToken) : message.streamToken; + var keys2; + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } + return object; + }; + + /** + * Converts this WriteRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + * @returns {Object.} JSON object + */ + WriteRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return WriteRequest; + })(); + + v1beta1.WriteResponse = (function() { + + /** + * Properties of a WriteResponse. + * @memberof google.firestore.v1beta1 + * @interface IWriteResponse + * @property {string|null} [streamId] WriteResponse streamId + * @property {Uint8Array|null} [streamToken] WriteResponse streamToken + * @property {Array.|null} [writeResults] WriteResponse writeResults + * @property {google.protobuf.ITimestamp|null} [commitTime] WriteResponse commitTime + */ + + /** + * Constructs a new WriteResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a WriteResponse. + * @implements IWriteResponse + * @constructor + * @param {google.firestore.v1beta1.IWriteResponse=} [properties] Properties to set + */ + function WriteResponse(properties) { + this.writeResults = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WriteResponse streamId. + * @member {string} streamId + * @memberof google.firestore.v1beta1.WriteResponse + * @instance + */ + WriteResponse.prototype.streamId = ""; + + /** + * WriteResponse streamToken. + * @member {Uint8Array} streamToken + * @memberof google.firestore.v1beta1.WriteResponse + * @instance + */ + WriteResponse.prototype.streamToken = $util.newBuffer([]); + + /** + * WriteResponse writeResults. + * @member {Array.} writeResults + * @memberof google.firestore.v1beta1.WriteResponse + * @instance + */ + WriteResponse.prototype.writeResults = $util.emptyArray; + + /** + * WriteResponse commitTime. + * @member {google.protobuf.ITimestamp|null|undefined} commitTime + * @memberof google.firestore.v1beta1.WriteResponse + * @instance + */ + WriteResponse.prototype.commitTime = null; + + /** + * Creates a WriteResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.WriteResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.WriteResponse} WriteResponse + */ + WriteResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.WriteResponse) + return object; + var message = new $root.google.firestore.v1beta1.WriteResponse(); + if (object.streamId != null) + message.streamId = String(object.streamId); + if (object.streamToken != null) + if (typeof object.streamToken === "string") + $util.base64.decode(object.streamToken, message.streamToken = $util.newBuffer($util.base64.length(object.streamToken)), 0); + else if (object.streamToken.length) + message.streamToken = object.streamToken; + if (object.writeResults) { + if (!Array.isArray(object.writeResults)) + throw TypeError(".google.firestore.v1beta1.WriteResponse.writeResults: array expected"); + message.writeResults = []; + for (var i = 0; i < object.writeResults.length; ++i) { + if (typeof object.writeResults[i] !== "object") + throw TypeError(".google.firestore.v1beta1.WriteResponse.writeResults: object expected"); + message.writeResults[i] = $root.google.firestore.v1beta1.WriteResult.fromObject(object.writeResults[i]); + } + } + if (object.commitTime != null) { + if (typeof object.commitTime !== "object") + throw TypeError(".google.firestore.v1beta1.WriteResponse.commitTime: object expected"); + message.commitTime = $root.google.protobuf.Timestamp.fromObject(object.commitTime); + } + return message; + }; + + /** + * Creates a plain object from a WriteResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.WriteResponse + * @static + * @param {google.firestore.v1beta1.WriteResponse} message WriteResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WriteResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.writeResults = []; + if (options.defaults) { + object.streamId = ""; + if (options.bytes === String) + object.streamToken = ""; + else { + object.streamToken = []; + if (options.bytes !== Array) + object.streamToken = $util.newBuffer(object.streamToken); + } + object.commitTime = null; + } + if (message.streamId != null && message.hasOwnProperty("streamId")) + object.streamId = message.streamId; + if (message.streamToken != null && message.hasOwnProperty("streamToken")) + object.streamToken = options.bytes === String ? $util.base64.encode(message.streamToken, 0, message.streamToken.length) : options.bytes === Array ? Array.prototype.slice.call(message.streamToken) : message.streamToken; + if (message.writeResults && message.writeResults.length) { + object.writeResults = []; + for (var j = 0; j < message.writeResults.length; ++j) + object.writeResults[j] = $root.google.firestore.v1beta1.WriteResult.toObject(message.writeResults[j], options); + } + if (message.commitTime != null && message.hasOwnProperty("commitTime")) + object.commitTime = $root.google.protobuf.Timestamp.toObject(message.commitTime, options); + return object; + }; + + /** + * Converts this WriteResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.WriteResponse + * @instance + * @returns {Object.} JSON object + */ + WriteResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return WriteResponse; + })(); + + v1beta1.ListenRequest = (function() { + + /** + * Properties of a ListenRequest. + * @memberof google.firestore.v1beta1 + * @interface IListenRequest + * @property {string|null} [database] ListenRequest database + * @property {google.firestore.v1beta1.ITarget|null} [addTarget] ListenRequest addTarget + * @property {number|null} [removeTarget] ListenRequest removeTarget + * @property {Object.|null} [labels] ListenRequest labels + */ + + /** + * Constructs a new ListenRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a ListenRequest. + * @implements IListenRequest + * @constructor + * @param {google.firestore.v1beta1.IListenRequest=} [properties] Properties to set + */ + function ListenRequest(properties) { + this.labels = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListenRequest database. + * @member {string} database + * @memberof google.firestore.v1beta1.ListenRequest + * @instance + */ + ListenRequest.prototype.database = ""; + + /** + * ListenRequest addTarget. + * @member {google.firestore.v1beta1.ITarget|null|undefined} addTarget + * @memberof google.firestore.v1beta1.ListenRequest + * @instance + */ + ListenRequest.prototype.addTarget = null; + + /** + * ListenRequest removeTarget. + * @member {number} removeTarget + * @memberof google.firestore.v1beta1.ListenRequest + * @instance + */ + ListenRequest.prototype.removeTarget = 0; + + /** + * ListenRequest labels. + * @member {Object.} labels + * @memberof google.firestore.v1beta1.ListenRequest + * @instance + */ + ListenRequest.prototype.labels = $util.emptyObject; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ListenRequest targetChange. + * @member {"addTarget"|"removeTarget"|undefined} targetChange + * @memberof google.firestore.v1beta1.ListenRequest + * @instance + */ + Object.defineProperty(ListenRequest.prototype, "targetChange", { + get: $util.oneOfGetter($oneOfFields = ["addTarget", "removeTarget"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a ListenRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.ListenRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.ListenRequest} ListenRequest + */ + ListenRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.ListenRequest) + return object; + var message = new $root.google.firestore.v1beta1.ListenRequest(); + if (object.database != null) + message.database = String(object.database); + if (object.addTarget != null) { + if (typeof object.addTarget !== "object") + throw TypeError(".google.firestore.v1beta1.ListenRequest.addTarget: object expected"); + message.addTarget = $root.google.firestore.v1beta1.Target.fromObject(object.addTarget); + } + if (object.removeTarget != null) + message.removeTarget = object.removeTarget | 0; + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.firestore.v1beta1.ListenRequest.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } + return message; + }; + + /** + * Creates a plain object from a ListenRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.ListenRequest + * @static + * @param {google.firestore.v1beta1.ListenRequest} message ListenRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListenRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.labels = {}; + if (options.defaults) + object.database = ""; + if (message.database != null && message.hasOwnProperty("database")) + object.database = message.database; + if (message.addTarget != null && message.hasOwnProperty("addTarget")) { + object.addTarget = $root.google.firestore.v1beta1.Target.toObject(message.addTarget, options); + if (options.oneofs) + object.targetChange = "addTarget"; + } + if (message.removeTarget != null && message.hasOwnProperty("removeTarget")) { + object.removeTarget = message.removeTarget; + if (options.oneofs) + object.targetChange = "removeTarget"; + } + var keys2; + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } + return object; + }; + + /** + * Converts this ListenRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.ListenRequest + * @instance + * @returns {Object.} JSON object + */ + ListenRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListenRequest; + })(); + + v1beta1.ListenResponse = (function() { + + /** + * Properties of a ListenResponse. + * @memberof google.firestore.v1beta1 + * @interface IListenResponse + * @property {google.firestore.v1beta1.ITargetChange|null} [targetChange] ListenResponse targetChange + * @property {google.firestore.v1beta1.IDocumentChange|null} [documentChange] ListenResponse documentChange + * @property {google.firestore.v1beta1.IDocumentDelete|null} [documentDelete] ListenResponse documentDelete + * @property {google.firestore.v1beta1.IDocumentRemove|null} [documentRemove] ListenResponse documentRemove + * @property {google.firestore.v1beta1.IExistenceFilter|null} [filter] ListenResponse filter + */ + + /** + * Constructs a new ListenResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a ListenResponse. + * @implements IListenResponse + * @constructor + * @param {google.firestore.v1beta1.IListenResponse=} [properties] Properties to set + */ + function ListenResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListenResponse targetChange. + * @member {google.firestore.v1beta1.ITargetChange|null|undefined} targetChange + * @memberof google.firestore.v1beta1.ListenResponse + * @instance + */ + ListenResponse.prototype.targetChange = null; + + /** + * ListenResponse documentChange. + * @member {google.firestore.v1beta1.IDocumentChange|null|undefined} documentChange + * @memberof google.firestore.v1beta1.ListenResponse + * @instance + */ + ListenResponse.prototype.documentChange = null; + + /** + * ListenResponse documentDelete. + * @member {google.firestore.v1beta1.IDocumentDelete|null|undefined} documentDelete + * @memberof google.firestore.v1beta1.ListenResponse + * @instance + */ + ListenResponse.prototype.documentDelete = null; + + /** + * ListenResponse documentRemove. + * @member {google.firestore.v1beta1.IDocumentRemove|null|undefined} documentRemove + * @memberof google.firestore.v1beta1.ListenResponse + * @instance + */ + ListenResponse.prototype.documentRemove = null; + + /** + * ListenResponse filter. + * @member {google.firestore.v1beta1.IExistenceFilter|null|undefined} filter + * @memberof google.firestore.v1beta1.ListenResponse + * @instance + */ + ListenResponse.prototype.filter = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ListenResponse responseType. + * @member {"targetChange"|"documentChange"|"documentDelete"|"documentRemove"|"filter"|undefined} responseType + * @memberof google.firestore.v1beta1.ListenResponse + * @instance + */ + Object.defineProperty(ListenResponse.prototype, "responseType", { + get: $util.oneOfGetter($oneOfFields = ["targetChange", "documentChange", "documentDelete", "documentRemove", "filter"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a ListenResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.ListenResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.ListenResponse} ListenResponse + */ + ListenResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.ListenResponse) + return object; + var message = new $root.google.firestore.v1beta1.ListenResponse(); + if (object.targetChange != null) { + if (typeof object.targetChange !== "object") + throw TypeError(".google.firestore.v1beta1.ListenResponse.targetChange: object expected"); + message.targetChange = $root.google.firestore.v1beta1.TargetChange.fromObject(object.targetChange); + } + if (object.documentChange != null) { + if (typeof object.documentChange !== "object") + throw TypeError(".google.firestore.v1beta1.ListenResponse.documentChange: object expected"); + message.documentChange = $root.google.firestore.v1beta1.DocumentChange.fromObject(object.documentChange); + } + if (object.documentDelete != null) { + if (typeof object.documentDelete !== "object") + throw TypeError(".google.firestore.v1beta1.ListenResponse.documentDelete: object expected"); + message.documentDelete = $root.google.firestore.v1beta1.DocumentDelete.fromObject(object.documentDelete); + } + if (object.documentRemove != null) { + if (typeof object.documentRemove !== "object") + throw TypeError(".google.firestore.v1beta1.ListenResponse.documentRemove: object expected"); + message.documentRemove = $root.google.firestore.v1beta1.DocumentRemove.fromObject(object.documentRemove); + } + if (object.filter != null) { + if (typeof object.filter !== "object") + throw TypeError(".google.firestore.v1beta1.ListenResponse.filter: object expected"); + message.filter = $root.google.firestore.v1beta1.ExistenceFilter.fromObject(object.filter); + } + return message; + }; + + /** + * Creates a plain object from a ListenResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.ListenResponse + * @static + * @param {google.firestore.v1beta1.ListenResponse} message ListenResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListenResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.targetChange != null && message.hasOwnProperty("targetChange")) { + object.targetChange = $root.google.firestore.v1beta1.TargetChange.toObject(message.targetChange, options); + if (options.oneofs) + object.responseType = "targetChange"; + } + if (message.documentChange != null && message.hasOwnProperty("documentChange")) { + object.documentChange = $root.google.firestore.v1beta1.DocumentChange.toObject(message.documentChange, options); + if (options.oneofs) + object.responseType = "documentChange"; + } + if (message.documentDelete != null && message.hasOwnProperty("documentDelete")) { + object.documentDelete = $root.google.firestore.v1beta1.DocumentDelete.toObject(message.documentDelete, options); + if (options.oneofs) + object.responseType = "documentDelete"; + } + if (message.filter != null && message.hasOwnProperty("filter")) { + object.filter = $root.google.firestore.v1beta1.ExistenceFilter.toObject(message.filter, options); + if (options.oneofs) + object.responseType = "filter"; + } + if (message.documentRemove != null && message.hasOwnProperty("documentRemove")) { + object.documentRemove = $root.google.firestore.v1beta1.DocumentRemove.toObject(message.documentRemove, options); + if (options.oneofs) + object.responseType = "documentRemove"; + } + return object; + }; + + /** + * Converts this ListenResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.ListenResponse + * @instance + * @returns {Object.} JSON object + */ + ListenResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListenResponse; + })(); + + v1beta1.Target = (function() { + + /** + * Properties of a Target. + * @memberof google.firestore.v1beta1 + * @interface ITarget + * @property {google.firestore.v1beta1.Target.IQueryTarget|null} [query] Target query + * @property {google.firestore.v1beta1.Target.IDocumentsTarget|null} [documents] Target documents + * @property {Uint8Array|null} [resumeToken] Target resumeToken + * @property {google.protobuf.ITimestamp|null} [readTime] Target readTime + * @property {number|null} [targetId] Target targetId + * @property {boolean|null} [once] Target once + */ + + /** + * Constructs a new Target. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a Target. + * @implements ITarget + * @constructor + * @param {google.firestore.v1beta1.ITarget=} [properties] Properties to set + */ + function Target(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Target query. + * @member {google.firestore.v1beta1.Target.IQueryTarget|null|undefined} query + * @memberof google.firestore.v1beta1.Target + * @instance + */ + Target.prototype.query = null; + + /** + * Target documents. + * @member {google.firestore.v1beta1.Target.IDocumentsTarget|null|undefined} documents + * @memberof google.firestore.v1beta1.Target + * @instance + */ + Target.prototype.documents = null; + + /** + * Target resumeToken. + * @member {Uint8Array} resumeToken + * @memberof google.firestore.v1beta1.Target + * @instance + */ + Target.prototype.resumeToken = $util.newBuffer([]); + + /** + * Target readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.Target + * @instance + */ + Target.prototype.readTime = null; + + /** + * Target targetId. + * @member {number} targetId + * @memberof google.firestore.v1beta1.Target + * @instance + */ + Target.prototype.targetId = 0; + + /** + * Target once. + * @member {boolean} once + * @memberof google.firestore.v1beta1.Target + * @instance + */ + Target.prototype.once = false; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Target targetType. + * @member {"query"|"documents"|undefined} targetType + * @memberof google.firestore.v1beta1.Target + * @instance + */ + Object.defineProperty(Target.prototype, "targetType", { + get: $util.oneOfGetter($oneOfFields = ["query", "documents"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Target resumeType. + * @member {"resumeToken"|"readTime"|undefined} resumeType + * @memberof google.firestore.v1beta1.Target + * @instance + */ + Object.defineProperty(Target.prototype, "resumeType", { + get: $util.oneOfGetter($oneOfFields = ["resumeToken", "readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a Target message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.Target + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.Target} Target + */ + Target.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.Target) + return object; + var message = new $root.google.firestore.v1beta1.Target(); + if (object.query != null) { + if (typeof object.query !== "object") + throw TypeError(".google.firestore.v1beta1.Target.query: object expected"); + message.query = $root.google.firestore.v1beta1.Target.QueryTarget.fromObject(object.query); + } + if (object.documents != null) { + if (typeof object.documents !== "object") + throw TypeError(".google.firestore.v1beta1.Target.documents: object expected"); + message.documents = $root.google.firestore.v1beta1.Target.DocumentsTarget.fromObject(object.documents); + } + if (object.resumeToken != null) + if (typeof object.resumeToken === "string") + $util.base64.decode(object.resumeToken, message.resumeToken = $util.newBuffer($util.base64.length(object.resumeToken)), 0); + else if (object.resumeToken.length) + message.resumeToken = object.resumeToken; + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1beta1.Target.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + if (object.targetId != null) + message.targetId = object.targetId | 0; + if (object.once != null) + message.once = Boolean(object.once); + return message; + }; + + /** + * Creates a plain object from a Target message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.Target + * @static + * @param {google.firestore.v1beta1.Target} message Target + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Target.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.targetId = 0; + object.once = false; + } + if (message.query != null && message.hasOwnProperty("query")) { + object.query = $root.google.firestore.v1beta1.Target.QueryTarget.toObject(message.query, options); + if (options.oneofs) + object.targetType = "query"; + } + if (message.documents != null && message.hasOwnProperty("documents")) { + object.documents = $root.google.firestore.v1beta1.Target.DocumentsTarget.toObject(message.documents, options); + if (options.oneofs) + object.targetType = "documents"; + } + if (message.resumeToken != null && message.hasOwnProperty("resumeToken")) { + object.resumeToken = options.bytes === String ? $util.base64.encode(message.resumeToken, 0, message.resumeToken.length) : options.bytes === Array ? Array.prototype.slice.call(message.resumeToken) : message.resumeToken; + if (options.oneofs) + object.resumeType = "resumeToken"; + } + if (message.targetId != null && message.hasOwnProperty("targetId")) + object.targetId = message.targetId; + if (message.once != null && message.hasOwnProperty("once")) + object.once = message.once; + if (message.readTime != null && message.hasOwnProperty("readTime")) { + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (options.oneofs) + object.resumeType = "readTime"; + } + return object; + }; + + /** + * Converts this Target to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.Target + * @instance + * @returns {Object.} JSON object + */ + Target.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + Target.DocumentsTarget = (function() { + + /** + * Properties of a DocumentsTarget. + * @memberof google.firestore.v1beta1.Target + * @interface IDocumentsTarget + * @property {Array.|null} [documents] DocumentsTarget documents + */ + + /** + * Constructs a new DocumentsTarget. + * @memberof google.firestore.v1beta1.Target + * @classdesc Represents a DocumentsTarget. + * @implements IDocumentsTarget + * @constructor + * @param {google.firestore.v1beta1.Target.IDocumentsTarget=} [properties] Properties to set + */ + function DocumentsTarget(properties) { + this.documents = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentsTarget documents. + * @member {Array.} documents + * @memberof google.firestore.v1beta1.Target.DocumentsTarget + * @instance + */ + DocumentsTarget.prototype.documents = $util.emptyArray; + + /** + * Creates a DocumentsTarget message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.Target.DocumentsTarget + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.Target.DocumentsTarget} DocumentsTarget + */ + DocumentsTarget.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.Target.DocumentsTarget) + return object; + var message = new $root.google.firestore.v1beta1.Target.DocumentsTarget(); + if (object.documents) { + if (!Array.isArray(object.documents)) + throw TypeError(".google.firestore.v1beta1.Target.DocumentsTarget.documents: array expected"); + message.documents = []; + for (var i = 0; i < object.documents.length; ++i) + message.documents[i] = String(object.documents[i]); + } + return message; + }; + + /** + * Creates a plain object from a DocumentsTarget message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.Target.DocumentsTarget + * @static + * @param {google.firestore.v1beta1.Target.DocumentsTarget} message DocumentsTarget + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentsTarget.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.documents = []; + if (message.documents && message.documents.length) { + object.documents = []; + for (var j = 0; j < message.documents.length; ++j) + object.documents[j] = message.documents[j]; + } + return object; + }; + + /** + * Converts this DocumentsTarget to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.Target.DocumentsTarget + * @instance + * @returns {Object.} JSON object + */ + DocumentsTarget.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DocumentsTarget; + })(); + + Target.QueryTarget = (function() { + + /** + * Properties of a QueryTarget. + * @memberof google.firestore.v1beta1.Target + * @interface IQueryTarget + * @property {string|null} [parent] QueryTarget parent + * @property {google.firestore.v1beta1.IStructuredQuery|null} [structuredQuery] QueryTarget structuredQuery + */ + + /** + * Constructs a new QueryTarget. + * @memberof google.firestore.v1beta1.Target + * @classdesc Represents a QueryTarget. + * @implements IQueryTarget + * @constructor + * @param {google.firestore.v1beta1.Target.IQueryTarget=} [properties] Properties to set + */ + function QueryTarget(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * QueryTarget parent. + * @member {string} parent + * @memberof google.firestore.v1beta1.Target.QueryTarget + * @instance + */ + QueryTarget.prototype.parent = ""; + + /** + * QueryTarget structuredQuery. + * @member {google.firestore.v1beta1.IStructuredQuery|null|undefined} structuredQuery + * @memberof google.firestore.v1beta1.Target.QueryTarget + * @instance + */ + QueryTarget.prototype.structuredQuery = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * QueryTarget queryType. + * @member {"structuredQuery"|undefined} queryType + * @memberof google.firestore.v1beta1.Target.QueryTarget + * @instance + */ + Object.defineProperty(QueryTarget.prototype, "queryType", { + get: $util.oneOfGetter($oneOfFields = ["structuredQuery"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a QueryTarget message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.Target.QueryTarget + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.Target.QueryTarget} QueryTarget + */ + QueryTarget.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.Target.QueryTarget) + return object; + var message = new $root.google.firestore.v1beta1.Target.QueryTarget(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.structuredQuery != null) { + if (typeof object.structuredQuery !== "object") + throw TypeError(".google.firestore.v1beta1.Target.QueryTarget.structuredQuery: object expected"); + message.structuredQuery = $root.google.firestore.v1beta1.StructuredQuery.fromObject(object.structuredQuery); + } + return message; + }; + + /** + * Creates a plain object from a QueryTarget message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.Target.QueryTarget + * @static + * @param {google.firestore.v1beta1.Target.QueryTarget} message QueryTarget + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + QueryTarget.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.parent = ""; + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.structuredQuery != null && message.hasOwnProperty("structuredQuery")) { + object.structuredQuery = $root.google.firestore.v1beta1.StructuredQuery.toObject(message.structuredQuery, options); + if (options.oneofs) + object.queryType = "structuredQuery"; + } + return object; + }; + + /** + * Converts this QueryTarget to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.Target.QueryTarget + * @instance + * @returns {Object.} JSON object + */ + QueryTarget.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return QueryTarget; + })(); + + return Target; + })(); + + v1beta1.TargetChange = (function() { + + /** + * Properties of a TargetChange. + * @memberof google.firestore.v1beta1 + * @interface ITargetChange + * @property {google.firestore.v1beta1.TargetChange.TargetChangeType|null} [targetChangeType] TargetChange targetChangeType + * @property {Array.|null} [targetIds] TargetChange targetIds + * @property {google.rpc.IStatus|null} [cause] TargetChange cause + * @property {Uint8Array|null} [resumeToken] TargetChange resumeToken + * @property {google.protobuf.ITimestamp|null} [readTime] TargetChange readTime + */ + + /** + * Constructs a new TargetChange. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a TargetChange. + * @implements ITargetChange + * @constructor + * @param {google.firestore.v1beta1.ITargetChange=} [properties] Properties to set + */ + function TargetChange(properties) { + this.targetIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * TargetChange targetChangeType. + * @member {google.firestore.v1beta1.TargetChange.TargetChangeType} targetChangeType + * @memberof google.firestore.v1beta1.TargetChange + * @instance + */ + TargetChange.prototype.targetChangeType = 0; + + /** + * TargetChange targetIds. + * @member {Array.} targetIds + * @memberof google.firestore.v1beta1.TargetChange + * @instance + */ + TargetChange.prototype.targetIds = $util.emptyArray; + + /** + * TargetChange cause. + * @member {google.rpc.IStatus|null|undefined} cause + * @memberof google.firestore.v1beta1.TargetChange + * @instance + */ + TargetChange.prototype.cause = null; + + /** + * TargetChange resumeToken. + * @member {Uint8Array} resumeToken + * @memberof google.firestore.v1beta1.TargetChange + * @instance + */ + TargetChange.prototype.resumeToken = $util.newBuffer([]); + + /** + * TargetChange readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.TargetChange + * @instance + */ + TargetChange.prototype.readTime = null; + + /** + * Creates a TargetChange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.TargetChange + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.TargetChange} TargetChange + */ + TargetChange.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.TargetChange) + return object; + var message = new $root.google.firestore.v1beta1.TargetChange(); + switch (object.targetChangeType) { + case "NO_CHANGE": + case 0: + message.targetChangeType = 0; + break; + case "ADD": + case 1: + message.targetChangeType = 1; + break; + case "REMOVE": + case 2: + message.targetChangeType = 2; + break; + case "CURRENT": + case 3: + message.targetChangeType = 3; + break; + case "RESET": + case 4: + message.targetChangeType = 4; + break; + } + if (object.targetIds) { + if (!Array.isArray(object.targetIds)) + throw TypeError(".google.firestore.v1beta1.TargetChange.targetIds: array expected"); + message.targetIds = []; + for (var i = 0; i < object.targetIds.length; ++i) + message.targetIds[i] = object.targetIds[i] | 0; + } + if (object.cause != null) { + if (typeof object.cause !== "object") + throw TypeError(".google.firestore.v1beta1.TargetChange.cause: object expected"); + message.cause = $root.google.rpc.Status.fromObject(object.cause); + } + if (object.resumeToken != null) + if (typeof object.resumeToken === "string") + $util.base64.decode(object.resumeToken, message.resumeToken = $util.newBuffer($util.base64.length(object.resumeToken)), 0); + else if (object.resumeToken.length) + message.resumeToken = object.resumeToken; + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1beta1.TargetChange.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a TargetChange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.TargetChange + * @static + * @param {google.firestore.v1beta1.TargetChange} message TargetChange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TargetChange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.targetIds = []; + if (options.defaults) { + object.targetChangeType = options.enums === String ? "NO_CHANGE" : 0; + object.cause = null; + if (options.bytes === String) + object.resumeToken = ""; + else { + object.resumeToken = []; + if (options.bytes !== Array) + object.resumeToken = $util.newBuffer(object.resumeToken); + } + object.readTime = null; + } + if (message.targetChangeType != null && message.hasOwnProperty("targetChangeType")) + object.targetChangeType = options.enums === String ? $root.google.firestore.v1beta1.TargetChange.TargetChangeType[message.targetChangeType] : message.targetChangeType; + if (message.targetIds && message.targetIds.length) { + object.targetIds = []; + for (var j = 0; j < message.targetIds.length; ++j) + object.targetIds[j] = message.targetIds[j]; + } + if (message.cause != null && message.hasOwnProperty("cause")) + object.cause = $root.google.rpc.Status.toObject(message.cause, options); + if (message.resumeToken != null && message.hasOwnProperty("resumeToken")) + object.resumeToken = options.bytes === String ? $util.base64.encode(message.resumeToken, 0, message.resumeToken.length) : options.bytes === Array ? Array.prototype.slice.call(message.resumeToken) : message.resumeToken; + if (message.readTime != null && message.hasOwnProperty("readTime")) + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + return object; + }; + + /** + * Converts this TargetChange to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.TargetChange + * @instance + * @returns {Object.} JSON object + */ + TargetChange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * TargetChangeType enum. + * @name google.firestore.v1beta1.TargetChange.TargetChangeType + * @enum {string} + * @property {string} NO_CHANGE=NO_CHANGE NO_CHANGE value + * @property {string} ADD=ADD ADD value + * @property {string} REMOVE=REMOVE REMOVE value + * @property {string} CURRENT=CURRENT CURRENT value + * @property {string} RESET=RESET RESET value + */ + TargetChange.TargetChangeType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "NO_CHANGE"] = "NO_CHANGE"; + values[valuesById[1] = "ADD"] = "ADD"; + values[valuesById[2] = "REMOVE"] = "REMOVE"; + values[valuesById[3] = "CURRENT"] = "CURRENT"; + values[valuesById[4] = "RESET"] = "RESET"; + return values; + })(); + + return TargetChange; + })(); + + v1beta1.ListCollectionIdsRequest = (function() { + + /** + * Properties of a ListCollectionIdsRequest. + * @memberof google.firestore.v1beta1 + * @interface IListCollectionIdsRequest + * @property {string|null} [parent] ListCollectionIdsRequest parent + * @property {number|null} [pageSize] ListCollectionIdsRequest pageSize + * @property {string|null} [pageToken] ListCollectionIdsRequest pageToken + */ + + /** + * Constructs a new ListCollectionIdsRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a ListCollectionIdsRequest. + * @implements IListCollectionIdsRequest + * @constructor + * @param {google.firestore.v1beta1.IListCollectionIdsRequest=} [properties] Properties to set + */ + function ListCollectionIdsRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListCollectionIdsRequest parent. + * @member {string} parent + * @memberof google.firestore.v1beta1.ListCollectionIdsRequest + * @instance + */ + ListCollectionIdsRequest.prototype.parent = ""; + + /** + * ListCollectionIdsRequest pageSize. + * @member {number} pageSize + * @memberof google.firestore.v1beta1.ListCollectionIdsRequest + * @instance + */ + ListCollectionIdsRequest.prototype.pageSize = 0; + + /** + * ListCollectionIdsRequest pageToken. + * @member {string} pageToken + * @memberof google.firestore.v1beta1.ListCollectionIdsRequest + * @instance + */ + ListCollectionIdsRequest.prototype.pageToken = ""; + + /** + * Creates a ListCollectionIdsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.ListCollectionIdsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.ListCollectionIdsRequest} ListCollectionIdsRequest + */ + ListCollectionIdsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.ListCollectionIdsRequest) + return object; + var message = new $root.google.firestore.v1beta1.ListCollectionIdsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + return message; + }; + + /** + * Creates a plain object from a ListCollectionIdsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.ListCollectionIdsRequest + * @static + * @param {google.firestore.v1beta1.ListCollectionIdsRequest} message ListCollectionIdsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListCollectionIdsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + return object; + }; + + /** + * Converts this ListCollectionIdsRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.ListCollectionIdsRequest + * @instance + * @returns {Object.} JSON object + */ + ListCollectionIdsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListCollectionIdsRequest; + })(); + + v1beta1.ListCollectionIdsResponse = (function() { + + /** + * Properties of a ListCollectionIdsResponse. + * @memberof google.firestore.v1beta1 + * @interface IListCollectionIdsResponse + * @property {Array.|null} [collectionIds] ListCollectionIdsResponse collectionIds + * @property {string|null} [nextPageToken] ListCollectionIdsResponse nextPageToken + */ + + /** + * Constructs a new ListCollectionIdsResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a ListCollectionIdsResponse. + * @implements IListCollectionIdsResponse + * @constructor + * @param {google.firestore.v1beta1.IListCollectionIdsResponse=} [properties] Properties to set + */ + function ListCollectionIdsResponse(properties) { + this.collectionIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListCollectionIdsResponse collectionIds. + * @member {Array.} collectionIds + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @instance + */ + ListCollectionIdsResponse.prototype.collectionIds = $util.emptyArray; + + /** + * ListCollectionIdsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @instance + */ + ListCollectionIdsResponse.prototype.nextPageToken = ""; + + /** + * Creates a ListCollectionIdsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.ListCollectionIdsResponse} ListCollectionIdsResponse + */ + ListCollectionIdsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.ListCollectionIdsResponse) + return object; + var message = new $root.google.firestore.v1beta1.ListCollectionIdsResponse(); + if (object.collectionIds) { + if (!Array.isArray(object.collectionIds)) + throw TypeError(".google.firestore.v1beta1.ListCollectionIdsResponse.collectionIds: array expected"); + message.collectionIds = []; + for (var i = 0; i < object.collectionIds.length; ++i) + message.collectionIds[i] = String(object.collectionIds[i]); + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListCollectionIdsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @static + * @param {google.firestore.v1beta1.ListCollectionIdsResponse} message ListCollectionIdsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListCollectionIdsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.collectionIds = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.collectionIds && message.collectionIds.length) { + object.collectionIds = []; + for (var j = 0; j < message.collectionIds.length; ++j) + object.collectionIds[j] = message.collectionIds[j]; + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListCollectionIdsResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @instance + * @returns {Object.} JSON object + */ + ListCollectionIdsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListCollectionIdsResponse; + })(); + + v1beta1.StructuredQuery = (function() { + + /** + * Properties of a StructuredQuery. + * @memberof google.firestore.v1beta1 + * @interface IStructuredQuery + * @property {google.firestore.v1beta1.StructuredQuery.IProjection|null} [select] StructuredQuery select + * @property {Array.|null} [from] StructuredQuery from + * @property {google.firestore.v1beta1.StructuredQuery.IFilter|null} [where] StructuredQuery where + * @property {Array.|null} [orderBy] StructuredQuery orderBy + * @property {google.firestore.v1beta1.ICursor|null} [startAt] StructuredQuery startAt + * @property {google.firestore.v1beta1.ICursor|null} [endAt] StructuredQuery endAt + * @property {number|null} [offset] StructuredQuery offset + * @property {google.protobuf.IInt32Value|null} [limit] StructuredQuery limit + */ + + /** + * Constructs a new StructuredQuery. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a StructuredQuery. + * @implements IStructuredQuery + * @constructor + * @param {google.firestore.v1beta1.IStructuredQuery=} [properties] Properties to set + */ + function StructuredQuery(properties) { + this.from = []; + this.orderBy = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StructuredQuery select. + * @member {google.firestore.v1beta1.StructuredQuery.IProjection|null|undefined} select + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.select = null; + + /** + * StructuredQuery from. + * @member {Array.} from + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.from = $util.emptyArray; + + /** + * StructuredQuery where. + * @member {google.firestore.v1beta1.StructuredQuery.IFilter|null|undefined} where + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.where = null; + + /** + * StructuredQuery orderBy. + * @member {Array.} orderBy + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.orderBy = $util.emptyArray; + + /** + * StructuredQuery startAt. + * @member {google.firestore.v1beta1.ICursor|null|undefined} startAt + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.startAt = null; + + /** + * StructuredQuery endAt. + * @member {google.firestore.v1beta1.ICursor|null|undefined} endAt + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.endAt = null; + + /** + * StructuredQuery offset. + * @member {number} offset + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.offset = 0; + + /** + * StructuredQuery limit. + * @member {google.protobuf.IInt32Value|null|undefined} limit + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + */ + StructuredQuery.prototype.limit = null; + + /** + * Creates a StructuredQuery message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.StructuredQuery + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.StructuredQuery} StructuredQuery + */ + StructuredQuery.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.StructuredQuery) + return object; + var message = new $root.google.firestore.v1beta1.StructuredQuery(); + if (object.select != null) { + if (typeof object.select !== "object") + throw TypeError(".google.firestore.v1beta1.StructuredQuery.select: object expected"); + message.select = $root.google.firestore.v1beta1.StructuredQuery.Projection.fromObject(object.select); + } + if (object.from) { + if (!Array.isArray(object.from)) + throw TypeError(".google.firestore.v1beta1.StructuredQuery.from: array expected"); + message.from = []; + for (var i = 0; i < object.from.length; ++i) { + if (typeof object.from[i] !== "object") + throw TypeError(".google.firestore.v1beta1.StructuredQuery.from: object expected"); + message.from[i] = $root.google.firestore.v1beta1.StructuredQuery.CollectionSelector.fromObject(object.from[i]); + } + } + if (object.where != null) { + if (typeof object.where !== "object") + throw TypeError(".google.firestore.v1beta1.StructuredQuery.where: object expected"); + message.where = $root.google.firestore.v1beta1.StructuredQuery.Filter.fromObject(object.where); + } + if (object.orderBy) { + if (!Array.isArray(object.orderBy)) + throw TypeError(".google.firestore.v1beta1.StructuredQuery.orderBy: array expected"); + message.orderBy = []; + for (var i = 0; i < object.orderBy.length; ++i) { + if (typeof object.orderBy[i] !== "object") + throw TypeError(".google.firestore.v1beta1.StructuredQuery.orderBy: object expected"); + message.orderBy[i] = $root.google.firestore.v1beta1.StructuredQuery.Order.fromObject(object.orderBy[i]); + } + } + if (object.startAt != null) { + if (typeof object.startAt !== "object") + throw TypeError(".google.firestore.v1beta1.StructuredQuery.startAt: object expected"); + message.startAt = $root.google.firestore.v1beta1.Cursor.fromObject(object.startAt); + } + if (object.endAt != null) { + if (typeof object.endAt !== "object") + throw TypeError(".google.firestore.v1beta1.StructuredQuery.endAt: object expected"); + message.endAt = $root.google.firestore.v1beta1.Cursor.fromObject(object.endAt); + } + if (object.offset != null) + message.offset = object.offset | 0; + if (object.limit != null) { + if (typeof object.limit !== "object") + throw TypeError(".google.firestore.v1beta1.StructuredQuery.limit: object expected"); + message.limit = $root.google.protobuf.Int32Value.fromObject(object.limit); + } + return message; + }; + + /** + * Creates a plain object from a StructuredQuery message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.StructuredQuery + * @static + * @param {google.firestore.v1beta1.StructuredQuery} message StructuredQuery + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StructuredQuery.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.from = []; + object.orderBy = []; + } + if (options.defaults) { + object.select = null; + object.where = null; + object.limit = null; + object.offset = 0; + object.startAt = null; + object.endAt = null; + } + if (message.select != null && message.hasOwnProperty("select")) + object.select = $root.google.firestore.v1beta1.StructuredQuery.Projection.toObject(message.select, options); + if (message.from && message.from.length) { + object.from = []; + for (var j = 0; j < message.from.length; ++j) + object.from[j] = $root.google.firestore.v1beta1.StructuredQuery.CollectionSelector.toObject(message.from[j], options); + } + if (message.where != null && message.hasOwnProperty("where")) + object.where = $root.google.firestore.v1beta1.StructuredQuery.Filter.toObject(message.where, options); + if (message.orderBy && message.orderBy.length) { + object.orderBy = []; + for (var j = 0; j < message.orderBy.length; ++j) + object.orderBy[j] = $root.google.firestore.v1beta1.StructuredQuery.Order.toObject(message.orderBy[j], options); + } + if (message.limit != null && message.hasOwnProperty("limit")) + object.limit = $root.google.protobuf.Int32Value.toObject(message.limit, options); + if (message.offset != null && message.hasOwnProperty("offset")) + object.offset = message.offset; + if (message.startAt != null && message.hasOwnProperty("startAt")) + object.startAt = $root.google.firestore.v1beta1.Cursor.toObject(message.startAt, options); + if (message.endAt != null && message.hasOwnProperty("endAt")) + object.endAt = $root.google.firestore.v1beta1.Cursor.toObject(message.endAt, options); + return object; + }; + + /** + * Converts this StructuredQuery to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.StructuredQuery + * @instance + * @returns {Object.} JSON object + */ + StructuredQuery.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + StructuredQuery.CollectionSelector = (function() { + + /** + * Properties of a CollectionSelector. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface ICollectionSelector + * @property {string|null} [collectionId] CollectionSelector collectionId + * @property {boolean|null} [allDescendants] CollectionSelector allDescendants + */ + + /** + * Constructs a new CollectionSelector. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents a CollectionSelector. + * @implements ICollectionSelector + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.ICollectionSelector=} [properties] Properties to set + */ + function CollectionSelector(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CollectionSelector collectionId. + * @member {string} collectionId + * @memberof google.firestore.v1beta1.StructuredQuery.CollectionSelector + * @instance + */ + CollectionSelector.prototype.collectionId = ""; + + /** + * CollectionSelector allDescendants. + * @member {boolean} allDescendants + * @memberof google.firestore.v1beta1.StructuredQuery.CollectionSelector + * @instance + */ + CollectionSelector.prototype.allDescendants = false; + + /** + * Creates a CollectionSelector message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.StructuredQuery.CollectionSelector + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.StructuredQuery.CollectionSelector} CollectionSelector + */ + CollectionSelector.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.StructuredQuery.CollectionSelector) + return object; + var message = new $root.google.firestore.v1beta1.StructuredQuery.CollectionSelector(); + if (object.collectionId != null) + message.collectionId = String(object.collectionId); + if (object.allDescendants != null) + message.allDescendants = Boolean(object.allDescendants); + return message; + }; + + /** + * Creates a plain object from a CollectionSelector message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.StructuredQuery.CollectionSelector + * @static + * @param {google.firestore.v1beta1.StructuredQuery.CollectionSelector} message CollectionSelector + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CollectionSelector.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.collectionId = ""; + object.allDescendants = false; + } + if (message.collectionId != null && message.hasOwnProperty("collectionId")) + object.collectionId = message.collectionId; + if (message.allDescendants != null && message.hasOwnProperty("allDescendants")) + object.allDescendants = message.allDescendants; + return object; + }; + + /** + * Converts this CollectionSelector to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.StructuredQuery.CollectionSelector + * @instance + * @returns {Object.} JSON object + */ + CollectionSelector.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CollectionSelector; + })(); + + StructuredQuery.Filter = (function() { + + /** + * Properties of a Filter. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface IFilter + * @property {google.firestore.v1beta1.StructuredQuery.ICompositeFilter|null} [compositeFilter] Filter compositeFilter + * @property {google.firestore.v1beta1.StructuredQuery.IFieldFilter|null} [fieldFilter] Filter fieldFilter + * @property {google.firestore.v1beta1.StructuredQuery.IUnaryFilter|null} [unaryFilter] Filter unaryFilter + */ + + /** + * Constructs a new Filter. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents a Filter. + * @implements IFilter + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.IFilter=} [properties] Properties to set + */ + function Filter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Filter compositeFilter. + * @member {google.firestore.v1beta1.StructuredQuery.ICompositeFilter|null|undefined} compositeFilter + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @instance + */ + Filter.prototype.compositeFilter = null; + + /** + * Filter fieldFilter. + * @member {google.firestore.v1beta1.StructuredQuery.IFieldFilter|null|undefined} fieldFilter + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @instance + */ + Filter.prototype.fieldFilter = null; + + /** + * Filter unaryFilter. + * @member {google.firestore.v1beta1.StructuredQuery.IUnaryFilter|null|undefined} unaryFilter + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @instance + */ + Filter.prototype.unaryFilter = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Filter filterType. + * @member {"compositeFilter"|"fieldFilter"|"unaryFilter"|undefined} filterType + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @instance + */ + Object.defineProperty(Filter.prototype, "filterType", { + get: $util.oneOfGetter($oneOfFields = ["compositeFilter", "fieldFilter", "unaryFilter"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a Filter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.StructuredQuery.Filter} Filter + */ + Filter.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.StructuredQuery.Filter) + return object; + var message = new $root.google.firestore.v1beta1.StructuredQuery.Filter(); + if (object.compositeFilter != null) { + if (typeof object.compositeFilter !== "object") + throw TypeError(".google.firestore.v1beta1.StructuredQuery.Filter.compositeFilter: object expected"); + message.compositeFilter = $root.google.firestore.v1beta1.StructuredQuery.CompositeFilter.fromObject(object.compositeFilter); + } + if (object.fieldFilter != null) { + if (typeof object.fieldFilter !== "object") + throw TypeError(".google.firestore.v1beta1.StructuredQuery.Filter.fieldFilter: object expected"); + message.fieldFilter = $root.google.firestore.v1beta1.StructuredQuery.FieldFilter.fromObject(object.fieldFilter); + } + if (object.unaryFilter != null) { + if (typeof object.unaryFilter !== "object") + throw TypeError(".google.firestore.v1beta1.StructuredQuery.Filter.unaryFilter: object expected"); + message.unaryFilter = $root.google.firestore.v1beta1.StructuredQuery.UnaryFilter.fromObject(object.unaryFilter); + } + return message; + }; + + /** + * Creates a plain object from a Filter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @static + * @param {google.firestore.v1beta1.StructuredQuery.Filter} message Filter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Filter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.compositeFilter != null && message.hasOwnProperty("compositeFilter")) { + object.compositeFilter = $root.google.firestore.v1beta1.StructuredQuery.CompositeFilter.toObject(message.compositeFilter, options); + if (options.oneofs) + object.filterType = "compositeFilter"; + } + if (message.fieldFilter != null && message.hasOwnProperty("fieldFilter")) { + object.fieldFilter = $root.google.firestore.v1beta1.StructuredQuery.FieldFilter.toObject(message.fieldFilter, options); + if (options.oneofs) + object.filterType = "fieldFilter"; + } + if (message.unaryFilter != null && message.hasOwnProperty("unaryFilter")) { + object.unaryFilter = $root.google.firestore.v1beta1.StructuredQuery.UnaryFilter.toObject(message.unaryFilter, options); + if (options.oneofs) + object.filterType = "unaryFilter"; + } + return object; + }; + + /** + * Converts this Filter to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.StructuredQuery.Filter + * @instance + * @returns {Object.} JSON object + */ + Filter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Filter; + })(); + + StructuredQuery.CompositeFilter = (function() { + + /** + * Properties of a CompositeFilter. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface ICompositeFilter + * @property {google.firestore.v1beta1.StructuredQuery.CompositeFilter.Operator|null} [op] CompositeFilter op + * @property {Array.|null} [filters] CompositeFilter filters + */ + + /** + * Constructs a new CompositeFilter. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents a CompositeFilter. + * @implements ICompositeFilter + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.ICompositeFilter=} [properties] Properties to set + */ + function CompositeFilter(properties) { + this.filters = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CompositeFilter op. + * @member {google.firestore.v1beta1.StructuredQuery.CompositeFilter.Operator} op + * @memberof google.firestore.v1beta1.StructuredQuery.CompositeFilter + * @instance + */ + CompositeFilter.prototype.op = 0; + + /** + * CompositeFilter filters. + * @member {Array.} filters + * @memberof google.firestore.v1beta1.StructuredQuery.CompositeFilter + * @instance + */ + CompositeFilter.prototype.filters = $util.emptyArray; + + /** + * Creates a CompositeFilter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.StructuredQuery.CompositeFilter + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.StructuredQuery.CompositeFilter} CompositeFilter + */ + CompositeFilter.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.StructuredQuery.CompositeFilter) + return object; + var message = new $root.google.firestore.v1beta1.StructuredQuery.CompositeFilter(); + switch (object.op) { + case "OPERATOR_UNSPECIFIED": + case 0: + message.op = 0; + break; + case "AND": + case 1: + message.op = 1; + break; + } + if (object.filters) { + if (!Array.isArray(object.filters)) + throw TypeError(".google.firestore.v1beta1.StructuredQuery.CompositeFilter.filters: array expected"); + message.filters = []; + for (var i = 0; i < object.filters.length; ++i) { + if (typeof object.filters[i] !== "object") + throw TypeError(".google.firestore.v1beta1.StructuredQuery.CompositeFilter.filters: object expected"); + message.filters[i] = $root.google.firestore.v1beta1.StructuredQuery.Filter.fromObject(object.filters[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a CompositeFilter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.StructuredQuery.CompositeFilter + * @static + * @param {google.firestore.v1beta1.StructuredQuery.CompositeFilter} message CompositeFilter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompositeFilter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.filters = []; + if (options.defaults) + object.op = options.enums === String ? "OPERATOR_UNSPECIFIED" : 0; + if (message.op != null && message.hasOwnProperty("op")) + object.op = options.enums === String ? $root.google.firestore.v1beta1.StructuredQuery.CompositeFilter.Operator[message.op] : message.op; + if (message.filters && message.filters.length) { + object.filters = []; + for (var j = 0; j < message.filters.length; ++j) + object.filters[j] = $root.google.firestore.v1beta1.StructuredQuery.Filter.toObject(message.filters[j], options); + } + return object; + }; + + /** + * Converts this CompositeFilter to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.StructuredQuery.CompositeFilter + * @instance + * @returns {Object.} JSON object + */ + CompositeFilter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Operator enum. + * @name google.firestore.v1beta1.StructuredQuery.CompositeFilter.Operator + * @enum {string} + * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value + * @property {string} AND=AND AND value + */ + CompositeFilter.Operator = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; + values[valuesById[1] = "AND"] = "AND"; + return values; + })(); + + return CompositeFilter; + })(); + + StructuredQuery.FieldFilter = (function() { + + /** + * Properties of a FieldFilter. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface IFieldFilter + * @property {google.firestore.v1beta1.StructuredQuery.IFieldReference|null} [field] FieldFilter field + * @property {google.firestore.v1beta1.StructuredQuery.FieldFilter.Operator|null} [op] FieldFilter op + * @property {google.firestore.v1beta1.IValue|null} [value] FieldFilter value + */ + + /** + * Constructs a new FieldFilter. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents a FieldFilter. + * @implements IFieldFilter + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.IFieldFilter=} [properties] Properties to set + */ + function FieldFilter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldFilter field. + * @member {google.firestore.v1beta1.StructuredQuery.IFieldReference|null|undefined} field + * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * @instance + */ + FieldFilter.prototype.field = null; + + /** + * FieldFilter op. + * @member {google.firestore.v1beta1.StructuredQuery.FieldFilter.Operator} op + * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * @instance + */ + FieldFilter.prototype.op = 0; + + /** + * FieldFilter value. + * @member {google.firestore.v1beta1.IValue|null|undefined} value + * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * @instance + */ + FieldFilter.prototype.value = null; + + /** + * Creates a FieldFilter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.StructuredQuery.FieldFilter} FieldFilter + */ + FieldFilter.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.StructuredQuery.FieldFilter) + return object; + var message = new $root.google.firestore.v1beta1.StructuredQuery.FieldFilter(); + if (object.field != null) { + if (typeof object.field !== "object") + throw TypeError(".google.firestore.v1beta1.StructuredQuery.FieldFilter.field: object expected"); + message.field = $root.google.firestore.v1beta1.StructuredQuery.FieldReference.fromObject(object.field); + } + switch (object.op) { + case "OPERATOR_UNSPECIFIED": + case 0: + message.op = 0; + break; + case "LESS_THAN": + case 1: + message.op = 1; + break; + case "LESS_THAN_OR_EQUAL": + case 2: + message.op = 2; + break; + case "GREATER_THAN": + case 3: + message.op = 3; + break; + case "GREATER_THAN_OR_EQUAL": + case 4: + message.op = 4; + break; + case "EQUAL": + case 5: + message.op = 5; + break; + case "ARRAY_CONTAINS": + case 7: + message.op = 7; + break; + case "IN": + case 8: + message.op = 8; + break; + case "ARRAY_CONTAINS_ANY": + case 9: + message.op = 9; + break; + } + if (object.value != null) { + if (typeof object.value !== "object") + throw TypeError(".google.firestore.v1beta1.StructuredQuery.FieldFilter.value: object expected"); + message.value = $root.google.firestore.v1beta1.Value.fromObject(object.value); + } + return message; + }; + + /** + * Creates a plain object from a FieldFilter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * @static + * @param {google.firestore.v1beta1.StructuredQuery.FieldFilter} message FieldFilter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldFilter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.field = null; + object.op = options.enums === String ? "OPERATOR_UNSPECIFIED" : 0; + object.value = null; + } + if (message.field != null && message.hasOwnProperty("field")) + object.field = $root.google.firestore.v1beta1.StructuredQuery.FieldReference.toObject(message.field, options); + if (message.op != null && message.hasOwnProperty("op")) + object.op = options.enums === String ? $root.google.firestore.v1beta1.StructuredQuery.FieldFilter.Operator[message.op] : message.op; + if (message.value != null && message.hasOwnProperty("value")) + object.value = $root.google.firestore.v1beta1.Value.toObject(message.value, options); + return object; + }; + + /** + * Converts this FieldFilter to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.StructuredQuery.FieldFilter + * @instance + * @returns {Object.} JSON object + */ + FieldFilter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Operator enum. + * @name google.firestore.v1beta1.StructuredQuery.FieldFilter.Operator + * @enum {string} + * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value + * @property {string} LESS_THAN=LESS_THAN LESS_THAN value + * @property {string} LESS_THAN_OR_EQUAL=LESS_THAN_OR_EQUAL LESS_THAN_OR_EQUAL value + * @property {string} GREATER_THAN=GREATER_THAN GREATER_THAN value + * @property {string} GREATER_THAN_OR_EQUAL=GREATER_THAN_OR_EQUAL GREATER_THAN_OR_EQUAL value + * @property {string} EQUAL=EQUAL EQUAL value + * @property {string} ARRAY_CONTAINS=ARRAY_CONTAINS ARRAY_CONTAINS value + * @property {string} IN=IN IN value + * @property {string} ARRAY_CONTAINS_ANY=ARRAY_CONTAINS_ANY ARRAY_CONTAINS_ANY value + */ + FieldFilter.Operator = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; + values[valuesById[1] = "LESS_THAN"] = "LESS_THAN"; + values[valuesById[2] = "LESS_THAN_OR_EQUAL"] = "LESS_THAN_OR_EQUAL"; + values[valuesById[3] = "GREATER_THAN"] = "GREATER_THAN"; + values[valuesById[4] = "GREATER_THAN_OR_EQUAL"] = "GREATER_THAN_OR_EQUAL"; + values[valuesById[5] = "EQUAL"] = "EQUAL"; + values[valuesById[7] = "ARRAY_CONTAINS"] = "ARRAY_CONTAINS"; + values[valuesById[8] = "IN"] = "IN"; + values[valuesById[9] = "ARRAY_CONTAINS_ANY"] = "ARRAY_CONTAINS_ANY"; + return values; + })(); + + return FieldFilter; + })(); + + StructuredQuery.UnaryFilter = (function() { + + /** + * Properties of an UnaryFilter. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface IUnaryFilter + * @property {google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator|null} [op] UnaryFilter op + * @property {google.firestore.v1beta1.StructuredQuery.IFieldReference|null} [field] UnaryFilter field + */ + + /** + * Constructs a new UnaryFilter. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents an UnaryFilter. + * @implements IUnaryFilter + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.IUnaryFilter=} [properties] Properties to set + */ + function UnaryFilter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UnaryFilter op. + * @member {google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator} op + * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * @instance + */ + UnaryFilter.prototype.op = 0; + + /** + * UnaryFilter field. + * @member {google.firestore.v1beta1.StructuredQuery.IFieldReference|null|undefined} field + * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * @instance + */ + UnaryFilter.prototype.field = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * UnaryFilter operandType. + * @member {"field"|undefined} operandType + * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * @instance + */ + Object.defineProperty(UnaryFilter.prototype, "operandType", { + get: $util.oneOfGetter($oneOfFields = ["field"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates an UnaryFilter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.StructuredQuery.UnaryFilter} UnaryFilter + */ + UnaryFilter.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.StructuredQuery.UnaryFilter) + return object; + var message = new $root.google.firestore.v1beta1.StructuredQuery.UnaryFilter(); + switch (object.op) { + case "OPERATOR_UNSPECIFIED": + case 0: + message.op = 0; + break; + case "IS_NAN": + case 2: + message.op = 2; + break; + case "IS_NULL": + case 3: + message.op = 3; + break; + } + if (object.field != null) { + if (typeof object.field !== "object") + throw TypeError(".google.firestore.v1beta1.StructuredQuery.UnaryFilter.field: object expected"); + message.field = $root.google.firestore.v1beta1.StructuredQuery.FieldReference.fromObject(object.field); + } + return message; + }; + + /** + * Creates a plain object from an UnaryFilter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * @static + * @param {google.firestore.v1beta1.StructuredQuery.UnaryFilter} message UnaryFilter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UnaryFilter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.op = options.enums === String ? "OPERATOR_UNSPECIFIED" : 0; + if (message.op != null && message.hasOwnProperty("op")) + object.op = options.enums === String ? $root.google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator[message.op] : message.op; + if (message.field != null && message.hasOwnProperty("field")) { + object.field = $root.google.firestore.v1beta1.StructuredQuery.FieldReference.toObject(message.field, options); + if (options.oneofs) + object.operandType = "field"; + } + return object; + }; + + /** + * Converts this UnaryFilter to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.StructuredQuery.UnaryFilter + * @instance + * @returns {Object.} JSON object + */ + UnaryFilter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Operator enum. + * @name google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator + * @enum {string} + * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value + * @property {string} IS_NAN=IS_NAN IS_NAN value + * @property {string} IS_NULL=IS_NULL IS_NULL value + */ + UnaryFilter.Operator = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; + values[valuesById[2] = "IS_NAN"] = "IS_NAN"; + values[valuesById[3] = "IS_NULL"] = "IS_NULL"; + return values; + })(); + + return UnaryFilter; + })(); + + StructuredQuery.Order = (function() { + + /** + * Properties of an Order. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface IOrder + * @property {google.firestore.v1beta1.StructuredQuery.IFieldReference|null} [field] Order field + * @property {google.firestore.v1beta1.StructuredQuery.Direction|null} [direction] Order direction + */ + + /** + * Constructs a new Order. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents an Order. + * @implements IOrder + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.IOrder=} [properties] Properties to set + */ + function Order(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Order field. + * @member {google.firestore.v1beta1.StructuredQuery.IFieldReference|null|undefined} field + * @memberof google.firestore.v1beta1.StructuredQuery.Order + * @instance + */ + Order.prototype.field = null; + + /** + * Order direction. + * @member {google.firestore.v1beta1.StructuredQuery.Direction} direction + * @memberof google.firestore.v1beta1.StructuredQuery.Order + * @instance + */ + Order.prototype.direction = 0; + + /** + * Creates an Order message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.StructuredQuery.Order + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.StructuredQuery.Order} Order + */ + Order.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.StructuredQuery.Order) + return object; + var message = new $root.google.firestore.v1beta1.StructuredQuery.Order(); + if (object.field != null) { + if (typeof object.field !== "object") + throw TypeError(".google.firestore.v1beta1.StructuredQuery.Order.field: object expected"); + message.field = $root.google.firestore.v1beta1.StructuredQuery.FieldReference.fromObject(object.field); + } + switch (object.direction) { + case "DIRECTION_UNSPECIFIED": + case 0: + message.direction = 0; + break; + case "ASCENDING": + case 1: + message.direction = 1; + break; + case "DESCENDING": + case 2: + message.direction = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.StructuredQuery.Order + * @static + * @param {google.firestore.v1beta1.StructuredQuery.Order} message Order + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Order.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.field = null; + object.direction = options.enums === String ? "DIRECTION_UNSPECIFIED" : 0; + } + if (message.field != null && message.hasOwnProperty("field")) + object.field = $root.google.firestore.v1beta1.StructuredQuery.FieldReference.toObject(message.field, options); + if (message.direction != null && message.hasOwnProperty("direction")) + object.direction = options.enums === String ? $root.google.firestore.v1beta1.StructuredQuery.Direction[message.direction] : message.direction; + return object; + }; + + /** + * Converts this Order to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.StructuredQuery.Order + * @instance + * @returns {Object.} JSON object + */ + Order.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Order; + })(); + + StructuredQuery.FieldReference = (function() { + + /** + * Properties of a FieldReference. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface IFieldReference + * @property {string|null} [fieldPath] FieldReference fieldPath + */ + + /** + * Constructs a new FieldReference. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents a FieldReference. + * @implements IFieldReference + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.IFieldReference=} [properties] Properties to set + */ + function FieldReference(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldReference fieldPath. + * @member {string} fieldPath + * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference + * @instance + */ + FieldReference.prototype.fieldPath = ""; + + /** + * Creates a FieldReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.StructuredQuery.FieldReference} FieldReference + */ + FieldReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.StructuredQuery.FieldReference) + return object; + var message = new $root.google.firestore.v1beta1.StructuredQuery.FieldReference(); + if (object.fieldPath != null) + message.fieldPath = String(object.fieldPath); + return message; + }; + + /** + * Creates a plain object from a FieldReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference + * @static + * @param {google.firestore.v1beta1.StructuredQuery.FieldReference} message FieldReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.fieldPath = ""; + if (message.fieldPath != null && message.hasOwnProperty("fieldPath")) + object.fieldPath = message.fieldPath; + return object; + }; + + /** + * Converts this FieldReference to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference + * @instance + * @returns {Object.} JSON object + */ + FieldReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FieldReference; + })(); + + StructuredQuery.Projection = (function() { + + /** + * Properties of a Projection. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface IProjection + * @property {Array.|null} [fields] Projection fields + */ + + /** + * Constructs a new Projection. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents a Projection. + * @implements IProjection + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.IProjection=} [properties] Properties to set + */ + function Projection(properties) { + this.fields = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Projection fields. + * @member {Array.} fields + * @memberof google.firestore.v1beta1.StructuredQuery.Projection + * @instance + */ + Projection.prototype.fields = $util.emptyArray; + + /** + * Creates a Projection message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.StructuredQuery.Projection + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.StructuredQuery.Projection} Projection + */ + Projection.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.StructuredQuery.Projection) + return object; + var message = new $root.google.firestore.v1beta1.StructuredQuery.Projection(); + if (object.fields) { + if (!Array.isArray(object.fields)) + throw TypeError(".google.firestore.v1beta1.StructuredQuery.Projection.fields: array expected"); + message.fields = []; + for (var i = 0; i < object.fields.length; ++i) { + if (typeof object.fields[i] !== "object") + throw TypeError(".google.firestore.v1beta1.StructuredQuery.Projection.fields: object expected"); + message.fields[i] = $root.google.firestore.v1beta1.StructuredQuery.FieldReference.fromObject(object.fields[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Projection message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.StructuredQuery.Projection + * @static + * @param {google.firestore.v1beta1.StructuredQuery.Projection} message Projection + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Projection.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.fields = []; + if (message.fields && message.fields.length) { + object.fields = []; + for (var j = 0; j < message.fields.length; ++j) + object.fields[j] = $root.google.firestore.v1beta1.StructuredQuery.FieldReference.toObject(message.fields[j], options); + } + return object; + }; + + /** + * Converts this Projection to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.StructuredQuery.Projection + * @instance + * @returns {Object.} JSON object + */ + Projection.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Projection; + })(); + + /** + * Direction enum. + * @name google.firestore.v1beta1.StructuredQuery.Direction + * @enum {string} + * @property {string} DIRECTION_UNSPECIFIED=DIRECTION_UNSPECIFIED DIRECTION_UNSPECIFIED value + * @property {string} ASCENDING=ASCENDING ASCENDING value + * @property {string} DESCENDING=DESCENDING DESCENDING value + */ + StructuredQuery.Direction = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DIRECTION_UNSPECIFIED"] = "DIRECTION_UNSPECIFIED"; + values[valuesById[1] = "ASCENDING"] = "ASCENDING"; + values[valuesById[2] = "DESCENDING"] = "DESCENDING"; + return values; + })(); + + return StructuredQuery; + })(); + + v1beta1.Cursor = (function() { + + /** + * Properties of a Cursor. + * @memberof google.firestore.v1beta1 + * @interface ICursor + * @property {Array.|null} [values] Cursor values + * @property {boolean|null} [before] Cursor before + */ + + /** + * Constructs a new Cursor. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a Cursor. + * @implements ICursor + * @constructor + * @param {google.firestore.v1beta1.ICursor=} [properties] Properties to set + */ + function Cursor(properties) { + this.values = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Cursor values. + * @member {Array.} values + * @memberof google.firestore.v1beta1.Cursor + * @instance + */ + Cursor.prototype.values = $util.emptyArray; + + /** + * Cursor before. + * @member {boolean} before + * @memberof google.firestore.v1beta1.Cursor + * @instance + */ + Cursor.prototype.before = false; + + /** + * Creates a Cursor message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.Cursor + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.Cursor} Cursor + */ + Cursor.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.Cursor) + return object; + var message = new $root.google.firestore.v1beta1.Cursor(); + if (object.values) { + if (!Array.isArray(object.values)) + throw TypeError(".google.firestore.v1beta1.Cursor.values: array expected"); + message.values = []; + for (var i = 0; i < object.values.length; ++i) { + if (typeof object.values[i] !== "object") + throw TypeError(".google.firestore.v1beta1.Cursor.values: object expected"); + message.values[i] = $root.google.firestore.v1beta1.Value.fromObject(object.values[i]); + } + } + if (object.before != null) + message.before = Boolean(object.before); + return message; + }; + + /** + * Creates a plain object from a Cursor message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.Cursor + * @static + * @param {google.firestore.v1beta1.Cursor} message Cursor + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Cursor.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.values = []; + if (options.defaults) + object.before = false; + if (message.values && message.values.length) { + object.values = []; + for (var j = 0; j < message.values.length; ++j) + object.values[j] = $root.google.firestore.v1beta1.Value.toObject(message.values[j], options); + } + if (message.before != null && message.hasOwnProperty("before")) + object.before = message.before; + return object; + }; + + /** + * Converts this Cursor to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.Cursor + * @instance + * @returns {Object.} JSON object + */ + Cursor.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Cursor; + })(); + + v1beta1.Write = (function() { + + /** + * Properties of a Write. + * @memberof google.firestore.v1beta1 + * @interface IWrite + * @property {google.firestore.v1beta1.IDocument|null} [update] Write update + * @property {string|null} ["delete"] Write delete + * @property {google.firestore.v1beta1.IDocumentTransform|null} [transform] Write transform + * @property {google.firestore.v1beta1.IDocumentMask|null} [updateMask] Write updateMask + * @property {google.firestore.v1beta1.IPrecondition|null} [currentDocument] Write currentDocument + */ + + /** + * Constructs a new Write. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a Write. + * @implements IWrite + * @constructor + * @param {google.firestore.v1beta1.IWrite=} [properties] Properties to set + */ + function Write(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Write update. + * @member {google.firestore.v1beta1.IDocument|null|undefined} update + * @memberof google.firestore.v1beta1.Write + * @instance + */ + Write.prototype.update = null; + + /** + * Write delete. + * @member {string} delete + * @memberof google.firestore.v1beta1.Write + * @instance + */ + Write.prototype["delete"] = ""; + + /** + * Write transform. + * @member {google.firestore.v1beta1.IDocumentTransform|null|undefined} transform + * @memberof google.firestore.v1beta1.Write + * @instance + */ + Write.prototype.transform = null; + + /** + * Write updateMask. + * @member {google.firestore.v1beta1.IDocumentMask|null|undefined} updateMask + * @memberof google.firestore.v1beta1.Write + * @instance + */ + Write.prototype.updateMask = null; + + /** + * Write currentDocument. + * @member {google.firestore.v1beta1.IPrecondition|null|undefined} currentDocument + * @memberof google.firestore.v1beta1.Write + * @instance + */ + Write.prototype.currentDocument = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Write operation. + * @member {"update"|"delete"|"transform"|undefined} operation + * @memberof google.firestore.v1beta1.Write + * @instance + */ + Object.defineProperty(Write.prototype, "operation", { + get: $util.oneOfGetter($oneOfFields = ["update", "delete", "transform"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a Write message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.Write + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.Write} Write + */ + Write.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.Write) + return object; + var message = new $root.google.firestore.v1beta1.Write(); + if (object.update != null) { + if (typeof object.update !== "object") + throw TypeError(".google.firestore.v1beta1.Write.update: object expected"); + message.update = $root.google.firestore.v1beta1.Document.fromObject(object.update); + } + if (object["delete"] != null) + message["delete"] = String(object["delete"]); + if (object.transform != null) { + if (typeof object.transform !== "object") + throw TypeError(".google.firestore.v1beta1.Write.transform: object expected"); + message.transform = $root.google.firestore.v1beta1.DocumentTransform.fromObject(object.transform); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.firestore.v1beta1.Write.updateMask: object expected"); + message.updateMask = $root.google.firestore.v1beta1.DocumentMask.fromObject(object.updateMask); + } + if (object.currentDocument != null) { + if (typeof object.currentDocument !== "object") + throw TypeError(".google.firestore.v1beta1.Write.currentDocument: object expected"); + message.currentDocument = $root.google.firestore.v1beta1.Precondition.fromObject(object.currentDocument); + } + return message; + }; + + /** + * Creates a plain object from a Write message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.Write + * @static + * @param {google.firestore.v1beta1.Write} message Write + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Write.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.updateMask = null; + object.currentDocument = null; + } + if (message.update != null && message.hasOwnProperty("update")) { + object.update = $root.google.firestore.v1beta1.Document.toObject(message.update, options); + if (options.oneofs) + object.operation = "update"; + } + if (message["delete"] != null && message.hasOwnProperty("delete")) { + object["delete"] = message["delete"]; + if (options.oneofs) + object.operation = "delete"; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.firestore.v1beta1.DocumentMask.toObject(message.updateMask, options); + if (message.currentDocument != null && message.hasOwnProperty("currentDocument")) + object.currentDocument = $root.google.firestore.v1beta1.Precondition.toObject(message.currentDocument, options); + if (message.transform != null && message.hasOwnProperty("transform")) { + object.transform = $root.google.firestore.v1beta1.DocumentTransform.toObject(message.transform, options); + if (options.oneofs) + object.operation = "transform"; + } + return object; + }; + + /** + * Converts this Write to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.Write + * @instance + * @returns {Object.} JSON object + */ + Write.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Write; + })(); + + v1beta1.DocumentTransform = (function() { + + /** + * Properties of a DocumentTransform. + * @memberof google.firestore.v1beta1 + * @interface IDocumentTransform + * @property {string|null} [document] DocumentTransform document + * @property {Array.|null} [fieldTransforms] DocumentTransform fieldTransforms + */ + + /** + * Constructs a new DocumentTransform. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a DocumentTransform. + * @implements IDocumentTransform + * @constructor + * @param {google.firestore.v1beta1.IDocumentTransform=} [properties] Properties to set + */ + function DocumentTransform(properties) { + this.fieldTransforms = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentTransform document. + * @member {string} document + * @memberof google.firestore.v1beta1.DocumentTransform + * @instance + */ + DocumentTransform.prototype.document = ""; + + /** + * DocumentTransform fieldTransforms. + * @member {Array.} fieldTransforms + * @memberof google.firestore.v1beta1.DocumentTransform + * @instance + */ + DocumentTransform.prototype.fieldTransforms = $util.emptyArray; + + /** + * Creates a DocumentTransform message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.DocumentTransform + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.DocumentTransform} DocumentTransform + */ + DocumentTransform.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.DocumentTransform) + return object; + var message = new $root.google.firestore.v1beta1.DocumentTransform(); + if (object.document != null) + message.document = String(object.document); + if (object.fieldTransforms) { + if (!Array.isArray(object.fieldTransforms)) + throw TypeError(".google.firestore.v1beta1.DocumentTransform.fieldTransforms: array expected"); + message.fieldTransforms = []; + for (var i = 0; i < object.fieldTransforms.length; ++i) { + if (typeof object.fieldTransforms[i] !== "object") + throw TypeError(".google.firestore.v1beta1.DocumentTransform.fieldTransforms: object expected"); + message.fieldTransforms[i] = $root.google.firestore.v1beta1.DocumentTransform.FieldTransform.fromObject(object.fieldTransforms[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a DocumentTransform message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.DocumentTransform + * @static + * @param {google.firestore.v1beta1.DocumentTransform} message DocumentTransform + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentTransform.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.fieldTransforms = []; + if (options.defaults) + object.document = ""; + if (message.document != null && message.hasOwnProperty("document")) + object.document = message.document; + if (message.fieldTransforms && message.fieldTransforms.length) { + object.fieldTransforms = []; + for (var j = 0; j < message.fieldTransforms.length; ++j) + object.fieldTransforms[j] = $root.google.firestore.v1beta1.DocumentTransform.FieldTransform.toObject(message.fieldTransforms[j], options); + } + return object; + }; + + /** + * Converts this DocumentTransform to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.DocumentTransform + * @instance + * @returns {Object.} JSON object + */ + DocumentTransform.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + DocumentTransform.FieldTransform = (function() { + + /** + * Properties of a FieldTransform. + * @memberof google.firestore.v1beta1.DocumentTransform + * @interface IFieldTransform + * @property {string|null} [fieldPath] FieldTransform fieldPath + * @property {google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue|null} [setToServerValue] FieldTransform setToServerValue + * @property {google.firestore.v1beta1.IValue|null} [increment] FieldTransform increment + * @property {google.firestore.v1beta1.IValue|null} [maximum] FieldTransform maximum + * @property {google.firestore.v1beta1.IValue|null} [minimum] FieldTransform minimum + * @property {google.firestore.v1beta1.IArrayValue|null} [appendMissingElements] FieldTransform appendMissingElements + * @property {google.firestore.v1beta1.IArrayValue|null} [removeAllFromArray] FieldTransform removeAllFromArray + */ + + /** + * Constructs a new FieldTransform. + * @memberof google.firestore.v1beta1.DocumentTransform + * @classdesc Represents a FieldTransform. + * @implements IFieldTransform + * @constructor + * @param {google.firestore.v1beta1.DocumentTransform.IFieldTransform=} [properties] Properties to set + */ + function FieldTransform(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldTransform fieldPath. + * @member {string} fieldPath + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.fieldPath = ""; + + /** + * FieldTransform setToServerValue. + * @member {google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue} setToServerValue + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.setToServerValue = 0; + + /** + * FieldTransform increment. + * @member {google.firestore.v1beta1.IValue|null|undefined} increment + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.increment = null; + + /** + * FieldTransform maximum. + * @member {google.firestore.v1beta1.IValue|null|undefined} maximum + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.maximum = null; + + /** + * FieldTransform minimum. + * @member {google.firestore.v1beta1.IValue|null|undefined} minimum + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.minimum = null; + + /** + * FieldTransform appendMissingElements. + * @member {google.firestore.v1beta1.IArrayValue|null|undefined} appendMissingElements + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.appendMissingElements = null; + + /** + * FieldTransform removeAllFromArray. + * @member {google.firestore.v1beta1.IArrayValue|null|undefined} removeAllFromArray + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + FieldTransform.prototype.removeAllFromArray = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * FieldTransform transformType. + * @member {"setToServerValue"|"increment"|"maximum"|"minimum"|"appendMissingElements"|"removeAllFromArray"|undefined} transformType + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + */ + Object.defineProperty(FieldTransform.prototype, "transformType", { + get: $util.oneOfGetter($oneOfFields = ["setToServerValue", "increment", "maximum", "minimum", "appendMissingElements", "removeAllFromArray"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a FieldTransform message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.DocumentTransform.FieldTransform} FieldTransform + */ + FieldTransform.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.DocumentTransform.FieldTransform) + return object; + var message = new $root.google.firestore.v1beta1.DocumentTransform.FieldTransform(); + if (object.fieldPath != null) + message.fieldPath = String(object.fieldPath); + switch (object.setToServerValue) { + case "SERVER_VALUE_UNSPECIFIED": + case 0: + message.setToServerValue = 0; + break; + case "REQUEST_TIME": + case 1: + message.setToServerValue = 1; + break; + } + if (object.increment != null) { + if (typeof object.increment !== "object") + throw TypeError(".google.firestore.v1beta1.DocumentTransform.FieldTransform.increment: object expected"); + message.increment = $root.google.firestore.v1beta1.Value.fromObject(object.increment); + } + if (object.maximum != null) { + if (typeof object.maximum !== "object") + throw TypeError(".google.firestore.v1beta1.DocumentTransform.FieldTransform.maximum: object expected"); + message.maximum = $root.google.firestore.v1beta1.Value.fromObject(object.maximum); + } + if (object.minimum != null) { + if (typeof object.minimum !== "object") + throw TypeError(".google.firestore.v1beta1.DocumentTransform.FieldTransform.minimum: object expected"); + message.minimum = $root.google.firestore.v1beta1.Value.fromObject(object.minimum); + } + if (object.appendMissingElements != null) { + if (typeof object.appendMissingElements !== "object") + throw TypeError(".google.firestore.v1beta1.DocumentTransform.FieldTransform.appendMissingElements: object expected"); + message.appendMissingElements = $root.google.firestore.v1beta1.ArrayValue.fromObject(object.appendMissingElements); + } + if (object.removeAllFromArray != null) { + if (typeof object.removeAllFromArray !== "object") + throw TypeError(".google.firestore.v1beta1.DocumentTransform.FieldTransform.removeAllFromArray: object expected"); + message.removeAllFromArray = $root.google.firestore.v1beta1.ArrayValue.fromObject(object.removeAllFromArray); + } + return message; + }; + + /** + * Creates a plain object from a FieldTransform message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @static + * @param {google.firestore.v1beta1.DocumentTransform.FieldTransform} message FieldTransform + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldTransform.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.fieldPath = ""; + if (message.fieldPath != null && message.hasOwnProperty("fieldPath")) + object.fieldPath = message.fieldPath; + if (message.setToServerValue != null && message.hasOwnProperty("setToServerValue")) { + object.setToServerValue = options.enums === String ? $root.google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue[message.setToServerValue] : message.setToServerValue; + if (options.oneofs) + object.transformType = "setToServerValue"; + } + if (message.increment != null && message.hasOwnProperty("increment")) { + object.increment = $root.google.firestore.v1beta1.Value.toObject(message.increment, options); + if (options.oneofs) + object.transformType = "increment"; + } + if (message.maximum != null && message.hasOwnProperty("maximum")) { + object.maximum = $root.google.firestore.v1beta1.Value.toObject(message.maximum, options); + if (options.oneofs) + object.transformType = "maximum"; + } + if (message.minimum != null && message.hasOwnProperty("minimum")) { + object.minimum = $root.google.firestore.v1beta1.Value.toObject(message.minimum, options); + if (options.oneofs) + object.transformType = "minimum"; + } + if (message.appendMissingElements != null && message.hasOwnProperty("appendMissingElements")) { + object.appendMissingElements = $root.google.firestore.v1beta1.ArrayValue.toObject(message.appendMissingElements, options); + if (options.oneofs) + object.transformType = "appendMissingElements"; + } + if (message.removeAllFromArray != null && message.hasOwnProperty("removeAllFromArray")) { + object.removeAllFromArray = $root.google.firestore.v1beta1.ArrayValue.toObject(message.removeAllFromArray, options); + if (options.oneofs) + object.transformType = "removeAllFromArray"; + } + return object; + }; + + /** + * Converts this FieldTransform to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform + * @instance + * @returns {Object.} JSON object + */ + FieldTransform.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * ServerValue enum. + * @name google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue + * @enum {string} + * @property {string} SERVER_VALUE_UNSPECIFIED=SERVER_VALUE_UNSPECIFIED SERVER_VALUE_UNSPECIFIED value + * @property {string} REQUEST_TIME=REQUEST_TIME REQUEST_TIME value + */ + FieldTransform.ServerValue = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SERVER_VALUE_UNSPECIFIED"] = "SERVER_VALUE_UNSPECIFIED"; + values[valuesById[1] = "REQUEST_TIME"] = "REQUEST_TIME"; + return values; + })(); + + return FieldTransform; + })(); + + return DocumentTransform; + })(); + + v1beta1.WriteResult = (function() { + + /** + * Properties of a WriteResult. + * @memberof google.firestore.v1beta1 + * @interface IWriteResult + * @property {google.protobuf.ITimestamp|null} [updateTime] WriteResult updateTime + * @property {Array.|null} [transformResults] WriteResult transformResults + */ + + /** + * Constructs a new WriteResult. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a WriteResult. + * @implements IWriteResult + * @constructor + * @param {google.firestore.v1beta1.IWriteResult=} [properties] Properties to set + */ + function WriteResult(properties) { + this.transformResults = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WriteResult updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.firestore.v1beta1.WriteResult + * @instance + */ + WriteResult.prototype.updateTime = null; + + /** + * WriteResult transformResults. + * @member {Array.} transformResults + * @memberof google.firestore.v1beta1.WriteResult + * @instance + */ + WriteResult.prototype.transformResults = $util.emptyArray; + + /** + * Creates a WriteResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.WriteResult + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.WriteResult} WriteResult + */ + WriteResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.WriteResult) + return object; + var message = new $root.google.firestore.v1beta1.WriteResult(); + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.firestore.v1beta1.WriteResult.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.transformResults) { + if (!Array.isArray(object.transformResults)) + throw TypeError(".google.firestore.v1beta1.WriteResult.transformResults: array expected"); + message.transformResults = []; + for (var i = 0; i < object.transformResults.length; ++i) { + if (typeof object.transformResults[i] !== "object") + throw TypeError(".google.firestore.v1beta1.WriteResult.transformResults: object expected"); + message.transformResults[i] = $root.google.firestore.v1beta1.Value.fromObject(object.transformResults[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a WriteResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.WriteResult + * @static + * @param {google.firestore.v1beta1.WriteResult} message WriteResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WriteResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.transformResults = []; + if (options.defaults) + object.updateTime = null; + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.transformResults && message.transformResults.length) { + object.transformResults = []; + for (var j = 0; j < message.transformResults.length; ++j) + object.transformResults[j] = $root.google.firestore.v1beta1.Value.toObject(message.transformResults[j], options); + } + return object; + }; + + /** + * Converts this WriteResult to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.WriteResult + * @instance + * @returns {Object.} JSON object + */ + WriteResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return WriteResult; + })(); + + v1beta1.DocumentChange = (function() { + + /** + * Properties of a DocumentChange. + * @memberof google.firestore.v1beta1 + * @interface IDocumentChange + * @property {google.firestore.v1beta1.IDocument|null} [document] DocumentChange document + * @property {Array.|null} [targetIds] DocumentChange targetIds + * @property {Array.|null} [removedTargetIds] DocumentChange removedTargetIds + */ + + /** + * Constructs a new DocumentChange. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a DocumentChange. + * @implements IDocumentChange + * @constructor + * @param {google.firestore.v1beta1.IDocumentChange=} [properties] Properties to set + */ + function DocumentChange(properties) { + this.targetIds = []; + this.removedTargetIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentChange document. + * @member {google.firestore.v1beta1.IDocument|null|undefined} document + * @memberof google.firestore.v1beta1.DocumentChange + * @instance + */ + DocumentChange.prototype.document = null; + + /** + * DocumentChange targetIds. + * @member {Array.} targetIds + * @memberof google.firestore.v1beta1.DocumentChange + * @instance + */ + DocumentChange.prototype.targetIds = $util.emptyArray; + + /** + * DocumentChange removedTargetIds. + * @member {Array.} removedTargetIds + * @memberof google.firestore.v1beta1.DocumentChange + * @instance + */ + DocumentChange.prototype.removedTargetIds = $util.emptyArray; + + /** + * Creates a DocumentChange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.DocumentChange + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.DocumentChange} DocumentChange + */ + DocumentChange.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.DocumentChange) + return object; + var message = new $root.google.firestore.v1beta1.DocumentChange(); + if (object.document != null) { + if (typeof object.document !== "object") + throw TypeError(".google.firestore.v1beta1.DocumentChange.document: object expected"); + message.document = $root.google.firestore.v1beta1.Document.fromObject(object.document); + } + if (object.targetIds) { + if (!Array.isArray(object.targetIds)) + throw TypeError(".google.firestore.v1beta1.DocumentChange.targetIds: array expected"); + message.targetIds = []; + for (var i = 0; i < object.targetIds.length; ++i) + message.targetIds[i] = object.targetIds[i] | 0; + } + if (object.removedTargetIds) { + if (!Array.isArray(object.removedTargetIds)) + throw TypeError(".google.firestore.v1beta1.DocumentChange.removedTargetIds: array expected"); + message.removedTargetIds = []; + for (var i = 0; i < object.removedTargetIds.length; ++i) + message.removedTargetIds[i] = object.removedTargetIds[i] | 0; + } + return message; + }; + + /** + * Creates a plain object from a DocumentChange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.DocumentChange + * @static + * @param {google.firestore.v1beta1.DocumentChange} message DocumentChange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentChange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.targetIds = []; + object.removedTargetIds = []; + } + if (options.defaults) + object.document = null; + if (message.document != null && message.hasOwnProperty("document")) + object.document = $root.google.firestore.v1beta1.Document.toObject(message.document, options); + if (message.targetIds && message.targetIds.length) { + object.targetIds = []; + for (var j = 0; j < message.targetIds.length; ++j) + object.targetIds[j] = message.targetIds[j]; + } + if (message.removedTargetIds && message.removedTargetIds.length) { + object.removedTargetIds = []; + for (var j = 0; j < message.removedTargetIds.length; ++j) + object.removedTargetIds[j] = message.removedTargetIds[j]; + } + return object; + }; + + /** + * Converts this DocumentChange to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.DocumentChange + * @instance + * @returns {Object.} JSON object + */ + DocumentChange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DocumentChange; + })(); + + v1beta1.DocumentDelete = (function() { + + /** + * Properties of a DocumentDelete. + * @memberof google.firestore.v1beta1 + * @interface IDocumentDelete + * @property {string|null} [document] DocumentDelete document + * @property {Array.|null} [removedTargetIds] DocumentDelete removedTargetIds + * @property {google.protobuf.ITimestamp|null} [readTime] DocumentDelete readTime + */ + + /** + * Constructs a new DocumentDelete. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a DocumentDelete. + * @implements IDocumentDelete + * @constructor + * @param {google.firestore.v1beta1.IDocumentDelete=} [properties] Properties to set + */ + function DocumentDelete(properties) { + this.removedTargetIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentDelete document. + * @member {string} document + * @memberof google.firestore.v1beta1.DocumentDelete + * @instance + */ + DocumentDelete.prototype.document = ""; + + /** + * DocumentDelete removedTargetIds. + * @member {Array.} removedTargetIds + * @memberof google.firestore.v1beta1.DocumentDelete + * @instance + */ + DocumentDelete.prototype.removedTargetIds = $util.emptyArray; + + /** + * DocumentDelete readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.DocumentDelete + * @instance + */ + DocumentDelete.prototype.readTime = null; + + /** + * Creates a DocumentDelete message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.DocumentDelete + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.DocumentDelete} DocumentDelete + */ + DocumentDelete.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.DocumentDelete) + return object; + var message = new $root.google.firestore.v1beta1.DocumentDelete(); + if (object.document != null) + message.document = String(object.document); + if (object.removedTargetIds) { + if (!Array.isArray(object.removedTargetIds)) + throw TypeError(".google.firestore.v1beta1.DocumentDelete.removedTargetIds: array expected"); + message.removedTargetIds = []; + for (var i = 0; i < object.removedTargetIds.length; ++i) + message.removedTargetIds[i] = object.removedTargetIds[i] | 0; + } + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1beta1.DocumentDelete.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a DocumentDelete message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.DocumentDelete + * @static + * @param {google.firestore.v1beta1.DocumentDelete} message DocumentDelete + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentDelete.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.removedTargetIds = []; + if (options.defaults) { + object.document = ""; + object.readTime = null; + } + if (message.document != null && message.hasOwnProperty("document")) + object.document = message.document; + if (message.readTime != null && message.hasOwnProperty("readTime")) + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (message.removedTargetIds && message.removedTargetIds.length) { + object.removedTargetIds = []; + for (var j = 0; j < message.removedTargetIds.length; ++j) + object.removedTargetIds[j] = message.removedTargetIds[j]; + } + return object; + }; + + /** + * Converts this DocumentDelete to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.DocumentDelete + * @instance + * @returns {Object.} JSON object + */ + DocumentDelete.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DocumentDelete; + })(); + + v1beta1.DocumentRemove = (function() { + + /** + * Properties of a DocumentRemove. + * @memberof google.firestore.v1beta1 + * @interface IDocumentRemove + * @property {string|null} [document] DocumentRemove document + * @property {Array.|null} [removedTargetIds] DocumentRemove removedTargetIds + * @property {google.protobuf.ITimestamp|null} [readTime] DocumentRemove readTime + */ + + /** + * Constructs a new DocumentRemove. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a DocumentRemove. + * @implements IDocumentRemove + * @constructor + * @param {google.firestore.v1beta1.IDocumentRemove=} [properties] Properties to set + */ + function DocumentRemove(properties) { + this.removedTargetIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentRemove document. + * @member {string} document + * @memberof google.firestore.v1beta1.DocumentRemove + * @instance + */ + DocumentRemove.prototype.document = ""; + + /** + * DocumentRemove removedTargetIds. + * @member {Array.} removedTargetIds + * @memberof google.firestore.v1beta1.DocumentRemove + * @instance + */ + DocumentRemove.prototype.removedTargetIds = $util.emptyArray; + + /** + * DocumentRemove readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.firestore.v1beta1.DocumentRemove + * @instance + */ + DocumentRemove.prototype.readTime = null; + + /** + * Creates a DocumentRemove message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.DocumentRemove + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.DocumentRemove} DocumentRemove + */ + DocumentRemove.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.DocumentRemove) + return object; + var message = new $root.google.firestore.v1beta1.DocumentRemove(); + if (object.document != null) + message.document = String(object.document); + if (object.removedTargetIds) { + if (!Array.isArray(object.removedTargetIds)) + throw TypeError(".google.firestore.v1beta1.DocumentRemove.removedTargetIds: array expected"); + message.removedTargetIds = []; + for (var i = 0; i < object.removedTargetIds.length; ++i) + message.removedTargetIds[i] = object.removedTargetIds[i] | 0; + } + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.firestore.v1beta1.DocumentRemove.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a DocumentRemove message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.DocumentRemove + * @static + * @param {google.firestore.v1beta1.DocumentRemove} message DocumentRemove + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentRemove.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.removedTargetIds = []; + if (options.defaults) { + object.document = ""; + object.readTime = null; + } + if (message.document != null && message.hasOwnProperty("document")) + object.document = message.document; + if (message.removedTargetIds && message.removedTargetIds.length) { + object.removedTargetIds = []; + for (var j = 0; j < message.removedTargetIds.length; ++j) + object.removedTargetIds[j] = message.removedTargetIds[j]; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + return object; + }; + + /** + * Converts this DocumentRemove to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.DocumentRemove + * @instance + * @returns {Object.} JSON object + */ + DocumentRemove.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DocumentRemove; + })(); + + v1beta1.ExistenceFilter = (function() { + + /** + * Properties of an ExistenceFilter. + * @memberof google.firestore.v1beta1 + * @interface IExistenceFilter + * @property {number|null} [targetId] ExistenceFilter targetId + * @property {number|null} [count] ExistenceFilter count + */ + + /** + * Constructs a new ExistenceFilter. + * @memberof google.firestore.v1beta1 + * @classdesc Represents an ExistenceFilter. + * @implements IExistenceFilter + * @constructor + * @param {google.firestore.v1beta1.IExistenceFilter=} [properties] Properties to set + */ + function ExistenceFilter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExistenceFilter targetId. + * @member {number} targetId + * @memberof google.firestore.v1beta1.ExistenceFilter + * @instance + */ + ExistenceFilter.prototype.targetId = 0; + + /** + * ExistenceFilter count. + * @member {number} count + * @memberof google.firestore.v1beta1.ExistenceFilter + * @instance + */ + ExistenceFilter.prototype.count = 0; + + /** + * Creates an ExistenceFilter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.ExistenceFilter + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.ExistenceFilter} ExistenceFilter + */ + ExistenceFilter.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.ExistenceFilter) + return object; + var message = new $root.google.firestore.v1beta1.ExistenceFilter(); + if (object.targetId != null) + message.targetId = object.targetId | 0; + if (object.count != null) + message.count = object.count | 0; + return message; + }; + + /** + * Creates a plain object from an ExistenceFilter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.ExistenceFilter + * @static + * @param {google.firestore.v1beta1.ExistenceFilter} message ExistenceFilter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExistenceFilter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.targetId = 0; + object.count = 0; + } + if (message.targetId != null && message.hasOwnProperty("targetId")) + object.targetId = message.targetId; + if (message.count != null && message.hasOwnProperty("count")) + object.count = message.count; + return object; + }; + + /** + * Converts this ExistenceFilter to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.ExistenceFilter + * @instance + * @returns {Object.} JSON object + */ + ExistenceFilter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ExistenceFilter; + })(); + + return v1beta1; + })(); + + return firestore; })(); - - longrunning.DeleteOperationRequest = (function() { - - /** - * Properties of a DeleteOperationRequest. - * @memberof google.longrunning - * @interface IDeleteOperationRequest - * @property {string|null} [name] DeleteOperationRequest name - */ - + + google.api = (function() { + /** - * Constructs a new DeleteOperationRequest. - * @memberof google.longrunning - * @classdesc Represents a DeleteOperationRequest. - * @implements IDeleteOperationRequest - * @constructor - * @param {google.longrunning.IDeleteOperationRequest=} [properties] Properties to set - */ - function DeleteOperationRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DeleteOperationRequest name. - * @member {string} name - * @memberof google.longrunning.DeleteOperationRequest - * @instance + * Namespace api. + * @memberof google + * @namespace */ - DeleteOperationRequest.prototype.name = ""; - - return DeleteOperationRequest; + var api = {}; + + api.Http = (function() { + + /** + * Properties of a Http. + * @memberof google.api + * @interface IHttp + * @property {Array.|null} [rules] Http rules + */ + + /** + * Constructs a new Http. + * @memberof google.api + * @classdesc Represents a Http. + * @implements IHttp + * @constructor + * @param {google.api.IHttp=} [properties] Properties to set + */ + function Http(properties) { + this.rules = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Http rules. + * @member {Array.} rules + * @memberof google.api.Http + * @instance + */ + Http.prototype.rules = $util.emptyArray; + + /** + * Creates a Http message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.Http + * @static + * @param {Object.} object Plain object + * @returns {google.api.Http} Http + */ + Http.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.Http) + return object; + var message = new $root.google.api.Http(); + if (object.rules) { + if (!Array.isArray(object.rules)) + throw TypeError(".google.api.Http.rules: array expected"); + message.rules = []; + for (var i = 0; i < object.rules.length; ++i) { + if (typeof object.rules[i] !== "object") + throw TypeError(".google.api.Http.rules: object expected"); + message.rules[i] = $root.google.api.HttpRule.fromObject(object.rules[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Http message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.Http + * @static + * @param {google.api.Http} message Http + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Http.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.rules = []; + if (message.rules && message.rules.length) { + object.rules = []; + for (var j = 0; j < message.rules.length; ++j) + object.rules[j] = $root.google.api.HttpRule.toObject(message.rules[j], options); + } + return object; + }; + + /** + * Converts this Http to JSON. + * @function toJSON + * @memberof google.api.Http + * @instance + * @returns {Object.} JSON object + */ + Http.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Http; + })(); + + api.HttpRule = (function() { + + /** + * Properties of a HttpRule. + * @memberof google.api + * @interface IHttpRule + * @property {string|null} [get] HttpRule get + * @property {string|null} [put] HttpRule put + * @property {string|null} [post] HttpRule post + * @property {string|null} ["delete"] HttpRule delete + * @property {string|null} [patch] HttpRule patch + * @property {google.api.ICustomHttpPattern|null} [custom] HttpRule custom + * @property {string|null} [selector] HttpRule selector + * @property {string|null} [body] HttpRule body + * @property {Array.|null} [additionalBindings] HttpRule additionalBindings + */ + + /** + * Constructs a new HttpRule. + * @memberof google.api + * @classdesc Represents a HttpRule. + * @implements IHttpRule + * @constructor + * @param {google.api.IHttpRule=} [properties] Properties to set + */ + function HttpRule(properties) { + this.additionalBindings = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * HttpRule get. + * @member {string} get + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.get = ""; + + /** + * HttpRule put. + * @member {string} put + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.put = ""; + + /** + * HttpRule post. + * @member {string} post + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.post = ""; + + /** + * HttpRule delete. + * @member {string} delete + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype["delete"] = ""; + + /** + * HttpRule patch. + * @member {string} patch + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.patch = ""; + + /** + * HttpRule custom. + * @member {google.api.ICustomHttpPattern|null|undefined} custom + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.custom = null; + + /** + * HttpRule selector. + * @member {string} selector + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.selector = ""; + + /** + * HttpRule body. + * @member {string} body + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.body = ""; + + /** + * HttpRule additionalBindings. + * @member {Array.} additionalBindings + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.additionalBindings = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * HttpRule pattern. + * @member {"get"|"put"|"post"|"delete"|"patch"|"custom"|undefined} pattern + * @memberof google.api.HttpRule + * @instance + */ + Object.defineProperty(HttpRule.prototype, "pattern", { + get: $util.oneOfGetter($oneOfFields = ["get", "put", "post", "delete", "patch", "custom"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a HttpRule message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.HttpRule + * @static + * @param {Object.} object Plain object + * @returns {google.api.HttpRule} HttpRule + */ + HttpRule.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.HttpRule) + return object; + var message = new $root.google.api.HttpRule(); + if (object.get != null) + message.get = String(object.get); + if (object.put != null) + message.put = String(object.put); + if (object.post != null) + message.post = String(object.post); + if (object["delete"] != null) + message["delete"] = String(object["delete"]); + if (object.patch != null) + message.patch = String(object.patch); + if (object.custom != null) { + if (typeof object.custom !== "object") + throw TypeError(".google.api.HttpRule.custom: object expected"); + message.custom = $root.google.api.CustomHttpPattern.fromObject(object.custom); + } + if (object.selector != null) + message.selector = String(object.selector); + if (object.body != null) + message.body = String(object.body); + if (object.additionalBindings) { + if (!Array.isArray(object.additionalBindings)) + throw TypeError(".google.api.HttpRule.additionalBindings: array expected"); + message.additionalBindings = []; + for (var i = 0; i < object.additionalBindings.length; ++i) { + if (typeof object.additionalBindings[i] !== "object") + throw TypeError(".google.api.HttpRule.additionalBindings: object expected"); + message.additionalBindings[i] = $root.google.api.HttpRule.fromObject(object.additionalBindings[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a HttpRule message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.HttpRule + * @static + * @param {google.api.HttpRule} message HttpRule + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HttpRule.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.additionalBindings = []; + if (options.defaults) { + object.selector = ""; + object.body = ""; + } + if (message.selector != null && message.hasOwnProperty("selector")) + object.selector = message.selector; + if (message.get != null && message.hasOwnProperty("get")) { + object.get = message.get; + if (options.oneofs) + object.pattern = "get"; + } + if (message.put != null && message.hasOwnProperty("put")) { + object.put = message.put; + if (options.oneofs) + object.pattern = "put"; + } + if (message.post != null && message.hasOwnProperty("post")) { + object.post = message.post; + if (options.oneofs) + object.pattern = "post"; + } + if (message["delete"] != null && message.hasOwnProperty("delete")) { + object["delete"] = message["delete"]; + if (options.oneofs) + object.pattern = "delete"; + } + if (message.patch != null && message.hasOwnProperty("patch")) { + object.patch = message.patch; + if (options.oneofs) + object.pattern = "patch"; + } + if (message.body != null && message.hasOwnProperty("body")) + object.body = message.body; + if (message.custom != null && message.hasOwnProperty("custom")) { + object.custom = $root.google.api.CustomHttpPattern.toObject(message.custom, options); + if (options.oneofs) + object.pattern = "custom"; + } + if (message.additionalBindings && message.additionalBindings.length) { + object.additionalBindings = []; + for (var j = 0; j < message.additionalBindings.length; ++j) + object.additionalBindings[j] = $root.google.api.HttpRule.toObject(message.additionalBindings[j], options); + } + return object; + }; + + /** + * Converts this HttpRule to JSON. + * @function toJSON + * @memberof google.api.HttpRule + * @instance + * @returns {Object.} JSON object + */ + HttpRule.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return HttpRule; + })(); + + api.CustomHttpPattern = (function() { + + /** + * Properties of a CustomHttpPattern. + * @memberof google.api + * @interface ICustomHttpPattern + * @property {string|null} [kind] CustomHttpPattern kind + * @property {string|null} [path] CustomHttpPattern path + */ + + /** + * Constructs a new CustomHttpPattern. + * @memberof google.api + * @classdesc Represents a CustomHttpPattern. + * @implements ICustomHttpPattern + * @constructor + * @param {google.api.ICustomHttpPattern=} [properties] Properties to set + */ + function CustomHttpPattern(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CustomHttpPattern kind. + * @member {string} kind + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.kind = ""; + + /** + * CustomHttpPattern path. + * @member {string} path + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.path = ""; + + /** + * Creates a CustomHttpPattern message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.CustomHttpPattern + * @static + * @param {Object.} object Plain object + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + */ + CustomHttpPattern.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.CustomHttpPattern) + return object; + var message = new $root.google.api.CustomHttpPattern(); + if (object.kind != null) + message.kind = String(object.kind); + if (object.path != null) + message.path = String(object.path); + return message; + }; + + /** + * Creates a plain object from a CustomHttpPattern message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.CustomHttpPattern} message CustomHttpPattern + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CustomHttpPattern.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.kind = ""; + object.path = ""; + } + if (message.kind != null && message.hasOwnProperty("kind")) + object.kind = message.kind; + if (message.path != null && message.hasOwnProperty("path")) + object.path = message.path; + return object; + }; + + /** + * Converts this CustomHttpPattern to JSON. + * @function toJSON + * @memberof google.api.CustomHttpPattern + * @instance + * @returns {Object.} JSON object + */ + CustomHttpPattern.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CustomHttpPattern; + })(); + + /** + * FieldBehavior enum. + * @name google.api.FieldBehavior + * @enum {string} + * @property {string} FIELD_BEHAVIOR_UNSPECIFIED=FIELD_BEHAVIOR_UNSPECIFIED FIELD_BEHAVIOR_UNSPECIFIED value + * @property {string} OPTIONAL=OPTIONAL OPTIONAL value + * @property {string} REQUIRED=REQUIRED REQUIRED value + * @property {string} OUTPUT_ONLY=OUTPUT_ONLY OUTPUT_ONLY value + * @property {string} INPUT_ONLY=INPUT_ONLY INPUT_ONLY value + * @property {string} IMMUTABLE=IMMUTABLE IMMUTABLE value + */ + api.FieldBehavior = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "FIELD_BEHAVIOR_UNSPECIFIED"] = "FIELD_BEHAVIOR_UNSPECIFIED"; + values[valuesById[1] = "OPTIONAL"] = "OPTIONAL"; + values[valuesById[2] = "REQUIRED"] = "REQUIRED"; + values[valuesById[3] = "OUTPUT_ONLY"] = "OUTPUT_ONLY"; + values[valuesById[4] = "INPUT_ONLY"] = "INPUT_ONLY"; + values[valuesById[5] = "IMMUTABLE"] = "IMMUTABLE"; + return values; + })(); + + api.ResourceDescriptor = (function() { + + /** + * Properties of a ResourceDescriptor. + * @memberof google.api + * @interface IResourceDescriptor + * @property {string|null} [type] ResourceDescriptor type + * @property {Array.|null} [pattern] ResourceDescriptor pattern + * @property {string|null} [nameField] ResourceDescriptor nameField + * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history + * @property {string|null} [plural] ResourceDescriptor plural + * @property {string|null} [singular] ResourceDescriptor singular + */ + + /** + * Constructs a new ResourceDescriptor. + * @memberof google.api + * @classdesc Represents a ResourceDescriptor. + * @implements IResourceDescriptor + * @constructor + * @param {google.api.IResourceDescriptor=} [properties] Properties to set + */ + function ResourceDescriptor(properties) { + this.pattern = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResourceDescriptor type. + * @member {string} type + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.type = ""; + + /** + * ResourceDescriptor pattern. + * @member {Array.} pattern + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.pattern = $util.emptyArray; + + /** + * ResourceDescriptor nameField. + * @member {string} nameField + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.nameField = ""; + + /** + * ResourceDescriptor history. + * @member {google.api.ResourceDescriptor.History} history + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.history = 0; + + /** + * ResourceDescriptor plural. + * @member {string} plural + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.plural = ""; + + /** + * ResourceDescriptor singular. + * @member {string} singular + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.singular = ""; + + /** + * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.ResourceDescriptor + * @static + * @param {Object.} object Plain object + * @returns {google.api.ResourceDescriptor} ResourceDescriptor + */ + ResourceDescriptor.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.ResourceDescriptor) + return object; + var message = new $root.google.api.ResourceDescriptor(); + if (object.type != null) + message.type = String(object.type); + if (object.pattern) { + if (!Array.isArray(object.pattern)) + throw TypeError(".google.api.ResourceDescriptor.pattern: array expected"); + message.pattern = []; + for (var i = 0; i < object.pattern.length; ++i) + message.pattern[i] = String(object.pattern[i]); + } + if (object.nameField != null) + message.nameField = String(object.nameField); + switch (object.history) { + case "HISTORY_UNSPECIFIED": + case 0: + message.history = 0; + break; + case "ORIGINALLY_SINGLE_PATTERN": + case 1: + message.history = 1; + break; + case "FUTURE_MULTI_PATTERN": + case 2: + message.history = 2; + break; + } + if (object.plural != null) + message.plural = String(object.plural); + if (object.singular != null) + message.singular = String(object.singular); + return message; + }; + + /** + * Creates a plain object from a ResourceDescriptor message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.ResourceDescriptor + * @static + * @param {google.api.ResourceDescriptor} message ResourceDescriptor + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResourceDescriptor.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.pattern = []; + if (options.defaults) { + object.type = ""; + object.nameField = ""; + object.history = options.enums === String ? "HISTORY_UNSPECIFIED" : 0; + object.plural = ""; + object.singular = ""; + } + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.pattern && message.pattern.length) { + object.pattern = []; + for (var j = 0; j < message.pattern.length; ++j) + object.pattern[j] = message.pattern[j]; + } + if (message.nameField != null && message.hasOwnProperty("nameField")) + object.nameField = message.nameField; + if (message.history != null && message.hasOwnProperty("history")) + object.history = options.enums === String ? $root.google.api.ResourceDescriptor.History[message.history] : message.history; + if (message.plural != null && message.hasOwnProperty("plural")) + object.plural = message.plural; + if (message.singular != null && message.hasOwnProperty("singular")) + object.singular = message.singular; + return object; + }; + + /** + * Converts this ResourceDescriptor to JSON. + * @function toJSON + * @memberof google.api.ResourceDescriptor + * @instance + * @returns {Object.} JSON object + */ + ResourceDescriptor.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * History enum. + * @name google.api.ResourceDescriptor.History + * @enum {string} + * @property {string} HISTORY_UNSPECIFIED=HISTORY_UNSPECIFIED HISTORY_UNSPECIFIED value + * @property {string} ORIGINALLY_SINGLE_PATTERN=ORIGINALLY_SINGLE_PATTERN ORIGINALLY_SINGLE_PATTERN value + * @property {string} FUTURE_MULTI_PATTERN=FUTURE_MULTI_PATTERN FUTURE_MULTI_PATTERN value + */ + ResourceDescriptor.History = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "HISTORY_UNSPECIFIED"] = "HISTORY_UNSPECIFIED"; + values[valuesById[1] = "ORIGINALLY_SINGLE_PATTERN"] = "ORIGINALLY_SINGLE_PATTERN"; + values[valuesById[2] = "FUTURE_MULTI_PATTERN"] = "FUTURE_MULTI_PATTERN"; + return values; + })(); + + return ResourceDescriptor; + })(); + + api.ResourceReference = (function() { + + /** + * Properties of a ResourceReference. + * @memberof google.api + * @interface IResourceReference + * @property {string|null} [type] ResourceReference type + * @property {string|null} [childType] ResourceReference childType + */ + + /** + * Constructs a new ResourceReference. + * @memberof google.api + * @classdesc Represents a ResourceReference. + * @implements IResourceReference + * @constructor + * @param {google.api.IResourceReference=} [properties] Properties to set + */ + function ResourceReference(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResourceReference type. + * @member {string} type + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.type = ""; + + /** + * ResourceReference childType. + * @member {string} childType + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.childType = ""; + + /** + * Creates a ResourceReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.ResourceReference + * @static + * @param {Object.} object Plain object + * @returns {google.api.ResourceReference} ResourceReference + */ + ResourceReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.ResourceReference) + return object; + var message = new $root.google.api.ResourceReference(); + if (object.type != null) + message.type = String(object.type); + if (object.childType != null) + message.childType = String(object.childType); + return message; + }; + + /** + * Creates a plain object from a ResourceReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.ResourceReference + * @static + * @param {google.api.ResourceReference} message ResourceReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResourceReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.type = ""; + object.childType = ""; + } + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.childType != null && message.hasOwnProperty("childType")) + object.childType = message.childType; + return object; + }; + + /** + * Converts this ResourceReference to JSON. + * @function toJSON + * @memberof google.api.ResourceReference + * @instance + * @returns {Object.} JSON object + */ + ResourceReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ResourceReference; + })(); + + return api; })(); - - longrunning.WaitOperationRequest = (function() { - - /** - * Properties of a WaitOperationRequest. - * @memberof google.longrunning - * @interface IWaitOperationRequest - * @property {string|null} [name] WaitOperationRequest name - * @property {google.protobuf.IDuration|null} [timeout] WaitOperationRequest timeout - */ - - /** - * Constructs a new WaitOperationRequest. - * @memberof google.longrunning - * @classdesc Represents a WaitOperationRequest. - * @implements IWaitOperationRequest - * @constructor - * @param {google.longrunning.IWaitOperationRequest=} [properties] Properties to set - */ - function WaitOperationRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * WaitOperationRequest name. - * @member {string} name - * @memberof google.longrunning.WaitOperationRequest - * @instance - */ - WaitOperationRequest.prototype.name = ""; - + + google.type = (function() { + /** - * WaitOperationRequest timeout. - * @member {google.protobuf.IDuration|null|undefined} timeout - * @memberof google.longrunning.WaitOperationRequest - * @instance + * Namespace type. + * @memberof google + * @namespace */ - WaitOperationRequest.prototype.timeout = null; - - return WaitOperationRequest; + var type = {}; + + type.LatLng = (function() { + + /** + * Properties of a LatLng. + * @memberof google.type + * @interface ILatLng + * @property {number|null} [latitude] LatLng latitude + * @property {number|null} [longitude] LatLng longitude + */ + + /** + * Constructs a new LatLng. + * @memberof google.type + * @classdesc Represents a LatLng. + * @implements ILatLng + * @constructor + * @param {google.type.ILatLng=} [properties] Properties to set + */ + function LatLng(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LatLng latitude. + * @member {number} latitude + * @memberof google.type.LatLng + * @instance + */ + LatLng.prototype.latitude = 0; + + /** + * LatLng longitude. + * @member {number} longitude + * @memberof google.type.LatLng + * @instance + */ + LatLng.prototype.longitude = 0; + + /** + * Creates a LatLng message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.type.LatLng + * @static + * @param {Object.} object Plain object + * @returns {google.type.LatLng} LatLng + */ + LatLng.fromObject = function fromObject(object) { + if (object instanceof $root.google.type.LatLng) + return object; + var message = new $root.google.type.LatLng(); + if (object.latitude != null) + message.latitude = Number(object.latitude); + if (object.longitude != null) + message.longitude = Number(object.longitude); + return message; + }; + + /** + * Creates a plain object from a LatLng message. Also converts values to other types if specified. + * @function toObject + * @memberof google.type.LatLng + * @static + * @param {google.type.LatLng} message LatLng + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LatLng.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.latitude = 0; + object.longitude = 0; + } + if (message.latitude != null && message.hasOwnProperty("latitude")) + object.latitude = options.json && !isFinite(message.latitude) ? String(message.latitude) : message.latitude; + if (message.longitude != null && message.hasOwnProperty("longitude")) + object.longitude = options.json && !isFinite(message.longitude) ? String(message.longitude) : message.longitude; + return object; + }; + + /** + * Converts this LatLng to JSON. + * @function toJSON + * @memberof google.type.LatLng + * @instance + * @returns {Object.} JSON object + */ + LatLng.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return LatLng; + })(); + + return type; })(); - - longrunning.OperationInfo = (function() { - - /** - * Properties of an OperationInfo. - * @memberof google.longrunning - * @interface IOperationInfo - * @property {string|null} [responseType] OperationInfo responseType - * @property {string|null} [metadataType] OperationInfo metadataType - */ - - /** - * Constructs a new OperationInfo. - * @memberof google.longrunning - * @classdesc Represents an OperationInfo. - * @implements IOperationInfo - * @constructor - * @param {google.longrunning.IOperationInfo=} [properties] Properties to set - */ - function OperationInfo(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - + + google.rpc = (function() { + /** - * OperationInfo responseType. - * @member {string} responseType - * @memberof google.longrunning.OperationInfo - * @instance + * Namespace rpc. + * @memberof google + * @namespace */ - OperationInfo.prototype.responseType = ""; - + var rpc = {}; + + rpc.Status = (function() { + + /** + * Properties of a Status. + * @memberof google.rpc + * @interface IStatus + * @property {number|null} [code] Status code + * @property {string|null} [message] Status message + * @property {Array.|null} [details] Status details + */ + + /** + * Constructs a new Status. + * @memberof google.rpc + * @classdesc Represents a Status. + * @implements IStatus + * @constructor + * @param {google.rpc.IStatus=} [properties] Properties to set + */ + function Status(properties) { + this.details = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Status code. + * @member {number} code + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.code = 0; + + /** + * Status message. + * @member {string} message + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.message = ""; + + /** + * Status details. + * @member {Array.} details + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.details = $util.emptyArray; + + /** + * Creates a Status message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.rpc.Status + * @static + * @param {Object.} object Plain object + * @returns {google.rpc.Status} Status + */ + Status.fromObject = function fromObject(object) { + if (object instanceof $root.google.rpc.Status) + return object; + var message = new $root.google.rpc.Status(); + if (object.code != null) + message.code = object.code | 0; + if (object.message != null) + message.message = String(object.message); + if (object.details) { + if (!Array.isArray(object.details)) + throw TypeError(".google.rpc.Status.details: array expected"); + message.details = []; + for (var i = 0; i < object.details.length; ++i) { + if (typeof object.details[i] !== "object") + throw TypeError(".google.rpc.Status.details: object expected"); + message.details[i] = $root.google.protobuf.Any.fromObject(object.details[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Status message. Also converts values to other types if specified. + * @function toObject + * @memberof google.rpc.Status + * @static + * @param {google.rpc.Status} message Status + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Status.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.details = []; + if (options.defaults) { + object.code = 0; + object.message = ""; + } + if (message.code != null && message.hasOwnProperty("code")) + object.code = message.code; + if (message.message != null && message.hasOwnProperty("message")) + object.message = message.message; + if (message.details && message.details.length) { + object.details = []; + for (var j = 0; j < message.details.length; ++j) + object.details[j] = $root.google.protobuf.Any.toObject(message.details[j], options); + } + return object; + }; + + /** + * Converts this Status to JSON. + * @function toJSON + * @memberof google.rpc.Status + * @instance + * @returns {Object.} JSON object + */ + Status.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Status; + })(); + + return rpc; + })(); + + google.longrunning = (function() { + /** - * OperationInfo metadataType. - * @member {string} metadataType - * @memberof google.longrunning.OperationInfo - * @instance + * Namespace longrunning. + * @memberof google + * @namespace */ - OperationInfo.prototype.metadataType = ""; - - return OperationInfo; + var longrunning = {}; + + longrunning.Operations = (function() { + + /** + * Constructs a new Operations service. + * @memberof google.longrunning + * @classdesc Represents an Operations + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function Operations(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (Operations.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Operations; + + /** + * Callback as used by {@link google.longrunning.Operations#listOperations}. + * @memberof google.longrunning.Operations + * @typedef ListOperationsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.ListOperationsResponse} [response] ListOperationsResponse + */ + + /** + * Calls ListOperations. + * @function listOperations + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object + * @param {google.longrunning.Operations.ListOperationsCallback} callback Node-style callback called with the error, if any, and ListOperationsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.listOperations = function listOperations(request, callback) { + return this.rpcCall(listOperations, $root.google.longrunning.ListOperationsRequest, $root.google.longrunning.ListOperationsResponse, request, callback); + }, "name", { value: "ListOperations" }); + + /** + * Calls ListOperations. + * @function listOperations + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#getOperation}. + * @memberof google.longrunning.Operations + * @typedef GetOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls GetOperation. + * @function getOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object + * @param {google.longrunning.Operations.GetOperationCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.getOperation = function getOperation(request, callback) { + return this.rpcCall(getOperation, $root.google.longrunning.GetOperationRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "GetOperation" }); + + /** + * Calls GetOperation. + * @function getOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#deleteOperation}. + * @memberof google.longrunning.Operations + * @typedef DeleteOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteOperation. + * @function deleteOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object + * @param {google.longrunning.Operations.DeleteOperationCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.deleteOperation = function deleteOperation(request, callback) { + return this.rpcCall(deleteOperation, $root.google.longrunning.DeleteOperationRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteOperation" }); + + /** + * Calls DeleteOperation. + * @function deleteOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#cancelOperation}. + * @memberof google.longrunning.Operations + * @typedef CancelOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls CancelOperation. + * @function cancelOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object + * @param {google.longrunning.Operations.CancelOperationCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.cancelOperation = function cancelOperation(request, callback) { + return this.rpcCall(cancelOperation, $root.google.longrunning.CancelOperationRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "CancelOperation" }); + + /** + * Calls CancelOperation. + * @function cancelOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#waitOperation}. + * @memberof google.longrunning.Operations + * @typedef WaitOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls WaitOperation. + * @function waitOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object + * @param {google.longrunning.Operations.WaitOperationCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.waitOperation = function waitOperation(request, callback) { + return this.rpcCall(waitOperation, $root.google.longrunning.WaitOperationRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "WaitOperation" }); + + /** + * Calls WaitOperation. + * @function waitOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return Operations; + })(); + + longrunning.Operation = (function() { + + /** + * Properties of an Operation. + * @memberof google.longrunning + * @interface IOperation + * @property {string|null} [name] Operation name + * @property {google.protobuf.IAny|null} [metadata] Operation metadata + * @property {boolean|null} [done] Operation done + * @property {google.rpc.IStatus|null} [error] Operation error + * @property {google.protobuf.IAny|null} [response] Operation response + */ + + /** + * Constructs a new Operation. + * @memberof google.longrunning + * @classdesc Represents an Operation. + * @implements IOperation + * @constructor + * @param {google.longrunning.IOperation=} [properties] Properties to set + */ + function Operation(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Operation name. + * @member {string} name + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.name = ""; + + /** + * Operation metadata. + * @member {google.protobuf.IAny|null|undefined} metadata + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.metadata = null; + + /** + * Operation done. + * @member {boolean} done + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.done = false; + + /** + * Operation error. + * @member {google.rpc.IStatus|null|undefined} error + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.error = null; + + /** + * Operation response. + * @member {google.protobuf.IAny|null|undefined} response + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.response = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Operation result. + * @member {"error"|"response"|undefined} result + * @memberof google.longrunning.Operation + * @instance + */ + Object.defineProperty(Operation.prototype, "result", { + get: $util.oneOfGetter($oneOfFields = ["error", "response"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates an Operation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.Operation + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.Operation} Operation + */ + Operation.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.Operation) + return object; + var message = new $root.google.longrunning.Operation(); + if (object.name != null) + message.name = String(object.name); + if (object.metadata != null) { + if (typeof object.metadata !== "object") + throw TypeError(".google.longrunning.Operation.metadata: object expected"); + message.metadata = $root.google.protobuf.Any.fromObject(object.metadata); + } + if (object.done != null) + message.done = Boolean(object.done); + if (object.error != null) { + if (typeof object.error !== "object") + throw TypeError(".google.longrunning.Operation.error: object expected"); + message.error = $root.google.rpc.Status.fromObject(object.error); + } + if (object.response != null) { + if (typeof object.response !== "object") + throw TypeError(".google.longrunning.Operation.response: object expected"); + message.response = $root.google.protobuf.Any.fromObject(object.response); + } + return message; + }; + + /** + * Creates a plain object from an Operation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.Operation + * @static + * @param {google.longrunning.Operation} message Operation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Operation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.metadata = null; + object.done = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.metadata != null && message.hasOwnProperty("metadata")) + object.metadata = $root.google.protobuf.Any.toObject(message.metadata, options); + if (message.done != null && message.hasOwnProperty("done")) + object.done = message.done; + if (message.error != null && message.hasOwnProperty("error")) { + object.error = $root.google.rpc.Status.toObject(message.error, options); + if (options.oneofs) + object.result = "error"; + } + if (message.response != null && message.hasOwnProperty("response")) { + object.response = $root.google.protobuf.Any.toObject(message.response, options); + if (options.oneofs) + object.result = "response"; + } + return object; + }; + + /** + * Converts this Operation to JSON. + * @function toJSON + * @memberof google.longrunning.Operation + * @instance + * @returns {Object.} JSON object + */ + Operation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Operation; + })(); + + longrunning.GetOperationRequest = (function() { + + /** + * Properties of a GetOperationRequest. + * @memberof google.longrunning + * @interface IGetOperationRequest + * @property {string|null} [name] GetOperationRequest name + */ + + /** + * Constructs a new GetOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a GetOperationRequest. + * @implements IGetOperationRequest + * @constructor + * @param {google.longrunning.IGetOperationRequest=} [properties] Properties to set + */ + function GetOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetOperationRequest name. + * @member {string} name + * @memberof google.longrunning.GetOperationRequest + * @instance + */ + GetOperationRequest.prototype.name = ""; + + /** + * Creates a GetOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.GetOperationRequest} GetOperationRequest + */ + GetOperationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.GetOperationRequest) + return object; + var message = new $root.google.longrunning.GetOperationRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {google.longrunning.GetOperationRequest} message GetOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetOperationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.GetOperationRequest + * @instance + * @returns {Object.} JSON object + */ + GetOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetOperationRequest; + })(); + + longrunning.ListOperationsRequest = (function() { + + /** + * Properties of a ListOperationsRequest. + * @memberof google.longrunning + * @interface IListOperationsRequest + * @property {string|null} [name] ListOperationsRequest name + * @property {string|null} [filter] ListOperationsRequest filter + * @property {number|null} [pageSize] ListOperationsRequest pageSize + * @property {string|null} [pageToken] ListOperationsRequest pageToken + */ + + /** + * Constructs a new ListOperationsRequest. + * @memberof google.longrunning + * @classdesc Represents a ListOperationsRequest. + * @implements IListOperationsRequest + * @constructor + * @param {google.longrunning.IListOperationsRequest=} [properties] Properties to set + */ + function ListOperationsRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListOperationsRequest name. + * @member {string} name + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.name = ""; + + /** + * ListOperationsRequest filter. + * @member {string} filter + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.filter = ""; + + /** + * ListOperationsRequest pageSize. + * @member {number} pageSize + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.pageSize = 0; + + /** + * ListOperationsRequest pageToken. + * @member {string} pageToken + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.pageToken = ""; + + /** + * Creates a ListOperationsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.ListOperationsRequest} ListOperationsRequest + */ + ListOperationsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.ListOperationsRequest) + return object; + var message = new $root.google.longrunning.ListOperationsRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.filter != null) + message.filter = String(object.filter); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + return message; + }; + + /** + * Creates a plain object from a ListOperationsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {google.longrunning.ListOperationsRequest} message ListOperationsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListOperationsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.filter = ""; + object.pageSize = 0; + object.pageToken = ""; + object.name = ""; + } + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this ListOperationsRequest to JSON. + * @function toJSON + * @memberof google.longrunning.ListOperationsRequest + * @instance + * @returns {Object.} JSON object + */ + ListOperationsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListOperationsRequest; + })(); + + longrunning.ListOperationsResponse = (function() { + + /** + * Properties of a ListOperationsResponse. + * @memberof google.longrunning + * @interface IListOperationsResponse + * @property {Array.|null} [operations] ListOperationsResponse operations + * @property {string|null} [nextPageToken] ListOperationsResponse nextPageToken + */ + + /** + * Constructs a new ListOperationsResponse. + * @memberof google.longrunning + * @classdesc Represents a ListOperationsResponse. + * @implements IListOperationsResponse + * @constructor + * @param {google.longrunning.IListOperationsResponse=} [properties] Properties to set + */ + function ListOperationsResponse(properties) { + this.operations = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListOperationsResponse operations. + * @member {Array.} operations + * @memberof google.longrunning.ListOperationsResponse + * @instance + */ + ListOperationsResponse.prototype.operations = $util.emptyArray; + + /** + * ListOperationsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.longrunning.ListOperationsResponse + * @instance + */ + ListOperationsResponse.prototype.nextPageToken = ""; + + /** + * Creates a ListOperationsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.ListOperationsResponse} ListOperationsResponse + */ + ListOperationsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.ListOperationsResponse) + return object; + var message = new $root.google.longrunning.ListOperationsResponse(); + if (object.operations) { + if (!Array.isArray(object.operations)) + throw TypeError(".google.longrunning.ListOperationsResponse.operations: array expected"); + message.operations = []; + for (var i = 0; i < object.operations.length; ++i) { + if (typeof object.operations[i] !== "object") + throw TypeError(".google.longrunning.ListOperationsResponse.operations: object expected"); + message.operations[i] = $root.google.longrunning.Operation.fromObject(object.operations[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListOperationsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {google.longrunning.ListOperationsResponse} message ListOperationsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListOperationsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.operations = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.operations && message.operations.length) { + object.operations = []; + for (var j = 0; j < message.operations.length; ++j) + object.operations[j] = $root.google.longrunning.Operation.toObject(message.operations[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListOperationsResponse to JSON. + * @function toJSON + * @memberof google.longrunning.ListOperationsResponse + * @instance + * @returns {Object.} JSON object + */ + ListOperationsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListOperationsResponse; + })(); + + longrunning.CancelOperationRequest = (function() { + + /** + * Properties of a CancelOperationRequest. + * @memberof google.longrunning + * @interface ICancelOperationRequest + * @property {string|null} [name] CancelOperationRequest name + */ + + /** + * Constructs a new CancelOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a CancelOperationRequest. + * @implements ICancelOperationRequest + * @constructor + * @param {google.longrunning.ICancelOperationRequest=} [properties] Properties to set + */ + function CancelOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CancelOperationRequest name. + * @member {string} name + * @memberof google.longrunning.CancelOperationRequest + * @instance + */ + CancelOperationRequest.prototype.name = ""; + + /** + * Creates a CancelOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.CancelOperationRequest} CancelOperationRequest + */ + CancelOperationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.CancelOperationRequest) + return object; + var message = new $root.google.longrunning.CancelOperationRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a CancelOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {google.longrunning.CancelOperationRequest} message CancelOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CancelOperationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this CancelOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.CancelOperationRequest + * @instance + * @returns {Object.} JSON object + */ + CancelOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CancelOperationRequest; + })(); + + longrunning.DeleteOperationRequest = (function() { + + /** + * Properties of a DeleteOperationRequest. + * @memberof google.longrunning + * @interface IDeleteOperationRequest + * @property {string|null} [name] DeleteOperationRequest name + */ + + /** + * Constructs a new DeleteOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a DeleteOperationRequest. + * @implements IDeleteOperationRequest + * @constructor + * @param {google.longrunning.IDeleteOperationRequest=} [properties] Properties to set + */ + function DeleteOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteOperationRequest name. + * @member {string} name + * @memberof google.longrunning.DeleteOperationRequest + * @instance + */ + DeleteOperationRequest.prototype.name = ""; + + /** + * Creates a DeleteOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.DeleteOperationRequest} DeleteOperationRequest + */ + DeleteOperationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.DeleteOperationRequest) + return object; + var message = new $root.google.longrunning.DeleteOperationRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {google.longrunning.DeleteOperationRequest} message DeleteOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteOperationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this DeleteOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.DeleteOperationRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DeleteOperationRequest; + })(); + + longrunning.WaitOperationRequest = (function() { + + /** + * Properties of a WaitOperationRequest. + * @memberof google.longrunning + * @interface IWaitOperationRequest + * @property {string|null} [name] WaitOperationRequest name + * @property {google.protobuf.IDuration|null} [timeout] WaitOperationRequest timeout + */ + + /** + * Constructs a new WaitOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a WaitOperationRequest. + * @implements IWaitOperationRequest + * @constructor + * @param {google.longrunning.IWaitOperationRequest=} [properties] Properties to set + */ + function WaitOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WaitOperationRequest name. + * @member {string} name + * @memberof google.longrunning.WaitOperationRequest + * @instance + */ + WaitOperationRequest.prototype.name = ""; + + /** + * WaitOperationRequest timeout. + * @member {google.protobuf.IDuration|null|undefined} timeout + * @memberof google.longrunning.WaitOperationRequest + * @instance + */ + WaitOperationRequest.prototype.timeout = null; + + /** + * Creates a WaitOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.WaitOperationRequest} WaitOperationRequest + */ + WaitOperationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.WaitOperationRequest) + return object; + var message = new $root.google.longrunning.WaitOperationRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.timeout != null) { + if (typeof object.timeout !== "object") + throw TypeError(".google.longrunning.WaitOperationRequest.timeout: object expected"); + message.timeout = $root.google.protobuf.Duration.fromObject(object.timeout); + } + return message; + }; + + /** + * Creates a plain object from a WaitOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {google.longrunning.WaitOperationRequest} message WaitOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WaitOperationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.timeout = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.timeout != null && message.hasOwnProperty("timeout")) + object.timeout = $root.google.protobuf.Duration.toObject(message.timeout, options); + return object; + }; + + /** + * Converts this WaitOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.WaitOperationRequest + * @instance + * @returns {Object.} JSON object + */ + WaitOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return WaitOperationRequest; + })(); + + longrunning.OperationInfo = (function() { + + /** + * Properties of an OperationInfo. + * @memberof google.longrunning + * @interface IOperationInfo + * @property {string|null} [responseType] OperationInfo responseType + * @property {string|null} [metadataType] OperationInfo metadataType + */ + + /** + * Constructs a new OperationInfo. + * @memberof google.longrunning + * @classdesc Represents an OperationInfo. + * @implements IOperationInfo + * @constructor + * @param {google.longrunning.IOperationInfo=} [properties] Properties to set + */ + function OperationInfo(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OperationInfo responseType. + * @member {string} responseType + * @memberof google.longrunning.OperationInfo + * @instance + */ + OperationInfo.prototype.responseType = ""; + + /** + * OperationInfo metadataType. + * @member {string} metadataType + * @memberof google.longrunning.OperationInfo + * @instance + */ + OperationInfo.prototype.metadataType = ""; + + /** + * Creates an OperationInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.OperationInfo + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.OperationInfo} OperationInfo + */ + OperationInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.OperationInfo) + return object; + var message = new $root.google.longrunning.OperationInfo(); + if (object.responseType != null) + message.responseType = String(object.responseType); + if (object.metadataType != null) + message.metadataType = String(object.metadataType); + return message; + }; + + /** + * Creates a plain object from an OperationInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.OperationInfo + * @static + * @param {google.longrunning.OperationInfo} message OperationInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OperationInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.responseType = ""; + object.metadataType = ""; + } + if (message.responseType != null && message.hasOwnProperty("responseType")) + object.responseType = message.responseType; + if (message.metadataType != null && message.hasOwnProperty("metadataType")) + object.metadataType = message.metadataType; + return object; + }; + + /** + * Converts this OperationInfo to JSON. + * @function toJSON + * @memberof google.longrunning.OperationInfo + * @instance + * @returns {Object.} JSON object + */ + OperationInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return OperationInfo; + })(); + + return longrunning; })(); - - return longrunning; + + return google; })(); - return google; -})(); + return $root; +}); diff --git a/dev/protos/google/api/resource.proto b/dev/protos/google/api/resource.proto index fdb7001ad..2a52e61aa 100644 --- a/dev/protos/google/api/resource.proto +++ b/dev/protos/google/api/resource.proto @@ -68,12 +68,12 @@ extend google.protobuf.MessageOptions { // // The ResourceDescriptor Yaml config will look like: // -// resources: -// - type: "pubsub.googleapis.com/Topic" -// name_descriptor: -// - pattern: "projects/{project}/topics/{topic}" -// parent_type: "cloudresourcemanager.googleapis.com/Project" -// parent_name_extractor: "projects/{project}" +// resources: +// - type: "pubsub.googleapis.com/Topic" +// name_descriptor: +// - pattern: "projects/{project}/topics/{topic}" +// parent_type: "cloudresourcemanager.googleapis.com/Project" +// parent_name_extractor: "projects/{project}" // // Sometimes, resources have multiple patterns, typically because they can // live under multiple parents. @@ -255,10 +255,10 @@ message ResourceReference { // // Example: // - // message ListLogEntriesRequest { - // string parent = 1 [(google.api.resource_reference) = { - // child_type: "logging.googleapis.com/LogEntry" - // }; - // } + // message ListLogEntriesRequest { + // string parent = 1 [(google.api.resource_reference) = { + // child_type: "logging.googleapis.com/LogEntry" + // }; + // } string child_type = 2; } diff --git a/dev/protos/google/firestore/v1/firestore.proto b/dev/protos/google/firestore/v1/firestore.proto index c2c374e9d..5e8c21c45 100644 --- a/dev/protos/google/firestore/v1/firestore.proto +++ b/dev/protos/google/firestore/v1/firestore.proto @@ -132,6 +132,20 @@ service Firestore { }; } + // 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. + rpc PartitionQuery(PartitionQueryRequest) returns (PartitionQueryResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*/documents}:partitionQuery" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/databases/*/documents/*/**}:partitionQuery" + body: "*" + } + }; + } + // Streams batches of document updates and deletes, in order. rpc Write(stream WriteRequest) returns (stream WriteResponse) { option (google.api.http) = { @@ -161,10 +175,18 @@ service Firestore { option (google.api.method_signature) = "parent"; } - // Commit a batch of non-transactional writes. + // 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 + // [BatchWriteResponse][google.firestore.v1.BatchWriteResponse] for the success status of each write. + // + // If you require an atomically applied set of writes, use + // [Commit][google.firestore.v1.Firestore.Commit] instead. rpc BatchWrite(BatchWriteRequest) returns (BatchWriteResponse) { option (google.api.http) = { - post: "/v1beta1/{database=projects/*/databases/*}/documents:batchWrite" + post: "/v1/{database=projects/*/databases/*}/documents:batchWrite" body: "*" }; } @@ -197,7 +219,7 @@ message GetDocumentRequest { bytes transaction = 3; // 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. google.protobuf.Timestamp read_time = 5; } } @@ -238,7 +260,7 @@ message ListDocumentsRequest { bytes transaction = 8; // 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. google.protobuf.Timestamp read_time = 10; } @@ -354,7 +376,7 @@ message BatchGetDocumentsRequest { TransactionOptions new_transaction = 5; // 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. google.protobuf.Timestamp read_time = 7; } } @@ -468,7 +490,7 @@ message RunQueryRequest { TransactionOptions new_transaction = 6; // 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. google.protobuf.Timestamp read_time = 7; } } @@ -499,6 +521,81 @@ message RunQueryResponse { int32 skipped_results = 4; } +// The request for [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery]. +message PartitionQueryRequest { + // 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. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The query to partition. + oneof query_type { + // A structured query. + // Filters, order bys, limits, offsets, and start/end cursors are not + // supported. + StructuredQuery structured_query = 2; + } + + // 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. + int64 partition_count = 3; + + // 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 + string page_token = 4; + + // 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`. + int32 page_size = 5; +} + +// The response for [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery]. +message PartitionQueryResponse { + // Partition results. + // Each partition is a split point that can be used by RunQuery as a starting + // or end point for the query results. The RunQuery requests must be made with + // the same query supplied to this PartitionQuery request. The partition + // cursors will be ordered according to same ordering as the results of the + // query supplied to PartitionQuery. + // + // For example, if a PartitionQuery request returns partition cursors A and B, + // running the following three queries will return the entire result set of + // the original query: + // + // * query, end_at A + // * query, start_at A, end_at B + // * query, start_at B + repeated Cursor partitions = 1; + + // A page token that may be used to request an additional set of results, up + // to the number specified by `partition_count` in the PartitionQuery request. + // If blank, there are no more results. + string next_page_token = 2; +} + // The request for [Firestore.Write][google.firestore.v1.Firestore.Write]. // // The first request creates a stream, or resumes an existing one from a token. @@ -765,29 +862,31 @@ message ListCollectionIdsResponse { string next_page_token = 2; } -// The request for [Firestore.BatchWrite][]. +// The request for [Firestore.BatchWrite][google.firestore.v1.Firestore.BatchWrite]. message BatchWriteRequest { - // The database name. In the format: + // Required. The database name. In the format: // `projects/{project_id}/databases/{database_id}`. - string database = 1; + string database = 1 [(google.api.field_behavior) = REQUIRED]; + // The writes to apply. - // The writes are not applied atomically, and can be applied out of order. - // More than 1 write per document is not allowed. - // The success status of each write is independent of the other ones (some may - // fail and some may succeed) and is specified in the BatchWriteResponse. - // Note that the writes here are not applied atomically but the writes in the - // Write(stream WriteRequest) are applied atomically and they cannot be - // batched. + // + // 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. repeated Write writes = 2; + + // Labels associated with this batch write. + map labels = 3; } -// The response from [Firestore.BatchWrite][]. +// The response from [Firestore.BatchWrite][google.firestore.v1.Firestore.BatchWrite]. message BatchWriteResponse { // The result of applying the writes. // // This i-th write result corresponds to the i-th write in the // request. repeated WriteResult write_results = 1; + // The status of applying the writes. // // This i-th write status corresponds to the i-th write in the diff --git a/dev/protos/google/firestore/v1/query.proto b/dev/protos/google/firestore/v1/query.proto index 226d32418..845019136 100644 --- a/dev/protos/google/firestore/v1/query.proto +++ b/dev/protos/google/firestore/v1/query.proto @@ -83,31 +83,55 @@ message StructuredQuery { // Unspecified. This value must not be used. OPERATOR_UNSPECIFIED = 0; - // Less than. Requires that the field come first in `order_by`. + // The given `field` is less than the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. LESS_THAN = 1; - // Less than or equal. Requires that the field come first in `order_by`. + // The given `field` is less than or equal to the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. LESS_THAN_OR_EQUAL = 2; - // Greater than. Requires that the field come first in `order_by`. + // The given `field` is greater than the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. GREATER_THAN = 3; - // Greater than or equal. Requires that the field come first in - // `order_by`. + // The given `field` is greater than or equal to the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. GREATER_THAN_OR_EQUAL = 4; - // Equal. + // The given `field` is equal to the given `value`. EQUAL = 5; - // Contains. Requires that the field is an array. + // The given `field` is an array that contains the given `value`. ARRAY_CONTAINS = 7; - // In. Requires that `value` is a non-empty ArrayValue with at most 10 - // values. + // The given `field` is equal to at least one value in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN`, `ARRAY_CONTAINS_ANY`, or `NOT_IN`. IN = 8; - // Contains any. Requires that the field is an array and - // `value` is a non-empty ArrayValue with at most 10 values. + // The given `field` is an array that contains any of the values in the + // given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN`, `ARRAY_CONTAINS_ANY`, or `NOT_IN`. ARRAY_CONTAINS_ANY = 9; } @@ -121,15 +145,6 @@ message StructuredQuery { Value value = 3; } - // The projection of document's fields to return. - message Projection { - // The fields to return. - // - // If empty, all fields are returned. To only return the name - // of the document, use `['__name__']`. - repeated FieldReference fields = 2; - } - // A filter with a single operand. message UnaryFilter { // A unary operator. @@ -137,10 +152,10 @@ message StructuredQuery { // Unspecified. This value must not be used. OPERATOR_UNSPECIFIED = 0; - // Test if a field is equal to NaN. + // The given `field` is equal to `NaN`. IS_NAN = 2; - // Test if an expression evaluates to Null. + // The given `field` is equal to `NULL`. IS_NULL = 3; } @@ -168,6 +183,15 @@ message StructuredQuery { Direction direction = 2; } + // The projection of document's fields to return. + message Projection { + // The fields to return. + // + // If empty, all fields are returned. To only return the name + // of the document, use `['__name__']`. + repeated FieldReference fields = 2; + } + // A sort direction. enum Direction { // Unspecified. diff --git a/dev/protos/google/rpc/status.proto b/dev/protos/google/rpc/status.proto index 652c534c8..3b1f7a932 100644 --- a/dev/protos/google/rpc/status.proto +++ b/dev/protos/google/rpc/status.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// 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. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; diff --git a/dev/protos/google/type/latlng.proto b/dev/protos/google/type/latlng.proto index 473856f98..e5d45f1eb 100644 --- a/dev/protos/google/type/latlng.proto +++ b/dev/protos/google/type/latlng.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// 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. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; diff --git a/dev/protos/protos.json b/dev/protos/protos.json index 8d231d120..f859c1deb 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -879,6 +879,16 @@ "(google.api.http).additional_bindings.body": "*" } }, + "PartitionQuery": { + "requestType": "PartitionQueryRequest", + "responseType": "PartitionQueryResponse", + "options": { + "(google.api.http).post": "/v1/{parent=projects/*/databases/*/documents}:partitionQuery", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v1/{parent=projects/*/databases/*/documents/*/**}:partitionQuery", + "(google.api.http).additional_bindings.body": "*" + } + }, "Write": { "requestType": "WriteRequest", "requestStream": true, @@ -910,6 +920,14 @@ "(google.api.method_signature)": "parent" } }, + "BatchWrite": { + "requestType": "BatchWriteRequest", + "responseType": "BatchWriteResponse", + "options": { + "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:batchWrite", + "(google.api.http).body": "*" + } + }, "CreateDocument": { "requestType": "CreateDocumentRequest", "responseType": "Document", @@ -1293,6 +1311,53 @@ } } }, + "PartitionQueryRequest": { + "oneofs": { + "queryType": { + "oneof": [ + "structuredQuery" + ] + } + }, + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "structuredQuery": { + "type": "StructuredQuery", + "id": 2 + }, + "partitionCount": { + "type": "int64", + "id": 3 + }, + "pageToken": { + "type": "string", + "id": 4 + }, + "pageSize": { + "type": "int32", + "id": 5 + } + } + }, + "PartitionQueryResponse": { + "fields": { + "partitions": { + "rule": "repeated", + "type": "Cursor", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, "WriteRequest": { "fields": { "database": { @@ -1550,6 +1615,41 @@ } } }, + "BatchWriteRequest": { + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "writes": { + "rule": "repeated", + "type": "Write", + "id": 2 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 3 + } + } + }, + "BatchWriteResponse": { + "fields": { + "writeResults": { + "rule": "repeated", + "type": "WriteResult", + "id": 1 + }, + "status": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 2 + } + } + }, "StructuredQuery": { "fields": { "select": { @@ -1677,15 +1777,6 @@ } } }, - "Projection": { - "fields": { - "fields": { - "rule": "repeated", - "type": "FieldReference", - "id": 2 - } - } - }, "UnaryFilter": { "oneofs": { "operandType": { @@ -1734,6 +1825,15 @@ } } }, + "Projection": { + "fields": { + "fields": { + "rule": "repeated", + "type": "FieldReference", + "id": 2 + } + } + }, "Direction": { "values": { "DIRECTION_UNSPECIFIED": 0, @@ -3691,6 +3791,10 @@ "options": { "type": "FieldOptions", "id": 8 + }, + "proto3Optional": { + "type": "bool", + "id": 17 } }, "nested": { @@ -3926,7 +4030,7 @@ "type": "bool", "id": 31, "options": { - "default": false + "default": true } }, "objcClassPrefix": { @@ -4561,26 +4665,32 @@ "extend": "google.protobuf.MethodOptions" }, "Operations": { + "options": { + "(google.api.default_host)": "longrunning.googleapis.com" + }, "methods": { "ListOperations": { "requestType": "ListOperationsRequest", "responseType": "ListOperationsResponse", "options": { - "(google.api.http).get": "/v1/{name=operations}" + "(google.api.http).get": "/v1/{name=operations}", + "(google.api.method_signature)": "name,filter" } }, "GetOperation": { "requestType": "GetOperationRequest", "responseType": "Operation", "options": { - "(google.api.http).get": "/v1/{name=operations/**}" + "(google.api.http).get": "/v1/{name=operations/**}", + "(google.api.method_signature)": "name" } }, "DeleteOperation": { "requestType": "DeleteOperationRequest", "responseType": "google.protobuf.Empty", "options": { - "(google.api.http).delete": "/v1/{name=operations/**}" + "(google.api.http).delete": "/v1/{name=operations/**}", + "(google.api.method_signature)": "name" } }, "CancelOperation": { @@ -4588,7 +4698,8 @@ "responseType": "google.protobuf.Empty", "options": { "(google.api.http).post": "/v1/{name=operations/**}:cancel", - "(google.api.http).body": "*" + "(google.api.http).body": "*", + "(google.api.method_signature)": "name" } }, "WaitOperation": { @@ -4714,6 +4825,7 @@ }, "rpc": { "options": { + "cc_enable_arenas": true, "go_package": "google.golang.org/genproto/googleapis/rpc/status;status", "java_multiple_files": true, "java_outer_classname": "StatusProto", diff --git a/dev/protos/update.sh b/dev/protos/update.sh index 9b8e7f687..d5d8587bd 100755 --- a/dev/protos/update.sh +++ b/dev/protos/update.sh @@ -38,8 +38,8 @@ PBTS="$(npm bin)/pbts" pushd "$WORK_DIR" # Clone necessary git repos. -git clone https://github.com/googleapis/googleapis.git -git clone https://github.com/google/protobuf.git +git clone --depth 1 https://github.com/googleapis/googleapis.git +git clone --depth 1 https://github.com/google/protobuf.git # Copy necessary protos. mkdir -p "${PROTOS_DIR}/google/api" @@ -74,45 +74,45 @@ mkdir -p "${PROTOS_DIR}/google/protobuf" cp protobuf/src/google/protobuf/{any,empty,field_mask,struct,timestamp,wrappers}.proto \ "${PROTOS_DIR}/google/protobuf/" +popd + # Generate the Protobuf typings PBJS_ARGS=( --proto_path=. \ --js_out=import_style=commonjs,binary:library \ - --target=static \ + --target=static-module \ --no-create \ --no-encode \ --no-decode \ --no-verify \ - --no-convert \ --no-delimited \ - --force-enum-string \ - --force-number) + --force-enum-string) "${PBJS}" "${PBJS_ARGS[@]}" -o firestore_v1_proto_api.js \ + -r firestore_v1 \ "${PROTOS_DIR}/google/firestore/v1/*.proto" \ + "${PROTOS_DIR}/firestore/*.proto" \ "${PROTOS_DIR}/google/protobuf/*.proto" "${PROTOS_DIR}/google/type/*.proto" \ "${PROTOS_DIR}/google/rpc/*.proto" "${PROTOS_DIR}/google/api/*.proto" \ "${PROTOS_DIR}/google/longrunning/*.proto" +perl -pi -e 's/number\|Long/number\|string/g' firestore_v1_proto_api.js "${PBTS}" -o firestore_v1_proto_api.d.ts firestore_v1_proto_api.js "${PBJS}" "${PBJS_ARGS[@]}" -o firestore_admin_v1_proto_api.js \ + -r firestore_admin_v1 \ "${PROTOS_DIR}/google/firestore/admin/v1/*.proto" \ "${PROTOS_DIR}/google/protobuf/*.proto" "${PROTOS_DIR}/google/type/*.proto" \ "${PROTOS_DIR}/google/rpc/*.proto" "${PROTOS_DIR}/google/api/*.proto" \ "${PROTOS_DIR}/google/longrunning/*.proto" +perl -pi -e 's/number\|Long/number\|string/g' firestore_admin_v1_proto_api.js "${PBTS}" -o firestore_admin_v1_proto_api.d.ts firestore_admin_v1_proto_api.js "${PBJS}" "${PBJS_ARGS[@]}" -o firestore_v1beta1_proto_api.js \ + -r firestore_v1beta1 \ "${PROTOS_DIR}/google/firestore/v1beta1/*.proto" \ "${PROTOS_DIR}/google/protobuf/*.proto" "${PROTOS_DIR}/google/type/*.proto" \ "${PROTOS_DIR}/google/rpc/*.proto" "${PROTOS_DIR}/google/api/*.proto" \ "${PROTOS_DIR}/google/longrunning/*.proto" +perl -pi -e 's/number\|Long/number\|string/g' firestore_v1beta1_proto_api.js "${PBTS}" -o firestore_v1beta1_proto_api.d.ts firestore_v1beta1_proto_api.js -node "${PROTOS_DIR}"/../../scripts/license.js *.d.ts *.js - -# Copy typings into source repo -cp {firestore_v1_proto_api.d.ts,firestore_v1_proto_api.js} ${PROTOS_DIR} -cp {firestore_admin_v1_proto_api.d.ts,firestore_admin_v1_proto_api.js} ${PROTOS_DIR} -cp {firestore_v1beta1_proto_api.d.ts,firestore_v1beta1_proto_api.js} ${PROTOS_DIR} - -popd +node ../../scripts/license.js *.d.ts *.js diff --git a/dev/src/backoff.ts b/dev/src/backoff.ts index d5ad8ae60..74365ae65 100644 --- a/dev/src/backoff.ts +++ b/dev/src/backoff.ts @@ -285,7 +285,7 @@ export class ExponentialBackoff { * @returns {number} The jitter to apply based on the current delay. * @private */ - private jitterDelayMs() { + private jitterDelayMs(): number { return (Math.random() - 0.5) * this.jitterFactor * this.currentBaseMs; } } diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 02bd6619f..227cf3256 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import * as firestore from '@google-cloud/firestore'; + import * as assert from 'assert'; import {FieldPath, Firestore} from '.'; @@ -20,7 +22,6 @@ import {delayExecution} from './backoff'; import {RateLimiter} from './rate-limiter'; import {DocumentReference} from './reference'; import {Timestamp} from './timestamp'; -import {Precondition, SetOptions, UpdateData} from './types'; import {Deferred, wrapError} from './util'; import {BatchWriteResult, WriteBatch, WriteResult} from './write-batch'; @@ -86,6 +87,7 @@ class BulkCommitBatch { private resultsMap = new Map>(); constructor( + private readonly firestore: Firestore, private readonly writeBatch: WriteBatch, private readonly maxBatchSize: number ) {} @@ -101,31 +103,48 @@ class BulkCommitBatch { * Adds a `create` operation to the WriteBatch. Returns a promise that * resolves with the result of the write. */ - create(documentRef: DocumentReference, data: T): Promise { + create( + documentRef: firestore.DocumentReference, + data: T + ): Promise { this.writeBatch.create(documentRef, data); return this.processOperation(documentRef); } /** * 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. */ delete( - documentRef: DocumentReference, - precondition?: Precondition + documentRef: firestore.DocumentReference, + precondition?: firestore.Precondition ): Promise { this.writeBatch.delete(documentRef, precondition); return this.processOperation(documentRef); } + set( + documentRef: firestore.DocumentReference, + data: Partial, + options: firestore.SetOptions + ): Promise; + set( + documentRef: firestore.DocumentReference, + data: T + ): Promise; + set( + documentRef: firestore.DocumentReference, + data: T | Partial, + options?: firestore.SetOptions + ): Promise; /** * Adds a `set` operation to the WriteBatch. Returns a promise that * resolves with the result of the write. */ set( - documentRef: DocumentReference, - data: T, - options?: SetOptions + documentRef: firestore.DocumentReference, + data: T | Partial, + options?: firestore.SetOptions ): Promise { this.writeBatch.set(documentRef, data, options); return this.processOperation(documentRef); @@ -136,8 +155,8 @@ class BulkCommitBatch { * resolves with the result of the write. */ update( - documentRef: DocumentReference, - dataOrField: UpdateData | string | FieldPath, + documentRef: firestore.DocumentReference, + dataOrField: firestore.UpdateData | string | firestore.FieldPath, ...preconditionOrValues: Array< {lastUpdateTime?: Timestamp} | unknown | string | FieldPath > @@ -151,7 +170,7 @@ class BulkCommitBatch { * return the result. */ private processOperation( - documentRef: DocumentReference + documentRef: firestore.DocumentReference ): Promise { assert( !this.docPaths.has(documentRef.path), @@ -262,6 +281,8 @@ export class BulkWriter { private readonly firestore: Firestore, enableThrottling: boolean ) { + this.firestore._incrementBulkWritersCount(); + if (enableThrottling) { this.rateLimiter = new RateLimiter( STARTING_MAXIMUM_OPS_PER_SECOND, @@ -301,7 +322,10 @@ export class BulkWriter { * }); * }); */ - create(documentRef: DocumentReference, data: T): Promise { + create( + documentRef: firestore.DocumentReference, + data: T + ): Promise { this.verifyNotClosed(); const bulkCommitBatch = this.getEligibleBatch(documentRef); const resultPromise = bulkCommitBatch.create(documentRef, data); @@ -319,8 +343,9 @@ export class BulkWriter { * @param {Timestamp=} precondition.lastUpdateTime If set, enforces that the * document was last updated at lastUpdateTime. Fails the batch if the * document doesn't exist or was last updated at a different time. - * @returns {Promise} A promise that resolves with the result of - * the write. Throws an error if the write fails. + * @returns {Promise} A promise that resolves with a sentinel + * Timestamp indicating that the delete was successful. Throws an error if + * the write fails. * * @example * let bulkWriter = firestore.bulkWriter(); @@ -329,7 +354,7 @@ export class BulkWriter { * bulkWriter * .delete(documentRef) * .then(result => { - * console.log('Successfully deleted document at: ', result); + * console.log('Successfully deleted document'); * }) * .catch(err => { * console.log('Delete failed with: ', err); @@ -337,8 +362,8 @@ export class BulkWriter { * }); */ delete( - documentRef: DocumentReference, - precondition?: Precondition + documentRef: firestore.DocumentReference, + precondition?: firestore.Precondition ): Promise { this.verifyNotClosed(); const bulkCommitBatch = this.getEligibleBatch(documentRef); @@ -347,6 +372,15 @@ export class BulkWriter { return resultPromise; } + set( + documentRef: firestore.DocumentReference, + data: Partial, + options: firestore.SetOptions + ): Promise; + set( + documentRef: firestore.DocumentReference, + data: T + ): Promise; /** * Write to the document referred to by the provided * [DocumentReference]{@link DocumentReference}. If the document does not @@ -382,9 +416,9 @@ export class BulkWriter { * }); */ set( - documentRef: DocumentReference, - data: T, - options?: SetOptions + documentRef: firestore.DocumentReference, + data: T | Partial, + options?: firestore.SetOptions ): Promise { this.verifyNotClosed(); const bulkCommitBatch = this.getEligibleBatch(documentRef); @@ -435,8 +469,8 @@ export class BulkWriter { * }); */ update( - documentRef: DocumentReference, - dataOrField: UpdateData | string | FieldPath, + documentRef: firestore.DocumentReference, + dataOrField: firestore.UpdateData | string | FieldPath, ...preconditionOrValues: Array< {lastUpdateTime?: Timestamp} | unknown | string | FieldPath > @@ -508,6 +542,8 @@ export class BulkWriter { * }); */ close(): Promise { + this.verifyNotClosed(); + this.firestore._decrementBulkWritersCount(); const flushPromise = this.flush(); this.closed = true; return flushPromise; @@ -525,7 +561,9 @@ export class BulkWriter { * * @private */ - private getEligibleBatch(ref: DocumentReference): BulkCommitBatch { + private getEligibleBatch( + ref: firestore.DocumentReference + ): BulkCommitBatch { if (this.batchQueue.length > 0) { const lastBatch = this.batchQueue[this.batchQueue.length - 1]; if ( @@ -546,6 +584,7 @@ export class BulkWriter { */ private createNewBatch(): BulkCommitBatch { const newBatch = new BulkCommitBatch( + this.firestore, this.firestore.batch(), this.maxBatchSize ); @@ -638,6 +677,7 @@ export class BulkWriter { .filter(batch => batch.state === BatchState.SENT) .find(batch => batch.docPaths.has(path)) !== undefined; if (isRefInFlight) { + // eslint-disable-next-line no-console console.warn( '[BulkWriter]', `Duplicate write to document "${path}" detected.`, diff --git a/dev/src/bundle.ts b/dev/src/bundle.ts new file mode 100644 index 000000000..6aa01f0d8 --- /dev/null +++ b/dev/src/bundle.ts @@ -0,0 +1,214 @@ +// 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 +// +// https://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 {firestore, google} from '../protos/firestore_v1_proto_api'; + +import {DocumentSnapshot} from './document'; +import {QuerySnapshot} from './reference'; +import {Timestamp} from './timestamp'; +import { + invalidArgumentMessage, + validateMaxNumberOfArguments, + validateMinNumberOfArguments, + validateString, +} from './validate'; + +import api = google.firestore.v1; + +const BUNDLE_VERSION = 1; + +/** + * Builds a Firestore data bundle with results from the given document and query snapshots. + * + * @private + */ +export class BundleBuilder { + // Resulting documents for the bundle, keyed by full document path. + private documents: Map = new Map(); + // Named queries saved in the bundle, keyed by query name. + private namedQueries: Map = new Map(); + + // The latest read time among all bundled documents and queries. + private latestReadTime = new Timestamp(0, 0); + + constructor(private bundleId: string) {} + + add(documentSnapshot: DocumentSnapshot): BundleBuilder; + add(queryName: string, querySnapshot: QuerySnapshot): BundleBuilder; + /** + * Adds a Firestore document snapshot or query snapshot to the bundle. + * Both the documents data and the query read time will be included in the bundle. + * + * @param {DocumentSnapshot | string} documentOrName A document snapshot to add or a name of a query. + * @param {Query=} querySnapshot A query snapshot to add to the bundle, if provided. + * @returns {BundleBuilder} This instance. + * + * @example + * const bundle = firestore.bundle('data-bundle'); + * const docSnapshot = await firestore.doc('abc/123').get(); + * const querySnapshot = await firestore.collection('coll').get(); + * + * const bundleBuffer = bundle.add(docSnapshot); // Add a document + * .add('coll-query', querySnapshot) // Add a named query. + * .build() + * // Save `bundleBuffer` to CDN or stream it to clients. + */ + add( + documentOrName: DocumentSnapshot | string, + querySnapshot?: QuerySnapshot + ): BundleBuilder { + // eslint-disable-next-line prefer-rest-params + validateMinNumberOfArguments('BundleBuilder.add', arguments, 1); + // eslint-disable-next-line prefer-rest-params + validateMaxNumberOfArguments('BundleBuilder.add', arguments, 2); + if (arguments.length === 1) { + validateDocumentSnapshot('documentOrName', documentOrName); + this.addBundledDocument(documentOrName as DocumentSnapshot); + } else { + validateString('documentOrName', documentOrName); + validateQuerySnapshot('querySnapshot', querySnapshot); + this.addNamedQuery(documentOrName as string, querySnapshot!); + } + + return this; + } + + private addBundledDocument(snap: DocumentSnapshot): void { + const docProto = snap.toDocumentProto(); + this.documents.set(snap.id, { + document: snap.exists ? docProto : undefined, + metadata: { + name: docProto.name, + readTime: snap.readTime.toProto().timestampValue, + exists: snap.exists, + }, + }); + if (snap.readTime > this.latestReadTime) { + this.latestReadTime = snap.readTime; + } + } + + private addNamedQuery(name: string, querySnap: QuerySnapshot): void { + if (this.namedQueries.has(name)) { + throw new Error(`Query name conflict: ${name} is already added.`); + } + + this.namedQueries.set(name, { + name, + bundledQuery: querySnap.query._toBundledQuery(), + readTime: querySnap.readTime.toProto().timestampValue, + }); + + for (const snap of querySnap.docs) { + this.addBundledDocument(snap); + } + + if (querySnap.readTime > this.latestReadTime) { + this.latestReadTime = querySnap.readTime; + } + } + + /** + * Converts a IBundleElement to a Buffer whose content is the length prefixed JSON representation + * of the element. + * @private + */ + private elementToLengthPrefixedBuffer( + bundleElement: firestore.IBundleElement + ): Buffer { + const buffer = Buffer.from(JSON.stringify(bundleElement), 'utf-8'); + const lengthBuffer = Buffer.from(buffer.length.toString()); + return Buffer.concat([lengthBuffer, buffer]); + } + + build(): Buffer { + let bundleBuffer = Buffer.alloc(0); + + for (const namedQuery of this.namedQueries.values()) { + bundleBuffer = Buffer.concat([ + bundleBuffer, + this.elementToLengthPrefixedBuffer({namedQuery}), + ]); + } + + for (const bundledDocument of this.documents.values()) { + const documentMetadata: firestore.IBundledDocumentMetadata = + bundledDocument.metadata; + + bundleBuffer = Buffer.concat([ + bundleBuffer, + this.elementToLengthPrefixedBuffer({documentMetadata}), + ]); + // Write to the bundle if document exists. + const document = bundledDocument.document; + if (document) { + bundleBuffer = Buffer.concat([ + bundleBuffer, + this.elementToLengthPrefixedBuffer({document}), + ]); + } + } + + const metadata: firestore.IBundleMetadata = { + id: this.bundleId, + createTime: this.latestReadTime.toProto().timestampValue, + version: BUNDLE_VERSION, + totalDocuments: this.documents.size, + totalBytes: bundleBuffer.length, + }; + // Prepends the metadata element to the bundleBuffer: `bundleBuffer` is the second argument to `Buffer.concat`. + bundleBuffer = Buffer.concat([ + this.elementToLengthPrefixedBuffer({metadata}), + bundleBuffer, + ]); + return bundleBuffer; + } +} + +/** + * Convenient class to hold both the metadata and the actual content of a document to be bundled. + * @private + */ +class BundledDocument { + constructor( + readonly metadata: firestore.IBundledDocumentMetadata, + readonly document?: api.IDocument + ) {} +} + +/** + * Validates that 'value' is DocumentSnapshot. + * + * @private + * @param arg The argument name or argument index (for varargs methods). + * @param value The input to validate. + */ +function validateDocumentSnapshot(arg: string | number, value: unknown): void { + if (!(value instanceof DocumentSnapshot)) { + throw new Error(invalidArgumentMessage(arg, 'DocumentSnapshot')); + } +} + +/** + * Validates that 'value' is QuerySnapshot. + * + * @private + * @param arg The argument name or argument index (for varargs methods). + * @param value The input to validate. + */ +function validateQuerySnapshot(arg: string | number, value: unknown): void { + if (!(value instanceof QuerySnapshot)) { + throw new Error(invalidArgumentMessage(arg, 'QuerySnapshot')); + } +} diff --git a/dev/src/convert.ts b/dev/src/convert.ts index 61399d38d..e1c50bfb8 100644 --- a/dev/src/convert.ts +++ b/dev/src/convert.ts @@ -177,16 +177,12 @@ export function valueFromJson(fieldValue: api.IValue): api.IValue { return { bytesValue: bytesFromJson(fieldValue.bytesValue!), }; - case 'integerValue': - return { - integerValue: Number(fieldValue.integerValue), - }; case 'doubleValue': return { doubleValue: Number(fieldValue.doubleValue), }; case 'arrayValue': { - const arrayValue: Array<{}> = []; + const arrayValue: Array = []; if (Array.isArray(fieldValue.arrayValue!.values)) { for (const value of fieldValue.arrayValue!.values!) { arrayValue.push(valueFromJson(value)); diff --git a/dev/src/document-change.ts b/dev/src/document-change.ts index 0b8c16ecf..0125783b9 100644 --- a/dev/src/document-change.ts +++ b/dev/src/document-change.ts @@ -14,8 +14,9 @@ * limitations under the License. */ +import * as firestore from '@google-cloud/firestore'; + import {QueryDocumentSnapshot} from './document'; -import {DocumentData} from './types'; export type DocumentChangeType = 'added' | 'removed' | 'modified'; @@ -25,7 +26,8 @@ export type DocumentChangeType = 'added' | 'removed' | 'modified'; * * @class */ -export class DocumentChange { +export class DocumentChange + implements firestore.DocumentChange { private readonly _type: DocumentChangeType; private readonly _document: QueryDocumentSnapshot; private readonly _oldIndex: number; @@ -73,7 +75,7 @@ export class DocumentChange { * // Remove this listener. * unsubscribe(); */ - get type() { + get type(): DocumentChangeType { return this._type; } @@ -96,7 +98,7 @@ export class DocumentChange { * // Remove this listener. * unsubscribe(); */ - get doc() { + get doc(): QueryDocumentSnapshot { return this._document; } @@ -127,7 +129,7 @@ export class DocumentChange { * // Remove this listener. * unsubscribe(); */ - get oldIndex() { + get oldIndex(): number { return this._oldIndex; } @@ -159,7 +161,7 @@ export class DocumentChange { * // Remove this listener. * unsubscribe(); */ - get newIndex() { + get newIndex(): number { return this._newIndex; } @@ -170,7 +172,7 @@ export class DocumentChange { * @param {*} other The value to compare against. * @return true if this `DocumentChange` is equal to the provided value. */ - isEqual(other: DocumentChange): boolean { + isEqual(other: firestore.DocumentChange): boolean { if (this === other) { return true; } diff --git a/dev/src/document.ts b/dev/src/document.ts index 442f7a42d..970169d45 100644 --- a/dev/src/document.ts +++ b/dev/src/document.ts @@ -14,10 +14,11 @@ * limitations under the License. */ -const deepEqual = require('deep-equal'); +import * as firestore from '@google-cloud/firestore'; + +import * as deepEqual from 'fast-deep-equal'; import * as assert from 'assert'; -import {describe, it} from 'mocha'; import {google} from '../protos/firestore_v1_proto_api'; import {FieldTransform} from './field-value'; @@ -25,7 +26,7 @@ import {FieldPath, validateFieldPath} from './path'; import {DocumentReference} from './reference'; import {Serializer} from './serializer'; import {Timestamp} from './timestamp'; -import {ApiMapValue, DocumentData, UpdateMap} from './types'; +import {ApiMapValue, defaultConverter, UpdateMap} from './types'; import {isEmpty, isObject, isPlainObject} from './util'; import api = google.firestore.v1; @@ -36,7 +37,7 @@ import api = google.firestore.v1; * * @private */ -export class DocumentSnapshotBuilder { +export class DocumentSnapshotBuilder { /** The fields of the Firestore `Document` Protobuf backing this document. */ fieldsProto?: ApiMapValue; @@ -95,7 +96,8 @@ export class DocumentSnapshotBuilder { * * @class */ -export class DocumentSnapshot { +export class DocumentSnapshot + implements firestore.DocumentSnapshot { private _ref: DocumentReference; private _serializer: Serializer; private _readTime: Timestamp | undefined; @@ -138,11 +140,14 @@ export class DocumentSnapshot { * @return The created DocumentSnapshot. */ static fromObject( - ref: DocumentReference, - obj: DocumentData + ref: firestore.DocumentReference, + obj: firestore.DocumentData ): DocumentSnapshot { - const serializer = ref.firestore._serializer!; - return new DocumentSnapshot(ref, serializer.encodeFields(obj)); + const serializer = (ref as DocumentReference).firestore._serializer!; + return new DocumentSnapshot( + ref as DocumentReference, + serializer.encodeFields(obj) + ); } /** * Creates a DocumentSnapshot from an UpdateMap. @@ -156,10 +161,10 @@ export class DocumentSnapshot { * @return The created DocumentSnapshot. */ static fromUpdateMap( - ref: DocumentReference, + ref: firestore.DocumentReference, data: UpdateMap ): DocumentSnapshot { - const serializer = ref.firestore._serializer!; + const serializer = (ref as DocumentReference).firestore._serializer!; /** * Merges 'value' at the field path specified by the path array into @@ -229,7 +234,7 @@ export class DocumentSnapshot { merge(res, value, path, 0); } - return new DocumentSnapshot(ref, res); + return new DocumentSnapshot(ref as DocumentReference, res); } /** @@ -354,7 +359,7 @@ export class DocumentSnapshot { */ get readTime(): Timestamp { if (this._readTime === undefined) { - throw new Error(`Called 'readTime' on a local document`); + throw new Error("Called 'readTime' on a local document"); } return this._readTime; } @@ -381,11 +386,29 @@ export class DocumentSnapshot { return undefined; } - const obj: DocumentData = {}; - 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 !== defaultConverter()) { + const untypedReference = new DocumentReference( + this.ref.firestore, + this.ref._path + ); + return this.ref._converter.fromFirestore( + new QueryDocumentSnapshot( + untypedReference, + this._fieldsProto!, + this.readTime, + this.createTime!, + this.updateTime! + ) + ); + } else { + const obj: firestore.DocumentData = {}; + for (const prop of Object.keys(fields)) { + obj[prop] = this._serializer.decodeValue(fields[prop]); + } + return obj as T; } - return this.ref._converter.fromFirestore(obj); } /** @@ -408,9 +431,8 @@ export class DocumentSnapshot { */ // We deliberately use `any` in the external API to not impose type-checking // on end users. - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any get(field: string | FieldPath): any { - // tslint:disable-line no-any validateFieldPath('field', field); const protoField = this.protoField(field); @@ -453,12 +475,11 @@ export class DocumentSnapshot { } /** - * 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 { return { update: { name: this._ref.formattedName, @@ -467,6 +488,20 @@ export class DocumentSnapshot { }; } + /** + * Convert a document snapshot to the Firestore 'Document' proto. + * + * @private + */ + toDocumentProto(): api.IDocument { + 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 * equal to the provided value. @@ -475,14 +510,14 @@ export class DocumentSnapshot { * @return {boolean} true if this `DocumentSnapshot` is equal to the provided * value. */ - isEqual(other: DocumentSnapshot): boolean { + isEqual(other: firestore.DocumentSnapshot): boolean { // Since the read time is different on every document read, we explicitly // ignore all document metadata in this comparison. return ( this === other || (other instanceof DocumentSnapshot && - this._ref.isEqual(other._ref) && - deepEqual(this._fieldsProto, other._fieldsProto, {strict: true})) + this._ref.isEqual((other as DocumentSnapshot)._ref) && + deepEqual(this._fieldsProto, other._fieldsProto)) ); } } @@ -502,9 +537,9 @@ export class DocumentSnapshot { * @class * @extends DocumentSnapshot */ -export class QueryDocumentSnapshot extends DocumentSnapshot< - T -> { +export class QueryDocumentSnapshot + extends DocumentSnapshot + implements firestore.QueryDocumentSnapshot { /** * The time the document was created. * @@ -615,7 +650,9 @@ export class DocumentMask { * @private * @param fieldMask A list of field paths. */ - static fromFieldMask(fieldMask: Array): DocumentMask { + static fromFieldMask( + fieldMask: Array + ): DocumentMask { const fieldPaths: FieldPath[] = []; for (const fieldPath of fieldMask) { @@ -632,11 +669,11 @@ export class DocumentMask { * @param data An object with fields to modify. Only the keys are used to * extract the document mask. */ - static fromObject(data: DocumentData): DocumentMask { + static fromObject(data: firestore.DocumentData): DocumentMask { const fieldPaths: FieldPath[] = []; function extractFieldPaths( - currentData: DocumentData, + currentData: firestore.DocumentData, currentPath?: FieldPath ): void { let isEmpty = true; @@ -679,7 +716,7 @@ export class DocumentMask { * @private * @return {boolean} Whether this document mask is empty. */ - get isEmpty() { + get isEmpty(): boolean { return this._sortedPaths.length === 0; } @@ -750,19 +787,21 @@ export class DocumentMask { * @param data An object to filter. * @return A shallow copy of the object filtered by this document mask. */ - applyTo(data: DocumentData): DocumentData { + applyTo(data: firestore.DocumentData): firestore.DocumentData { /*! * Applies this DocumentMask to 'data' and computes the list of field paths * that were specified in the mask but are not present in 'data'. */ - const applyDocumentMask = (data: DocumentData) => { + const applyDocumentMask: ( + data: firestore.DocumentData + ) => firestore.DocumentData = data => { const remainingPaths = this._sortedPaths.slice(0); - const processObject = ( - currentData: DocumentData, + const processObject: ( + currentData: firestore.DocumentData, currentPath?: FieldPath - ) => { - let result: DocumentData | null = null; + ) => firestore.DocumentData | null = (currentData, currentPath) => { + let result: firestore.DocumentData | null = null; Object.keys(currentData).forEach(key => { const childPath = currentPath @@ -774,7 +813,7 @@ export class DocumentMask { result[key] = currentData[key]; } else if (isObject(currentData[key])) { const childObject = processObject( - currentData[key] as DocumentData, + currentData[key] as firestore.DocumentData, childPath ); if (childObject) { @@ -838,7 +877,7 @@ export class DocumentMask { * @private * @class */ -export class DocumentTransform { +export class DocumentTransform { /** * @private * @hideconstructor @@ -860,8 +899,8 @@ export class DocumentTransform { * @returns The Document Transform. */ static fromObject( - ref: DocumentReference, - obj: DocumentData + ref: firestore.DocumentReference, + obj: firestore.DocumentData ): DocumentTransform { const updateMap = new Map(); @@ -881,12 +920,16 @@ export class DocumentTransform { * @returns The Document Transform. */ static fromUpdateMap( - ref: DocumentReference, + ref: firestore.DocumentReference, data: UpdateMap ): DocumentTransform { const transforms = new Map(); - function encode_(val: unknown, path: FieldPath, allowTransforms: boolean) { + function encode_( + val: unknown, + path: FieldPath, + allowTransforms: boolean + ): void { if (val instanceof FieldTransform && val.includeInDocumentTransform) { if (allowTransforms) { transforms.set(path, val); @@ -911,7 +954,7 @@ export class DocumentTransform { encode_(value, FieldPath.fromArgument(key), true); }); - return new DocumentTransform(ref, transforms); + return new DocumentTransform(ref as DocumentReference, transforms); } /** @@ -976,10 +1019,13 @@ export class Precondition { * document in Firestore. * @param options */ - constructor(options?: {exists?: boolean; lastUpdateTime?: Timestamp}) { + constructor(options?: { + exists?: boolean; + lastUpdateTime?: firestore.Timestamp; + }) { if (options !== undefined) { this._exists = options.exists; - this._lastUpdateTime = options.lastUpdateTime; + this._lastUpdateTime = options.lastUpdateTime as Timestamp; } } diff --git a/dev/src/external-modules.d.ts b/dev/src/external-modules.d.ts index 2747e5615..a7e069d4d 100644 --- a/dev/src/external-modules.d.ts +++ b/dev/src/external-modules.d.ts @@ -15,4 +15,5 @@ */ // TODO(mrschmidt): Come up with actual definitions for these modules. -declare module 'functional-red-black-tree' +declare module 'functional-red-black-tree'; +declare module 'length-prefixed-json-stream'; diff --git a/dev/src/field-value.ts b/dev/src/field-value.ts index 6282acced..d894d8e35 100644 --- a/dev/src/field-value.ts +++ b/dev/src/field-value.ts @@ -14,7 +14,9 @@ * limitations under the License. */ -const deepEqual = require('deep-equal'); +import * as firestore from '@google-cloud/firestore'; + +import * as deepEqual from 'fast-deep-equal'; import * as proto from '../protos/firestore_v1_proto_api'; @@ -34,7 +36,7 @@ import api = proto.google.firestore.v1; * * @class */ -export class FieldValue { +export class FieldValue implements firestore.FieldValue { /** * @hideconstructor */ @@ -111,6 +113,7 @@ export class FieldValue { * }); */ static increment(n: number): FieldValue { + // eslint-disable-next-line prefer-rest-params validateMinNumberOfArguments('FieldValue.increment', arguments, 1); return new NumericIncrementTransform(n); } @@ -139,7 +142,7 @@ export class FieldValue { * }); */ static arrayUnion(...elements: unknown[]): FieldValue { - validateMinNumberOfArguments('FieldValue.arrayUnion', arguments, 1); + validateMinNumberOfArguments('FieldValue.arrayUnion', elements, 1); return new ArrayUnionTransform(elements); } @@ -166,7 +169,7 @@ export class FieldValue { * }); */ static arrayRemove(...elements: unknown[]): FieldValue { - validateMinNumberOfArguments('FieldValue.arrayRemove', arguments, 1); + validateMinNumberOfArguments('FieldValue.arrayRemove', elements, 1); return new ArrayRemoveTransform(elements); } @@ -198,7 +201,7 @@ export class FieldValue { * } * console.log(`Found ${equal} equalities.`); */ - isEqual(other: FieldValue): boolean { + isEqual(other: firestore.FieldValue): boolean { return this === other; } } @@ -284,7 +287,7 @@ export class DeleteTransform extends FieldTransform { validate(): void {} - toProto(serializer: Serializer, fieldPath: FieldPath): never { + toProto(): never { throw new Error( 'FieldValue.delete() should not be included in a FieldTransform' ); @@ -387,7 +390,7 @@ class NumericIncrementTransform extends FieldTransform { return {fieldPath: fieldPath.formattedName, increment: encodedOperand}; } - isEqual(other: FieldValue): boolean { + isEqual(other: firestore.FieldValue): boolean { return ( this === other || (other instanceof NumericIncrementTransform && @@ -443,11 +446,11 @@ class ArrayUnionTransform extends FieldTransform { }; } - isEqual(other: FieldValue): boolean { + isEqual(other: firestore.FieldValue): boolean { return ( this === other || (other instanceof ArrayUnionTransform && - deepEqual(this.elements, other.elements, {strict: true})) + deepEqual(this.elements, other.elements)) ); } } @@ -499,11 +502,11 @@ class ArrayRemoveTransform extends FieldTransform { }; } - isEqual(other: FieldValue): boolean { + isEqual(other: firestore.FieldValue): boolean { return ( this === other || (other instanceof ArrayRemoveTransform && - deepEqual(this.elements, other.elements, {strict: true})) + deepEqual(this.elements, other.elements)) ); } } diff --git a/dev/src/geo-point.ts b/dev/src/geo-point.ts index 37efc8b72..5bd7f3c7d 100644 --- a/dev/src/geo-point.ts +++ b/dev/src/geo-point.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import * as firestore from '@google-cloud/firestore'; + import {google} from '../protos/firestore_v1_proto_api'; import {Serializable} from './serializer'; import {validateNumber} from './validate'; @@ -26,7 +28,7 @@ import api = google.firestore.v1; * * @class */ -export class GeoPoint implements Serializable { +export class GeoPoint implements Serializable, firestore.GeoPoint { private readonly _latitude: number; private readonly _longitude: number; @@ -82,7 +84,7 @@ export class GeoPoint implements Serializable { * @param {*} other The value to compare against. * @return {boolean} true if this `GeoPoint` is equal to the provided value. */ - isEqual(other: GeoPoint): boolean { + isEqual(other: firestore.GeoPoint): boolean { return ( this === other || (other instanceof GeoPoint && diff --git a/dev/src/index.ts b/dev/src/index.ts index 99fd754b0..f684d15eb 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -14,14 +14,17 @@ * limitations under the License. */ -import {CallOptions, RetryOptions, Status} from 'google-gax'; -import {Duplex, PassThrough} from 'stream'; -import * as through2 from 'through2'; +import * as firestore from '@google-cloud/firestore'; + +import {CallOptions, grpc, RetryOptions} from 'google-gax'; +import {Duplex, PassThrough, Transform} from 'stream'; + import {URL} from 'url'; import {google} from '../protos/firestore_v1_proto_api'; import {ExponentialBackoff, ExponentialBackoffSetting} from './backoff'; import {BulkWriter} from './bulk-writer'; +import {BundleBuilder} from './bundle'; import {fieldsFromJson, timestampFromJson} from './convert'; import { DocumentSnapshot, @@ -45,15 +48,13 @@ import {parseGetAllArguments, Transaction} from './transaction'; import { ApiMapValue, BulkWriterOptions, - DocumentData, FirestoreStreamingMethod, FirestoreUnaryMethod, GapicClient, - ReadOptions, - Settings, UnaryMethod, } from './types'; import { + autoId, Deferred, getRetryParams, isPermanentRpcError, @@ -91,15 +92,7 @@ export {DocumentChange} from './document-change'; export {FieldPath} from './path'; export {GeoPoint} from './geo-point'; 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'; const libVersion = require('../../package.json').version; @@ -169,6 +162,53 @@ const MAX_CONCURRENT_REQUESTS_PER_CLIENT = 100; * @typedef {Object.} DocumentData */ +/** + * 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}) * that contains paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that @@ -265,7 +305,7 @@ const MAX_CONCURRENT_REQUESTS_PER_CLIENT = 100; * region_tag:firestore_quickstart * Full quickstart example: */ -export class Firestore { +export class Firestore implements firestore.Firestore { /** * A client pool to distribute requests over multiple GAPIC clients in order * to work around a connection limit of 100 concurrent requests per client. @@ -277,7 +317,7 @@ export class Firestore { * The configuration options for the GAPIC client. * @private */ - _settings: Settings = {}; + _settings: firestore.Settings = {}; /** * Settings for the exponential backoff used by the streaming endpoints. @@ -310,22 +350,20 @@ export class Firestore { /** * Count of listeners that have been registered on the client. * - * 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 = 0; - // 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. - /** @private */ - _preferTransactions: boolean; - /** @private */ - _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 + */ + private bulkWritersCount = 0; /** * @param {Object=} settings [Configuration object](#/docs). @@ -350,13 +388,18 @@ export class Firestore { * can specify a `keyFilename` instead. * @param {string=} settings.host The host to connect to. * @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 * 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. + * @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) { const libraryHeader = { libName: 'gccl', libVersion, @@ -372,7 +415,7 @@ export class Firestore { process.env.FIRESTORE_EMULATOR_HOST ); - const emulatorSettings: Settings = { + const emulatorSettings: firestore.Settings = { ...settings, ...libraryHeader, host: process.env.FIRESTORE_EMULATOR_HOST, @@ -396,20 +439,6 @@ export class Firestore { backoffFactor: retryConfig.retry_delay_multiplier, }; - // 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('Firestore', null, 'Detected GCF environment'); - } - const maxIdleChannels = this._settings.maxIdleChannels === undefined ? DEFAULT_MAX_IDLE_CHANNELS @@ -421,8 +450,8 @@ export class Firestore { let client: GapicClient; if (this._settings.ssl === false) { - const grpc = require('@grpc/grpc-js'); - const sslCreds = grpc.credentials.createInsecure(); + const grpcModule = this._settings.grpc ?? grpc; + const sslCreds = grpcModule.credentials.createInsecure(); client = new module.exports.v1({ sslCreds, @@ -451,7 +480,7 @@ export class Firestore { * * @param {object} settings The settings to use for all Firestore operations. */ - settings(settings: Settings): void { + settings(settings: firestore.Settings): void { validateObject('settings', settings); validateString('settings.projectId', settings.projectId, {optional: true}); @@ -468,7 +497,7 @@ export class Firestore { this._settingsFrozen = true; } - private validateAndApplySettings(settings: Settings): void { + private validateAndApplySettings(settings: firestore.Settings): void { if (settings.projectId !== undefined) { validateString('settings.projectId', settings.projectId); this._projectId = settings.projectId; @@ -745,7 +774,7 @@ export class Firestore { convertFields = fieldsFromJson; } else { throw new Error( - `Unsupported encoding format. Expected "json" or "protobufJS", ` + + 'Unsupported encoding format. Expected "json" or "protobufJS", ' + `but was "${encoding}".` ); } @@ -792,6 +821,20 @@ export class Firestore { return document.build(); } + /** + * 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 { + return new BundleBuilder(name || autoId()); + } + /** * Executes the given updateFunction and commits the changes applied within * the transaction. @@ -903,9 +946,15 @@ export class Firestore { * }); */ getAll( - ...documentRefsOrReadOptions: Array | ReadOptions> + ...documentRefsOrReadOptions: Array< + firestore.DocumentReference | firestore.ReadOptions + > ): Promise>> { - validateMinNumberOfArguments('Firestore.getAll', arguments, 1); + validateMinNumberOfArguments( + 'Firestore.getAll', + documentRefsOrReadOptions, + 1 + ); const {documents, fieldMask} = parseGetAllArguments( documentRefsOrReadOptions @@ -934,8 +983,8 @@ export class Firestore { * @returns A Promise that contains an array with the resulting documents. */ getAll_( - docRefs: Array>, - fieldMask: FieldPath[] | null, + docRefs: Array>, + fieldMask: firestore.FieldPath[] | null, requestTag: string, transactionId?: Uint8Array ): Promise>> { @@ -943,7 +992,7 @@ export class Firestore { const retrievedDocuments = new Map(); for (const docRef of docRefs) { - requestedDocuments.add(docRef.formattedName); + requestedDocuments.add((docRef as DocumentReference).formattedName); } const request: api.IBatchGetDocumentsRequest = { @@ -953,7 +1002,9 @@ export class Firestore { }; if (fieldMask) { - const fieldPaths = fieldMask.map(fieldPath => fieldPath.formattedName); + const fieldPaths = fieldMask.map( + fieldPath => (fieldPath as FieldPath).formattedName + ); request.mask = {fieldPaths}; } @@ -1024,7 +1075,9 @@ export class Firestore { if (document !== undefined) { // Recreate the DocumentSnapshot with the DocumentReference // containing the original converter. - const finalDoc = new DocumentSnapshotBuilder(docRef); + const finalDoc = new DocumentSnapshotBuilder( + docRef as DocumentReference + ); finalDoc.fieldsProto = document._fieldsProto; finalDoc.readTime = document.readTime; finalDoc.createTime = document.createTime; @@ -1066,15 +1119,38 @@ export class Firestore { this.registeredListenersCount -= 1; } + /** + * 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 { + 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(): void { + this.bulkWritersCount -= 1; + } + /** * Terminates the Firestore client and closes all open streams. * * @return A Promise that resolves when the client is terminated. */ terminate(): Promise { - if (this.registeredListenersCount > 0) { + if (this.registeredListenersCount > 0 || this.bulkWritersCount > 0) { return Promise.reject( - 'All onSnapshot() listeners must be unsubscribed before terminating the client.' + '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.` ); } return this._clientPool.terminate(); @@ -1198,9 +1274,7 @@ export class Firestore { try { await backoff.backoffAndWait(); - const result = await func(); - this._lastSuccessfulRequest = new Date().getTime(); - return result; + return await func(); } catch (err) { lastError = err; @@ -1250,7 +1324,7 @@ export class Firestore { let streamInitialized = false; return new Promise((resolve, reject) => { - function streamReady() { + function streamReady(): void { if (!streamInitialized) { streamInitialized = true; logger('Firestore._initializeStream', requestTag, 'Releasing stream'); @@ -1258,7 +1332,7 @@ export class Firestore { } } - function streamEnded() { + function streamEnded(): void { logger( 'Firestore._initializeStream', requestTag, @@ -1269,7 +1343,7 @@ export class Firestore { lifetime.resolve(); } - function streamFailed(err: Error) { + function streamFailed(err: Error): void { if (!streamInitialized) { // If we receive an error before we were able to receive any data, // reject this stream. @@ -1362,7 +1436,6 @@ export class Firestore { 'Received response: %j', result ); - this._lastSuccessfulRequest = new Date().getTime(); return result; } catch (err) { logger('Firestore.request', requestTag, 'Received error:', err); @@ -1408,14 +1481,17 @@ export class Firestore { const stream = bidirectional ? gapicClient[methodName](callOptions) : gapicClient[methodName](request, callOptions); - const logStream = through2.obj(function(this, chunk, enc, callback) { - logger( - 'Firestore.requestStream', - requestTag, - 'Received response: %j', - chunk - ); - callback(); + const logStream = new Transform({ + objectMode: true, + transform: (chunk, encoding, callback) => { + logger( + 'Firestore.requestStream', + requestTag, + 'Received response: %j', + chunk + ); + callback(); + }, }); stream.pipe(logStream); diff --git a/dev/src/path.ts b/dev/src/path.ts index 56a47a916..b38c1de89 100644 --- a/dev/src/path.ts +++ b/dev/src/path.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import * as firestore from '@google-cloud/firestore'; + import {google} from '../protos/firestore_v1_proto_api'; import {isObject} from './util'; @@ -242,7 +244,7 @@ export class ResourcePath extends Path { * database. * @private */ - get relativeName() { + get relativeName(): string { return this.segments.join('/'); } @@ -408,14 +410,11 @@ export class QualifiedResourcePath extends ResourcePath { /** * 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 { return this; } @@ -494,7 +493,7 @@ export function validateResourcePath( * * @class */ -export class FieldPath extends Path { +export class FieldPath extends Path implements firestore.FieldPath { /** * A special sentinel value to refer to the ID of a document. * @@ -543,7 +542,7 @@ export class FieldPath extends Path { * * @returns {FieldPath} */ - static documentId() { + static documentId(): FieldPath { return FieldPath._DOCUMENT_ID; } @@ -556,12 +555,12 @@ export class FieldPath extends Path { * @param {string|FieldPath} fieldPath The FieldPath to create. * @returns {FieldPath} A field path representation. */ - static fromArgument(fieldPath: string | FieldPath) { + static fromArgument(fieldPath: string | firestore.FieldPath): FieldPath { // validateFieldPath() is used in all public API entry points to validate // that fromArgument() is only called with a Field Path or a string. return fieldPath instanceof FieldPath ? fieldPath - : new FieldPath(...fieldPath.split('.')); + : new FieldPath(...(fieldPath as string).split('.')); } /** @@ -613,7 +612,7 @@ export class FieldPath extends Path { * @param segments Sequence of field names. * @returns The newly created FieldPath. */ - construct(segments: string[]) { + construct(segments: string[]): FieldPath { return new FieldPath(...segments); } @@ -639,7 +638,7 @@ export class FieldPath extends Path { export function validateFieldPath( arg: string | number, fieldPath: unknown -): void { +): asserts fieldPath is string | FieldPath { if (fieldPath instanceof FieldPath) { return; } diff --git a/dev/src/pool.ts b/dev/src/pool.ts index be234673f..e46fd0b7a 100644 --- a/dev/src/pool.ts +++ b/dev/src/pool.ts @@ -19,6 +19,9 @@ import * as assert from 'assert'; import {logger} from './logger'; import {Deferred} from './util'; +export const CLIENT_TERMINATED_ERROR_MSG = + 'The client has already been terminated'; + /** * An auto-resizing pool that distributes concurrent operations over multiple * clients of type `T`. @@ -142,7 +145,7 @@ export class ClientPool { } let idleCapacityCount = 0; - for (const [_, count] of this.activeClients) { + for (const [, count] of this.activeClients) { idleCapacityCount += this.concurrentOperationLimit - count; } return ( @@ -187,9 +190,7 @@ export class ClientPool { */ run(requestTag: string, op: (client: T) => Promise): Promise { if (this.terminated) { - return Promise.reject( - new Error('The client has already been terminated') - ); + return Promise.reject(new Error(CLIENT_TERMINATED_ERROR_MSG)); } const client = this.acquire(requestTag); @@ -217,7 +218,7 @@ export class ClientPool { ); await this.terminateDeferred.promise; } - for (const [client, _requestCount] of this.activeClients) { + for (const [client] of this.activeClients) { this.activeClients.delete(client); await this.clientDestructor(client); } diff --git a/dev/src/rate-limiter.ts b/dev/src/rate-limiter.ts index c3ee91d33..b3f5ccca3 100644 --- a/dev/src/rate-limiter.ts +++ b/dev/src/rate-limiter.ts @@ -15,8 +15,6 @@ */ import * as assert from 'assert'; -import {Timestamp} from './timestamp'; - /** * A helper that uses the Token Bucket algorithm to rate limit the number of * operations that can be made in a second. @@ -60,7 +58,7 @@ export class RateLimiter { * Tries to make the number of operations. Returns true if the request * succeeded and false otherwise. * - * @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 */ @@ -82,7 +80,7 @@ export class RateLimiter { * capacity. Returns -1 if the request is not possible with the current * capacity. * - * @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 */ @@ -108,11 +106,11 @@ export class RateLimiter { * Refills the number of available tokens based on how much time has elapsed * since the last time the tokens were refilled. * - * @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 */ - private refillTokens(requestTimeMillis = Date.now()): void { + private refillTokens(requestTimeMillis: number): void { if (requestTimeMillis >= this.lastRefillTimeMillis) { const elapsedTime = requestTimeMillis - this.lastRefillTimeMillis; const capacity = this.calculateCapacity(requestTimeMillis); diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 7003c4378..857afbc84 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -const deepEqual = require('deep-equal'); +import * as firestore from '@google-cloud/firestore'; -import * as through2 from 'through2'; +import {Transform} from 'stream'; +import * as deepEqual from 'fast-deep-equal'; -import * as proto from '../protos/firestore_v1_proto_api'; +import * as protos from '../protos/firestore_v1_proto_api'; import { DocumentSnapshot, @@ -38,16 +39,7 @@ import { } from './path'; import {Serializable, Serializer, validateUserInput} from './serializer'; import {Timestamp} from './timestamp'; -import { - defaultConverter, - DocumentData, - FirestoreDataConverter, - OrderByDirection, - Precondition, - SetOptions, - UpdateData, - WhereFilterOp, -} from './types'; +import {defaultConverter} from './types'; import { autoId, Deferred, @@ -65,7 +57,7 @@ import { import {DocumentWatch, QueryWatch} from './watch'; import {validateDocumentData, WriteBatch, WriteResult} from './write-batch'; -import api = proto.google.firestore.v1; +import api = protos.google.firestore.v1; /** * The direction of a `Query.orderBy()` clause is specified as 'desc' or 'asc' @@ -129,7 +121,8 @@ const comparisonOperators: { * * @class */ -export class DocumentReference implements Serializable { +export class DocumentReference + implements Serializable, firestore.DocumentReference { /** * @hideconstructor * @@ -139,7 +132,7 @@ export class DocumentReference implements Serializable { constructor( private readonly _firestore: Firestore, readonly _path: ResourcePath, - readonly _converter = defaultConverter as FirestoreDataConverter + readonly _converter = defaultConverter() ) {} /** @@ -295,7 +288,9 @@ export class DocumentReference implements Serializable { * } * }); */ - listCollections(): Promise>> { + listCollections(): Promise< + Array> + > { const tag = requestTag(); return this.firestore.initializeIfNeeded(tag).then(() => { const request: api.IListCollectionIdsRequest = { @@ -312,7 +307,9 @@ export class DocumentReference implements Serializable { tag ) .then(collectionIds => { - const collections: Array> = []; + const collections: Array> = []; // We can just sort this list using the default comparator since it // will only contain collection ids. @@ -374,7 +371,7 @@ export class DocumentReference implements Serializable { * console.log('Document successfully deleted.'); * }); */ - delete(precondition?: Precondition): Promise { + delete(precondition?: firestore.Precondition): Promise { const writeBatch = new WriteBatch(this._firestore); return writeBatch .delete(this, precondition) @@ -382,13 +379,15 @@ export class DocumentReference implements Serializable { .then(([writeResult]) => writeResult); } + set(data: Partial, options: firestore.SetOptions): Promise; + set(data: T): Promise; /** * 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 {T|Partial} 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. @@ -405,7 +404,10 @@ export class DocumentReference implements Serializable { * console.log(`Document written at ${res.updateTime}`); * }); */ - set(data: T, options?: SetOptions): Promise { + set( + data: T | Partial, + options?: firestore.SetOptions + ): Promise { const writeBatch = new WriteBatch(this._firestore); return writeBatch .set(this, data, options) @@ -443,18 +445,17 @@ export class DocumentReference implements Serializable { * }); */ update( - dataOrField: UpdateData | string | FieldPath, - ...preconditionOrValues: Array + dataOrField: firestore.UpdateData | string | firestore.FieldPath, + ...preconditionOrValues: Array< + unknown | string | firestore.FieldPath | firestore.Precondition + > ): Promise { + // eslint-disable-next-line prefer-rest-params validateMinNumberOfArguments('DocumentReference.update', arguments, 1); const writeBatch = new WriteBatch(this._firestore); return writeBatch - .update( - this as DocumentReference, - dataOrField, - ...preconditionOrValues - ) + .update(this, dataOrField, ...preconditionOrValues) .commit() .then(([writeResult]) => writeResult); } @@ -486,7 +487,7 @@ export class DocumentReference implements Serializable { * unsubscribe(); */ onSnapshot( - onNext: (snapshot: DocumentSnapshot) => void, + onNext: (snapshot: firestore.DocumentSnapshot) => void, onError?: (error: Error) => void ): () => void { validateFunction('onNext', onNext); @@ -521,7 +522,7 @@ export class DocumentReference implements Serializable { * @return {boolean} true if this `DocumentReference` is equal to the provided * value. */ - isEqual(other: DocumentReference): boolean { + isEqual(other: firestore.DocumentReference): boolean { return ( this === other || (other instanceof DocumentReference && @@ -541,11 +542,10 @@ export class DocumentReference implements Serializable { } /** - * 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. * * Using the converter allows you to specify generic type arguments when * storing and retrieving objects from Firestore. @@ -564,8 +564,9 @@ export class DocumentReference implements Serializable { * return {title: post.title, author: post.author}; * }, * fromFirestore( - * data: FirebaseFirestore.DocumentData + * snapshot: FirebaseFirestore.QueryDocumentSnapshot * ): Post { + * const data = snapshot.data(); * return new Post(data.title, data.author); * } * }; @@ -581,10 +582,13 @@ export class DocumentReference implements Serializable { * post.someNonExistentProperty; // TS error * } * - * @param converter Converts objects to and from Firestore. + * @param {FirestoreDataConverter} converter Converts objects to and from + * Firestore. * @return A DocumentReference that uses the provided converter. */ - withConverter(converter: FirestoreDataConverter): DocumentReference { + withConverter( + converter: firestore.FirestoreDataConverter + ): DocumentReference { return new DocumentReference(this.firestore, this._path, converter); } } @@ -711,7 +715,8 @@ class FieldFilter { * * @class QuerySnapshot */ -export class QuerySnapshot { +export class QuerySnapshot + implements firestore.QuerySnapshot { private _materializedDocs: Array> | null = null; private _materializedChanges: Array> | null = null; private _docs: (() => Array>) | null = null; @@ -890,7 +895,7 @@ export class QuerySnapshot { * }); */ forEach( - callback: (result: QueryDocumentSnapshot) => void, + callback: (result: firestore.QueryDocumentSnapshot) => void, thisArg?: unknown ): void { validateFunction('callback', callback); @@ -908,7 +913,7 @@ export class QuerySnapshot { * @return {boolean} true if this `QuerySnapshot` is equal to the provided * value. */ - isEqual(other: QuerySnapshot): boolean { + isEqual(other: firestore.QuerySnapshot): boolean { // Since the read time is different on every query read, we explicitly // ignore all metadata in this comparison. @@ -944,31 +949,6 @@ export class QuerySnapshot { } } -// TODO: As of v0.17.0, we're changing docChanges from an array into a method. -// Because this is a runtime breaking change and somewhat subtle (both Array and -// Function have a .length, etc.), we'll replace commonly-used properties -// (including Symbol.iterator) to throw a custom error message. By our v1.0 -// release, we should remove this code. -function throwDocChangesMethodError() { - throw new Error( - 'QuerySnapshot.docChanges has been changed from a property into a ' + - 'method, so usages like "querySnapshot.docChanges" should become ' + - '"querySnapshot.docChanges()"' - ); -} - -const docChangesPropertiesToOverride = [ - 'length', - 'forEach', - 'map', - ...(typeof Symbol !== 'undefined' ? [Symbol.iterator] : []), -]; -docChangesPropertiesToOverride.forEach(property => { - Object.defineProperty(QuerySnapshot.prototype.docChanges, property, { - get: () => throwDocChangesMethodError(), - }); -}); - /** Internal representation of a query cursor before serialization. */ interface QueryCursor { before: boolean; @@ -994,7 +974,7 @@ export class QueryOptions { constructor( readonly parentPath: ResourcePath, readonly collectionId: string, - readonly converter: FirestoreDataConverter, + readonly converter: firestore.FirestoreDataConverter, readonly allDescendants: boolean, readonly fieldFilters: FieldFilter[], readonly fieldOrders: FieldOrder[], @@ -1012,7 +992,7 @@ export class QueryOptions { */ static forCollectionGroupQuery( collectionId: string, - converter = defaultConverter as FirestoreDataConverter + converter = defaultConverter() ): QueryOptions { return new QueryOptions( /*parentPath=*/ ResourcePath.EMPTY, @@ -1030,7 +1010,7 @@ export class QueryOptions { */ static forCollectionQuery( collectionRef: ResourcePath, - converter = defaultConverter as FirestoreDataConverter + converter = defaultConverter() ): QueryOptions { return new QueryOptions( collectionRef.parent()!, @@ -1063,7 +1043,9 @@ export class QueryOptions { ); } - withConverter(converter: FirestoreDataConverter): QueryOptions { + withConverter( + converter: firestore.FirestoreDataConverter + ): QueryOptions { return new QueryOptions( this.parentPath, this.collectionId, @@ -1084,7 +1066,7 @@ export class QueryOptions { return this.fieldOrders.length > 0; } - isEqual(other: QueryOptions) { + isEqual(other: QueryOptions): boolean { if (this === other) { return true; } @@ -1097,11 +1079,11 @@ export class QueryOptions { this.allDescendants === other.allDescendants && this.limit === other.limit && this.offset === other.offset && - deepEqual(this.fieldFilters, other.fieldFilters, {strict: true}) && - deepEqual(this.fieldOrders, other.fieldOrders, {strict: true}) && - deepEqual(this.startAt, other.startAt, {strict: true}) && - deepEqual(this.endAt, other.endAt, {strict: true}) && - deepEqual(this.projection, other.projection, {strict: true}) + deepEqual(this.fieldFilters, other.fieldFilters) && + deepEqual(this.fieldOrders, other.fieldOrders) && + deepEqual(this.startAt, other.startAt) && + deepEqual(this.endAt, other.endAt) && + deepEqual(this.projection, other.projection) ); } } @@ -1112,7 +1094,7 @@ export class QueryOptions { * * @class Query */ -export class Query { +export class Query implements firestore.Query { private readonly _serializer: Serializer; protected readonly _allowUndefined: boolean; @@ -1162,7 +1144,7 @@ export class Query { static _extractFieldValues( documentSnapshot: DocumentSnapshot, fieldOrders: FieldOrder[] - ) { + ): unknown[] { const fieldValues: unknown[] = []; for (const fieldOrder of fieldOrders) { @@ -1231,8 +1213,8 @@ export class Query { * }); */ where( - fieldPath: string | FieldPath, - opStr: WhereFilterOp, + fieldPath: string | firestore.FieldPath, + opStr: firestore.WhereFilterOp, value: unknown ): Query { validateFieldPath('fieldPath', fieldPath); @@ -1347,8 +1329,8 @@ export class Query { * }); */ orderBy( - fieldPath: string | FieldPath, - directionStr?: OrderByDirection + fieldPath: string | firestore.FieldPath, + directionStr?: firestore.OrderByDirection ): Query { validateFieldPath('fieldPath', fieldPath); directionStr = validateQueryOrder('directionStr', directionStr); @@ -1460,7 +1442,7 @@ export class Query { * @param {*} other The value to compare against. * @return {boolean} true if this `Query` is equal to the provided value. */ - isEqual(other: Query): boolean { + isEqual(other: firestore.Query): boolean { if (this === other) { return true; } @@ -1659,9 +1641,15 @@ export class Query { * }); */ startAt( - ...fieldValuesOrDocumentSnapshot: Array | unknown> + ...fieldValuesOrDocumentSnapshot: Array< + firestore.DocumentSnapshot | unknown + > ): Query { - validateMinNumberOfArguments('Query.startAt', arguments, 1); + validateMinNumberOfArguments( + 'Query.startAt', + fieldValuesOrDocumentSnapshot, + 1 + ); const fieldOrders = this.createImplicitOrderBy( fieldValuesOrDocumentSnapshot @@ -1697,9 +1685,15 @@ export class Query { * }); */ startAfter( - ...fieldValuesOrDocumentSnapshot: Array | unknown> + ...fieldValuesOrDocumentSnapshot: Array< + firestore.DocumentSnapshot | unknown + > ): Query { - validateMinNumberOfArguments('Query.startAfter', arguments, 1); + validateMinNumberOfArguments( + 'Query.startAfter', + fieldValuesOrDocumentSnapshot, + 1 + ); const fieldOrders = this.createImplicitOrderBy( fieldValuesOrDocumentSnapshot @@ -1734,9 +1728,15 @@ export class Query { * }); */ endBefore( - ...fieldValuesOrDocumentSnapshot: Array | unknown> + ...fieldValuesOrDocumentSnapshot: Array< + firestore.DocumentSnapshot | unknown + > ): Query { - validateMinNumberOfArguments('Query.endBefore', arguments, 1); + validateMinNumberOfArguments( + 'Query.endBefore', + fieldValuesOrDocumentSnapshot, + 1 + ); const fieldOrders = this.createImplicitOrderBy( fieldValuesOrDocumentSnapshot @@ -1771,9 +1771,15 @@ export class Query { * }); */ endAt( - ...fieldValuesOrDocumentSnapshot: Array | unknown> + ...fieldValuesOrDocumentSnapshot: Array< + firestore.DocumentSnapshot | unknown + > ): Query { - validateMinNumberOfArguments('Query.endAt', arguments, 1); + validateMinNumberOfArguments( + 'Query.endAt', + fieldValuesOrDocumentSnapshot, + 1 + ); const fieldOrders = this.createImplicitOrderBy( fieldValuesOrDocumentSnapshot @@ -1888,13 +1894,11 @@ export class Query { } const responseStream = this._stream(); - - const transform = through2.obj(function(this, chunk, encoding, callback) { - // Only send chunks with documents. - if (chunk.document) { - this.push(chunk.document); - } - callback(); + const transform = new Transform({ + objectMode: true, + transform(chunk, encoding, callback) { + callback(undefined, chunk.document); + }, }); responseStream.pipe(transform); @@ -1936,38 +1940,10 @@ export class Query { projectId ); - const reqOpts: api.IRunQueryRequest = { - parent: parentPath.formattedName, - structuredQuery: { - from: [ - { - collectionId: this._queryOptions.collectionId, - }, - ], - }, - }; - - if (this._queryOptions.allDescendants) { - reqOpts.structuredQuery!.from![0].allDescendants = true; - } - - const structuredQuery = reqOpts.structuredQuery!; - - if (this._queryOptions.fieldFilters.length === 1) { - structuredQuery.where = this._queryOptions.fieldFilters[0].toProto(); - } else if (this._queryOptions.fieldFilters.length > 1) { - const filters: api.StructuredQuery.IFilter[] = []; - for (const fieldFilter of this._queryOptions.fieldFilters) { - filters.push(fieldFilter.toProto()); - } - structuredQuery.where = { - compositeFilter: { - op: 'AND', - filters, - }, - }; - } + const structuredQuery = this.toStructuredQuery(); + // For limitToLast queries, the structured query has to be translated to a version with + // reversed ordered, and flipped startAt/endAt to work properly. if (this._queryOptions.limitType === LimitType.Last) { if (!this._queryOptions.hasFieldOrders()) { throw new Error( @@ -1995,16 +1971,82 @@ export class Query { before: !this._queryOptions.startAt.before, }) : undefined; - } else { - if (this._queryOptions.hasFieldOrders()) { - structuredQuery.orderBy = this._queryOptions.fieldOrders.map(o => - o.toProto() - ); + } + + const runQueryRequest: api.IRunQueryRequest = { + parent: parentPath.formattedName, + structuredQuery, + }; + + if (transactionIdOrReadTime instanceof Uint8Array) { + runQueryRequest.transaction = transactionIdOrReadTime; + } else if (transactionIdOrReadTime instanceof Timestamp) { + runQueryRequest.readTime = transactionIdOrReadTime.toProto().timestampValue; + } + + return runQueryRequest; + } + + /** + * Converts current Query to an IBundledQuery. + */ + _toBundledQuery(): protos.firestore.IBundledQuery { + const projectId = this.firestore.projectId; + const parentPath = this._queryOptions.parentPath.toQualifiedResourcePath( + projectId + ); + const structuredQuery = this.toStructuredQuery(); + + const bundledQuery: protos.firestore.IBundledQuery = { + parent: parentPath.formattedName, + structuredQuery, + }; + if (this._queryOptions.limitType === LimitType.First) { + bundledQuery.limitType = 'FIRST'; + } else if (this._queryOptions.limitType === LimitType.Last) { + bundledQuery.limitType = 'LAST'; + } + + return bundledQuery; + } + + private toStructuredQuery(): api.IStructuredQuery { + const structuredQuery: api.IStructuredQuery = { + from: [ + { + collectionId: this._queryOptions.collectionId, + }, + ], + }; + + if (this._queryOptions.allDescendants) { + structuredQuery.from![0].allDescendants = true; + } + + if (this._queryOptions.fieldFilters.length === 1) { + structuredQuery.where = this._queryOptions.fieldFilters[0].toProto(); + } else if (this._queryOptions.fieldFilters.length > 1) { + const filters: api.StructuredQuery.IFilter[] = []; + for (const fieldFilter of this._queryOptions.fieldFilters) { + filters.push(fieldFilter.toProto()); } - structuredQuery.startAt = this.toCursor(this._queryOptions.startAt); - structuredQuery.endAt = this.toCursor(this._queryOptions.endAt); + structuredQuery.where = { + compositeFilter: { + op: 'AND', + filters, + }, + }; + } + + if (this._queryOptions.hasFieldOrders()) { + structuredQuery.orderBy = this._queryOptions.fieldOrders.map(o => + o.toProto() + ); } + structuredQuery.startAt = this.toCursor(this._queryOptions.startAt); + structuredQuery.endAt = this.toCursor(this._queryOptions.endAt); + if (this._queryOptions.limit) { structuredQuery.limit = {value: this._queryOptions.limit}; } @@ -2012,12 +2054,7 @@ export class Query { structuredQuery.offset = this._queryOptions.offset; structuredQuery.select = this._queryOptions.projection; - if (transactionIdOrReadTime instanceof Uint8Array) { - reqOpts.transaction = transactionIdOrReadTime; - } else if (transactionIdOrReadTime instanceof Timestamp) { - reqOpts.readTime = transactionIdOrReadTime.toProto().timestampValue; - } - return reqOpts; + return structuredQuery; } /** @@ -2029,32 +2066,33 @@ export class Query { */ _stream(transactionId?: Uint8Array): NodeJS.ReadableStream { const tag = requestTag(); - const self = this; let lastReceivedDocument: QueryDocumentSnapshot | null = null; - const stream = through2.obj(function(this, proto, enc, callback) { - const readTime = Timestamp.fromProto(proto.readTime); - if (proto.document) { - const document = self.firestore.snapshot_( - proto.document, - proto.readTime - ); - const finalDoc = new DocumentSnapshotBuilder( - document.ref.withConverter(self._queryOptions.converter) - ); - // Recreate the QueryDocumentSnapshot with the DocumentReference - // containing the original converter. - finalDoc.fieldsProto = document._fieldsProto; - finalDoc.readTime = document.readTime; - finalDoc.createTime = document.createTime; - finalDoc.updateTime = document.updateTime; - lastReceivedDocument = finalDoc.build() as QueryDocumentSnapshot; - this.push({document: lastReceivedDocument, readTime}); - } else { - this.push({readTime}); - } - callback(); + const stream = new Transform({ + objectMode: true, + transform: (proto, enc, callback) => { + const readTime = Timestamp.fromProto(proto.readTime); + if (proto.document) { + const document = this.firestore.snapshot_( + proto.document, + proto.readTime + ); + const finalDoc = new DocumentSnapshotBuilder( + document.ref.withConverter(this._queryOptions.converter) + ); + // Recreate the QueryDocumentSnapshot with the DocumentReference + // containing the original converter. + finalDoc.fieldsProto = document._fieldsProto; + finalDoc.readTime = document.readTime; + finalDoc.createTime = document.createTime; + finalDoc.updateTime = document.updateTime; + lastReceivedDocument = finalDoc.build() as QueryDocumentSnapshot; + callback(undefined, {document: lastReceivedDocument, readTime}); + } else { + callback(undefined, {readTime}); + } + }, }); this.firestore @@ -2142,7 +2180,7 @@ export class Query { * unsubscribe(); */ onSnapshot( - onNext: (snapshot: QuerySnapshot) => void, + onNext: (snapshot: firestore.QuerySnapshot) => void, onError?: (error: Error) => void ): () => void { validateFunction('onNext', onNext); @@ -2230,8 +2268,9 @@ export class Query { * return {title: post.title, author: post.author}; * }, * fromFirestore( - * data: FirebaseFirestore.DocumentData + * snapshot: FirebaseFirestore.QueryDocumentSnapshot * ): Post { + * const data = snapshot.data(); * return new Post(data.title, data.author); * } * }; @@ -2247,10 +2286,11 @@ export class Query { * post.someNonExistentProperty; // TS error * } * - * @param converter Converts objects to and from Firestore. + * @param {FirestoreDataConverter} converter Converts objects to and from + * Firestore. * @return A Query that uses the provided converter. */ - withConverter(converter: FirestoreDataConverter): Query { + withConverter(converter: firestore.FirestoreDataConverter): Query { return new Query( this.firestore, this._queryOptions.withConverter(converter) @@ -2266,7 +2306,8 @@ export class Query { * @class * @extends Query */ -export class CollectionReference extends Query { +export class CollectionReference extends Query + implements firestore.CollectionReference { /** * @hideconstructor * @@ -2276,7 +2317,7 @@ export class CollectionReference extends Query { constructor( firestore: Firestore, path: ResourcePath, - converter?: FirestoreDataConverter + converter?: firestore.FirestoreDataConverter ) { super(firestore, QueryOptions.forCollectionQuery(path, converter)); } @@ -2285,7 +2326,7 @@ export class CollectionReference extends Query { * Returns a resource path for this collection. * @private */ - private get resourcePath() { + private get resourcePath(): ResourcePath { return this._queryOptions.parentPath.append( this._queryOptions.collectionId ); @@ -2319,7 +2360,7 @@ export class CollectionReference extends Query { * let documentRef = collectionRef.parent; * console.log(`Parent name: ${documentRef.path}`); */ - get parent(): DocumentReference | null { + get parent(): DocumentReference | null { if (this._queryOptions.parentPath.isDocument) { return new DocumentReference( this.firestore, @@ -2485,7 +2526,7 @@ export class CollectionReference extends Query { * @return {boolean} true if this `CollectionReference` is equal to the * provided value. */ - isEqual(other: CollectionReference): boolean { + isEqual(other: firestore.CollectionReference): boolean { return ( this === other || (other instanceof CollectionReference && super.isEqual(other)) @@ -2494,8 +2535,8 @@ export class CollectionReference extends Query { /** * 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. * * Using the converter allows you to specify generic type arguments when @@ -2515,8 +2556,9 @@ export class CollectionReference extends Query { * return {title: post.title, author: post.author}; * }, * fromFirestore( - * data: FirebaseFirestore.DocumentData + * snapshot: FirebaseFirestore.QueryDocumentSnapshot * ): Post { + * const data = snapshot.data(); * return new Post(data.title, data.author); * } * }; @@ -2532,11 +2574,12 @@ export class CollectionReference extends Query { * post.someNonExistentProperty; // TS error * } * - * @param converter Converts objects to and from Firestore. + * @param {FirestoreDataConverter} converter Converts objects to and from + * Firestore. * @return A CollectionReference that uses the provided converter. */ withConverter( - converter: FirestoreDataConverter + converter: firestore.FirestoreDataConverter ): CollectionReference { return new CollectionReference( this.firestore, @@ -2559,11 +2602,11 @@ export class CollectionReference extends Query { export function validateQueryOrder( arg: string, op: unknown -): OrderByDirection | undefined { +): firestore.OrderByDirection | undefined { // For backwards compatibility, we support both lower and uppercase values. op = typeof op === 'string' ? op.toLowerCase() : op; validateEnumValue(arg, op, Object.keys(directionOperators), {optional: true}); - return op as OrderByDirection | undefined; + return op as firestore.OrderByDirection | undefined; } /** @@ -2581,7 +2624,7 @@ export function validateQueryOperator( arg: string | number, op: unknown, fieldValue: unknown -): WhereFilterOp { +): firestore.WhereFilterOp { // For backwards compatibility, we support both `=` and `==` for "equals". op = op === '=' ? '==' : op; @@ -2599,7 +2642,7 @@ export function validateQueryOperator( ); } - return op as WhereFilterOp; + return op as firestore.WhereFilterOp; } /** @@ -2608,14 +2651,16 @@ export function validateQueryOperator( * @private * @param arg The argument name or argument index (for varargs methods). * @param value The argument to validate. + * @return the DocumentReference if valid */ export function validateDocumentReference( arg: string | number, value: unknown -): void { +): DocumentReference { if (!(value instanceof DocumentReference)) { throw new Error(invalidArgumentMessage(arg, 'DocumentReference')); } + return value; } /** diff --git a/dev/src/serializer.ts b/dev/src/serializer.ts index 3936bfbcc..c1de7a289 100644 --- a/dev/src/serializer.ts +++ b/dev/src/serializer.ts @@ -14,16 +14,17 @@ * limitations under the License. */ +import {DocumentData} from '@google-cloud/firestore'; + import * as proto from '../protos/firestore_v1_proto_api'; import {detectValueType} from './convert'; -import {FieldTransform} from './field-value'; -import {DeleteTransform} from './field-value'; +import {DeleteTransform, FieldTransform} from './field-value'; import {GeoPoint} from './geo-point'; import {DocumentReference, Firestore} from './index'; import {FieldPath, QualifiedResourcePath} from './path'; import {Timestamp} from './timestamp'; -import {ApiMapValue, DocumentData, ValidationOptions} from './types'; +import {ApiMapValue, ValidationOptions} from './types'; import {isEmpty, isObject, isPlainObject} from './util'; import {customObjectMessage, invalidArgumentMessage} from './validate'; @@ -54,12 +55,15 @@ export interface Serializable { export class Serializer { private allowUndefined: boolean; private createReference: (path: string) => DocumentReference; + private createInteger: (n: number | string) => number | BigInt; constructor(firestore: Firestore) { // Instead of storing the `firestore` object, we store just a reference to // its `.doc()` method. This avoid a circular reference, which breaks // JSON.stringify(). this.createReference = path => firestore.doc(path); + this.createInteger = n => + firestore._settings.useBigInt ? BigInt(n) : Number(n); this.allowUndefined = !!firestore._settings.ignoreUndefinedProperties; } @@ -120,6 +124,12 @@ export class Serializer { } } + if (typeof val === 'bigint') { + return { + integerValue: val.toString(), + }; + } + if (val instanceof Date) { const timestamp = Timestamp.fromDate(val); return { @@ -219,14 +229,13 @@ export class Serializer { return proto.booleanValue; } 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.fromProto(proto.timestampValue!); - return timestamp; + return Timestamp.fromProto(proto.timestampValue!); } case 'referenceValue': { const resourcePath = QualifiedResourcePath.fromSlashSeparatedString( @@ -304,7 +313,6 @@ export function validateUserInput( ); } - options = options || {}; level = level || 0; inArray = inArray || false; @@ -410,13 +418,12 @@ export function validateUserInput( * Returns true if value is a MomentJs date object. * @private */ -function isMomentJsType(value: unknown): value is {toDate: () => Date} { +function isMomentJsType(value: unknown): value is {toDate(): Date} { return ( typeof value === 'object' && value !== null && value.constructor && value.constructor.name === 'Moment' && - // tslint:disable-next-line:no-any - typeof (value as any).toDate === 'function' + typeof (value as {toDate: unknown}).toDate === 'function' ); } diff --git a/dev/src/timestamp.ts b/dev/src/timestamp.ts index 27d13b180..4d3a57415 100644 --- a/dev/src/timestamp.ts +++ b/dev/src/timestamp.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import * as firestore from '@google-cloud/firestore'; + import {google} from '../protos/firestore_v1_proto_api'; import {validateInteger} from './validate'; @@ -55,7 +57,7 @@ const MAX_SECONDS = 253402300799; * * @see https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto */ -export class Timestamp { +export class Timestamp implements firestore.Timestamp { private readonly _seconds: number; private readonly _nanoseconds: number; @@ -69,7 +71,7 @@ export class Timestamp { * * @return {Timestamp} A new `Timestamp` representing the current date. */ - static now() { + static now(): Timestamp { return Timestamp.fromMillis(Date.now()); } @@ -86,7 +88,7 @@ export class Timestamp { * @return {Timestamp} A new `Timestamp` representing the same point in time * as the given date. */ - static fromDate(date: Date) { + static fromDate(date: Date): Timestamp { return Timestamp.fromMillis(date.getTime()); } @@ -103,7 +105,7 @@ export class Timestamp { * @return {Timestamp} A new `Timestamp` representing the same point in time * as the given number of milliseconds. */ - static fromMillis(milliseconds: number) { + static fromMillis(milliseconds: number): Timestamp { const seconds = Math.floor(milliseconds / 1000); const nanos = (milliseconds - seconds * 1000) * MS_TO_NANOS; return new Timestamp(seconds, nanos); @@ -115,11 +117,8 @@ export class Timestamp { * @private * @param {Object} timestamp The `Timestamp` Protobuf object. */ - static fromProto(timestamp: google.protobuf.ITimestamp) { - return new Timestamp( - Number(timestamp.seconds || 0), - Number(timestamp.nanos || 0) - ); + static fromProto(timestamp: google.protobuf.ITimestamp): Timestamp { + return new Timestamp(Number(timestamp.seconds || 0), timestamp.nanos || 0); } /** @@ -165,7 +164,7 @@ export class Timestamp { * * @type {number} */ - get seconds() { + get seconds(): number { return this._seconds; } @@ -182,7 +181,7 @@ export class Timestamp { * * @type {number} */ - get nanoseconds() { + get nanoseconds(): number { return this._nanoseconds; } @@ -200,7 +199,7 @@ export class Timestamp { * @return {Date} JavaScript `Date` object representing the same point in time * as this `Timestamp`, with millisecond precision. */ - toDate() { + toDate(): Date { return new Date( this._seconds * 1000 + Math.round(this._nanoseconds / MS_TO_NANOS) ); @@ -222,7 +221,7 @@ export class Timestamp { * represented as the number of milliseconds since Unix epoch * 1970-01-01T00:00:00Z. */ - toMillis() { + toMillis(): number { return this._seconds * 1000 + Math.floor(this._nanoseconds / MS_TO_NANOS); } @@ -241,7 +240,7 @@ export class Timestamp { * @param {any} other The `Timestamp` to compare against. * @return {boolean} 'true' if this `Timestamp` is equal to the provided one. */ - isEqual(other: Timestamp): boolean { + isEqual(other: firestore.Timestamp): boolean { return ( this === other || (other instanceof Timestamp && diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index 833db2a59..12b3716de 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -14,12 +14,14 @@ * limitations under the License. */ +import * as firestore from '@google-cloud/firestore'; + import {GoogleError, Status} from 'google-gax'; import * as proto from '../protos/firestore_v1_proto_api'; import {ExponentialBackoff} from './backoff'; -import {DocumentSnapshot, Precondition} from './document'; +import {DocumentSnapshot} from './document'; import {Firestore, WriteBatch} from './index'; import {logger} from './logger'; import {FieldPath, validateFieldPath} from './path'; @@ -29,13 +31,6 @@ import { QuerySnapshot, validateDocumentReference, } from './reference'; -import { - DocumentData, - Precondition as PublicPrecondition, - ReadOptions, - SetOptions, - UpdateData, -} from './types'; import {isObject, isPlainObject} from './util'; import { invalidArgumentMessage, @@ -62,7 +57,7 @@ const READ_AFTER_WRITE_ERROR_MSG = * * @class */ -export class Transaction { +export class Transaction implements firestore.Transaction { private _firestore: Firestore; private _writeBatch: WriteBatch; private _backoff: ExponentialBackoff; @@ -178,13 +173,19 @@ export class Transaction { * }); */ getAll( - ...documentRefsOrReadOptions: Array | ReadOptions> + ...documentRefsOrReadOptions: Array< + firestore.DocumentReference | firestore.ReadOptions + > ): Promise>> { if (!this._writeBatch.isEmpty) { throw new Error(READ_AFTER_WRITE_ERROR_MSG); } - validateMinNumberOfArguments('Transaction.getAll', arguments, 1); + validateMinNumberOfArguments( + 'Transaction.getAll', + documentRefsOrReadOptions, + 1 + ); const {documents, fieldMask} = parseGetAllArguments( documentRefsOrReadOptions @@ -219,11 +220,17 @@ export class Transaction { * }); * }); */ - create(documentRef: DocumentReference, data: T): Transaction { + create(documentRef: firestore.DocumentReference, data: T): Transaction { this._writeBatch.create(documentRef, data); return this; } + set( + documentRef: firestore.DocumentReference, + data: Partial, + options: firestore.SetOptions + ): Transaction; + set(documentRef: firestore.DocumentReference, data: T): Transaction; /** * Writes to the document referred to by the provided * [DocumentReference]{@link DocumentReference}. If the document @@ -233,7 +240,7 @@ export class Transaction { * * @param {DocumentReference} documentRef A reference to the document to be * set. - * @param {T} data The object to serialize as the document. + * @param {T|Partial} 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 @@ -252,9 +259,9 @@ export class Transaction { * }); */ set( - documentRef: DocumentReference, - data: T, - options?: SetOptions + documentRef: firestore.DocumentReference, + data: T | Partial, + options?: firestore.SetOptions ): Transaction { this._writeBatch.set(documentRef, data, options); return this; @@ -299,10 +306,13 @@ export class Transaction { * }); */ update( - documentRef: DocumentReference, - dataOrField: UpdateData | string | FieldPath, - ...preconditionOrValues: Array + documentRef: firestore.DocumentReference, + dataOrField: firestore.UpdateData | string | firestore.FieldPath, + ...preconditionOrValues: Array< + firestore.Precondition | unknown | string | firestore.FieldPath + > ): Transaction { + // eslint-disable-next-line prefer-rest-params validateMinNumberOfArguments('Transaction.update', arguments, 2); this._writeBatch.update(documentRef, dataOrField, ...preconditionOrValues); @@ -332,7 +342,7 @@ export class Transaction { */ delete( documentRef: DocumentReference, - precondition?: PublicPrecondition + precondition?: firestore.Precondition ): this { this._writeBatch.delete(documentRef, precondition); return this; @@ -374,7 +384,7 @@ export class Transaction { */ commit(): Promise { return this._writeBatch - .commit_({ + ._commit({ transactionId: this._transactionId, requestTag: this._requestTag, }) @@ -417,7 +427,7 @@ export class Transaction { logger( 'Firestore.runTransaction', this._requestTag, - `Retrying transaction after error:`, + 'Retrying transaction after error:', lastError ); } @@ -470,7 +480,7 @@ export class Transaction { * @private * @return A Promise that resolves after the delay expired. */ - private async maybeBackoff(error?: GoogleError) { + private async maybeBackoff(error?: GoogleError): Promise { if (error && error.code === Status.RESOURCE_EXHAUSTED) { this._backoff.resetToMax(); } @@ -487,10 +497,12 @@ export class Transaction { * an optional ReadOptions object. */ export function parseGetAllArguments( - documentRefsOrReadOptions: Array | ReadOptions> + documentRefsOrReadOptions: Array< + firestore.DocumentReference | firestore.ReadOptions + > ): {documents: Array>; fieldMask: FieldPath[] | null} { let documents: Array>; - let readOptions: ReadOptions | undefined = undefined; + let readOptions: firestore.ReadOptions | undefined = undefined; if (Array.isArray(documentRefsOrReadOptions[0])) { throw new Error( @@ -505,7 +517,7 @@ export function parseGetAllArguments( documentRefsOrReadOptions[documentRefsOrReadOptions.length - 1] ) ) { - readOptions = documentRefsOrReadOptions.pop() as ReadOptions; + readOptions = documentRefsOrReadOptions.pop() as firestore.ReadOptions; documents = documentRefsOrReadOptions as Array>; } else { documents = documentRefsOrReadOptions as Array>; diff --git a/dev/src/types.ts b/dev/src/types.ts index a2ae70988..1048c9b9e 100644 --- a/dev/src/types.ts +++ b/dev/src/types.ts @@ -14,14 +14,16 @@ * limitations under the License. */ +import {FirestoreDataConverter, DocumentData} from '@google-cloud/firestore'; + import {CallOptions} from 'google-gax'; import {Duplex} from 'stream'; import {google} from '../protos/firestore_v1_proto_api'; import {FieldPath} from './path'; -import {Timestamp} from './timestamp'; import api = google.firestore.v1; +import {QueryDocumentSnapshot} from './document'; /** * A map in the format of the Proto API @@ -94,143 +96,32 @@ export type UnaryMethod = ( // We don't have type information for the npm package // `functional-red-black-tree`. -// tslint:disable-next-line:no-any +// eslint-disable-next-line @typescript-eslint/no-explicit-any export type RBTree = any; -/** - * 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 { - /** - * 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. + * + * By declaring the converter as a variable instead of creating the object + * inside defaultConverter(), object equality when comparing default converters + * is preserved. * @private */ -export const defaultConverter: FirestoreDataConverter = { +const defaultConverterObj: FirestoreDataConverter = { toFirestore(modelObject: DocumentData): DocumentData { return modelObject; }, - fromFirestore(data: DocumentData): DocumentData { - return data; + fromFirestore(snapshot: QueryDocumentSnapshot): DocumentData { + return snapshot.data()!; }, }; /** - * 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; - - // tslint:disable-next-line:no-any - [key: string]: any; // Accept other properties, such as GRPC settings. -} - -/** - * Document data (for use with `DocumentReference.set()`) consists of fields - * mapped to values. - */ -export interface DocumentData { - // tslint:disable-next-line:no-any - [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. + * A default converter to use when none is provided. + * @private */ -export interface UpdateData { - [fieldPath: string]: unknown; +export function defaultConverter(): FirestoreDataConverter { + return defaultConverterObj as FirestoreDataConverter; } /** @@ -238,81 +129,6 @@ export interface UpdateData { */ export type UpdateMap = Map; -/** - * The direction of a `Query.orderBy()` clause is specified as 'desc' or 'asc' - * (descending or ascending). - */ -export type OrderByDirection = 'desc' | 'asc'; - -/** - * Filter conditions in a `Query.where()` clause are specified using the - * strings '<', '<=', '==', '>=', '>','array-contains', 'in', and - * 'array-contains-any'. - */ -export 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; -} - -/** - * 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; -} - /** * Internal user data validation options. * @private diff --git a/dev/src/util.ts b/dev/src/util.ts index b2e073d3b..408c50224 100644 --- a/dev/src/util.ts +++ b/dev/src/util.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import {DocumentData} from '@google-cloud/firestore'; + import {randomBytes} from 'crypto'; import { CallSettings, @@ -26,8 +28,6 @@ import { import {BackoffSettings} from 'google-gax/build/src/gax'; import * as gapicConfig from './v1/firestore_client_config.json'; -import {DocumentData} from './types'; - const serviceConfig = constructSettings( 'google.firestore.v1.Firestore', gapicConfig as ClientConfig, diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index f182d73a7..63d77a582 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -18,21 +18,21 @@ import * as gax from 'google-gax'; import { - APICallback, Callback, CallOptions, - ClientOptions, Descriptors, + ClientOptions, LROperation, PaginationCallback, - PaginationResponse, + GaxCall, } from 'google-gax'; import * as path from 'path'; import {Transform} from 'stream'; -import * as protosTypes from '../../protos/firestore_admin_v1_proto_api'; +import {RequestType} from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/firestore_admin_v1_proto_api'; import * as gapicConfig from './firestore_admin_client_config.json'; - +import {operationsProtos} from 'google-gax'; const version = require('../../../package.json').version; /** @@ -42,14 +42,6 @@ const version = require('../../../package.json').version; * @memberof v1 */ export class FirestoreAdminClient { - private _descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - private _innerApiCalls: {[name: string]: Function}; - private _pathTemplates: {[name: string]: gax.PathTemplate}; private _terminated = false; private _opts: ClientOptions; private _gaxModule: typeof gax | typeof gax.fallback; @@ -57,6 +49,14 @@ export class FirestoreAdminClient { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; operationsClient: gax.OperationsClient; firestoreAdminStub?: Promise<{[name: string]: Function}>; @@ -149,13 +149,16 @@ export class FirestoreAdminClient { 'protos.json' ); this._protos = this._gaxGrpc.loadProto( - opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath + 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}' ), @@ -173,7 +176,7 @@ export class FirestoreAdminClient { // 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 = { listIndexes: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', @@ -191,6 +194,7 @@ export class FirestoreAdminClient { // rather than holding a request open. const protoFilesRoot = opts.fallback ? this._gaxModule.protobuf.Root.fromJSON( + // eslint-disable-next-line @typescript-eslint/no-var-requires require('../../protos/protos.json') ) : this._gaxModule.protobuf.loadSync(nodejsProtoPath); @@ -226,7 +230,7 @@ export class FirestoreAdminClient { '.google.firestore.admin.v1.ImportDocumentsMetadata' ) as gax.protobuf.Type; - this._descriptors.longrunning = { + this.descriptors.longrunning = { createIndex: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createIndexResponse.decode.bind(createIndexResponse), @@ -260,7 +264,7 @@ export class FirestoreAdminClient { // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. - this._innerApiCalls = {}; + this.innerApiCalls = {}; } /** @@ -287,7 +291,7 @@ export class FirestoreAdminClient { ? (this._protos as protobuf.Root).lookupService( 'google.firestore.admin.v1.FirestoreAdmin' ) - : // tslint:disable-next-line no-any + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.firestore.admin.v1.FirestoreAdmin, this._opts ) as Promise<{[method: string]: Function}>; @@ -305,9 +309,8 @@ export class FirestoreAdminClient { 'exportDocuments', 'importDocuments', ]; - for (const methodName of firestoreAdminStubMethods) { - const innerCallPromise = this.firestoreAdminStub.then( + const callPromise = this.firestoreAdminStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject( @@ -323,20 +326,14 @@ export class FirestoreAdminClient { ); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], - this._descriptors.page[methodName] || - this._descriptors.stream[methodName] || - this._descriptors.longrunning[methodName] + this.descriptors.page[methodName] || + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); - this._innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.firestoreAdminStub; @@ -396,22 +393,30 @@ export class FirestoreAdminClient { // -- Service calls -- // ------------------- getIndex( - request: protosTypes.google.firestore.admin.v1.IGetIndexRequest, + request: protos.google.firestore.admin.v1.IGetIndexRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.firestore.admin.v1.IIndex, - protosTypes.google.firestore.admin.v1.IGetIndexRequest | undefined, + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IGetIndexRequest | undefined, {} | undefined ] >; getIndex( - request: protosTypes.google.firestore.admin.v1.IGetIndexRequest, + request: protos.google.firestore.admin.v1.IGetIndexRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.firestore.admin.v1.IIndex, - protosTypes.google.firestore.admin.v1.IGetIndexRequest | undefined, - {} | undefined + 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; /** @@ -429,23 +434,23 @@ export class FirestoreAdminClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ getIndex( - request: protosTypes.google.firestore.admin.v1.IGetIndexRequest, + request: protos.google.firestore.admin.v1.IGetIndexRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.firestore.admin.v1.IIndex, - protosTypes.google.firestore.admin.v1.IGetIndexRequest | undefined, - {} | undefined + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IGetIndexRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.firestore.admin.v1.IIndex, - protosTypes.google.firestore.admin.v1.IGetIndexRequest | undefined, - {} | undefined + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IGetIndexRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.firestore.admin.v1.IIndex, - protosTypes.google.firestore.admin.v1.IGetIndexRequest | undefined, + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IGetIndexRequest | undefined, {} | undefined ] > | void { @@ -466,25 +471,33 @@ export class FirestoreAdminClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.getIndex(request, options, callback); + return this.innerApiCalls.getIndex(request, options, callback); } deleteIndex( - request: protosTypes.google.firestore.admin.v1.IDeleteIndexRequest, + request: protos.google.firestore.admin.v1.IDeleteIndexRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.admin.v1.IDeleteIndexRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IDeleteIndexRequest | undefined, {} | undefined ] >; deleteIndex( - request: protosTypes.google.firestore.admin.v1.IDeleteIndexRequest, + request: protos.google.firestore.admin.v1.IDeleteIndexRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.admin.v1.IDeleteIndexRequest | undefined, - {} | undefined + 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; /** @@ -502,23 +515,25 @@ export class FirestoreAdminClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ deleteIndex( - request: protosTypes.google.firestore.admin.v1.IDeleteIndexRequest, + request: protos.google.firestore.admin.v1.IDeleteIndexRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.admin.v1.IDeleteIndexRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + | protos.google.firestore.admin.v1.IDeleteIndexRequest + | null + | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.admin.v1.IDeleteIndexRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IDeleteIndexRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.admin.v1.IDeleteIndexRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IDeleteIndexRequest | undefined, {} | undefined ] > | void { @@ -539,25 +554,33 @@ export class FirestoreAdminClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.deleteIndex(request, options, callback); + return this.innerApiCalls.deleteIndex(request, options, callback); } getField( - request: protosTypes.google.firestore.admin.v1.IGetFieldRequest, + request: protos.google.firestore.admin.v1.IGetFieldRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.firestore.admin.v1.IField, - protosTypes.google.firestore.admin.v1.IGetFieldRequest | undefined, + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IGetFieldRequest | undefined, {} | undefined ] >; getField( - request: protosTypes.google.firestore.admin.v1.IGetFieldRequest, + request: protos.google.firestore.admin.v1.IGetFieldRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.firestore.admin.v1.IField, - protosTypes.google.firestore.admin.v1.IGetFieldRequest | undefined, - {} | undefined + 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; /** @@ -575,23 +598,23 @@ export class FirestoreAdminClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ getField( - request: protosTypes.google.firestore.admin.v1.IGetFieldRequest, + request: protos.google.firestore.admin.v1.IGetFieldRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.firestore.admin.v1.IField, - protosTypes.google.firestore.admin.v1.IGetFieldRequest | undefined, - {} | undefined + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IGetFieldRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.firestore.admin.v1.IField, - protosTypes.google.firestore.admin.v1.IGetFieldRequest | undefined, - {} | undefined + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IGetFieldRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.firestore.admin.v1.IField, - protosTypes.google.firestore.admin.v1.IGetFieldRequest | undefined, + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IGetFieldRequest | undefined, {} | undefined ] > | void { @@ -612,32 +635,43 @@ export class FirestoreAdminClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.getField(request, options, callback); + return this.innerApiCalls.getField(request, options, callback); } createIndex( - request: protosTypes.google.firestore.admin.v1.ICreateIndexRequest, + request: protos.google.firestore.admin.v1.ICreateIndexRequest, options?: gax.CallOptions ): Promise< [ LROperation< - protosTypes.google.firestore.admin.v1.IIndex, - protosTypes.google.firestore.admin.v1.IIndexOperationMetadata + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IIndexOperationMetadata >, - protosTypes.google.longrunning.IOperation | undefined, + protos.google.longrunning.IOperation | undefined, {} | undefined ] >; createIndex( - request: protosTypes.google.firestore.admin.v1.ICreateIndexRequest, + request: protos.google.firestore.admin.v1.ICreateIndexRequest, options: gax.CallOptions, callback: Callback< LROperation< - protosTypes.google.firestore.admin.v1.IIndex, - protosTypes.google.firestore.admin.v1.IIndexOperationMetadata + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IIndexOperationMetadata >, - protosTypes.google.longrunning.IOperation | undefined, - {} | undefined + 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; /** @@ -659,32 +693,32 @@ export class FirestoreAdminClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ createIndex( - request: protosTypes.google.firestore.admin.v1.ICreateIndexRequest, + request: protos.google.firestore.admin.v1.ICreateIndexRequest, optionsOrCallback?: | gax.CallOptions | Callback< LROperation< - protosTypes.google.firestore.admin.v1.IIndex, - protosTypes.google.firestore.admin.v1.IIndexOperationMetadata + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IIndexOperationMetadata >, - protosTypes.google.longrunning.IOperation | undefined, - {} | undefined + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined >, callback?: Callback< LROperation< - protosTypes.google.firestore.admin.v1.IIndex, - protosTypes.google.firestore.admin.v1.IIndexOperationMetadata + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IIndexOperationMetadata >, - protosTypes.google.longrunning.IOperation | undefined, - {} | undefined + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined > ): Promise< [ LROperation< - protosTypes.google.firestore.admin.v1.IIndex, - protosTypes.google.firestore.admin.v1.IIndexOperationMetadata + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IIndexOperationMetadata >, - protosTypes.google.longrunning.IOperation | undefined, + protos.google.longrunning.IOperation | undefined, {} | undefined ] > | void { @@ -705,31 +739,78 @@ export class FirestoreAdminClient { parent: request.parent || '', }); 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: string + ): Promise< + LROperation< + protos.google.firestore.admin.v1.Index, + protos.google.firestore.admin.v1.IndexOperationMetadata + > + > { + const request = new 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 as LROperation< + protos.google.firestore.admin.v1.Index, + protos.google.firestore.admin.v1.IndexOperationMetadata + >; } updateField( - request: protosTypes.google.firestore.admin.v1.IUpdateFieldRequest, + request: protos.google.firestore.admin.v1.IUpdateFieldRequest, options?: gax.CallOptions ): Promise< [ LROperation< - protosTypes.google.firestore.admin.v1.IField, - protosTypes.google.firestore.admin.v1.IFieldOperationMetadata + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IFieldOperationMetadata >, - protosTypes.google.longrunning.IOperation | undefined, + protos.google.longrunning.IOperation | undefined, {} | undefined ] >; updateField( - request: protosTypes.google.firestore.admin.v1.IUpdateFieldRequest, + request: protos.google.firestore.admin.v1.IUpdateFieldRequest, options: gax.CallOptions, callback: Callback< LROperation< - protosTypes.google.firestore.admin.v1.IField, - protosTypes.google.firestore.admin.v1.IFieldOperationMetadata + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IFieldOperationMetadata >, - protosTypes.google.longrunning.IOperation | undefined, - {} | undefined + 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; /** @@ -761,32 +842,32 @@ export class FirestoreAdminClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ updateField( - request: protosTypes.google.firestore.admin.v1.IUpdateFieldRequest, + request: protos.google.firestore.admin.v1.IUpdateFieldRequest, optionsOrCallback?: | gax.CallOptions | Callback< LROperation< - protosTypes.google.firestore.admin.v1.IField, - protosTypes.google.firestore.admin.v1.IFieldOperationMetadata + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IFieldOperationMetadata >, - protosTypes.google.longrunning.IOperation | undefined, - {} | undefined + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined >, callback?: Callback< LROperation< - protosTypes.google.firestore.admin.v1.IField, - protosTypes.google.firestore.admin.v1.IFieldOperationMetadata + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IFieldOperationMetadata >, - protosTypes.google.longrunning.IOperation | undefined, - {} | undefined + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined > ): Promise< [ LROperation< - protosTypes.google.firestore.admin.v1.IField, - protosTypes.google.firestore.admin.v1.IFieldOperationMetadata + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IFieldOperationMetadata >, - protosTypes.google.longrunning.IOperation | undefined, + protos.google.longrunning.IOperation | undefined, {} | undefined ] > | void { @@ -807,31 +888,78 @@ export class FirestoreAdminClient { 'field.name': request.field!.name || '', }); 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: string + ): Promise< + LROperation< + protos.google.firestore.admin.v1.Field, + protos.google.firestore.admin.v1.FieldOperationMetadata + > + > { + const request = new 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 as LROperation< + protos.google.firestore.admin.v1.Field, + protos.google.firestore.admin.v1.FieldOperationMetadata + >; } exportDocuments( - request: protosTypes.google.firestore.admin.v1.IExportDocumentsRequest, + request: protos.google.firestore.admin.v1.IExportDocumentsRequest, options?: gax.CallOptions ): Promise< [ LROperation< - protosTypes.google.firestore.admin.v1.IExportDocumentsResponse, - protosTypes.google.firestore.admin.v1.IExportDocumentsMetadata + protos.google.firestore.admin.v1.IExportDocumentsResponse, + protos.google.firestore.admin.v1.IExportDocumentsMetadata >, - protosTypes.google.longrunning.IOperation | undefined, + protos.google.longrunning.IOperation | undefined, {} | undefined ] >; exportDocuments( - request: protosTypes.google.firestore.admin.v1.IExportDocumentsRequest, + request: protos.google.firestore.admin.v1.IExportDocumentsRequest, options: gax.CallOptions, callback: Callback< LROperation< - protosTypes.google.firestore.admin.v1.IExportDocumentsResponse, - protosTypes.google.firestore.admin.v1.IExportDocumentsMetadata + protos.google.firestore.admin.v1.IExportDocumentsResponse, + protos.google.firestore.admin.v1.IExportDocumentsMetadata >, - protosTypes.google.longrunning.IOperation | undefined, - {} | undefined + 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; /** @@ -867,32 +995,32 @@ export class FirestoreAdminClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ exportDocuments( - request: protosTypes.google.firestore.admin.v1.IExportDocumentsRequest, + request: protos.google.firestore.admin.v1.IExportDocumentsRequest, optionsOrCallback?: | gax.CallOptions | Callback< LROperation< - protosTypes.google.firestore.admin.v1.IExportDocumentsResponse, - protosTypes.google.firestore.admin.v1.IExportDocumentsMetadata + protos.google.firestore.admin.v1.IExportDocumentsResponse, + protos.google.firestore.admin.v1.IExportDocumentsMetadata >, - protosTypes.google.longrunning.IOperation | undefined, - {} | undefined + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined >, callback?: Callback< LROperation< - protosTypes.google.firestore.admin.v1.IExportDocumentsResponse, - protosTypes.google.firestore.admin.v1.IExportDocumentsMetadata + protos.google.firestore.admin.v1.IExportDocumentsResponse, + protos.google.firestore.admin.v1.IExportDocumentsMetadata >, - protosTypes.google.longrunning.IOperation | undefined, - {} | undefined + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined > ): Promise< [ LROperation< - protosTypes.google.firestore.admin.v1.IExportDocumentsResponse, - protosTypes.google.firestore.admin.v1.IExportDocumentsMetadata + protos.google.firestore.admin.v1.IExportDocumentsResponse, + protos.google.firestore.admin.v1.IExportDocumentsMetadata >, - protosTypes.google.longrunning.IOperation | undefined, + protos.google.longrunning.IOperation | undefined, {} | undefined ] > | void { @@ -913,31 +1041,78 @@ export class FirestoreAdminClient { name: request.name || '', }); 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: string + ): Promise< + LROperation< + protos.google.firestore.admin.v1.ExportDocumentsResponse, + protos.google.firestore.admin.v1.ExportDocumentsMetadata + > + > { + const request = new 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 as LROperation< + protos.google.firestore.admin.v1.ExportDocumentsResponse, + protos.google.firestore.admin.v1.ExportDocumentsMetadata + >; } importDocuments( - request: protosTypes.google.firestore.admin.v1.IImportDocumentsRequest, + request: protos.google.firestore.admin.v1.IImportDocumentsRequest, options?: gax.CallOptions ): Promise< [ LROperation< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.admin.v1.IImportDocumentsMetadata + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IImportDocumentsMetadata >, - protosTypes.google.longrunning.IOperation | undefined, + protos.google.longrunning.IOperation | undefined, {} | undefined ] >; importDocuments( - request: protosTypes.google.firestore.admin.v1.IImportDocumentsRequest, + request: protos.google.firestore.admin.v1.IImportDocumentsRequest, options: gax.CallOptions, callback: Callback< LROperation< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.admin.v1.IImportDocumentsMetadata + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IImportDocumentsMetadata >, - protosTypes.google.longrunning.IOperation | undefined, - {} | undefined + 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; /** @@ -968,32 +1143,32 @@ export class FirestoreAdminClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ importDocuments( - request: protosTypes.google.firestore.admin.v1.IImportDocumentsRequest, + request: protos.google.firestore.admin.v1.IImportDocumentsRequest, optionsOrCallback?: | gax.CallOptions | Callback< LROperation< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.admin.v1.IImportDocumentsMetadata + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IImportDocumentsMetadata >, - protosTypes.google.longrunning.IOperation | undefined, - {} | undefined + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined >, callback?: Callback< LROperation< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.admin.v1.IImportDocumentsMetadata + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IImportDocumentsMetadata >, - protosTypes.google.longrunning.IOperation | undefined, - {} | undefined + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined > ): Promise< [ LROperation< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.admin.v1.IImportDocumentsMetadata + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IImportDocumentsMetadata >, - protosTypes.google.longrunning.IOperation | undefined, + protos.google.longrunning.IOperation | undefined, {} | undefined ] > | void { @@ -1014,25 +1189,69 @@ export class FirestoreAdminClient { name: request.name || '', }); 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: string + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.firestore.admin.v1.ImportDocumentsMetadata + > + > { + const request = new 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 as LROperation< + protos.google.protobuf.Empty, + protos.google.firestore.admin.v1.ImportDocumentsMetadata + >; } listIndexes( - request: protosTypes.google.firestore.admin.v1.IListIndexesRequest, + request: protos.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 + protos.google.firestore.admin.v1.IIndex[], + protos.google.firestore.admin.v1.IListIndexesRequest | null, + protos.google.firestore.admin.v1.IListIndexesResponse ] >; listIndexes( - request: protosTypes.google.firestore.admin.v1.IListIndexesRequest, + request: protos.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 + 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; /** @@ -1070,24 +1289,26 @@ export class FirestoreAdminClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listIndexes( - request: protosTypes.google.firestore.admin.v1.IListIndexesRequest, + request: protos.google.firestore.admin.v1.IListIndexesRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - protosTypes.google.firestore.admin.v1.IIndex[], - protosTypes.google.firestore.admin.v1.IListIndexesRequest | null, - protosTypes.google.firestore.admin.v1.IListIndexesResponse + | PaginationCallback< + protos.google.firestore.admin.v1.IListIndexesRequest, + | protos.google.firestore.admin.v1.IListIndexesResponse + | null + | undefined, + protos.google.firestore.admin.v1.IIndex >, - callback?: Callback< - protosTypes.google.firestore.admin.v1.IIndex[], - protosTypes.google.firestore.admin.v1.IListIndexesRequest | null, - protosTypes.google.firestore.admin.v1.IListIndexesResponse + callback?: PaginationCallback< + protos.google.firestore.admin.v1.IListIndexesRequest, + protos.google.firestore.admin.v1.IListIndexesResponse | null | undefined, + protos.google.firestore.admin.v1.IIndex > ): Promise< [ - protosTypes.google.firestore.admin.v1.IIndex[], - protosTypes.google.firestore.admin.v1.IListIndexesRequest | null, - protosTypes.google.firestore.admin.v1.IListIndexesResponse + protos.google.firestore.admin.v1.IIndex[], + protos.google.firestore.admin.v1.IListIndexesRequest | null, + protos.google.firestore.admin.v1.IListIndexesResponse ] > | void { request = request || {}; @@ -1107,7 +1328,7 @@ export class FirestoreAdminClient { parent: request.parent || '', }); this.initialize(); - return this._innerApiCalls.listIndexes(request, options, callback); + return this.innerApiCalls.listIndexes(request, options, callback); } /** @@ -1142,7 +1363,7 @@ export class FirestoreAdminClient { * An object stream which emits an object representing [Index]{@link google.firestore.admin.v1.Index} on 'data' event. */ listIndexesStream( - request?: protosTypes.google.firestore.admin.v1.IListIndexesRequest, + request?: protos.google.firestore.admin.v1.IListIndexesRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -1156,29 +1377,83 @@ export class FirestoreAdminClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listIndexes.createStream( - this._innerApiCalls.listIndexes as gax.GaxCall, + return this.descriptors.page.listIndexes.createStream( + this.innerApiCalls.listIndexes as gax.GaxCall, 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?: protos.google.firestore.admin.v1.IListIndexesRequest, + options?: gax.CallOptions + ): AsyncIterable { + 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'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } listFields( - request: protosTypes.google.firestore.admin.v1.IListFieldsRequest, + request: protos.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 + protos.google.firestore.admin.v1.IField[], + protos.google.firestore.admin.v1.IListFieldsRequest | null, + protos.google.firestore.admin.v1.IListFieldsResponse ] >; listFields( - request: protosTypes.google.firestore.admin.v1.IListFieldsRequest, + request: protos.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 + 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; /** @@ -1225,24 +1500,26 @@ export class FirestoreAdminClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listFields( - request: protosTypes.google.firestore.admin.v1.IListFieldsRequest, + request: protos.google.firestore.admin.v1.IListFieldsRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - protosTypes.google.firestore.admin.v1.IField[], - protosTypes.google.firestore.admin.v1.IListFieldsRequest | null, - protosTypes.google.firestore.admin.v1.IListFieldsResponse + | PaginationCallback< + protos.google.firestore.admin.v1.IListFieldsRequest, + | protos.google.firestore.admin.v1.IListFieldsResponse + | null + | undefined, + protos.google.firestore.admin.v1.IField >, - callback?: Callback< - protosTypes.google.firestore.admin.v1.IField[], - protosTypes.google.firestore.admin.v1.IListFieldsRequest | null, - protosTypes.google.firestore.admin.v1.IListFieldsResponse + callback?: PaginationCallback< + protos.google.firestore.admin.v1.IListFieldsRequest, + protos.google.firestore.admin.v1.IListFieldsResponse | null | undefined, + protos.google.firestore.admin.v1.IField > ): Promise< [ - protosTypes.google.firestore.admin.v1.IField[], - protosTypes.google.firestore.admin.v1.IListFieldsRequest | null, - protosTypes.google.firestore.admin.v1.IListFieldsResponse + protos.google.firestore.admin.v1.IField[], + protos.google.firestore.admin.v1.IListFieldsRequest | null, + protos.google.firestore.admin.v1.IListFieldsResponse ] > | void { request = request || {}; @@ -1262,7 +1539,7 @@ export class FirestoreAdminClient { parent: request.parent || '', }); this.initialize(); - return this._innerApiCalls.listFields(request, options, callback); + return this.innerApiCalls.listFields(request, options, callback); } /** @@ -1301,7 +1578,7 @@ export class FirestoreAdminClient { * An object stream which emits an object representing [Field]{@link google.firestore.admin.v1.Field} on 'data' event. */ listFieldsStream( - request?: protosTypes.google.firestore.admin.v1.IListFieldsRequest, + request?: protos.google.firestore.admin.v1.IListFieldsRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -1315,12 +1592,62 @@ export class FirestoreAdminClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listFields.createStream( - this._innerApiCalls.listFields as gax.GaxCall, + return this.descriptors.page.listFields.createStream( + this.innerApiCalls.listFields as gax.GaxCall, 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?: protos.google.firestore.admin.v1.IListFieldsRequest, + options?: gax.CallOptions + ): AsyncIterable { + 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'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- @@ -1334,10 +1661,10 @@ export class FirestoreAdminClient { * @returns {string} Resource name string. */ collectionGroupPath(project: string, database: string, collection: string) { - return this._pathTemplates.collectionGroupPathTemplate.render({ - project, - database, - collection, + return this.pathTemplates.collectionGroupPathTemplate.render({ + project: project, + database: database, + collection: collection, }); } @@ -1349,7 +1676,7 @@ export class FirestoreAdminClient { * @returns {string} A string representing the project. */ matchProjectFromCollectionGroupName(collectionGroupName: string) { - return this._pathTemplates.collectionGroupPathTemplate.match( + return this.pathTemplates.collectionGroupPathTemplate.match( collectionGroupName ).project; } @@ -1362,7 +1689,7 @@ export class FirestoreAdminClient { * @returns {string} A string representing the database. */ matchDatabaseFromCollectionGroupName(collectionGroupName: string) { - return this._pathTemplates.collectionGroupPathTemplate.match( + return this.pathTemplates.collectionGroupPathTemplate.match( collectionGroupName ).database; } @@ -1375,7 +1702,7 @@ export class FirestoreAdminClient { * @returns {string} A string representing the collection. */ matchCollectionFromCollectionGroupName(collectionGroupName: string) { - return this._pathTemplates.collectionGroupPathTemplate.match( + return this.pathTemplates.collectionGroupPathTemplate.match( collectionGroupName ).collection; } @@ -1388,9 +1715,9 @@ export class FirestoreAdminClient { * @returns {string} Resource name string. */ databasePath(project: string, database: string) { - return this._pathTemplates.databasePathTemplate.render({ - project, - database, + return this.pathTemplates.databasePathTemplate.render({ + project: project, + database: database, }); } @@ -1402,7 +1729,7 @@ export class FirestoreAdminClient { * @returns {string} A string representing the project. */ matchProjectFromDatabaseName(databaseName: string) { - return this._pathTemplates.databasePathTemplate.match(databaseName).project; + return this.pathTemplates.databasePathTemplate.match(databaseName).project; } /** @@ -1413,8 +1740,7 @@ export class FirestoreAdminClient { * @returns {string} A string representing the database. */ matchDatabaseFromDatabaseName(databaseName: string) { - return this._pathTemplates.databasePathTemplate.match(databaseName) - .database; + return this.pathTemplates.databasePathTemplate.match(databaseName).database; } /** @@ -1432,11 +1758,11 @@ export class FirestoreAdminClient { collection: string, field: string ) { - return this._pathTemplates.fieldPathTemplate.render({ - project, - database, - collection, - field, + return this.pathTemplates.fieldPathTemplate.render({ + project: project, + database: database, + collection: collection, + field: field, }); } @@ -1448,7 +1774,7 @@ export class FirestoreAdminClient { * @returns {string} A string representing the project. */ matchProjectFromFieldName(fieldName: string) { - return this._pathTemplates.fieldPathTemplate.match(fieldName).project; + return this.pathTemplates.fieldPathTemplate.match(fieldName).project; } /** @@ -1459,7 +1785,7 @@ export class FirestoreAdminClient { * @returns {string} A string representing the database. */ matchDatabaseFromFieldName(fieldName: string) { - return this._pathTemplates.fieldPathTemplate.match(fieldName).database; + return this.pathTemplates.fieldPathTemplate.match(fieldName).database; } /** @@ -1470,7 +1796,7 @@ export class FirestoreAdminClient { * @returns {string} A string representing the collection. */ matchCollectionFromFieldName(fieldName: string) { - return this._pathTemplates.fieldPathTemplate.match(fieldName).collection; + return this.pathTemplates.fieldPathTemplate.match(fieldName).collection; } /** @@ -1481,7 +1807,7 @@ export class FirestoreAdminClient { * @returns {string} A string representing the field. */ matchFieldFromFieldName(fieldName: string) { - return this._pathTemplates.fieldPathTemplate.match(fieldName).field; + return this.pathTemplates.fieldPathTemplate.match(fieldName).field; } /** @@ -1499,11 +1825,11 @@ export class FirestoreAdminClient { collection: string, index: string ) { - return this._pathTemplates.indexPathTemplate.render({ - project, - database, - collection, - index, + return this.pathTemplates.indexPathTemplate.render({ + project: project, + database: database, + collection: collection, + index: index, }); } @@ -1515,7 +1841,7 @@ export class FirestoreAdminClient { * @returns {string} A string representing the project. */ matchProjectFromIndexName(indexName: string) { - return this._pathTemplates.indexPathTemplate.match(indexName).project; + return this.pathTemplates.indexPathTemplate.match(indexName).project; } /** @@ -1526,7 +1852,7 @@ export class FirestoreAdminClient { * @returns {string} A string representing the database. */ matchDatabaseFromIndexName(indexName: string) { - return this._pathTemplates.indexPathTemplate.match(indexName).database; + return this.pathTemplates.indexPathTemplate.match(indexName).database; } /** @@ -1537,7 +1863,7 @@ export class FirestoreAdminClient { * @returns {string} A string representing the collection. */ matchCollectionFromIndexName(indexName: string) { - return this._pathTemplates.indexPathTemplate.match(indexName).collection; + return this.pathTemplates.indexPathTemplate.match(indexName).collection; } /** @@ -1548,7 +1874,7 @@ export class FirestoreAdminClient { * @returns {string} A string representing the index. */ matchIndexFromIndexName(indexName: string) { - return this._pathTemplates.indexPathTemplate.match(indexName).index; + return this.pathTemplates.indexPathTemplate.match(indexName).index; } /** diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 4ae1ef3fc..69832d08a 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -18,18 +18,18 @@ import * as gax from 'google-gax'; import { - APICallback, Callback, CallOptions, - ClientOptions, Descriptors, + ClientOptions, PaginationCallback, - PaginationResponse, + GaxCall, } from 'google-gax'; import * as path from 'path'; import {Transform} from 'stream'; -import * as protosTypes from '../../protos/firestore_v1_proto_api'; +import {RequestType} from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/firestore_v1_proto_api'; import * as gapicConfig from './firestore_client_config.json'; const version = require('../../../package.json').version; @@ -47,13 +47,6 @@ const version = require('../../../package.json').version; * @memberof v1 */ export class FirestoreClient { - private _descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - private _innerApiCalls: {[name: string]: Function}; private _terminated = false; private _opts: ClientOptions; private _gaxModule: typeof gax | typeof gax.fallback; @@ -61,6 +54,13 @@ export class FirestoreClient { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; firestoreStub?: Promise<{[name: string]: Function}>; /** @@ -152,18 +152,26 @@ export class FirestoreClient { 'protos.json' ); this._protos = this._gaxGrpc.loadProto( - opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath + 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', @@ -173,7 +181,7 @@ export class FirestoreClient { // Some of the methods on this service provide streaming responses. // Provide descriptors for these. - this._descriptors.stream = { + this.descriptors.stream = { batchGetDocuments: new this._gaxModule.StreamDescriptor( gax.StreamType.SERVER_STREAMING ), @@ -199,7 +207,7 @@ export class FirestoreClient { // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. - this._innerApiCalls = {}; + this.innerApiCalls = {}; } /** @@ -226,7 +234,7 @@ export class FirestoreClient { ? (this._protos as protobuf.Root).lookupService( 'google.firestore.v1.Firestore' ) - : // tslint:disable-next-line no-any + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.firestore.v1.Firestore, this._opts ) as Promise<{[method: string]: Function}>; @@ -243,14 +251,15 @@ export class FirestoreClient { 'commit', 'rollback', 'runQuery', + 'partitionQuery', 'write', 'listen', 'listCollectionIds', + 'batchWrite', 'createDocument', ]; - for (const methodName of firestoreStubMethods) { - const innerCallPromise = this.firestoreStub.then( + const callPromise = this.firestoreStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject( @@ -266,20 +275,14 @@ export class FirestoreClient { ); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], - this._descriptors.page[methodName] || - this._descriptors.stream[methodName] || - this._descriptors.longrunning[methodName] + this.descriptors.page[methodName] || + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); - this._innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.firestoreStub; @@ -339,22 +342,30 @@ export class FirestoreClient { // -- Service calls -- // ------------------- getDocument( - request: protosTypes.google.firestore.v1.IGetDocumentRequest, + request: protos.google.firestore.v1.IGetDocumentRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.IGetDocumentRequest | undefined, + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IGetDocumentRequest | undefined, {} | undefined ] >; getDocument( - request: protosTypes.google.firestore.v1.IGetDocumentRequest, + request: protos.google.firestore.v1.IGetDocumentRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.IGetDocumentRequest | undefined, - {} | undefined + 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; /** @@ -374,7 +385,7 @@ export class FirestoreClient { * Reads the document in a transaction. * @param {google.protobuf.Timestamp} request.readTime * 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] * 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. @@ -382,23 +393,23 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ getDocument( - request: protosTypes.google.firestore.v1.IGetDocumentRequest, + request: protos.google.firestore.v1.IGetDocumentRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.IGetDocumentRequest | undefined, - {} | undefined + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IGetDocumentRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.IGetDocumentRequest | undefined, - {} | undefined + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IGetDocumentRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.IGetDocumentRequest | undefined, + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IGetDocumentRequest | undefined, {} | undefined ] > | void { @@ -419,25 +430,33 @@ export class FirestoreClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.getDocument(request, options, callback); + return this.innerApiCalls.getDocument(request, options, callback); } updateDocument( - request: protosTypes.google.firestore.v1.IUpdateDocumentRequest, + request: protos.google.firestore.v1.IUpdateDocumentRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.IUpdateDocumentRequest | undefined, + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IUpdateDocumentRequest | undefined, {} | undefined ] >; updateDocument( - request: protosTypes.google.firestore.v1.IUpdateDocumentRequest, + request: protos.google.firestore.v1.IUpdateDocumentRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.IUpdateDocumentRequest | undefined, - {} | undefined + 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; /** @@ -471,23 +490,23 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ updateDocument( - request: protosTypes.google.firestore.v1.IUpdateDocumentRequest, + request: protos.google.firestore.v1.IUpdateDocumentRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.IUpdateDocumentRequest | undefined, - {} | undefined + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IUpdateDocumentRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.IUpdateDocumentRequest | undefined, - {} | undefined + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IUpdateDocumentRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.IUpdateDocumentRequest | undefined, + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IUpdateDocumentRequest | undefined, {} | undefined ] > | void { @@ -508,25 +527,33 @@ export class FirestoreClient { 'document.name': request.document!.name || '', }); this.initialize(); - return this._innerApiCalls.updateDocument(request, options, callback); + return this.innerApiCalls.updateDocument(request, options, callback); } deleteDocument( - request: protosTypes.google.firestore.v1.IDeleteDocumentRequest, + request: protos.google.firestore.v1.IDeleteDocumentRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1.IDeleteDocumentRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IDeleteDocumentRequest | undefined, {} | undefined ] >; deleteDocument( - request: protosTypes.google.firestore.v1.IDeleteDocumentRequest, + request: protos.google.firestore.v1.IDeleteDocumentRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1.IDeleteDocumentRequest | undefined, - {} | undefined + 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; /** @@ -547,23 +574,23 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ deleteDocument( - request: protosTypes.google.firestore.v1.IDeleteDocumentRequest, + request: protos.google.firestore.v1.IDeleteDocumentRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1.IDeleteDocumentRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IDeleteDocumentRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1.IDeleteDocumentRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IDeleteDocumentRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1.IDeleteDocumentRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IDeleteDocumentRequest | undefined, {} | undefined ] > | void { @@ -584,25 +611,33 @@ export class FirestoreClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.deleteDocument(request, options, callback); + return this.innerApiCalls.deleteDocument(request, options, callback); } beginTransaction( - request: protosTypes.google.firestore.v1.IBeginTransactionRequest, + request: protos.google.firestore.v1.IBeginTransactionRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.firestore.v1.IBeginTransactionResponse, - protosTypes.google.firestore.v1.IBeginTransactionRequest | undefined, + protos.google.firestore.v1.IBeginTransactionResponse, + protos.google.firestore.v1.IBeginTransactionRequest | undefined, {} | undefined ] >; beginTransaction( - request: protosTypes.google.firestore.v1.IBeginTransactionRequest, + request: protos.google.firestore.v1.IBeginTransactionRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.firestore.v1.IBeginTransactionResponse, - protosTypes.google.firestore.v1.IBeginTransactionRequest | undefined, - {} | undefined + 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; /** @@ -623,23 +658,25 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ beginTransaction( - request: protosTypes.google.firestore.v1.IBeginTransactionRequest, + request: protos.google.firestore.v1.IBeginTransactionRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.firestore.v1.IBeginTransactionResponse, - protosTypes.google.firestore.v1.IBeginTransactionRequest | undefined, - {} | undefined + protos.google.firestore.v1.IBeginTransactionResponse, + | protos.google.firestore.v1.IBeginTransactionRequest + | null + | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.firestore.v1.IBeginTransactionResponse, - protosTypes.google.firestore.v1.IBeginTransactionRequest | undefined, - {} | undefined + protos.google.firestore.v1.IBeginTransactionResponse, + protos.google.firestore.v1.IBeginTransactionRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.firestore.v1.IBeginTransactionResponse, - protosTypes.google.firestore.v1.IBeginTransactionRequest | undefined, + protos.google.firestore.v1.IBeginTransactionResponse, + protos.google.firestore.v1.IBeginTransactionRequest | undefined, {} | undefined ] > | void { @@ -660,25 +697,33 @@ export class FirestoreClient { database: request.database || '', }); this.initialize(); - return this._innerApiCalls.beginTransaction(request, options, callback); + return this.innerApiCalls.beginTransaction(request, options, callback); } commit( - request: protosTypes.google.firestore.v1.ICommitRequest, + request: protos.google.firestore.v1.ICommitRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.firestore.v1.ICommitResponse, - protosTypes.google.firestore.v1.ICommitRequest | undefined, + protos.google.firestore.v1.ICommitResponse, + protos.google.firestore.v1.ICommitRequest | undefined, {} | undefined ] >; commit( - request: protosTypes.google.firestore.v1.ICommitRequest, + request: protos.google.firestore.v1.ICommitRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.firestore.v1.ICommitResponse, - protosTypes.google.firestore.v1.ICommitRequest | undefined, - {} | undefined + 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; /** @@ -702,23 +747,23 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ commit( - request: protosTypes.google.firestore.v1.ICommitRequest, + request: protos.google.firestore.v1.ICommitRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.firestore.v1.ICommitResponse, - protosTypes.google.firestore.v1.ICommitRequest | undefined, - {} | undefined + protos.google.firestore.v1.ICommitResponse, + protos.google.firestore.v1.ICommitRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.firestore.v1.ICommitResponse, - protosTypes.google.firestore.v1.ICommitRequest | undefined, - {} | undefined + protos.google.firestore.v1.ICommitResponse, + protos.google.firestore.v1.ICommitRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.firestore.v1.ICommitResponse, - protosTypes.google.firestore.v1.ICommitRequest | undefined, + protos.google.firestore.v1.ICommitResponse, + protos.google.firestore.v1.ICommitRequest | undefined, {} | undefined ] > | void { @@ -739,25 +784,33 @@ export class FirestoreClient { database: request.database || '', }); this.initialize(); - return this._innerApiCalls.commit(request, options, callback); + return this.innerApiCalls.commit(request, options, callback); } rollback( - request: protosTypes.google.firestore.v1.IRollbackRequest, + request: protos.google.firestore.v1.IRollbackRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1.IRollbackRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IRollbackRequest | undefined, {} | undefined ] >; rollback( - request: protosTypes.google.firestore.v1.IRollbackRequest, + request: protos.google.firestore.v1.IRollbackRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1.IRollbackRequest | undefined, - {} | undefined + 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; /** @@ -777,23 +830,120 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ rollback( - request: protosTypes.google.firestore.v1.IRollbackRequest, + request: protos.google.firestore.v1.IRollbackRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1.IRollbackRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IRollbackRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1.IRollbackRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IRollbackRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IRollbackRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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.rollback(request, options, callback); + } + 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; + /** + * 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: protos.google.firestore.v1.IBatchWriteRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protos.google.firestore.v1.IBatchWriteResponse, + protos.google.firestore.v1.IBatchWriteRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.firestore.v1.IBatchWriteResponse, + protos.google.firestore.v1.IBatchWriteRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1.IRollbackRequest | undefined, + protos.google.firestore.v1.IBatchWriteResponse, + protos.google.firestore.v1.IBatchWriteRequest | undefined, {} | undefined ] > | void { @@ -814,25 +964,33 @@ export class FirestoreClient { database: request.database || '', }); this.initialize(); - return this._innerApiCalls.rollback(request, options, callback); + return this.innerApiCalls.batchWrite(request, options, callback); } createDocument( - request: protosTypes.google.firestore.v1.ICreateDocumentRequest, + request: protos.google.firestore.v1.ICreateDocumentRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.ICreateDocumentRequest | undefined, + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.ICreateDocumentRequest | undefined, {} | undefined ] >; createDocument( - request: protosTypes.google.firestore.v1.ICreateDocumentRequest, + request: protos.google.firestore.v1.ICreateDocumentRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.ICreateDocumentRequest | undefined, - {} | undefined + 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; /** @@ -864,23 +1022,23 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ createDocument( - request: protosTypes.google.firestore.v1.ICreateDocumentRequest, + request: protos.google.firestore.v1.ICreateDocumentRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.ICreateDocumentRequest | undefined, - {} | undefined + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.ICreateDocumentRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.ICreateDocumentRequest | undefined, - {} | undefined + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.ICreateDocumentRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.firestore.v1.IDocument, - protosTypes.google.firestore.v1.ICreateDocumentRequest | undefined, + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.ICreateDocumentRequest | undefined, {} | undefined ] > | void { @@ -901,7 +1059,7 @@ export class FirestoreClient { parent: request.parent || '', }); this.initialize(); - return this._innerApiCalls.createDocument(request, options, callback); + return this.innerApiCalls.createDocument(request, options, callback); } /** @@ -934,14 +1092,14 @@ export class FirestoreClient { * stream. * @param {google.protobuf.Timestamp} request.readTime * 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] * 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 [BatchGetDocumentsResponse]{@link google.firestore.v1.BatchGetDocumentsResponse} on 'data' event. */ batchGetDocuments( - request?: protosTypes.google.firestore.v1.IBatchGetDocumentsRequest, + request?: protos.google.firestore.v1.IBatchGetDocumentsRequest, options?: gax.CallOptions ): gax.CancellableStream { request = request || {}; @@ -954,7 +1112,7 @@ export class FirestoreClient { database: request.database || '', }); this.initialize(); - return this._innerApiCalls.batchGetDocuments(request, options); + return this.innerApiCalls.batchGetDocuments(request, options); } /** @@ -980,14 +1138,14 @@ export class FirestoreClient { * stream. * @param {google.protobuf.Timestamp} request.readTime * 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] * 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 [RunQueryResponse]{@link google.firestore.v1.RunQueryResponse} on 'data' event. */ runQuery( - request?: protosTypes.google.firestore.v1.IRunQueryRequest, + request?: protos.google.firestore.v1.IRunQueryRequest, options?: gax.CallOptions ): gax.CancellableStream { request = request || {}; @@ -1000,7 +1158,7 @@ export class FirestoreClient { parent: request.parent || '', }); this.initialize(); - return this._innerApiCalls.runQuery(request, options); + return this.innerApiCalls.runQuery(request, options); } /** @@ -1015,7 +1173,7 @@ export class FirestoreClient { */ write(options?: gax.CallOptions): gax.CancellableStream { this.initialize(); - return this._innerApiCalls.write(options); + return this.innerApiCalls.write({}, options); } /** @@ -1030,26 +1188,34 @@ export class FirestoreClient { */ listen(options?: gax.CallOptions): gax.CancellableStream { this.initialize(); - return this._innerApiCalls.listen({}, options); + return this.innerApiCalls.listen({}, options); } listDocuments( - request: protosTypes.google.firestore.v1.IListDocumentsRequest, + request: protos.google.firestore.v1.IListDocumentsRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.firestore.v1.IDocument[], - protosTypes.google.firestore.v1.IListDocumentsRequest | null, - protosTypes.google.firestore.v1.IListDocumentsResponse + protos.google.firestore.v1.IDocument[], + protos.google.firestore.v1.IListDocumentsRequest | null, + protos.google.firestore.v1.IListDocumentsResponse ] >; listDocuments( - request: protosTypes.google.firestore.v1.IListDocumentsRequest, + request: protos.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 + 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; /** @@ -1082,7 +1248,7 @@ export class FirestoreClient { * 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. + * 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 @@ -1110,24 +1276,24 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listDocuments( - request: protosTypes.google.firestore.v1.IListDocumentsRequest, + request: protos.google.firestore.v1.IListDocumentsRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - protosTypes.google.firestore.v1.IDocument[], - protosTypes.google.firestore.v1.IListDocumentsRequest | null, - protosTypes.google.firestore.v1.IListDocumentsResponse + | PaginationCallback< + protos.google.firestore.v1.IListDocumentsRequest, + protos.google.firestore.v1.IListDocumentsResponse | null | undefined, + protos.google.firestore.v1.IDocument >, - callback?: Callback< - protosTypes.google.firestore.v1.IDocument[], - protosTypes.google.firestore.v1.IListDocumentsRequest | null, - protosTypes.google.firestore.v1.IListDocumentsResponse + callback?: PaginationCallback< + protos.google.firestore.v1.IListDocumentsRequest, + protos.google.firestore.v1.IListDocumentsResponse | null | undefined, + protos.google.firestore.v1.IDocument > ): Promise< [ - protosTypes.google.firestore.v1.IDocument[], - protosTypes.google.firestore.v1.IListDocumentsRequest | null, - protosTypes.google.firestore.v1.IListDocumentsResponse + protos.google.firestore.v1.IDocument[], + protos.google.firestore.v1.IListDocumentsRequest | null, + protos.google.firestore.v1.IListDocumentsResponse ] > | void { request = request || {}; @@ -1147,7 +1313,7 @@ export class FirestoreClient { parent: request.parent || '', }); this.initialize(); - return this._innerApiCalls.listDocuments(request, options, callback); + return this.innerApiCalls.listDocuments(request, options, callback); } /** @@ -1190,7 +1356,7 @@ export class FirestoreClient { * 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. + * 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 @@ -1205,7 +1371,290 @@ export class FirestoreClient { * An object stream which emits an object representing [Document]{@link google.firestore.v1.Document} on 'data' event. */ listDocumentsStream( - request?: protosTypes.google.firestore.v1.IListDocumentsRequest, + request?: protos.google.firestore.v1.IListDocumentsRequest, + options?: gax.CallOptions + ): Transform { + 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.listDocuments.createStream( + this.innerApiCalls.listDocuments as gax.GaxCall, + 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?: protos.google.firestore.v1.IListDocumentsRequest, + options?: gax.CallOptions + ): AsyncIterable { + 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'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } + 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; + /** + * 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: protos.google.firestore.v1.IPartitionQueryRequest, + optionsOrCallback?: + | gax.CallOptions + | PaginationCallback< + protos.google.firestore.v1.IPartitionQueryRequest, + protos.google.firestore.v1.IPartitionQueryResponse | null | undefined, + protos.google.firestore.v1.ICursor + >, + callback?: PaginationCallback< + protos.google.firestore.v1.IPartitionQueryRequest, + protos.google.firestore.v1.IPartitionQueryResponse | null | undefined, + protos.google.firestore.v1.ICursor + > + ): Promise< + [ + protos.google.firestore.v1.ICursor[], + protos.google.firestore.v1.IPartitionQueryRequest | null, + protos.google.firestore.v1.IPartitionQueryResponse + ] + > | void { + request = request || {}; + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + 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?: protos.google.firestore.v1.IPartitionQueryRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -1219,29 +1668,112 @@ export class FirestoreClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listDocuments.createStream( - this._innerApiCalls.listDocuments as gax.GaxCall, + return this.descriptors.page.partitionQuery.createStream( + this.innerApiCalls.partitionQuery as gax.GaxCall, 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?: protos.google.firestore.v1.IPartitionQueryRequest, + options?: gax.CallOptions + ): AsyncIterable { + 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'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } listCollectionIds( - request: protosTypes.google.firestore.v1.IListCollectionIdsRequest, + request: protos.google.firestore.v1.IListCollectionIdsRequest, options?: gax.CallOptions ): Promise< [ string[], - protosTypes.google.firestore.v1.IListCollectionIdsRequest | null, - protosTypes.google.firestore.v1.IListCollectionIdsResponse + protos.google.firestore.v1.IListCollectionIdsRequest | null, + protos.google.firestore.v1.IListCollectionIdsResponse ] >; listCollectionIds( - request: protosTypes.google.firestore.v1.IListCollectionIdsRequest, + request: protos.google.firestore.v1.IListCollectionIdsRequest, options: gax.CallOptions, - callback: Callback< - string[], - protosTypes.google.firestore.v1.IListCollectionIdsRequest | null, - protosTypes.google.firestore.v1.IListCollectionIdsResponse + 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; /** @@ -1278,24 +1810,26 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listCollectionIds( - request: protosTypes.google.firestore.v1.IListCollectionIdsRequest, + request: protos.google.firestore.v1.IListCollectionIdsRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - string[], - protosTypes.google.firestore.v1.IListCollectionIdsRequest | null, - protosTypes.google.firestore.v1.IListCollectionIdsResponse + | PaginationCallback< + protos.google.firestore.v1.IListCollectionIdsRequest, + | protos.google.firestore.v1.IListCollectionIdsResponse + | null + | undefined, + string >, - callback?: Callback< - string[], - protosTypes.google.firestore.v1.IListCollectionIdsRequest | null, - protosTypes.google.firestore.v1.IListCollectionIdsResponse + callback?: PaginationCallback< + protos.google.firestore.v1.IListCollectionIdsRequest, + protos.google.firestore.v1.IListCollectionIdsResponse | null | undefined, + string > ): Promise< [ string[], - protosTypes.google.firestore.v1.IListCollectionIdsRequest | null, - protosTypes.google.firestore.v1.IListCollectionIdsResponse + protos.google.firestore.v1.IListCollectionIdsRequest | null, + protos.google.firestore.v1.IListCollectionIdsResponse ] > | void { request = request || {}; @@ -1315,7 +1849,7 @@ export class FirestoreClient { parent: request.parent || '', }); this.initialize(); - return this._innerApiCalls.listCollectionIds(request, options, callback); + return this.innerApiCalls.listCollectionIds(request, options, callback); } /** @@ -1349,7 +1883,7 @@ export class FirestoreClient { * An object stream which emits an object representing string on 'data' event. */ listCollectionIdsStream( - request?: protosTypes.google.firestore.v1.IListCollectionIdsRequest, + request?: protos.google.firestore.v1.IListCollectionIdsRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -1363,13 +1897,58 @@ export class FirestoreClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listCollectionIds.createStream( - this._innerApiCalls.listCollectionIds as gax.GaxCall, + return this.descriptors.page.listCollectionIds.createStream( + this.innerApiCalls.listCollectionIds as gax.GaxCall, 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?: protos.google.firestore.v1.IListCollectionIdsRequest, + options?: gax.CallOptions + ): AsyncIterable { + 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'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } + /** * Terminate the GRPC channel and close the client. * diff --git a/dev/src/v1/firestore_client_config.json b/dev/src/v1/firestore_client_config.json index b832f2b4b..f4cd67a1f 100644 --- a/dev/src/v1/firestore_client_config.json +++ b/dev/src/v1/firestore_client_config.json @@ -70,6 +70,10 @@ "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, + "PartitionQuery": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "Write": { "timeout_millis": 86400000, "retry_codes_name": "non_idempotent", @@ -85,6 +89,10 @@ "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, + "BatchWrite": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "CreateDocument": { "timeout_millis": 60000, "retry_codes_name": "non_idempotent", diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index e4ed2a25e..3ebaac25b 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -18,20 +18,22 @@ import * as gax from 'google-gax'; import { - APICallback, Callback, CallOptions, - ClientOptions, Descriptors, + ClientOptions, PaginationCallback, - PaginationResponse, + GaxCall, } from 'google-gax'; import * as path from 'path'; import {Transform} from 'stream'; -import * as protosTypes from '../../protos/firestore_v1beta1_proto_api'; +import {RequestType} from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/firestore_v1beta1_proto_api'; import * as gapicConfig from './firestore_client_config.json'; +// tslint:disable deprecation + const version = require('../../../package.json').version; /** @@ -52,16 +54,10 @@ const version = require('../../../package.json').version; * committed. Any read with an equal or greater `read_time` is guaranteed * to see the effects of the transaction. * @class + * @deprecated Use v1/firestore_client instead. * @memberof v1beta1 */ export class FirestoreClient { - private _descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - private _innerApiCalls: {[name: string]: Function}; private _terminated = false; private _opts: ClientOptions; private _gaxModule: typeof gax | typeof gax.fallback; @@ -69,6 +65,13 @@ export class FirestoreClient { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; firestoreStub?: Promise<{[name: string]: Function}>; /** @@ -160,13 +163,16 @@ export class FirestoreClient { 'protos.json' ); this._protos = this._gaxGrpc.loadProto( - opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath + 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', @@ -181,7 +187,7 @@ export class FirestoreClient { // Some of the methods on this service provide streaming responses. // Provide descriptors for these. - this._descriptors.stream = { + this.descriptors.stream = { batchGetDocuments: new this._gaxModule.StreamDescriptor( gax.StreamType.SERVER_STREAMING ), @@ -207,7 +213,7 @@ export class FirestoreClient { // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. - this._innerApiCalls = {}; + this.innerApiCalls = {}; } /** @@ -234,7 +240,7 @@ export class FirestoreClient { ? (this._protos as protobuf.Root).lookupService( 'google.firestore.v1beta1.Firestore' ) - : // tslint:disable-next-line no-any + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.firestore.v1beta1.Firestore, this._opts ) as Promise<{[method: string]: Function}>; @@ -256,9 +262,8 @@ export class FirestoreClient { 'listen', 'listCollectionIds', ]; - for (const methodName of firestoreStubMethods) { - const innerCallPromise = this.firestoreStub.then( + const callPromise = this.firestoreStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject( @@ -274,20 +279,14 @@ export class FirestoreClient { ); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], - this._descriptors.page[methodName] || - this._descriptors.stream[methodName] || - this._descriptors.longrunning[methodName] + this.descriptors.page[methodName] || + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); - this._innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.firestoreStub; @@ -347,22 +346,30 @@ export class FirestoreClient { // -- Service calls -- // ------------------- getDocument( - request: protosTypes.google.firestore.v1beta1.IGetDocumentRequest, + request: protos.google.firestore.v1beta1.IGetDocumentRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.firestore.v1beta1.IDocument, - protosTypes.google.firestore.v1beta1.IGetDocumentRequest | undefined, + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IGetDocumentRequest | undefined, {} | undefined ] >; getDocument( - request: protosTypes.google.firestore.v1beta1.IGetDocumentRequest, + request: protos.google.firestore.v1beta1.IGetDocumentRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.firestore.v1beta1.IDocument, - protosTypes.google.firestore.v1beta1.IGetDocumentRequest | undefined, - {} | undefined + 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; /** @@ -390,23 +397,25 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ getDocument( - request: protosTypes.google.firestore.v1beta1.IGetDocumentRequest, + request: protos.google.firestore.v1beta1.IGetDocumentRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.firestore.v1beta1.IDocument, - protosTypes.google.firestore.v1beta1.IGetDocumentRequest | undefined, - {} | undefined + protos.google.firestore.v1beta1.IDocument, + | protos.google.firestore.v1beta1.IGetDocumentRequest + | null + | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.firestore.v1beta1.IDocument, - protosTypes.google.firestore.v1beta1.IGetDocumentRequest | undefined, - {} | undefined + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IGetDocumentRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.firestore.v1beta1.IDocument, - protosTypes.google.firestore.v1beta1.IGetDocumentRequest | undefined, + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IGetDocumentRequest | undefined, {} | undefined ] > | void { @@ -427,25 +436,33 @@ export class FirestoreClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.getDocument(request, options, callback); + return this.innerApiCalls.getDocument(request, options, callback); } createDocument( - request: protosTypes.google.firestore.v1beta1.ICreateDocumentRequest, + request: protos.google.firestore.v1beta1.ICreateDocumentRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.firestore.v1beta1.IDocument, - protosTypes.google.firestore.v1beta1.ICreateDocumentRequest | undefined, + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.ICreateDocumentRequest | undefined, {} | undefined ] >; createDocument( - request: protosTypes.google.firestore.v1beta1.ICreateDocumentRequest, + request: protos.google.firestore.v1beta1.ICreateDocumentRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.firestore.v1beta1.IDocument, - protosTypes.google.firestore.v1beta1.ICreateDocumentRequest | undefined, - {} | undefined + 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; /** @@ -477,24 +494,25 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ createDocument( - request: protosTypes.google.firestore.v1beta1.ICreateDocumentRequest, + request: protos.google.firestore.v1beta1.ICreateDocumentRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.firestore.v1beta1.IDocument, - | protosTypes.google.firestore.v1beta1.ICreateDocumentRequest + protos.google.firestore.v1beta1.IDocument, + | protos.google.firestore.v1beta1.ICreateDocumentRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.firestore.v1beta1.IDocument, - protosTypes.google.firestore.v1beta1.ICreateDocumentRequest | undefined, - {} | undefined + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.ICreateDocumentRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.firestore.v1beta1.IDocument, - protosTypes.google.firestore.v1beta1.ICreateDocumentRequest | undefined, + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.ICreateDocumentRequest | undefined, {} | undefined ] > | void { @@ -515,25 +533,33 @@ export class FirestoreClient { parent: request.parent || '', }); this.initialize(); - return this._innerApiCalls.createDocument(request, options, callback); + return this.innerApiCalls.createDocument(request, options, callback); } updateDocument( - request: protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest, + request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.firestore.v1beta1.IDocument, - protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest | undefined, + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IUpdateDocumentRequest | undefined, {} | undefined ] >; updateDocument( - request: protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest, + request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.firestore.v1beta1.IDocument, - protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest | undefined, - {} | undefined + 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; /** @@ -567,24 +593,25 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ updateDocument( - request: protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest, + request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.firestore.v1beta1.IDocument, - | protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest + protos.google.firestore.v1beta1.IDocument, + | protos.google.firestore.v1beta1.IUpdateDocumentRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.firestore.v1beta1.IDocument, - protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest | undefined, - {} | undefined + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IUpdateDocumentRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.firestore.v1beta1.IDocument, - protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest | undefined, + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IUpdateDocumentRequest | undefined, {} | undefined ] > | void { @@ -605,25 +632,33 @@ export class FirestoreClient { 'document.name': request.document!.name || '', }); this.initialize(); - return this._innerApiCalls.updateDocument(request, options, callback); + return this.innerApiCalls.updateDocument(request, options, callback); } deleteDocument( - request: protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest, + request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IDeleteDocumentRequest | undefined, {} | undefined ] >; deleteDocument( - request: protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest, + request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest | undefined, - {} | undefined + 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; /** @@ -644,24 +679,25 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ deleteDocument( - request: protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest, + request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.protobuf.IEmpty, - | protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest + protos.google.protobuf.IEmpty, + | protos.google.firestore.v1beta1.IDeleteDocumentRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IDeleteDocumentRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IDeleteDocumentRequest | undefined, {} | undefined ] > | void { @@ -682,25 +718,37 @@ export class FirestoreClient { name: request.name || '', }); this.initialize(); - return this._innerApiCalls.deleteDocument(request, options, callback); + return this.innerApiCalls.deleteDocument(request, options, callback); } beginTransaction( - request: protosTypes.google.firestore.v1beta1.IBeginTransactionRequest, + request: protos.google.firestore.v1beta1.IBeginTransactionRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.firestore.v1beta1.IBeginTransactionResponse, - protosTypes.google.firestore.v1beta1.IBeginTransactionRequest | undefined, + protos.google.firestore.v1beta1.IBeginTransactionResponse, + protos.google.firestore.v1beta1.IBeginTransactionRequest | undefined, {} | undefined ] >; beginTransaction( - request: protosTypes.google.firestore.v1beta1.IBeginTransactionRequest, + request: protos.google.firestore.v1beta1.IBeginTransactionRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.firestore.v1beta1.IBeginTransactionResponse, - protosTypes.google.firestore.v1beta1.IBeginTransactionRequest | undefined, - {} | undefined + 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; /** @@ -721,24 +769,27 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ beginTransaction( - request: protosTypes.google.firestore.v1beta1.IBeginTransactionRequest, + request: protos.google.firestore.v1beta1.IBeginTransactionRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.firestore.v1beta1.IBeginTransactionResponse, - | protosTypes.google.firestore.v1beta1.IBeginTransactionRequest + protos.google.firestore.v1beta1.IBeginTransactionResponse, + | protos.google.firestore.v1beta1.IBeginTransactionRequest + | null | undefined, - {} | undefined + {} | null | undefined >, callback?: Callback< - protosTypes.google.firestore.v1beta1.IBeginTransactionResponse, - protosTypes.google.firestore.v1beta1.IBeginTransactionRequest | undefined, - {} | undefined + protos.google.firestore.v1beta1.IBeginTransactionResponse, + | protos.google.firestore.v1beta1.IBeginTransactionRequest + | null + | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.firestore.v1beta1.IBeginTransactionResponse, - protosTypes.google.firestore.v1beta1.IBeginTransactionRequest | undefined, + protos.google.firestore.v1beta1.IBeginTransactionResponse, + protos.google.firestore.v1beta1.IBeginTransactionRequest | undefined, {} | undefined ] > | void { @@ -759,25 +810,33 @@ export class FirestoreClient { database: request.database || '', }); this.initialize(); - return this._innerApiCalls.beginTransaction(request, options, callback); + return this.innerApiCalls.beginTransaction(request, options, callback); } commit( - request: protosTypes.google.firestore.v1beta1.ICommitRequest, + request: protos.google.firestore.v1beta1.ICommitRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.firestore.v1beta1.ICommitResponse, - protosTypes.google.firestore.v1beta1.ICommitRequest | undefined, + protos.google.firestore.v1beta1.ICommitResponse, + protos.google.firestore.v1beta1.ICommitRequest | undefined, {} | undefined ] >; commit( - request: protosTypes.google.firestore.v1beta1.ICommitRequest, + request: protos.google.firestore.v1beta1.ICommitRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.firestore.v1beta1.ICommitResponse, - protosTypes.google.firestore.v1beta1.ICommitRequest | undefined, - {} | undefined + 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; /** @@ -801,23 +860,23 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ commit( - request: protosTypes.google.firestore.v1beta1.ICommitRequest, + request: protos.google.firestore.v1beta1.ICommitRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.firestore.v1beta1.ICommitResponse, - protosTypes.google.firestore.v1beta1.ICommitRequest | undefined, - {} | undefined + protos.google.firestore.v1beta1.ICommitResponse, + protos.google.firestore.v1beta1.ICommitRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.firestore.v1beta1.ICommitResponse, - protosTypes.google.firestore.v1beta1.ICommitRequest | undefined, - {} | undefined + protos.google.firestore.v1beta1.ICommitResponse, + protos.google.firestore.v1beta1.ICommitRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.firestore.v1beta1.ICommitResponse, - protosTypes.google.firestore.v1beta1.ICommitRequest | undefined, + protos.google.firestore.v1beta1.ICommitResponse, + protos.google.firestore.v1beta1.ICommitRequest | undefined, {} | undefined ] > | void { @@ -838,25 +897,33 @@ export class FirestoreClient { database: request.database || '', }); this.initialize(); - return this._innerApiCalls.commit(request, options, callback); + return this.innerApiCalls.commit(request, options, callback); } rollback( - request: protosTypes.google.firestore.v1beta1.IRollbackRequest, + request: protos.google.firestore.v1beta1.IRollbackRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1beta1.IRollbackRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IRollbackRequest | undefined, {} | undefined ] >; rollback( - request: protosTypes.google.firestore.v1beta1.IRollbackRequest, + request: protos.google.firestore.v1beta1.IRollbackRequest, options: gax.CallOptions, callback: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1beta1.IRollbackRequest | undefined, - {} | undefined + 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; /** @@ -876,23 +943,23 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ rollback( - request: protosTypes.google.firestore.v1beta1.IRollbackRequest, + request: protos.google.firestore.v1beta1.IRollbackRequest, optionsOrCallback?: | gax.CallOptions | Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1beta1.IRollbackRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IRollbackRequest | null | undefined, + {} | null | undefined >, callback?: Callback< - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1beta1.IRollbackRequest | undefined, - {} | undefined + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IRollbackRequest | null | undefined, + {} | null | undefined > ): Promise< [ - protosTypes.google.protobuf.IEmpty, - protosTypes.google.firestore.v1beta1.IRollbackRequest | undefined, + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IRollbackRequest | undefined, {} | undefined ] > | void { @@ -913,7 +980,7 @@ export class FirestoreClient { database: request.database || '', }); this.initialize(); - return this._innerApiCalls.rollback(request, options, callback); + return this.innerApiCalls.rollback(request, options, callback); } /** @@ -953,7 +1020,7 @@ export class FirestoreClient { * An object stream which emits [BatchGetDocumentsResponse]{@link google.firestore.v1beta1.BatchGetDocumentsResponse} on 'data' event. */ batchGetDocuments( - request?: protosTypes.google.firestore.v1beta1.IBatchGetDocumentsRequest, + request?: protos.google.firestore.v1beta1.IBatchGetDocumentsRequest, options?: gax.CallOptions ): gax.CancellableStream { request = request || {}; @@ -966,7 +1033,7 @@ export class FirestoreClient { database: request.database || '', }); this.initialize(); - return this._innerApiCalls.batchGetDocuments(request, options); + return this.innerApiCalls.batchGetDocuments(request, options); } /** @@ -999,7 +1066,7 @@ export class FirestoreClient { * An object stream which emits [RunQueryResponse]{@link google.firestore.v1beta1.RunQueryResponse} on 'data' event. */ runQuery( - request?: protosTypes.google.firestore.v1beta1.IRunQueryRequest, + request?: protos.google.firestore.v1beta1.IRunQueryRequest, options?: gax.CallOptions ): gax.CancellableStream { request = request || {}; @@ -1012,7 +1079,7 @@ export class FirestoreClient { parent: request.parent || '', }); this.initialize(); - return this._innerApiCalls.runQuery(request, options); + return this.innerApiCalls.runQuery(request, options); } /** @@ -1027,7 +1094,7 @@ export class FirestoreClient { */ write(options?: gax.CallOptions): gax.CancellableStream { this.initialize(); - return this._innerApiCalls.write(options); + return this.innerApiCalls.write({}, options); } /** @@ -1042,26 +1109,34 @@ export class FirestoreClient { */ listen(options?: gax.CallOptions): gax.CancellableStream { this.initialize(); - return this._innerApiCalls.listen({}, options); + return this.innerApiCalls.listen({}, options); } listDocuments( - request: protosTypes.google.firestore.v1beta1.IListDocumentsRequest, + request: protos.google.firestore.v1beta1.IListDocumentsRequest, options?: gax.CallOptions ): Promise< [ - protosTypes.google.firestore.v1beta1.IDocument[], - protosTypes.google.firestore.v1beta1.IListDocumentsRequest | null, - protosTypes.google.firestore.v1beta1.IListDocumentsResponse + protos.google.firestore.v1beta1.IDocument[], + protos.google.firestore.v1beta1.IListDocumentsRequest | null, + protos.google.firestore.v1beta1.IListDocumentsResponse ] >; listDocuments( - request: protosTypes.google.firestore.v1beta1.IListDocumentsRequest, + request: protos.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 + 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; /** @@ -1122,24 +1197,26 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listDocuments( - request: protosTypes.google.firestore.v1beta1.IListDocumentsRequest, + request: protos.google.firestore.v1beta1.IListDocumentsRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - protosTypes.google.firestore.v1beta1.IDocument[], - protosTypes.google.firestore.v1beta1.IListDocumentsRequest | null, - protosTypes.google.firestore.v1beta1.IListDocumentsResponse + | PaginationCallback< + protos.google.firestore.v1beta1.IListDocumentsRequest, + | protos.google.firestore.v1beta1.IListDocumentsResponse + | null + | undefined, + protos.google.firestore.v1beta1.IDocument >, - callback?: Callback< - protosTypes.google.firestore.v1beta1.IDocument[], - protosTypes.google.firestore.v1beta1.IListDocumentsRequest | null, - protosTypes.google.firestore.v1beta1.IListDocumentsResponse + callback?: PaginationCallback< + protos.google.firestore.v1beta1.IListDocumentsRequest, + protos.google.firestore.v1beta1.IListDocumentsResponse | null | undefined, + protos.google.firestore.v1beta1.IDocument > ): Promise< [ - protosTypes.google.firestore.v1beta1.IDocument[], - protosTypes.google.firestore.v1beta1.IListDocumentsRequest | null, - protosTypes.google.firestore.v1beta1.IListDocumentsResponse + protos.google.firestore.v1beta1.IDocument[], + protos.google.firestore.v1beta1.IListDocumentsRequest | null, + protos.google.firestore.v1beta1.IListDocumentsResponse ] > | void { request = request || {}; @@ -1159,7 +1236,7 @@ export class FirestoreClient { parent: request.parent || '', }); this.initialize(); - return this._innerApiCalls.listDocuments(request, options, callback); + return this.innerApiCalls.listDocuments(request, options, callback); } /** @@ -1217,7 +1294,7 @@ export class FirestoreClient { * An object stream which emits an object representing [Document]{@link google.firestore.v1beta1.Document} on 'data' event. */ listDocumentsStream( - request?: protosTypes.google.firestore.v1beta1.IListDocumentsRequest, + request?: protos.google.firestore.v1beta1.IListDocumentsRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -1231,29 +1308,110 @@ export class FirestoreClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listDocuments.createStream( - this._innerApiCalls.listDocuments as gax.GaxCall, + return this.descriptors.page.listDocuments.createStream( + this.innerApiCalls.listDocuments as gax.GaxCall, 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?: protos.google.firestore.v1beta1.IListDocumentsRequest, + options?: gax.CallOptions + ): AsyncIterable { + 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'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } listCollectionIds( - request: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest, + request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, options?: gax.CallOptions ): Promise< [ string[], - protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest | null, - protosTypes.google.firestore.v1beta1.IListCollectionIdsResponse + protos.google.firestore.v1beta1.IListCollectionIdsRequest | null, + protos.google.firestore.v1beta1.IListCollectionIdsResponse ] >; listCollectionIds( - request: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest, + request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, options: gax.CallOptions, - callback: Callback< - string[], - protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest | null, - protosTypes.google.firestore.v1beta1.IListCollectionIdsResponse + 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; /** @@ -1290,24 +1448,28 @@ export class FirestoreClient { * The promise has a method named "cancel" which cancels the ongoing API call. */ listCollectionIds( - request: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest, + request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, optionsOrCallback?: | gax.CallOptions - | Callback< - string[], - protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest | null, - protosTypes.google.firestore.v1beta1.IListCollectionIdsResponse + | PaginationCallback< + protos.google.firestore.v1beta1.IListCollectionIdsRequest, + | protos.google.firestore.v1beta1.IListCollectionIdsResponse + | null + | undefined, + string >, - callback?: Callback< - string[], - protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest | null, - protosTypes.google.firestore.v1beta1.IListCollectionIdsResponse + callback?: PaginationCallback< + protos.google.firestore.v1beta1.IListCollectionIdsRequest, + | protos.google.firestore.v1beta1.IListCollectionIdsResponse + | null + | undefined, + string > ): Promise< [ string[], - protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest | null, - protosTypes.google.firestore.v1beta1.IListCollectionIdsResponse + protos.google.firestore.v1beta1.IListCollectionIdsRequest | null, + protos.google.firestore.v1beta1.IListCollectionIdsResponse ] > | void { request = request || {}; @@ -1327,7 +1489,7 @@ export class FirestoreClient { parent: request.parent || '', }); this.initialize(); - return this._innerApiCalls.listCollectionIds(request, options, callback); + return this.innerApiCalls.listCollectionIds(request, options, callback); } /** @@ -1361,7 +1523,7 @@ export class FirestoreClient { * An object stream which emits an object representing string on 'data' event. */ listCollectionIdsStream( - request?: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest, + request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, options?: gax.CallOptions ): Transform { request = request || {}; @@ -1375,13 +1537,58 @@ export class FirestoreClient { }); const callSettings = new gax.CallSettings(options); this.initialize(); - return this._descriptors.page.listCollectionIds.createStream( - this._innerApiCalls.listCollectionIds as gax.GaxCall, + return this.descriptors.page.listCollectionIds.createStream( + this.innerApiCalls.listCollectionIds as gax.GaxCall, 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?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, + options?: gax.CallOptions + ): AsyncIterable { + 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'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } + /** * Terminate the GRPC channel and close the client. * diff --git a/dev/src/v1beta1/index.ts b/dev/src/v1beta1/index.ts index 9a03699e8..b19eff7ed 100644 --- a/dev/src/v1beta1/index.ts +++ b/dev/src/v1beta1/index.ts @@ -16,6 +16,8 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** +// tslint:disable deprecation + import {FirestoreClient} from './firestore_client'; export {FirestoreClient}; diff --git a/dev/src/validate.ts b/dev/src/validate.ts index b820cca0f..3db6390f1 100644 --- a/dev/src/validate.ts +++ b/dev/src/validate.ts @@ -288,7 +288,7 @@ export function validateInteger( export function invalidArgumentMessage( arg: string | number, expectedType: string -) { +): string { return `${formatArgumentName(arg)} is not a valid ${expectedType}.`; } diff --git a/dev/src/watch.ts b/dev/src/watch.ts index 2a870b577..ab97aab14 100644 --- a/dev/src/watch.ts +++ b/dev/src/watch.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import * as firestore from '@google-cloud/firestore'; + import * as assert from 'assert'; import * as rbtree from 'functional-red-black-tree'; import {GoogleError, Status} from 'google-gax'; @@ -27,13 +29,9 @@ import {DocumentReference, Firestore, Query} from './index'; import {logger} from './logger'; import {QualifiedResourcePath} from './path'; import {Timestamp} from './timestamp'; -import { - defaultConverter, - DocumentData, - FirestoreDataConverter, - RBTree, -} from './types'; +import {defaultConverter, RBTree} from './types'; import {requestTag} from './util'; + import api = google.firestore.v1; /*! @@ -55,8 +53,7 @@ export const WATCH_IDLE_TIMEOUT_MS = 120 * 1000; /*! * Sentinel value for a document remove. */ -// tslint:disable-next-line:no-any -const REMOVED = {} as DocumentSnapshotBuilder; +const REMOVED = {} as DocumentSnapshotBuilder; /*! * The change type for document change events. @@ -72,15 +69,15 @@ const ChangeType: {[k: string]: DocumentChangeType} = { * The comparator used for document watches (which should always get called with * the same document). */ -const DOCUMENT_WATCH_COMPARATOR = ( +const DOCUMENT_WATCH_COMPARATOR: ( doc1: QueryDocumentSnapshot, doc2: QueryDocumentSnapshot -) => { +) => number = (doc1, doc2) => { assert(doc1 === doc2, 'Document watches only support one document.'); return 0; }; -const EMPTY_FUNCTION = () => {}; +const EMPTY_FUNCTION: () => void = () => {}; /** * @private @@ -114,7 +111,7 @@ type DocumentComparator = ( r: QueryDocumentSnapshot ) => number; -interface DocumentChangeSet { +interface DocumentChangeSet { deletes: string[]; adds: Array>; updates: Array>; @@ -127,7 +124,7 @@ interface DocumentChangeSet { * @class * @private */ -abstract class Watch { +abstract class Watch { protected readonly firestore: Firestore; private readonly backoff: ExponentialBackoff; private readonly requestTag: string; @@ -208,7 +205,7 @@ abstract class Watch { */ constructor( firestore: Firestore, - readonly _converter = defaultConverter as FirestoreDataConverter + readonly _converter = defaultConverter() ) { this.firestore = firestore; this.backoff = new ExponentialBackoff(); @@ -265,7 +262,7 @@ abstract class Watch { this.initStream(); - const unsubscribe = () => { + const unsubscribe: () => void = () => { logger('Watch.onSnapshot', this.requestTag, 'Unsubscribe called'); // Prevent further callbacks. this.onNext = () => {}; @@ -324,7 +321,10 @@ abstract class Watch { this.docTree.forEach((snapshot: QueryDocumentSnapshot) => { // Mark each document as deleted. If documents are not deleted, they // will be send again by the server. - this.changeMap.set(snapshot.ref.path, REMOVED); + this.changeMap.set( + snapshot.ref.path, + REMOVED as DocumentSnapshotBuilder + ); }); this.current = false; @@ -559,14 +559,14 @@ abstract class Watch { this.changeMap.set(relativeName, snapshot); } else if (removed) { logger('Watch.onData', this.requestTag, 'Received document remove'); - this.changeMap.set(relativeName, REMOVED); + this.changeMap.set(relativeName, REMOVED as DocumentSnapshotBuilder); } } else if (proto.documentDelete || proto.documentRemove) { logger('Watch.onData', this.requestTag, 'Processing remove event'); const name = (proto.documentDelete || proto.documentRemove)!.document!; const relativeName = QualifiedResourcePath.fromSlashSeparatedString(name) .relativeName; - this.changeMap.set(relativeName, REMOVED); + this.changeMap.set(relativeName, REMOVED as DocumentSnapshotBuilder); } else if (proto.filter) { logger('Watch.onData', this.requestTag, 'Processing filter update'); if (proto.filter.count !== this.currentSize()) { @@ -807,7 +807,7 @@ abstract class Watch { * * @private */ -export class DocumentWatch extends Watch { +export class DocumentWatch extends Watch { constructor( firestore: Firestore, private readonly ref: DocumentReference @@ -836,13 +836,13 @@ export class DocumentWatch extends Watch { * * @private */ -export class QueryWatch extends Watch { +export class QueryWatch extends Watch { private comparator: DocumentComparator; constructor( firestore: Firestore, private readonly query: Query, - converter?: FirestoreDataConverter + converter?: firestore.FirestoreDataConverter ) { super(firestore, converter); this.comparator = query.comparator(); diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 1e40e73d5..af9f95465 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import * as firestore from '@google-cloud/firestore'; + import {google} from '../protos/firestore_v1_proto_api'; import { DocumentMask, @@ -24,16 +26,10 @@ import { import {Firestore} from './index'; import {logger} from './logger'; import {FieldPath, validateFieldPath} from './path'; -import {DocumentReference, validateDocumentReference} from './reference'; +import {validateDocumentReference} from './reference'; import {Serializer, validateUserInput} from './serializer'; import {Timestamp} from './timestamp'; -import { - Precondition as PublicPrecondition, - SetOptions, - UpdateData, - UpdateMap, -} from './types'; -import {DocumentData} from './types'; +import {UpdateMap} from './types'; import { getRetryCodes, isObject, @@ -53,20 +49,13 @@ import { import api = google.firestore.v1; import {GoogleError, Status} from '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; - /** * A WriteResult wraps the write time set by the Firestore servers on sets(), * updates(), and creates(). * * @class */ -export class WriteResult { +export class WriteResult implements firestore.WriteResult { /** * @hideconstructor * @@ -98,7 +87,7 @@ export class WriteResult { * @param {*} other The value to compare against. * @return true if this `WriteResult` is equal to the provided value. */ - isEqual(other: WriteResult): boolean { + isEqual(other: firestore.WriteResult): boolean { return ( this === other || (other instanceof WriteResult && @@ -120,12 +109,12 @@ export class BatchWriteResult { ) {} } -/** Helper type to manage the list of writes in a WriteBatch. */ -// TODO(mrschmidt): Replace with api.IWrite -interface WriteOp { - write: api.IWrite; - precondition?: api.IPrecondition | null; -} +/** + * A lazily-evaluated write that allows us to detect the Project ID before + * serializing the request. + * @private + */ +type PendingWriteOp = () => api.IWrite; /** * A Firestore WriteBatch that can be used to atomically commit multiple write @@ -133,7 +122,7 @@ interface WriteOp { * * @class */ -export class WriteBatch { +export class WriteBatch implements firestore.WriteBatch { private readonly _firestore: Firestore; private readonly _serializer: Serializer; private readonly _allowUndefined: boolean; @@ -143,7 +132,7 @@ export class WriteBatch { * resulting `api.IWrite` will be sent to the backend. * @private */ - private readonly _ops: Array<() => WriteOp> = []; + private readonly _ops: Array = []; private _committed = false; @@ -198,9 +187,9 @@ export class WriteBatch { * console.log('Successfully executed batch.'); * }); */ - create(documentRef: DocumentReference, data: T): WriteBatch { - validateDocumentReference('documentRef', documentRef); - const firestoreData = documentRef._converter.toFirestore(data); + create(documentRef: firestore.DocumentReference, data: T): WriteBatch { + const ref = validateDocumentReference('documentRef', documentRef); + const firestoreData = ref._converter.toFirestore(data); validateDocumentData( 'data', firestoreData, @@ -210,22 +199,19 @@ export class WriteBatch { this.verifyNotCommitted(); - const transform = DocumentTransform.fromObject(documentRef, firestoreData); + const transform = DocumentTransform.fromObject(ref, firestoreData); transform.validate(); const precondition = new Precondition({exists: false}); - const op = () => { - const document = DocumentSnapshot.fromObject(documentRef, firestoreData); - const write = document.toProto(); + const op: PendingWriteOp = () => { + const document = 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; }; this._ops.push(op); @@ -257,23 +243,22 @@ export class WriteBatch { * }); */ delete( - documentRef: DocumentReference, - precondition?: PublicPrecondition + documentRef: firestore.DocumentReference, + precondition?: firestore.Precondition ): WriteBatch { - validateDocumentReference('documentRef', documentRef); + const ref = validateDocumentReference('documentRef', documentRef); validateDeletePrecondition('precondition', precondition, {optional: true}); this.verifyNotCommitted(); const conditions = new Precondition(precondition); - const op = () => { - return { - write: { - delete: documentRef.formattedName, - }, - precondition: conditions.toProto(), - }; + const op: PendingWriteOp = () => { + const write: api.IWrite = {delete: ref.formattedName}; + if (!conditions.isEmpty) { + write.currentDocument = conditions.toProto(); + } + return write; }; this._ops.push(op); @@ -281,16 +266,26 @@ export class WriteBatch { return this; } + set( + documentRef: firestore.DocumentReference, + data: Partial, + options: firestore.SetOptions + ): WriteBatch; + set(documentRef: firestore.DocumentReference, data: T): WriteBatch; + set( + documentRef: firestore.DocumentReference, + data: T | Partial, + 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. + * [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} 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 @@ -312,15 +307,23 @@ export class WriteBatch { * }); */ set( - documentRef: DocumentReference, - data: T, - options?: SetOptions + documentRef: firestore.DocumentReference, + data: T | Partial, + options?: firestore.SetOptions ): WriteBatch { validateSetOptions('options', options, {optional: true}); const mergeLeaves = options && options.merge === true; const mergePaths = options && options.mergeFields; - validateDocumentReference('documentRef', documentRef); - let firestoreData = documentRef._converter.toFirestore(data); + const ref = validateDocumentReference('documentRef', documentRef); + let firestoreData: firestore.DocumentData; + 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 as any).toFirestore(data, options); + } else { + firestoreData = ref._converter.toFirestore(data as T); + } validateDocumentData( 'data', firestoreData, @@ -340,7 +343,7 @@ export class WriteBatch { const transform = DocumentTransform.fromObject(documentRef, firestoreData); transform.validate(); - const op = () => { + const op: PendingWriteOp = () => { const document = DocumentSnapshot.fromObject(documentRef, firestoreData); if (mergePaths) { @@ -349,18 +352,14 @@ export class WriteBatch { documentMask = DocumentMask.fromObject(firestoreData); } - const write = document.toProto(); + const write = document.toWriteProto(); if (!transform.isEmpty) { write.updateTransforms = transform.toProto(this._serializer); } - if (mergePaths || mergeLeaves) { write.updateMask = documentMask!.toProto(); } - - return { - write, - }; + return write; }; this._ops.push(op); @@ -404,13 +403,17 @@ export class WriteBatch { * console.log('Successfully executed batch.'); * }); */ - update( - documentRef: DocumentReference, - dataOrField: UpdateData | string | FieldPath, + update( + documentRef: firestore.DocumentReference, + dataOrField: firestore.UpdateData | string | firestore.FieldPath, ...preconditionOrValues: Array< - {lastUpdateTime?: Timestamp} | unknown | string | FieldPath + | {lastUpdateTime?: firestore.Timestamp} + | unknown + | string + | firestore.FieldPath > ): WriteBatch { + // eslint-disable-next-line prefer-rest-params validateMinNumberOfArguments('WriteBatch.update', arguments, 2); validateDocumentReference('documentRef', documentRef); @@ -428,27 +431,31 @@ export class WriteBatch { typeof dataOrField === 'string' || dataOrField instanceof FieldPath; 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 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 Precondition(maybePrecondition); } else { - validateFieldPath(i, arguments[i]); + const maybeFieldPath = fieldOrValues[i]; + validateFieldPath(i + argumentOffset, maybeFieldPath); // Unlike the `validateMinNumberOfArguments` invocation above, this // validation can be triggered both from `WriteBatch.update()` and // `DocumentReference.update()`. Hence, we don't use the fully // qualified API name in the error message. - validateMinNumberOfArguments('update', arguments, i + 1); + validateMinNumberOfArguments('update', fieldOrValues, i + 1); - const fieldPath = FieldPath.fromArgument(arguments[i]); + const fieldPath = FieldPath.fromArgument(maybeFieldPath); validateFieldValue( - i, - arguments[i + 1], + i + argumentOffset, + fieldOrValues[i + 1], this._allowUndefined, fieldPath ); - updateMap.set(fieldPath, arguments[i + 1]); + updateMap.set(fieldPath, fieldOrValues[i + 1]); } } } catch (err) { @@ -460,9 +467,10 @@ export class WriteBatch { } else { try { validateUpdateMap('dataOrField', dataOrField, this._allowUndefined); + // eslint-disable-next-line prefer-rest-params validateMaxNumberOfArguments('update', arguments, 3); - const data = dataOrField as UpdateData; + const data = dataOrField as firestore.UpdateData; Object.keys(data).forEach(key => { validateFieldPath(key, key); updateMap.set(FieldPath.fromArgument(key), data[key]); @@ -499,17 +507,15 @@ export class WriteBatch { const documentMask = DocumentMask.fromUpdateMap(updateMap); - const op = () => { + const op: PendingWriteOp = () => { const document = DocumentSnapshot.fromUpdateMap(documentRef, updateMap); - const write = document.toProto(); - write!.updateMask = documentMask.toProto(); + const write = document.toWriteProto(); + write.updateMask = documentMask.toProto(); if (!transform.isEmpty) { - write!.updateTransforms = transform.toProto(this._serializer); + write.updateTransforms = transform.toProto(this._serializer); } - return { - write, - precondition: precondition.toProto(), - }; + write.currentDocument = precondition.toProto(); + return write; }; this._ops.push(op); @@ -538,7 +544,7 @@ export class WriteBatch { // Capture the error stack to preserve stack tracing across async calls. const stack = Error().stack!; - return this.commit_().catch(err => { + return this._commit().catch(err => { throw wrapError(err, stack); }); } @@ -558,15 +564,10 @@ export class WriteBatch { await this._firestore.initializeIfNeeded(tag); const database = this._firestore.formattedName; - const request: api.IBatchWriteRequest = {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: api.IBatchWriteRequest = { + database, + writes: this._ops.map(op => op()), + }; const retryCodes = [Status.ABORTED, ...getRetryCodes('commit')]; @@ -579,10 +580,16 @@ export class WriteBatch { const status = response.status[i]; const error = new GoogleError(status.message || undefined); error.code = status.code as Status; - return new BatchWriteResult( - result.updateTime ? 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.fromMillis(0); + const updateTime = + error.code === Status.OK + ? Timestamp.fromProto(result.updateTime || DELETE_TIMESTAMP_SENTINEL) + : null; + return new BatchWriteResult(updateTime, error); }); } @@ -596,7 +603,7 @@ export class WriteBatch { * this request. * @returns A Promise that resolves when this batch completes. */ - async commit_(commitOptions?: { + async _commit(commitOptions?: { transactionId?: Uint8Array; requestTag?: string; }): Promise { @@ -607,32 +614,14 @@ export class WriteBatch { await this._firestore.initializeIfNeeded(tag); 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('WriteBatch.commit', tag, 'Using transaction for commit'); - return this._firestore - .request( - 'beginTransaction', - {database}, - tag - ) - .then(resp => { - return this.commit_({transactionId: resp.transaction!}); - }); - } - - const request: api.ICommitRequest = {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: api.ICommitRequest = { + database, + writes: this._ops.map(op => op()), + }; + if (commitOptions?.transactionId) { + request.transaction = commitOptions.transactionId; } logger( @@ -665,31 +654,11 @@ export class WriteBatch { ); } - /** - * 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(): boolean { - 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. * @private */ - _reset() { + _reset(): void { this._ops.splice(0); this._committed = false; } @@ -772,7 +741,7 @@ function validateUpdatePrecondition( arg: string | number, value: unknown, options?: RequiredArgumentOptions -): void { +): asserts value is {lastUpdateTime?: Timestamp} { if (!validateOptional(value, options)) { validatePrecondition(arg, value, /* allowExists= */ false); } diff --git a/dev/system-test/.eslintrc.yml b/dev/system-test/.eslintrc.yml deleted file mode 100644 index cd21505a4..000000000 --- a/dev/system-test/.eslintrc.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- - diff --git a/dev/system-test/.gitignore b/dev/system-test/.gitignore deleted file mode 100644 index 8cd1e2ebd..000000000 --- a/dev/system-test/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -CAcert.pem -keyfile.json diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 9882fc37d..b94c4dd1e 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -12,12 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {QuerySnapshot, DocumentData} from '@google-cloud/firestore'; + +import {describe, it, beforeEach, afterEach} from 'mocha'; import {expect, use} from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; +import * as extend from 'extend'; +import {firestore} from '../protos/firestore_v1_proto_api'; import { CollectionReference, - DocumentData, DocumentReference, DocumentSnapshot, FieldPath, @@ -26,13 +30,21 @@ import { GeoPoint, Query, QueryDocumentSnapshot, - QuerySnapshot, setLogFunction, Timestamp, WriteResult, } from '../src'; import {autoId, Deferred} from '../src/util'; -import {Post, postConverter, verifyInstance} from '../test/util/helpers'; +import {TEST_BUNDLE_ID, verifyMetadata} from '../test/bundle'; +import { + bundleToElementArray, + Post, + postConverter, + postConverterMerge, + verifyInstance, +} from '../test/util/helpers'; +import IBundleElement = firestore.IBundleElement; +import {BulkWriter} from '../src/bulk-writer'; use(chaiAsPromised); @@ -67,7 +79,7 @@ describe('Firestore class', () => { let randomCol: CollectionReference; beforeEach(() => { - firestore = new Firestore({}); + firestore = new Firestore(); randomCol = getTestRoot(firestore); }); @@ -162,15 +174,23 @@ describe('Firestore class', () => { // No-op }); - try { - await firestore.terminate(); - throw new Error('terminate() should have failed'); - } catch (err) { - expect(err).to.equal( - 'All onSnapshot() listeners must be unsubscribed before terminating the client.' - ); - unsubscribe(); - } + await expect(firestore.terminate()).to.eventually.be.rejectedWith( + 'All onSnapshot() listeners must be unsubscribed, and all BulkWriter ' + + 'instances must be closed before terminating the client. There are 1 ' + + 'active listeners and 0 open BulkWriter instances.' + ); + unsubscribe(); + }); + + it('throws an error if terminate() is called with pending BulkWriter operations', async () => { + const writer = firestore._bulkWriter(); + const ref = randomCol.doc('doc-1'); + writer.set(ref, {foo: 'bar'}); + await expect(firestore.terminate()).to.eventually.be.rejectedWith( + 'All onSnapshot() listeners must be unsubscribed, and all BulkWriter ' + + 'instances must be closed before terminating the client. There are 0 ' + + 'active listeners and 1 open BulkWriter instances.' + ); }); }); @@ -258,7 +278,7 @@ describe('DocumentReference class', () => { let randomCol: CollectionReference; beforeEach(() => { - firestore = new Firestore({}); + firestore = new Firestore(); randomCol = getTestRoot(firestore); }); @@ -357,6 +377,24 @@ describe('DocumentReference class', () => { }); }); + it('round-trips BigInts', () => { + const bigIntValue = BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1); + + const firestore = new Firestore({useBigInt: true}); + const randomCol = getTestRoot(firestore); + const ref = randomCol.doc('doc'); + return ref + .set({bigIntValue}) + .then(() => ref.get()) + .then(doc => ref.set(doc.data()!)) + .then(() => ref.get()) + .then(doc => { + const actualValue = doc.data()!.bigIntValue; + expect(actualValue).to.be.a('bigint'); + expect(actualValue).to.equal(bigIntValue); + }); + }); + it('supports server timestamps', () => { const baseObject = { a: 'bar', @@ -615,7 +653,7 @@ describe('DocumentReference class', () => { }); // tslint:disable-next-line:only-arrow-function - it('can add and delete fields sequentially', function() { + it('can add and delete fields sequentially', function () { this.timeout(30 * 1000); const ref = randomCol.doc('doc'); @@ -689,7 +727,7 @@ describe('DocumentReference class', () => { }); // tslint:disable-next-line:only-arrow-function - it('can add and delete fields with server timestamps', function() { + it('can add and delete fields with server timestamps', function () { this.timeout(10 * 1000); const ref = randomCol.doc('doc'); @@ -909,9 +947,6 @@ describe('DocumentReference class', () => { const doc1 = randomCol.doc(); const doc2 = randomCol.doc(); - let unsubscribe1: () => void; - let unsubscribe2: () => void; - // Documents transition from non-existent to existent to non-existent. const exists1 = [false, true, false]; const exists2 = [false, true, false]; @@ -940,12 +975,12 @@ describe('DocumentReference class', () => { run.shift()!(); } }; - unsubscribe1 = doc1.onSnapshot(snapshot => { + const unsubscribe1 = doc1.onSnapshot(snapshot => { expect(snapshot.exists).to.equal(exists1.shift()); maybeRun(); }); - unsubscribe2 = doc2.onSnapshot(snapshot => { + const unsubscribe2 = doc2.onSnapshot(snapshot => { expect(snapshot.exists).to.equal(exists2.shift()); maybeRun(); }); @@ -954,9 +989,6 @@ describe('DocumentReference class', () => { it('handles multiple streams on same doc', done => { const doc = randomCol.doc(); - let unsubscribe1: () => void; - let unsubscribe2: () => void; - // Document transitions from non-existent to existent to non-existent. const exists1 = [false, true, false]; const exists2 = [false, true, false]; @@ -984,12 +1016,12 @@ describe('DocumentReference class', () => { } }; - unsubscribe1 = doc.onSnapshot(snapshot => { + const unsubscribe1 = doc.onSnapshot(snapshot => { expect(snapshot.exists).to.equal(exists1.shift()); maybeRun(); }); - unsubscribe2 = doc.onSnapshot(snapshot => { + const unsubscribe2 = doc.onSnapshot(snapshot => { expect(snapshot.exists).to.equal(exists2.shift()); maybeRun(); }); @@ -1169,10 +1201,7 @@ describe('Query class', () => { return ref .set({foo: NaN, bar: null}) .then(() => { - return randomCol - .where('foo', '==', NaN) - .where('bar', '==', null) - .get(); + return randomCol.where('foo', '==', NaN).where('bar', '==', null).get(); }) .then(res => { expect( @@ -1282,19 +1311,13 @@ describe('Query class', () => { it('has limit() method', async () => { await addDocs({foo: 'a'}, {foo: 'b'}); - const res = await randomCol - .orderBy('foo') - .limit(1) - .get(); + const res = await randomCol.orderBy('foo').limit(1).get(); expectDocs(res, {foo: 'a'}); }); it('has limitToLast() method', async () => { await addDocs({doc: 1}, {doc: 2}, {doc: 3}); - const res = await randomCol - .orderBy('doc') - .limitToLast(2) - .get(); + const res = await randomCol.orderBy('doc').limitToLast(2).get(); expectDocs(res, {doc: 2}, {doc: 3}); }); @@ -1311,10 +1334,7 @@ describe('Query class', () => { it('has offset() method', async () => { await addDocs({foo: 'a'}, {foo: 'b'}); - const res = await randomCol - .orderBy('foo') - .offset(1) - .get(); + const res = await randomCol.orderBy('foo').offset(1).get(); expectDocs(res, {foo: 'b'}); }); @@ -1381,37 +1401,25 @@ describe('Query class', () => { it('has startAt() method', async () => { await addDocs({foo: 'a'}, {foo: 'b'}); - const res = await randomCol - .orderBy('foo') - .startAt('b') - .get(); + const res = await randomCol.orderBy('foo').startAt('b').get(); expectDocs(res, {foo: 'b'}); }); it('has startAfter() method', async () => { await addDocs({foo: 'a'}, {foo: 'b'}); - const res = await randomCol - .orderBy('foo') - .startAfter('a') - .get(); + const res = await randomCol.orderBy('foo').startAfter('a').get(); expectDocs(res, {foo: 'b'}); }); it('has endAt() method', async () => { await addDocs({foo: 'a'}, {foo: 'b'}); - const res = await randomCol - .orderBy('foo') - .endAt('b') - .get(); + const res = await randomCol.orderBy('foo').endAt('b').get(); expectDocs(res, {foo: 'a'}, {foo: 'b'}); }); it('has endBefore() method', async () => { await addDocs({foo: 'a'}, {foo: 'b'}); - const res = await randomCol - .orderBy('foo') - .endBefore('b') - .get(); + const res = await randomCol.orderBy('foo').endBefore('b').get(); expectDocs(res, {foo: 'a'}); }); @@ -1440,7 +1448,8 @@ describe('Query class', () => { await randomCol.doc().set({foo: 'bar'}); const stream = randomCol.stream(); - for await (const chunk of stream) { + for await (const doc of stream) { + expect(doc).to.be.an.instanceOf(QueryDocumentSnapshot); ++received; } @@ -1495,7 +1504,7 @@ describe('Query class', () => { `a/b/c/d/${collectionGroup}/cg-doc4`, `a/c/${collectionGroup}/cg-doc5`, `${collectionGroup}/cg-doc6`, - `a/b/nope/nope`, + 'a/b/nope/nope', ]; const batch = firestore.batch(); for (const docPath of docPaths) { @@ -1506,7 +1515,7 @@ describe('Query class', () => { let querySnapshot = await firestore .collectionGroup(collectionGroup) .orderBy(FieldPath.documentId()) - .startAt(`a/b`) + .startAt('a/b') .endAt('a/b0') .get(); expect(querySnapshot.docs.map(d => d.id)).to.deep.equal([ @@ -1536,7 +1545,7 @@ describe('Query class', () => { `a/b/c/d/${collectionGroup}/cg-doc4`, `a/c/${collectionGroup}/cg-doc5`, `${collectionGroup}/cg-doc6`, - `a/b/nope/nope`, + 'a/b/nope/nope', ]; const batch = firestore.batch(); for (const docPath of docPaths) { @@ -1546,7 +1555,7 @@ describe('Query class', () => { let querySnapshot = await firestore .collectionGroup(collectionGroup) - .where(FieldPath.documentId(), '>=', `a/b`) + .where(FieldPath.documentId(), '>=', 'a/b') .where(FieldPath.documentId(), '<=', 'a/b0') .get(); expect(querySnapshot.docs.map(d => d.id)).to.deep.equal([ @@ -1557,7 +1566,7 @@ describe('Query class', () => { querySnapshot = await firestore .collectionGroup(collectionGroup) - .where(FieldPath.documentId(), '>', `a/b`) + .where(FieldPath.documentId(), '>', 'a/b') .where(FieldPath.documentId(), '<', `a/b/${collectionGroup}/cg-doc3`) .get(); expect(querySnapshot.docs.map(d => d.id)).to.deep.equal(['cg-doc2']); @@ -2070,7 +2079,6 @@ describe('Transaction class', () => { it('retries transactions that fail with contention', async () => { const ref = randomCol.doc('doc'); - let firstTransaction, secondTransaction: Promise; let attempts = 0; // Create two transactions that both read and update the same document. @@ -2079,7 +2087,7 @@ describe('Transaction class', () => { // and be retried. const contentionPromise = [new Deferred(), new Deferred()]; - firstTransaction = firestore.runTransaction(async transaction => { + const firstTransaction = firestore.runTransaction(async transaction => { ++attempts; await transaction.get(ref); contentionPromise[0].resolve(); @@ -2087,7 +2095,7 @@ describe('Transaction class', () => { transaction.set(ref, {first: true}, {merge: true}); }); - secondTransaction = firestore.runTransaction(async transaction => { + const secondTransaction = firestore.runTransaction(async transaction => { ++attempts; await transaction.get(ref); contentionPromise[1].resolve(); @@ -2148,6 +2156,36 @@ describe('WriteBatch class', () => { }); }); + it('set supports partials', async () => { + const ref = randomCol.doc('doc').withConverter(postConverterMerge); + await ref.set(new Post('walnut', 'author')); + const batch = firestore.batch(); + batch.set(ref, {title: 'olive'}, {merge: true}); + return batch + .commit() + .then(() => { + return ref.get(); + }) + .then(doc => { + expect(doc.get('title')).to.equal('olive'); + expect(doc.get('author')).to.equal('author'); + }); + }); + + it('set()', () => { + const ref = randomCol.doc('doc'); + const batch = firestore.batch(); + batch.set(ref, {foo: 'a'}); + return batch + .commit() + .then(() => { + return ref.get(); + }) + .then(doc => { + expect(doc.get('foo')).to.equal('a'); + }); + }); + it('has a full stack trace if set() errors', () => { // Use an invalid document name that the backend will reject. const ref = randomCol.doc('__doc__'); @@ -2289,6 +2327,81 @@ describe('QuerySnapshot class', () => { }); }); +describe('BulkWriter class', () => { + let firestore: Firestore; + let randomCol: CollectionReference; + let writer: BulkWriter; + + beforeEach(() => { + firestore = new Firestore({}); + writer = firestore._bulkWriter(); + randomCol = getTestRoot(firestore); + }); + + afterEach(() => verifyInstance(firestore)); + + it('has create() method', async () => { + const ref = randomCol.doc('doc1'); + const singleOp = writer.create(ref, {foo: 'bar'}); + await writer.close(); + const result = await ref.get(); + expect(result.data()).to.deep.equal({foo: 'bar'}); + const writeTime = (await singleOp).writeTime; + expect(writeTime).to.not.be.null; + }); + + it('has set() method', async () => { + const ref = randomCol.doc('doc1'); + const singleOp = writer.set(ref, {foo: 'bar'}); + await writer.close(); + const result = await ref.get(); + expect(result.data()).to.deep.equal({foo: 'bar'}); + const writeTime = (await singleOp).writeTime; + expect(writeTime).to.not.be.null; + }); + + it('has update() method', async () => { + const ref = randomCol.doc('doc1'); + await ref.set({foo: 'bar'}); + const singleOp = writer.update(ref, {foo: 'bar2'}); + await writer.close(); + const result = await ref.get(); + expect(result.data()).to.deep.equal({foo: 'bar2'}); + const writeTime = (await singleOp).writeTime; + expect(writeTime).to.not.be.null; + }); + + it('has delete() method', async () => { + const ref = randomCol.doc('doc1'); + await ref.set({foo: 'bar'}); + const singleOp = writer.delete(ref); + await writer.close(); + const result = await ref.get(); + expect(result.exists).to.be.false; + // TODO(b/158502664): Remove this check once we can get write times. + const deleteResult = await singleOp; + expect(deleteResult.writeTime).to.deep.equal(new Timestamp(0, 0)); + }); + + it('can terminate once BulkWriter is closed', async () => { + const ref = randomCol.doc('doc1'); + writer.set(ref, {foo: 'bar'}); + await writer.close(); + return firestore.terminate(); + }); + + it('writes to the same document in order', async () => { + const ref = randomCol.doc('doc1'); + await ref.set({foo: 'bar0'}); + writer.set(ref, {foo: 'bar1'}); + writer.set(ref, {foo: 'bar2'}); + writer.set(ref, {foo: 'bar3'}); + await writer.flush(); + const res = await ref.get(); + expect(res.data()).to.deep.equal({foo: 'bar3'}); + }); +}); + describe('Client initialization', () => { const ops: Array<[ string, @@ -2369,3 +2482,148 @@ describe('Client initialization', () => { }); } }); + +describe('Bundle building', () => { + let firestore: Firestore; + let testCol: CollectionReference; + + beforeEach(async () => { + firestore = new Firestore({}); + testCol = getTestRoot(firestore); + const ref1 = testCol.doc('doc1'); + const ref2 = testCol.doc('doc2'); + const ref3 = testCol.doc('doc3'); + const ref4 = testCol.doc('doc4'); + + await Promise.all([ + ref1.set({name: '1', sort: 1, value: 'string value'}), + ref2.set({name: '2', sort: 2, value: 42}), + ref3.set({name: '3', sort: 3, value: {nested: 'nested value'}}), + ref4.set({name: '4', sort: 4, value: FieldValue.serverTimestamp()}), + ]); + }); + + afterEach(() => verifyInstance(firestore)); + + it('succeeds when there are no results', async () => { + const bundle = firestore._bundle(TEST_BUNDLE_ID); + const query = testCol.where('sort', '==', 5); + const snap = await query.get(); + + bundle.add('query', snap); + // `elements` is expected to be [bundleMeta, query]. + const elements = await bundleToElementArray(bundle.build()); + + const meta = (elements[0] as IBundleElement).metadata; + verifyMetadata(meta!, snap.readTime.toProto().timestampValue!, 0); + + const namedQuery = (elements[1] as IBundleElement).namedQuery; + // Verify saved query. + expect(namedQuery).to.deep.equal({ + name: 'query', + readTime: snap.readTime.toProto().timestampValue, + // TODO(wuandy): Fix query.toProto to skip undefined fields, so we can stop using `extend` here. + bundledQuery: extend( + true, + {}, + { + parent: query.toProto().parent, + structuredQuery: query.toProto().structuredQuery, + } + ), + }); + }); + + it('succeeds when added document does not exist', async () => { + const bundle = firestore._bundle(TEST_BUNDLE_ID); + const snap = await testCol.doc('doc5-not-exist').get(); + + bundle.add(snap); + // `elements` is expected to be [bundleMeta, docMeta]. + const elements = await bundleToElementArray(bundle.build()); + expect(elements.length).to.equal(2); + + const meta = (elements[0] as IBundleElement).metadata; + verifyMetadata(meta!, snap.readTime.toProto().timestampValue!, 1); + + const docMeta = (elements[1] as IBundleElement).documentMetadata; + expect(docMeta).to.deep.equal({ + name: snap.toDocumentProto().name, + readTime: snap.readTime.toProto().timestampValue, + exists: false, + }); + }); + + it('succeeds to save limit and limitToLast queries', async () => { + const bundle = firestore._bundle(TEST_BUNDLE_ID); + const limitQuery = testCol.orderBy('sort', 'desc').limit(1); + const limitSnap = await limitQuery.get(); + const limitToLastQuery = testCol.orderBy('sort', 'asc').limitToLast(1); + const limitToLastSnap = await limitToLastQuery.get(); + + bundle.add('limitQuery', limitSnap); + bundle.add('limitToLastQuery', limitToLastSnap); + // `elements` is expected to be [bundleMeta, limitQuery, limitToLastQuery, doc4Meta, doc4Snap]. + const elements = await bundleToElementArray(await bundle.build()); + + const meta = (elements[0] as IBundleElement).metadata; + verifyMetadata( + meta!, + limitToLastSnap.readTime.toProto().timestampValue!, + 1 + ); + + let namedQuery1 = (elements[1] as IBundleElement).namedQuery; + let namedQuery2 = (elements[2] as IBundleElement).namedQuery; + // We might need to swap them. + if (namedQuery1!.name === 'limitToLastQuery') { + const temp = namedQuery2; + namedQuery2 = namedQuery1; + namedQuery1 = temp; + } + + // Verify saved limit query. + expect(namedQuery1).to.deep.equal({ + name: 'limitQuery', + readTime: limitSnap.readTime.toProto().timestampValue, + bundledQuery: extend( + true, + {}, + { + parent: limitQuery.toProto().parent, + structuredQuery: limitQuery.toProto().structuredQuery, + limitType: 'FIRST', + } + ), + }); + + // `limitToLastQuery`'s structured query should be the same as this one. This together with + // `limitType` can re-construct a limitToLast client query by client SDKs. + const q = testCol.orderBy('sort', 'asc').limit(1); + // Verify saved limitToLast query. + expect(namedQuery2).to.deep.equal({ + name: 'limitToLastQuery', + readTime: limitToLastSnap.readTime.toProto().timestampValue, + bundledQuery: extend( + true, + {}, + { + parent: q.toProto().parent, + structuredQuery: q.toProto().structuredQuery, + limitType: 'LAST', + } + ), + }); + + // Verify bundled document + const docMeta = (elements[3] as IBundleElement).documentMetadata; + expect(docMeta).to.deep.equal({ + name: limitToLastSnap.docs[0].toDocumentProto().name, + readTime: limitToLastSnap.readTime.toProto().timestampValue, + exists: true, + }); + + const bundledDoc = (elements[4] as IBundleElement).document; + expect(bundledDoc).to.deep.equal(limitToLastSnap.docs[0].toDocumentProto()); + }); +}); diff --git a/dev/test/backoff.ts b/dev/test/backoff.ts index 1feb26981..787d23b8e 100644 --- a/dev/test/backoff.ts +++ b/dev/test/backoff.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {describe, it, beforeEach, before, after} from 'mocha'; import {expect, use} from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index eacb0b608..167fd6117 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -12,17 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {DocumentData} from '@google-cloud/firestore'; + +import {describe, it, beforeEach, afterEach} from 'mocha'; import {expect} from 'chai'; import {Status} from 'google-gax'; import * as proto from '../protos/firestore_v1_proto_api'; -import { - DocumentData, - Firestore, - setLogFunction, - Timestamp, - WriteResult, -} from '../src'; +import {Firestore, setLogFunction, Timestamp, WriteResult} from '../src'; import {setTimeoutHandler} from '../src/backoff'; import {BulkWriter} from '../src/bulk-writer'; import {Deferred} from '../src/util'; @@ -55,12 +52,19 @@ describe('BulkWriter', () => { let firestore: Firestore; let requestCounter: number; let opCount: number; - const activeRequestDeferred = new Deferred(); + let activeRequestDeferred: Deferred; let activeRequestCounter = 0; + let timeoutHandlerCounter = 0; beforeEach(() => { + activeRequestDeferred = new Deferred(); requestCounter = 0; opCount = 0; + timeoutHandlerCounter = 0; + setTimeoutHandler(fn => { + timeoutHandlerCounter++; + fn(); + }); }); function incrementOpCount(): void { @@ -100,13 +104,13 @@ describe('BulkWriter', () => { }; } - function successResponse(seconds: number): api.IBatchWriteResponse { + function successResponse(updateTimeSeconds: number): api.IBatchWriteResponse { return { writeResults: [ { updateTime: { nanos: 0, - seconds, + seconds: updateTimeSeconds, }, }, ], @@ -114,7 +118,7 @@ describe('BulkWriter', () => { }; } - function failResponse(): api.IBatchWriteResponse { + function failedResponse(): api.IBatchWriteResponse { return { writeResults: [ { @@ -177,7 +181,11 @@ describe('BulkWriter', () => { }); } - afterEach(() => verifyInstance(firestore)); + afterEach(() => { + verifyInstance(firestore); + expect(timeoutHandlerCounter).to.equal(0); + setTimeoutHandler(setTimeout); + }); it('has a set() method', async () => { const bulkWriter = await instantiateInstance([ @@ -259,7 +267,7 @@ describe('BulkWriter', () => { const bulkWriter = await instantiateInstance([ { request: createRequest([setOp('doc', 'bar')]), - response: failResponse(), + response: failedResponse(), }, ]); @@ -330,18 +338,18 @@ describe('BulkWriter', () => { expect(() => bulkWriter.update(doc, {})).to.throw(expected); expect(() => bulkWriter.delete(doc)).to.throw(expected); expect(bulkWriter.flush()).to.eventually.be.rejectedWith(expected); - expect(bulkWriter.close()).to.eventually.be.rejectedWith(expected); + expect(() => bulkWriter.close()).to.throw(expected); }); it('sends writes to the same document in separate batches', async () => { const bulkWriter = await instantiateInstance([ { request: createRequest([setOp('doc', 'bar')]), - response: successResponse(0), + response: successResponse(1), }, { request: createRequest([updateOp('doc', 'bar1')]), - response: successResponse(1), + response: successResponse(2), }, ]); @@ -360,7 +368,7 @@ describe('BulkWriter', () => { const bulkWriter = await instantiateInstance([ { request: createRequest([setOp('doc1', 'bar'), updateOp('doc2', 'bar')]), - response: mergeResponses([successResponse(0), successResponse(1)]), + response: mergeResponses([successResponse(1), successResponse(2)]), }, ]); @@ -409,7 +417,7 @@ describe('BulkWriter', () => { const bulkWriter = await instantiateInstance([ { request: createRequest([setOp('doc', 'bar')]), - response: successResponse(0), + response: successResponse(1), }, { request: createRequest([ @@ -452,9 +460,9 @@ describe('BulkWriter', () => { createOp('doc3', 'bar'), ]), response: mergeResponses([ - successResponse(0), successResponse(1), successResponse(2), + successResponse(3), ]), }, { @@ -488,7 +496,7 @@ describe('BulkWriter', () => { }); }); - it('does not send batches if a document containing the same write is in flight', async () => { + it('uses timeout for batches that exceed the rate limit', async () => { const bulkWriter = await instantiateInstance( [ { @@ -550,56 +558,46 @@ describe('BulkWriter', () => { }); describe('500/50/5 support', () => { - afterEach(() => setTimeoutHandler(setTimeout)); - - it('does not send batches if doing so exceeds the rate limit', async () => { - // The test is considered a success if BulkWriter tries to send the second - // batch again after a timeout. + // Return success responses for all requests. + function instantiateInstance(): Promise { + const overrides: ApiOverride = { + batchWrite: request => { + const requestLength = request.writes?.length || 0; + const responses = mergeResponses( + Array.from(new Array(requestLength), (_, i) => successResponse(i)) + ); + return response({ + writeResults: responses.writeResults, + status: responses.status, + }); + }, + }; + return createInstance(overrides).then(firestoreClient => { + firestore = firestoreClient; + return firestore._bulkWriter(); + }); + } - const arrayRange = Array.from(new Array(500), (_, i) => i); - const requests1 = arrayRange.map(i => setOp('doc' + i, 'bar')); - const responses1 = arrayRange.map(i => successResponse(i)); - const arrayRange2 = [500, 501, 502, 503, 504]; - const requests2 = arrayRange2.map(i => setOp('doc' + i, 'bar')); - const responses2 = arrayRange2.map(i => successResponse(i)); + it('does not send batches if doing so exceeds the rate limit', done => { + instantiateInstance().then(bulkWriter => { + let timeoutCalled = false; + setTimeoutHandler((_, timeout) => { + if (!timeoutCalled) { + timeoutCalled = true; + expect(timeout).to.be.greaterThan(0); + done(); + } + }); - const bulkWriter = await instantiateInstance([ - { - request: createRequest(requests1), - response: mergeResponses(responses1), - }, - { - request: createRequest(requests2), - response: mergeResponses(responses2), - }, - ]); - for (let i = 0; i < 500; i++) { - bulkWriter - .set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}) - .then(incrementOpCount); - } - const flush1 = bulkWriter.flush(); - - // Sending this next batch would go over the 500/50/5 capacity, so - // check that BulkWriter doesn't send this batch until the first batch - // is resolved. - let timeoutCalled = false; - setTimeoutHandler((_, timeout) => { - // Check that BulkWriter has not yet sent the 2nd batch. - timeoutCalled = true; - expect(requestCounter).to.equal(0); - expect(timeout).to.be.greaterThan(0); + for (let i = 0; i < 600; i++) { + bulkWriter.set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}); + } + // The close() promise will never resolve. Since we do not call the + // callback function in the overridden handler, subsequent requests + // after the timeout will not be made. The close() call is used to + // ensure that the final batch is sent. + bulkWriter.close(); }); - for (let i = 500; i < 505; i++) { - bulkWriter - .set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}) - .then(incrementOpCount); - } - const flush2 = bulkWriter.flush(); - await flush1; - await flush2; - expect(timeoutCalled).to.be.true; - return bulkWriter.close(); }); }); diff --git a/dev/test/bundle.ts b/dev/test/bundle.ts new file mode 100644 index 000000000..d93221233 --- /dev/null +++ b/dev/test/bundle.ts @@ -0,0 +1,275 @@ +// 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 +// +// https://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 {expect} from 'chai'; +import * as extend from 'extend'; +import {afterEach, beforeEach, describe, it} from 'mocha'; +import {firestore, google} from '../protos/firestore_v1_proto_api'; +import {Firestore, QuerySnapshot, Timestamp} from '../src'; +import { + bundleToElementArray, + createInstance, + DATABASE_ROOT, + verifyInstance, +} from './util/helpers'; +import IBundleElement = firestore.IBundleElement; +import IBundleMetadata = firestore.IBundleMetadata; +import ITimestamp = google.protobuf.ITimestamp; + +export const TEST_BUNDLE_ID = 'test-bundle'; +const TEST_BUNDLE_VERSION = 1; + +export function verifyMetadata( + meta: IBundleMetadata, + createTime: ITimestamp, + totalDocuments: number, + expectEmptyContent = false +): void { + if (!expectEmptyContent) { + expect(meta.totalBytes).greaterThan(0); + } else { + expect(meta.totalBytes).to.equal(0); + } + expect(meta.id).to.equal(TEST_BUNDLE_ID); + expect(meta.version).to.equal(TEST_BUNDLE_VERSION); + expect(meta.totalDocuments).to.equal(totalDocuments); + expect(meta.createTime).to.deep.equal(createTime); +} + +describe('Bundle Buidler', () => { + let firestore: Firestore; + + beforeEach(() => { + return createInstance().then(firestoreInstance => { + firestore = firestoreInstance; + }); + }); + + afterEach(() => verifyInstance(firestore)); + + // Tests the testing helper function bundleToElementArray works as expected. + it('succeeds to read length prefixed json with testing function', async () => { + const bundleString = + '20{"a":"string value"}9{"b":123}26{"c":{"d":"nested value"}}'; + const elements = await bundleToElementArray(Buffer.from(bundleString)); + expect(elements).to.deep.equal([ + {a: 'string value'}, + {b: 123}, + {c: {d: 'nested value'}}, + ]); + }); + + it('succeeds with document snapshots', async () => { + const bundle = firestore._bundle(TEST_BUNDLE_ID); + const snap1 = firestore.snapshot_( + { + name: `${DATABASE_ROOT}/documents/collectionId/doc1`, + fields: {foo: {stringValue: 'value'}, bar: {integerValue: 42}}, + createTime: '1970-01-01T00:00:01.002Z', + updateTime: '1970-01-01T00:00:03.000004Z', + }, + // This should be the bundle read time. + '2020-01-01T00:00:05.000000006Z', + 'json' + ); + // Same document but older read time. + const snap2 = firestore.snapshot_( + { + name: `${DATABASE_ROOT}/documents/collectionId/doc1`, + fields: {foo: {stringValue: 'value'}, bar: {integerValue: -42}}, + createTime: '1970-01-01T00:00:01.002Z', + updateTime: '1970-01-01T00:00:03.000004Z', + }, + '1970-01-01T00:00:05.000000006Z', + 'json' + ); + + bundle.add(snap1); + bundle.add(snap2); + // Bundle is expected to be [bundleMeta, snap2Meta, snap2] because `snap2` is added later. + const elements = await bundleToElementArray(bundle.build()); + expect(elements.length).to.equal(3); + + const meta = (elements[0] as IBundleElement).metadata; + verifyMetadata( + meta!, + // `snap1.readTime` is the bundle createTime, because it is larger than `snap2.readTime`. + snap1.readTime.toProto().timestampValue!, + 1 + ); + + // Verify doc1Meta and doc1Snap + const docMeta = (elements[1] as IBundleElement).documentMetadata; + const docSnap = (elements[2] as IBundleElement).document; + expect(docMeta).to.deep.equal({ + name: snap2.toDocumentProto().name, + readTime: snap2.readTime.toProto().timestampValue, + exists: true, + }); + expect(docSnap).to.deep.equal(snap2.toDocumentProto()); + }); + + it('succeeds with query snapshots', async () => { + const bundle = firestore._bundle(TEST_BUNDLE_ID); + const snap = firestore.snapshot_( + { + name: `${DATABASE_ROOT}/documents/collectionId/doc1`, + value: 'string', + createTime: '1970-01-01T00:00:01.002Z', + updateTime: '1970-01-01T00:00:03.000004Z', + }, + // This should be the bundle read time. + '2020-01-01T00:00:05.000000006Z', + 'json' + ); + const query = firestore + .collection('collectionId') + .where('value', '==', 'string'); + const querySnapshot = new QuerySnapshot( + query, + snap.readTime, + 1, + () => [snap], + () => [] + ); + + bundle.add('test-query', querySnapshot); + // Bundle is expected to be [bundleMeta, namedQuery, snapMeta, snap] + const elements = await bundleToElementArray(bundle.build()); + expect(elements.length).to.equal(4); + + const meta = (elements[0] as IBundleElement).metadata; + verifyMetadata( + meta!, + // `snap.readTime` is the bundle createTime, because it is larger than `snap2.readTime`. + snap.readTime.toProto().timestampValue!, + 1 + ); + + // Verify named query + const namedQuery = (elements[1] as IBundleElement).namedQuery; + expect(namedQuery).to.deep.equal({ + name: 'test-query', + readTime: snap.readTime.toProto().timestampValue, + bundledQuery: extend( + true, + {}, + { + parent: query.toProto().parent, + structuredQuery: query.toProto().structuredQuery, + } + ), + }); + + // Verify docMeta and docSnap + const docMeta = (elements[2] as IBundleElement).documentMetadata; + const docSnap = (elements[3] as IBundleElement).document; + expect(docMeta).to.deep.equal({ + name: snap.toDocumentProto().name, + readTime: snap.readTime.toProto().timestampValue, + exists: true, + }); + expect(docSnap).to.deep.equal(snap.toDocumentProto()); + }); + + it('succeeds with multiple calls to build()', async () => { + const bundle = firestore._bundle(TEST_BUNDLE_ID); + const snap1 = firestore.snapshot_( + { + name: `${DATABASE_ROOT}/documents/collectionId/doc1`, + fields: {foo: {stringValue: 'value'}, bar: {integerValue: 42}}, + createTime: '1970-01-01T00:00:01.002Z', + updateTime: '1970-01-01T00:00:03.000004Z', + }, + // This should be the bundle read time. + '2020-01-01T00:00:05.000000006Z', + 'json' + ); + bundle.add(snap1); + // Bundle is expected to be [bundleMeta, doc1Meta, doc1Snap]. + const elements = await bundleToElementArray(bundle.build()); + + expect(elements.length).to.equal(3); + + const meta = (elements[0] as IBundleElement).metadata; + verifyMetadata( + meta!, + // `snap1.readTime` is the bundle createTime, because it is larger than `snap2.readTime`. + snap1.readTime.toProto().timestampValue!, + 1 + ); + + // Verify doc1Meta and doc1Snap + const doc1Meta = (elements[1] as IBundleElement).documentMetadata; + const doc1Snap = (elements[2] as IBundleElement).document; + expect(doc1Meta).to.deep.equal({ + name: snap1.toDocumentProto().name, + readTime: snap1.readTime.toProto().timestampValue, + exists: true, + }); + expect(doc1Snap).to.deep.equal(snap1.toDocumentProto()); + + // Add another document + const snap2 = firestore.snapshot_( + { + name: `${DATABASE_ROOT}/documents/collectionId/doc2`, + fields: {foo: {stringValue: 'value'}, bar: {integerValue: -42}}, + createTime: '1970-01-01T00:00:01.002Z', + updateTime: '1970-01-01T00:00:03.000004Z', + }, + '1970-01-01T00:00:05.000000006Z', + 'json' + ); + bundle.add(snap2); + + // Bundle is expected to be [bundleMeta, doc1Meta, doc1Snap, doc2Meta, doc2Snap]. + const newElements = await bundleToElementArray(bundle.build()); + + expect(newElements.length).to.equal(5); + const newMeta = (newElements[0] as IBundleElement).metadata; + verifyMetadata( + newMeta!, + // `snap1.readTime` is the bundle createTime, because it is larger than `snap2.readTime`. + snap1.readTime.toProto().timestampValue!, + 2 + ); + expect(newElements.slice(1, 3)).to.deep.equal(elements.slice(1)); + + // Verify doc2Meta and doc2Snap + const doc2Meta = (newElements[3] as IBundleElement).documentMetadata; + const doc2Snap = (newElements[4] as IBundleElement).document; + expect(doc2Meta).to.deep.equal({ + name: snap2.toDocumentProto().name, + readTime: snap2.readTime.toProto().timestampValue, + exists: true, + }); + expect(doc2Snap).to.deep.equal(snap2.toDocumentProto()); + }); + + it('succeeds when nothing is added', async () => { + const bundle = firestore._bundle(TEST_BUNDLE_ID); + + // `elements` is expected to be [bundleMeta]. + const elements = await bundleToElementArray(bundle.build()); + expect(elements.length).to.equal(1); + + const meta = (elements[0] as IBundleElement).metadata; + verifyMetadata( + meta!, + new Timestamp(0, 0).toProto().timestampValue!, + 0, + true + ); + }); +}); diff --git a/dev/test/collection.ts b/dev/test/collection.ts index ada5891d6..77ce13a7c 100644 --- a/dev/test/collection.ts +++ b/dev/test/collection.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {describe, it, beforeEach, afterEach} from 'mocha'; import {expect} from 'chai'; import * as through2 from 'through2'; @@ -149,7 +150,7 @@ describe('Collection interface', () => { it('has list() method', () => { const overrides: ApiOverride = { - listDocuments: (request, options) => { + listDocuments: request => { expect(request).to.deep.eq({ parent: `${DATABASE_ROOT}/documents/a/b`, collectionId: 'c', diff --git a/dev/test/document.ts b/dev/test/document.ts index bc33f9224..9a0b0c986 100644 --- a/dev/test/document.ts +++ b/dev/test/document.ts @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {describe, it, beforeEach, afterEach} from 'mocha'; import {expect} from 'chai'; import {GoogleError, Status} from 'google-gax'; import * as through2 from 'through2'; import { DocumentReference, - DocumentSnapshot, FieldPath, FieldValue, Firestore, @@ -36,6 +36,7 @@ import { missing, Post, postConverter, + postConverterMerge, remove, requestEquals, response, @@ -279,6 +280,28 @@ describe('serialize document', () => { }); }); + it('supports BigInt', () => { + const overrides: ApiOverride = { + commit: request => { + requestEquals( + request, + set({ + document: document('documentId', 'bigIntValue', { + integerValue: '9007199254740992', + }), + }) + ); + return response(writeResult(1)); + }, + }; + + return createInstance(overrides).then(firestore => { + return firestore.doc('collectionId/documentId').set({ + bigIntValue: BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1), + }); + }); + }); + it('serializes unicode keys', () => { const overrides: ApiOverride = { commit: request => { @@ -419,7 +442,7 @@ describe('serialize document', () => { // instances, even if they have cyclic references (we shouldn't try to // validate them beyond the instanceof check). const ref = firestore.doc('collectionId/documentId'); - // tslint:disable-next-line:no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any (ref.firestore as any).firestore = firestore; return ref.set({ref}); }); @@ -528,6 +551,30 @@ describe('deserialize document', () => { }); }); + it('deserializes BigInt', () => { + const overrides: ApiOverride = { + batchGetDocuments: () => { + return stream( + found( + document('documentId', 'bigIntValue', { + integerValue: '9007199254740992', + }) + ) + ); + }, + }; + + return createInstance(overrides, {useBigInt: true}).then(firestore => { + return firestore + .doc('collectionId/documentId') + .get() + .then(res => { + expect(res.get('bigIntValue')).to.be.a('bigint'); + expect(res.get('bigIntValue')).to.equal(BigInt('9007199254740992')); + }); + }); + }); + it("doesn't deserialize unsupported types", () => { const overrides: ApiOverride = { batchGetDocuments: () => { @@ -1190,6 +1237,58 @@ describe('set document', () => { }); }); + it('supports partials with merge', () => { + const overrides: ApiOverride = { + commit: request => { + requestEquals( + request, + set({ + document: document('documentId', 'title', { + stringValue: 'story', + }), + mask: updateMask('title'), + }) + ); + return response(writeResult(1)); + }, + }; + + return createInstance(overrides).then(firestore => { + return firestore + .doc('collectionId/documentId') + .withConverter(postConverterMerge) + .set({title: 'story'} as Partial, { + merge: true, + }); + }); + }); + + it('supports partials with mergeFields', () => { + const overrides: ApiOverride = { + commit: request => { + requestEquals( + request, + set({ + document: document('documentId', 'title', { + stringValue: 'story', + }), + mask: updateMask('title'), + }) + ); + return response(writeResult(1)); + }, + }; + + return createInstance(overrides).then(firestore => { + return firestore + .doc('collectionId/documentId') + .withConverter(postConverterMerge) + .set({title: 'story', author: 'writer'} as Partial, { + mergeFields: ['title'], + }); + }); + }); + it("doesn't split on dots", () => { const overrides: ApiOverride = { commit: request => { diff --git a/dev/test/field-value.ts b/dev/test/field-value.ts index a49d2387d..c19e8c3c8 100644 --- a/dev/test/field-value.ts +++ b/dev/test/field-value.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {describe, it} from 'mocha'; import {expect} from 'chai'; import {FieldValue} from '../src'; diff --git a/dev/test/gapic-firestore-v1.ts b/dev/test/gapic-firestore-v1.ts deleted file mode 100644 index 7e884a8d2..000000000 --- a/dev/test/gapic-firestore-v1.ts +++ /dev/null @@ -1,870 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as assert from 'assert'; -import {describe, it} from 'mocha'; -import * as protosTypes from '../protos/firestore_v1_proto_api'; -const firestoreModule = require('../src'); - -import {PassThrough} from 'stream'; - -const FAKE_STATUS_CODE = 1; -class FakeError { - name: string; - message: string; - code: number; - constructor(n: number) { - this.name = 'fakeName'; - this.message = 'fake message'; - this.code = n; - } -} -const error = new FakeError(FAKE_STATUS_CODE); -export interface Callback { - (err: FakeError | null, response?: {} | null): void; -} - -export class Operation { - constructor() {} - promise() {} -} -function mockSimpleGrpcMethod( - expectedRequest: {}, - response: {} | null, - error: FakeError | null -) { - return (actualRequest: {}, options: {}, callback: Callback) => { - assert.deepStrictEqual(actualRequest, expectedRequest); - if (error) { - callback(error); - } else if (response) { - callback(null, response); - } else { - callback(null); - } - }; -} -function mockServerStreamingGrpcMethod( - expectedRequest: {}, - response: {} | null, - error: FakeError | null -) { - return (actualRequest: {}) => { - assert.deepStrictEqual(actualRequest, expectedRequest); - const mockStream = new PassThrough({ - objectMode: true, - transform: (chunk: {}, enc: {}, callback: Callback) => { - if (error) { - callback(error); - } else { - callback(null, response); - } - }, - }); - return mockStream; - }; -} -function mockBidiStreamingGrpcMethod( - expectedRequest: {}, - response: {} | null, - error: FakeError | null -) { - return () => { - const mockStream = new PassThrough({ - objectMode: true, - transform: (chunk: {}, enc: {}, callback: Callback) => { - assert.deepStrictEqual(chunk, expectedRequest); - if (error) { - callback(error); - } else { - callback(null, response); - } - }, - }); - return mockStream; - }; -} -describe('v1.FirestoreClient', () => { - it('has servicePath', () => { - const servicePath = firestoreModule.v1.FirestoreClient.servicePath; - assert(servicePath); - }); - it('has apiEndpoint', () => { - const apiEndpoint = firestoreModule.v1.FirestoreClient.apiEndpoint; - assert(apiEndpoint); - }); - it('has port', () => { - const port = firestoreModule.v1.FirestoreClient.port; - assert(port); - assert(typeof port === 'number'); - }); - it('should create a client with no option', () => { - const client = new firestoreModule.v1.FirestoreClient(); - assert(client); - }); - it('should create a client with gRPC fallback', () => { - const client = new firestoreModule.v1.FirestoreClient({ - fallback: true, - }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.firestoreStub, undefined); - await client.initialize(); - assert(client.firestoreStub); - }); - it('has close method', () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.close(); - }); - describe('getDocument', () => { - it('invokes getDocument without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IGetDocumentRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getDocument = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.getDocument(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes getDocument with error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IGetDocumentRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getDocument = mockSimpleGrpcMethod( - request, - null, - error - ); - client.getDocument(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('updateDocument', () => { - it('invokes updateDocument without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IUpdateDocumentRequest = {}; - request.document = {}; - request.document.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateDocument = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.updateDocument(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes updateDocument with error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IUpdateDocumentRequest = {}; - request.document = {}; - request.document.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateDocument = mockSimpleGrpcMethod( - request, - null, - error - ); - client.updateDocument(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('deleteDocument', () => { - it('invokes deleteDocument without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IDeleteDocumentRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteDocument = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.deleteDocument(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes deleteDocument with error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IDeleteDocumentRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteDocument = mockSimpleGrpcMethod( - request, - null, - error - ); - client.deleteDocument(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('beginTransaction', () => { - it('invokes beginTransaction without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IBeginTransactionRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.beginTransaction = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.beginTransaction(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes beginTransaction with error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IBeginTransactionRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.beginTransaction = mockSimpleGrpcMethod( - request, - null, - error - ); - client.beginTransaction(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('commit', () => { - it('invokes commit without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.ICommitRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.commit = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.commit(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes commit with error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.ICommitRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.commit = mockSimpleGrpcMethod(request, null, error); - client.commit(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('rollback', () => { - it('invokes rollback without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IRollbackRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.rollback = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.rollback(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes rollback with error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IRollbackRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.rollback = mockSimpleGrpcMethod( - request, - null, - error - ); - client.rollback(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('createDocument', () => { - it('invokes createDocument without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.ICreateDocumentRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createDocument = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.createDocument(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes createDocument with error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.ICreateDocumentRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createDocument = mockSimpleGrpcMethod( - request, - null, - error - ); - client.createDocument(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('batchGetDocuments', () => { - it('invokes batchGetDocuments without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IBatchGetDocumentsRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.batchGetDocuments = mockServerStreamingGrpcMethod( - request, - expectedResponse, - null - ); - const stream = client.batchGetDocuments(request); - stream.on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - stream.on('error', (err: FakeError) => { - done(err); - }); - stream.write(); - }); - it('invokes batchGetDocuments with error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IBatchGetDocumentsRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.batchGetDocuments = mockServerStreamingGrpcMethod( - request, - null, - error - ); - const stream = client.batchGetDocuments(request); - stream.on('data', () => { - assert.fail(); - }); - stream.on('error', (err: FakeError) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - done(); - }); - stream.write(); - }); - }); - describe('runQuery', () => { - it('invokes runQuery without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IRunQueryRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.runQuery = mockServerStreamingGrpcMethod( - request, - expectedResponse, - null - ); - const stream = client.runQuery(request); - stream.on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - stream.on('error', (err: FakeError) => { - done(err); - }); - stream.write(); - }); - it('invokes runQuery with error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IRunQueryRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.runQuery = mockServerStreamingGrpcMethod( - request, - null, - error - ); - const stream = client.runQuery(request); - stream.on('data', () => { - assert.fail(); - }); - stream.on('error', (err: FakeError) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - done(); - }); - stream.write(); - }); - }); - describe('write', () => { - it('invokes write without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IWriteRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.write = mockBidiStreamingGrpcMethod( - request, - expectedResponse, - null - ); - const stream = client - .write() - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(request); - }); - it('invokes write with error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IWriteRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.write = mockBidiStreamingGrpcMethod( - request, - null, - error - ); - const stream = client - .write() - .on('data', () => { - assert.fail(); - }) - .on('error', (err: FakeError) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - done(); - }); - stream.write(request); - }); - }); - describe('listen', () => { - it('invokes listen without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IListenRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.listen = mockBidiStreamingGrpcMethod( - request, - expectedResponse, - null - ); - const stream = client - .listen() - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(request); - }); - it('invokes listen with error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IListenRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.listen = mockBidiStreamingGrpcMethod( - request, - null, - error - ); - const stream = client - .listen() - .on('data', () => { - assert.fail(); - }) - .on('error', (err: FakeError) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - done(); - }); - stream.write(request); - }); - }); - describe('listDocuments', () => { - it('invokes listDocuments without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IListDocumentsRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listDocuments = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listDocuments(request, (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - }); - describe('listDocumentsStream', () => { - it('invokes listDocumentsStream without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IListDocumentsRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listDocuments = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listDocumentsStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); - describe('listCollectionIds', () => { - it('invokes listCollectionIds without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IListCollectionIdsRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listCollectionIds = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listCollectionIds(request, (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - }); - describe('listCollectionIdsStream', () => { - it('invokes listCollectionIdsStream without error', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1.IListCollectionIdsRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listCollectionIds = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listCollectionIdsStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); -}); diff --git a/dev/test/gapic-firestore-v1beta1.ts b/dev/test/gapic-firestore-v1beta1.ts deleted file mode 100644 index bd1169dbc..000000000 --- a/dev/test/gapic-firestore-v1beta1.ts +++ /dev/null @@ -1,870 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as assert from 'assert'; -import {describe, it} from 'mocha'; -import * as protosTypes from '../protos/firestore_v1beta1_proto_api'; -const firestoreModule = require('../src'); - -import {PassThrough} from 'stream'; - -const FAKE_STATUS_CODE = 1; -class FakeError { - name: string; - message: string; - code: number; - constructor(n: number) { - this.name = 'fakeName'; - this.message = 'fake message'; - this.code = n; - } -} -const error = new FakeError(FAKE_STATUS_CODE); -export interface Callback { - (err: FakeError | null, response?: {} | null): void; -} - -export class Operation { - constructor() {} - promise() {} -} -function mockSimpleGrpcMethod( - expectedRequest: {}, - response: {} | null, - error: FakeError | null -) { - return (actualRequest: {}, options: {}, callback: Callback) => { - assert.deepStrictEqual(actualRequest, expectedRequest); - if (error) { - callback(error); - } else if (response) { - callback(null, response); - } else { - callback(null); - } - }; -} -function mockServerStreamingGrpcMethod( - expectedRequest: {}, - response: {} | null, - error: FakeError | null -) { - return (actualRequest: {}) => { - assert.deepStrictEqual(actualRequest, expectedRequest); - const mockStream = new PassThrough({ - objectMode: true, - transform: (chunk: {}, enc: {}, callback: Callback) => { - if (error) { - callback(error); - } else { - callback(null, response); - } - }, - }); - return mockStream; - }; -} -function mockBidiStreamingGrpcMethod( - expectedRequest: {}, - response: {} | null, - error: FakeError | null -) { - return () => { - const mockStream = new PassThrough({ - objectMode: true, - transform: (chunk: {}, enc: {}, callback: Callback) => { - assert.deepStrictEqual(chunk, expectedRequest); - if (error) { - callback(error); - } else { - callback(null, response); - } - }, - }); - return mockStream; - }; -} -describe('v1beta1.FirestoreClient', () => { - it('has servicePath', () => { - const servicePath = firestoreModule.v1beta1.FirestoreClient.servicePath; - assert(servicePath); - }); - it('has apiEndpoint', () => { - const apiEndpoint = firestoreModule.v1beta1.FirestoreClient.apiEndpoint; - assert(apiEndpoint); - }); - it('has port', () => { - const port = firestoreModule.v1beta1.FirestoreClient.port; - assert(port); - assert(typeof port === 'number'); - }); - it('should create a client with no option', () => { - const client = new firestoreModule.v1beta1.FirestoreClient(); - assert(client); - }); - it('should create a client with gRPC fallback', () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - fallback: true, - }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.firestoreStub, undefined); - await client.initialize(); - assert(client.firestoreStub); - }); - it('has close method', () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.close(); - }); - describe('getDocument', () => { - it('invokes getDocument without error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IGetDocumentRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getDocument = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.getDocument(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes getDocument with error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IGetDocumentRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getDocument = mockSimpleGrpcMethod( - request, - null, - error - ); - client.getDocument(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('createDocument', () => { - it('invokes createDocument without error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.ICreateDocumentRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createDocument = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.createDocument(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes createDocument with error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.ICreateDocumentRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createDocument = mockSimpleGrpcMethod( - request, - null, - error - ); - client.createDocument(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('updateDocument', () => { - it('invokes updateDocument without error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest = {}; - request.document = {}; - request.document.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateDocument = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.updateDocument(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes updateDocument with error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest = {}; - request.document = {}; - request.document.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateDocument = mockSimpleGrpcMethod( - request, - null, - error - ); - client.updateDocument(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('deleteDocument', () => { - it('invokes deleteDocument without error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteDocument = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.deleteDocument(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes deleteDocument with error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteDocument = mockSimpleGrpcMethod( - request, - null, - error - ); - client.deleteDocument(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('beginTransaction', () => { - it('invokes beginTransaction without error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IBeginTransactionRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.beginTransaction = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.beginTransaction(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes beginTransaction with error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IBeginTransactionRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.beginTransaction = mockSimpleGrpcMethod( - request, - null, - error - ); - client.beginTransaction(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('commit', () => { - it('invokes commit without error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.ICommitRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.commit = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.commit(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes commit with error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.ICommitRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.commit = mockSimpleGrpcMethod(request, null, error); - client.commit(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('rollback', () => { - it('invokes rollback without error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IRollbackRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.rollback = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.rollback(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes rollback with error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IRollbackRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.rollback = mockSimpleGrpcMethod( - request, - null, - error - ); - client.rollback(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('batchGetDocuments', () => { - it('invokes batchGetDocuments without error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IBatchGetDocumentsRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.batchGetDocuments = mockServerStreamingGrpcMethod( - request, - expectedResponse, - null - ); - const stream = client.batchGetDocuments(request); - stream.on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - stream.on('error', (err: FakeError) => { - done(err); - }); - stream.write(); - }); - it('invokes batchGetDocuments with error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IBatchGetDocumentsRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.batchGetDocuments = mockServerStreamingGrpcMethod( - request, - null, - error - ); - const stream = client.batchGetDocuments(request); - stream.on('data', () => { - assert.fail(); - }); - stream.on('error', (err: FakeError) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - done(); - }); - stream.write(); - }); - }); - describe('runQuery', () => { - it('invokes runQuery without error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IRunQueryRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.runQuery = mockServerStreamingGrpcMethod( - request, - expectedResponse, - null - ); - const stream = client.runQuery(request); - stream.on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - stream.on('error', (err: FakeError) => { - done(err); - }); - stream.write(); - }); - it('invokes runQuery with error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IRunQueryRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.runQuery = mockServerStreamingGrpcMethod( - request, - null, - error - ); - const stream = client.runQuery(request); - stream.on('data', () => { - assert.fail(); - }); - stream.on('error', (err: FakeError) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - done(); - }); - stream.write(); - }); - }); - describe('write', () => { - it('invokes write without error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IWriteRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.write = mockBidiStreamingGrpcMethod( - request, - expectedResponse, - null - ); - const stream = client - .write() - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(request); - }); - it('invokes write with error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IWriteRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.write = mockBidiStreamingGrpcMethod( - request, - null, - error - ); - const stream = client - .write() - .on('data', () => { - assert.fail(); - }) - .on('error', (err: FakeError) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - done(); - }); - stream.write(request); - }); - }); - describe('listen', () => { - it('invokes listen without error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IListenRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.listen = mockBidiStreamingGrpcMethod( - request, - expectedResponse, - null - ); - const stream = client - .listen() - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(request); - }); - it('invokes listen with error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IListenRequest = {}; - request.database = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.listen = mockBidiStreamingGrpcMethod( - request, - null, - error - ); - const stream = client - .listen() - .on('data', () => { - assert.fail(); - }) - .on('error', (err: FakeError) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - done(); - }); - stream.write(request); - }); - }); - describe('listDocuments', () => { - it('invokes listDocuments without error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IListDocumentsRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listDocuments = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listDocuments(request, (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - }); - describe('listDocumentsStream', () => { - it('invokes listDocumentsStream without error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IListDocumentsRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listDocuments = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listDocumentsStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); - describe('listCollectionIds', () => { - it('invokes listCollectionIds without error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listCollectionIds = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listCollectionIds(request, (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - }); - describe('listCollectionIdsStream', () => { - it('invokes listCollectionIdsStream without error', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listCollectionIds = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listCollectionIdsStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); -}); diff --git a/dev/test/gapic-firestore_admin-v1.ts b/dev/test/gapic-firestore_admin-v1.ts deleted file mode 100644 index 179089643..000000000 --- a/dev/test/gapic-firestore_admin-v1.ts +++ /dev/null @@ -1,675 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as assert from 'assert'; -import {describe, it} from 'mocha'; -import * as protosTypes from '../protos/firestore_admin_v1_proto_api'; -const firestoreadminModule = require('../src'); - -const FAKE_STATUS_CODE = 1; -class FakeError { - name: string; - message: string; - code: number; - constructor(n: number) { - this.name = 'fakeName'; - this.message = 'fake message'; - this.code = n; - } -} -const error = new FakeError(FAKE_STATUS_CODE); -export interface Callback { - (err: FakeError | null, response?: {} | null): void; -} - -export class Operation { - constructor() {} - promise() {} -} -function mockSimpleGrpcMethod( - expectedRequest: {}, - response: {} | null, - error: FakeError | null -) { - return (actualRequest: {}, options: {}, callback: Callback) => { - assert.deepStrictEqual(actualRequest, expectedRequest); - if (error) { - callback(error); - } else if (response) { - callback(null, response); - } else { - callback(null); - } - }; -} -function mockLongRunningGrpcMethod( - expectedRequest: {}, - response: {} | null, - error?: {} | null -) { - return (request: {}) => { - assert.deepStrictEqual(request, expectedRequest); - const mockOperation = { - promise() { - return new Promise((resolve, reject) => { - if (error) { - reject(error); - } else { - resolve([response]); - } - }); - }, - }; - return Promise.resolve([mockOperation]); - }; -} -describe('v1.FirestoreAdminClient', () => { - it('has servicePath', () => { - const servicePath = - firestoreadminModule.v1.FirestoreAdminClient.servicePath; - assert(servicePath); - }); - it('has apiEndpoint', () => { - const apiEndpoint = - firestoreadminModule.v1.FirestoreAdminClient.apiEndpoint; - assert(apiEndpoint); - }); - it('has port', () => { - const port = firestoreadminModule.v1.FirestoreAdminClient.port; - assert(port); - assert(typeof port === 'number'); - }); - it('should create a client with no option', () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient(); - assert(client); - }); - it('should create a client with gRPC fallback', () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - fallback: true, - }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.firestoreAdminStub, undefined); - await client.initialize(); - assert(client.firestoreAdminStub); - }); - it('has close method', () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.close(); - }); - describe('getIndex', () => { - it('invokes getIndex without error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.IGetIndexRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getIndex = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.getIndex(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes getIndex with error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.IGetIndexRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getIndex = mockSimpleGrpcMethod( - request, - null, - error - ); - client.getIndex(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('deleteIndex', () => { - it('invokes deleteIndex without error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.IDeleteIndexRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteIndex = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.deleteIndex(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes deleteIndex with error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.IDeleteIndexRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.deleteIndex = mockSimpleGrpcMethod( - request, - null, - error - ); - client.deleteIndex(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('getField', () => { - it('invokes getField without error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.IGetFieldRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getField = mockSimpleGrpcMethod( - request, - expectedResponse, - null - ); - client.getField(request, (err: {}, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - - it('invokes getField with error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.IGetFieldRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.getField = mockSimpleGrpcMethod( - request, - null, - error - ); - client.getField(request, (err: FakeError, response: {}) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - assert(typeof response === 'undefined'); - done(); - }); - }); - }); - describe('createIndex', () => { - it('invokes createIndex without error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.ICreateIndexRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createIndex = mockLongRunningGrpcMethod( - request, - expectedResponse - ); - client - .createIndex(request) - .then((responses: [Operation]) => { - const operation = responses[0]; - return operation ? operation.promise() : {}; - }) - .then((responses: [Operation]) => { - assert.deepStrictEqual(responses[0], expectedResponse); - done(); - }) - .catch((err: {}) => { - done(err); - }); - }); - - it('invokes createIndex with error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.ICreateIndexRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.createIndex = mockLongRunningGrpcMethod( - request, - null, - error - ); - client - .createIndex(request) - .then((responses: [Operation]) => { - const operation = responses[0]; - return operation ? operation.promise() : {}; - }) - .then(() => { - assert.fail(); - }) - .catch((err: FakeError) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - done(); - }); - }); - }); - describe('updateField', () => { - it('invokes updateField without error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.IUpdateFieldRequest = {}; - request.field = {}; - request.field.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateField = mockLongRunningGrpcMethod( - request, - expectedResponse - ); - client - .updateField(request) - .then((responses: [Operation]) => { - const operation = responses[0]; - return operation ? operation.promise() : {}; - }) - .then((responses: [Operation]) => { - assert.deepStrictEqual(responses[0], expectedResponse); - done(); - }) - .catch((err: {}) => { - done(err); - }); - }); - - it('invokes updateField with error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.IUpdateFieldRequest = {}; - request.field = {}; - request.field.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.updateField = mockLongRunningGrpcMethod( - request, - null, - error - ); - client - .updateField(request) - .then((responses: [Operation]) => { - const operation = responses[0]; - return operation ? operation.promise() : {}; - }) - .then(() => { - assert.fail(); - }) - .catch((err: FakeError) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - done(); - }); - }); - }); - describe('exportDocuments', () => { - it('invokes exportDocuments without error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.IExportDocumentsRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.exportDocuments = mockLongRunningGrpcMethod( - request, - expectedResponse - ); - client - .exportDocuments(request) - .then((responses: [Operation]) => { - const operation = responses[0]; - return operation ? operation.promise() : {}; - }) - .then((responses: [Operation]) => { - assert.deepStrictEqual(responses[0], expectedResponse); - done(); - }) - .catch((err: {}) => { - done(err); - }); - }); - - it('invokes exportDocuments with error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.IExportDocumentsRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.exportDocuments = mockLongRunningGrpcMethod( - request, - null, - error - ); - client - .exportDocuments(request) - .then((responses: [Operation]) => { - const operation = responses[0]; - return operation ? operation.promise() : {}; - }) - .then(() => { - assert.fail(); - }) - .catch((err: FakeError) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - done(); - }); - }); - }); - describe('importDocuments', () => { - it('invokes importDocuments without error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.IImportDocumentsRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.importDocuments = mockLongRunningGrpcMethod( - request, - expectedResponse - ); - client - .importDocuments(request) - .then((responses: [Operation]) => { - const operation = responses[0]; - return operation ? operation.promise() : {}; - }) - .then((responses: [Operation]) => { - assert.deepStrictEqual(responses[0], expectedResponse); - done(); - }) - .catch((err: {}) => { - done(err); - }); - }); - - it('invokes importDocuments with error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.IImportDocumentsRequest = {}; - request.name = ''; - // Mock response - const expectedResponse = {}; - // Mock gRPC layer - client._innerApiCalls.importDocuments = mockLongRunningGrpcMethod( - request, - null, - error - ); - client - .importDocuments(request) - .then((responses: [Operation]) => { - const operation = responses[0]; - return operation ? operation.promise() : {}; - }) - .then(() => { - assert.fail(); - }) - .catch((err: FakeError) => { - assert(err instanceof FakeError); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - done(); - }); - }); - }); - describe('listIndexes', () => { - it('invokes listIndexes without error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.IListIndexesRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listIndexes = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listIndexes(request, (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - }); - describe('listIndexesStream', () => { - it('invokes listIndexesStream without error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.IListIndexesRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listIndexes = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listIndexesStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); - describe('listFields', () => { - it('invokes listFields without error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.IListFieldsRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {}; - // Mock Grpc layer - client._innerApiCalls.listFields = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - client.listFields(request, (err: FakeError, response: {}) => { - assert.ifError(err); - assert.deepStrictEqual(response, expectedResponse); - done(); - }); - }); - }); - describe('listFieldsStream', () => { - it('invokes listFieldsStream without error', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - // Initialize client before mocking - client.initialize(); - // Mock request - const request: protosTypes.google.firestore.admin.v1.IListFieldsRequest = {}; - request.parent = ''; - // Mock response - const expectedResponse = {response: 'data'}; - // Mock Grpc layer - client._innerApiCalls.listFields = ( - actualRequest: {}, - options: {}, - callback: Callback - ) => { - assert.deepStrictEqual(actualRequest, request); - callback(null, expectedResponse); - }; - const stream = client - .listFieldsStream(request, {}) - .on('data', (response: {}) => { - assert.deepStrictEqual(response, expectedResponse); - done(); - }) - .on('error', (err: FakeError) => { - done(err); - }); - stream.write(expectedResponse); - }); - }); -}); diff --git a/dev/test/gapic_firestore_admin_v1.ts b/dev/test/gapic_firestore_admin_v1.ts new file mode 100644 index 000000000..2f87b5d7f --- /dev/null +++ b/dev/test/gapic_firestore_admin_v1.ts @@ -0,0 +1,2179 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/firestore_admin_v1_proto_api'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as firestoreadminModule from '../src/v1'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message).toObject( + instance as protobuf.Message, + {defaults: true} + ); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); + } + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.FirestoreAdminClient', () => { + it('has servicePath', () => { + const servicePath = firestoreadminModule.FirestoreAdminClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = firestoreadminModule.FirestoreAdminClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = firestoreadminModule.FirestoreAdminClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new firestoreadminModule.FirestoreAdminClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.firestoreAdminStub, undefined); + await client.initialize(); + assert(client.firestoreAdminStub); + }); + + it('has close method', () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('getIndex', () => { + it('invokes getIndex without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.GetIndexRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.admin.v1.Index() + ); + client.innerApiCalls.getIndex = stubSimpleCall(expectedResponse); + const [response] = await client.getIndex(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getIndex as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getIndex without error using callback', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.GetIndexRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.admin.v1.Index() + ); + client.innerApiCalls.getIndex = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getIndex( + request, + ( + err?: Error | null, + result?: protos.google.firestore.admin.v1.IIndex | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getIndex as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getIndex with error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.GetIndexRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getIndex = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIndex(request), expectedError); + assert( + (client.innerApiCalls.getIndex as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('deleteIndex', () => { + it('invokes deleteIndex without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.DeleteIndexRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteIndex = stubSimpleCall(expectedResponse); + const [response] = await client.deleteIndex(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteIndex without error using callback', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.DeleteIndexRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteIndex = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deleteIndex( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes deleteIndex with error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.DeleteIndexRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteIndex = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteIndex(request), expectedError); + assert( + (client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('getField', () => { + it('invokes getField without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.GetFieldRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.admin.v1.Field() + ); + client.innerApiCalls.getField = stubSimpleCall(expectedResponse); + const [response] = await client.getField(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getField as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getField without error using callback', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.GetFieldRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.admin.v1.Field() + ); + client.innerApiCalls.getField = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getField( + request, + ( + err?: Error | null, + result?: protos.google.firestore.admin.v1.IField | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getField as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getField with error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.GetFieldRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getField = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getField(request), expectedError); + assert( + (client.innerApiCalls.getField as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('createIndex', () => { + it('invokes createIndex without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.CreateIndexRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createIndex = stubLongRunningCall(expectedResponse); + const [operation] = await client.createIndex(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createIndex as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createIndex without error using callback', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.CreateIndexRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createIndex = stubLongRunningCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createIndex( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IIndexOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IIndexOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createIndex as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createIndex with call error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.CreateIndexRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createIndex = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.createIndex(request), expectedError); + assert( + (client.innerApiCalls.createIndex as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createIndex with LRO error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.CreateIndexRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createIndex = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.createIndex(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.createIndex as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes checkCreateIndexProgress without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateIndexProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateIndexProgress with error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.checkCreateIndexProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateField', () => { + it('invokes updateField without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.UpdateFieldRequest() + ); + request.field = {}; + request.field.name = ''; + const expectedHeaderRequestParams = 'field.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateField = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateField(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateField as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateField without error using callback', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.UpdateFieldRequest() + ); + request.field = {}; + request.field.name = ''; + const expectedHeaderRequestParams = 'field.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateField = stubLongRunningCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.updateField( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IFieldOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IFieldOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateField as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes updateField with call error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.UpdateFieldRequest() + ); + request.field = {}; + request.field.name = ''; + const expectedHeaderRequestParams = 'field.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateField = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.updateField(request), expectedError); + assert( + (client.innerApiCalls.updateField as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateField with LRO error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.UpdateFieldRequest() + ); + request.field = {}; + request.field.name = ''; + const expectedHeaderRequestParams = 'field.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateField = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.updateField(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.updateField as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes checkUpdateFieldProgress without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateFieldProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateFieldProgress with error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.checkUpdateFieldProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('exportDocuments', () => { + it('invokes exportDocuments without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ExportDocumentsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.exportDocuments = stubLongRunningCall( + expectedResponse + ); + const [operation] = await client.exportDocuments(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes exportDocuments without error using callback', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ExportDocumentsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.exportDocuments = stubLongRunningCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.exportDocuments( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.firestore.admin.v1.IExportDocumentsResponse, + protos.google.firestore.admin.v1.IExportDocumentsMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.firestore.admin.v1.IExportDocumentsResponse, + protos.google.firestore.admin.v1.IExportDocumentsMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes exportDocuments with call error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ExportDocumentsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.exportDocuments = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.exportDocuments(request), expectedError); + assert( + (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes exportDocuments with LRO error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ExportDocumentsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.exportDocuments = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.exportDocuments(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes checkExportDocumentsProgress without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkExportDocumentsProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkExportDocumentsProgress with error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkExportDocumentsProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('importDocuments', () => { + it('invokes importDocuments without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ImportDocumentsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importDocuments = stubLongRunningCall( + expectedResponse + ); + const [operation] = await client.importDocuments(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes importDocuments without error using callback', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ImportDocumentsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importDocuments = stubLongRunningCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.importDocuments( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IImportDocumentsMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IImportDocumentsMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes importDocuments with call error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ImportDocumentsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importDocuments = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.importDocuments(request), expectedError); + assert( + (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes importDocuments with LRO error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ImportDocumentsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importDocuments = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.importDocuments(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes checkImportDocumentsProgress without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportDocumentsProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportDocumentsProgress with error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkImportDocumentsProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listIndexes', () => { + it('invokes listIndexes without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ListIndexesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + ]; + client.innerApiCalls.listIndexes = stubSimpleCall(expectedResponse); + const [response] = await client.listIndexes(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listIndexes as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listIndexes without error using callback', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ListIndexesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + ]; + client.innerApiCalls.listIndexes = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listIndexes( + request, + ( + err?: Error | null, + result?: protos.google.firestore.admin.v1.IIndex[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listIndexes as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listIndexes with error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ListIndexesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listIndexes = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listIndexes(request), expectedError); + assert( + (client.innerApiCalls.listIndexes as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listIndexesStream without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ListIndexesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + ]; + client.descriptors.page.listIndexes.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listIndexesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.admin.v1.Index[] = []; + stream.on( + 'data', + (response: protos.google.firestore.admin.v1.Index) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listIndexes, request) + ); + assert.strictEqual( + (client.descriptors.page.listIndexes.createStream as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listIndexesStream with error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ListIndexesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listIndexes.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listIndexesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.admin.v1.Index[] = []; + stream.on( + 'data', + (response: protos.google.firestore.admin.v1.Index) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listIndexes, request) + ); + assert.strictEqual( + (client.descriptors.page.listIndexes.createStream as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listIndexes without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ListIndexesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + ]; + client.descriptors.page.listIndexes.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.firestore.admin.v1.IIndex[] = []; + const iterable = client.listIndexesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub).getCall( + 0 + ).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listIndexes with error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ListIndexesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listIndexes.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listIndexesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.firestore.admin.v1.IIndex[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub).getCall( + 0 + ).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listFields', () => { + it('invokes listFields without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ListFieldsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + ]; + client.innerApiCalls.listFields = stubSimpleCall(expectedResponse); + const [response] = await client.listFields(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listFields as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listFields without error using callback', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ListFieldsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + ]; + client.innerApiCalls.listFields = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listFields( + request, + ( + err?: Error | null, + result?: protos.google.firestore.admin.v1.IField[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listFields as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listFields with error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ListFieldsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listFields = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listFields(request), expectedError); + assert( + (client.innerApiCalls.listFields as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listFieldsStream without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ListFieldsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + ]; + client.descriptors.page.listFields.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listFieldsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.admin.v1.Field[] = []; + stream.on( + 'data', + (response: protos.google.firestore.admin.v1.Field) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listFields.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listFields, request) + ); + assert.strictEqual( + (client.descriptors.page.listFields.createStream as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listFieldsStream with error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ListFieldsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listFields.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listFieldsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.admin.v1.Field[] = []; + stream.on( + 'data', + (response: protos.google.firestore.admin.v1.Field) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listFields.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listFields, request) + ); + assert.strictEqual( + (client.descriptors.page.listFields.createStream as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listFields without error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ListFieldsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + ]; + client.descriptors.page.listFields.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.firestore.admin.v1.IField[] = []; + const iterable = client.listFieldsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listFields.asyncIterate as SinonStub).getCall( + 0 + ).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listFields.asyncIterate as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listFields with error', async () => { + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.admin.v1.ListFieldsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listFields.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listFieldsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.firestore.admin.v1.IField[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listFields.asyncIterate as SinonStub).getCall( + 0 + ).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listFields.asyncIterate as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + describe('collectionGroup', () => { + const fakePath = '/rendered/path/collectionGroup'; + const expectedParameters = { + project: 'projectValue', + database: 'databaseValue', + collection: 'collectionValue', + }; + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.collectionGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.collectionGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('collectionGroupPath', () => { + const result = client.collectionGroupPath( + 'projectValue', + 'databaseValue', + 'collectionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.collectionGroupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCollectionGroupName', () => { + const result = client.matchProjectFromCollectionGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.collectionGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchDatabaseFromCollectionGroupName', () => { + const result = client.matchDatabaseFromCollectionGroupName(fakePath); + assert.strictEqual(result, 'databaseValue'); + assert( + (client.pathTemplates.collectionGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCollectionFromCollectionGroupName', () => { + const result = client.matchCollectionFromCollectionGroupName(fakePath); + assert.strictEqual(result, 'collectionValue'); + assert( + (client.pathTemplates.collectionGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('database', () => { + const fakePath = '/rendered/path/database'; + const expectedParameters = { + project: 'projectValue', + database: 'databaseValue', + }; + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.databasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.databasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('databasePath', () => { + const result = client.databasePath('projectValue', 'databaseValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.databasePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromDatabaseName', () => { + const result = client.matchProjectFromDatabaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.databasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchDatabaseFromDatabaseName', () => { + const result = client.matchDatabaseFromDatabaseName(fakePath); + assert.strictEqual(result, 'databaseValue'); + assert( + (client.pathTemplates.databasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('field', () => { + const fakePath = '/rendered/path/field'; + const expectedParameters = { + project: 'projectValue', + database: 'databaseValue', + collection: 'collectionValue', + field: 'fieldValue', + }; + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.fieldPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.fieldPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('fieldPath', () => { + const result = client.fieldPath( + 'projectValue', + 'databaseValue', + 'collectionValue', + 'fieldValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.fieldPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromFieldName', () => { + const result = client.matchProjectFromFieldName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.fieldPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchDatabaseFromFieldName', () => { + const result = client.matchDatabaseFromFieldName(fakePath); + assert.strictEqual(result, 'databaseValue'); + assert( + (client.pathTemplates.fieldPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCollectionFromFieldName', () => { + const result = client.matchCollectionFromFieldName(fakePath); + assert.strictEqual(result, 'collectionValue'); + assert( + (client.pathTemplates.fieldPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchFieldFromFieldName', () => { + const result = client.matchFieldFromFieldName(fakePath); + assert.strictEqual(result, 'fieldValue'); + assert( + (client.pathTemplates.fieldPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('index', () => { + const fakePath = '/rendered/path/index'; + const expectedParameters = { + project: 'projectValue', + database: 'databaseValue', + collection: 'collectionValue', + index: 'indexValue', + }; + const client = new firestoreadminModule.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.indexPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.indexPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('indexPath', () => { + const result = client.indexPath( + 'projectValue', + 'databaseValue', + 'collectionValue', + 'indexValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.indexPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromIndexName', () => { + const result = client.matchProjectFromIndexName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.indexPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchDatabaseFromIndexName', () => { + const result = client.matchDatabaseFromIndexName(fakePath); + assert.strictEqual(result, 'databaseValue'); + assert( + (client.pathTemplates.indexPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCollectionFromIndexName', () => { + const result = client.matchCollectionFromIndexName(fakePath); + assert.strictEqual(result, 'collectionValue'); + assert( + (client.pathTemplates.indexPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchIndexFromIndexName', () => { + const result = client.matchIndexFromIndexName(fakePath); + assert.strictEqual(result, 'indexValue'); + assert( + (client.pathTemplates.indexPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/dev/test/gapic_firestore_v1.ts b/dev/test/gapic_firestore_v1.ts new file mode 100644 index 000000000..a0791a441 --- /dev/null +++ b/dev/test/gapic_firestore_v1.ts @@ -0,0 +1,2311 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/firestore_v1_proto_api'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as firestoreModule from '../src/v1'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message).toObject( + instance as protobuf.Message, + {defaults: true} + ); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubServerStreamingCall( + response?: ResponseType, + error?: Error +) { + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // write something to the stream to trigger transformStub and send the response back to the client + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + return sinon.stub().returns(mockStream); +} + +function stubBidiStreamingCall( + response?: ResponseType, + error?: Error +) { + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + return sinon.stub().returns(mockStream); +} + +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); + } + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.FirestoreClient', () => { + it('has servicePath', () => { + const servicePath = firestoreModule.FirestoreClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = firestoreModule.FirestoreClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = firestoreModule.FirestoreClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new firestoreModule.FirestoreClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new firestoreModule.FirestoreClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.firestoreStub, undefined); + await client.initialize(); + assert(client.firestoreStub); + }); + + it('has close method', () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('getDocument', () => { + it('invokes getDocument without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.GetDocumentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.Document() + ); + client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); + const [response] = await client.getDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getDocument without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.GetDocumentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.Document() + ); + client.innerApiCalls.getDocument = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getDocument( + request, + ( + err?: Error | null, + result?: protos.google.firestore.v1.IDocument | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getDocument with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.GetDocumentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getDocument = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getDocument(request), expectedError); + assert( + (client.innerApiCalls.getDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('updateDocument', () => { + it('invokes updateDocument without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.UpdateDocumentRequest() + ); + request.document = {}; + request.document.name = ''; + const expectedHeaderRequestParams = 'document.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.Document() + ); + client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); + const [response] = await client.updateDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateDocument without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.UpdateDocumentRequest() + ); + request.document = {}; + request.document.name = ''; + const expectedHeaderRequestParams = 'document.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.Document() + ); + client.innerApiCalls.updateDocument = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.updateDocument( + request, + ( + err?: Error | null, + result?: protos.google.firestore.v1.IDocument | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes updateDocument with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.UpdateDocumentRequest() + ); + request.document = {}; + request.document.name = ''; + const expectedHeaderRequestParams = 'document.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDocument = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateDocument(request), expectedError); + assert( + (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('deleteDocument', () => { + it('invokes deleteDocument without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.DeleteDocumentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteDocument without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.DeleteDocumentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocument = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deleteDocument( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes deleteDocument with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.DeleteDocumentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDocument = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteDocument(request), expectedError); + assert( + (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('beginTransaction', () => { + it('invokes beginTransaction without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.BeginTransactionRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.BeginTransactionResponse() + ); + client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); + const [response] = await client.beginTransaction(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes beginTransaction without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.BeginTransactionRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.BeginTransactionResponse() + ); + client.innerApiCalls.beginTransaction = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.beginTransaction( + request, + ( + err?: Error | null, + result?: protos.google.firestore.v1.IBeginTransactionResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes beginTransaction with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.BeginTransactionRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.beginTransaction = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.beginTransaction(request), expectedError); + assert( + (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('commit', () => { + it('invokes commit without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.CommitRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.CommitResponse() + ); + client.innerApiCalls.commit = stubSimpleCall(expectedResponse); + const [response] = await client.commit(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.commit as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes commit without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.CommitRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.CommitResponse() + ); + client.innerApiCalls.commit = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.commit( + request, + ( + err?: Error | null, + result?: protos.google.firestore.v1.ICommitResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.commit as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes commit with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.CommitRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.commit(request), expectedError); + assert( + (client.innerApiCalls.commit as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('rollback', () => { + it('invokes rollback without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.RollbackRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); + const [response] = await client.rollback(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.rollback as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes rollback without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.RollbackRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.rollback = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.rollback( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.rollback as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes rollback with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.RollbackRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.rollback(request), expectedError); + assert( + (client.innerApiCalls.rollback as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('batchWrite', () => { + it('invokes batchWrite without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.BatchWriteRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.BatchWriteResponse() + ); + client.innerApiCalls.batchWrite = stubSimpleCall(expectedResponse); + const [response] = await client.batchWrite(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes batchWrite without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.BatchWriteRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.BatchWriteResponse() + ); + client.innerApiCalls.batchWrite = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.batchWrite( + request, + ( + err?: Error | null, + result?: protos.google.firestore.v1.IBatchWriteResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes batchWrite with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.BatchWriteRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchWrite = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.batchWrite(request), expectedError); + assert( + (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('createDocument', () => { + it('invokes createDocument without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.CreateDocumentRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.Document() + ); + client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); + const [response] = await client.createDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createDocument without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.CreateDocumentRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.Document() + ); + client.innerApiCalls.createDocument = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createDocument( + request, + ( + err?: Error | null, + result?: protos.google.firestore.v1.IDocument | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createDocument with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.CreateDocumentRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createDocument = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createDocument(request), expectedError); + assert( + (client.innerApiCalls.createDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('batchGetDocuments', () => { + it('invokes batchGetDocuments without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.BatchGetDocumentsRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.BatchGetDocumentsResponse() + ); + client.innerApiCalls.batchGetDocuments = stubServerStreamingCall( + expectedResponse + ); + const stream = client.batchGetDocuments(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.firestore.v1.BatchGetDocumentsResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions) + ); + }); + + it('invokes batchGetDocuments with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.BatchGetDocumentsRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchGetDocuments = stubServerStreamingCall( + undefined, + expectedError + ); + const stream = client.batchGetDocuments(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.firestore.v1.BatchGetDocumentsResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions) + ); + }); + }); + + describe('runQuery', () => { + it('invokes runQuery without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.RunQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.RunQueryResponse() + ); + client.innerApiCalls.runQuery = stubServerStreamingCall(expectedResponse); + const stream = client.runQuery(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.firestore.v1.RunQueryResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.runQuery as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions) + ); + }); + + it('invokes runQuery with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.RunQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.runQuery = stubServerStreamingCall( + undefined, + expectedError + ); + const stream = client.runQuery(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.firestore.v1.RunQueryResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.runQuery as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions) + ); + }); + }); + + describe('write', () => { + it('invokes write without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.WriteRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.WriteResponse() + ); + client.innerApiCalls.write = stubBidiStreamingCall(expectedResponse); + const stream = client.write(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.firestore.v1.WriteResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.write as SinonStub) + .getCall(0) + .calledWithExactly({}, undefined) + ); + assert.deepStrictEqual( + (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( + 0 + ).args[0], + request + ); + }); + + it('invokes write with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.WriteRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedError = new Error('expected'); + client.innerApiCalls.write = stubBidiStreamingCall( + undefined, + expectedError + ); + const stream = client.write(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.firestore.v1.WriteResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.write as SinonStub) + .getCall(0) + .calledWithExactly({}, undefined) + ); + assert.deepStrictEqual( + (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( + 0 + ).args[0], + request + ); + }); + }); + + describe('listen', () => { + it('invokes listen without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.ListenRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.ListenResponse() + ); + client.innerApiCalls.listen = stubBidiStreamingCall(expectedResponse); + const stream = client.listen(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.firestore.v1.ListenResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listen as SinonStub) + .getCall(0) + .calledWithExactly({}, undefined) + ); + assert.deepStrictEqual( + (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( + 0 + ).args[0], + request + ); + }); + + it('invokes listen with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.ListenRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedError = new Error('expected'); + client.innerApiCalls.listen = stubBidiStreamingCall( + undefined, + expectedError + ); + const stream = client.listen(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.firestore.v1.ListenResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.listen as SinonStub) + .getCall(0) + .calledWithExactly({}, undefined) + ); + assert.deepStrictEqual( + (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( + 0 + ).args[0], + request + ); + }); + }); + + describe('listDocuments', () => { + it('invokes listDocuments without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.ListDocumentsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1.Document()), + generateSampleMessage(new protos.google.firestore.v1.Document()), + generateSampleMessage(new protos.google.firestore.v1.Document()), + ]; + client.innerApiCalls.listDocuments = stubSimpleCall(expectedResponse); + const [response] = await client.listDocuments(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listDocuments without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.ListDocumentsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1.Document()), + generateSampleMessage(new protos.google.firestore.v1.Document()), + generateSampleMessage(new protos.google.firestore.v1.Document()), + ]; + client.innerApiCalls.listDocuments = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listDocuments( + request, + ( + err?: Error | null, + result?: protos.google.firestore.v1.IDocument[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listDocuments with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.ListDocumentsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listDocuments = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listDocuments(request), expectedError); + assert( + (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listDocumentsStream without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.ListDocumentsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1.Document()), + generateSampleMessage(new protos.google.firestore.v1.Document()), + generateSampleMessage(new protos.google.firestore.v1.Document()), + ]; + client.descriptors.page.listDocuments.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listDocumentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.v1.Document[] = []; + stream.on('data', (response: protos.google.firestore.v1.Document) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDocuments, request) + ); + assert.strictEqual( + (client.descriptors.page.listDocuments + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes listDocumentsStream with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.ListDocumentsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listDocuments.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listDocumentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.v1.Document[] = []; + stream.on('data', (response: protos.google.firestore.v1.Document) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDocuments, request) + ); + assert.strictEqual( + (client.descriptors.page.listDocuments + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listDocuments without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.ListDocumentsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1.Document()), + generateSampleMessage(new protos.google.firestore.v1.Document()), + generateSampleMessage(new protos.google.firestore.v1.Document()), + ]; + client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.firestore.v1.IDocument[] = []; + const iterable = client.listDocumentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listDocuments + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listDocuments + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listDocuments with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.ListDocumentsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listDocumentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.firestore.v1.IDocument[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listDocuments + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listDocuments + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); + + describe('partitionQuery', () => { + it('invokes partitionQuery without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.PartitionQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + ]; + client.innerApiCalls.partitionQuery = stubSimpleCall(expectedResponse); + const [response] = await client.partitionQuery(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes partitionQuery without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.PartitionQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + ]; + client.innerApiCalls.partitionQuery = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.partitionQuery( + request, + ( + err?: Error | null, + result?: protos.google.firestore.v1.ICursor[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes partitionQuery with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.PartitionQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.partitionQuery = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.partitionQuery(request), expectedError); + assert( + (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes partitionQueryStream without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.PartitionQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + ]; + client.descriptors.page.partitionQuery.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.partitionQueryStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.v1.Cursor[] = []; + stream.on('data', (response: protos.google.firestore.v1.Cursor) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.partitionQuery, request) + ); + assert.strictEqual( + (client.descriptors.page.partitionQuery + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes partitionQueryStream with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.PartitionQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.partitionQuery.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.partitionQueryStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.v1.Cursor[] = []; + stream.on('data', (response: protos.google.firestore.v1.Cursor) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.partitionQuery, request) + ); + assert.strictEqual( + (client.descriptors.page.partitionQuery + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with partitionQuery without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.PartitionQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + ]; + client.descriptors.page.partitionQuery.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.firestore.v1.ICursor[] = []; + const iterable = client.partitionQueryAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.partitionQuery + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.partitionQuery + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with partitionQuery with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.PartitionQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.partitionQuery.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.partitionQueryAsync(request); + await assert.rejects(async () => { + const responses: protos.google.firestore.v1.ICursor[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.partitionQuery + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.partitionQuery + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); + + describe('listCollectionIds', () => { + it('invokes listCollectionIds without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.ListCollectionIdsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.listCollectionIds = stubSimpleCall(expectedResponse); + const [response] = await client.listCollectionIds(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listCollectionIds without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.ListCollectionIdsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.listCollectionIds = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listCollectionIds( + request, + (err?: Error | null, result?: string[] | null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listCollectionIds with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.ListCollectionIdsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listCollectionIds = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listCollectionIds(request), expectedError); + assert( + (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listCollectionIdsStream without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.ListCollectionIdsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [new String(), new String(), new String()]; + client.descriptors.page.listCollectionIds.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listCollectionIdsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: string[] = []; + stream.on('data', (response: string) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCollectionIds, request) + ); + assert.strictEqual( + (client.descriptors.page.listCollectionIds + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes listCollectionIdsStream with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.ListCollectionIdsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listCollectionIds.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listCollectionIdsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: string[] = []; + stream.on('data', (response: string) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCollectionIds, request) + ); + assert.strictEqual( + (client.descriptors.page.listCollectionIds + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCollectionIds without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.ListCollectionIdsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [new String(), new String(), new String()]; + client.descriptors.page.listCollectionIds.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: string[] = []; + const iterable = client.listCollectionIdsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCollectionIds + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listCollectionIds + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCollectionIds with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1.ListCollectionIdsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listCollectionIds.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listCollectionIdsAsync(request); + await assert.rejects(async () => { + const responses: string[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCollectionIds + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listCollectionIds + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); +}); diff --git a/dev/test/gapic_firestore_v1beta1.ts b/dev/test/gapic_firestore_v1beta1.ts new file mode 100644 index 000000000..3b762c5e7 --- /dev/null +++ b/dev/test/gapic_firestore_v1beta1.ts @@ -0,0 +1,1925 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/firestore_v1beta1_proto_api'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as firestoreModule from '../src/v1beta1'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message).toObject( + instance as protobuf.Message, + {defaults: true} + ); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubServerStreamingCall( + response?: ResponseType, + error?: Error +) { + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // write something to the stream to trigger transformStub and send the response back to the client + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + return sinon.stub().returns(mockStream); +} + +function stubBidiStreamingCall( + response?: ResponseType, + error?: Error +) { + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + return sinon.stub().returns(mockStream); +} + +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); + } + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1beta1.FirestoreClient', () => { + it('has servicePath', () => { + const servicePath = firestoreModule.FirestoreClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = firestoreModule.FirestoreClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = firestoreModule.FirestoreClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new firestoreModule.FirestoreClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new firestoreModule.FirestoreClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.firestoreStub, undefined); + await client.initialize(); + assert(client.firestoreStub); + }); + + it('has close method', () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('getDocument', () => { + it('invokes getDocument without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.GetDocumentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.Document() + ); + client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); + const [response] = await client.getDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getDocument without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.GetDocumentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.Document() + ); + client.innerApiCalls.getDocument = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getDocument( + request, + ( + err?: Error | null, + result?: protos.google.firestore.v1beta1.IDocument | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getDocument with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.GetDocumentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getDocument = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getDocument(request), expectedError); + assert( + (client.innerApiCalls.getDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('createDocument', () => { + it('invokes createDocument without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.CreateDocumentRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.Document() + ); + client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); + const [response] = await client.createDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createDocument without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.CreateDocumentRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.Document() + ); + client.innerApiCalls.createDocument = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createDocument( + request, + ( + err?: Error | null, + result?: protos.google.firestore.v1beta1.IDocument | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createDocument with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.CreateDocumentRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createDocument = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createDocument(request), expectedError); + assert( + (client.innerApiCalls.createDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('updateDocument', () => { + it('invokes updateDocument without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.UpdateDocumentRequest() + ); + request.document = {}; + request.document.name = ''; + const expectedHeaderRequestParams = 'document.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.Document() + ); + client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); + const [response] = await client.updateDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateDocument without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.UpdateDocumentRequest() + ); + request.document = {}; + request.document.name = ''; + const expectedHeaderRequestParams = 'document.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.Document() + ); + client.innerApiCalls.updateDocument = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.updateDocument( + request, + ( + err?: Error | null, + result?: protos.google.firestore.v1beta1.IDocument | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes updateDocument with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.UpdateDocumentRequest() + ); + request.document = {}; + request.document.name = ''; + const expectedHeaderRequestParams = 'document.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDocument = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateDocument(request), expectedError); + assert( + (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('deleteDocument', () => { + it('invokes deleteDocument without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.DeleteDocumentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteDocument without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.DeleteDocumentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocument = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deleteDocument( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes deleteDocument with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.DeleteDocumentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDocument = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteDocument(request), expectedError); + assert( + (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('beginTransaction', () => { + it('invokes beginTransaction without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.BeginTransactionRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.BeginTransactionResponse() + ); + client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); + const [response] = await client.beginTransaction(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes beginTransaction without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.BeginTransactionRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.BeginTransactionResponse() + ); + client.innerApiCalls.beginTransaction = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.beginTransaction( + request, + ( + err?: Error | null, + result?: protos.google.firestore.v1beta1.IBeginTransactionResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes beginTransaction with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.BeginTransactionRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.beginTransaction = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.beginTransaction(request), expectedError); + assert( + (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('commit', () => { + it('invokes commit without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.CommitRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.CommitResponse() + ); + client.innerApiCalls.commit = stubSimpleCall(expectedResponse); + const [response] = await client.commit(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.commit as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes commit without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.CommitRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.CommitResponse() + ); + client.innerApiCalls.commit = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.commit( + request, + ( + err?: Error | null, + result?: protos.google.firestore.v1beta1.ICommitResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.commit as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes commit with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.CommitRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.commit(request), expectedError); + assert( + (client.innerApiCalls.commit as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('rollback', () => { + it('invokes rollback without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.RollbackRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); + const [response] = await client.rollback(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.rollback as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes rollback without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.RollbackRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.rollback = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.rollback( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.rollback as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes rollback with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.RollbackRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.rollback(request), expectedError); + assert( + (client.innerApiCalls.rollback as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('batchGetDocuments', () => { + it('invokes batchGetDocuments without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.BatchGetDocumentsRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.BatchGetDocumentsResponse() + ); + client.innerApiCalls.batchGetDocuments = stubServerStreamingCall( + expectedResponse + ); + const stream = client.batchGetDocuments(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.firestore.v1beta1.BatchGetDocumentsResponse + ) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions) + ); + }); + + it('invokes batchGetDocuments with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.BatchGetDocumentsRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchGetDocuments = stubServerStreamingCall( + undefined, + expectedError + ); + const stream = client.batchGetDocuments(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.firestore.v1beta1.BatchGetDocumentsResponse + ) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions) + ); + }); + }); + + describe('runQuery', () => { + it('invokes runQuery without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.RunQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.RunQueryResponse() + ); + client.innerApiCalls.runQuery = stubServerStreamingCall(expectedResponse); + const stream = client.runQuery(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.firestore.v1beta1.RunQueryResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.runQuery as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions) + ); + }); + + it('invokes runQuery with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.RunQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.runQuery = stubServerStreamingCall( + undefined, + expectedError + ); + const stream = client.runQuery(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.firestore.v1beta1.RunQueryResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.runQuery as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions) + ); + }); + }); + + describe('write', () => { + it('invokes write without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.WriteRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.WriteResponse() + ); + client.innerApiCalls.write = stubBidiStreamingCall(expectedResponse); + const stream = client.write(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.firestore.v1beta1.WriteResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.write as SinonStub) + .getCall(0) + .calledWithExactly({}, undefined) + ); + assert.deepStrictEqual( + (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( + 0 + ).args[0], + request + ); + }); + + it('invokes write with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.WriteRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedError = new Error('expected'); + client.innerApiCalls.write = stubBidiStreamingCall( + undefined, + expectedError + ); + const stream = client.write(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.firestore.v1beta1.WriteResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.write as SinonStub) + .getCall(0) + .calledWithExactly({}, undefined) + ); + assert.deepStrictEqual( + (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( + 0 + ).args[0], + request + ); + }); + }); + + describe('listen', () => { + it('invokes listen without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.ListenRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.ListenResponse() + ); + client.innerApiCalls.listen = stubBidiStreamingCall(expectedResponse); + const stream = client.listen(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.firestore.v1beta1.ListenResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listen as SinonStub) + .getCall(0) + .calledWithExactly({}, undefined) + ); + assert.deepStrictEqual( + (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( + 0 + ).args[0], + request + ); + }); + + it('invokes listen with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.ListenRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedError = new Error('expected'); + client.innerApiCalls.listen = stubBidiStreamingCall( + undefined, + expectedError + ); + const stream = client.listen(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.firestore.v1beta1.ListenResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.listen as SinonStub) + .getCall(0) + .calledWithExactly({}, undefined) + ); + assert.deepStrictEqual( + (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( + 0 + ).args[0], + request + ); + }); + }); + + describe('listDocuments', () => { + it('invokes listDocuments without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.ListDocumentsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + ]; + client.innerApiCalls.listDocuments = stubSimpleCall(expectedResponse); + const [response] = await client.listDocuments(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listDocuments without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.ListDocumentsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + ]; + client.innerApiCalls.listDocuments = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listDocuments( + request, + ( + err?: Error | null, + result?: protos.google.firestore.v1beta1.IDocument[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listDocuments with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.ListDocumentsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listDocuments = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listDocuments(request), expectedError); + assert( + (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listDocumentsStream without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.ListDocumentsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + ]; + client.descriptors.page.listDocuments.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listDocumentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.v1beta1.Document[] = []; + stream.on( + 'data', + (response: protos.google.firestore.v1beta1.Document) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDocuments, request) + ); + assert.strictEqual( + (client.descriptors.page.listDocuments + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes listDocumentsStream with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.ListDocumentsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listDocuments.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listDocumentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.v1beta1.Document[] = []; + stream.on( + 'data', + (response: protos.google.firestore.v1beta1.Document) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDocuments, request) + ); + assert.strictEqual( + (client.descriptors.page.listDocuments + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listDocuments without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.ListDocumentsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + ]; + client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.firestore.v1beta1.IDocument[] = []; + const iterable = client.listDocumentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listDocuments + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listDocuments + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listDocuments with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.ListDocumentsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listDocumentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.firestore.v1beta1.IDocument[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listDocuments + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listDocuments + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); + + describe('listCollectionIds', () => { + it('invokes listCollectionIds without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.ListCollectionIdsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.listCollectionIds = stubSimpleCall(expectedResponse); + const [response] = await client.listCollectionIds(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listCollectionIds without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.ListCollectionIdsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.listCollectionIds = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listCollectionIds( + request, + (err?: Error | null, result?: string[] | null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listCollectionIds with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.ListCollectionIdsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listCollectionIds = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listCollectionIds(request), expectedError); + assert( + (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listCollectionIdsStream without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.ListCollectionIdsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [new String(), new String(), new String()]; + client.descriptors.page.listCollectionIds.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listCollectionIdsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: string[] = []; + stream.on('data', (response: string) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCollectionIds, request) + ); + assert.strictEqual( + (client.descriptors.page.listCollectionIds + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes listCollectionIdsStream with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.ListCollectionIdsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listCollectionIds.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listCollectionIdsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: string[] = []; + stream.on('data', (response: string) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCollectionIds, request) + ); + assert.strictEqual( + (client.descriptors.page.listCollectionIds + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCollectionIds without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.ListCollectionIdsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [new String(), new String(), new String()]; + client.descriptors.page.listCollectionIds.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: string[] = []; + const iterable = client.listCollectionIdsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCollectionIds + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listCollectionIds + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCollectionIds with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.ListCollectionIdsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listCollectionIds.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listCollectionIdsAsync(request); + await assert.rejects(async () => { + const responses: string[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCollectionIds + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listCollectionIds + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); +}); diff --git a/dev/test/ignore-undefined.ts b/dev/test/ignore-undefined.ts index 0b20f32d9..8f63f051e 100644 --- a/dev/test/ignore-undefined.ts +++ b/dev/test/ignore-undefined.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {describe, it} from 'mocha'; import {expect} from 'chai'; import {fieldFilters, orderBy, queryEquals, startAt} from './query'; import { diff --git a/dev/test/index.ts b/dev/test/index.ts index e4354214a..8687757ca 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {describe, it, beforeEach, before, afterEach, after} from 'mocha'; import {expect, use} from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; import * as extend from 'extend'; @@ -251,7 +252,7 @@ const allSupportedTypesInput = { { formattedName: DATABASE_ROOT, _getProjectId: () => ({projectId: PROJECT_ID, databaseId: '(default)'}), - } as any, // tslint:disable-line no-any + } as any, // eslint-disable-line @typescript-eslint/no-explicit-any new QualifiedResourcePath(PROJECT_ID, '(default)', 'collection', 'document') ), arrayValue: ['foo', 42, 'bar'], @@ -281,7 +282,7 @@ const allSupportedTypesOutput = { { formattedName: DATABASE_ROOT, _getProjectId: () => ({projectId: PROJECT_ID, databaseId: '(default)'}), - } as any, // tslint:disable-line no-any + } as any, // eslint-disable-line @typescript-eslint/no-explicit-any new QualifiedResourcePath(PROJECT_ID, '(default)', 'collection', 'document') ), arrayValue: ['foo', 42, 'bar'], @@ -301,10 +302,10 @@ describe('instantiation', () => { const firestore = new Firestore.Firestore(DEFAULT_SETTINGS); firestore.settings({foo: 'bar'}); - /* tslint:disable:no-any */ + /* eslint-disable @typescript-eslint/no-explicit-any */ expect((firestore as any)._settings.projectId).to.equal(PROJECT_ID); expect((firestore as any)._settings.foo).to.equal('bar'); - /* tslint:enable:no-any */ + /* eslint-enable @typescript-eslint/no-explicit-any */ }); it('can only call settings() once', () => { @@ -508,7 +509,7 @@ describe('instantiation', () => { const firestore = new Firestore.Firestore({projectId: 'foo'}); return expect(firestore.formattedName).to.equal( - `projects/foo/databases/(default)` + 'projects/foo/databases/(default)' ); }); @@ -522,7 +523,7 @@ describe('instantiation', () => { await firestore.initializeIfNeeded('tag'); expect(firestore.projectId).to.equal('foo'); expect(firestore.formattedName).to.equal( - `projects/foo/databases/(default)` + 'projects/foo/databases/(default)' ); }); }); @@ -905,10 +906,10 @@ describe('getAll() method', () => { result: DocumentSnapshot[], ...docs: api.IBatchGetDocumentsResponse[] ) { - expect(result.length).to.equal(arguments.length - 1); + expect(result.length).to.equal(docs.length); for (let i = 0; i < result.length; ++i) { - const doc = arguments[i + 1]; + const doc = docs[i]; if (doc.found) { expect(result[i].exists).to.be.true; diff --git a/dev/test/order.ts b/dev/test/order.ts index 58a5316b6..eeada46c2 100644 --- a/dev/test/order.ts +++ b/dev/test/order.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {describe, it, beforeEach, afterEach} from 'mocha'; import {expect} from 'chai'; import {google} from '../protos/firestore_v1_proto_api'; diff --git a/dev/test/path.ts b/dev/test/path.ts index e62eb8b58..805c50b6e 100644 --- a/dev/test/path.ts +++ b/dev/test/path.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {describe, it} from 'mocha'; import {expect} from 'chai'; import {FieldPath, QualifiedResourcePath} from '../src/path'; diff --git a/dev/test/pool.ts b/dev/test/pool.ts index 7538e67a0..7c50df9fe 100644 --- a/dev/test/pool.ts +++ b/dev/test/pool.ts @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {describe, it} from 'mocha'; import {expect, use} from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; -import {ClientPool} from '../src/pool'; +import {ClientPool, CLIENT_TERMINATED_ERROR_MSG} from '../src/pool'; import {Deferred} from '../src/util'; use(chaiAsPromised); @@ -324,7 +325,7 @@ describe('Client pool', () => { ); }) .catch((err: Error) => { - expect(err.message).to.equal('The client has already been terminated'); + expect(err.message).to.equal(CLIENT_TERMINATED_ERROR_MSG); }); }); diff --git a/dev/test/query.ts b/dev/test/query.ts index 1f2bb20e8..4045b95b2 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -12,13 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {DocumentData} from '@google-cloud/firestore'; + +import {describe, it, beforeEach, afterEach} from 'mocha'; import {expect, use} from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; import * as extend from 'extend'; -import {google} from '../protos/firestore_v1_proto_api'; +import {firestore, google} from '../protos/firestore_v1_proto_api'; import { - DocumentData, DocumentReference, FieldPath, FieldValue, @@ -83,10 +85,14 @@ export function fieldFilters( ): api.IStructuredQuery { const filters: api.StructuredQuery.IFilter[] = []; - for (let i = 0; i < arguments.length; i += 3) { - fieldPath = arguments[i]; - op = arguments[i + 1]; - value = arguments[i + 2]; + fieldPathOpAndValues = [fieldPath, op, value, ...fieldPathOpAndValues]; + + for (let i = 0; i < fieldPathOpAndValues.length; i += 3) { + fieldPath = fieldPathOpAndValues[i] as string; + op = fieldPathOpAndValues[ + i + 1 + ] as api.StructuredQuery.FieldFilter.Operator; + value = fieldPathOpAndValues[i + 2] as string | api.IValue; const filter: api.StructuredQuery.IFieldFilter = { field: { @@ -298,6 +304,36 @@ export function queryEquals( expect(actual).to.deep.eq(query); } +function bundledQueryEquals( + actual: firestore.IBundledQuery | undefined, + limitType: firestore.BundledQuery.LimitType | undefined, + ...protoComponents: api.IStructuredQuery[] +) { + expect(actual).to.not.be.undefined; + + const query: firestore.IBundledQuery = { + parent: DATABASE_ROOT + '/documents', + structuredQuery: { + from: [ + { + collectionId: 'collectionId', + }, + ], + }, + limitType, + }; + + for (const protoComponent of protoComponents) { + extend(true, query.structuredQuery, protoComponent); + } + + // 'extend' removes undefined fields in the request object. The backend + // ignores these fields, but we need to manually strip them before we compare + // the expected and the actual request. + actual = extend(true, {}, actual); + expect(actual).to.deep.eq(query); +} + export function result(documentId: string): api.IRunQueryResponse { return {document: document(documentId), readTime: {seconds: 5, nanos: 6}}; } @@ -396,14 +432,8 @@ describe('query interface', () => { queryEquals( [ - query - .orderBy('foo') - .orderBy('__name__') - .startAt('b', 'c'), - query - .orderBy('foo') - .orderBy('__name__') - .startAt('b', 'c'), + query.orderBy('foo').orderBy('__name__').startAt('b', 'c'), + query.orderBy('foo').orderBy('__name__').startAt('b', 'c'), ], [] ); @@ -457,7 +487,7 @@ describe('query interface', () => { it('retries on stream failure', () => { let attempts = 0; const overrides: ApiOverride = { - runQuery: request => { + runQuery: () => { ++attempts; throw new Error('Expected error'); }, @@ -637,33 +667,6 @@ describe('query interface', () => { }); }); - it('throws if QuerySnapshot.docChanges() is used as a property', () => { - const overrides: ApiOverride = { - runQuery: request => { - queryEquals(request); - return stream(result('first'), result('second')); - }, - }; - - return createInstance(overrides).then(firestore => { - const query = firestore.collection('collectionId'); - return query.get().then(snapshot => { - expect(() => { - (snapshot.docChanges as InvalidApiUsage).forEach(() => {}); - }).to.throw( - 'QuerySnapshot.docChanges has been changed from a property into a method' - ); - - expect(() => { - for (const doc of snapshot.docChanges as InvalidApiUsage) { - } - }).to.throw( - 'QuerySnapshot.docChanges has been changed from a property into a method' - ); - }); - }); - }); - it('for Query.withConverter()', async () => { const doc = document('documentId', 'author', 'author', 'title', 'post'); const overrides: ApiOverride = { @@ -923,7 +926,7 @@ describe('where() interface', () => { arrayValue: { values: [ { - stringValue: `bar`, + stringValue: 'bar', }, ], }, @@ -1224,10 +1227,7 @@ describe('orderBy() interface', () => { return snapshot('collectionId/doc', {foo: 'bar'}).then(snapshot => { expect(() => { - query = query - .orderBy('foo') - .startAt('foo') - .orderBy('foo'); + query = query.orderBy('foo').startAt('foo').orderBy('foo'); }).to.throw( 'Cannot specify an orderBy() constraint after calling startAt(), startAfter(), endBefore() or endAt().' ); @@ -1242,10 +1242,7 @@ describe('orderBy() interface', () => { ); expect(() => { - query = query - .orderBy('foo') - .endAt('foo') - .orderBy('foo'); + query = query.orderBy('foo').endAt('foo').orderBy('foo'); }).to.throw( 'Cannot specify an orderBy() constraint after calling startAt(), startAfter(), endBefore() or endAt().' ); @@ -1334,10 +1331,7 @@ describe('limit() interface', () => { return createInstance(overrides).then(firestore => { let query: Query = firestore.collection('collectionId'); - query = query - .limit(1) - .limit(2) - .limit(3); + query = query.limit(1).limit(2).limit(3); return query.get(); }); }); @@ -1442,13 +1436,77 @@ describe('limitToLast() interface', () => { }; return createInstance(overrides).then(firestore => { + let query: Query = firestore.collection('collectionId'); + query = query.orderBy('foo').limitToLast(1).limitToLast(2).limitToLast(3); + return query.get(); + }); + }); + + it('converts to bundled query without order reversing', () => { + return createInstance().then(firestore => { + let query: Query = firestore.collection('collectionId'); + query = query.orderBy('foo').limitToLast(10); + const bundledQuery = query._toBundledQuery(); + bundledQueryEquals( + bundledQuery, + 'LAST', + orderBy('foo', 'ASCENDING'), + limit(10) + ); + }); + }); + + it('converts to bundled query without cursor flipping', () => { + return createInstance().then(firestore => { let query: Query = firestore.collection('collectionId'); query = query .orderBy('foo') - .limitToLast(1) - .limitToLast(2) - .limitToLast(3); - return query.get(); + .startAt('start') + .endAt('end') + .limitToLast(10); + const bundledQuery = query._toBundledQuery(); + bundledQueryEquals( + bundledQuery, + 'LAST', + orderBy('foo', 'ASCENDING'), + limit(10), + startAt(true, 'start'), + endAt(false, 'end') + ); + }); + }); + + it('converts to bundled query without order reversing', () => { + return createInstance().then(firestore => { + let query: Query = firestore.collection('collectionId'); + query = query.orderBy('foo').limitToLast(10); + const bundledQuery = query._toBundledQuery(); + bundledQueryEquals( + bundledQuery, + 'LAST', + orderBy('foo', 'ASCENDING'), + limit(10) + ); + }); + }); + + it('converts to bundled query without cursor flipping', () => { + return createInstance().then(firestore => { + let query: Query = firestore.collection('collectionId'); + query = query + .orderBy('foo') + .startAt('start') + .endAt('end') + .limitToLast(10); + const bundledQuery = query._toBundledQuery(); + bundledQueryEquals( + bundledQuery, + 'LAST', + orderBy('foo', 'ASCENDING'), + limit(10), + startAt(true, 'start'), + endAt(false, 'end') + ); }); }); }); @@ -1496,10 +1554,7 @@ describe('offset() interface', () => { return createInstance(overrides).then(firestore => { let query: Query = firestore.collection('collectionId'); - query = query - .offset(1) - .offset(2) - .offset(3); + query = query.offset(1).offset(2).offset(3); return query.get(); }); }); @@ -1602,10 +1657,7 @@ describe('startAt() interface', () => { return createInstance(overrides).then(firestore => { let query: Query = firestore.collection('collectionId'); - query = query - .orderBy('foo') - .orderBy('bar') - .startAt('foo', 'bar'); + query = query.orderBy('foo').orderBy('bar').startAt('foo', 'bar'); return query.get(); }); }); @@ -1632,14 +1684,8 @@ describe('startAt() interface', () => { const query = firestore.collection('collectionId'); return Promise.all([ - query - .orderBy(FieldPath.documentId()) - .startAt(doc.id) - .get(), - query - .orderBy(FieldPath.documentId()) - .startAt(doc.ref) - .get(), + query.orderBy(FieldPath.documentId()).startAt(doc.id).get(), + query.orderBy(FieldPath.documentId()).startAt(doc.ref).get(), ]); }); }); @@ -1927,10 +1973,7 @@ describe('startAt() interface', () => { return createInstance(overrides).then(firestore => { let query: Query = firestore.collection('collectionId'); - query = query - .orderBy('foo') - .orderBy('bar') - .startAt('foo'); + query = query.orderBy('foo').orderBy('bar').startAt('foo'); return query.get(); }); }); @@ -1953,10 +1996,7 @@ describe('startAt() interface', () => { return createInstance(overrides).then(firestore => { let query: Query = firestore.collection('collectionId'); - query = query - .orderBy('foo') - .startAt('foo') - .startAt('bar'); + query = query.orderBy('foo').startAt('foo').startAt('bar'); return query.get(); }); }); @@ -1988,10 +2028,7 @@ describe('startAfter() interface', () => { return createInstance(overrides).then(firestore => { let query: Query = firestore.collection('collectionId'); - query = query - .orderBy('foo') - .orderBy('bar') - .startAfter('foo', 'bar'); + query = query.orderBy('foo').orderBy('bar').startAfter('foo', 'bar'); return query.get(); }); }); @@ -2018,10 +2055,7 @@ describe('startAfter() interface', () => { return createInstance(overrides).then(firestore => { let query: Query = firestore.collection('collectionId'); - query = query - .orderBy('foo') - .startAfter('foo') - .startAfter('bar'); + query = query.orderBy('foo').startAfter('foo').startAfter('bar'); return query.get(); }); }); @@ -2053,10 +2087,7 @@ describe('endAt() interface', () => { return createInstance(overrides).then(firestore => { let query: Query = firestore.collection('collectionId'); - query = query - .orderBy('foo') - .orderBy('bar') - .endAt('foo', 'bar'); + query = query.orderBy('foo').orderBy('bar').endAt('foo', 'bar'); return query.get(); }); }); @@ -2079,10 +2110,7 @@ describe('endAt() interface', () => { return createInstance(overrides).then(firestore => { let query: Query = firestore.collection('collectionId'); - query = query - .orderBy('foo') - .endAt('foo') - .endAt('bar'); + query = query.orderBy('foo').endAt('foo').endAt('bar'); return query.get(); }); }); @@ -2114,10 +2142,7 @@ describe('endBefore() interface', () => { return createInstance(overrides).then(firestore => { let query: Query = firestore.collection('collectionId'); - query = query - .orderBy('foo') - .orderBy('bar') - .endBefore('foo', 'bar'); + query = query.orderBy('foo').orderBy('bar').endBefore('foo', 'bar'); return query.get(); }); }); @@ -2140,10 +2165,7 @@ describe('endBefore() interface', () => { return createInstance(overrides).then(firestore => { let query: Query = firestore.collection('collectionId'); - query = query - .orderBy('foo') - .endBefore('foo') - .endBefore('bar'); + query = query.orderBy('foo').endBefore('foo').endBefore('bar'); return query.get(); }); }); diff --git a/dev/test/rate-limiter.ts b/dev/test/rate-limiter.ts index e3271303d..24061c5b0 100644 --- a/dev/test/rate-limiter.ts +++ b/dev/test/rate-limiter.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {describe, it, beforeEach} from 'mocha'; import {expect} from 'chai'; import {RateLimiter} from '../src/rate-limiter'; @@ -71,7 +72,7 @@ describe('RateLimiter', () => { expect(limiter.getNextRequestDelayMs(500, timestamp)).to.equal(0); // Should factor in remaining tokens when calculating the time. - expect(limiter.tryMakeRequest(250, timestamp)); + expect(limiter.tryMakeRequest(250, timestamp)).to.be.true; expect(limiter.getNextRequestDelayMs(500, timestamp)).to.equal(500); // Once tokens have been used, should calculate time before next request. diff --git a/dev/test/timestamp.ts b/dev/test/timestamp.ts index 59c7c6d4e..cb08df086 100644 --- a/dev/test/timestamp.ts +++ b/dev/test/timestamp.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {describe, it} from 'mocha'; import {expect} from 'chai'; import * as through2 from 'through2'; diff --git a/dev/test/transaction.ts b/dev/test/transaction.ts index 7a452cf4d..9e59137cb 100644 --- a/dev/test/transaction.ts +++ b/dev/test/transaction.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {describe, it} from 'mocha'; import {expect, use} from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; import * as extend from 'extend'; @@ -28,6 +29,9 @@ import { createInstance, InvalidApiUsage, response, + postConverter, + Post, + postConverterMerge, } from './util/helpers'; import api = proto.google.firestore.v1; @@ -841,6 +845,66 @@ describe('transaction operations', () => { ); }); + it('support set with partials and merge', () => { + const set = { + update: { + fields: { + title: { + stringValue: 'story', + }, + }, + name: DOCUMENT_NAME, + }, + updateMask: { + fieldPaths: ['title'], + }, + }; + + return runTransaction( + (transaction, docRef) => { + const postRef = docRef.withConverter(postConverterMerge); + transaction.set(postRef, {title: 'story'} as Partial, { + merge: true, + }); + return Promise.resolve(); + }, + begin(), + commit(undefined, [set]) + ); + }); + + it('support set with partials and mergeFields', () => { + const set = { + update: { + fields: { + title: { + stringValue: 'story', + }, + }, + name: DOCUMENT_NAME, + }, + updateMask: { + fieldPaths: ['title'], + }, + }; + + return runTransaction( + (transaction, docRef) => { + const postRef = docRef.withConverter(postConverter); + transaction.set( + postRef, + {title: 'story', author: 'person'} as Partial, + { + mergeFields: ['title'], + } + ); + return Promise.resolve(); + }, + begin(), + commit(undefined, [set]) + ); + }); + it('support delete', () => { const remove = { delete: DOCUMENT_NAME, diff --git a/dev/test/typescript.ts b/dev/test/typescript.ts deleted file mode 100644 index a73ea272d..000000000 --- a/dev/test/typescript.ts +++ /dev/null @@ -1,361 +0,0 @@ -// Copyright 2017 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 FirebaseFirestore from '../src'; - -import CollectionReference = FirebaseFirestore.CollectionReference; -import DocumentReference = FirebaseFirestore.DocumentReference; -import DocumentSnapshot = FirebaseFirestore.DocumentSnapshot; -import WriteBatch = FirebaseFirestore.WriteBatch; -import Transaction = FirebaseFirestore.Transaction; -import FieldPath = FirebaseFirestore.FieldPath; -import QuerySnapshot = FirebaseFirestore.QuerySnapshot; -import QueryDocumentSnapshot = FirebaseFirestore.QueryDocumentSnapshot; -import UpdateData = FirebaseFirestore.UpdateData; -import Query = FirebaseFirestore.Query; -import DocumentChange = FirebaseFirestore.DocumentChange; -import FieldValue = FirebaseFirestore.FieldValue; -import Firestore = FirebaseFirestore.Firestore; -import DocumentData = FirebaseFirestore.DocumentData; -import GeoPoint = FirebaseFirestore.GeoPoint; -import Precondition = FirebaseFirestore.Precondition; -import SetOptions = FirebaseFirestore.SetOptions; -import FirestoreDataConverter = FirebaseFirestore.FirestoreDataConverter; -import Timestamp = FirebaseFirestore.Timestamp; -import Settings = FirebaseFirestore.Settings; -import GrpcStatus = FirebaseFirestore.GrpcStatus; - -// This test verifies the Typescript typings and is not meant for execution. -xdescribe('firestore.d.ts', () => { - const firestore: Firestore = new Firestore({ - keyFilename: 'foo', - projectId: 'foo', - host: 'localhost', - ssl: false, - otherOption: 'foo', - } as Settings); - - const precondition: Precondition = {lastUpdateTime: Timestamp.now()}; - const setOptions: SetOptions = {merge: true}; - const fieldPath: FieldPath = new FieldPath('foo'); - const docRef: DocumentReference = firestore.doc('coll/doc'); - const collRef: CollectionReference = firestore.collection('coll'); - const updateData: UpdateData = {}; - const documentData: DocumentData = {}; - - const defaultConverter: FirestoreDataConverter = { - toFirestore(modelObject: DocumentData): DocumentData { - return modelObject; - }, - fromFirestore(data: DocumentData): DocumentData { - return data; - }, - }; - - FirebaseFirestore.setLogFunction(console.log); - - it('has typings for Firestore', () => { - firestore.settings({ - keyFilename: 'foo', - projectId: 'foo', - maxIdleChannels: 42, - otherOption: 'foo', - }); - const collRef: CollectionReference = firestore.collection('coll'); - const docRef1: DocumentReference = firestore.doc('coll/doc'); - const docRef2: DocumentReference = firestore.doc('coll/doc'); - const collectionGroup: Query = firestore.collectionGroup('collectionId'); - firestore.getAll(docRef1, docRef2).then((docs: DocumentSnapshot[]) => {}); - firestore - .getAll(docRef1, docRef2, {}) - .then((docs: DocumentSnapshot[]) => {}); - firestore - .getAll(docRef1, docRef2, {fieldMask: ['foo', new FieldPath('foo')]}) - .then((docs: DocumentSnapshot[]) => {}); - firestore - .listCollections() - .then((collections: CollectionReference[]) => {}); - const transactionResult: Promise = firestore.runTransaction( - (updateFunction: Transaction) => { - return Promise.resolve('string'); - } - ); - const batch: WriteBatch = firestore.batch(); - }); - - it('has typings for GeoPoint', () => { - const geoPoint: GeoPoint = new GeoPoint(90.0, 90.0); - const latitude: number = geoPoint.latitude; - const longitude: number = geoPoint.longitude; - const equals: boolean = geoPoint.isEqual(geoPoint); - }); - - it('has typings for Transaction', () => { - return firestore.runTransaction((transaction: Transaction) => { - transaction.get(collRef).then((snapshot: QuerySnapshot) => {}); - transaction.get(docRef).then((doc: DocumentSnapshot) => {}); - transaction.getAll(docRef, docRef).then((docs: DocumentSnapshot[]) => {}); - transaction = transaction.create(docRef, documentData); - transaction = transaction.set(docRef, documentData); - transaction = transaction.set(docRef, documentData, setOptions); - transaction = transaction.update(docRef, updateData); - transaction = transaction.update(docRef, updateData, precondition); - transaction = transaction.update(docRef, 'foo', 'bar'); - transaction = transaction.update(docRef, 'foo', 'bar', precondition); - transaction = transaction.update(docRef, new FieldPath('foo'), 'bar'); - transaction = transaction.update( - docRef, - new FieldPath('foo'), - 'bar', - precondition - ); - transaction = transaction.delete(docRef); - transaction = transaction.delete(docRef, precondition); - return Promise.resolve(); - }); - }); - - it('has typings for WriteBatch', () => { - let batch: WriteBatch = firestore.batch(); - batch = batch.create(docRef, documentData); - batch = batch.set(docRef, documentData); - batch = batch.set(docRef, documentData, setOptions); - batch = batch.update(docRef, updateData); - batch = batch.update(docRef, updateData, precondition); - batch = batch.update(docRef, 'foo', 'bar'); - batch = batch.update(docRef, 'foo', 'bar', precondition); - batch = batch.update(docRef, new FieldPath('foo'), 'bar'); - batch = batch.update(docRef, new FieldPath('foo'), 'bar', precondition); - batch = batch.delete(docRef); - batch = batch.delete(docRef, precondition); - batch.commit().then((result: FirebaseFirestore.WriteResult[]) => {}); - }); - - it('has typings for WriteResult', () => { - docRef.set(documentData).then((result: FirebaseFirestore.WriteResult) => { - const writeTime: Timestamp = result.writeTime; - const equals: boolean = result.isEqual(result); - }); - }); - - it('has typings for FieldPath', () => { - const path1: FieldPath = new FieldPath('a'); - const path2: FieldPath = new FieldPath('a', 'b'); - const path3: FieldPath = FieldPath.documentId(); - const equals: boolean = path1.isEqual(path2); - }); - - it('has typings for DocumentReference', () => { - const id: string = docRef.id; - const firestore: FirebaseFirestore.Firestore = docRef.firestore; - const parent: CollectionReference = docRef.parent; - const path: string = docRef.path; - const subcollection: CollectionReference = docRef.collection('coll'); - docRef.listCollections().then((collections: CollectionReference[]) => {}); - docRef.get().then((snapshot: DocumentSnapshot) => {}); - docRef.withConverter(defaultConverter); - docRef - .create(documentData) - .then((writeResult: FirebaseFirestore.WriteResult) => {}); - docRef - .set(documentData) - .then((writeResult: FirebaseFirestore.WriteResult) => {}); - docRef - .set(documentData, setOptions) - .then((writeResult: FirebaseFirestore.WriteResult) => {}); - docRef - .update(updateData) - .then((writeResult: FirebaseFirestore.WriteResult) => {}); - docRef - .update(updateData, precondition) - .then((writeResult: FirebaseFirestore.WriteResult) => {}); - docRef - .update('foo', 'bar') - .then((writeResult: FirebaseFirestore.WriteResult) => {}); - docRef - .update('foo', 'bar', precondition) - .then((writeResult: FirebaseFirestore.WriteResult) => {}); - docRef - .update(new FieldPath('foo'), 'bar') - .then((writeResult: FirebaseFirestore.WriteResult) => {}); - docRef - .update(new FieldPath('foo'), 'bar', precondition) - .then((writeResult: FirebaseFirestore.WriteResult) => {}); - docRef.delete().then((writeResult: FirebaseFirestore.WriteResult) => {}); - docRef - .delete(precondition) - .then((writeResult: FirebaseFirestore.WriteResult) => {}); - let unsubscribe: () => void = docRef.onSnapshot( - (snapshot: DocumentSnapshot) => {} - ); - unsubscribe = docRef.onSnapshot( - (snapshot: DocumentSnapshot) => {}, - (error: Error) => {} - ); - const equals: boolean = docRef.isEqual(docRef); - }); - - it('has typings for DocumentSnapshot', () => { - docRef.get().then((snapshot: DocumentSnapshot) => { - const exists: boolean = snapshot.exists; - const ref: DocumentReference = snapshot.ref; - const id: string = snapshot.id; - const readTime: Timestamp = snapshot.readTime; - const updateTime: Timestamp = snapshot.updateTime!; - const createTime: Timestamp = snapshot.createTime!; - const data: DocumentData = snapshot.data()!; - let value = snapshot.get('foo'); - value = snapshot.get(new FieldPath('foo')); - const equals: boolean = snapshot.isEqual(snapshot); - }); - }); - - it('has typings for QueryDocumentSnapshot', () => { - collRef.get().then((querySnapshot: QuerySnapshot) => { - const snapshot: QueryDocumentSnapshot = querySnapshot.docs[0]; - const exists: boolean = snapshot.exists; - const ref: DocumentReference = snapshot.ref; - const id: string = snapshot.id; - const readTime: Timestamp = snapshot.readTime; - const updateTime: Timestamp = snapshot.updateTime; - const createTime: Timestamp = snapshot.createTime; - const data: DocumentData = snapshot.data(); - let value = snapshot.get('foo'); - value = snapshot.get(new FieldPath('foo')); - const equals: boolean = snapshot.isEqual(snapshot); - }); - }); - - it('has typings for Query', () => { - let query: Query = collRef; - const firestore: FirebaseFirestore.Firestore = collRef.firestore; - docRef.get().then((snapshot: DocumentSnapshot) => { - query = query.where('foo', '<', 'bar'); - query = query.where('foo', '<=', 'bar'); - query = query.where('foo', '==', 'bar'); - query = query.where('foo', '>=', 'bar'); - query = query.where('foo', '>', 'bar'); - query = query.where('foo', 'array-contains', 'bar'); - query = query.where('foo', 'in', ['bar']); - query = query.where('foo', 'array-contains-any', ['bar']); - query = query.where(new FieldPath('foo'), '==', 'bar'); - query = query.orderBy('foo'); - query = query.orderBy('foo', 'asc'); - query = query.orderBy(new FieldPath('foo')); - query = query.orderBy(new FieldPath('foo'), 'desc'); - query = query.limit(42); - query = query.limitToLast(42); - query = query.offset(42); - query = query.select('foo'); - query = query.select('foo', 'bar'); - query = query.select(new FieldPath('foo')); - query = query.select(new FieldPath('foo'), new FieldPath('bar')); - query = query.startAt(snapshot); - query = query.startAt('foo'); - query = query.startAt('foo', 'bar'); - query = query.startAfter(snapshot); - query = query.startAfter('foo'); - query = query.startAfter('foo', 'bar'); - query = query.endAt(snapshot); - query = query.endAt('foo'); - query = query.endAt('foo', 'bar'); - query = query.endBefore(snapshot); - query = query.endBefore('foo'); - query = query.endBefore('foo', 'bar'); - query = query.withConverter(defaultConverter); - query.get().then((results: QuerySnapshot) => {}); - query.stream().on('data', () => {}); - let unsubscribe: () => void = query.onSnapshot( - (snapshot: QuerySnapshot) => {} - ); - unsubscribe = query.onSnapshot( - (snapshot: QuerySnapshot) => {}, - (error: Error) => {} - ); - const equals: boolean = query.isEqual(query); - }); - }); - - it('has typings for QuerySnapshot', () => { - collRef.get().then((snapshot: QuerySnapshot) => { - const query: Query = snapshot.query; - const docChanges: DocumentChange[] = snapshot.docChanges(); - const docs: QueryDocumentSnapshot[] = snapshot.docs; - const size: number = snapshot.size; - const empty: boolean = snapshot.empty; - const readTime: Timestamp = snapshot.readTime; - snapshot.forEach((result: QueryDocumentSnapshot) => {}); - snapshot.forEach((result: QueryDocumentSnapshot) => {}, {}); - const equals: boolean = snapshot.isEqual(snapshot); - }); - }); - - it('has typings for DocumentChange', () => { - collRef.get().then((snapshot: QuerySnapshot) => { - const docChange: DocumentChange = snapshot.docChanges()[0]; - const doc: QueryDocumentSnapshot = docChange.doc; - const oldIndex: number = docChange.oldIndex; - const newIndex: number = docChange.newIndex; - const equals: boolean = docChange.isEqual(docChange); - }); - }); - - it('has typings for CollectionReference', () => { - const firestore: Firestore = collRef.firestore; - const parent: DocumentReference | null = collRef.parent; - const path: string = collRef.path; - const id: string = collRef.id; - const docRef1: DocumentReference = collRef.doc(); - const docRef2: DocumentReference = collRef.doc('doc'); - collRef.add(documentData).then((docRef: DocumentReference) => {}); - collRef.withConverter(defaultConverter); - const list: Promise = collRef.listDocuments(); - const equals: boolean = collRef.isEqual(collRef); - }); - - it('has typings for FieldValue', () => { - const documentData: UpdateData = { - a: FieldValue.serverTimestamp(), - b: FieldValue.delete(), - c: FieldValue.arrayUnion('foo'), - d: FieldValue.arrayRemove('bar'), - e: FieldValue.increment(0), - }; - const serverTimestamp: FieldValue = FieldValue.serverTimestamp(); - const deleteField: FieldValue = FieldValue.delete(); - const arrayUnion: FieldValue = FieldValue.arrayUnion('foo', 'bar'); - const arrayRemove: FieldValue = FieldValue.arrayRemove('foo', 'bar'); - const equals: boolean = FieldValue.serverTimestamp().isEqual( - FieldValue.serverTimestamp() - ); - }); - - it('has typings for SetOptions', () => { - const merge: SetOptions = {merge: true}; - const mergeFields: SetOptions = {mergeFields: ['foo', fieldPath]}; - }); - - it('has typings for Timestamp', () => { - let timestamp: Timestamp = new Timestamp(0, 0); - timestamp = Timestamp.now(); - timestamp = Timestamp.fromDate(new Date()); - timestamp = Timestamp.fromMillis(0); - const seconds: number = timestamp.seconds; - const nanoseconds: number = timestamp.nanoseconds; - }); - - it('has typings for GrpcStatus', () => { - const status = GrpcStatus.ABORTED; - }); -}); diff --git a/dev/test/util.ts b/dev/test/util.ts index 805d2bd8b..c4687eef7 100644 --- a/dev/test/util.ts +++ b/dev/test/util.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {describe, it} from 'mocha'; import {expect} from 'chai'; import {isPlainObject} from '../src/util'; diff --git a/dev/test/util/helpers.ts b/dev/test/util/helpers.ts index 3786029a5..54678d7be 100644 --- a/dev/test/util/helpers.ts +++ b/dev/test/util/helpers.ts @@ -12,25 +12,25 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {DocumentData, Settings, SetOptions} from '@google-cloud/firestore'; + import {expect} from 'chai'; import * as extend from 'extend'; -import {GrpcClient} from 'google-gax'; -import {Duplex} from 'stream'; +import {grpc} from 'google-gax'; +import {JSONStreamIterator} from 'length-prefixed-json-stream'; +import {Duplex, PassThrough} from 'stream'; import * as through2 from 'through2'; +import {firestore} from '../../protos/firestore_v1_proto_api'; import * as proto from '../../protos/firestore_v1_proto_api'; -import {Firestore, Settings} from '../../src'; +import * as v1 from '../../src/v1'; +import {Firestore, QueryDocumentSnapshot} from '../../src'; import {ClientPool} from '../../src/pool'; -import {DocumentData, GapicClient} from '../../src/types'; +import {GapicClient} from '../../src/types'; import api = proto.google.firestore.v1; -const v1 = require('../../src/v1'); - -/* tslint:disable:no-any */ -const grpc = new GrpcClient({} as any).grpc; -const SSL_CREDENTIALS = (grpc.credentials as any).createInsecure(); -/* tslint:enable:no-any */ +const SSL_CREDENTIALS = grpc.credentials.createInsecure(); export const PROJECT_ID = 'test-project'; export const DATABASE_ROOT = `projects/${PROJECT_ID}/databases/(default)`; @@ -38,7 +38,7 @@ export const COLLECTION_ROOT = `${DATABASE_ROOT}/documents/collectionId`; export const DOCUMENT_NAME = `${COLLECTION_ROOT}/documentId`; // Allow invalid API usage to test error handling. -// tslint:disable-next-line:no-any +// eslint-disable-next-line @typescript-eslint/no-explicit-any export type InvalidApiUsage = any; /** Defines the request handlers used by Firestore. */ @@ -67,7 +67,11 @@ export function createInstance( firestore['_clientPool'] = new ClientPool( /* concurrentRequestLimit= */ 1, /* maxIdleClients= */ 0, - () => ({...new v1(initializationOptions), ...apiOverrides}) + () => + ({ + ...new v1.FirestoreClient(initializationOptions), + ...apiOverrides, + } as any) // eslint-disable-line @typescript-eslint/no-explicit-any ); return Promise.resolve(firestore); @@ -334,7 +338,39 @@ export const postConverter = { toFirestore(post: Post): DocumentData { return {title: post.title, author: post.author}; }, - fromFirestore(data: DocumentData): Post { + fromFirestore(snapshot: QueryDocumentSnapshot): Post { + const data = snapshot.data(); return new Post(data.title, data.author); }, }; + +export const postConverterMerge = { + toFirestore(post: Partial, options?: SetOptions): DocumentData { + if (options && (options.merge || options.mergeFields)) { + expect(post).to.not.be.an.instanceOf(Post); + } else { + expect(post).to.be.an.instanceof(Post); + } + const result: DocumentData = {}; + if (post.title) result.title = post.title; + if (post.author) result.author = post.author; + return result; + }, + fromFirestore(snapshot: QueryDocumentSnapshot): Post { + const data = snapshot.data(); + return new Post(data.title, data.author); + }, +}; + +export async function bundleToElementArray( + bundle: Buffer +): Promise> { + const result: Array = []; + const readable = new PassThrough(); + readable.end(bundle); + const streamIterator = new JSONStreamIterator(readable); + for await (const value of streamIterator) { + result.push(value as firestore.IBundleElement); + } + return result; +} diff --git a/dev/test/watch.ts b/dev/test/watch.ts index f759d52c9..bb9428e95 100644 --- a/dev/test/watch.ts +++ b/dev/test/watch.ts @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {WATCH_IDLE_TIMEOUT_MS} from '../src/watch'; - -const duplexify = require('duplexify'); +import {DocumentData} from '@google-cloud/firestore'; +import * as duplexify from 'duplexify'; +import {describe, it, beforeEach, afterEach} from 'mocha'; import {expect} from 'chai'; import * as extend from 'extend'; import {GoogleError, Status} from 'google-gax'; @@ -26,7 +26,6 @@ import {google} from '../protos/firestore_v1_proto_api'; import { CollectionReference, - DocumentData, DocumentReference, DocumentSnapshot, FieldPath, @@ -42,6 +41,7 @@ import {MAX_RETRY_ATTEMPTS, setTimeoutHandler} from '../src/backoff'; import {DocumentSnapshotBuilder} from '../src/document'; import {DocumentChangeType} from '../src/document-change'; import {Serializer} from '../src/serializer'; +import {WATCH_IDLE_TIMEOUT_MS} from '../src/watch'; import {createInstance, InvalidApiUsage, verifyInstance} from './util/helpers'; import api = google.firestore.v1; @@ -306,7 +306,7 @@ class StreamHelper { write(data: string | object): void { // The stream returned by the Gapic library accepts Protobuf // messages, but the type information does not expose this. - // tslint:disable-next-line no-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any this.writeStream!.write(data as any); } diff --git a/dev/test/write-batch.ts b/dev/test/write-batch.ts index d4ebee9c9..7ad58cfdc 100644 --- a/dev/test/write-batch.ts +++ b/dev/test/write-batch.ts @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +import {DocumentData} from '@google-cloud/firestore'; + +import {describe, it, beforeEach, afterEach} from 'mocha'; import {expect} from 'chai'; import {Status} from 'google-gax'; @@ -22,6 +25,7 @@ import { Timestamp, WriteBatch, WriteResult, + QueryDocumentSnapshot, } from '../src'; import {BatchWriteResult} from '../src/write-batch'; import { @@ -30,6 +34,7 @@ import { InvalidApiUsage, response, verifyInstance, + Post, } from './util/helpers'; const REQUEST_TIME = 'REQUEST_TIME'; @@ -75,6 +80,24 @@ describe('set() method', () => { nullObject.bar = 'ack'; writeBatch.set(firestore.doc('sub/doc'), nullObject); }); + + it('requires the correct converter for Partial usage', async () => { + const converter = { + toFirestore(post: Post): DocumentData { + return {title: post.title, author: post.author}; + }, + fromFirestore(snapshot: QueryDocumentSnapshot): Post { + const data = snapshot.data(); + return new Post(data.title, data.author); + }, + }; + const ref = firestore.doc('sub/doc').withConverter(converter); + expect(() => + writeBatch.set(ref, {title: 'foo'} as Partial, {merge: true}) + ).to.throw( + 'Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field "author").' + ); + }); }); describe('delete() method', () => { @@ -379,7 +402,7 @@ describe('batch support', () => { it('can return same write result', () => { const overrides: ApiOverride = { - commit: request => { + commit: () => { return response({ commitTime: { nanos: 0, @@ -412,59 +435,6 @@ describe('batch support', () => { }); }); }); - - it('uses transactions on GCF', () => { - // We use this environment variable during initialization to detect whether - // we are running on GCF. - process.env.FUNCTION_TRIGGER_TYPE = 'http-trigger'; - - let beginCalled = 0; - let commitCalled = 0; - - const overrides: ApiOverride = { - beginTransaction: () => { - ++beginCalled; - return response({transaction: Buffer.from('foo')}); - }, - commit: () => { - ++commitCalled; - return response({ - commitTime: { - nanos: 0, - seconds: 0, - }, - }); - }, - }; - - return createInstance(overrides).then(firestore => { - firestore['_preferTransactions'] = true; - firestore['_lastSuccessfulRequest'] = 0; - - return firestore - .batch() - .commit() - .then(() => { - // The first commit always uses a transcation. - expect(beginCalled).to.equal(1); - expect(commitCalled).to.equal(1); - return firestore.batch().commit(); - }) - .then(() => { - // The following commits don't use transactions if they happen - // within two minutes. - expect(beginCalled).to.equal(1); - expect(commitCalled).to.equal(2); - firestore['_lastSuccessfulRequest'] = 1337; - return firestore.batch().commit(); - }) - .then(() => { - expect(beginCalled).to.equal(2); - expect(commitCalled).to.equal(3); - delete process.env.FUNCTION_TRIGGER_TYPE; - }); - }); - }); }); describe('bulkCommit support', () => { diff --git a/package.json b/package.json index 0d461c5cc..8c3b4abd0 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "license": "Apache-2.0", "author": "Google Inc.", "engines": { - "node": "^8.13.0 || >=10.10.0" + "node": ">=10.10.0" }, "repository": "googleapis/nodejs-firestore", "main": "./build/src/index.js", @@ -50,11 +50,9 @@ "precompile": "gts clean" }, "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" }, "devDependencies": { "@types/assert": "^1.4.0", @@ -64,6 +62,7 @@ "@types/extend": "^3.0.0", "@types/mocha": "^7.0.0", "@types/node": "^12.12.17", + "@types/sinon": "^9.0.0", "@types/through2": "^2.0.34", "c8": "^7.0.0", "chai": "^4.1.2", @@ -71,15 +70,18 @@ "codecov": "^3.6.1", "duplexify": "^4.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", "mocha": "^7.0.0", "protobufjs": "^6.8.6", "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" } } diff --git a/samples/.eslintrc.yml b/samples/.eslintrc.yml index 282535f55..46c73eea4 100644 --- a/samples/.eslintrc.yml +++ b/samples/.eslintrc.yml @@ -1,3 +1,5 @@ --- rules: no-console: off + no-unused-vars: off + node/no-unpublished-require: off diff --git a/samples/limit-to-last-query.js b/samples/limit-to-last-query.js index ad764d9a3..df91ea134 100644 --- a/samples/limit-to-last-query.js +++ b/samples/limit-to-last-query.js @@ -15,18 +15,21 @@ 'use strict'; // [START firestore_limit_to_last_query] -const { Firestore } = require('@google-cloud/firestore'); +const {Firestore} = require('@google-cloud/firestore'); // Create a new client const firestore = new Firestore(); async function limitToLastQuery() { - const collectionReference = firestore.collection('cities'); - var cityDocuments = await collectionReference.orderBy('name').limitToLast(2).get(); - var cityDocumentData = cityDocuments.docs.map(d => d.data()); - cityDocumentData.forEach(doc => { - console.log(doc.name); - }); + const collectionReference = firestore.collection('cities'); + const cityDocuments = await collectionReference + .orderBy('name') + .limitToLast(2) + .get(); + const cityDocumentData = cityDocuments.docs.map(d => d.data()); + cityDocumentData.forEach(doc => { + console.log(doc.name); + }); } limitToLastQuery(); // [END firestore_limit_to_last_query] diff --git a/samples/solution-counters.js b/samples/solution-counters.js index c374f3f25..6c6bdbfa7 100644 --- a/samples/solution-counters.js +++ b/samples/solution-counters.js @@ -42,7 +42,7 @@ async function main() { const shardsCollectionRef = docRef.collection('shards'); const shardDocs = await shardsCollectionRef.select('id').get(); const promises = []; - shardDocs.forEach(async (doc) => { + shardDocs.forEach(async doc => { promises.push(shardsCollectionRef.doc(doc.id).delete()); }); return Promise.all(promises); diff --git a/samples/test/limit-to-last-query.test.js b/samples/test/limit-to-last-query.test.js index 256feb80a..ed393bec1 100644 --- a/samples/test/limit-to-last-query.test.js +++ b/samples/test/limit-to-last-query.test.js @@ -14,29 +14,35 @@ 'use strict'; -const { execSync } = require('child_process'); -const { assert } = require('chai'); -const { describe, it } = require('mocha'); -const exec = (cmd) => execSync(cmd, { encoding: 'utf8' }); -const { Firestore, FieldPath } = require('@google-cloud/firestore'); +const {execSync} = require('child_process'); +const {assert} = require('chai'); +const {after, before, describe, it} = require('mocha'); +const exec = cmd => execSync(cmd, {encoding: 'utf8'}); +const {Firestore, FieldPath} = require('@google-cloud/firestore'); describe('limit to last query', () => { - const firestore = new Firestore(); - const cities = ['San Francisco', 'Los Angeles', 'Tokyo', 'Beijing']; + const firestore = new Firestore(); + const cities = ['San Francisco', 'Los Angeles', 'Tokyo', 'Beijing']; - before(async () => { - await Promise.all(cities.map(city => firestore.doc(`cities/${city}`).set({ name: city }))); - }); + before(async () => { + await Promise.all( + cities.map(city => firestore.doc(`cities/${city}`).set({name: city})) + ); + }); - after(async () => { - const cityCollectionRef = firestore.collection('cities'); - const cityDocs = (await cityCollectionRef.select(FieldPath.documentId()).get()).docs; - await Promise.all(cityDocs.map(doc => cityCollectionRef.doc(doc.id).delete())); - }); + after(async () => { + const cityCollectionRef = firestore.collection('cities'); + const cityDocs = ( + await cityCollectionRef.select(FieldPath.documentId()).get() + ).docs; + await Promise.all( + cityDocs.map(doc => cityCollectionRef.doc(doc.id).delete()) + ); + }); - it('should run limitToLast query', () => { - const output = exec('node limit-to-last-query.js'); - assert.include(output, 'San Francisco'); - assert.include(output, 'Tokyo'); - }); + it('should run limitToLast query', () => { + const output = exec('node limit-to-last-query.js'); + assert.include(output, 'San Francisco'); + assert.include(output, 'Tokyo'); + }); }); diff --git a/samples/test/quickstart.test.js b/samples/test/quickstart.test.js index 75b04b580..add01a103 100644 --- a/samples/test/quickstart.test.js +++ b/samples/test/quickstart.test.js @@ -17,7 +17,7 @@ const {execSync} = require('child_process'); const {assert} = require('chai'); const {describe, it} = require('mocha'); -const exec = (cmd) => execSync(cmd, {encoding: 'utf8'}); +const exec = cmd => execSync(cmd, {encoding: 'utf8'}); describe('should make some API calls', () => { it('should run quickstart', () => { diff --git a/samples/test/solution-counters.test.js b/samples/test/solution-counters.test.js index dadd44547..bf1f10f06 100644 --- a/samples/test/solution-counters.test.js +++ b/samples/test/solution-counters.test.js @@ -16,7 +16,8 @@ const {execSync} = require('child_process'); const {assert} = require('chai'); -const exec = (cmd) => execSync(cmd, {encoding: 'utf8'}); +const {describe, it} = require('mocha'); +const exec = cmd => execSync(cmd, {encoding: 'utf8'}); describe('distributed counter', () => { it('should increase, get counter and delete the docs', () => { diff --git a/scripts/.eslintrc.yml b/scripts/.eslintrc.yml new file mode 100644 index 000000000..4e82c4b69 --- /dev/null +++ b/scripts/.eslintrc.yml @@ -0,0 +1,7 @@ +--- +rules: + no-console: off + no-unused-vars: off + node/no-unpublished-require: off + node/no-extraneous-require: off + diff --git a/dev/synth.metadata b/synth.metadata similarity index 74% rename from dev/synth.metadata rename to synth.metadata index fb2024a6f..a01f262a6 100644 --- a/dev/synth.metadata +++ b/synth.metadata @@ -1,19 +1,25 @@ { - "updateTime": "2020-03-22T11:28:16.621427Z", "sources": [ + { + "git": { + "name": ".", + "remote": "git@github.com:googleapis/nodejs-firestore.git", + "sha": "ea5efde27605df068277fa2ffcd0ca4a95f01450" + } + }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "0be7105dc52590fa9a24e784052298ae37ce53aa", - "internalRef": "302154871" + "sha": "d5fe42c39cd35f95131a0267314ae108ab1bef8d", + "internalRef": "314471006" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "7e98e1609c91082f4eeb63b530c6468aefd18cfd" + "sha": "f06a850db98490bf90c6a476d3f4c6c7cdfb1e5e" } } ], diff --git a/synth.py b/synth.py index 8e8d6f5e6..ec1fbdafe 100644 --- a/synth.py +++ b/synth.py @@ -3,6 +3,7 @@ import synthtool.languages.node as node import logging import os +import subprocess logging.basicConfig(level=logging.DEBUG) @@ -13,52 +14,60 @@ v1_admin_library = gapic_micro.typescript_library( "firestore-admin", "v1", proto_path="/google/firestore/admin/v1", - generator_args={'grpc-service-config': 'google/firestore/admin/v1/firestore_admin_grpc_service_config.json'} + generator_args={'package-name': '@google-cloud/firestore', + 'grpc-service-config': 'google/firestore/admin/v1/firestore_admin_grpc_service_config.json'} ) v1beta1_library = gapic_micro.typescript_library( "firestore", "v1beta1", proto_path="/google/firestore/v1beta1", - generator_args={'grpc-service-config': 'google/firestore/v1beta1/firestore_grpc_service_config.json'} + generator_args={'package-name': '@google-cloud/firestore', + 'grpc-service-config': 'google/firestore/v1beta1/firestore_grpc_service_config.json'} ) v1_library = gapic_micro.typescript_library( "firestore", "v1", proto_path="/google/firestore/v1", - generator_args={'grpc-service-config': 'google/firestore/v1/firestore_grpc_service_config.json'} + generator_args={'package-name': '@google-cloud/firestore', + 'grpc-service-config': 'google/firestore/v1/firestore_grpc_service_config.json'} ) # skip index, protos, package.json, and README.md s.copy(v1_admin_library, "dev", excludes=["package.json", "README.md", "src/index.ts", "src/v1/index.ts", - "tsconfig.json", "tslint.json", "linkinator.config.json", "webpack.config.js"]) + "tsconfig.json", "linkinator.config.json", "webpack.config.js"]) s.copy(v1beta1_library, "dev", excludes=["package.json", "README.md", "src/index.ts", "src/v1beta1/index.ts", - "tsconfig.json", "tslint.json", "linkinator.config.json", "webpack.config.js"]) + "tsconfig.json", "linkinator.config.json", "webpack.config.js"]) s.copy(v1_library, "dev", excludes=["package.json", "README.md", "src/index.ts", "src/v1/index.ts", - "tsconfig.json", "tslint.json", "linkinator.config.json", "webpack.config.js"]) + "tsconfig.json", "linkinator.config.json", "webpack.config.js"]) # Fix dropping of google-cloud-resource-header # See: https://github.com/googleapis/nodejs-firestore/pull/375 s.replace( "dev/src/v1beta1/firestore_client.ts", - "return this\._innerApiCalls\.listen\(options\);", - "return this._innerApiCalls.listen({}, options);", + "return this\.innerApiCalls\.listen\(options\);", + "return this.innerApiCalls.listen({}, options);", ) s.replace( "dev/src/v1/firestore_client.ts", - "return this\._innerApiCalls\.listen\(options\);", - "return this._innerApiCalls.listen({}, options);", + "return this\.innerApiCalls\.listen\(options\);", + "return this.innerApiCalls.listen({}, options);", ) - -# Copy template files -common_templates = gcp.CommonTemplates() -templates = common_templates.node_library( - source_location="build/src", - test_project="node-gcloud-ci", - excludes=[ - ".kokoro/presubmit/node10/system-test.cfg", - ".kokoro/continuous/node10/system-test.cfg", - ".kokoro/presubmit/node10/samples-test.cfg", - ".kokoro/continuous/node10/samples-test.cfg" - ] +s.replace( + "dev/test/gapic_firestore_v1beta1.ts", + "calledWithExactly\(undefined\)", + "calledWithExactly({}, undefined)", +) +s.replace( + "dev/src/v1beta1/firestore_client.ts", + "return this\.innerApiCalls\.write\(options\);", + "return this.innerApiCalls.write({}, options);", +) +s.replace( + "dev/src/v1/firestore_client.ts", + "return this\.innerApiCalls\.write\(options\);", + "return this.innerApiCalls.write({}, options);", +) +s.replace( + "dev/test/gapic_firestore_v1.ts", + "calledWithExactly\(undefined\)", + "calledWithExactly({}, undefined)", ) - -s.copy(templates) # use the existing proto .js / .d.ts files s.replace( @@ -67,30 +76,90 @@ "/protos/firestore_v1_proto_api'" ) s.replace( - "dev/test/gapic-firestore-v1.ts", + "dev/test/gapic_firestore_v1.ts", "/protos/protos'", "/protos/firestore_v1_proto_api'" ) +s.replace( + "dev/test/gapic_firestore_v1.ts", + "import \* as firestoreModule from '\.\./src';", + "import * as firestoreModule from '../src/v1';" +) +s.replace( + "dev/test/gapic_firestore_v1.ts", + "firestoreModule\.v1", + "firestoreModule" +) s.replace( "dev/src/v1/firestore_admin_client.ts", "/protos/protos'", "/protos/firestore_admin_v1_proto_api'" ) s.replace( - "dev/test/gapic-firestore_admin-v1.ts", + "dev/test/gapic_firestore_admin_v1.ts", "/protos/protos'", "/protos/firestore_admin_v1_proto_api'" ) +s.replace( + "dev/test/gapic_firestore_admin_v1.ts", + "import \* as firestoreadminModule from '\.\./src';", + "import * as firestoreadminModule from '../src/v1';" +) +s.replace( + "dev/test/gapic_firestore_admin_v1.ts", + "firestoreadminModule\.v1", + "firestoreadminModule" +) s.replace( "dev/src/v1beta1/firestore_client.ts", "/protos/protos'", "/protos/firestore_v1beta1_proto_api'" - ) +) s.replace( - "dev/test/gapic-firestore-v1beta1.ts", + "dev/test/gapic_firestore_v1beta1.ts", "/protos/protos'", "/protos/firestore_v1beta1_proto_api'" ) +s.replace( + "dev/test/gapic_firestore_v1beta1.ts", + "import \* as firestoreModule from \'../src\';", + "import * as firestoreModule from '../src/v1beta1';" +) +s.replace( + "dev/test/gapic_firestore_v1beta1.ts", + "firestoreModule\.v1beta1", + "firestoreModule" +) + +# Mark v1beta1 as deprecated +s.replace( + "dev/src/v1beta1/firestore_client.ts", + "@class", + "@class\n * @deprecated Use v1/firestore_client instead." +) +s.replace( + "dev/src/v1beta1/firestore_client.ts", + "const version", + "// tslint:disable deprecation\n\nconst version", + 1 +) + +os.rename("dev/.gitignore", ".gitignore") +os.rename("dev/.eslintignore", ".eslintignore") +os.rename("dev/.mocharc.js", ".mocharc.js") +os.rename("dev/.jsdoc.js", ".jsdoc.js") +os.rename("dev/.prettierrc.js", ".prettierrc.js") +os.unlink("dev/.eslintrc.json") + +s.replace(".jsdoc.js", "protos", "build/protos", 1) + +# Copy template files +common_templates = gcp.CommonTemplates() +templates = common_templates.node_library( + source_location="build/src", test_project="node-gcloud-ci" +) + +s.copy(templates, excludes=[".eslintrc.json"]) # Remove auto-generated packaging tests os.system('rm -rf dev/system-test/fixtures dev/system-test/install.ts') @@ -99,6 +168,8 @@ node.fix() os.chdir("dev") node.compile_protos() -os.unlink('protos/protos.js') -os.unlink('protos/protos.d.ts') -os.unlink('.jsdoc.js') +os.chdir("protos") +os.unlink('protos.js') +os.unlink('protos.d.ts') +subprocess.run('./update.sh', shell=True) +os.chdir("../../") diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 35146685a..000000000 --- a/tslint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "gts/tslint.json" , - "jsRules": { - "no-bitwise": true - }, - "rules": { - "no-unused-expression": false, - "ordered-imports": true - } -} diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 97af5607f..822223cc8 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -16,7 +16,9 @@ * limitations under the License. */ -// 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 */ // Declare a global (ambient) namespace // (used when not using import statement, but just script include). @@ -36,12 +38,12 @@ declare namespace FirebaseFirestore { /** * 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; + /** * Converter used by `withConverter()` to transform user objects of type T * into Firestore data. @@ -63,8 +65,9 @@ declare namespace FirebaseFirestore { * return {title: post.title, author: post.author}; * }, * fromFirestore( - * data: FirebaseFirestore.DocumentData + * snapshot: FirebaseFirestore.QueryDocumentSnapshot * ): Post { + * const data = snapshot.data(); * return new Post(data.title, data.author); * } * }; @@ -84,15 +87,17 @@ declare namespace FirebaseFirestore { /** * 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). + * Firestore database). To use set() with `merge` and `mergeFields`, + * toFirestore() must be defined with `Partial`. */ toFirestore(modelObject: T): DocumentData; + toFirestore(modelObject: Partial, options: SetOptions): DocumentData; /** * Called by the Firestore SDK to convert Firestore data into an object of * type T. */ - fromFirestore(data: DocumentData): T; + fromFirestore(snapshot: QueryDocumentSnapshot): T; } /** @@ -131,7 +136,7 @@ declare namespace FirebaseFirestore { * Default Credentials}. If your credentials are stored in a JSON file, you * can specify a `keyFilename` instead. */ - credentials?: {client_email?:string, private_key?:string}; + credentials?: {client_email?: string; private_key?: string}; /** Whether to use SSL when connecting. */ ssl?: boolean; @@ -144,6 +149,14 @@ declare namespace FirebaseFirestore { */ maxIdleChannels?: number; + /** + * 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 * object serialization. If set to `true`, these properties are skipped @@ -151,7 +164,7 @@ declare namespace FirebaseFirestore { * an exception when it encounters properties of type `undefined`. */ ignoreUndefinedProperties?: boolean; - + [key: string]: any; // Accept other properties, such as GRPC settings. } @@ -223,8 +236,11 @@ declare namespace FirebaseFirestore { * @return A Promise that resolves with an array of resulting document * snapshots. */ - getAll(...documentRefsOrReadOptions: Array | ReadOptions>): - Promise>>; + getAll( + ...documentRefsOrReadOptions: Array< + DocumentReference | ReadOptions + > + ): Promise>>; /** * Terminates the Firestore client and closes all open streams. @@ -239,7 +255,7 @@ declare namespace FirebaseFirestore { * * @returns A Promise that resolves with an array of CollectionReferences. */ - listCollections() : Promise>>; + listCollections(): Promise>>; /** * Executes the given updateFunction and commits the changes applied within @@ -261,8 +277,8 @@ declare namespace FirebaseFirestore { * error will be returned. */ runTransaction( - updateFunction: (transaction: Transaction) => Promise, - transactionOptions?:{maxAttempts?: number} + updateFunction: (transaction: Transaction) => Promise, + transactionOptions?: {maxAttempts?: number} ): Promise; /** @@ -341,8 +357,9 @@ declare namespace FirebaseFirestore { * @return A Promise that resolves with an array of resulting document * snapshots. */ - getAll(...documentRefsOrReadOptions: Array): - Promise>>; + getAll( + ...documentRefsOrReadOptions: Array | ReadOptions> + ): Promise>>; /** * Create the document referred to by the provided `DocumentReference`. @@ -365,8 +382,12 @@ declare namespace FirebaseFirestore { * @param options An object to configure the set behavior. * @return This `Transaction` instance. Used for chaining method calls. */ - set(documentRef: DocumentReference, data: T, - options?: SetOptions): Transaction; + set( + documentRef: DocumentReference, + data: Partial, + options: SetOptions + ): Transaction; + set(documentRef: DocumentReference, data: T): Transaction; /** * Updates fields in the document referred to by the provided @@ -382,8 +403,11 @@ declare namespace FirebaseFirestore { * @param precondition A Precondition to enforce on this update. * @return This `Transaction` instance. Used for chaining method calls. */ - update(documentRef: DocumentReference, data: UpdateData, - precondition?: Precondition): Transaction; + update( + documentRef: DocumentReference, + data: UpdateData, + precondition?: Precondition + ): Transaction; /** * Updates fields in the document referred to by the provided @@ -404,8 +428,12 @@ declare namespace FirebaseFirestore { * update. * @return This `Transaction` instance. Used for chaining method calls. */ - update(documentRef: DocumentReference, field: string|FieldPath, value:any, - ...fieldsOrPrecondition: any[]): Transaction; + update( + documentRef: DocumentReference, + field: string | FieldPath, + value: any, + ...fieldsOrPrecondition: any[] + ): Transaction; /** * Deletes the document referred to by the provided `DocumentReference`. @@ -414,8 +442,10 @@ declare namespace FirebaseFirestore { * @param precondition A Precondition to enforce for this delete. * @return This `Transaction` instance. Used for chaining method calls. */ - delete(documentRef: DocumentReference, - precondition?: Precondition): Transaction; + delete( + documentRef: DocumentReference, + precondition?: Precondition + ): Transaction; } /** @@ -453,8 +483,12 @@ declare namespace FirebaseFirestore { * @param options An object to configure the set behavior. * @return This `WriteBatch` instance. Used for chaining method calls. */ - set(documentRef: DocumentReference, data: T, - options?: SetOptions): WriteBatch; + set( + documentRef: DocumentReference, + data: Partial, + options: SetOptions + ): WriteBatch; + set(documentRef: DocumentReference, data: T): WriteBatch; /** * Update fields of the document referred to by the provided @@ -470,8 +504,11 @@ declare namespace FirebaseFirestore { * @param precondition A Precondition to enforce on this update. * @return This `WriteBatch` instance. Used for chaining method calls. */ - update(documentRef: DocumentReference, data: UpdateData, - precondition?: Precondition): WriteBatch; + update( + documentRef: DocumentReference, + data: UpdateData, + precondition?: Precondition + ): WriteBatch; /** * Updates fields in the document referred to by the provided @@ -491,8 +528,12 @@ declare namespace FirebaseFirestore { * to update, optionally followed a `Precondition` to enforce on this update. * @return This `WriteBatch` instance. Used for chaining method calls. */ - update(documentRef: DocumentReference, field: string|FieldPath, value:any, - ...fieldsOrPrecondition: any[]): WriteBatch; + update( + documentRef: DocumentReference, + field: string | FieldPath, + value: any, + ...fieldsOrPrecondition: any[] + ): WriteBatch; /** * Deletes the document referred to by the provided `DocumentReference`. @@ -501,8 +542,10 @@ declare namespace FirebaseFirestore { * @param precondition A Precondition to enforce for this delete. * @return This `WriteBatch` instance. Used for chaining method calls. */ - delete(documentRef: DocumentReference, - precondition?: Precondition): WriteBatch; + delete( + documentRef: DocumentReference, + precondition?: Precondition + ): WriteBatch; /** * Commits all of the writes in this write batch as a single atomic unit. @@ -548,7 +591,7 @@ declare namespace FirebaseFirestore { * 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?: (string|FieldPath)[]; + readonly mergeFields?: (string | FieldPath)[]; } /** @@ -565,7 +608,7 @@ declare namespace FirebaseFirestore { * contain values for all the fields in the mask to be part of the result * set. */ - readonly fieldMask?: (string|FieldPath)[]; + readonly fieldMask?: (string | FieldPath)[]; } /** @@ -632,7 +675,7 @@ declare namespace FirebaseFirestore { * * @returns A Promise that resolves with an array of CollectionReferences. */ - listCollections() : Promise>>; + listCollections(): Promise>>; /** * Creates a document referred to by this `DocumentReference` with the @@ -652,7 +695,8 @@ declare namespace FirebaseFirestore { * @param options An object to configure the set behavior. * @return A Promise resolved with the write time of this set. */ - set(data: T, options?: SetOptions): Promise; + set(data: Partial, options: SetOptions): Promise; + set(data: T): Promise; /** * Updates fields in the document referred to by this `DocumentReference`. @@ -685,8 +729,11 @@ declare namespace FirebaseFirestore { * this update. * @return A Promise resolved with the write time of this update. */ - update(field: string|FieldPath, value:any, - ...moreFieldsOrPrecondition: any[]): Promise; + update( + field: string | FieldPath, + value: any, + ...moreFieldsOrPrecondition: any[] + ): Promise; /** * Deletes the document referred to by this `DocumentReference`. @@ -694,7 +741,7 @@ declare namespace FirebaseFirestore { * @param precondition A Precondition to enforce for this delete. * @return A Promise resolved with the write time of this delete. */ - delete(precondition?:Precondition): Promise; + delete(precondition?: Precondition): Promise; /** * Reads the document referred to by this `DocumentReference`. @@ -714,8 +761,10 @@ declare namespace FirebaseFirestore { * @return An unsubscribe function that can be called to cancel * the snapshot listener. */ - onSnapshot(onNext: (snapshot: DocumentSnapshot) => void, - onError?: (error: Error) => void): () => void; + onSnapshot( + onNext: (snapshot: DocumentSnapshot) => void, + onError?: (error: Error) => void + ): () => void; /** * Returns true if this `DocumentReference` is equal to the provided one. @@ -795,7 +844,7 @@ declare namespace FirebaseFirestore { * @return The data at the specified field location or undefined if no such * field exists in the document. */ - get(fieldPath: string|FieldPath): any; + get(fieldPath: string | FieldPath): any; /** * Returns true if the document's data and path in this `DocumentSnapshot` @@ -818,7 +867,9 @@ declare namespace FirebaseFirestore { * `exists` property will always be true and `data()` will never return * 'undefined'. */ - export class QueryDocumentSnapshot extends DocumentSnapshot { + export class QueryDocumentSnapshot extends DocumentSnapshot< + T + > { private constructor(); /** @@ -849,11 +900,18 @@ declare namespace FirebaseFirestore { /** * 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'; /** * A `Query` refers to a Query which you can read or listen to. You can also @@ -881,7 +939,11 @@ declare namespace FirebaseFirestore { * @param value The value for comparison * @return The created Query. */ - where(fieldPath: string|FieldPath, opStr: WhereFilterOp, value: any): Query; + where( + fieldPath: string | FieldPath, + opStr: WhereFilterOp, + value: any + ): Query; /** * Creates and returns a new Query that's additionally sorted by the @@ -896,11 +958,12 @@ declare namespace FirebaseFirestore { * @return The created Query. */ orderBy( - fieldPath: string|FieldPath, directionStr?: OrderByDirection + fieldPath: string | FieldPath, + directionStr?: OrderByDirection ): Query; /** - * 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. * * This function returns a new (immutable) instance of the Query (rather @@ -910,14 +973,14 @@ declare namespace FirebaseFirestore { * @return The created Query. */ limit(limit: number): Query; - + /** * Creates and returns a new Query that only returns the last matching * documents. * - * 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()` * API. * @@ -1066,8 +1129,10 @@ declare namespace FirebaseFirestore { * @return An unsubscribe function that can be called to cancel * the snapshot listener. */ - onSnapshot(onNext: (snapshot: QuerySnapshot) => void, - onError?: (error: Error) => void) : () => void; + onSnapshot( + onNext: (snapshot: QuerySnapshot) => void, + onError?: (error: Error) => void + ): () => void; /** * Returns true if this `Query` is equal to the provided one. @@ -1077,7 +1142,7 @@ declare namespace FirebaseFirestore { */ isEqual(other: Query): boolean; - /** + /** * Applies a custom data converter to this Query, allowing you to use your * own custom model objects with Firestore. When you call get() on the * returned Query, the provided converter will convert between Firestore @@ -1132,7 +1197,8 @@ declare namespace FirebaseFirestore { * @param thisArg The `this` binding for the callback. */ forEach( - callback: (result: QueryDocumentSnapshot) => void, thisArg?: any + callback: (result: QueryDocumentSnapshot) => void, + thisArg?: any ): void; /** @@ -1477,14 +1543,15 @@ declare namespace FirebaseFirestore { /** * The v1beta1 Veneer client. This client provides access to to the underlying * Firestore v1beta1 RPCs. + * @deprecated Use v1 instead. */ - export const v1beta1 : any; + export const v1beta1: any; /** * The v1 Veneer clients. These clients provide access to the Firestore Admin * API and the underlying Firestore v1 RPCs. */ - export const v1: {FirestoreClient: any, FirestoreAdminClient: any}; + export const v1: {FirestoreClient: any; FirestoreAdminClient: any}; /** * Status codes returned by Firestore's gRPC calls. @@ -1506,7 +1573,7 @@ declare namespace FirebaseFirestore { INTERNAL = 13, UNAVAILABLE = 14, DATA_LOSS = 15, - UNAUTHENTICATED = 16 + UNAUTHENTICATED = 16, } } From c93011d04511363c549897be69422337fa32ca3b Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 24 Jun 2020 13:44:16 -0700 Subject: [PATCH 143/337] chore: run synthtool after node10 merge (#1235) --- .github/ISSUE_TEMPLATE/bug_report.md | 11 +- README.md | 1 + dev/protos/firestore_v1_proto_api.d.ts | 80 ++++----- dev/protos/firestore_v1_proto_api.js | 166 +++++++++--------- dev/protos/google/api/client.proto | 3 +- dev/protos/google/api/field_behavior.proto | 3 +- dev/protos/google/api/http.proto | 3 +- dev/protos/google/api/resource.proto | 24 ++- .../google/firestore/admin/v1/field.proto | 1 + .../firestore/admin/v1/firestore_admin.proto | 1 + .../google/firestore/admin/v1/index.proto | 1 + .../google/firestore/admin/v1/location.proto | 1 + .../google/firestore/admin/v1/operation.proto | 1 + dev/protos/google/firestore/v1/common.proto | 1 + dev/protos/google/firestore/v1/document.proto | 1 + .../google/firestore/v1/firestore.proto | 1 + dev/protos/google/firestore/v1/query.proto | 11 +- dev/protos/google/firestore/v1/write.proto | 1 + .../google/firestore/v1beta1/common.proto | 1 + .../google/firestore/v1beta1/document.proto | 1 + .../google/firestore/v1beta1/firestore.proto | 1 + .../google/firestore/v1beta1/query.proto | 1 + .../google/firestore/v1beta1/write.proto | 1 + dev/protos/protos.json | 23 +-- dev/src/v1/firestore_admin_client.ts | 24 +-- dev/src/v1/firestore_client.ts | 24 +-- dev/src/v1/firestore_client_config.json | 9 +- dev/src/v1beta1/firestore_client.ts | 24 +-- samples/README.md | 18 ++ synth.metadata | 8 +- synth.py | 2 +- 31 files changed, 255 insertions(+), 193 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 9382de877..a3924b981 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -8,13 +8,18 @@ Thanks for stopping by to let us know something could be better! **PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. -Please run down the following list and make sure you've tried the usual "quick fixes": +1) Is this a client library issue or a product issue? +This is the client library for . We will only be able to assist with issues that pertain to the behaviors of this library. If the issue you're experiencing is due to the behavior of the product itself, please visit the [ Support page]() to reach the most relevant engineers. +2) Did someone already solve this? - Search the issues already opened: https://github.com/googleapis/nodejs-firestore/issues - Search the issues on our "catch-all" repository: https://github.com/googleapis/google-cloud-node - - Search StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js + - Search or ask on StackOverflow (engineers monitor these tags): http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js -If you are still having issues, please be sure to include as much information as possible: +3) Do you have a support contract? +Please create an issue in the [support console](https://cloud.google.com/support/) to ensure a timely response. + +If the support paths suggested above still do not result in a resolution, please provide the following details. #### Environment details diff --git a/README.md b/README.md index 3cfc4d972..0b5f2ac1d 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ has instructions for running the samples. | Sample | Source Code | Try it | | --------------------------- | --------------------------------- | ------ | +| 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) | | 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) | diff --git a/dev/protos/firestore_v1_proto_api.d.ts b/dev/protos/firestore_v1_proto_api.d.ts index 0b4afb29c..adde59dfa 100644 --- a/dev/protos/firestore_v1_proto_api.d.ts +++ b/dev/protos/firestore_v1_proto_api.d.ts @@ -5531,89 +5531,89 @@ export namespace google { "OPERATOR_UNSPECIFIED"| "IS_NAN"| "IS_NULL"; } - /** Properties of a FieldReference. */ - interface IFieldReference { + /** Properties of an Order. */ + interface IOrder { - /** FieldReference fieldPath */ - fieldPath?: (string|null); + /** Order field */ + field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); + + /** Order direction */ + direction?: (google.firestore.v1.StructuredQuery.Direction|null); } - /** Represents a FieldReference. */ - class FieldReference implements IFieldReference { + /** Represents an Order. */ + class Order implements IOrder { /** - * Constructs a new FieldReference. + * Constructs a new Order. * @param [properties] Properties to set */ - constructor(properties?: google.firestore.v1.StructuredQuery.IFieldReference); + constructor(properties?: google.firestore.v1.StructuredQuery.IOrder); - /** FieldReference fieldPath. */ - public fieldPath: string; + /** Order field. */ + public field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); + + /** Order direction. */ + public direction: google.firestore.v1.StructuredQuery.Direction; /** - * Creates a FieldReference message from a plain object. Also converts values to their respective internal types. + * Creates an Order message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns FieldReference + * @returns Order */ - public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.FieldReference; + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.Order; /** - * Creates a plain object from a FieldReference message. Also converts values to other types if specified. - * @param message FieldReference + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @param message Order * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.firestore.v1.StructuredQuery.FieldReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.firestore.v1.StructuredQuery.Order, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this FieldReference to JSON. + * Converts this Order to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; } - /** Properties of an Order. */ - interface IOrder { - - /** Order field */ - field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); + /** Properties of a FieldReference. */ + interface IFieldReference { - /** Order direction */ - direction?: (google.firestore.v1.StructuredQuery.Direction|null); + /** FieldReference fieldPath */ + fieldPath?: (string|null); } - /** Represents an Order. */ - class Order implements IOrder { + /** Represents a FieldReference. */ + class FieldReference implements IFieldReference { /** - * Constructs a new Order. + * Constructs a new FieldReference. * @param [properties] Properties to set */ - constructor(properties?: google.firestore.v1.StructuredQuery.IOrder); - - /** Order field. */ - public field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); + constructor(properties?: google.firestore.v1.StructuredQuery.IFieldReference); - /** Order direction. */ - public direction: google.firestore.v1.StructuredQuery.Direction; + /** FieldReference fieldPath. */ + public fieldPath: string; /** - * Creates an Order message from a plain object. Also converts values to their respective internal types. + * Creates a FieldReference message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns Order + * @returns FieldReference */ - public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.Order; + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.FieldReference; /** - * Creates a plain object from an Order message. Also converts values to other types if specified. - * @param message Order + * Creates a plain object from a FieldReference message. Also converts values to other types if specified. + * @param message FieldReference * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.firestore.v1.StructuredQuery.Order, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.firestore.v1.StructuredQuery.FieldReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this Order to JSON. + * Converts this FieldReference to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; diff --git a/dev/protos/firestore_v1_proto_api.js b/dev/protos/firestore_v1_proto_api.js index 3404fd4af..bf33044b0 100644 --- a/dev/protos/firestore_v1_proto_api.js +++ b/dev/protos/firestore_v1_proto_api.js @@ -13329,89 +13329,6 @@ return UnaryFilter; })(); - StructuredQuery.FieldReference = (function() { - - /** - * Properties of a FieldReference. - * @memberof google.firestore.v1.StructuredQuery - * @interface IFieldReference - * @property {string|null} [fieldPath] FieldReference fieldPath - */ - - /** - * Constructs a new FieldReference. - * @memberof google.firestore.v1.StructuredQuery - * @classdesc Represents a FieldReference. - * @implements IFieldReference - * @constructor - * @param {google.firestore.v1.StructuredQuery.IFieldReference=} [properties] Properties to set - */ - function FieldReference(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FieldReference fieldPath. - * @member {string} fieldPath - * @memberof google.firestore.v1.StructuredQuery.FieldReference - * @instance - */ - FieldReference.prototype.fieldPath = ""; - - /** - * Creates a FieldReference message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.firestore.v1.StructuredQuery.FieldReference - * @static - * @param {Object.} object Plain object - * @returns {google.firestore.v1.StructuredQuery.FieldReference} FieldReference - */ - FieldReference.fromObject = function fromObject(object) { - if (object instanceof $root.google.firestore.v1.StructuredQuery.FieldReference) - return object; - var message = new $root.google.firestore.v1.StructuredQuery.FieldReference(); - if (object.fieldPath != null) - message.fieldPath = String(object.fieldPath); - return message; - }; - - /** - * Creates a plain object from a FieldReference message. Also converts values to other types if specified. - * @function toObject - * @memberof google.firestore.v1.StructuredQuery.FieldReference - * @static - * @param {google.firestore.v1.StructuredQuery.FieldReference} message FieldReference - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - FieldReference.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.fieldPath = ""; - if (message.fieldPath != null && message.hasOwnProperty("fieldPath")) - object.fieldPath = message.fieldPath; - return object; - }; - - /** - * Converts this FieldReference to JSON. - * @function toJSON - * @memberof google.firestore.v1.StructuredQuery.FieldReference - * @instance - * @returns {Object.} JSON object - */ - FieldReference.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return FieldReference; - })(); - StructuredQuery.Order = (function() { /** @@ -13525,6 +13442,89 @@ return Order; })(); + StructuredQuery.FieldReference = (function() { + + /** + * Properties of a FieldReference. + * @memberof google.firestore.v1.StructuredQuery + * @interface IFieldReference + * @property {string|null} [fieldPath] FieldReference fieldPath + */ + + /** + * Constructs a new FieldReference. + * @memberof google.firestore.v1.StructuredQuery + * @classdesc Represents a FieldReference. + * @implements IFieldReference + * @constructor + * @param {google.firestore.v1.StructuredQuery.IFieldReference=} [properties] Properties to set + */ + function FieldReference(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldReference fieldPath. + * @member {string} fieldPath + * @memberof google.firestore.v1.StructuredQuery.FieldReference + * @instance + */ + FieldReference.prototype.fieldPath = ""; + + /** + * Creates a FieldReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.StructuredQuery.FieldReference + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.StructuredQuery.FieldReference} FieldReference + */ + FieldReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.StructuredQuery.FieldReference) + return object; + var message = new $root.google.firestore.v1.StructuredQuery.FieldReference(); + if (object.fieldPath != null) + message.fieldPath = String(object.fieldPath); + return message; + }; + + /** + * Creates a plain object from a FieldReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.StructuredQuery.FieldReference + * @static + * @param {google.firestore.v1.StructuredQuery.FieldReference} message FieldReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.fieldPath = ""; + if (message.fieldPath != null && message.hasOwnProperty("fieldPath")) + object.fieldPath = message.fieldPath; + return object; + }; + + /** + * Converts this FieldReference to JSON. + * @function toJSON + * @memberof google.firestore.v1.StructuredQuery.FieldReference + * @instance + * @returns {Object.} JSON object + */ + FieldReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FieldReference; + })(); + StructuredQuery.Projection = (function() { /** diff --git a/dev/protos/google/api/client.proto b/dev/protos/google/api/client.proto index 56f8664aa..2102623d3 100644 --- a/dev/protos/google/api/client.proto +++ b/dev/protos/google/api/client.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// 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. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; diff --git a/dev/protos/google/api/field_behavior.proto b/dev/protos/google/api/field_behavior.proto index eb7f78ef1..aa7127bf8 100644 --- a/dev/protos/google/api/field_behavior.proto +++ b/dev/protos/google/api/field_behavior.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// 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. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; diff --git a/dev/protos/google/api/http.proto b/dev/protos/google/api/http.proto index b2977f514..69460cf79 100644 --- a/dev/protos/google/api/http.proto +++ b/dev/protos/google/api/http.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// 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. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; diff --git a/dev/protos/google/api/resource.proto b/dev/protos/google/api/resource.proto index 2a52e61aa..22611d243 100644 --- a/dev/protos/google/api/resource.proto +++ b/dev/protos/google/api/resource.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// 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. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; @@ -223,10 +222,14 @@ message ResourceDescriptor { // } History history = 4; - // The plural name used in the resource name, such as 'projects' for - // the name of 'projects/{project}'. It is the same concept of the `plural` - // field in k8s CRD spec + // The plural name used in the resource name and permission names, such as + // 'projects' for the resource name of 'projects/{project}' and the permission + // name of 'cloudresourcemanager.googleapis.com/projects.get'. It is the same + // concept of the `plural` field in k8s CRD spec // https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ + // + // Note: The plural form is required even for singleton resources. See + // https://aip.dev/156 string plural = 5; // The same concept of the `singular` field in k8s CRD spec @@ -247,6 +250,17 @@ message ResourceReference { // type: "pubsub.googleapis.com/Topic" // }]; // } + // + // Occasionally, a field may reference an arbitrary resource. In this case, + // APIs use the special value * in their resource reference. + // + // Example: + // + // message GetIamPolicyRequest { + // string resource = 2 [(google.api.resource_reference) = { + // type: "*" + // }]; + // } string type = 1; // The resource type of a child collection that the annotated field diff --git a/dev/protos/google/firestore/admin/v1/field.proto b/dev/protos/google/firestore/admin/v1/field.proto index 48430d87c..1b9b99cf3 100644 --- a/dev/protos/google/firestore/admin/v1/field.proto +++ b/dev/protos/google/firestore/admin/v1/field.proto @@ -28,6 +28,7 @@ option java_outer_classname = "FieldProto"; option java_package = "com.google.firestore.admin.v1"; option objc_class_prefix = "GCFS"; option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; // Represents a single field in the database. // diff --git a/dev/protos/google/firestore/admin/v1/firestore_admin.proto b/dev/protos/google/firestore/admin/v1/firestore_admin.proto index 75dd2d311..c3eb58f9c 100644 --- a/dev/protos/google/firestore/admin/v1/firestore_admin.proto +++ b/dev/protos/google/firestore/admin/v1/firestore_admin.proto @@ -34,6 +34,7 @@ option java_outer_classname = "FirestoreAdminProto"; option java_package = "com.google.firestore.admin.v1"; option objc_class_prefix = "GCFS"; option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; option (google.api.resource_definition) = { type: "firestore.googleapis.com/Database" pattern: "projects/{project}/databases/{database}" diff --git a/dev/protos/google/firestore/admin/v1/index.proto b/dev/protos/google/firestore/admin/v1/index.proto index 4b9c6e35b..e27686be4 100644 --- a/dev/protos/google/firestore/admin/v1/index.proto +++ b/dev/protos/google/firestore/admin/v1/index.proto @@ -27,6 +27,7 @@ option java_outer_classname = "IndexProto"; option java_package = "com.google.firestore.admin.v1"; option objc_class_prefix = "GCFS"; option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; // Cloud Firestore indexes enable simple and complex queries against // documents in a database. diff --git a/dev/protos/google/firestore/admin/v1/location.proto b/dev/protos/google/firestore/admin/v1/location.proto index d9dc6f9b9..e435c6f0d 100644 --- a/dev/protos/google/firestore/admin/v1/location.proto +++ b/dev/protos/google/firestore/admin/v1/location.proto @@ -27,6 +27,7 @@ option java_outer_classname = "LocationProto"; option java_package = "com.google.firestore.admin.v1"; option objc_class_prefix = "GCFS"; option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; // The metadata message for [google.cloud.location.Location.metadata][google.cloud.location.Location.metadata]. message LocationMetadata { diff --git a/dev/protos/google/firestore/admin/v1/operation.proto b/dev/protos/google/firestore/admin/v1/operation.proto index 08194fe09..dcdc6ee65 100644 --- a/dev/protos/google/firestore/admin/v1/operation.proto +++ b/dev/protos/google/firestore/admin/v1/operation.proto @@ -28,6 +28,7 @@ option java_outer_classname = "OperationProto"; option java_package = "com.google.firestore.admin.v1"; option objc_class_prefix = "GCFS"; option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; // Metadata for [google.longrunning.Operation][google.longrunning.Operation] results from // [FirestoreAdmin.CreateIndex][google.firestore.admin.v1.FirestoreAdmin.CreateIndex]. diff --git a/dev/protos/google/firestore/v1/common.proto b/dev/protos/google/firestore/v1/common.proto index b6de070a5..4367f168d 100644 --- a/dev/protos/google/firestore/v1/common.proto +++ b/dev/protos/google/firestore/v1/common.proto @@ -26,6 +26,7 @@ option java_outer_classname = "CommonProto"; option java_package = "com.google.firestore.v1"; option objc_class_prefix = "GCFS"; option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; // A set of field paths on a document. // Used to restrict a get or update operation on a document to a subset of its diff --git a/dev/protos/google/firestore/v1/document.proto b/dev/protos/google/firestore/v1/document.proto index 43f69478e..148d2bddd 100644 --- a/dev/protos/google/firestore/v1/document.proto +++ b/dev/protos/google/firestore/v1/document.proto @@ -28,6 +28,7 @@ option java_outer_classname = "DocumentProto"; option java_package = "com.google.firestore.v1"; option objc_class_prefix = "GCFS"; option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; // A Firestore document. // diff --git a/dev/protos/google/firestore/v1/firestore.proto b/dev/protos/google/firestore/v1/firestore.proto index 5e8c21c45..ee32c410c 100644 --- a/dev/protos/google/firestore/v1/firestore.proto +++ b/dev/protos/google/firestore/v1/firestore.proto @@ -34,6 +34,7 @@ option java_outer_classname = "FirestoreProto"; option java_package = "com.google.firestore.v1"; option objc_class_prefix = "GCFS"; option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; // Specification of the Firestore API. diff --git a/dev/protos/google/firestore/v1/query.proto b/dev/protos/google/firestore/v1/query.proto index 845019136..557fbad1b 100644 --- a/dev/protos/google/firestore/v1/query.proto +++ b/dev/protos/google/firestore/v1/query.proto @@ -27,6 +27,7 @@ option java_outer_classname = "QueryProto"; option java_package = "com.google.firestore.v1"; option objc_class_prefix = "GCFS"; option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; // A Firestore query. message StructuredQuery { @@ -169,11 +170,6 @@ message StructuredQuery { } } - // A reference to a field, such as `max(messages.time) as max_time`. - message FieldReference { - string field_path = 2; - } - // An order on a field. message Order { // The field to order by. @@ -183,6 +179,11 @@ message StructuredQuery { Direction direction = 2; } + // A reference to a field, such as `max(messages.time) as max_time`. + message FieldReference { + string field_path = 2; + } + // The projection of document's fields to return. message Projection { // The fields to return. diff --git a/dev/protos/google/firestore/v1/write.proto b/dev/protos/google/firestore/v1/write.proto index 403c80f81..a6befb0e6 100644 --- a/dev/protos/google/firestore/v1/write.proto +++ b/dev/protos/google/firestore/v1/write.proto @@ -28,6 +28,7 @@ option java_outer_classname = "WriteProto"; option java_package = "com.google.firestore.v1"; option objc_class_prefix = "GCFS"; option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; // A write on a document. message Write { diff --git a/dev/protos/google/firestore/v1beta1/common.proto b/dev/protos/google/firestore/v1beta1/common.proto index 2eaa18347..b71a2e32e 100644 --- a/dev/protos/google/firestore/v1beta1/common.proto +++ b/dev/protos/google/firestore/v1beta1/common.proto @@ -27,6 +27,7 @@ option java_outer_classname = "CommonProto"; option java_package = "com.google.firestore.v1beta1"; option objc_class_prefix = "GCFS"; option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; +option ruby_package = "Google::Cloud::Firestore::V1beta1"; // A set of field paths on a document. // Used to restrict a get or update operation on a document to a subset of its diff --git a/dev/protos/google/firestore/v1beta1/document.proto b/dev/protos/google/firestore/v1beta1/document.proto index 7caae4688..38d81af96 100644 --- a/dev/protos/google/firestore/v1beta1/document.proto +++ b/dev/protos/google/firestore/v1beta1/document.proto @@ -29,6 +29,7 @@ option java_outer_classname = "DocumentProto"; option java_package = "com.google.firestore.v1beta1"; option objc_class_prefix = "GCFS"; option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; +option ruby_package = "Google::Cloud::Firestore::V1beta1"; // A Firestore document. // diff --git a/dev/protos/google/firestore/v1beta1/firestore.proto b/dev/protos/google/firestore/v1beta1/firestore.proto index c2b15b048..5cdccb7ea 100644 --- a/dev/protos/google/firestore/v1beta1/firestore.proto +++ b/dev/protos/google/firestore/v1beta1/firestore.proto @@ -35,6 +35,7 @@ option java_outer_classname = "FirestoreProto"; option java_package = "com.google.firestore.v1beta1"; option objc_class_prefix = "GCFS"; option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; +option ruby_package = "Google::Cloud::Firestore::V1beta1"; // Specification of the Firestore API. diff --git a/dev/protos/google/firestore/v1beta1/query.proto b/dev/protos/google/firestore/v1beta1/query.proto index 4f515fabe..5f9c3ab93 100644 --- a/dev/protos/google/firestore/v1beta1/query.proto +++ b/dev/protos/google/firestore/v1beta1/query.proto @@ -28,6 +28,7 @@ option java_outer_classname = "QueryProto"; option java_package = "com.google.firestore.v1beta1"; option objc_class_prefix = "GCFS"; option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; +option ruby_package = "Google::Cloud::Firestore::V1beta1"; // A Firestore query. message StructuredQuery { diff --git a/dev/protos/google/firestore/v1beta1/write.proto b/dev/protos/google/firestore/v1beta1/write.proto index c02a2a8a1..ba75b42a0 100644 --- a/dev/protos/google/firestore/v1beta1/write.proto +++ b/dev/protos/google/firestore/v1beta1/write.proto @@ -29,6 +29,7 @@ option java_outer_classname = "WriteProto"; option java_package = "com.google.firestore.v1beta1"; option objc_class_prefix = "GCFS"; option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; +option ruby_package = "Google::Cloud::Firestore::V1beta1"; // A write on a document. message Write { diff --git a/dev/protos/protos.json b/dev/protos/protos.json index f859c1deb..56d5a1d9b 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -15,6 +15,7 @@ "java_package": "com.google.firestore.admin.v1", "objc_class_prefix": "GCFS", "php_namespace": "Google\\Cloud\\Firestore\\Admin\\V1", + "ruby_package": "Google::Cloud::Firestore::Admin::V1", "(google.api.resource_definition).type": "firestore.googleapis.com/CollectionGroup", "(google.api.resource_definition).pattern": "projects/{project}/databases/{database}/collectionGroups/{collection}" }, @@ -614,7 +615,8 @@ "java_outer_classname": "WriteProto", "java_package": "com.google.firestore.v1", "objc_class_prefix": "GCFS", - "php_namespace": "Google\\Cloud\\Firestore\\V1" + "php_namespace": "Google\\Cloud\\Firestore\\V1", + "ruby_package": "Google::Cloud::Firestore::V1" }, "nested": { "DocumentMask": { @@ -1805,14 +1807,6 @@ } } }, - "FieldReference": { - "fields": { - "fieldPath": { - "type": "string", - "id": 2 - } - } - }, "Order": { "fields": { "field": { @@ -1825,6 +1819,14 @@ } } }, + "FieldReference": { + "fields": { + "fieldPath": { + "type": "string", + "id": 2 + } + } + }, "Projection": { "fields": { "fields": { @@ -2048,7 +2050,8 @@ "java_outer_classname": "WriteProto", "java_package": "com.google.firestore.v1beta1", "objc_class_prefix": "GCFS", - "php_namespace": "Google\\Cloud\\Firestore\\V1beta1" + "php_namespace": "Google\\Cloud\\Firestore\\V1beta1", + "ruby_package": "Google::Cloud::Firestore::V1beta1" }, "nested": { "DocumentMask": { diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index 63d77a582..07d7b5620 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -102,16 +102,20 @@ export class FirestoreAdminClient { } opts.servicePath = opts.servicePath || servicePath; 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 // sent to the client. @@ -313,9 +317,7 @@ export class FirestoreAdminClient { const callPromise = this.firestoreAdminStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { - return Promise.reject( - new Error('The client has already been closed.') - ); + return Promise.reject('The client has already been closed.'); } const func = stub[methodName]; return func.apply(stub, args); diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 69832d08a..9cf4fcd7f 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -105,16 +105,20 @@ export class FirestoreClient { } opts.servicePath = opts.servicePath || servicePath; 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 // sent to the client. @@ -262,9 +266,7 @@ export class FirestoreClient { const callPromise = this.firestoreStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { - return Promise.reject( - new Error('The client has already been closed.') - ); + return Promise.reject('The client has already been closed.'); } const func = stub[methodName]; return func.apply(stub, args); diff --git a/dev/src/v1/firestore_client_config.json b/dev/src/v1/firestore_client_config.json index f4cd67a1f..9feba0d63 100644 --- a/dev/src/v1/firestore_client_config.json +++ b/dev/src/v1/firestore_client_config.json @@ -11,6 +11,9 @@ "DEADLINE_EXCEEDED", "INTERNAL", "UNAVAILABLE" + ], + "unavailable": [ + "UNAVAILABLE" ] }, "retry_params": { @@ -37,7 +40,7 @@ }, "UpdateDocument": { "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", + "retry_codes_name": "unavailable", "retry_params_name": "default" }, "DeleteDocument": { @@ -57,7 +60,7 @@ }, "Commit": { "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", + "retry_codes_name": "unavailable", "retry_params_name": "default" }, "Rollback": { @@ -95,7 +98,7 @@ }, "CreateDocument": { "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", + "retry_codes_name": "unavailable", "retry_params_name": "default" } } diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index 3ebaac25b..ca2a5a2e9 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -116,16 +116,20 @@ export class FirestoreClient { } opts.servicePath = opts.servicePath || servicePath; 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 // sent to the client. @@ -266,9 +270,7 @@ export class FirestoreClient { const callPromise = this.firestoreStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { - return Promise.reject( - new Error('The client has already been closed.') - ); + return Promise.reject('The client has already been closed.'); } const func = stub[methodName]; return func.apply(stub, args); diff --git a/samples/README.md b/samples/README.md index b34c2473e..48d2baf5e 100644 --- a/samples/README.md +++ b/samples/README.md @@ -20,6 +20,7 @@ Applications that use Google's Server SDKs should not be used in end-user e * [Before you begin](#before-you-begin) * [Samples](#samples) + * [Limit-to-last-query](#limit-to-last-query) * [Quickstart](#quickstart) * [Solution-counters](#solution-counters) @@ -38,6 +39,23 @@ Before running the samples, make sure you've followed the steps outlined in +### Limit-to-last-query + +View the [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) + +__Usage:__ + + +`node samples/limit-to-last-query.js` + + +----- + + + + ### Quickstart View the [source code](https://github.com/googleapis/nodejs-firestore/blob/master/samples/quickstart.js). diff --git a/synth.metadata b/synth.metadata index a01f262a6..127de1069 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,22 +4,22 @@ "git": { "name": ".", "remote": "git@github.com:googleapis/nodejs-firestore.git", - "sha": "ea5efde27605df068277fa2ffcd0ca4a95f01450" + "sha": "b71de4ab955252536bed37fb69f9731d2a499db9" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "d5fe42c39cd35f95131a0267314ae108ab1bef8d", - "internalRef": "314471006" + "sha": "a60b165895ad1f100d7014c74b7df512f9377fdb", + "internalRef": "318104666" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "f06a850db98490bf90c6a476d3f4c6c7cdfb1e5e" + "sha": "ce68c0e70d36c93ffcde96e9908fb4d94aa4f2e4" } } ], diff --git a/synth.py b/synth.py index ec1fbdafe..9de2ef1db 100644 --- a/synth.py +++ b/synth.py @@ -159,7 +159,7 @@ source_location="build/src", test_project="node-gcloud-ci" ) -s.copy(templates, excludes=[".eslintrc.json"]) +s.copy(templates, excludes=[".eslintrc.json", ".kokoro/**/*"]) # Remove auto-generated packaging tests os.system('rm -rf dev/system-test/fixtures dev/system-test/install.ts') From bab9d3a64b3822d8a6afcb06e18c3ce40db2861b Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 24 Jun 2020 14:13:58 -0700 Subject: [PATCH 144/337] chore: release 4.0.0 (#1234) --- CHANGELOG.md | 19 +++++++++++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b09304d9..5bb68093e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,25 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [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) diff --git a/package.json b/package.json index 8c3b4abd0..b2b366ffb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "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": { diff --git a/samples/package.json b/samples/package.json index e130e6dc4..1e82ea9e2 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^3.8.6" + "@google-cloud/firestore": "^4.0.0" }, "devDependencies": { "chai": "^4.2.0", From 1dbc77cc2e4e6a0be9f1b72c75ac35fc4b913df2 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Thu, 25 Jun 2020 14:22:56 -0700 Subject: [PATCH 145/337] chore: run synthtool (#1242) --- dev/protos/firestore_v1_proto_api.d.ts | 94 ++++----- dev/protos/firestore_v1_proto_api.js | 226 ++++++++++----------- dev/protos/google/firestore/v1/query.proto | 18 +- dev/protos/protos.json | 24 +-- dev/src/v1/firestore_client_config.json | 7 +- synth.metadata | 6 +- 6 files changed, 190 insertions(+), 185 deletions(-) diff --git a/dev/protos/firestore_v1_proto_api.d.ts b/dev/protos/firestore_v1_proto_api.d.ts index adde59dfa..6cc2c9a8f 100644 --- a/dev/protos/firestore_v1_proto_api.d.ts +++ b/dev/protos/firestore_v1_proto_api.d.ts @@ -5531,53 +5531,6 @@ export namespace google { "OPERATOR_UNSPECIFIED"| "IS_NAN"| "IS_NULL"; } - /** Properties of an Order. */ - interface IOrder { - - /** Order field */ - field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); - - /** Order direction */ - direction?: (google.firestore.v1.StructuredQuery.Direction|null); - } - - /** Represents an Order. */ - class Order implements IOrder { - - /** - * Constructs a new Order. - * @param [properties] Properties to set - */ - constructor(properties?: google.firestore.v1.StructuredQuery.IOrder); - - /** Order field. */ - public field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); - - /** Order direction. */ - public direction: google.firestore.v1.StructuredQuery.Direction; - - /** - * Creates an Order message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns Order - */ - public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.Order; - - /** - * Creates a plain object from an Order message. Also converts values to other types if specified. - * @param message Order - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: google.firestore.v1.StructuredQuery.Order, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this Order to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - } - /** Properties of a FieldReference. */ interface IFieldReference { @@ -5660,6 +5613,53 @@ export namespace google { public toJSON(): { [k: string]: any }; } + /** Properties of an Order. */ + interface IOrder { + + /** Order field */ + field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); + + /** Order direction */ + direction?: (google.firestore.v1.StructuredQuery.Direction|null); + } + + /** Represents an Order. */ + class Order implements IOrder { + + /** + * Constructs a new Order. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.StructuredQuery.IOrder); + + /** Order field. */ + public field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); + + /** Order direction. */ + public direction: google.firestore.v1.StructuredQuery.Direction; + + /** + * Creates an Order message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Order + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.Order; + + /** + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @param message Order + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.Order, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Order to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + /** Direction enum. */ type Direction = "DIRECTION_UNSPECIFIED"| "ASCENDING"| "DESCENDING"; diff --git a/dev/protos/firestore_v1_proto_api.js b/dev/protos/firestore_v1_proto_api.js index bf33044b0..83155cfba 100644 --- a/dev/protos/firestore_v1_proto_api.js +++ b/dev/protos/firestore_v1_proto_api.js @@ -13329,119 +13329,6 @@ return UnaryFilter; })(); - StructuredQuery.Order = (function() { - - /** - * Properties of an Order. - * @memberof google.firestore.v1.StructuredQuery - * @interface IOrder - * @property {google.firestore.v1.StructuredQuery.IFieldReference|null} [field] Order field - * @property {google.firestore.v1.StructuredQuery.Direction|null} [direction] Order direction - */ - - /** - * Constructs a new Order. - * @memberof google.firestore.v1.StructuredQuery - * @classdesc Represents an Order. - * @implements IOrder - * @constructor - * @param {google.firestore.v1.StructuredQuery.IOrder=} [properties] Properties to set - */ - function Order(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Order field. - * @member {google.firestore.v1.StructuredQuery.IFieldReference|null|undefined} field - * @memberof google.firestore.v1.StructuredQuery.Order - * @instance - */ - Order.prototype.field = null; - - /** - * Order direction. - * @member {google.firestore.v1.StructuredQuery.Direction} direction - * @memberof google.firestore.v1.StructuredQuery.Order - * @instance - */ - Order.prototype.direction = 0; - - /** - * Creates an Order message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.firestore.v1.StructuredQuery.Order - * @static - * @param {Object.} object Plain object - * @returns {google.firestore.v1.StructuredQuery.Order} Order - */ - Order.fromObject = function fromObject(object) { - if (object instanceof $root.google.firestore.v1.StructuredQuery.Order) - return object; - var message = new $root.google.firestore.v1.StructuredQuery.Order(); - if (object.field != null) { - if (typeof object.field !== "object") - throw TypeError(".google.firestore.v1.StructuredQuery.Order.field: object expected"); - message.field = $root.google.firestore.v1.StructuredQuery.FieldReference.fromObject(object.field); - } - switch (object.direction) { - case "DIRECTION_UNSPECIFIED": - case 0: - message.direction = 0; - break; - case "ASCENDING": - case 1: - message.direction = 1; - break; - case "DESCENDING": - case 2: - message.direction = 2; - break; - } - return message; - }; - - /** - * Creates a plain object from an Order message. Also converts values to other types if specified. - * @function toObject - * @memberof google.firestore.v1.StructuredQuery.Order - * @static - * @param {google.firestore.v1.StructuredQuery.Order} message Order - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Order.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.field = null; - object.direction = options.enums === String ? "DIRECTION_UNSPECIFIED" : 0; - } - if (message.field != null && message.hasOwnProperty("field")) - object.field = $root.google.firestore.v1.StructuredQuery.FieldReference.toObject(message.field, options); - if (message.direction != null && message.hasOwnProperty("direction")) - object.direction = options.enums === String ? $root.google.firestore.v1.StructuredQuery.Direction[message.direction] : message.direction; - return object; - }; - - /** - * Converts this Order to JSON. - * @function toJSON - * @memberof google.firestore.v1.StructuredQuery.Order - * @instance - * @returns {Object.} JSON object - */ - Order.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Order; - })(); - StructuredQuery.FieldReference = (function() { /** @@ -13620,6 +13507,119 @@ return Projection; })(); + StructuredQuery.Order = (function() { + + /** + * Properties of an Order. + * @memberof google.firestore.v1.StructuredQuery + * @interface IOrder + * @property {google.firestore.v1.StructuredQuery.IFieldReference|null} [field] Order field + * @property {google.firestore.v1.StructuredQuery.Direction|null} [direction] Order direction + */ + + /** + * Constructs a new Order. + * @memberof google.firestore.v1.StructuredQuery + * @classdesc Represents an Order. + * @implements IOrder + * @constructor + * @param {google.firestore.v1.StructuredQuery.IOrder=} [properties] Properties to set + */ + function Order(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Order field. + * @member {google.firestore.v1.StructuredQuery.IFieldReference|null|undefined} field + * @memberof google.firestore.v1.StructuredQuery.Order + * @instance + */ + Order.prototype.field = null; + + /** + * Order direction. + * @member {google.firestore.v1.StructuredQuery.Direction} direction + * @memberof google.firestore.v1.StructuredQuery.Order + * @instance + */ + Order.prototype.direction = 0; + + /** + * Creates an Order message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.StructuredQuery.Order + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.StructuredQuery.Order} Order + */ + Order.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.StructuredQuery.Order) + return object; + var message = new $root.google.firestore.v1.StructuredQuery.Order(); + if (object.field != null) { + if (typeof object.field !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.Order.field: object expected"); + message.field = $root.google.firestore.v1.StructuredQuery.FieldReference.fromObject(object.field); + } + switch (object.direction) { + case "DIRECTION_UNSPECIFIED": + case 0: + message.direction = 0; + break; + case "ASCENDING": + case 1: + message.direction = 1; + break; + case "DESCENDING": + case 2: + message.direction = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.StructuredQuery.Order + * @static + * @param {google.firestore.v1.StructuredQuery.Order} message Order + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Order.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.field = null; + object.direction = options.enums === String ? "DIRECTION_UNSPECIFIED" : 0; + } + if (message.field != null && message.hasOwnProperty("field")) + object.field = $root.google.firestore.v1.StructuredQuery.FieldReference.toObject(message.field, options); + if (message.direction != null && message.hasOwnProperty("direction")) + object.direction = options.enums === String ? $root.google.firestore.v1.StructuredQuery.Direction[message.direction] : message.direction; + return object; + }; + + /** + * Converts this Order to JSON. + * @function toJSON + * @memberof google.firestore.v1.StructuredQuery.Order + * @instance + * @returns {Object.} JSON object + */ + Order.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Order; + })(); + /** * Direction enum. * @name google.firestore.v1.StructuredQuery.Direction diff --git a/dev/protos/google/firestore/v1/query.proto b/dev/protos/google/firestore/v1/query.proto index 557fbad1b..9c267fe68 100644 --- a/dev/protos/google/firestore/v1/query.proto +++ b/dev/protos/google/firestore/v1/query.proto @@ -170,15 +170,6 @@ message StructuredQuery { } } - // An order on a field. - message Order { - // The field to order by. - FieldReference field = 1; - - // The direction to order by. Defaults to `ASCENDING`. - Direction direction = 2; - } - // A reference to a field, such as `max(messages.time) as max_time`. message FieldReference { string field_path = 2; @@ -193,6 +184,15 @@ message StructuredQuery { repeated FieldReference fields = 2; } + // An order on a field. + message Order { + // The field to order by. + FieldReference field = 1; + + // The direction to order by. Defaults to `ASCENDING`. + Direction direction = 2; + } + // A sort direction. enum Direction { // Unspecified. diff --git a/dev/protos/protos.json b/dev/protos/protos.json index 56d5a1d9b..fb07f7b58 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -1807,18 +1807,6 @@ } } }, - "Order": { - "fields": { - "field": { - "type": "FieldReference", - "id": 1 - }, - "direction": { - "type": "Direction", - "id": 2 - } - } - }, "FieldReference": { "fields": { "fieldPath": { @@ -1836,6 +1824,18 @@ } } }, + "Order": { + "fields": { + "field": { + "type": "FieldReference", + "id": 1 + }, + "direction": { + "type": "Direction", + "id": 2 + } + } + }, "Direction": { "values": { "DIRECTION_UNSPECIFIED": 0, diff --git a/dev/src/v1/firestore_client_config.json b/dev/src/v1/firestore_client_config.json index 9feba0d63..f3f8938bb 100644 --- a/dev/src/v1/firestore_client_config.json +++ b/dev/src/v1/firestore_client_config.json @@ -14,6 +14,10 @@ ], "unavailable": [ "UNAVAILABLE" + ], + "aborted_unavailable": [ + "ABORTED", + "UNAVAILABLE" ] }, "retry_params": { @@ -93,7 +97,8 @@ "retry_params_name": "default" }, "BatchWrite": { - "retry_codes_name": "non_idempotent", + "timeout_millis": 60000, + "retry_codes_name": "aborted_unavailable", "retry_params_name": "default" }, "CreateDocument": { diff --git a/synth.metadata b/synth.metadata index 127de1069..c1eaf2d1a 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "git@github.com:googleapis/nodejs-firestore.git", - "sha": "b71de4ab955252536bed37fb69f9731d2a499db9" + "sha": "bab9d3a64b3822d8a6afcb06e18c3ce40db2861b" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "a60b165895ad1f100d7014c74b7df512f9377fdb", - "internalRef": "318104666" + "sha": "0a602be7b3835b51d59daf8f6f5dc2dc22f69d7e", + "internalRef": "318331819" } }, { From b83874cfb27e6e8538197aa3643775e26dc7088f Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Sat, 27 Jun 2020 17:46:10 -0700 Subject: [PATCH 146/337] build: add config .gitattributes (#1247) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/2a81bca4-7abd-4108-ac1f-21340f858709/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: https://github.com/googleapis/synthtool/commit/dc9caca650c77b7039e2bbc3339ffb34ae78e5b7 --- .gitattributes | 3 +++ synth.metadata | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..2e63216ae --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +*.ts text eol=lf +*.js test eol=lf +protos/* linguist-generated diff --git a/synth.metadata b/synth.metadata index c1eaf2d1a..5904f0e1f 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,8 +3,8 @@ { "git": { "name": ".", - "remote": "git@github.com:googleapis/nodejs-firestore.git", - "sha": "bab9d3a64b3822d8a6afcb06e18c3ce40db2861b" + "remote": "https://github.com/googleapis/nodejs-firestore.git", + "sha": "1dbc77cc2e4e6a0be9f1b72c75ac35fc4b913df2" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "ce68c0e70d36c93ffcde96e9908fb4d94aa4f2e4" + "sha": "dc9caca650c77b7039e2bbc3339ffb34ae78e5b7" } } ], From 6007e43dd51bdc29744fa07daef2e4ac1089a1dc Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Mon, 29 Jun 2020 11:43:46 -0700 Subject: [PATCH 147/337] fix: retry ABORTED writes in bulkCommit (#1243) --- dev/src/bulk-writer.ts | 155 +++++++++++++++++++++++++++------------- dev/src/write-batch.ts | 50 +++++++++---- dev/test/bulk-writer.ts | 143 +++++++++++++++++++++++++++++++++--- dev/test/write-batch.ts | 4 +- 4 files changed, 277 insertions(+), 75 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 227cf3256..788c78508 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -14,16 +14,22 @@ * limitations under the License. */ import * as firestore from '@google-cloud/firestore'; +import {Status} from 'google-gax'; import * as assert from 'assert'; import {FieldPath, Firestore} from '.'; -import {delayExecution} from './backoff'; +import { + delayExecution, + ExponentialBackoff, + MAX_RETRY_ATTEMPTS, +} from './backoff'; import {RateLimiter} from './rate-limiter'; import {DocumentReference} from './reference'; import {Timestamp} from './timestamp'; -import {Deferred, wrapError} from './util'; +import {Deferred, getRetryCodes, wrapError} from './util'; import {BatchWriteResult, WriteBatch, WriteResult} from './write-batch'; +import {logger} from './logger'; /*! * The maximum number of writes that can be in a single batch. @@ -76,27 +82,29 @@ class BulkCommitBatch { */ state = BatchState.OPEN; - // The set of document reference paths present in the WriteBatch. - readonly docPaths = new Set(); - // A deferred promise that is resolved after the batch has been sent, and a // response is received. private completedDeferred = new Deferred(); - // A map from each WriteBatch operation to its corresponding result. - private resultsMap = new Map>(); + // A map from each write's document path to its corresponding result. + // Only contains writes that have not been resolved. + private pendingOps = new Map>(); + + private readonly backoff: ExponentialBackoff; constructor( private readonly firestore: Firestore, - private readonly writeBatch: WriteBatch, + private writeBatch: WriteBatch, private readonly maxBatchSize: number - ) {} + ) { + this.backoff = new ExponentialBackoff(); + } /** * The number of writes in this batch. */ get opCount(): number { - return this.resultsMap.size; + return this.pendingOps.size; } /** @@ -173,16 +181,15 @@ class BulkCommitBatch { documentRef: firestore.DocumentReference ): Promise { assert( - !this.docPaths.has(documentRef.path), + !this.pendingOps.has(documentRef.path), 'Batch should not contain writes to the same document' ); assert( this.state === BatchState.OPEN, 'Batch should be OPEN when adding writes' ); - this.docPaths.add(documentRef.path); const deferred = new Deferred(); - this.resultsMap.set(this.opCount, deferred); + this.pendingOps.set(documentRef.path, deferred); if (this.opCount === this.maxBatchSize) { this.state = BatchState.READY_TO_SEND; @@ -198,10 +205,13 @@ class BulkCommitBatch { } /** - * Commits the batch and returns a promise that resolves with the result of - * all writes in this batch. + * Commits the batch and returns a promise that resolves when all the writes + * in the batch have finished. + * + * If any writes in the batch fail with a retryable error, this method will + * retry the failed writes. */ - bulkCommit(): Promise { + async bulkCommit(): Promise { assert( this.state === BatchState.READY_TO_SEND, 'The batch should be marked as READY_TO_SEND before committing' @@ -211,25 +221,81 @@ class BulkCommitBatch { // Capture the error stack to preserve stack tracing across async calls. const stack = Error().stack!; - return this.writeBatch.bulkCommit().catch(err => { - throw wrapError(err, stack); - }); + let results: BatchWriteResult[] = []; + for (let attempt = 0; attempt < MAX_RETRY_ATTEMPTS; attempt++) { + await this.backoff.backoffAndWait(); + + try { + results = await this.writeBatch.bulkCommit(); + } catch (err) { + // Map the failure to each individual write's result. + results = [...this.pendingOps.keys()].map(path => { + return {key: path, writeTime: null, status: wrapError(err, stack)}; + }); + } + this.processResults(results); + + if (this.pendingOps.size > 0) { + logger( + 'BulkWriter.bulkCommit', + null, + `Current batch failed at retry #${attempt}. Num failures: ` + + `${this.pendingOps.size}.` + ); + + this.writeBatch = new WriteBatch(this.firestore, this.writeBatch, [ + ...this.pendingOps.keys(), + ]); + } else { + this.completedDeferred.resolve(); + return; + } + } + + this.failRemainingOperations(results); + this.completedDeferred.resolve(); } /** * Resolves the individual operations in the batch with the results. */ - processResults(results: BatchWriteResult[], error?: Error): void { - if (error === undefined) { - for (let i = 0; i < this.opCount; i++) { - this.resultsMap.get(i)!.resolve(results[i]); - } - } else { - for (let i = 0; i < this.opCount; i++) { - this.resultsMap.get(i)!.reject(error); + private processResults(results: BatchWriteResult[]): void { + for (const result of results) { + if (result.status.code === Status.OK) { + this.pendingOps.get(result.key)!.resolve(result); + this.pendingOps.delete(result.key); + } else if (!this.shouldRetry(result.status.code)) { + this.pendingOps.get(result.key)!.reject(result.status); + this.pendingOps.delete(result.key); } } - this.completedDeferred.resolve(); + } + + private failRemainingOperations(results: BatchWriteResult[]): void { + for (const result of results) { + assert( + result.status.code !== Status.OK, + 'Should not fail successful operation' + ); + this.pendingOps.get(result.key)!.reject(result.status); + this.pendingOps.delete(result.key); + } + } + + private shouldRetry(code: Status | undefined): boolean { + const retryCodes = getRetryCodes('batchWrite'); + return code !== undefined && retryCodes.includes(code); + } + + hasPath(path: string): boolean { + for (const [docPath] of this.pendingOps) { + if (docPath === path) return true; + } + return false; + } + + docPaths(): IterableIterator { + return this.pendingOps.keys(); } /** @@ -566,10 +632,7 @@ export class BulkWriter { ): BulkCommitBatch { if (this.batchQueue.length > 0) { const lastBatch = this.batchQueue[this.batchQueue.length - 1]; - if ( - lastBatch.state === BatchState.OPEN && - !lastBatch.docPaths.has(ref.path) - ) { + if (lastBatch.state === BatchState.OPEN && !lastBatch.hasPath(ref.path)) { return lastBatch; } } @@ -641,22 +704,14 @@ export class BulkWriter { private sendBatch(batch: BulkCommitBatch): void { const success = this.rateLimiter.tryMakeRequest(batch.opCount); assert(success, 'Batch should be under rate limit to be sent.'); - batch - .bulkCommit() - .then(results => { - batch.processResults(results); - }) - .catch((error: Error) => { - batch.processResults([], error); - }) - .then(() => { - // Remove the batch from the BatchQueue after it has been processed. - const batchIndex = this.batchQueue.indexOf(batch); - assert(batchIndex !== -1, 'The batch should be in the BatchQueue'); - this.batchQueue.splice(batchIndex, 1); - - this.sendReadyBatches(); - }); + batch.bulkCommit().then(() => { + // Remove the batch from the BatchQueue after it has been processed. + const batchIndex = this.batchQueue.indexOf(batch); + assert(batchIndex !== -1, 'The batch should be in the BatchQueue'); + this.batchQueue.splice(batchIndex, 1); + + this.sendReadyBatches(); + }); } /** @@ -671,11 +726,11 @@ export class BulkWriter { return false; } - for (const path of batch.docPaths) { + for (const path of batch.docPaths()) { const isRefInFlight = this.batchQueue .filter(batch => batch.state === BatchState.SENT) - .find(batch => batch.docPaths.has(path)) !== undefined; + .find(batch => batch.hasPath(path)) !== undefined; if (isRefInFlight) { // eslint-disable-next-line no-console console.warn( diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index af9f95465..77a819135 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -104,6 +104,7 @@ export class WriteResult implements firestore.WriteResult { */ export class BatchWriteResult { constructor( + readonly key: string, readonly writeTime: Timestamp | null, readonly status: GoogleError ) {} @@ -128,11 +129,13 @@ export class WriteBatch implements firestore.WriteBatch { private readonly _allowUndefined: boolean; /** - * An array of write operations that are executed as part of the commit. The - * resulting `api.IWrite` will be sent to the backend. + * An array of document paths and the corresponding write operations that are + * executed as part of the commit. The resulting `api.IWrite` will be sent to + * the backend. + * * @private */ - private readonly _ops: Array = []; + private readonly _ops: Array<{docPath: string; op: PendingWriteOp}> = []; private _committed = false; @@ -140,11 +143,32 @@ export class WriteBatch implements firestore.WriteBatch { * @hideconstructor * * @param firestore The Firestore Database client. + * @param retryBatch The WriteBatch that needs to be retried. + * @param docsToRetry The documents from the provided WriteBatch that need + * to be retried. */ - constructor(firestore: Firestore) { + constructor( + firestore: Firestore, + retryBatch: WriteBatch, + docsToRetry: string[] + ); + constructor(firestore: Firestore); + constructor( + firestore: Firestore, + retryBatch?: WriteBatch, + docsToRetry?: string[] + ) { this._firestore = firestore; this._serializer = new Serializer(firestore); this._allowUndefined = !!firestore._settings.ignoreUndefinedProperties; + + if (retryBatch) { + // Creates a new WriteBatch containing only the operations from the + // provided document paths to retry. + this._ops = retryBatch._ops.filter( + v => docsToRetry!.indexOf(v.docPath) !== -1 + ); + } } /** @@ -214,7 +238,7 @@ export class WriteBatch implements firestore.WriteBatch { return write; }; - this._ops.push(op); + this._ops.push({docPath: documentRef.path, op}); return this; } @@ -261,7 +285,7 @@ export class WriteBatch implements firestore.WriteBatch { return write; }; - this._ops.push(op); + this._ops.push({docPath: documentRef.path, op}); return this; } @@ -362,7 +386,7 @@ export class WriteBatch implements firestore.WriteBatch { return write; }; - this._ops.push(op); + this._ops.push({docPath: documentRef.path, op}); return this; } @@ -518,7 +542,7 @@ export class WriteBatch implements firestore.WriteBatch { return write; }; - this._ops.push(op); + this._ops.push({docPath: documentRef.path, op}); return this; } @@ -566,17 +590,17 @@ export class WriteBatch implements firestore.WriteBatch { const database = this._firestore.formattedName; const request: api.IBatchWriteRequest = { database, - writes: this._ops.map(op => op()), + writes: this._ops.map(op => op.op()), }; - const retryCodes = [Status.ABORTED, ...getRetryCodes('commit')]; + const retryCodes = getRetryCodes('batchWrite'); const response = await this._firestore.request< api.IBatchWriteRequest, api.BatchWriteResponse >('batchWrite', request, tag, retryCodes); - return (response.writeResults || []).map((result, i) => { + return response.writeResults.map((result, i) => { const status = response.status[i]; const error = new GoogleError(status.message || undefined); error.code = status.code as Status; @@ -589,7 +613,7 @@ export class WriteBatch implements firestore.WriteBatch { error.code === Status.OK ? Timestamp.fromProto(result.updateTime || DELETE_TIMESTAMP_SENTINEL) : null; - return new BatchWriteResult(updateTime, error); + return new BatchWriteResult(this._ops[i].docPath, updateTime, error); }); } @@ -618,7 +642,7 @@ export class WriteBatch implements firestore.WriteBatch { const request: api.ICommitRequest = { database, - writes: this._ops.map(op => op()), + writes: this._ops.map(op => op.op()), }; if (commitOptions?.transactionId) { request.transaction = commitOptions.transactionId; diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index 167fd6117..976febd13 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -14,9 +14,9 @@ import {DocumentData} from '@google-cloud/firestore'; -import {describe, it, beforeEach, afterEach} from 'mocha'; +import {afterEach, beforeEach, describe, it} from 'mocha'; import {expect} from 'chai'; -import {Status} from 'google-gax'; +import {GoogleError, Status} from 'google-gax'; import * as proto from '../protos/firestore_v1_proto_api'; import {Firestore, setLogFunction, Timestamp, WriteResult} from '../src'; @@ -61,8 +61,13 @@ describe('BulkWriter', () => { requestCounter = 0; opCount = 0; timeoutHandlerCounter = 0; - setTimeoutHandler(fn => { - timeoutHandlerCounter++; + setTimeoutHandler((fn, timeout) => { + // Since a call to the backoff is made before each batchWrite, only + // increment the counter if the timeout is non-zero, which indicates a + // retry from an error. + if (timeout > 0) { + timeoutHandlerCounter++; + } fn(); }); }); @@ -118,14 +123,16 @@ describe('BulkWriter', () => { }; } - function failedResponse(): api.IBatchWriteResponse { + function failedResponse( + code = Status.DEADLINE_EXCEEDED + ): api.IBatchWriteResponse { return { writeResults: [ { updateTime: null, }, ], - status: [{code: Status.UNAVAILABLE}], + status: [{code}], }; } @@ -274,7 +281,7 @@ describe('BulkWriter', () => { const doc = firestore.doc('collectionId/doc'); bulkWriter.set(doc, {foo: 'bar'}).catch(err => { incrementOpCount(); - expect(err.code).to.equal(Status.UNAVAILABLE); + expect(err.code).to.equal(Status.DEADLINE_EXCEEDED); }); return bulkWriter.close().then(async () => verifyOpCount(1)); @@ -557,7 +564,56 @@ describe('BulkWriter', () => { return bulkWriter.close().then(() => verifyOpCount(2)); }); - describe('500/50/5 support', () => { + it('retries individual rites that fail with ABORTED errors', async () => { + setTimeoutHandler(setImmediate); + // Create mock responses that simulate one successful write followed by + // failed responses. + const bulkWriter = await instantiateInstance([ + { + request: createRequest([ + setOp('doc1', 'bar'), + setOp('doc2', 'bar'), + setOp('doc3', 'bar'), + ]), + response: mergeResponses([ + failedResponse(), + failedResponse(Status.UNAVAILABLE), + failedResponse(Status.ABORTED), + ]), + }, + { + request: createRequest([setOp('doc2', 'bar'), setOp('doc3', 'bar')]), + response: mergeResponses([ + successResponse(2), + failedResponse(Status.ABORTED), + ]), + }, + { + request: createRequest([setOp('doc3', 'bar')]), + response: mergeResponses([successResponse(3)]), + }, + ]); + + bulkWriter + .set(firestore.doc('collectionId/doc1'), { + foo: 'bar', + }) + .catch(incrementOpCount); + const set2 = bulkWriter.set(firestore.doc('collectionId/doc2'), { + foo: 'bar', + }); + const set3 = bulkWriter.set(firestore.doc('collectionId/doc3'), { + foo: 'bar', + }); + await bulkWriter.close(); + expect((await set2).writeTime).to.deep.equal(new Timestamp(2, 0)); + expect((await set3).writeTime).to.deep.equal(new Timestamp(3, 0)); + + // Check that set1 was not retried + verifyOpCount(1); + }); + + describe('Timeout handler tests', () => { // Return success responses for all requests. function instantiateInstance(): Promise { const overrides: ApiOverride = { @@ -582,9 +638,8 @@ describe('BulkWriter', () => { instantiateInstance().then(bulkWriter => { let timeoutCalled = false; setTimeoutHandler((_, timeout) => { - if (!timeoutCalled) { + if (!timeoutCalled && timeout > 0) { timeoutCalled = true; - expect(timeout).to.be.greaterThan(0); done(); } }); @@ -601,6 +656,74 @@ describe('BulkWriter', () => { }); }); + it('retries batchWrite when the RPC fails with retryable error', async () => { + setTimeoutHandler(setImmediate); + let retryAttempts = 0; + function instantiateInstance(): Promise { + const overrides: ApiOverride = { + batchWrite: () => { + retryAttempts++; + if (retryAttempts < 5) { + const error = new GoogleError('Mock batchWrite failed in test'); + error.code = Status.ABORTED; + throw error; + } else { + const mockResponse = successResponse(1); + return response({ + writeResults: mockResponse.writeResults, + status: mockResponse.status, + }); + } + }, + }; + return createInstance(overrides).then(firestoreClient => { + firestore = firestoreClient; + return firestore._bulkWriter(); + }); + } + const bulkWriter = await instantiateInstance(); + let writeResult: WriteResult; + bulkWriter + .create(firestore.doc('collectionId/doc'), { + foo: 'bar', + }) + .then(result => { + incrementOpCount(); + writeResult = result; + }); + return bulkWriter.close().then(async () => { + expect(writeResult.writeTime.isEqual(new Timestamp(1, 0))).to.be.true; + }); + }); + + it('fails writes after all retry attempts failed', async () => { + setTimeoutHandler(setImmediate); + function instantiateInstance(): Promise { + const overrides: ApiOverride = { + batchWrite: () => { + const error = new GoogleError('Mock batchWrite failed in test'); + error.code = Status.ABORTED; + throw error; + }, + }; + return createInstance(overrides).then(firestoreClient => { + firestore = firestoreClient; + return firestore._bulkWriter(); + }); + } + const bulkWriter = await instantiateInstance(); + bulkWriter + .create(firestore.doc('collectionId/doc'), { + foo: 'bar', + }) + .catch(err => { + expect(err instanceof GoogleError && err.code === Status.ABORTED).to.be + .true; + incrementOpCount(); + }); + return bulkWriter.close().then(() => verifyOpCount(1)); + }); + describe('if bulkCommit() fails', async () => { function instantiateInstance(): Promise { const overrides: ApiOverride = { diff --git a/dev/test/write-batch.ts b/dev/test/write-batch.ts index 7ad58cfdc..ffcc2f392 100644 --- a/dev/test/write-batch.ts +++ b/dev/test/write-batch.ts @@ -491,7 +491,7 @@ describe('bulkCommit support', () => { updateTime: null, }, ], - status: [{code: 0}, {code: 14}], + status: [{code: 0}, {code: 4}], }); }, }; @@ -507,7 +507,7 @@ describe('bulkCommit support', () => { expect(writeResults[0].writeTime!.isEqual(new Timestamp(0, 0))).to.be.true; expect(writeResults[1].writeTime).to.be.null; expect(writeResults[0].status.code).to.equal(Status.OK); - expect(writeResults[1].status.code).to.equal(Status.UNAVAILABLE); + expect(writeResults[1].status.code).to.equal(Status.DEADLINE_EXCEEDED); } it('bulkCommit', () => { From 51d7633d758a532656066bf4ac8ef8c70f89fb86 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Mon, 29 Jun 2020 14:40:56 -0700 Subject: [PATCH 148/337] fix: update maximum batch size in BulkWriter (#1250) --- dev/src/bulk-writer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 788c78508..5444671bc 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -34,7 +34,7 @@ import {logger} from './logger'; /*! * The maximum number of writes that can be in a single batch. */ -const MAX_BATCH_SIZE = 500; +const MAX_BATCH_SIZE = 20; /*! * The starting maximum number of operations per second as allowed by the From c324bdbb9a42af0ae7d1b5da23a7022f15a4b7ef Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 30 Jun 2020 15:40:41 -0700 Subject: [PATCH 149/337] feat: add deprecation message to WriteBatch (#1251) --- dev/src/index.ts | 4 ++++ dev/src/write-batch.ts | 4 ++++ types/firestore.d.ts | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/dev/src/index.ts b/dev/src/index.ts index f684d15eb..7d9cf58fe 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -659,6 +659,10 @@ export class Firestore implements firestore.Firestore { * @returns {WriteBatch} A WriteBatch that operates on this Firestore * client. * + * @deprecated This class is now deprecated. Use `runTransaction()` to update + * multiple documents atomically or `bulkWriter()` to update a large number + * of documents in parallel. + * * @example * let writeBatch = firestore.batch(); * diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 77a819135..74119736c 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -121,6 +121,10 @@ type PendingWriteOp = () => api.IWrite; * A Firestore WriteBatch that can be used to atomically commit multiple write * operations at once. * + * @deprecated This class is now deprecated. Use `runTransaction()` to update + * multiple documents atomically or `bulkWriter()` to update a large number + * of documents in parallel. + * * @class */ export class WriteBatch implements firestore.WriteBatch { diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 822223cc8..3f819d2d0 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -284,6 +284,10 @@ declare namespace FirebaseFirestore { /** * Creates a write batch, used for performing multiple writes as a single * atomic operation. + * + * @deprecated This class is now deprecated. Use `runTransaction()` to update + * multiple documents atomically or `bulkWriter()` to update a large number + * of documents in parallel. */ batch(): WriteBatch; } @@ -458,6 +462,10 @@ declare namespace FirebaseFirestore { * * Unlike transactions, write batches are persisted offline and therefore are * preferable when you don't need to condition your writes on read data. + * + * @deprecated This class is now deprecated. Use `runTransaction()` to update + * multiple documents atomically or `bulkWriter()` to update a large number + * of documents in parallel. */ export class WriteBatch { private constructor(); From 0d20c84a468104814900c0264bf8f86a1ea40d8c Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Mon, 6 Jul 2020 11:20:14 -0700 Subject: [PATCH 150/337] chore: update CODEOWNERS (#1254) --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 39a8fc72b..7aad1ccc4 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -7,4 +7,4 @@ # The firestore-dpe team is the default owner for anything not # explicitly taken by someone else. -* @googleapis/firestore-dpe +* @googleapis/firestore-dpe @googleapis/yoshi-nodejs From eb4d84c9c05e9556cddf892a4df3322d44f26089 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 7 Jul 2020 22:49:38 +0200 Subject: [PATCH 151/337] chore(deps): update dependency through2 to v4 (#1246) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b2b366ffb..967544109 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,6 @@ "sinon": "^9.0.2", "ts-node": "^8.5.4", "typescript": "3.8.3", - "through2": "^3.0.0" + "through2": "^4.0.0" } } From d0c6c4b116e096a1bb59c89de26cedb8cf5f1224 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 7 Jul 2020 15:37:34 -0700 Subject: [PATCH 152/337] feat: make BulkWriter public (#1252) --- dev/src/bulk-writer.ts | 1 - dev/src/index.ts | 6 +- dev/src/types.ts | 9 --- dev/system-test/firestore.ts | 4 +- dev/test/bulk-writer.ts | 10 +-- types/firestore.d.ts | 145 +++++++++++++++++++++++++++++++++++ 6 files changed, 154 insertions(+), 21 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 5444671bc..598f45da4 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -319,7 +319,6 @@ class BulkCommitBatch { * in parallel. Writes to the same document will be executed sequentially. * * @class - * @private */ export class BulkWriter { /** diff --git a/dev/src/index.ts b/dev/src/index.ts index 7d9cf58fe..32997e695 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -47,7 +47,6 @@ import {Timestamp} from './timestamp'; import {parseGetAllArguments, Transaction} from './transaction'; import { ApiMapValue, - BulkWriterOptions, FirestoreStreamingMethod, FirestoreUnaryMethod, GapicClient, @@ -83,6 +82,7 @@ export { QuerySnapshot, Query, } from './reference'; +export {BulkWriter} from './bulk-writer'; export {DocumentSnapshot, QueryDocumentSnapshot} from './document'; export {FieldValue} from './field-value'; export {WriteBatch, WriteResult} from './write-batch'; @@ -92,7 +92,6 @@ export {DocumentChange} from './document-change'; export {FieldPath} from './path'; export {GeoPoint} from './geo-point'; export {setLogFunction} from './logger'; -export {BulkWriterOptions} from './types'; export {Status as GrpcStatus} from 'google-gax'; const libVersion = require('../../package.json').version; @@ -686,7 +685,6 @@ export class Firestore implements firestore.Firestore { * * @see [500/50/5 Documentation]{@link https://cloud.google.com/datastore/docs/best-practices#ramping_up_traffic} * - * @private * @param {object=} options BulkWriter options. * @param {boolean=} options.disableThrottling Whether to disable throttling * as specified by the 500/50/5 rule. @@ -712,7 +710,7 @@ export class Firestore implements firestore.Firestore { * console.log('Executed all writes'); * }); */ - _bulkWriter(options?: BulkWriterOptions): BulkWriter { + bulkWriter(options?: firestore.BulkWriterOptions): BulkWriter { return new BulkWriter(this, !options?.disableThrottling); } diff --git a/dev/src/types.ts b/dev/src/types.ts index 1048c9b9e..ab5a359fa 100644 --- a/dev/src/types.ts +++ b/dev/src/types.ts @@ -147,15 +147,6 @@ export interface ValidationOptions { allowUndefined: boolean; } -/** - * An options object that can be used to disable request throttling in - * BulkWriter. - */ -export interface BulkWriterOptions { - /** Whether to disable throttling. */ - readonly disableThrottling?: boolean; -} - /** * A Firestore Proto value in ProtoJs format. * @private diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index b94c4dd1e..f1096d837 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -183,7 +183,7 @@ describe('Firestore class', () => { }); it('throws an error if terminate() is called with pending BulkWriter operations', async () => { - const writer = firestore._bulkWriter(); + const writer = firestore.bulkWriter(); const ref = randomCol.doc('doc-1'); writer.set(ref, {foo: 'bar'}); await expect(firestore.terminate()).to.eventually.be.rejectedWith( @@ -2334,7 +2334,7 @@ describe('BulkWriter class', () => { beforeEach(() => { firestore = new Firestore({}); - writer = firestore._bulkWriter(); + writer = firestore.bulkWriter(); randomCol = getTestRoot(firestore); }); diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index 976febd13..30bd178c1 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -184,7 +184,7 @@ describe('BulkWriter', () => { }; return createInstance(overrides).then(firestoreClient => { firestore = firestoreClient; - return firestore._bulkWriter(); + return firestore.bulkWriter(); }); } @@ -630,7 +630,7 @@ describe('BulkWriter', () => { }; return createInstance(overrides).then(firestoreClient => { firestore = firestoreClient; - return firestore._bulkWriter(); + return firestore.bulkWriter(); }); } @@ -678,7 +678,7 @@ describe('BulkWriter', () => { }; return createInstance(overrides).then(firestoreClient => { firestore = firestoreClient; - return firestore._bulkWriter(); + return firestore.bulkWriter(); }); } const bulkWriter = await instantiateInstance(); @@ -708,7 +708,7 @@ describe('BulkWriter', () => { }; return createInstance(overrides).then(firestoreClient => { firestore = firestoreClient; - return firestore._bulkWriter(); + return firestore.bulkWriter(); }); } const bulkWriter = await instantiateInstance(); @@ -733,7 +733,7 @@ describe('BulkWriter', () => { }; return createInstance(overrides).then(firestoreClient => { firestore = firestoreClient; - return firestore._bulkWriter(); + return firestore.bulkWriter(); }); } it('flush() should not fail', async () => { diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 3f819d2d0..1fed3cb28 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -452,6 +452,151 @@ declare namespace FirebaseFirestore { ): Transaction; } + /** + * A Firestore BulkWriter than can be used to perform a large number of writes + * in parallel. Writes to the same document will be executed sequentially. + * + * @class + */ + export class BulkWriter { + private constructor(); + + /** + * Create a document with the provided data. This single operation will fail + * if a document exists at its location. + * + * @param documentRef A reference to the document to be + * created. + * @param data The object to serialize as the document. + * @returns A promise that resolves with the result + * of the write. Throws an error if the write fails. + */ + create( + documentRef: DocumentReference, + data: DocumentData + ): Promise; + + /** + * Delete a document from the database. + * + * @param documentRef A reference to the document to be + * deleted. + * @param precondition A precondition to enforce for this + * delete. + * @param precondition.lastUpdateTime If set, enforces that the + * document was last updated at lastUpdateTime. Fails the batch if the + * document doesn't exist or was last updated at a different time. + * @returns A promise that resolves with the result + * of the write. Throws an error if the write fails. + */ + delete( + documentRef: DocumentReference, + precondition?: Precondition + ): Promise; + + /** + * 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 documentRef A reference to the document to be + * set. + * @param data The object to serialize as the document. + * @param options An object to configure the set behavior. + * @param options.merge - If true, set() merges the values + * specified in its data argument. Fields omitted from this set() call + * remain untouched. + * @param options.mergeFields - If provided, + * set() only replaces the specified field paths. Any field path that is not + * specified is ignored and remains untouched. + * @returns A promise that resolves with the result + * of the write. Throws an error if the write fails. + */ + set( + documentRef: DocumentReference, + data: Partial, + options: SetOptions + ): Promise; + set(documentRef: DocumentReference, data: T): Promise; + + /** + * Update fields of the document referred to by the provided + * [DocumentReference]{@link DocumentReference}. If the document doesn't yet + * exist, the update fails and the entire batch will be rejected. + * + * The update() method accepts either an object with field paths encoded as + * keys and field values encoded as values, or a variable number of + * arguments that alternate between field paths and field values. Nested + * fields can be updated by providing dot-separated field path strings or by + * providing FieldPath objects. + * + * + * A Precondition restricting this update can be specified as the last + * argument. + * + * @param documentRef A reference to the document to be + * updated. + * @param dataOrField An object containing the + * fields and values with which to update the document or the path of the + * first field to update. + * @param preconditionOrValues - An + * alternating list of field paths and values to update or a Precondition to + * restrict this update + * @returns A promise that resolves with the result + * of the write. Throws an error if the write fails. + */ + update( + documentRef: DocumentReference, + dataOrField: UpdateData | string | FieldPath, + ...preconditionOrValues: Array< + {lastUpdateTime?: Timestamp} | unknown | string | FieldPath + > + ): Promise; + + /** + * Commits all writes that have been enqueued up to this point in parallel. + * + * Returns a Promise that resolves when all currently queued operations have + * been committed. The Promise will never be rejected since the results for + * each individual operation are conveyed via their individual Promises. + * + * The Promise resolves immediately if there are no pending writes. + * Otherwise, the Promise waits for all previously issued writes, but it + * does not wait for writes that were added after the method is called. If + * you want to wait for additional writes, call `flush()` again. + * + * @return A promise that resolves when all enqueued writes + * up to this point have been committed. + */ + flush(): Promise; + + /** + * Commits all enqueued writes and marks the BulkWriter instance as closed. + * + * After calling `close()`, calling any method wil throw an error. + * + * Returns a Promise that resolves when all writes have been committed. The + * Promise will never be rejected. Calling this method will send all + * requests. The promise resolves immediately if there are no pending + * writes. + * + * @return A promise that resolves when all enqueued writes + * up to this point have been committed. + */ + close(): Promise; + } + + /** + * An options object that can be used to disable request throttling in + * BulkWriter. + */ + export interface BulkWriterOptions { + /** Whether to disable throttling. */ + readonly disableThrottling?: boolean; + } + /** * A write batch, used to perform multiple writes as a single atomic unit. * From 3686816d4a98cabaee4bac089c34a335aa4ddbf8 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 8 Jul 2020 10:02:44 -0700 Subject: [PATCH 153/337] Revert "feat: add deprecation message to WriteBatch (#1251)" (#1255) --- dev/src/index.ts | 4 ---- dev/src/write-batch.ts | 4 ---- types/firestore.d.ts | 8 -------- 3 files changed, 16 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index 32997e695..df80fdd01 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -658,10 +658,6 @@ export class Firestore implements firestore.Firestore { * @returns {WriteBatch} A WriteBatch that operates on this Firestore * client. * - * @deprecated This class is now deprecated. Use `runTransaction()` to update - * multiple documents atomically or `bulkWriter()` to update a large number - * of documents in parallel. - * * @example * let writeBatch = firestore.batch(); * diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 74119736c..77a819135 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -121,10 +121,6 @@ type PendingWriteOp = () => api.IWrite; * A Firestore WriteBatch that can be used to atomically commit multiple write * operations at once. * - * @deprecated This class is now deprecated. Use `runTransaction()` to update - * multiple documents atomically or `bulkWriter()` to update a large number - * of documents in parallel. - * * @class */ export class WriteBatch implements firestore.WriteBatch { diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 1fed3cb28..c574113cf 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -284,10 +284,6 @@ declare namespace FirebaseFirestore { /** * Creates a write batch, used for performing multiple writes as a single * atomic operation. - * - * @deprecated This class is now deprecated. Use `runTransaction()` to update - * multiple documents atomically or `bulkWriter()` to update a large number - * of documents in parallel. */ batch(): WriteBatch; } @@ -607,10 +603,6 @@ declare namespace FirebaseFirestore { * * Unlike transactions, write batches are persisted offline and therefore are * preferable when you don't need to condition your writes on read data. - * - * @deprecated This class is now deprecated. Use `runTransaction()` to update - * multiple documents atomically or `bulkWriter()` to update a large number - * of documents in parallel. */ export class WriteBatch { private constructor(); From e32198cbee4f2e52954e23a34cd320d143e23b66 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 8 Jul 2020 14:50:52 -0700 Subject: [PATCH 154/337] chore: release 4.1.0 (#1253) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bb68093e..cc09c1e94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [4.1.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.0.0...v4.1.0) (2020-07-08) + + +### Features + +* Added `Firestore.bulkWriter()`, which performs large scale writes in parallel. By default, BulkWriter throttles writes according to the "500/50/5" rule and retries writes that fail due to contention. ([#1252](https://www.github.com/googleapis/nodejs-firestore/issues/1252)) ([d0c6c4b](https://www.github.com/googleapis/nodejs-firestore/commit/d0c6c4b116e096a1bb59c89de26cedb8cf5f1224)) + ## [4.0.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.8.6...v4.0.0) (2020-06-24) diff --git a/package.json b/package.json index 967544109..a3b8c6064 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.0.0", + "version": "4.1.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 1e82ea9e2..253eee5e0 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.0.0" + "@google-cloud/firestore": "^4.1.0" }, "devDependencies": { "chai": "^4.2.0", From 2664878c0f71d83b0d9e5475d31a9daec1a34eaa Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 9 Jul 2020 06:32:06 -0700 Subject: [PATCH 155/337] fix: typeo in nodejs .gitattribute (#1257) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/cc99acfa-05b8-434b-9500-2f6faf2eaa02/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: https://github.com/googleapis/synthtool/commit/799d8e6522c1ef7cb55a70d9ea0b15e045c3d00b --- .gitattributes | 2 +- synth.metadata | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitattributes b/.gitattributes index 2e63216ae..d4f4169b2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,3 @@ *.ts text eol=lf -*.js test eol=lf +*.js text eol=lf protos/* linguist-generated diff --git a/synth.metadata b/synth.metadata index 5904f0e1f..5ed5e3c70 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "1dbc77cc2e4e6a0be9f1b72c75ac35fc4b913df2" + "sha": "e32198cbee4f2e52954e23a34cd320d143e23b66" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "dc9caca650c77b7039e2bbc3339ffb34ae78e5b7" + "sha": "799d8e6522c1ef7cb55a70d9ea0b15e045c3d00b" } } ], From b02925f44c63b0ac58303fdcd4a2b1f59b5de463 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 9 Jul 2020 18:09:03 -0700 Subject: [PATCH 156/337] chore: release 4.1.1 (#1258) * updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc09c1e94..6e668a504 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.1.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.1.0...v4.1.1) (2020-07-09) + + +### Bug Fixes + +* typeo in nodejs .gitattribute ([#1257](https://www.github.com/googleapis/nodejs-firestore/issues/1257)) ([2664878](https://www.github.com/googleapis/nodejs-firestore/commit/2664878c0f71d83b0d9e5475d31a9daec1a34eaa)) + ## [4.1.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.0.0...v4.1.0) (2020-07-08) diff --git a/package.json b/package.json index a3b8c6064..dcfd1b26a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.1.0", + "version": "4.1.1", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 253eee5e0..86bfa9527 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.1.0" + "@google-cloud/firestore": "^4.1.1" }, "devDependencies": { "chai": "^4.2.0", From f079122dd27e05831ee474fe22160e8e4b0d7578 Mon Sep 17 00:00:00 2001 From: Alexander Fenster Date: Fri, 10 Jul 2020 15:18:26 -0700 Subject: [PATCH 157/337] build: use bazel build in synthtool (#1260) --- dev/protos/firestore_admin_v1_proto_api.js | 28 ++++++++++---------- dev/protos/firestore_v1_proto_api.js | 30 +++++++++++----------- dev/protos/firestore_v1beta1_proto_api.js | 28 ++++++++++---------- synth.metadata | 20 +++++++-------- synth.py | 24 +++++++---------- 5 files changed, 62 insertions(+), 68 deletions(-) diff --git a/dev/protos/firestore_admin_v1_proto_api.js b/dev/protos/firestore_admin_v1_proto_api.js index d13a0b98a..ff7bcd613 100644 --- a/dev/protos/firestore_admin_v1_proto_api.js +++ b/dev/protos/firestore_admin_v1_proto_api.js @@ -2109,7 +2109,7 @@ /** * Order enum. * @name google.firestore.admin.v1.Index.IndexField.Order - * @enum {string} + * @enum {number} * @property {string} ORDER_UNSPECIFIED=ORDER_UNSPECIFIED ORDER_UNSPECIFIED value * @property {string} ASCENDING=ASCENDING ASCENDING value * @property {string} DESCENDING=DESCENDING DESCENDING value @@ -2125,7 +2125,7 @@ /** * ArrayConfig enum. * @name google.firestore.admin.v1.Index.IndexField.ArrayConfig - * @enum {string} + * @enum {number} * @property {string} ARRAY_CONFIG_UNSPECIFIED=ARRAY_CONFIG_UNSPECIFIED ARRAY_CONFIG_UNSPECIFIED value * @property {string} CONTAINS=CONTAINS CONTAINS value */ @@ -2142,7 +2142,7 @@ /** * QueryScope enum. * @name google.firestore.admin.v1.Index.QueryScope - * @enum {string} + * @enum {number} * @property {string} QUERY_SCOPE_UNSPECIFIED=QUERY_SCOPE_UNSPECIFIED QUERY_SCOPE_UNSPECIFIED value * @property {string} COLLECTION=COLLECTION COLLECTION value * @property {string} COLLECTION_GROUP=COLLECTION_GROUP COLLECTION_GROUP value @@ -2158,7 +2158,7 @@ /** * State enum. * @name google.firestore.admin.v1.Index.State - * @enum {string} + * @enum {number} * @property {string} STATE_UNSPECIFIED=STATE_UNSPECIFIED STATE_UNSPECIFIED value * @property {string} CREATING=CREATING CREATING value * @property {string} READY=READY READY value @@ -2773,7 +2773,7 @@ /** * ChangeType enum. * @name google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType - * @enum {string} + * @enum {number} * @property {string} CHANGE_TYPE_UNSPECIFIED=CHANGE_TYPE_UNSPECIFIED CHANGE_TYPE_UNSPECIFIED value * @property {string} ADD=ADD ADD value * @property {string} REMOVE=REMOVE REMOVE value @@ -3448,7 +3448,7 @@ /** * OperationState enum. * @name google.firestore.admin.v1.OperationState - * @enum {string} + * @enum {number} * @property {string} OPERATION_STATE_UNSPECIFIED=OPERATION_STATE_UNSPECIFIED OPERATION_STATE_UNSPECIFIED value * @property {string} INITIALIZING=INITIALIZING INITIALIZING value * @property {string} PROCESSING=PROCESSING PROCESSING value @@ -3923,7 +3923,7 @@ /** * FieldBehavior enum. * @name google.api.FieldBehavior - * @enum {string} + * @enum {number} * @property {string} FIELD_BEHAVIOR_UNSPECIFIED=FIELD_BEHAVIOR_UNSPECIFIED FIELD_BEHAVIOR_UNSPECIFIED value * @property {string} OPTIONAL=OPTIONAL OPTIONAL value * @property {string} REQUIRED=REQUIRED REQUIRED value @@ -4118,7 +4118,7 @@ /** * History enum. * @name google.api.ResourceDescriptor.History - * @enum {string} + * @enum {number} * @property {string} HISTORY_UNSPECIFIED=HISTORY_UNSPECIFIED HISTORY_UNSPECIFIED value * @property {string} ORIGINALLY_SINGLE_PATTERN=ORIGINALLY_SINGLE_PATTERN ORIGINALLY_SINGLE_PATTERN value * @property {string} FUTURE_MULTI_PATTERN=FUTURE_MULTI_PATTERN FUTURE_MULTI_PATTERN value @@ -5461,7 +5461,7 @@ /** * Type enum. * @name google.protobuf.FieldDescriptorProto.Type - * @enum {string} + * @enum {number} * @property {string} TYPE_DOUBLE=TYPE_DOUBLE TYPE_DOUBLE value * @property {string} TYPE_FLOAT=TYPE_FLOAT TYPE_FLOAT value * @property {string} TYPE_INT64=TYPE_INT64 TYPE_INT64 value @@ -5507,7 +5507,7 @@ /** * Label enum. * @name google.protobuf.FieldDescriptorProto.Label - * @enum {string} + * @enum {number} * @property {string} LABEL_OPTIONAL=LABEL_OPTIONAL LABEL_OPTIONAL value * @property {string} LABEL_REQUIRED=LABEL_REQUIRED LABEL_REQUIRED value * @property {string} LABEL_REPEATED=LABEL_REPEATED LABEL_REPEATED value @@ -6484,7 +6484,7 @@ /** * OptimizeMode enum. * @name google.protobuf.FileOptions.OptimizeMode - * @enum {string} + * @enum {number} * @property {string} SPEED=SPEED SPEED value * @property {string} CODE_SIZE=CODE_SIZE CODE_SIZE value * @property {string} LITE_RUNTIME=LITE_RUNTIME LITE_RUNTIME value @@ -6942,7 +6942,7 @@ /** * CType enum. * @name google.protobuf.FieldOptions.CType - * @enum {string} + * @enum {number} * @property {string} STRING=STRING STRING value * @property {string} CORD=CORD CORD value * @property {string} STRING_PIECE=STRING_PIECE STRING_PIECE value @@ -6958,7 +6958,7 @@ /** * JSType enum. * @name google.protobuf.FieldOptions.JSType - * @enum {string} + * @enum {number} * @property {string} JS_NORMAL=JS_NORMAL JS_NORMAL value * @property {string} JS_STRING=JS_STRING JS_STRING value * @property {string} JS_NUMBER=JS_NUMBER JS_NUMBER value @@ -9085,7 +9085,7 @@ /** * NullValue enum. * @name google.protobuf.NullValue - * @enum {string} + * @enum {number} * @property {string} NULL_VALUE=NULL_VALUE NULL_VALUE value */ protobuf.NullValue = (function() { diff --git a/dev/protos/firestore_v1_proto_api.js b/dev/protos/firestore_v1_proto_api.js index 83155cfba..e20720604 100644 --- a/dev/protos/firestore_v1_proto_api.js +++ b/dev/protos/firestore_v1_proto_api.js @@ -180,7 +180,7 @@ /** * LimitType enum. * @name firestore.BundledQuery.LimitType - * @enum {string} + * @enum {number} * @property {string} FIRST=FIRST FIRST value * @property {string} LAST=LAST LAST value */ @@ -2092,7 +2092,7 @@ /** * Type enum. * @name google.protobuf.FieldDescriptorProto.Type - * @enum {string} + * @enum {number} * @property {string} TYPE_DOUBLE=TYPE_DOUBLE TYPE_DOUBLE value * @property {string} TYPE_FLOAT=TYPE_FLOAT TYPE_FLOAT value * @property {string} TYPE_INT64=TYPE_INT64 TYPE_INT64 value @@ -2138,7 +2138,7 @@ /** * Label enum. * @name google.protobuf.FieldDescriptorProto.Label - * @enum {string} + * @enum {number} * @property {string} LABEL_OPTIONAL=LABEL_OPTIONAL LABEL_OPTIONAL value * @property {string} LABEL_REQUIRED=LABEL_REQUIRED LABEL_REQUIRED value * @property {string} LABEL_REPEATED=LABEL_REPEATED LABEL_REPEATED value @@ -3115,7 +3115,7 @@ /** * OptimizeMode enum. * @name google.protobuf.FileOptions.OptimizeMode - * @enum {string} + * @enum {number} * @property {string} SPEED=SPEED SPEED value * @property {string} CODE_SIZE=CODE_SIZE CODE_SIZE value * @property {string} LITE_RUNTIME=LITE_RUNTIME LITE_RUNTIME value @@ -3573,7 +3573,7 @@ /** * CType enum. * @name google.protobuf.FieldOptions.CType - * @enum {string} + * @enum {number} * @property {string} STRING=STRING STRING value * @property {string} CORD=CORD CORD value * @property {string} STRING_PIECE=STRING_PIECE STRING_PIECE value @@ -3589,7 +3589,7 @@ /** * JSType enum. * @name google.protobuf.FieldOptions.JSType - * @enum {string} + * @enum {number} * @property {string} JS_NORMAL=JS_NORMAL JS_NORMAL value * @property {string} JS_STRING=JS_STRING JS_STRING value * @property {string} JS_NUMBER=JS_NUMBER JS_NUMBER value @@ -5341,7 +5341,7 @@ /** * NullValue enum. * @name google.protobuf.NullValue - * @enum {string} + * @enum {number} * @property {string} NULL_VALUE=NULL_VALUE NULL_VALUE value */ protobuf.NullValue = (function() { @@ -11918,7 +11918,7 @@ /** * TargetChangeType enum. * @name google.firestore.v1.TargetChange.TargetChangeType - * @enum {string} + * @enum {number} * @property {string} NO_CHANGE=NO_CHANGE NO_CHANGE value * @property {string} ADD=ADD ADD value * @property {string} REMOVE=REMOVE REMOVE value @@ -12989,7 +12989,7 @@ /** * Operator enum. * @name google.firestore.v1.StructuredQuery.CompositeFilter.Operator - * @enum {string} + * @enum {number} * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value * @property {string} AND=AND AND value */ @@ -13157,7 +13157,7 @@ /** * Operator enum. * @name google.firestore.v1.StructuredQuery.FieldFilter.Operator - * @enum {string} + * @enum {number} * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value * @property {string} LESS_THAN=LESS_THAN LESS_THAN value * @property {string} LESS_THAN_OR_EQUAL=LESS_THAN_OR_EQUAL LESS_THAN_OR_EQUAL value @@ -13313,7 +13313,7 @@ /** * Operator enum. * @name google.firestore.v1.StructuredQuery.UnaryFilter.Operator - * @enum {string} + * @enum {number} * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value * @property {string} IS_NAN=IS_NAN IS_NAN value * @property {string} IS_NULL=IS_NULL IS_NULL value @@ -13623,7 +13623,7 @@ /** * Direction enum. * @name google.firestore.v1.StructuredQuery.Direction - * @enum {string} + * @enum {number} * @property {string} DIRECTION_UNSPECIFIED=DIRECTION_UNSPECIFIED DIRECTION_UNSPECIFIED value * @property {string} ASCENDING=ASCENDING ASCENDING value * @property {string} DESCENDING=DESCENDING DESCENDING value @@ -14271,7 +14271,7 @@ /** * ServerValue enum. * @name google.firestore.v1.DocumentTransform.FieldTransform.ServerValue - * @enum {string} + * @enum {number} * @property {string} SERVER_VALUE_UNSPECIFIED=SERVER_VALUE_UNSPECIFIED SERVER_VALUE_UNSPECIFIED value * @property {string} REQUEST_TIME=REQUEST_TIME REQUEST_TIME value */ @@ -15332,7 +15332,7 @@ /** * FieldBehavior enum. * @name google.api.FieldBehavior - * @enum {string} + * @enum {number} * @property {string} FIELD_BEHAVIOR_UNSPECIFIED=FIELD_BEHAVIOR_UNSPECIFIED FIELD_BEHAVIOR_UNSPECIFIED value * @property {string} OPTIONAL=OPTIONAL OPTIONAL value * @property {string} REQUIRED=REQUIRED REQUIRED value @@ -15527,7 +15527,7 @@ /** * History enum. * @name google.api.ResourceDescriptor.History - * @enum {string} + * @enum {number} * @property {string} HISTORY_UNSPECIFIED=HISTORY_UNSPECIFIED HISTORY_UNSPECIFIED value * @property {string} ORIGINALLY_SINGLE_PATTERN=ORIGINALLY_SINGLE_PATTERN ORIGINALLY_SINGLE_PATTERN value * @property {string} FUTURE_MULTI_PATTERN=FUTURE_MULTI_PATTERN FUTURE_MULTI_PATTERN value diff --git a/dev/protos/firestore_v1beta1_proto_api.js b/dev/protos/firestore_v1beta1_proto_api.js index 35a0681fa..ebf2a5404 100644 --- a/dev/protos/firestore_v1beta1_proto_api.js +++ b/dev/protos/firestore_v1beta1_proto_api.js @@ -1379,7 +1379,7 @@ /** * Type enum. * @name google.protobuf.FieldDescriptorProto.Type - * @enum {string} + * @enum {number} * @property {string} TYPE_DOUBLE=TYPE_DOUBLE TYPE_DOUBLE value * @property {string} TYPE_FLOAT=TYPE_FLOAT TYPE_FLOAT value * @property {string} TYPE_INT64=TYPE_INT64 TYPE_INT64 value @@ -1425,7 +1425,7 @@ /** * Label enum. * @name google.protobuf.FieldDescriptorProto.Label - * @enum {string} + * @enum {number} * @property {string} LABEL_OPTIONAL=LABEL_OPTIONAL LABEL_OPTIONAL value * @property {string} LABEL_REQUIRED=LABEL_REQUIRED LABEL_REQUIRED value * @property {string} LABEL_REPEATED=LABEL_REPEATED LABEL_REPEATED value @@ -2402,7 +2402,7 @@ /** * OptimizeMode enum. * @name google.protobuf.FileOptions.OptimizeMode - * @enum {string} + * @enum {number} * @property {string} SPEED=SPEED SPEED value * @property {string} CODE_SIZE=CODE_SIZE CODE_SIZE value * @property {string} LITE_RUNTIME=LITE_RUNTIME LITE_RUNTIME value @@ -2860,7 +2860,7 @@ /** * CType enum. * @name google.protobuf.FieldOptions.CType - * @enum {string} + * @enum {number} * @property {string} STRING=STRING STRING value * @property {string} CORD=CORD CORD value * @property {string} STRING_PIECE=STRING_PIECE STRING_PIECE value @@ -2876,7 +2876,7 @@ /** * JSType enum. * @name google.protobuf.FieldOptions.JSType - * @enum {string} + * @enum {number} * @property {string} JS_NORMAL=JS_NORMAL JS_NORMAL value * @property {string} JS_STRING=JS_STRING JS_STRING value * @property {string} JS_NUMBER=JS_NUMBER JS_NUMBER value @@ -4628,7 +4628,7 @@ /** * NullValue enum. * @name google.protobuf.NullValue - * @enum {string} + * @enum {number} * @property {string} NULL_VALUE=NULL_VALUE NULL_VALUE value */ protobuf.NullValue = (function() { @@ -10856,7 +10856,7 @@ /** * TargetChangeType enum. * @name google.firestore.v1beta1.TargetChange.TargetChangeType - * @enum {string} + * @enum {number} * @property {string} NO_CHANGE=NO_CHANGE NO_CHANGE value * @property {string} ADD=ADD ADD value * @property {string} REMOVE=REMOVE REMOVE value @@ -11670,7 +11670,7 @@ /** * Operator enum. * @name google.firestore.v1beta1.StructuredQuery.CompositeFilter.Operator - * @enum {string} + * @enum {number} * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value * @property {string} AND=AND AND value */ @@ -11838,7 +11838,7 @@ /** * Operator enum. * @name google.firestore.v1beta1.StructuredQuery.FieldFilter.Operator - * @enum {string} + * @enum {number} * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value * @property {string} LESS_THAN=LESS_THAN LESS_THAN value * @property {string} LESS_THAN_OR_EQUAL=LESS_THAN_OR_EQUAL LESS_THAN_OR_EQUAL value @@ -11994,7 +11994,7 @@ /** * Operator enum. * @name google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator - * @enum {string} + * @enum {number} * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value * @property {string} IS_NAN=IS_NAN IS_NAN value * @property {string} IS_NULL=IS_NULL IS_NULL value @@ -12304,7 +12304,7 @@ /** * Direction enum. * @name google.firestore.v1beta1.StructuredQuery.Direction - * @enum {string} + * @enum {number} * @property {string} DIRECTION_UNSPECIFIED=DIRECTION_UNSPECIFIED DIRECTION_UNSPECIFIED value * @property {string} ASCENDING=ASCENDING ASCENDING value * @property {string} DESCENDING=DESCENDING DESCENDING value @@ -12925,7 +12925,7 @@ /** * ServerValue enum. * @name google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue - * @enum {string} + * @enum {number} * @property {string} SERVER_VALUE_UNSPECIFIED=SERVER_VALUE_UNSPECIFIED SERVER_VALUE_UNSPECIFIED value * @property {string} REQUEST_TIME=REQUEST_TIME REQUEST_TIME value */ @@ -13986,7 +13986,7 @@ /** * FieldBehavior enum. * @name google.api.FieldBehavior - * @enum {string} + * @enum {number} * @property {string} FIELD_BEHAVIOR_UNSPECIFIED=FIELD_BEHAVIOR_UNSPECIFIED FIELD_BEHAVIOR_UNSPECIFIED value * @property {string} OPTIONAL=OPTIONAL OPTIONAL value * @property {string} REQUIRED=REQUIRED REQUIRED value @@ -14181,7 +14181,7 @@ /** * History enum. * @name google.api.ResourceDescriptor.History - * @enum {string} + * @enum {number} * @property {string} HISTORY_UNSPECIFIED=HISTORY_UNSPECIFIED HISTORY_UNSPECIFIED value * @property {string} ORIGINALLY_SINGLE_PATTERN=ORIGINALLY_SINGLE_PATTERN ORIGINALLY_SINGLE_PATTERN value * @property {string} FUTURE_MULTI_PATTERN=FUTURE_MULTI_PATTERN FUTURE_MULTI_PATTERN value diff --git a/synth.metadata b/synth.metadata index 5ed5e3c70..2072c1aa4 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,16 +3,16 @@ { "git": { "name": ".", - "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "e32198cbee4f2e52954e23a34cd320d143e23b66" + "remote": "git@github.com:googleapis/nodejs-firestore.git", + "sha": "b02925f44c63b0ac58303fdcd4a2b1f59b5de463" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "0a602be7b3835b51d59daf8f6f5dc2dc22f69d7e", - "internalRef": "318331819" + "sha": "8500bd52067f0842f56d81369ac36087afe617f8", + "internalRef": "320626855" } }, { @@ -29,8 +29,8 @@ "source": "googleapis", "apiName": "firestore-admin", "apiVersion": "v1", - "language": "typescript", - "generator": "gapic-generator-typescript" + "language": "nodejs", + "generator": "bazel" } }, { @@ -38,8 +38,8 @@ "source": "googleapis", "apiName": "firestore", "apiVersion": "v1beta1", - "language": "typescript", - "generator": "gapic-generator-typescript" + "language": "nodejs", + "generator": "bazel" } }, { @@ -47,8 +47,8 @@ "source": "googleapis", "apiName": "firestore", "apiVersion": "v1", - "language": "typescript", - "generator": "gapic-generator-typescript" + "language": "nodejs", + "generator": "bazel" } } ] diff --git a/synth.py b/synth.py index 9de2ef1db..a8e649a2d 100644 --- a/synth.py +++ b/synth.py @@ -10,22 +10,16 @@ AUTOSYNTH_MULTIPLE_COMMITS = True -gapic_micro = gcp.GAPICMicrogenerator() +gapic_bazel = gcp.GAPICBazel() -v1_admin_library = gapic_micro.typescript_library( - "firestore-admin", "v1", proto_path="/google/firestore/admin/v1", - generator_args={'package-name': '@google-cloud/firestore', - 'grpc-service-config': 'google/firestore/admin/v1/firestore_admin_grpc_service_config.json'} -) -v1beta1_library = gapic_micro.typescript_library( - "firestore", "v1beta1", proto_path="/google/firestore/v1beta1", - generator_args={'package-name': '@google-cloud/firestore', - 'grpc-service-config': 'google/firestore/v1beta1/firestore_grpc_service_config.json'} -) -v1_library = gapic_micro.typescript_library( - "firestore", "v1", proto_path="/google/firestore/v1", - generator_args={'package-name': '@google-cloud/firestore', - 'grpc-service-config': 'google/firestore/v1/firestore_grpc_service_config.json'} +v1_admin_library = gapic_bazel.node_library( + "firestore-admin", "v1", proto_path="/google/firestore/admin/v1" +) +v1beta1_library = gapic_bazel.node_library( + "firestore", "v1beta1", proto_path="/google/firestore/v1beta1" +) +v1_library = gapic_bazel.node_library( + "firestore", "v1", proto_path="/google/firestore/v1" ) # skip index, protos, package.json, and README.md From 5bcc82040711a53c2b28cd10fafa33e32b4af061 Mon Sep 17 00:00:00 2001 From: "F. Hinkelmann" Date: Tue, 14 Jul 2020 14:30:41 -0400 Subject: [PATCH 158/337] chore: delete Node 8 presubmit tests (#1263) --- .kokoro/presubmit/node8/common.cfg | 24 ------------------------ .kokoro/presubmit/node8/test.cfg | 0 2 files changed, 24 deletions(-) delete mode 100644 .kokoro/presubmit/node8/common.cfg delete mode 100644 .kokoro/presubmit/node8/test.cfg diff --git a/.kokoro/presubmit/node8/common.cfg b/.kokoro/presubmit/node8/common.cfg deleted file mode 100644 index 21659d8ad..000000000 --- a/.kokoro/presubmit/node8/common.cfg +++ /dev/null @@ -1,24 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "nodejs-firestore/.kokoro/trampoline.sh" - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:8-user" -} -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/nodejs-firestore/.kokoro/test.sh" -} diff --git a/.kokoro/presubmit/node8/test.cfg b/.kokoro/presubmit/node8/test.cfg deleted file mode 100644 index e69de29bb..000000000 From 4d61b377e8c6b1ee9efdebd6f0d3f658ec8874fa Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 14 Jul 2020 18:14:06 -0700 Subject: [PATCH 159/337] build: typo from .gittatributes fix (#1261) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/c5f13b1f-7668-46f2-8dd5-c0086c0e412f/targets - [ ] To automatically regenerate this PR, check this box. --- dev/protos/firestore_admin_v1_proto_api.js | 28 ++++++++++---------- dev/protos/firestore_v1_proto_api.js | 30 +++++++++++----------- dev/protos/firestore_v1beta1_proto_api.js | 28 ++++++++++---------- synth.metadata | 4 +-- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/dev/protos/firestore_admin_v1_proto_api.js b/dev/protos/firestore_admin_v1_proto_api.js index ff7bcd613..d13a0b98a 100644 --- a/dev/protos/firestore_admin_v1_proto_api.js +++ b/dev/protos/firestore_admin_v1_proto_api.js @@ -2109,7 +2109,7 @@ /** * Order enum. * @name google.firestore.admin.v1.Index.IndexField.Order - * @enum {number} + * @enum {string} * @property {string} ORDER_UNSPECIFIED=ORDER_UNSPECIFIED ORDER_UNSPECIFIED value * @property {string} ASCENDING=ASCENDING ASCENDING value * @property {string} DESCENDING=DESCENDING DESCENDING value @@ -2125,7 +2125,7 @@ /** * ArrayConfig enum. * @name google.firestore.admin.v1.Index.IndexField.ArrayConfig - * @enum {number} + * @enum {string} * @property {string} ARRAY_CONFIG_UNSPECIFIED=ARRAY_CONFIG_UNSPECIFIED ARRAY_CONFIG_UNSPECIFIED value * @property {string} CONTAINS=CONTAINS CONTAINS value */ @@ -2142,7 +2142,7 @@ /** * QueryScope enum. * @name google.firestore.admin.v1.Index.QueryScope - * @enum {number} + * @enum {string} * @property {string} QUERY_SCOPE_UNSPECIFIED=QUERY_SCOPE_UNSPECIFIED QUERY_SCOPE_UNSPECIFIED value * @property {string} COLLECTION=COLLECTION COLLECTION value * @property {string} COLLECTION_GROUP=COLLECTION_GROUP COLLECTION_GROUP value @@ -2158,7 +2158,7 @@ /** * State enum. * @name google.firestore.admin.v1.Index.State - * @enum {number} + * @enum {string} * @property {string} STATE_UNSPECIFIED=STATE_UNSPECIFIED STATE_UNSPECIFIED value * @property {string} CREATING=CREATING CREATING value * @property {string} READY=READY READY value @@ -2773,7 +2773,7 @@ /** * ChangeType enum. * @name google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType - * @enum {number} + * @enum {string} * @property {string} CHANGE_TYPE_UNSPECIFIED=CHANGE_TYPE_UNSPECIFIED CHANGE_TYPE_UNSPECIFIED value * @property {string} ADD=ADD ADD value * @property {string} REMOVE=REMOVE REMOVE value @@ -3448,7 +3448,7 @@ /** * OperationState enum. * @name google.firestore.admin.v1.OperationState - * @enum {number} + * @enum {string} * @property {string} OPERATION_STATE_UNSPECIFIED=OPERATION_STATE_UNSPECIFIED OPERATION_STATE_UNSPECIFIED value * @property {string} INITIALIZING=INITIALIZING INITIALIZING value * @property {string} PROCESSING=PROCESSING PROCESSING value @@ -3923,7 +3923,7 @@ /** * FieldBehavior enum. * @name google.api.FieldBehavior - * @enum {number} + * @enum {string} * @property {string} FIELD_BEHAVIOR_UNSPECIFIED=FIELD_BEHAVIOR_UNSPECIFIED FIELD_BEHAVIOR_UNSPECIFIED value * @property {string} OPTIONAL=OPTIONAL OPTIONAL value * @property {string} REQUIRED=REQUIRED REQUIRED value @@ -4118,7 +4118,7 @@ /** * History enum. * @name google.api.ResourceDescriptor.History - * @enum {number} + * @enum {string} * @property {string} HISTORY_UNSPECIFIED=HISTORY_UNSPECIFIED HISTORY_UNSPECIFIED value * @property {string} ORIGINALLY_SINGLE_PATTERN=ORIGINALLY_SINGLE_PATTERN ORIGINALLY_SINGLE_PATTERN value * @property {string} FUTURE_MULTI_PATTERN=FUTURE_MULTI_PATTERN FUTURE_MULTI_PATTERN value @@ -5461,7 +5461,7 @@ /** * Type enum. * @name google.protobuf.FieldDescriptorProto.Type - * @enum {number} + * @enum {string} * @property {string} TYPE_DOUBLE=TYPE_DOUBLE TYPE_DOUBLE value * @property {string} TYPE_FLOAT=TYPE_FLOAT TYPE_FLOAT value * @property {string} TYPE_INT64=TYPE_INT64 TYPE_INT64 value @@ -5507,7 +5507,7 @@ /** * Label enum. * @name google.protobuf.FieldDescriptorProto.Label - * @enum {number} + * @enum {string} * @property {string} LABEL_OPTIONAL=LABEL_OPTIONAL LABEL_OPTIONAL value * @property {string} LABEL_REQUIRED=LABEL_REQUIRED LABEL_REQUIRED value * @property {string} LABEL_REPEATED=LABEL_REPEATED LABEL_REPEATED value @@ -6484,7 +6484,7 @@ /** * OptimizeMode enum. * @name google.protobuf.FileOptions.OptimizeMode - * @enum {number} + * @enum {string} * @property {string} SPEED=SPEED SPEED value * @property {string} CODE_SIZE=CODE_SIZE CODE_SIZE value * @property {string} LITE_RUNTIME=LITE_RUNTIME LITE_RUNTIME value @@ -6942,7 +6942,7 @@ /** * CType enum. * @name google.protobuf.FieldOptions.CType - * @enum {number} + * @enum {string} * @property {string} STRING=STRING STRING value * @property {string} CORD=CORD CORD value * @property {string} STRING_PIECE=STRING_PIECE STRING_PIECE value @@ -6958,7 +6958,7 @@ /** * JSType enum. * @name google.protobuf.FieldOptions.JSType - * @enum {number} + * @enum {string} * @property {string} JS_NORMAL=JS_NORMAL JS_NORMAL value * @property {string} JS_STRING=JS_STRING JS_STRING value * @property {string} JS_NUMBER=JS_NUMBER JS_NUMBER value @@ -9085,7 +9085,7 @@ /** * NullValue enum. * @name google.protobuf.NullValue - * @enum {number} + * @enum {string} * @property {string} NULL_VALUE=NULL_VALUE NULL_VALUE value */ protobuf.NullValue = (function() { diff --git a/dev/protos/firestore_v1_proto_api.js b/dev/protos/firestore_v1_proto_api.js index e20720604..83155cfba 100644 --- a/dev/protos/firestore_v1_proto_api.js +++ b/dev/protos/firestore_v1_proto_api.js @@ -180,7 +180,7 @@ /** * LimitType enum. * @name firestore.BundledQuery.LimitType - * @enum {number} + * @enum {string} * @property {string} FIRST=FIRST FIRST value * @property {string} LAST=LAST LAST value */ @@ -2092,7 +2092,7 @@ /** * Type enum. * @name google.protobuf.FieldDescriptorProto.Type - * @enum {number} + * @enum {string} * @property {string} TYPE_DOUBLE=TYPE_DOUBLE TYPE_DOUBLE value * @property {string} TYPE_FLOAT=TYPE_FLOAT TYPE_FLOAT value * @property {string} TYPE_INT64=TYPE_INT64 TYPE_INT64 value @@ -2138,7 +2138,7 @@ /** * Label enum. * @name google.protobuf.FieldDescriptorProto.Label - * @enum {number} + * @enum {string} * @property {string} LABEL_OPTIONAL=LABEL_OPTIONAL LABEL_OPTIONAL value * @property {string} LABEL_REQUIRED=LABEL_REQUIRED LABEL_REQUIRED value * @property {string} LABEL_REPEATED=LABEL_REPEATED LABEL_REPEATED value @@ -3115,7 +3115,7 @@ /** * OptimizeMode enum. * @name google.protobuf.FileOptions.OptimizeMode - * @enum {number} + * @enum {string} * @property {string} SPEED=SPEED SPEED value * @property {string} CODE_SIZE=CODE_SIZE CODE_SIZE value * @property {string} LITE_RUNTIME=LITE_RUNTIME LITE_RUNTIME value @@ -3573,7 +3573,7 @@ /** * CType enum. * @name google.protobuf.FieldOptions.CType - * @enum {number} + * @enum {string} * @property {string} STRING=STRING STRING value * @property {string} CORD=CORD CORD value * @property {string} STRING_PIECE=STRING_PIECE STRING_PIECE value @@ -3589,7 +3589,7 @@ /** * JSType enum. * @name google.protobuf.FieldOptions.JSType - * @enum {number} + * @enum {string} * @property {string} JS_NORMAL=JS_NORMAL JS_NORMAL value * @property {string} JS_STRING=JS_STRING JS_STRING value * @property {string} JS_NUMBER=JS_NUMBER JS_NUMBER value @@ -5341,7 +5341,7 @@ /** * NullValue enum. * @name google.protobuf.NullValue - * @enum {number} + * @enum {string} * @property {string} NULL_VALUE=NULL_VALUE NULL_VALUE value */ protobuf.NullValue = (function() { @@ -11918,7 +11918,7 @@ /** * TargetChangeType enum. * @name google.firestore.v1.TargetChange.TargetChangeType - * @enum {number} + * @enum {string} * @property {string} NO_CHANGE=NO_CHANGE NO_CHANGE value * @property {string} ADD=ADD ADD value * @property {string} REMOVE=REMOVE REMOVE value @@ -12989,7 +12989,7 @@ /** * Operator enum. * @name google.firestore.v1.StructuredQuery.CompositeFilter.Operator - * @enum {number} + * @enum {string} * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value * @property {string} AND=AND AND value */ @@ -13157,7 +13157,7 @@ /** * Operator enum. * @name google.firestore.v1.StructuredQuery.FieldFilter.Operator - * @enum {number} + * @enum {string} * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value * @property {string} LESS_THAN=LESS_THAN LESS_THAN value * @property {string} LESS_THAN_OR_EQUAL=LESS_THAN_OR_EQUAL LESS_THAN_OR_EQUAL value @@ -13313,7 +13313,7 @@ /** * Operator enum. * @name google.firestore.v1.StructuredQuery.UnaryFilter.Operator - * @enum {number} + * @enum {string} * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value * @property {string} IS_NAN=IS_NAN IS_NAN value * @property {string} IS_NULL=IS_NULL IS_NULL value @@ -13623,7 +13623,7 @@ /** * Direction enum. * @name google.firestore.v1.StructuredQuery.Direction - * @enum {number} + * @enum {string} * @property {string} DIRECTION_UNSPECIFIED=DIRECTION_UNSPECIFIED DIRECTION_UNSPECIFIED value * @property {string} ASCENDING=ASCENDING ASCENDING value * @property {string} DESCENDING=DESCENDING DESCENDING value @@ -14271,7 +14271,7 @@ /** * ServerValue enum. * @name google.firestore.v1.DocumentTransform.FieldTransform.ServerValue - * @enum {number} + * @enum {string} * @property {string} SERVER_VALUE_UNSPECIFIED=SERVER_VALUE_UNSPECIFIED SERVER_VALUE_UNSPECIFIED value * @property {string} REQUEST_TIME=REQUEST_TIME REQUEST_TIME value */ @@ -15332,7 +15332,7 @@ /** * FieldBehavior enum. * @name google.api.FieldBehavior - * @enum {number} + * @enum {string} * @property {string} FIELD_BEHAVIOR_UNSPECIFIED=FIELD_BEHAVIOR_UNSPECIFIED FIELD_BEHAVIOR_UNSPECIFIED value * @property {string} OPTIONAL=OPTIONAL OPTIONAL value * @property {string} REQUIRED=REQUIRED REQUIRED value @@ -15527,7 +15527,7 @@ /** * History enum. * @name google.api.ResourceDescriptor.History - * @enum {number} + * @enum {string} * @property {string} HISTORY_UNSPECIFIED=HISTORY_UNSPECIFIED HISTORY_UNSPECIFIED value * @property {string} ORIGINALLY_SINGLE_PATTERN=ORIGINALLY_SINGLE_PATTERN ORIGINALLY_SINGLE_PATTERN value * @property {string} FUTURE_MULTI_PATTERN=FUTURE_MULTI_PATTERN FUTURE_MULTI_PATTERN value diff --git a/dev/protos/firestore_v1beta1_proto_api.js b/dev/protos/firestore_v1beta1_proto_api.js index ebf2a5404..35a0681fa 100644 --- a/dev/protos/firestore_v1beta1_proto_api.js +++ b/dev/protos/firestore_v1beta1_proto_api.js @@ -1379,7 +1379,7 @@ /** * Type enum. * @name google.protobuf.FieldDescriptorProto.Type - * @enum {number} + * @enum {string} * @property {string} TYPE_DOUBLE=TYPE_DOUBLE TYPE_DOUBLE value * @property {string} TYPE_FLOAT=TYPE_FLOAT TYPE_FLOAT value * @property {string} TYPE_INT64=TYPE_INT64 TYPE_INT64 value @@ -1425,7 +1425,7 @@ /** * Label enum. * @name google.protobuf.FieldDescriptorProto.Label - * @enum {number} + * @enum {string} * @property {string} LABEL_OPTIONAL=LABEL_OPTIONAL LABEL_OPTIONAL value * @property {string} LABEL_REQUIRED=LABEL_REQUIRED LABEL_REQUIRED value * @property {string} LABEL_REPEATED=LABEL_REPEATED LABEL_REPEATED value @@ -2402,7 +2402,7 @@ /** * OptimizeMode enum. * @name google.protobuf.FileOptions.OptimizeMode - * @enum {number} + * @enum {string} * @property {string} SPEED=SPEED SPEED value * @property {string} CODE_SIZE=CODE_SIZE CODE_SIZE value * @property {string} LITE_RUNTIME=LITE_RUNTIME LITE_RUNTIME value @@ -2860,7 +2860,7 @@ /** * CType enum. * @name google.protobuf.FieldOptions.CType - * @enum {number} + * @enum {string} * @property {string} STRING=STRING STRING value * @property {string} CORD=CORD CORD value * @property {string} STRING_PIECE=STRING_PIECE STRING_PIECE value @@ -2876,7 +2876,7 @@ /** * JSType enum. * @name google.protobuf.FieldOptions.JSType - * @enum {number} + * @enum {string} * @property {string} JS_NORMAL=JS_NORMAL JS_NORMAL value * @property {string} JS_STRING=JS_STRING JS_STRING value * @property {string} JS_NUMBER=JS_NUMBER JS_NUMBER value @@ -4628,7 +4628,7 @@ /** * NullValue enum. * @name google.protobuf.NullValue - * @enum {number} + * @enum {string} * @property {string} NULL_VALUE=NULL_VALUE NULL_VALUE value */ protobuf.NullValue = (function() { @@ -10856,7 +10856,7 @@ /** * TargetChangeType enum. * @name google.firestore.v1beta1.TargetChange.TargetChangeType - * @enum {number} + * @enum {string} * @property {string} NO_CHANGE=NO_CHANGE NO_CHANGE value * @property {string} ADD=ADD ADD value * @property {string} REMOVE=REMOVE REMOVE value @@ -11670,7 +11670,7 @@ /** * Operator enum. * @name google.firestore.v1beta1.StructuredQuery.CompositeFilter.Operator - * @enum {number} + * @enum {string} * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value * @property {string} AND=AND AND value */ @@ -11838,7 +11838,7 @@ /** * Operator enum. * @name google.firestore.v1beta1.StructuredQuery.FieldFilter.Operator - * @enum {number} + * @enum {string} * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value * @property {string} LESS_THAN=LESS_THAN LESS_THAN value * @property {string} LESS_THAN_OR_EQUAL=LESS_THAN_OR_EQUAL LESS_THAN_OR_EQUAL value @@ -11994,7 +11994,7 @@ /** * Operator enum. * @name google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator - * @enum {number} + * @enum {string} * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value * @property {string} IS_NAN=IS_NAN IS_NAN value * @property {string} IS_NULL=IS_NULL IS_NULL value @@ -12304,7 +12304,7 @@ /** * Direction enum. * @name google.firestore.v1beta1.StructuredQuery.Direction - * @enum {number} + * @enum {string} * @property {string} DIRECTION_UNSPECIFIED=DIRECTION_UNSPECIFIED DIRECTION_UNSPECIFIED value * @property {string} ASCENDING=ASCENDING ASCENDING value * @property {string} DESCENDING=DESCENDING DESCENDING value @@ -12925,7 +12925,7 @@ /** * ServerValue enum. * @name google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue - * @enum {number} + * @enum {string} * @property {string} SERVER_VALUE_UNSPECIFIED=SERVER_VALUE_UNSPECIFIED SERVER_VALUE_UNSPECIFIED value * @property {string} REQUEST_TIME=REQUEST_TIME REQUEST_TIME value */ @@ -13986,7 +13986,7 @@ /** * FieldBehavior enum. * @name google.api.FieldBehavior - * @enum {number} + * @enum {string} * @property {string} FIELD_BEHAVIOR_UNSPECIFIED=FIELD_BEHAVIOR_UNSPECIFIED FIELD_BEHAVIOR_UNSPECIFIED value * @property {string} OPTIONAL=OPTIONAL OPTIONAL value * @property {string} REQUIRED=REQUIRED REQUIRED value @@ -14181,7 +14181,7 @@ /** * History enum. * @name google.api.ResourceDescriptor.History - * @enum {number} + * @enum {string} * @property {string} HISTORY_UNSPECIFIED=HISTORY_UNSPECIFIED HISTORY_UNSPECIFIED value * @property {string} ORIGINALLY_SINGLE_PATTERN=ORIGINALLY_SINGLE_PATTERN ORIGINALLY_SINGLE_PATTERN value * @property {string} FUTURE_MULTI_PATTERN=FUTURE_MULTI_PATTERN FUTURE_MULTI_PATTERN value diff --git a/synth.metadata b/synth.metadata index 2072c1aa4..4cc64579a 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,8 +3,8 @@ { "git": { "name": ".", - "remote": "git@github.com:googleapis/nodejs-firestore.git", - "sha": "b02925f44c63b0ac58303fdcd4a2b1f59b5de463" + "remote": "https://github.com/googleapis/nodejs-firestore.git", + "sha": "f079122dd27e05831ee474fe22160e8e4b0d7578" } }, { From f29ded728cadac54b2909a812baab8dafa3f3a4f Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 17 Jul 2020 15:18:43 -0700 Subject: [PATCH 160/337] chore: add config files for cloud-rad for node.js (#1266) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/5e903fff-57bb-4395-bb94-8b4d1909dbf6/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: https://github.com/googleapis/synthtool/commit/21f1470ecd01424dc91c70f1a7c798e4e87d1eec --- api-extractor.json | 369 +++++++++++++++++++++++++++++++++++++++++++++ synth.metadata | 4 +- 2 files changed, 371 insertions(+), 2 deletions(-) create mode 100644 api-extractor.json diff --git a/api-extractor.json b/api-extractor.json new file mode 100644 index 000000000..de228294b --- /dev/null +++ b/api-extractor.json @@ -0,0 +1,369 @@ +/** + * Config file for API Extractor. For more info, please visit: https://api-extractor.com + */ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + + /** + * Optionally specifies another JSON config file that this file extends from. This provides a way for + * standard settings to be shared across multiple projects. + * + * If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains + * the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be + * resolved using NodeJS require(). + * + * SUPPORTED TOKENS: none + * DEFAULT VALUE: "" + */ + // "extends": "./shared/api-extractor-base.json" + // "extends": "my-package/include/api-extractor-base.json" + + /** + * Determines the "" token that can be used with other config file settings. The project folder + * typically contains the tsconfig.json and package.json config files, but the path is user-defined. + * + * The path is resolved relative to the folder of the config file that contains the setting. + * + * The default value for "projectFolder" is the token "", which means the folder is determined by traversing + * parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder + * that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error + * will be reported. + * + * SUPPORTED TOKENS: + * DEFAULT VALUE: "" + */ + // "projectFolder": "..", + + /** + * (REQUIRED) Specifies the .d.ts file to be used as the starting point for analysis. API Extractor + * analyzes the symbols exported by this module. + * + * The file extension must be ".d.ts" and not ".ts". + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + */ + "mainEntryPointFilePath": "/protos/protos.d.ts", + + /** + * A list of NPM package names whose exports should be treated as part of this package. + * + * For example, suppose that Webpack is used to generate a distributed bundle for the project "library1", + * and another NPM package "library2" is embedded in this bundle. Some types from library2 may become part + * of the exported API for library1, but by default API Extractor would generate a .d.ts rollup that explicitly + * imports library2. To avoid this, we can specify: + * + * "bundledPackages": [ "library2" ], + * + * This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been + * local files for library1. + */ + "bundledPackages": [ ], + + /** + * Determines how the TypeScript compiler engine will be invoked by API Extractor. + */ + "compiler": { + /** + * Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * Note: This setting will be ignored if "overrideTsconfig" is used. + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/tsconfig.json" + */ + // "tsconfigFilePath": "/tsconfig.json", + + /** + * Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk. + * The object must conform to the TypeScript tsconfig schema: + * + * http://json.schemastore.org/tsconfig + * + * If omitted, then the tsconfig.json file will be read from the "projectFolder". + * + * DEFAULT VALUE: no overrideTsconfig section + */ + // "overrideTsconfig": { + // . . . + // } + + /** + * This option causes the compiler to be invoked with the --skipLibCheck option. This option is not recommended + * and may cause API Extractor to produce incomplete or incorrect declarations, but it may be required when + * dependencies contain declarations that are incompatible with the TypeScript engine that API Extractor uses + * for its analysis. Where possible, the underlying issue should be fixed rather than relying on skipLibCheck. + * + * DEFAULT VALUE: false + */ + // "skipLibCheck": true, + }, + + /** + * Configures how the API report file (*.api.md) will be generated. + */ + "apiReport": { + /** + * (REQUIRED) Whether to generate an API report. + */ + "enabled": true, + + /** + * The filename for the API report files. It will be combined with "reportFolder" or "reportTempFolder" to produce + * a full file path. + * + * The file extension should be ".api.md", and the string should not contain a path separator such as "\" or "/". + * + * SUPPORTED TOKENS: , + * DEFAULT VALUE: ".api.md" + */ + // "reportFileName": ".api.md", + + /** + * Specifies the folder where the API report file is written. The file name portion is determined by + * the "reportFileName" setting. + * + * The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy, + * e.g. for an API review. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/etc/" + */ + // "reportFolder": "/etc/", + + /** + * Specifies the folder where the temporary report file is written. The file name portion is determined by + * the "reportFileName" setting. + * + * After the temporary file is written to disk, it is compared with the file in the "reportFolder". + * If they are different, a production build will fail. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/temp/" + */ + // "reportTempFolder": "/temp/" + }, + + /** + * Configures how the doc model file (*.api.json) will be generated. + */ + "docModel": { + /** + * (REQUIRED) Whether to generate a doc model file. + */ + "enabled": true, + + /** + * The output path for the doc model file. The file extension should be ".api.json". + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/temp/.api.json" + */ + // "apiJsonFilePath": "/temp/.api.json" + }, + + /** + * Configures how the .d.ts rollup file will be generated. + */ + "dtsRollup": { + /** + * (REQUIRED) Whether to generate the .d.ts rollup file. + */ + "enabled": true, + + /** + * Specifies the output path for a .d.ts rollup file to be generated without any trimming. + * This file will include all declarations that are exported by the main entry point. + * + * If the path is an empty string, then this file will not be written. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/dist/.d.ts" + */ + // "untrimmedFilePath": "/dist/.d.ts", + + /** + * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release. + * This file will include only declarations that are marked as "@public" or "@beta". + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "" + */ + // "betaTrimmedFilePath": "/dist/-beta.d.ts", + + + /** + * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release. + * This file will include only declarations that are marked as "@public". + * + * If the path is an empty string, then this file will not be written. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "" + */ + // "publicTrimmedFilePath": "/dist/-public.d.ts", + + /** + * When a declaration is trimmed, by default it will be replaced by a code comment such as + * "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the + * declaration completely. + * + * DEFAULT VALUE: false + */ + // "omitTrimmingComments": true + }, + + /** + * Configures how the tsdoc-metadata.json file will be generated. + */ + "tsdocMetadata": { + /** + * Whether to generate the tsdoc-metadata.json file. + * + * DEFAULT VALUE: true + */ + // "enabled": true, + + /** + * Specifies where the TSDoc metadata file should be written. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * The default value is "", which causes the path to be automatically inferred from the "tsdocMetadata", + * "typings" or "main" fields of the project's package.json. If none of these fields are set, the lookup + * falls back to "tsdoc-metadata.json" in the package folder. + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "" + */ + // "tsdocMetadataFilePath": "/dist/tsdoc-metadata.json" + }, + + /** + * Specifies what type of newlines API Extractor should use when writing output files. By default, the output files + * will be written with Windows-style newlines. To use POSIX-style newlines, specify "lf" instead. + * To use the OS's default newline kind, specify "os". + * + * DEFAULT VALUE: "crlf" + */ + // "newlineKind": "crlf", + + /** + * Configures how API Extractor reports error and warning messages produced during analysis. + * + * There are three sources of messages: compiler messages, API Extractor messages, and TSDoc messages. + */ + "messages": { + /** + * Configures handling of diagnostic messages reported by the TypeScript compiler engine while analyzing + * the input .d.ts files. + * + * TypeScript message identifiers start with "TS" followed by an integer. For example: "TS2551" + * + * DEFAULT VALUE: A single "default" entry with logLevel=warning. + */ + "compilerMessageReporting": { + /** + * Configures the default routing for messages that don't match an explicit rule in this table. + */ + "default": { + /** + * Specifies whether the message should be written to the the tool's output log. Note that + * the "addToApiReportFile" property may supersede this option. + * + * Possible values: "error", "warning", "none" + * + * Errors cause the build to fail and return a nonzero exit code. Warnings cause a production build fail + * and return a nonzero exit code. For a non-production build (e.g. when "api-extractor run" includes + * the "--local" option), the warning is displayed but the build will not fail. + * + * DEFAULT VALUE: "warning" + */ + "logLevel": "warning", + + /** + * When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md), + * then the message will be written inside that file; otherwise, the message is instead logged according to + * the "logLevel" option. + * + * DEFAULT VALUE: false + */ + // "addToApiReportFile": false + }, + + // "TS2551": { + // "logLevel": "warning", + // "addToApiReportFile": true + // }, + // + // . . . + }, + + /** + * Configures handling of messages reported by API Extractor during its analysis. + * + * API Extractor message identifiers start with "ae-". For example: "ae-extra-release-tag" + * + * DEFAULT VALUE: See api-extractor-defaults.json for the complete table of extractorMessageReporting mappings + */ + "extractorMessageReporting": { + "default": { + "logLevel": "warning", + // "addToApiReportFile": false + }, + + // "ae-extra-release-tag": { + // "logLevel": "warning", + // "addToApiReportFile": true + // }, + // + // . . . + }, + + /** + * Configures handling of messages reported by the TSDoc parser when analyzing code comments. + * + * TSDoc message identifiers start with "tsdoc-". For example: "tsdoc-link-tag-unescaped-text" + * + * DEFAULT VALUE: A single "default" entry with logLevel=warning. + */ + "tsdocMessageReporting": { + "default": { + "logLevel": "warning", + // "addToApiReportFile": false + } + + // "tsdoc-link-tag-unescaped-text": { + // "logLevel": "warning", + // "addToApiReportFile": true + // }, + // + // . . . + } + } + +} diff --git a/synth.metadata b/synth.metadata index 4cc64579a..23c2c37a4 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "f079122dd27e05831ee474fe22160e8e4b0d7578" + "sha": "4d61b377e8c6b1ee9efdebd6f0d3f658ec8874fa" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "799d8e6522c1ef7cb55a70d9ea0b15e045c3d00b" + "sha": "21f1470ecd01424dc91c70f1a7c798e4e87d1eec" } } ], From 7b0495a8c85052ce8a11539929f092f13ccff927 Mon Sep 17 00:00:00 2001 From: "F. Hinkelmann" Date: Tue, 21 Jul 2020 14:47:47 -0400 Subject: [PATCH 161/337] chore: add dev dependencies for cloud-rad ref docs (#1268) --- package.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index dcfd1b26a..bd81a9b35 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,9 @@ "docs-test": "linkinator docs", "predocs-test": "npm run docs", "prelint": "cd samples; npm link ../; npm install", - "precompile": "gts clean" + "precompile": "gts clean", + "api-extractor": "api-extractor run --local", + "api-documenter": "api-documenter yaml --input-folder=temp" }, "dependencies": { "fast-deep-equal": "^3.1.1", @@ -82,6 +84,8 @@ "sinon": "^9.0.2", "ts-node": "^8.5.4", "typescript": "3.8.3", - "through2": "^4.0.0" + "through2": "^4.0.0", + "@microsoft/api-documenter": "^7.8.10", + "@microsoft/api-extractor": "^7.8.10" } } From 5e7e62712ab049ce1adcb26213dd13964939bf65 Mon Sep 17 00:00:00 2001 From: Sebastian Kreft Date: Fri, 24 Jul 2020 15:31:32 -0400 Subject: [PATCH 162/337] fix: add Firestore.bulkWriter to firestore.d.ts (#1272) This method was missing in PR https://github.com/googleapis/nodejs-firestore/pull/1252 --- types/firestore.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/types/firestore.d.ts b/types/firestore.d.ts index c574113cf..7d551819d 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -286,6 +286,13 @@ declare namespace FirebaseFirestore { * atomic operation. */ batch(): WriteBatch; + + /** + * Creates a [BulkWriter]{@link BulkWriter}, used for performing + * multiple writes in parallel. Gradually ramps up writes as specified + * by the 500/50/5 rule. + */ + bulkWriter(options?: BulkWriterOptions): BulkWriter; } /** From 016d1eb059c0fd226efd48930085759bd6560952 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 24 Jul 2020 13:30:27 -0700 Subject: [PATCH 163/337] chore: move gitattributes files to node templates (#1273) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/d43b90cc-a087-4c57-864c-1e4f93292dc6/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: https://github.com/googleapis/synthtool/commit/3a00b7fea8c4c83eaff8eb207f530a2e3e8e1de3 --- .gitattributes | 1 + synth.metadata | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index d4f4169b2..33739cb74 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ *.ts text eol=lf *.js text eol=lf protos/* linguist-generated +**/api-extractor.json linguist-language=JSON-with-Comments diff --git a/synth.metadata b/synth.metadata index 23c2c37a4..21d823415 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "4d61b377e8c6b1ee9efdebd6f0d3f658ec8874fa" + "sha": "7b0495a8c85052ce8a11539929f092f13ccff927" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "21f1470ecd01424dc91c70f1a7c798e4e87d1eec" + "sha": "3a00b7fea8c4c83eaff8eb207f530a2e3e8e1de3" } } ], From c34970dcbdf04559e604eb5a5a33ca0cea87f735 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 28 Jul 2020 16:49:18 -0700 Subject: [PATCH 164/337] chore: release 4.1.2 (#1274) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e668a504..37bebe0a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.1.2](https://www.github.com/googleapis/nodejs-firestore/compare/v4.1.1...v4.1.2) (2020-07-24) + + +### Bug Fixes + +* add Firestore.bulkWriter to firestore.d.ts ([#1272](https://www.github.com/googleapis/nodejs-firestore/issues/1272)) ([5e7e627](https://www.github.com/googleapis/nodejs-firestore/commit/5e7e62712ab049ce1adcb26213dd13964939bf65)) + ### [4.1.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.1.0...v4.1.1) (2020-07-09) diff --git a/package.json b/package.json index bd81a9b35..3f7557529 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.1.1", + "version": "4.1.2", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 86bfa9527..9d24d94f7 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.1.1" + "@google-cloud/firestore": "^4.1.2" }, "devDependencies": { "chai": "^4.2.0", From 34d672870f9a4673e990176e4453c4202a1386f9 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Fri, 31 Jul 2020 08:30:06 -0500 Subject: [PATCH 165/337] feat: allow `Settings.host` to be used when `Settings.servicePath` is set (#1275) --- dev/src/index.ts | 75 +++++++++++++++++++++++++---------------------- dev/test/index.ts | 63 ++++++++++++++++++++++++++++++++------- 2 files changed, 93 insertions(+), 45 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index df80fdd01..4f26a91fd 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -408,28 +408,7 @@ export class Firestore implements firestore.Firestore { libraryHeader.libVersion += ' fire/' + settings.firebaseVersion; } - if (process.env.FIRESTORE_EMULATOR_HOST) { - validateHost( - 'FIRESTORE_EMULATOR_HOST', - process.env.FIRESTORE_EMULATOR_HOST - ); - - const emulatorSettings: firestore.Settings = { - ...settings, - ...libraryHeader, - host: process.env.FIRESTORE_EMULATOR_HOST, - ssl: false, - }; - - // If FIRESTORE_EMULATOR_HOST is set, we unset `servicePath` and `apiEndpoint` to - // ensure that only one endpoint setting is provided. - delete emulatorSettings.servicePath; - delete emulatorSettings.apiEndpoint; - - this.validateAndApplySettings(emulatorSettings); - } else { - this.validateAndApplySettings({...settings, ...libraryHeader}); - } + this.validateAndApplySettings({...settings, ...libraryHeader}); const retryConfig = serviceConfig.retry_params.default; this._backoffSettings = { @@ -502,28 +481,54 @@ export class Firestore implements firestore.Firestore { this._projectId = settings.projectId; } - if (settings.host !== undefined) { + let url: URL | null = null; + + // If the environment variable is set, it should always take precedence + // over any user passed in settings. + if (process.env.FIRESTORE_EMULATOR_HOST) { + validateHost( + 'FIRESTORE_EMULATOR_HOST', + process.env.FIRESTORE_EMULATOR_HOST + ); + + settings = { + ...settings, + host: process.env.FIRESTORE_EMULATOR_HOST, + ssl: false, + }; + url = new URL(`http://${settings.host}`); + } else if (settings.host !== undefined) { validateHost('settings.host', settings.host); - if (settings.servicePath !== undefined) { - throw new Error( - 'Cannot set both "settings.host" and "settings.servicePath".' - ); - } - if (settings.apiEndpoint !== undefined) { - throw new Error( - 'Cannot set both "settings.host" and "settings.apiEndpoint".' + url = new URL(`http://${settings.host}`); + } + + // Only store the host if a valid value was provided in `host`. + if (url !== null) { + if ( + (settings.servicePath !== undefined && + settings.servicePath !== url.hostname) || + (settings.apiEndpoint !== undefined && + settings.apiEndpoint !== url.hostname) + ) { + // eslint-disable-next-line no-console + console.warn( + `The provided host (${url.hostname}) in "settings" does not ` + + `match the existing host (${ + settings.servicePath ?? settings.apiEndpoint + }). Using the provided host.` ); } - const url = new URL(`http://${settings.host}`); settings.servicePath = url.hostname; if (url.port !== '' && settings.port === undefined) { settings.port = Number(url.port); } - // We need to remove the `host` setting, in case a user calls `settings()`, - // which will again enforce that `host` and `servicePath` are not both - // specified. + + // We need to remove the `host` and `apiEndpoint` setting, in case a user + // calls `settings()`, which will compare the the provided `host` to the + // existing hostname stored on `servicePath`. delete settings.host; + delete settings.apiEndpoint; } if (settings.ssl !== undefined) { diff --git a/dev/test/index.ts b/dev/test/index.ts index 8687757ca..b96c9f7b5 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -424,14 +424,57 @@ describe('instantiation', () => { } }); - it('validates only one endpoint is provided', () => { - expect(() => { - new Firestore.Firestore({host: 'foo', apiEndpoint: 'foo'}); - }).to.throw('Cannot set both "settings.host" and "settings.apiEndpoint".'); + it('"settings.host" takes precedence without FIRESTORE_EMULATOR_HOST', () => { + const oldValue = process.env.FIRESTORE_EMULATOR_HOST; - expect(() => { - new Firestore.Firestore({host: 'foo', servicePath: 'foo'}); - }).to.throw('Cannot set both "settings.host" and "settings.servicePath".'); + try { + delete process.env.FIRESTORE_EMULATOR_HOST; + + let firestore = new Firestore.Firestore({ + apiEndpoint: 'api-host', + }); + firestore.settings({host: 'new-host:100'}); + expect(firestore._settings.servicePath).to.equal('new-host'); + + firestore = new Firestore.Firestore({ + servicePath: 'service-host', + }); + firestore.settings({host: 'new-host:100'}); + expect(firestore._settings.servicePath).to.equal('new-host'); + + firestore = new Firestore.Firestore({ + apiEndpoint: 'api-host', + servicePath: 'service-host', + }); + firestore.settings({host: 'new-host:100'}); + expect(firestore._settings.servicePath).to.equal('new-host'); + } finally { + if (oldValue) { + process.env.FIRESTORE_EMULATOR_HOST = oldValue; + } else { + delete process.env.FIRESTORE_EMULATOR_HOST; + } + } + }); + + it('FIRESTORE_EMULATOR_HOST ignores host', () => { + const oldValue = process.env.FIRESTORE_EMULATOR_HOST; + + try { + process.env.FIRESTORE_EMULATOR_HOST = 'env-host:8080'; + const firestore = new Firestore.Firestore({ + host: 'localhost:8080', + }); + expect(firestore._settings.servicePath).to.equal('env-host'); + firestore.settings({host: 'localhost:8080'}); + expect(firestore._settings.servicePath).to.equal('env-host'); + } finally { + if (oldValue) { + process.env.FIRESTORE_EMULATOR_HOST = oldValue; + } else { + delete process.env.FIRESTORE_EMULATOR_HOST; + } + } }); it('FIRESTORE_EMULATOR_HOST ignores servicePath', () => { @@ -440,9 +483,9 @@ describe('instantiation', () => { try { process.env.FIRESTORE_EMULATOR_HOST = 'foo'; const firestore = new Firestore.Firestore({servicePath: 'bar'}); - // The call to `settings()` used to throw ("Cannot set both 'settings.host' and 'settings.servicePath'"). - // See https://github.com/googleapis/nodejs-firestore/pull/696#issuecomment-505822099 - firestore.settings({}); + expect(firestore._settings.servicePath).to.equal('foo'); + firestore.settings({servicePath: 'bar'}); + expect(firestore._settings.servicePath).to.equal('foo'); } finally { if (oldValue) { process.env.FIRESTORE_EMULATOR_HOST = oldValue; From 7cc277b2b4cd7c7e9bd3f2b161fc6ffac591dba7 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 31 Jul 2020 09:24:27 -0700 Subject: [PATCH 166/337] docs: add links to the CHANGELOG from the README.md for Java and Node (#1278) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/7b446397-88f3-4463-9e7d-d2ce7069989d/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: https://github.com/googleapis/synthtool/commit/5936421202fb53ed4641bcb824017dd393a3dbcc --- README.md | 3 +++ synth.metadata | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0b5f2ac1d..13a2bdefa 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,9 @@ Applications that use Google's Server SDKs should not be used in end-user e **Note:** This Cloud Firestore Server SDK does not support Firestore databases created in [Datastore mode](https://cloud.google.com/datastore/docs/firestore-or-datastore#in_datastore_mode). To access these databases, use the [Datastore SDK](https://www.npmjs.com/package/@google-cloud/datastore). +A comprehensive list of changes in each version may be found in +[the CHANGELOG](https://github.com/googleapis/nodejs-firestore/blob/master/CHANGELOG.md). + * [Cloud Firestore Node.js Client API Reference][client-docs] * [Cloud Firestore Documentation][product-docs] * [github.com/googleapis/nodejs-firestore](https://github.com/googleapis/nodejs-firestore) diff --git a/synth.metadata b/synth.metadata index 21d823415..c20f3dbd5 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "7b0495a8c85052ce8a11539929f092f13ccff927" + "sha": "34d672870f9a4673e990176e4453c4202a1386f9" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "3a00b7fea8c4c83eaff8eb207f530a2e3e8e1de3" + "sha": "5936421202fb53ed4641bcb824017dd393a3dbcc" } } ], From 22ce4becffed1a66ccf3e60e6d39148c9d07e1c9 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Fri, 31 Jul 2020 17:14:19 -0500 Subject: [PATCH 167/337] chore: add firestore to CODEOWNERS (#1277) --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 7aad1ccc4..5f7bc27be 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -7,4 +7,4 @@ # The firestore-dpe team is the default owner for anything not # explicitly taken by someone else. -* @googleapis/firestore-dpe @googleapis/yoshi-nodejs +* @googleapis/firestore-dpe @googleapis/yoshi-nodejs @googleapis/api-firestore From b8759ffdc7569e701112ed2823e14b0e4535a01d Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 3 Aug 2020 10:30:00 -0700 Subject: [PATCH 168/337] chore: release 4.2.0 (#1276) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37bebe0a3..761d79a82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [4.2.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.1.2...v4.2.0) (2020-07-31) + + +### Features + +* allow `Settings.host` to be used when `Settings.servicePath` is set ([#1275](https://www.github.com/googleapis/nodejs-firestore/issues/1275)) ([34d6728](https://www.github.com/googleapis/nodejs-firestore/commit/34d672870f9a4673e990176e4453c4202a1386f9)) + ### [4.1.2](https://www.github.com/googleapis/nodejs-firestore/compare/v4.1.1...v4.1.2) (2020-07-24) diff --git a/package.json b/package.json index 3f7557529..673cabc35 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.1.2", + "version": "4.2.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 9d24d94f7..8b4b9762e 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.1.2" + "@google-cloud/firestore": "^4.2.0" }, "devDependencies": { "chai": "^4.2.0", From 9cd53be4a7f37b8d1f61a1b8567fa8b7ccce0e3e Mon Sep 17 00:00:00 2001 From: wu-hui <53845758+wu-hui@users.noreply.github.com> Date: Mon, 10 Aug 2020 11:52:23 -0400 Subject: [PATCH 169/337] feat: Build query/document mapping in bundles. (#1280) * feat: Build query/document mapping in bundles. * fix system test failure. * fix lint error. * Remove ugly swap. * Mutiple queries mapping and never go back in time. * Address comments and fix system-tests * Fix system-tests. --- dev/protos/firestore/bundle.proto | 3 ++ dev/protos/firestore_v1_proto_api.d.ts | 6 ++++ dev/protos/firestore_v1_proto_api.js | 24 +++++++++++++ dev/src/bundle.ts | 41 ++++++++++++++------- dev/system-test/firestore.ts | 2 ++ dev/test/bundle.ts | 49 +++++++++++++++++++++----- 6 files changed, 104 insertions(+), 21 deletions(-) diff --git a/dev/protos/firestore/bundle.proto b/dev/protos/firestore/bundle.proto index 7b71db117..22bbd8a09 100644 --- a/dev/protos/firestore/bundle.proto +++ b/dev/protos/firestore/bundle.proto @@ -79,6 +79,9 @@ message BundledDocumentMetadata { // Whether the document exists. bool exists = 3; + + // The names of the queries in this bundle that this document matches to. + repeated string queries = 4; } // Metadata describing the bundle file/stream. diff --git a/dev/protos/firestore_v1_proto_api.d.ts b/dev/protos/firestore_v1_proto_api.d.ts index 6cc2c9a8f..3d1c5468d 100644 --- a/dev/protos/firestore_v1_proto_api.d.ts +++ b/dev/protos/firestore_v1_proto_api.d.ts @@ -145,6 +145,9 @@ export namespace firestore { /** BundledDocumentMetadata exists */ exists?: (boolean|null); + + /** BundledDocumentMetadata queries */ + queries?: (string[]|null); } /** Represents a BundledDocumentMetadata. */ @@ -165,6 +168,9 @@ export namespace firestore { /** BundledDocumentMetadata exists. */ public exists: boolean; + /** BundledDocumentMetadata queries. */ + public queries: string[]; + /** * Creates a BundledDocumentMetadata message from a plain object. Also converts values to their respective internal types. * @param object Plain object diff --git a/dev/protos/firestore_v1_proto_api.js b/dev/protos/firestore_v1_proto_api.js index 83155cfba..72cba1091 100644 --- a/dev/protos/firestore_v1_proto_api.js +++ b/dev/protos/firestore_v1_proto_api.js @@ -321,6 +321,7 @@ * @property {string|null} [name] BundledDocumentMetadata name * @property {google.protobuf.ITimestamp|null} [readTime] BundledDocumentMetadata readTime * @property {boolean|null} [exists] BundledDocumentMetadata exists + * @property {Array.|null} [queries] BundledDocumentMetadata queries */ /** @@ -332,6 +333,7 @@ * @param {firestore.IBundledDocumentMetadata=} [properties] Properties to set */ function BundledDocumentMetadata(properties) { + this.queries = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -362,6 +364,14 @@ */ BundledDocumentMetadata.prototype.exists = false; + /** + * BundledDocumentMetadata queries. + * @member {Array.} queries + * @memberof firestore.BundledDocumentMetadata + * @instance + */ + BundledDocumentMetadata.prototype.queries = $util.emptyArray; + /** * Creates a BundledDocumentMetadata message from a plain object. Also converts values to their respective internal types. * @function fromObject @@ -383,6 +393,13 @@ } if (object.exists != null) message.exists = Boolean(object.exists); + if (object.queries) { + if (!Array.isArray(object.queries)) + throw TypeError(".firestore.BundledDocumentMetadata.queries: array expected"); + message.queries = []; + for (var i = 0; i < object.queries.length; ++i) + message.queries[i] = String(object.queries[i]); + } return message; }; @@ -399,6 +416,8 @@ if (!options) options = {}; var object = {}; + if (options.arrays || options.defaults) + object.queries = []; if (options.defaults) { object.name = ""; object.readTime = null; @@ -410,6 +429,11 @@ object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); if (message.exists != null && message.hasOwnProperty("exists")) object.exists = message.exists; + if (message.queries && message.queries.length) { + object.queries = []; + for (var j = 0; j < message.queries.length; ++j) + object.queries[j] = message.queries[j]; + } return object; }; diff --git a/dev/src/bundle.ts b/dev/src/bundle.ts index 6aa01f0d8..eb511bb01 100644 --- a/dev/src/bundle.ts +++ b/dev/src/bundle.ts @@ -84,16 +84,33 @@ export class BundleBuilder { return this; } - private addBundledDocument(snap: DocumentSnapshot): void { - const docProto = snap.toDocumentProto(); - this.documents.set(snap.id, { - document: snap.exists ? docProto : undefined, - metadata: { - name: docProto.name, - readTime: snap.readTime.toProto().timestampValue, - exists: snap.exists, - }, - }); + private addBundledDocument(snap: DocumentSnapshot, queryName?: string): void { + const originalDocument = this.documents.get(snap.id); + const originalQueries = originalDocument?.metadata.queries; + + // Update with document built from `snap` because it is newer. + if ( + !originalDocument || + Timestamp.fromProto(originalDocument.metadata.readTime!) < snap.readTime + ) { + const docProto = snap.toDocumentProto(); + this.documents.set(snap.id, { + document: snap.exists ? docProto : undefined, + metadata: { + name: docProto.name, + readTime: snap.readTime.toProto().timestampValue, + exists: snap.exists, + }, + }); + } + + // Update `queries` to include both original and `queryName`. + const newDocument = this.documents.get(snap.id)!; + newDocument.metadata.queries = originalQueries || []; + if (queryName) { + newDocument.metadata.queries!.push(queryName); + } + if (snap.readTime > this.latestReadTime) { this.latestReadTime = snap.readTime; } @@ -101,7 +118,7 @@ export class BundleBuilder { private addNamedQuery(name: string, querySnap: QuerySnapshot): void { if (this.namedQueries.has(name)) { - throw new Error(`Query name conflict: ${name} is already added.`); + throw new Error(`Query name conflict: ${name} has already been added.`); } this.namedQueries.set(name, { @@ -111,7 +128,7 @@ export class BundleBuilder { }); for (const snap of querySnap.docs) { - this.addBundledDocument(snap); + this.addBundledDocument(snap, name); } if (querySnap.readTime > this.latestReadTime) { diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index f1096d837..d1edab48c 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -2551,6 +2551,7 @@ describe('Bundle building', () => { name: snap.toDocumentProto().name, readTime: snap.readTime.toProto().timestampValue, exists: false, + queries: [], }); }); @@ -2621,6 +2622,7 @@ describe('Bundle building', () => { name: limitToLastSnap.docs[0].toDocumentProto().name, readTime: limitToLastSnap.readTime.toProto().timestampValue, exists: true, + queries: ['limitQuery', 'limitToLastQuery'], }); const bundledDoc = (elements[4] as IBundleElement).document; diff --git a/dev/test/bundle.ts b/dev/test/bundle.ts index d93221233..a3d42a572 100644 --- a/dev/test/bundle.ts +++ b/dev/test/bundle.ts @@ -97,7 +97,7 @@ describe('Bundle Buidler', () => { bundle.add(snap1); bundle.add(snap2); - // Bundle is expected to be [bundleMeta, snap2Meta, snap2] because `snap2` is added later. + // Bundle is expected to be [bundleMeta, snap2Meta, snap2] because `snap1` is newer. const elements = await bundleToElementArray(bundle.build()); expect(elements.length).to.equal(3); @@ -113,11 +113,12 @@ describe('Bundle Buidler', () => { const docMeta = (elements[1] as IBundleElement).documentMetadata; const docSnap = (elements[2] as IBundleElement).document; expect(docMeta).to.deep.equal({ - name: snap2.toDocumentProto().name, - readTime: snap2.readTime.toProto().timestampValue, + name: snap1.toDocumentProto().name, + readTime: snap1.readTime.toProto().timestampValue, exists: true, + queries: [], }); - expect(docSnap).to.deep.equal(snap2.toDocumentProto()); + expect(docSnap).to.deep.equal(snap1.toDocumentProto()); }); it('succeeds with query snapshots', async () => { @@ -144,10 +145,20 @@ describe('Bundle Buidler', () => { () => [] ); + const newQuery = firestore.collection('collectionId'); + const newQuerySnapshot = new QuerySnapshot( + newQuery, + snap.readTime, + 1, + () => [snap], + () => [] + ); + bundle.add('test-query', querySnapshot); - // Bundle is expected to be [bundleMeta, namedQuery, snapMeta, snap] + bundle.add('test-query-new', newQuerySnapshot); + // Bundle is expected to be [bundleMeta, namedQuery, newNamedQuery, snapMeta, snap] const elements = await bundleToElementArray(bundle.build()); - expect(elements.length).to.equal(4); + expect(elements.length).to.equal(5); const meta = (elements[0] as IBundleElement).metadata; verifyMetadata( @@ -158,7 +169,11 @@ describe('Bundle Buidler', () => { ); // Verify named query - const namedQuery = (elements[1] as IBundleElement).namedQuery; + const namedQuery = elements.find(e => e.namedQuery?.name === 'test-query')! + .namedQuery; + const newNamedQuery = elements.find( + e => e.namedQuery?.name === 'test-query-new' + )!.namedQuery; expect(namedQuery).to.deep.equal({ name: 'test-query', readTime: snap.readTime.toProto().timestampValue, @@ -171,14 +186,28 @@ describe('Bundle Buidler', () => { } ), }); + expect(newNamedQuery).to.deep.equal({ + name: 'test-query-new', + readTime: snap.readTime.toProto().timestampValue, + bundledQuery: extend( + true, + {}, + { + parent: newQuery.toProto().parent, + structuredQuery: newQuery.toProto().structuredQuery, + } + ), + }); // Verify docMeta and docSnap - const docMeta = (elements[2] as IBundleElement).documentMetadata; - const docSnap = (elements[3] as IBundleElement).document; + const docMeta = (elements[3] as IBundleElement).documentMetadata; + const docSnap = (elements[4] as IBundleElement).document; + docMeta?.queries?.sort(); expect(docMeta).to.deep.equal({ name: snap.toDocumentProto().name, readTime: snap.readTime.toProto().timestampValue, exists: true, + queries: ['test-query', 'test-query-new'], }); expect(docSnap).to.deep.equal(snap.toDocumentProto()); }); @@ -217,6 +246,7 @@ describe('Bundle Buidler', () => { name: snap1.toDocumentProto().name, readTime: snap1.readTime.toProto().timestampValue, exists: true, + queries: [], }); expect(doc1Snap).to.deep.equal(snap1.toDocumentProto()); @@ -253,6 +283,7 @@ describe('Bundle Buidler', () => { name: snap2.toDocumentProto().name, readTime: snap2.readTime.toProto().timestampValue, exists: true, + queries: [], }); expect(doc2Snap).to.deep.equal(snap2.toDocumentProto()); }); From 421986e351d84602e0352a73e361fe7b78ae56f0 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 11 Aug 2020 22:11:03 -0700 Subject: [PATCH 170/337] build: use gapic-generator-typescript v1.0.7. (#1283) This new generator will bring some changes to the generated code across all libraries, but the behavior will only change for nodejs-logging and nodejs-pubsub (those two libraries that use request batching). For other libraries, the changes should be minor (the createApiCall call is simplified) and it should be safe to merge them. Please talk to @alexander-fenster if you have any questions. PiperOrigin-RevId: 325949033 Source-Author: Google APIs Source-Date: Mon Aug 10 21:11:13 2020 -0700 Source-Repo: googleapis/googleapis Source-Sha: 94006b3cb8d2fb44703cf535da15608eed6bf7db Source-Link: https://github.com/googleapis/googleapis/commit/94006b3cb8d2fb44703cf535da15608eed6bf7db --- dev/src/v1/firestore_admin_client.ts | 8 +++++--- dev/src/v1/firestore_client.ts | 8 +++++--- dev/src/v1beta1/firestore_client.ts | 8 +++++--- synth.metadata | 6 +++--- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index 07d7b5620..6c0694e63 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -327,12 +327,14 @@ export class FirestoreAdminClient { } ); + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - this.descriptors.page[methodName] || - this.descriptors.stream[methodName] || - this.descriptors.longrunning[methodName] + descriptor ); this.innerApiCalls[methodName] = apiCall; diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 9cf4fcd7f..d18376520 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -276,12 +276,14 @@ export class FirestoreClient { } ); + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.stream[methodName] || + undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - this.descriptors.page[methodName] || - this.descriptors.stream[methodName] || - this.descriptors.longrunning[methodName] + descriptor ); this.innerApiCalls[methodName] = apiCall; diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index ca2a5a2e9..125dee107 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -280,12 +280,14 @@ export class FirestoreClient { } ); + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.stream[methodName] || + undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - this.descriptors.page[methodName] || - this.descriptors.stream[methodName] || - this.descriptors.longrunning[methodName] + descriptor ); this.innerApiCalls[methodName] = apiCall; diff --git a/synth.metadata b/synth.metadata index c20f3dbd5..8603c8222 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "34d672870f9a4673e990176e4453c4202a1386f9" + "sha": "9cd53be4a7f37b8d1f61a1b8567fa8b7ccce0e3e" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "8500bd52067f0842f56d81369ac36087afe617f8", - "internalRef": "320626855" + "sha": "94006b3cb8d2fb44703cf535da15608eed6bf7db", + "internalRef": "325949033" } }, { From 382128b83de01cc0f88110393a1271b8d768509e Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Mon, 17 Aug 2020 12:30:25 -0500 Subject: [PATCH 171/337] fix: correct BulkWriter types in firestore.d.ts (#1284) --- types/firestore.d.ts | 61 +++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 7d551819d..769e79c38 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -474,10 +474,7 @@ declare namespace FirebaseFirestore { * @returns A promise that resolves with the result * of the write. Throws an error if the write fails. */ - create( - documentRef: DocumentReference, - data: DocumentData - ): Promise; + create(documentRef: DocumentReference, data: T): Promise; /** * Delete a document from the database. @@ -493,7 +490,7 @@ declare namespace FirebaseFirestore { * of the write. Throws an error if the write fails. */ delete( - documentRef: DocumentReference, + documentRef: DocumentReference, precondition?: Precondition ): Promise; @@ -539,23 +536,47 @@ declare namespace FirebaseFirestore { * A Precondition restricting this update can be specified as the last * argument. * - * @param documentRef A reference to the document to be - * updated. - * @param dataOrField An object containing the - * fields and values with which to update the document or the path of the - * first field to update. - * @param preconditionOrValues - An - * alternating list of field paths and values to update or a Precondition to - * restrict this update - * @returns A promise that resolves with the result - * of the write. Throws an error if the write fails. + * @param documentRef A reference to the document to be updated. + * @param data An object containing the fields and values with which to + * update the document. + * @param precondition A Precondition to enforce on this update. + * @returns A promise that resolves with the result of the write. Throws + * an error if the write fails. */ update( - documentRef: DocumentReference, - dataOrField: UpdateData | string | FieldPath, - ...preconditionOrValues: Array< - {lastUpdateTime?: Timestamp} | unknown | string | FieldPath - > + documentRef: DocumentReference, + data: UpdateData, + precondition?: Precondition + ): Promise; + + /** + * Update fields of the document referred to by the provided + * [DocumentReference]{@link DocumentReference}. If the document doesn't yet + * exist, the update fails and the entire batch will be rejected. + * + * The update() method accepts either an object with field paths encoded as + * keys and field values encoded as values, or a variable number of + * arguments that alternate between field paths and field values. Nested + * fields can be updated by providing dot-separated field path strings or by + * providing FieldPath objects. + * + * + * A Precondition restricting this update can be specified as the last + * argument. + * + * @param documentRef A reference to the document to be updated. + * @param field The first field to update. + * @param value The first value + * @param fieldsOrPrecondition An alternating list of field paths and values + * to update, optionally followed a `Precondition` to enforce on this update. + * @returns A promise that resolves with the result of the write. Throws + * an error if the write fails. + */ + update( + documentRef: DocumentReference, + field: string | FieldPath, + value: any, + ...fieldsOrPrecondition: any[] ): Promise; /** From 6718ec20f94851a403ecea2e2bb329d77afa1016 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Thu, 20 Aug 2020 16:15:06 -0500 Subject: [PATCH 172/337] chore: run synthtool for != queries (#1288) --- dev/protos/firestore_v1_proto_api.d.ts | 98 +++---- dev/protos/firestore_v1_proto_api.js | 250 ++++++++++-------- .../google/firestore/v1/firestore.proto | 10 +- dev/protos/google/firestore/v1/query.proto | 56 +++- dev/protos/google/protobuf/any.proto | 9 +- dev/protos/google/protobuf/empty.proto | 2 +- dev/protos/google/protobuf/field_mask.proto | 2 +- dev/protos/google/protobuf/struct.proto | 2 +- dev/protos/google/protobuf/timestamp.proto | 13 +- dev/protos/google/protobuf/wrappers.proto | 2 +- dev/protos/protos.json | 32 ++- dev/src/v1/firestore_client.ts | 21 +- synth.metadata | 10 +- 13 files changed, 294 insertions(+), 213 deletions(-) diff --git a/dev/protos/firestore_v1_proto_api.d.ts b/dev/protos/firestore_v1_proto_api.d.ts index 3d1c5468d..2e07e21c9 100644 --- a/dev/protos/firestore_v1_proto_api.d.ts +++ b/dev/protos/firestore_v1_proto_api.d.ts @@ -5477,7 +5477,7 @@ export namespace google { /** Operator enum. */ type Operator = - "OPERATOR_UNSPECIFIED"| "LESS_THAN"| "LESS_THAN_OR_EQUAL"| "GREATER_THAN"| "GREATER_THAN_OR_EQUAL"| "EQUAL"| "ARRAY_CONTAINS"| "IN"| "ARRAY_CONTAINS_ANY"; + "OPERATOR_UNSPECIFIED"| "LESS_THAN"| "LESS_THAN_OR_EQUAL"| "GREATER_THAN"| "GREATER_THAN_OR_EQUAL"| "EQUAL"| "NOT_EQUAL"| "ARRAY_CONTAINS"| "IN"| "ARRAY_CONTAINS_ANY"| "NOT_IN"; } /** Properties of an UnaryFilter. */ @@ -5534,7 +5534,54 @@ export namespace google { /** Operator enum. */ type Operator = - "OPERATOR_UNSPECIFIED"| "IS_NAN"| "IS_NULL"; + "OPERATOR_UNSPECIFIED"| "IS_NAN"| "IS_NULL"| "IS_NOT_NAN"| "IS_NOT_NULL"; + } + + /** Properties of an Order. */ + interface IOrder { + + /** Order field */ + field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); + + /** Order direction */ + direction?: (google.firestore.v1.StructuredQuery.Direction|null); + } + + /** Represents an Order. */ + class Order implements IOrder { + + /** + * Constructs a new Order. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.StructuredQuery.IOrder); + + /** Order field. */ + public field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); + + /** Order direction. */ + public direction: google.firestore.v1.StructuredQuery.Direction; + + /** + * Creates an Order message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Order + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.Order; + + /** + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @param message Order + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.Order, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Order to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; } /** Properties of a FieldReference. */ @@ -5619,53 +5666,6 @@ export namespace google { public toJSON(): { [k: string]: any }; } - /** Properties of an Order. */ - interface IOrder { - - /** Order field */ - field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); - - /** Order direction */ - direction?: (google.firestore.v1.StructuredQuery.Direction|null); - } - - /** Represents an Order. */ - class Order implements IOrder { - - /** - * Constructs a new Order. - * @param [properties] Properties to set - */ - constructor(properties?: google.firestore.v1.StructuredQuery.IOrder); - - /** Order field. */ - public field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); - - /** Order direction. */ - public direction: google.firestore.v1.StructuredQuery.Direction; - - /** - * Creates an Order message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns Order - */ - public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.Order; - - /** - * Creates a plain object from an Order message. Also converts values to other types if specified. - * @param message Order - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: google.firestore.v1.StructuredQuery.Order, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this Order to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - } - /** Direction enum. */ type Direction = "DIRECTION_UNSPECIFIED"| "ASCENDING"| "DESCENDING"; diff --git a/dev/protos/firestore_v1_proto_api.js b/dev/protos/firestore_v1_proto_api.js index 72cba1091..ded2d07c8 100644 --- a/dev/protos/firestore_v1_proto_api.js +++ b/dev/protos/firestore_v1_proto_api.js @@ -13119,6 +13119,10 @@ case 5: message.op = 5; break; + case "NOT_EQUAL": + case 6: + message.op = 6; + break; case "ARRAY_CONTAINS": case 7: message.op = 7; @@ -13131,6 +13135,10 @@ case 9: message.op = 9; break; + case "NOT_IN": + case 10: + message.op = 10; + break; } if (object.value != null) { if (typeof object.value !== "object") @@ -13188,9 +13196,11 @@ * @property {string} GREATER_THAN=GREATER_THAN GREATER_THAN value * @property {string} GREATER_THAN_OR_EQUAL=GREATER_THAN_OR_EQUAL GREATER_THAN_OR_EQUAL value * @property {string} EQUAL=EQUAL EQUAL value + * @property {string} NOT_EQUAL=NOT_EQUAL NOT_EQUAL value * @property {string} ARRAY_CONTAINS=ARRAY_CONTAINS ARRAY_CONTAINS value * @property {string} IN=IN IN value * @property {string} ARRAY_CONTAINS_ANY=ARRAY_CONTAINS_ANY ARRAY_CONTAINS_ANY value + * @property {string} NOT_IN=NOT_IN NOT_IN value */ FieldFilter.Operator = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -13200,9 +13210,11 @@ values[valuesById[3] = "GREATER_THAN"] = "GREATER_THAN"; values[valuesById[4] = "GREATER_THAN_OR_EQUAL"] = "GREATER_THAN_OR_EQUAL"; values[valuesById[5] = "EQUAL"] = "EQUAL"; + values[valuesById[6] = "NOT_EQUAL"] = "NOT_EQUAL"; values[valuesById[7] = "ARRAY_CONTAINS"] = "ARRAY_CONTAINS"; values[valuesById[8] = "IN"] = "IN"; values[valuesById[9] = "ARRAY_CONTAINS_ANY"] = "ARRAY_CONTAINS_ANY"; + values[valuesById[10] = "NOT_IN"] = "NOT_IN"; return values; })(); @@ -13289,6 +13301,14 @@ case 3: message.op = 3; break; + case "IS_NOT_NAN": + case 4: + message.op = 4; + break; + case "IS_NOT_NULL": + case 5: + message.op = 5; + break; } if (object.field != null) { if (typeof object.field !== "object") @@ -13341,18 +13361,135 @@ * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value * @property {string} IS_NAN=IS_NAN IS_NAN value * @property {string} IS_NULL=IS_NULL IS_NULL value + * @property {string} IS_NOT_NAN=IS_NOT_NAN IS_NOT_NAN value + * @property {string} IS_NOT_NULL=IS_NOT_NULL IS_NOT_NULL value */ UnaryFilter.Operator = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; values[valuesById[2] = "IS_NAN"] = "IS_NAN"; values[valuesById[3] = "IS_NULL"] = "IS_NULL"; + values[valuesById[4] = "IS_NOT_NAN"] = "IS_NOT_NAN"; + values[valuesById[5] = "IS_NOT_NULL"] = "IS_NOT_NULL"; return values; })(); return UnaryFilter; })(); + StructuredQuery.Order = (function() { + + /** + * Properties of an Order. + * @memberof google.firestore.v1.StructuredQuery + * @interface IOrder + * @property {google.firestore.v1.StructuredQuery.IFieldReference|null} [field] Order field + * @property {google.firestore.v1.StructuredQuery.Direction|null} [direction] Order direction + */ + + /** + * Constructs a new Order. + * @memberof google.firestore.v1.StructuredQuery + * @classdesc Represents an Order. + * @implements IOrder + * @constructor + * @param {google.firestore.v1.StructuredQuery.IOrder=} [properties] Properties to set + */ + function Order(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Order field. + * @member {google.firestore.v1.StructuredQuery.IFieldReference|null|undefined} field + * @memberof google.firestore.v1.StructuredQuery.Order + * @instance + */ + Order.prototype.field = null; + + /** + * Order direction. + * @member {google.firestore.v1.StructuredQuery.Direction} direction + * @memberof google.firestore.v1.StructuredQuery.Order + * @instance + */ + Order.prototype.direction = 0; + + /** + * Creates an Order message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1.StructuredQuery.Order + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1.StructuredQuery.Order} Order + */ + Order.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1.StructuredQuery.Order) + return object; + var message = new $root.google.firestore.v1.StructuredQuery.Order(); + if (object.field != null) { + if (typeof object.field !== "object") + throw TypeError(".google.firestore.v1.StructuredQuery.Order.field: object expected"); + message.field = $root.google.firestore.v1.StructuredQuery.FieldReference.fromObject(object.field); + } + switch (object.direction) { + case "DIRECTION_UNSPECIFIED": + case 0: + message.direction = 0; + break; + case "ASCENDING": + case 1: + message.direction = 1; + break; + case "DESCENDING": + case 2: + message.direction = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1.StructuredQuery.Order + * @static + * @param {google.firestore.v1.StructuredQuery.Order} message Order + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Order.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.field = null; + object.direction = options.enums === String ? "DIRECTION_UNSPECIFIED" : 0; + } + if (message.field != null && message.hasOwnProperty("field")) + object.field = $root.google.firestore.v1.StructuredQuery.FieldReference.toObject(message.field, options); + if (message.direction != null && message.hasOwnProperty("direction")) + object.direction = options.enums === String ? $root.google.firestore.v1.StructuredQuery.Direction[message.direction] : message.direction; + return object; + }; + + /** + * Converts this Order to JSON. + * @function toJSON + * @memberof google.firestore.v1.StructuredQuery.Order + * @instance + * @returns {Object.} JSON object + */ + Order.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Order; + })(); + StructuredQuery.FieldReference = (function() { /** @@ -13531,119 +13668,6 @@ return Projection; })(); - StructuredQuery.Order = (function() { - - /** - * Properties of an Order. - * @memberof google.firestore.v1.StructuredQuery - * @interface IOrder - * @property {google.firestore.v1.StructuredQuery.IFieldReference|null} [field] Order field - * @property {google.firestore.v1.StructuredQuery.Direction|null} [direction] Order direction - */ - - /** - * Constructs a new Order. - * @memberof google.firestore.v1.StructuredQuery - * @classdesc Represents an Order. - * @implements IOrder - * @constructor - * @param {google.firestore.v1.StructuredQuery.IOrder=} [properties] Properties to set - */ - function Order(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Order field. - * @member {google.firestore.v1.StructuredQuery.IFieldReference|null|undefined} field - * @memberof google.firestore.v1.StructuredQuery.Order - * @instance - */ - Order.prototype.field = null; - - /** - * Order direction. - * @member {google.firestore.v1.StructuredQuery.Direction} direction - * @memberof google.firestore.v1.StructuredQuery.Order - * @instance - */ - Order.prototype.direction = 0; - - /** - * Creates an Order message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.firestore.v1.StructuredQuery.Order - * @static - * @param {Object.} object Plain object - * @returns {google.firestore.v1.StructuredQuery.Order} Order - */ - Order.fromObject = function fromObject(object) { - if (object instanceof $root.google.firestore.v1.StructuredQuery.Order) - return object; - var message = new $root.google.firestore.v1.StructuredQuery.Order(); - if (object.field != null) { - if (typeof object.field !== "object") - throw TypeError(".google.firestore.v1.StructuredQuery.Order.field: object expected"); - message.field = $root.google.firestore.v1.StructuredQuery.FieldReference.fromObject(object.field); - } - switch (object.direction) { - case "DIRECTION_UNSPECIFIED": - case 0: - message.direction = 0; - break; - case "ASCENDING": - case 1: - message.direction = 1; - break; - case "DESCENDING": - case 2: - message.direction = 2; - break; - } - return message; - }; - - /** - * Creates a plain object from an Order message. Also converts values to other types if specified. - * @function toObject - * @memberof google.firestore.v1.StructuredQuery.Order - * @static - * @param {google.firestore.v1.StructuredQuery.Order} message Order - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Order.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.field = null; - object.direction = options.enums === String ? "DIRECTION_UNSPECIFIED" : 0; - } - if (message.field != null && message.hasOwnProperty("field")) - object.field = $root.google.firestore.v1.StructuredQuery.FieldReference.toObject(message.field, options); - if (message.direction != null && message.hasOwnProperty("direction")) - object.direction = options.enums === String ? $root.google.firestore.v1.StructuredQuery.Direction[message.direction] : message.direction; - return object; - }; - - /** - * Converts this Order to JSON. - * @function toJSON - * @memberof google.firestore.v1.StructuredQuery.Order - * @instance - * @returns {Object.} JSON object - */ - Order.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Order; - })(); - /** * Direction enum. * @name google.firestore.v1.StructuredQuery.Direction diff --git a/dev/protos/google/firestore/v1/firestore.proto b/dev/protos/google/firestore/v1/firestore.proto index ee32c410c..e035d1b4e 100644 --- a/dev/protos/google/firestore/v1/firestore.proto +++ b/dev/protos/google/firestore/v1/firestore.proto @@ -533,14 +533,15 @@ message PartitionQueryRequest { // The query to partition. oneof query_type { // A structured query. - // Filters, order bys, limits, offsets, and start/end cursors are not - // supported. + // Query must specify collection with all descendants and be ordered by name + // ascending. Other filters, order bys, limits, offsets, and start/end + // cursors are not supported. StructuredQuery structured_query = 2; } // 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 + // The number must be positive. The actual number of partitions // returned may be fewer. // // For example, this may be set to one fewer than the number of parallel @@ -589,6 +590,9 @@ message PartitionQueryResponse { // * query, end_at A // * query, start_at A, end_at B // * query, start_at B + // + // An empty result may indicate that the query has too few results to be + // partitioned. repeated Cursor partitions = 1; // A page token that may be used to request an additional set of results, up diff --git a/dev/protos/google/firestore/v1/query.proto b/dev/protos/google/firestore/v1/query.proto index 9c267fe68..eea1d1178 100644 --- a/dev/protos/google/firestore/v1/query.proto +++ b/dev/protos/google/firestore/v1/query.proto @@ -115,6 +115,14 @@ message StructuredQuery { // The given `field` is equal to the given `value`. EQUAL = 5; + // The given `field` is not equal to the given `value`. + // + // Requires: + // + // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + NOT_EQUAL = 6; + // The given `field` is an array that contains the given `value`. ARRAY_CONTAINS = 7; @@ -123,7 +131,7 @@ message StructuredQuery { // Requires: // // * That `value` is a non-empty `ArrayValue` with at most 10 values. - // * No other `IN`, `ARRAY_CONTAINS_ANY`, or `NOT_IN`. + // * No other `IN` or `ARRAY_CONTAINS_ANY` or `NOT_IN`. IN = 8; // The given `field` is an array that contains any of the values in the @@ -132,8 +140,18 @@ message StructuredQuery { // Requires: // // * That `value` is a non-empty `ArrayValue` with at most 10 values. - // * No other `IN`, `ARRAY_CONTAINS_ANY`, or `NOT_IN`. + // * No other `IN` or `ARRAY_CONTAINS_ANY` or `NOT_IN`. ARRAY_CONTAINS_ANY = 9; + + // The value of the `field` is not in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN`, `ARRAY_CONTAINS_ANY`, `NOT_IN`, `NOT_EQUAL`, + // `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + NOT_IN = 10; } // The field to filter by. @@ -158,6 +176,22 @@ message StructuredQuery { // The given `field` is equal to `NULL`. IS_NULL = 3; + + // The given `field` is not equal to `NaN`. + // + // Requires: + // + // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + IS_NOT_NAN = 4; + + // The given `field` is not equal to `NULL`. + // + // Requires: + // + // * A single `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + IS_NOT_NULL = 5; } // The unary operator to apply. @@ -170,6 +204,15 @@ message StructuredQuery { } } + // An order on a field. + message Order { + // The field to order by. + FieldReference field = 1; + + // The direction to order by. Defaults to `ASCENDING`. + Direction direction = 2; + } + // A reference to a field, such as `max(messages.time) as max_time`. message FieldReference { string field_path = 2; @@ -184,15 +227,6 @@ message StructuredQuery { repeated FieldReference fields = 2; } - // An order on a field. - message Order { - // The field to order by. - FieldReference field = 1; - - // The direction to order by. Defaults to `ASCENDING`. - Direction direction = 2; - } - // A sort direction. enum Direction { // Unspecified. diff --git a/dev/protos/google/protobuf/any.proto b/dev/protos/google/protobuf/any.proto index c9be85416..6ed8a23cf 100644 --- a/dev/protos/google/protobuf/any.proto +++ b/dev/protos/google/protobuf/any.proto @@ -33,7 +33,7 @@ syntax = "proto3"; package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option go_package = "github.com/golang/protobuf/ptypes/any"; +option go_package = "google.golang.org/protobuf/types/known/anypb"; option java_package = "com.google.protobuf"; option java_outer_classname = "AnyProto"; option java_multiple_files = true; @@ -77,10 +77,13 @@ option objc_class_prefix = "GPB"; // Example 4: Pack and unpack a message in Go // // foo := &pb.Foo{...} -// any, err := ptypes.MarshalAny(foo) +// any, err := anypb.New(foo) +// if err != nil { +// ... +// } // ... // foo := &pb.Foo{} -// if err := ptypes.UnmarshalAny(any, foo); err != nil { +// if err := any.UnmarshalTo(foo); err != nil { // ... // } // diff --git a/dev/protos/google/protobuf/empty.proto b/dev/protos/google/protobuf/empty.proto index 03cacd233..5f992de94 100644 --- a/dev/protos/google/protobuf/empty.proto +++ b/dev/protos/google/protobuf/empty.proto @@ -33,7 +33,7 @@ syntax = "proto3"; package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option go_package = "github.com/golang/protobuf/ptypes/empty"; +option go_package = "google.golang.org/protobuf/types/known/emptypb"; option java_package = "com.google.protobuf"; option java_outer_classname = "EmptyProto"; option java_multiple_files = true; diff --git a/dev/protos/google/protobuf/field_mask.proto b/dev/protos/google/protobuf/field_mask.proto index baac8744c..6b5104f18 100644 --- a/dev/protos/google/protobuf/field_mask.proto +++ b/dev/protos/google/protobuf/field_mask.proto @@ -37,7 +37,7 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "FieldMaskProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; -option go_package = "google.golang.org/genproto/protobuf/field_mask;field_mask"; +option go_package = "google.golang.org/protobuf/types/known/fieldmaskpb"; option cc_enable_arenas = true; // `FieldMask` represents a set of symbolic field paths, for example: diff --git a/dev/protos/google/protobuf/struct.proto b/dev/protos/google/protobuf/struct.proto index ed990e31d..545215c25 100644 --- a/dev/protos/google/protobuf/struct.proto +++ b/dev/protos/google/protobuf/struct.proto @@ -34,7 +34,7 @@ package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option cc_enable_arenas = true; -option go_package = "github.com/golang/protobuf/ptypes/struct;structpb"; +option go_package = "google.golang.org/protobuf/types/known/structpb"; option java_package = "com.google.protobuf"; option java_outer_classname = "StructProto"; option java_multiple_files = true; diff --git a/dev/protos/google/protobuf/timestamp.proto b/dev/protos/google/protobuf/timestamp.proto index cd357864a..3b2df6d91 100644 --- a/dev/protos/google/protobuf/timestamp.proto +++ b/dev/protos/google/protobuf/timestamp.proto @@ -34,7 +34,7 @@ package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option cc_enable_arenas = true; -option go_package = "github.com/golang/protobuf/ptypes/timestamp"; +option go_package = "google.golang.org/protobuf/types/known/timestamppb"; option java_package = "com.google.protobuf"; option java_outer_classname = "TimestampProto"; option java_multiple_files = true; @@ -91,7 +91,16 @@ option objc_class_prefix = "GPB"; // .setNanos((int) ((millis % 1000) * 1000000)).build(); // // -// Example 5: Compute Timestamp from current time in Python. +// Example 5: Compute Timestamp from Java `Instant.now()`. +// +// Instant now = Instant.now(); +// +// Timestamp timestamp = +// Timestamp.newBuilder().setSeconds(now.getEpochSecond()) +// .setNanos(now.getNano()).build(); +// +// +// Example 6: Compute Timestamp from current time in Python. // // timestamp = Timestamp() // timestamp.GetCurrentTime() diff --git a/dev/protos/google/protobuf/wrappers.proto b/dev/protos/google/protobuf/wrappers.proto index 9ee41e384..d49dd53c8 100644 --- a/dev/protos/google/protobuf/wrappers.proto +++ b/dev/protos/google/protobuf/wrappers.proto @@ -44,7 +44,7 @@ package google.protobuf; option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option cc_enable_arenas = true; -option go_package = "github.com/golang/protobuf/ptypes/wrappers"; +option go_package = "google.golang.org/protobuf/types/known/wrapperspb"; option java_package = "com.google.protobuf"; option java_outer_classname = "WrappersProto"; option java_multiple_files = true; diff --git a/dev/protos/protos.json b/dev/protos/protos.json index fb07f7b58..5de9ba2e7 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -1772,9 +1772,11 @@ "GREATER_THAN": 3, "GREATER_THAN_OR_EQUAL": 4, "EQUAL": 5, + "NOT_EQUAL": 6, "ARRAY_CONTAINS": 7, "IN": 8, - "ARRAY_CONTAINS_ANY": 9 + "ARRAY_CONTAINS_ANY": 9, + "NOT_IN": 10 } } } @@ -1802,11 +1804,25 @@ "values": { "OPERATOR_UNSPECIFIED": 0, "IS_NAN": 2, - "IS_NULL": 3 + "IS_NULL": 3, + "IS_NOT_NAN": 4, + "IS_NOT_NULL": 5 } } } }, + "Order": { + "fields": { + "field": { + "type": "FieldReference", + "id": 1 + }, + "direction": { + "type": "Direction", + "id": 2 + } + } + }, "FieldReference": { "fields": { "fieldPath": { @@ -1824,18 +1840,6 @@ } } }, - "Order": { - "fields": { - "field": { - "type": "FieldReference", - "id": 1 - }, - "direction": { - "type": "Direction", - "id": 2 - } - } - }, "Direction": { "values": { "DIRECTION_UNSPECIFIED": 0, diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index d18376520..194b26f83 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -1505,12 +1505,13 @@ export class FirestoreClient { * 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. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other 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 + * The number must be positive. The actual number of partitions * returned may be fewer. * * For example, this may be set to one fewer than the number of parallel @@ -1619,12 +1620,13 @@ export class FirestoreClient { * 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. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other 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 + * The number must be positive. The actual number of partitions * returned may be fewer. * * For example, this may be set to one fewer than the number of parallel @@ -1693,12 +1695,13 @@ export class FirestoreClient { * 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. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other 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 + * The number must be positive. The actual number of partitions * returned may be fewer. * * For example, this may be set to one fewer than the number of parallel diff --git a/synth.metadata b/synth.metadata index 8603c8222..0db9a4581 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,23 +3,23 @@ { "git": { "name": ".", - "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "9cd53be4a7f37b8d1f61a1b8567fa8b7ccce0e3e" + "remote": "git@github.com:googleapis/nodejs-firestore.git", + "sha": "382128b83de01cc0f88110393a1271b8d768509e" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "94006b3cb8d2fb44703cf535da15608eed6bf7db", - "internalRef": "325949033" + "sha": "65097bb8a18449d7ebbb5f61bc4eefed81640d71", + "internalRef": "327525660" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "5936421202fb53ed4641bcb824017dd393a3dbcc" + "sha": "9602086c6c5b05db77950c7f7495a2a3868f3537" } } ], From befe625f35b7c96e9a90399a1ca71a8a049224ad Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Thu, 20 Aug 2020 16:29:35 -0500 Subject: [PATCH 173/337] fix: add capacity logging to RateLimiter (#1287) --- dev/src/rate-limiter.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dev/src/rate-limiter.ts b/dev/src/rate-limiter.ts index b3f5ccca3..2265fc975 100644 --- a/dev/src/rate-limiter.ts +++ b/dev/src/rate-limiter.ts @@ -14,6 +14,7 @@ * limitations under the License. */ import * as assert from 'assert'; +import {logger} from './logger'; /** * A helper that uses the Token Bucket algorithm to rate limit the number of @@ -36,6 +37,10 @@ export class RateLimiter { // When the token bucket was last refilled. lastRefillTimeMillis: number; + // The last operations per second capacity that was calculated. Used to log + // changes to the maximum QPS. + previousCapacity: number; + /** * @param initialCapacity Initial maximum number of operations per second. * @param multiplier Rate by which to increase the capacity. @@ -52,6 +57,7 @@ export class RateLimiter { ) { this.availableTokens = initialCapacity; this.lastRefillTimeMillis = startTimeMillis; + this.previousCapacity = initialCapacity; } /** @@ -147,6 +153,16 @@ export class RateLimiter { Math.floor(millisElapsed / this.multiplierMillis) ) * this.initialCapacity ); + + if (operationsPerSecond !== this.previousCapacity) { + logger( + 'RateLimiter.calculateCapacity', + null, + `New request capacity: ${operationsPerSecond} operations per second.` + ); + } + + this.previousCapacity = operationsPerSecond; return operationsPerSecond; } } From 852a2805ddc2486aa446c3c196f7d9f64f1cac25 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 21 Aug 2020 09:39:42 -0700 Subject: [PATCH 174/337] chore: start tracking obsolete files (#1289) --- synth.metadata | 95 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 90 insertions(+), 5 deletions(-) diff --git a/synth.metadata b/synth.metadata index 0db9a4581..0cad1e959 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,23 +3,23 @@ { "git": { "name": ".", - "remote": "git@github.com:googleapis/nodejs-firestore.git", - "sha": "382128b83de01cc0f88110393a1271b8d768509e" + "remote": "https://github.com/googleapis/nodejs-firestore.git", + "sha": "befe625f35b7c96e9a90399a1ca71a8a049224ad" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "65097bb8a18449d7ebbb5f61bc4eefed81640d71", - "internalRef": "327525660" + "sha": "6db0bbeb6e959dc4a401f7be17ce2fb79e164a5e", + "internalRef": "327771486" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "9602086c6c5b05db77950c7f7495a2a3868f3537" + "sha": "05de3e1e14a0b07eab8b474e669164dbd31f81fb" } } ], @@ -51,5 +51,90 @@ "generator": "bazel" } } + ], + "generatedFiles": [ + ".eslintignore", + ".gitattributes", + ".github/ISSUE_TEMPLATE/bug_report.md", + ".github/ISSUE_TEMPLATE/feature_request.md", + ".github/ISSUE_TEMPLATE/support_request.md", + ".github/PULL_REQUEST_TEMPLATE.md", + ".github/publish.yml", + ".github/release-please.yml", + ".github/workflows/ci.yaml", + ".gitignore", + ".jsdoc.js", + ".mocharc.js", + ".nycrc", + ".prettierignore", + ".prettierrc.js", + "CODE_OF_CONDUCT.md", + "CONTRIBUTING.md", + "LICENSE", + "README.md", + "api-extractor.json", + "dev/.eslintignore", + "dev/.eslintrc.json", + "dev/.gitignore", + "dev/.jsdoc.js", + "dev/.mocharc.js", + "dev/.prettierrc.js", + "dev/protos/firestore_admin_v1_proto_api.d.ts", + "dev/protos/firestore_admin_v1_proto_api.js", + "dev/protos/firestore_v1_proto_api.d.ts", + "dev/protos/firestore_v1_proto_api.js", + "dev/protos/firestore_v1beta1_proto_api.d.ts", + "dev/protos/firestore_v1beta1_proto_api.js", + "dev/protos/google/api/annotations.proto", + "dev/protos/google/api/client.proto", + "dev/protos/google/api/field_behavior.proto", + "dev/protos/google/api/http.proto", + "dev/protos/google/api/resource.proto", + "dev/protos/google/firestore/admin/v1/field.proto", + "dev/protos/google/firestore/admin/v1/firestore_admin.proto", + "dev/protos/google/firestore/admin/v1/index.proto", + "dev/protos/google/firestore/admin/v1/location.proto", + "dev/protos/google/firestore/admin/v1/operation.proto", + "dev/protos/google/firestore/v1/common.proto", + "dev/protos/google/firestore/v1/document.proto", + "dev/protos/google/firestore/v1/firestore.proto", + "dev/protos/google/firestore/v1/query.proto", + "dev/protos/google/firestore/v1/write.proto", + "dev/protos/google/firestore/v1beta1/common.proto", + "dev/protos/google/firestore/v1beta1/document.proto", + "dev/protos/google/firestore/v1beta1/firestore.proto", + "dev/protos/google/firestore/v1beta1/query.proto", + "dev/protos/google/firestore/v1beta1/write.proto", + "dev/protos/google/longrunning/operations.proto", + "dev/protos/google/protobuf/any.proto", + "dev/protos/google/protobuf/empty.proto", + "dev/protos/google/protobuf/field_mask.proto", + "dev/protos/google/protobuf/struct.proto", + "dev/protos/google/protobuf/timestamp.proto", + "dev/protos/google/protobuf/wrappers.proto", + "dev/protos/google/rpc/status.proto", + "dev/protos/google/type/latlng.proto", + "dev/protos/protos.d.ts", + "dev/protos/protos.js", + "dev/protos/protos.json", + "dev/src/v1/firestore_admin_client.ts", + "dev/src/v1/firestore_admin_client_config.json", + "dev/src/v1/firestore_admin_proto_list.json", + "dev/src/v1/firestore_client.ts", + "dev/src/v1/firestore_client_config.json", + "dev/src/v1/firestore_proto_list.json", + "dev/src/v1beta1/firestore_client.ts", + "dev/src/v1beta1/firestore_client_config.json", + "dev/src/v1beta1/firestore_proto_list.json", + "dev/system-test/fixtures/sample/src/index.js", + "dev/system-test/fixtures/sample/src/index.ts", + "dev/system-test/install.ts", + "dev/test/gapic_firestore_admin_v1.ts", + "dev/test/gapic_firestore_v1.ts", + "dev/test/gapic_firestore_v1beta1.ts", + "package-lock.json.3261340735", + "renovate.json", + "samples/README.md", + "samples/package-lock.json.3433869271" ] } \ No newline at end of file From 388583bae74e0daead296974beaee9c230f770ef Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sat, 22 Aug 2020 18:38:30 +0200 Subject: [PATCH 175/337] chore(deps): update dependency ts-node to v9 (#1290) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 673cabc35..0b4b581c7 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "protobufjs": "^6.8.6", "proxyquire": "^2.1.3", "sinon": "^9.0.2", - "ts-node": "^8.5.4", + "ts-node": "^9.0.0", "typescript": "3.8.3", "through2": "^4.0.0", "@microsoft/api-documenter": "^7.8.10", From e019021f7f973f75ddbd81d6f5aea184fc2a3924 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Tue, 8 Sep 2020 15:31:35 -0700 Subject: [PATCH 176/337] build: update kokoro config (#1294) --- .kokoro/continuous/node12/lint.cfg | 4 ++++ .kokoro/continuous/{node10 => node12}/samples-test.cfg | 0 .kokoro/continuous/{node10 => node12}/system-test.cfg | 0 .kokoro/populate-secrets.sh | 1 - .kokoro/presubmit/{node10 => node12}/samples-test.cfg | 0 .kokoro/presubmit/{node10 => node12}/system-test.cfg | 0 .kokoro/publish.sh | 2 +- .kokoro/release/publish.cfg | 5 +++++ .kokoro/samples-test.sh | 2 +- .kokoro/system-test.sh | 2 +- .kokoro/test.sh | 2 +- dev/src/reference.ts | 3 ++- 12 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 .kokoro/continuous/node12/lint.cfg rename .kokoro/continuous/{node10 => node12}/samples-test.cfg (100%) rename .kokoro/continuous/{node10 => node12}/system-test.cfg (100%) rename .kokoro/presubmit/{node10 => node12}/samples-test.cfg (100%) rename .kokoro/presubmit/{node10 => node12}/system-test.cfg (100%) diff --git a/.kokoro/continuous/node12/lint.cfg b/.kokoro/continuous/node12/lint.cfg new file mode 100644 index 000000000..17e5e331c --- /dev/null +++ b/.kokoro/continuous/node12/lint.cfg @@ -0,0 +1,4 @@ +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-firestore/.kokoro/lint.sh" +} diff --git a/.kokoro/continuous/node10/samples-test.cfg b/.kokoro/continuous/node12/samples-test.cfg similarity index 100% rename from .kokoro/continuous/node10/samples-test.cfg rename to .kokoro/continuous/node12/samples-test.cfg diff --git a/.kokoro/continuous/node10/system-test.cfg b/.kokoro/continuous/node12/system-test.cfg similarity index 100% rename from .kokoro/continuous/node10/system-test.cfg rename to .kokoro/continuous/node12/system-test.cfg diff --git a/.kokoro/populate-secrets.sh b/.kokoro/populate-secrets.sh index e6ce8200d..6f9d22885 100755 --- a/.kokoro/populate-secrets.sh +++ b/.kokoro/populate-secrets.sh @@ -32,7 +32,6 @@ do --volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \ gcr.io/google.com/cloudsdktool/cloud-sdk \ secrets versions access latest \ - --credential-file-override=${KOKORO_GFILE_DIR}/kokoro-trampoline.service-account.json \ --project cloud-devrel-kokoro-resources \ --secret $key > \ "$SECRET_LOCATION/$key" diff --git a/.kokoro/presubmit/node10/samples-test.cfg b/.kokoro/presubmit/node12/samples-test.cfg similarity index 100% rename from .kokoro/presubmit/node10/samples-test.cfg rename to .kokoro/presubmit/node12/samples-test.cfg diff --git a/.kokoro/presubmit/node10/system-test.cfg b/.kokoro/presubmit/node12/system-test.cfg similarity index 100% rename from .kokoro/presubmit/node10/system-test.cfg rename to .kokoro/presubmit/node12/system-test.cfg diff --git a/.kokoro/publish.sh b/.kokoro/publish.sh index 3b95b2ed3..f056d8617 100755 --- a/.kokoro/publish.sh +++ b/.kokoro/publish.sh @@ -24,7 +24,7 @@ python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source / cd $(dirname $0)/.. -NPM_TOKEN=$(cat $KOKORO_KEYSTORE_DIR/73713_google-cloud-firestore-npm-token) +NPM_TOKEN=$(cat $KOKORO_GFILE_DIR/secret_manager/npm_publish_token) echo "//wombat-dressing-room.appspot.com/:_authToken=${NPM_TOKEN}" > ~/.npmrc npm install diff --git a/.kokoro/release/publish.cfg b/.kokoro/release/publish.cfg index b5913f205..3b4b5a5fd 100644 --- a/.kokoro/release/publish.cfg +++ b/.kokoro/release/publish.cfg @@ -72,3 +72,8 @@ env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/nodejs-firestore/.kokoro/publish.sh" } + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "npm_publish_token" +} \ No newline at end of file diff --git a/.kokoro/samples-test.sh b/.kokoro/samples-test.sh index 8b49ec273..f72fa8c69 100755 --- a/.kokoro/samples-test.sh +++ b/.kokoro/samples-test.sh @@ -41,7 +41,7 @@ if [ -f samples/package.json ]; then cd .. # If tests are running against master, configure Build Cop # to open issues on failures: - if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then + if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]] || [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"nightly"* ]]; then export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml export MOCHA_REPORTER=xunit cleanup() { diff --git a/.kokoro/system-test.sh b/.kokoro/system-test.sh index 9fb520bf8..18a6a40fd 100755 --- a/.kokoro/system-test.sh +++ b/.kokoro/system-test.sh @@ -35,7 +35,7 @@ npm install # If tests are running against master, configure Build Cop # to open issues on failures: -if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then +if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]] || [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"nightly"* ]]; then export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml export MOCHA_REPORTER=xunit cleanup() { diff --git a/.kokoro/test.sh b/.kokoro/test.sh index 8d9c29545..47be59b98 100755 --- a/.kokoro/test.sh +++ b/.kokoro/test.sh @@ -23,7 +23,7 @@ cd $(dirname $0)/.. npm install # If tests are running against master, configure Build Cop # to open issues on failures: -if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then +if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]] || [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"nightly"* ]]; then export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml export MOCHA_REPORTER=xunit cleanup() { diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 857afbc84..91b964bc1 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -2306,7 +2306,8 @@ export class Query implements firestore.Query { * @class * @extends Query */ -export class CollectionReference extends Query +export class CollectionReference + extends Query implements firestore.CollectionReference { /** * @hideconstructor From 786e52f8c8b7b9c6b84ffc988190470a063d5855 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 8 Sep 2020 18:07:01 -0500 Subject: [PATCH 177/337] feat: add support for != and not-in queries (#1292) --- dev/src/reference.ts | 29 +++++++---- dev/system-test/firestore.ts | 96 ++++++++++++++++++++++++++++++++++++ dev/test/query.ts | 65 +++++++++++++++++++++--- types/firestore.d.ts | 6 ++- 4 files changed, 177 insertions(+), 19 deletions(-) diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 91b964bc1..8a0c33557 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -72,8 +72,8 @@ const directionOperators: {[k: string]: api.StructuredQuery.Direction} = { /** * Filter conditions in a `Query.where()` clause are specified using the - * strings '<', '<=', '==', '>=', '>', 'array-contains', 'in', and - * 'array-contains-any'. + * strings '<', '<=', '==', '!=', '>=', '>', 'array-contains', 'in', 'not-in', + * and 'array-contains-any'. * * @private */ @@ -83,10 +83,12 @@ const comparisonOperators: { '<': 'LESS_THAN', '<=': 'LESS_THAN_OR_EQUAL', '==': 'EQUAL', + '!=': 'NOT_EQUAL', '>': 'GREATER_THAN', '>=': 'GREATER_THAN_OR_EQUAL', 'array-contains': 'ARRAY_CONTAINS', in: 'IN', + 'not-in': 'NOT_IN', 'array-contains-any': 'ARRAY_CONTAINS_ANY', }; @@ -675,7 +677,7 @@ class FieldFilter { field: { fieldPath: this.field.formattedName, }, - op: 'IS_NAN', + op: this.op === 'EQUAL' ? 'IS_NAN' : 'IS_NOT_NAN', }, }; } @@ -686,7 +688,7 @@ class FieldFilter { field: { fieldPath: this.field.formattedName, }, - op: 'IS_NULL', + op: this.op === 'EQUAL' ? 'IS_NULL' : 'IS_NOT_NULL', }, }; } @@ -1238,7 +1240,7 @@ export class Query implements firestore.Query { ); } - if (opStr === 'in') { + if (opStr === 'in' || opStr === 'not-in') { if (!Array.isArray(value) || value.length === 0) { throw new Error( `Invalid Query. A non-empty array is required for '${opStr}' filters.` @@ -2627,19 +2629,26 @@ export function validateQueryOperator( fieldValue: unknown ): firestore.WhereFilterOp { // For backwards compatibility, we support both `=` and `==` for "equals". - op = op === '=' ? '==' : op; + if (op === '=') { + op = '=='; + } validateEnumValue(arg, op, Object.keys(comparisonOperators)); - if (typeof fieldValue === 'number' && isNaN(fieldValue) && op !== '==') { + if ( + typeof fieldValue === 'number' && + isNaN(fieldValue) && + op !== '==' && + op !== '!=' + ) { throw new Error( - 'Invalid query. You can only perform equals comparisons on NaN.' + "Invalid query. You can only perform '==' and '!=' comparisons on NaN." ); } - if (fieldValue === null && op !== '==') { + if (fieldValue === null && op !== '==' && op !== '!=') { throw new Error( - 'Invalid query. You can only perform equals comparisons on Null.' + "Invalid query. You can only perform '==' and '!=' comparisons on Null." ); } diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index d1edab48c..0dcc55f2e 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -1224,6 +1224,102 @@ describe('Query class', () => { }); }); + it('supports !=', async () => { + await addDocs( + {zip: NaN}, + {zip: 91102}, + {zip: 98101}, + {zip: 98103}, + {zip: [98101]}, + {zip: ['98101', {zip: 98101}]}, + {zip: {zip: 98101}}, + {zip: null} + ); + + let res = await randomCol.where('zip', '!=', 98101).get(); + expectDocs( + res, + {zip: NaN}, + {zip: 91102}, + {zip: 98103}, + {zip: [98101]}, + {zip: ['98101', {zip: 98101}]}, + {zip: {zip: 98101}} + ); + + res = await randomCol.where('zip', '!=', NaN).get(); + expectDocs( + res, + {zip: 91102}, + {zip: 98101}, + {zip: 98103}, + {zip: [98101]}, + {zip: ['98101', {zip: 98101}]}, + {zip: {zip: 98101}} + ); + + res = await randomCol.where('zip', '!=', null).get(); + expectDocs( + res, + {zip: NaN}, + {zip: 91102}, + {zip: 98101}, + {zip: 98103}, + {zip: [98101]}, + {zip: ['98101', {zip: 98101}]}, + {zip: {zip: 98101}} + ); + }); + + it('supports != with document ID', async () => { + const refs = await addDocs({count: 1}, {count: 2}, {count: 3}); + const res = await randomCol + .where(FieldPath.documentId(), '!=', refs[0].id) + .get(); + expectDocs(res, {count: 2}, {count: 3}); + }); + + it('supports not-in', async () => { + await addDocs( + {zip: 98101}, + {zip: 91102}, + {zip: 98103}, + {zip: [98101]}, + {zip: ['98101', {zip: 98101}]}, + {zip: {zip: 98101}} + ); + let res = await randomCol.where('zip', 'not-in', [98101, 98103]).get(); + expectDocs( + res, + {zip: 91102}, + {zip: [98101]}, + {zip: ['98101', {zip: 98101}]}, + {zip: {zip: 98101}} + ); + + res = await randomCol.where('zip', 'not-in', [NaN]).get(); + expectDocs( + res, + {zip: 91102}, + {zip: 98101}, + {zip: 98103}, + {zip: [98101]}, + {zip: ['98101', {zip: 98101}]}, + {zip: {zip: 98101}} + ); + + res = await randomCol.where('zip', 'not-in', [null]).get(); + expect(res.size).to.equal(0); + }); + + it('supports not-in with document ID array', async () => { + const refs = await addDocs({count: 1}, {count: 2}, {count: 3}); + const res = await randomCol + .where(FieldPath.documentId(), 'not-in', [refs[0].id, refs[1]]) + .get(); + expectDocs(res, {count: 3}); + }); + it('supports "in"', async () => { await addDocs( {zip: 98101}, diff --git a/dev/test/query.ts b/dev/test/query.ts index 4045b95b2..ea4505fbf 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -130,7 +130,7 @@ export function fieldFilters( function unaryFilters( fieldPath: string, - equals: 'IS_NAN' | 'IS_NULL', + equals: 'IS_NAN' | 'IS_NULL' | 'IS_NOT_NAN' | 'IS_NOT_NULL', ...fieldPathsAndEquals: string[] ): api.IStructuredQuery { const filters: api.StructuredQuery.IFilter[] = []; @@ -141,14 +141,19 @@ function unaryFilters( const fieldPath = fieldPathsAndEquals[i]; const equals = fieldPathsAndEquals[i + 1]; - expect(equals).to.be.oneOf(['IS_NAN', 'IS_NULL']); + expect(equals).to.be.oneOf([ + 'IS_NAN', + 'IS_NULL', + 'IS_NOT_NAN', + 'IS_NOT_NULL', + ]); filters.push({ unaryFilter: { field: { fieldPath, }, - op: equals as 'IS_NAN' | 'IS_NULL', + op: equals as 'IS_NAN' | 'IS_NULL' | 'IS_NOT_NAN' | 'IS_NOT_NULL', }, }); } @@ -787,6 +792,12 @@ describe('where() interface', () => { arrValue, 'fooContainsAny', 'ARRAY_CONTAINS_ANY', + arrValue, + 'fooNotEqual', + 'NOT_EQUAL', + 'barEqualsLong', + 'fooNotIn', + 'NOT_IN', arrValue ) ); @@ -806,6 +817,8 @@ describe('where() interface', () => { query = query.where('fooContains', 'array-contains', 'barContains'); query = query.where('fooIn', 'in', ['barArray']); query = query.where('fooContainsAny', 'array-contains-any', ['barArray']); + query = query.where('fooNotEqual', '!=', 'barEqualsLong'); + query = query.where('fooNotIn', 'not-in', ['barArray']); return query.get(); }); }); @@ -952,7 +965,7 @@ describe('where() interface', () => { }); }); - it('validates references for IN queries', () => { + it('validates references for in/not-in queries', () => { const query = firestore.collection('collectionId'); expect(() => { @@ -972,6 +985,24 @@ describe('where() interface', () => { }).to.throw( "Invalid Query. A non-empty array is required for 'in' filters." ); + + expect(() => { + query.where(FieldPath.documentId(), 'not-in', ['foo', 42]); + }).to.throw( + 'The corresponding value for FieldPath.documentId() must be a string or a DocumentReference, but was "42".' + ); + + expect(() => { + query.where(FieldPath.documentId(), 'not-in', 42); + }).to.throw( + "Invalid Query. A non-empty array is required for 'not-in' filters." + ); + + expect(() => { + query.where(FieldPath.documentId(), 'not-in', []); + }).to.throw( + "Invalid Query. A non-empty array is required for 'not-in' filters." + ); }); it('validates query operator for FieldPath.document()', () => { @@ -1086,13 +1117,33 @@ describe('where() interface', () => { }); }); + it('supports unary filters', () => { + const overrides: ApiOverride = { + runQuery: request => { + queryEquals( + request, + unaryFilters('foo', 'IS_NOT_NAN', 'bar', 'IS_NOT_NULL') + ); + + return stream(); + }, + }; + + return createInstance(overrides).then(firestore => { + let query: Query = firestore.collection('collectionId'); + query = query.where('foo', '!=', NaN); + query = query.where('bar', '!=', null); + return query.get(); + }); + }); + it('rejects invalid NaN filter', () => { expect(() => { let query: Query = firestore.collection('collectionId'); query = query.where('foo', '>', NaN); return query.get(); }).to.throw( - 'Invalid query. You can only perform equals comparisons on NaN.' + "Invalid query. You can only perform '==' and '!=' comparisons on NaN." ); }); @@ -1102,7 +1153,7 @@ describe('where() interface', () => { query = query.where('foo', '>', null); return query.get(); }).to.throw( - 'Invalid query. You can only perform equals comparisons on Null.' + "Invalid query. You can only perform '==' and '!=' comparisons on Null." ); }); @@ -1120,7 +1171,7 @@ describe('where() interface', () => { expect(() => { query = query.where('foo', '@' as InvalidApiUsage, 'foobar'); }).to.throw( - 'Value for argument "opStr" is invalid. Acceptable values are: <, <=, ==, >, >=, array-contains, in, array-contains-any' + 'Value for argument "opStr" is invalid. Acceptable values are: <, <=, ==, !=, >, >=, array-contains, in, not-in, array-contains-any' ); }); }); diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 769e79c38..036ed97f6 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -1073,17 +1073,19 @@ declare namespace FirebaseFirestore { /** * Filter conditions in a `Query.where()` clause are specified using the - * strings '<', '<=', '==', '>=', '>', 'array-contains', 'in', and - * 'array-contains-any'. + * strings '<', '<=', '==', '!=', '>=', '>', 'array-contains', 'in', 'not-in', + * and 'array-contains-any'. */ export type WhereFilterOp = | '<' | '<=' | '==' + | '!=' | '>=' | '>' | 'array-contains' | 'in' + | 'not-in' | 'array-contains-any'; /** From 404699a3f2a3dbfbe85dfe64d667a92d036b7819 Mon Sep 17 00:00:00 2001 From: Lalji Kanjareeya <46327204+laljikanjareeya@users.noreply.github.com> Date: Sat, 19 Sep 2020 01:05:02 +0530 Subject: [PATCH 178/337] test: fix invalid operator conformance test (#1301) --- dev/conformance/conformance-tests/query-invalid-operator.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/conformance/conformance-tests/query-invalid-operator.json b/dev/conformance/conformance-tests/query-invalid-operator.json index 064164dc0..70f28424d 100644 --- a/dev/conformance/conformance-tests/query-invalid-operator.json +++ b/dev/conformance/conformance-tests/query-invalid-operator.json @@ -2,7 +2,7 @@ "tests": [ { "description": "query: invalid operator in Where clause", - "comment": "The != operator is not supported.", + "comment": "The ! operator is not supported.", "query": { "collPath": "projects/projectID/databases/(default)/documents/C", "clauses": [ @@ -13,7 +13,7 @@ "a" ] }, - "op": "!=", + "op": "!", "jsonValue": "4" } } From 20b122695843bffc106f73c92e112144f0b96070 Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Tue, 22 Sep 2020 19:53:17 +0200 Subject: [PATCH 179/337] fix: allow `setLogFunction(null)` (#1304) --- dev/src/logger.ts | 2 +- dev/test/bulk-writer.ts | 2 +- dev/test/collection.ts | 2 +- dev/test/document.ts | 2 +- dev/test/index.ts | 2 +- dev/test/order.ts | 2 +- dev/test/query.ts | 2 +- dev/test/transaction.ts | 2 +- dev/test/watch.ts | 2 +- dev/test/write-batch.ts | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dev/src/logger.ts b/dev/src/logger.ts index c0b3cb07f..05007bc8d 100644 --- a/dev/src/logger.ts +++ b/dev/src/logger.ts @@ -55,7 +55,7 @@ export function logger( * `null` to turn off logging. */ export function setLogFunction(logger: ((msg: string) => void) | null): void { - validateFunction('logger', logger); + if (logger !== null) validateFunction('logger', logger); logFunction = logger; } diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index 30bd178c1..4786e8fa3 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -39,7 +39,7 @@ import { import api = proto.google.firestore.v1; // Change the argument to 'console.log' to enable debug output. -setLogFunction(() => {}); +setLogFunction(null); const PROJECT_ID = 'test-project'; diff --git a/dev/test/collection.ts b/dev/test/collection.ts index 77ce13a7c..1a94899f7 100644 --- a/dev/test/collection.ts +++ b/dev/test/collection.ts @@ -33,7 +33,7 @@ import { } from './util/helpers'; // Change the argument to 'console.log' to enable debug output. -setLogFunction(() => {}); +setLogFunction(null); describe('Collection interface', () => { let firestore: Firestore; diff --git a/dev/test/document.ts b/dev/test/document.ts index 9a0b0c986..3a861b32e 100644 --- a/dev/test/document.ts +++ b/dev/test/document.ts @@ -59,7 +59,7 @@ const INVALID_ARGUMENTS_TO_UPDATE = new RegExp( ); // Change the argument to 'console.log' to enable debug output. -setLogFunction(() => {}); +setLogFunction(null); describe('DocumentReference interface', () => { let firestore: Firestore; diff --git a/dev/test/index.ts b/dev/test/index.ts index b96c9f7b5..7095001df 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -51,7 +51,7 @@ const DEFAULT_SETTINGS = { }; // Change the argument to 'console.log' to enable debug output. -Firestore.setLogFunction(() => {}); +Firestore.setLogFunction(null); const bytesData = Buffer.from('AQI=', 'base64'); diff --git a/dev/test/order.ts b/dev/test/order.ts index eeada46c2..a193b6d2d 100644 --- a/dev/test/order.ts +++ b/dev/test/order.ts @@ -32,7 +32,7 @@ import {createInstance, InvalidApiUsage, verifyInstance} from './util/helpers'; import api = google.firestore.v1; // Change the argument to 'console.log' to enable debug output. -setLogFunction(() => {}); +setLogFunction(null); describe('Order', () => { let firestore: Firestore; diff --git a/dev/test/query.ts b/dev/test/query.ts index ea4505fbf..23222e1e0 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -53,7 +53,7 @@ const PROJECT_ID = 'test-project'; const DATABASE_ROOT = `projects/${PROJECT_ID}/databases/(default)`; // Change the argument to 'console.log' to enable debug output. -setLogFunction(() => {}); +setLogFunction(null); use(chaiAsPromised); diff --git a/dev/test/transaction.ts b/dev/test/transaction.ts index 9e59137cb..0177b99f2 100644 --- a/dev/test/transaction.ts +++ b/dev/test/transaction.ts @@ -45,7 +45,7 @@ const DOCUMENT_ID = 'documentId'; const DOCUMENT_NAME = `${COLLECTION_ROOT}/${DOCUMENT_ID}`; // Change the argument to 'console.log' to enable debug output. -Firestore.setLogFunction(() => {}); +Firestore.setLogFunction(null); /** Helper to create a transaction ID from either a string or a Uint8Array. */ function transactionId(transaction?: Uint8Array | string): Uint8Array { diff --git a/dev/test/watch.ts b/dev/test/watch.ts index bb9428e95..3ac3a9681 100644 --- a/dev/test/watch.ts +++ b/dev/test/watch.ts @@ -46,7 +46,7 @@ import {createInstance, InvalidApiUsage, verifyInstance} from './util/helpers'; import api = google.firestore.v1; // Change the argument to 'console.log' to enable debug output. -setLogFunction(() => {}); +setLogFunction(null); let PROJECT_ID = process.env.PROJECT_ID; if (!PROJECT_ID) { diff --git a/dev/test/write-batch.ts b/dev/test/write-batch.ts index ffcc2f392..beb304a24 100644 --- a/dev/test/write-batch.ts +++ b/dev/test/write-batch.ts @@ -40,7 +40,7 @@ import { const REQUEST_TIME = 'REQUEST_TIME'; // Change the argument to 'console.log' to enable debug output. -setLogFunction(() => {}); +setLogFunction(null); const PROJECT_ID = 'test-project'; From b678857afcdf14be5d645d7552e5f4aa4183b037 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 22 Sep 2020 14:04:50 -0700 Subject: [PATCH 180/337] fix: change typings for select() to return Query (#1303) --- dev/src/reference.ts | 10 ++++++++-- types/firestore.d.ts | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 8a0c33557..6166d2328 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -1290,7 +1290,9 @@ export class Query implements firestore.Query { * console.log(`y is ${res.docs[0].get('y')}.`); * }); */ - select(...fieldPaths: Array): Query { + select( + ...fieldPaths: Array + ): Query { const fields: api.StructuredQuery.IFieldReference[] = []; if (fieldPaths.length === 0) { @@ -1304,7 +1306,11 @@ export class Query implements firestore.Query { } } - const options = this._queryOptions.with({projection: {fields}}); + // By specifying a field mask, the query result no longer conforms to type + // `T`. We there return `Query`; + const options = this._queryOptions.with({ + projection: {fields}, + }) as QueryOptions; return new Query(this._firestore, options); } diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 036ed97f6..222e9304a 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -1190,7 +1190,7 @@ declare namespace FirebaseFirestore { * @param field The field paths to return. * @return The created Query. */ - select(...field: (string | FieldPath)[]): Query; + select(...field: (string | FieldPath)[]): Query; /** * Creates and returns a new Query that starts at the provided document From 6243d625481e8f9a852b4a3bf8d77ca9cbca4dd3 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 22 Sep 2020 17:38:51 -0500 Subject: [PATCH 181/337] fix: bulkWriter: writing to the same document does not create a new batch (#1298) --- dev/src/bulk-writer.ts | 147 ++++++++++++++--------------------- dev/src/write-batch.ts | 16 ++-- dev/system-test/firestore.ts | 11 --- dev/test/bulk-writer.ts | 127 ++++++------------------------ 4 files changed, 91 insertions(+), 210 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 598f45da4..34b18b1ac 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -71,6 +71,18 @@ enum BatchState { SENT, } +/*! + * Used to represent a pending write operation. + * + * Contains a pending write's WriteBatch index, document path, and the + * corresponding result. + */ +interface PendingOp { + writeBatchIndex: number; + key: string; + deferred: Deferred; +} + /** * Used to represent a batch on the BatchQueue. * @@ -86,9 +98,9 @@ class BulkCommitBatch { // response is received. private completedDeferred = new Deferred(); - // A map from each write's document path to its corresponding result. - // Only contains writes that have not been resolved. - private pendingOps = new Map>(); + // An array of pending write operations. Only contains writes that have not + // been resolved. + private pendingOps: Array = []; private readonly backoff: ExponentialBackoff; @@ -104,7 +116,7 @@ class BulkCommitBatch { * The number of writes in this batch. */ get opCount(): number { - return this.pendingOps.size; + return this.pendingOps.length; } /** @@ -180,16 +192,16 @@ class BulkCommitBatch { private processOperation( documentRef: firestore.DocumentReference ): Promise { - assert( - !this.pendingOps.has(documentRef.path), - 'Batch should not contain writes to the same document' - ); assert( this.state === BatchState.OPEN, 'Batch should be OPEN when adding writes' ); const deferred = new Deferred(); - this.pendingOps.set(documentRef.path, deferred); + this.pendingOps.push({ + writeBatchIndex: this.opCount, + key: documentRef.path, + deferred: deferred, + }); if (this.opCount === this.maxBatchSize) { this.state = BatchState.READY_TO_SEND; @@ -229,57 +241,63 @@ class BulkCommitBatch { results = await this.writeBatch.bulkCommit(); } catch (err) { // Map the failure to each individual write's result. - results = [...this.pendingOps.keys()].map(path => { - return {key: path, writeTime: null, status: wrapError(err, stack)}; + results = this.pendingOps.map(op => { + return {key: op.key, writeTime: null, status: wrapError(err, stack)}; }); } - this.processResults(results); + this.processResults(results, /* allowRetry= */ true); - if (this.pendingOps.size > 0) { + if (this.pendingOps.length > 0) { logger( 'BulkWriter.bulkCommit', null, `Current batch failed at retry #${attempt}. Num failures: ` + - `${this.pendingOps.size}.` + `${this.pendingOps.length}.` ); - this.writeBatch = new WriteBatch(this.firestore, this.writeBatch, [ - ...this.pendingOps.keys(), - ]); + this.writeBatch = new WriteBatch( + this.firestore, + this.writeBatch, + new Set(this.pendingOps.map(op => op.writeBatchIndex)) + ); } else { this.completedDeferred.resolve(); return; } } - this.failRemainingOperations(results); + this.processResults(results); this.completedDeferred.resolve(); } /** * Resolves the individual operations in the batch with the results. */ - private processResults(results: BatchWriteResult[]): void { - for (const result of results) { + private processResults( + results: BatchWriteResult[], + allowRetry = false + ): void { + const newPendingOps: Array = []; + for (let i = 0; i < results.length; i++) { + const result = results[i]; + const op = this.pendingOps[i]; if (result.status.code === Status.OK) { - this.pendingOps.get(result.key)!.resolve(result); - this.pendingOps.delete(result.key); - } else if (!this.shouldRetry(result.status.code)) { - this.pendingOps.get(result.key)!.reject(result.status); - this.pendingOps.delete(result.key); + op.deferred.resolve(result); + } else if (!allowRetry || !this.shouldRetry(result.status.code)) { + op.deferred.reject(result.status); + } else { + // Retry the operation if it has not been processed. + // Store the current index of pendingOps to preserve the mapping of + // this operation's index in the underlying WriteBatch. + newPendingOps.push({ + writeBatchIndex: i, + key: op.key, + deferred: op.deferred, + }); } } - } - private failRemainingOperations(results: BatchWriteResult[]): void { - for (const result of results) { - assert( - result.status.code !== Status.OK, - 'Should not fail successful operation' - ); - this.pendingOps.get(result.key)!.reject(result.status); - this.pendingOps.delete(result.key); - } + this.pendingOps = newPendingOps; } private shouldRetry(code: Status | undefined): boolean { @@ -287,17 +305,6 @@ class BulkCommitBatch { return code !== undefined && retryCodes.includes(code); } - hasPath(path: string): boolean { - for (const [docPath] of this.pendingOps) { - if (docPath === path) return true; - } - return false; - } - - docPaths(): IterableIterator { - return this.pendingOps.keys(); - } - /** * Returns a promise that resolves when the batch has been sent, and a * response is received. @@ -392,7 +399,7 @@ export class BulkWriter { data: T ): Promise { this.verifyNotClosed(); - const bulkCommitBatch = this.getEligibleBatch(documentRef); + const bulkCommitBatch = this.getEligibleBatch(); const resultPromise = bulkCommitBatch.create(documentRef, data); this.sendReadyBatches(); return resultPromise; @@ -431,7 +438,7 @@ export class BulkWriter { precondition?: firestore.Precondition ): Promise { this.verifyNotClosed(); - const bulkCommitBatch = this.getEligibleBatch(documentRef); + const bulkCommitBatch = this.getEligibleBatch(); const resultPromise = bulkCommitBatch.delete(documentRef, precondition); this.sendReadyBatches(); return resultPromise; @@ -486,7 +493,7 @@ export class BulkWriter { options?: firestore.SetOptions ): Promise { this.verifyNotClosed(); - const bulkCommitBatch = this.getEligibleBatch(documentRef); + const bulkCommitBatch = this.getEligibleBatch(); const resultPromise = bulkCommitBatch.set(documentRef, data, options); this.sendReadyBatches(); return resultPromise; @@ -541,7 +548,7 @@ export class BulkWriter { > ): Promise { this.verifyNotClosed(); - const bulkCommitBatch = this.getEligibleBatch(documentRef); + const bulkCommitBatch = this.getEligibleBatch(); const resultPromise = bulkCommitBatch.update( documentRef, dataOrField, @@ -626,12 +633,10 @@ export class BulkWriter { * * @private */ - private getEligibleBatch( - ref: firestore.DocumentReference - ): BulkCommitBatch { + private getEligibleBatch(): BulkCommitBatch { if (this.batchQueue.length > 0) { const lastBatch = this.batchQueue[this.batchQueue.length - 1]; - if (lastBatch.state === BatchState.OPEN && !lastBatch.hasPath(ref.path)) { + if (lastBatch.state === BatchState.OPEN) { return lastBatch; } } @@ -675,7 +680,7 @@ export class BulkWriter { let index = 0; while ( index < unsentBatches.length && - this.isBatchSendable(unsentBatches[index]) + unsentBatches[index].state === BatchState.READY_TO_SEND ) { const batch = unsentBatches[index]; @@ -713,38 +718,6 @@ export class BulkWriter { }); } - /** - * Checks that the provided batch is sendable. To be sendable, a batch must: - * (1) be marked as READY_TO_SEND - * (2) not write to references that are currently in flight - * - * @private - */ - private isBatchSendable(batch: BulkCommitBatch): boolean { - if (batch.state !== BatchState.READY_TO_SEND) { - return false; - } - - for (const path of batch.docPaths()) { - const isRefInFlight = - this.batchQueue - .filter(batch => batch.state === BatchState.SENT) - .find(batch => batch.hasPath(path)) !== undefined; - 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. ' + - 'Write to unique documents in order to maximize throughput.' - ); - return false; - } - } - - return true; - } - /** * Sets the maximum number of allowed operations in a batch. * diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 77a819135..46e70b69f 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -144,29 +144,29 @@ export class WriteBatch implements firestore.WriteBatch { * * @param firestore The Firestore Database client. * @param retryBatch The WriteBatch that needs to be retried. - * @param docsToRetry The documents from the provided WriteBatch that need - * to be retried. + * @param indexesToRetry The indexes of the operations from the provided + * WriteBatch that need to be retried. */ constructor( firestore: Firestore, retryBatch: WriteBatch, - docsToRetry: string[] + indexesToRetry: Set ); constructor(firestore: Firestore); constructor( firestore: Firestore, retryBatch?: WriteBatch, - docsToRetry?: string[] + indexesToRetry?: Set ) { this._firestore = firestore; this._serializer = new Serializer(firestore); this._allowUndefined = !!firestore._settings.ignoreUndefinedProperties; if (retryBatch) { - // Creates a new WriteBatch containing only the operations from the - // provided document paths to retry. - this._ops = retryBatch._ops.filter( - v => docsToRetry!.indexOf(v.docPath) !== -1 + // Creates a new WriteBatch containing only the indexes from the provided + // indexes to retry. + this._ops = retryBatch._ops.filter((op, index) => + indexesToRetry!.has(index) ); } } diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 0dcc55f2e..11072e010 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -2485,17 +2485,6 @@ describe('BulkWriter class', () => { await writer.close(); return firestore.terminate(); }); - - it('writes to the same document in order', async () => { - const ref = randomCol.doc('doc1'); - await ref.set({foo: 'bar0'}); - writer.set(ref, {foo: 'bar1'}); - writer.set(ref, {foo: 'bar2'}); - writer.set(ref, {foo: 'bar3'}); - await writer.flush(); - const res = await ref.get(); - expect(res.data()).to.deep.equal({foo: 'bar3'}); - }); }); describe('Client initialization', () => { diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index 4786e8fa3..a6442fa0c 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -19,10 +19,14 @@ import {expect} from 'chai'; import {GoogleError, Status} from 'google-gax'; import * as proto from '../protos/firestore_v1_proto_api'; -import {Firestore, setLogFunction, Timestamp, WriteResult} from '../src'; +import { + BulkWriter, + Firestore, + setLogFunction, + Timestamp, + WriteResult, +} from '../src'; import {setTimeoutHandler} from '../src/backoff'; -import {BulkWriter} from '../src/bulk-writer'; -import {Deferred} from '../src/util'; import { ApiOverride, create, @@ -52,12 +56,9 @@ describe('BulkWriter', () => { let firestore: Firestore; let requestCounter: number; let opCount: number; - let activeRequestDeferred: Deferred; - let activeRequestCounter = 0; let timeoutHandlerCounter = 0; beforeEach(() => { - activeRequestDeferred = new Deferred(); requestCounter = 0; opCount = 0; timeoutHandlerCounter = 0; @@ -147,15 +148,8 @@ describe('BulkWriter', () => { /** * Creates an instance with the mocked objects. - * - * @param enforceSingleConcurrentRequest Whether to check that there is only - * one active request at a time. If true, the `activeRequestDeferred` must be - * manually resolved for the response to return. */ - function instantiateInstance( - mock: RequestResponse[], - enforceSingleConcurrentRequest = false - ): Promise { + function instantiateInstance(mock: RequestResponse[]): Promise { const overrides: ApiOverride = { batchWrite: async (request, options) => { expect(options!.retry!.retryCodes).contains(Status.ABORTED); @@ -164,16 +158,6 @@ describe('BulkWriter', () => { database: `projects/${PROJECT_ID}/databases/(default)`, writes: mock[requestCounter].request.writes, }); - if (enforceSingleConcurrentRequest) { - activeRequestCounter++; - - // This expect statement is used to test that only one request is - // made at a time. - expect(activeRequestCounter).to.equal(1); - await activeRequestDeferred.promise; - activeRequestCounter--; - } - const responsePromise = response({ writeResults: mock[requestCounter].response.writeResults, status: mock[requestCounter].response.status, @@ -348,23 +332,20 @@ describe('BulkWriter', () => { expect(() => bulkWriter.close()).to.throw(expected); }); - it('sends writes to the same document in separate batches', async () => { + it('can send writes to the same documents in the same batch', async () => { const bulkWriter = await instantiateInstance([ { - request: createRequest([setOp('doc', 'bar')]), - response: successResponse(1), - }, - { - request: createRequest([updateOp('doc', 'bar1')]), - response: successResponse(2), + request: createRequest([ + setOp('doc1', 'bar'), + updateOp('doc1', 'bar2'), + ]), + response: mergeResponses([successResponse(1), successResponse(2)]), }, ]); - // Create two document references pointing to the same document. - const doc = firestore.doc('collectionId/doc'); - const doc2 = firestore.doc('collectionId/doc'); - bulkWriter.set(doc, {foo: 'bar'}).then(incrementOpCount); - bulkWriter.update(doc2, {foo: 'bar1'}).then(incrementOpCount); + const doc1 = firestore.doc('collectionId/doc1'); + bulkWriter.set(doc1, {foo: 'bar'}).then(incrementOpCount); + bulkWriter.update(doc1, {foo: 'bar2'}).then(incrementOpCount); return bulkWriter.close().then(async () => { verifyOpCount(2); @@ -420,44 +401,6 @@ describe('BulkWriter', () => { }); }); - it('sends existing batches when a new batch is created', async () => { - const bulkWriter = await instantiateInstance([ - { - request: createRequest([setOp('doc', 'bar')]), - response: successResponse(1), - }, - { - request: createRequest([ - updateOp('doc', 'bar1'), - createOp('doc2', 'bar1'), - ]), - response: mergeResponses([successResponse(1), successResponse(2)]), - }, - ]); - - bulkWriter._setMaxBatchSize(2); - - const doc = firestore.doc('collectionId/doc'); - const doc2 = firestore.doc('collectionId/doc2'); - - // Create a new batch by writing to the same document. - const setPromise = bulkWriter.set(doc, {foo: 'bar'}).then(incrementOpCount); - const updatePromise = bulkWriter - .update(doc, {foo: 'bar1'}) - .then(incrementOpCount); - await setPromise; - - // Create a new batch by reaching the batch size limit. - const createPromise = bulkWriter - .create(doc2, {foo: 'bar1'}) - .then(incrementOpCount); - - await updatePromise; - await createPromise; - verifyOpCount(3); - return bulkWriter.close(); - }); - it('sends batches automatically when the batch size limit is reached', async () => { const bulkWriter = await instantiateInstance([ { @@ -503,32 +446,6 @@ describe('BulkWriter', () => { }); }); - it('uses timeout for batches that exceed the rate limit', async () => { - const bulkWriter = await instantiateInstance( - [ - { - request: createRequest([setOp('doc1', 'bar'), setOp('doc2', 'bar')]), - response: mergeResponses([successResponse(1), successResponse(2)]), - }, - { - request: createRequest([setOp('doc1', 'bar')]), - response: successResponse(3), - }, - ], - /* enforceSingleConcurrentRequest= */ true - ); - bulkWriter.set(firestore.doc('collectionId/doc1'), {foo: 'bar'}); - bulkWriter.set(firestore.doc('collectionId/doc2'), {foo: 'bar'}); - const flush1 = bulkWriter.flush(); - // The third write will be placed in a new batch - bulkWriter.set(firestore.doc('collectionId/doc1'), {foo: 'bar'}); - const flush2 = bulkWriter.flush(); - activeRequestDeferred.resolve(); - await flush1; - await flush2; - return bulkWriter.close(); - }); - it('supports different type converters', async () => { const bulkWriter = await instantiateInstance([ { @@ -572,7 +489,7 @@ describe('BulkWriter', () => { { request: createRequest([ setOp('doc1', 'bar'), - setOp('doc2', 'bar'), + setOp('doc1', 'bar2'), setOp('doc3', 'bar'), ]), response: mergeResponses([ @@ -582,7 +499,7 @@ describe('BulkWriter', () => { ]), }, { - request: createRequest([setOp('doc2', 'bar'), setOp('doc3', 'bar')]), + request: createRequest([setOp('doc1', 'bar2'), setOp('doc3', 'bar')]), response: mergeResponses([ successResponse(2), failedResponse(Status.ABORTED), @@ -594,13 +511,15 @@ describe('BulkWriter', () => { }, ]); + // Test writes to the same document in order to verify that retry logic + // is unaffected by the document key. bulkWriter .set(firestore.doc('collectionId/doc1'), { foo: 'bar', }) .catch(incrementOpCount); - const set2 = bulkWriter.set(firestore.doc('collectionId/doc2'), { - foo: 'bar', + const set2 = bulkWriter.set(firestore.doc('collectionId/doc1'), { + foo: 'bar2', }); const set3 = bulkWriter.set(firestore.doc('collectionId/doc3'), { foo: 'bar', From ab4b24abc292e46065363e08232fe47326484a81 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 16:23:49 -0700 Subject: [PATCH 182/337] chore: release 4.3.0 (#1281) --- CHANGELOG.md | 16 ++++++++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 761d79a82..2e451c103 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,22 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [4.3.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.2.0...v4.3.0) (2020-09-22) + + +### Features + +* add support for != and not-in queries ([#1292](https://www.github.com/googleapis/nodejs-firestore/issues/1292)) ([786e52f](https://www.github.com/googleapis/nodejs-firestore/commit/786e52f8c8b7b9c6b84ffc988190470a063d5855)) + + +### Bug Fixes + +* add capacity logging to RateLimiter ([#1287](https://www.github.com/googleapis/nodejs-firestore/issues/1287)) ([befe625](https://www.github.com/googleapis/nodejs-firestore/commit/befe625f35b7c96e9a90399a1ca71a8a049224ad)) +* allow `setLogFunction(null)` ([#1304](https://www.github.com/googleapis/nodejs-firestore/issues/1304)) ([20b1226](https://www.github.com/googleapis/nodejs-firestore/commit/20b122695843bffc106f73c92e112144f0b96070)) +* bulkWriter: writing to the same document does not create a new batch ([#1298](https://www.github.com/googleapis/nodejs-firestore/issues/1298)) ([6243d62](https://www.github.com/googleapis/nodejs-firestore/commit/6243d625481e8f9a852b4a3bf8d77ca9cbca4dd3)) +* change typings for select() to return `Query` ([#1303](https://www.github.com/googleapis/nodejs-firestore/issues/1303)) ([b678857](https://www.github.com/googleapis/nodejs-firestore/commit/b678857afcdf14be5d645d7552e5f4aa4183b037)) +* correct BulkWriter types in firestore.d.ts ([#1284](https://www.github.com/googleapis/nodejs-firestore/issues/1284)) ([382128b](https://www.github.com/googleapis/nodejs-firestore/commit/382128b83de01cc0f88110393a1271b8d768509e)) + ## [4.2.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.1.2...v4.2.0) (2020-07-31) diff --git a/package.json b/package.json index 0b4b581c7..2f66fe856 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.2.0", + "version": "4.3.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 8b4b9762e..13032037a 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.2.0" + "@google-cloud/firestore": "^4.3.0" }, "devDependencies": { "chai": "^4.2.0", From 67b0abaf14b343d477bb4e6e97d772cac2aced75 Mon Sep 17 00:00:00 2001 From: Christopher Wilcox Date: Wed, 23 Sep 2020 11:15:58 -0700 Subject: [PATCH 183/337] docs: expand on FieldPath docstr (#1308) Co-authored-by: Sebastian Schmidt --- dev/src/path.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/src/path.ts b/dev/src/path.ts index b38c1de89..388fc86c1 100644 --- a/dev/src/path.ts +++ b/dev/src/path.ts @@ -489,7 +489,7 @@ export function validateResourcePath( } /** - * A dot-separated path for navigating sub-objects within a document. + * A dot-separated path for navigating sub-objects (e.g. nested maps) within a document. * * @class */ From 57dcf1c42b406a15ecb960059d67d99a97d42547 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Fri, 25 Sep 2020 09:52:21 -0500 Subject: [PATCH 184/337] feat: add starting/max rates to BulkWriterOptions (#1305) --- dev/src/bulk-writer.ts | 120 +++++++++++++++++++++++++++++++++++---- dev/src/index.ts | 2 +- dev/src/rate-limiter.ts | 16 ++++-- dev/test/bulk-writer.ts | 107 ++++++++++++++++++++++++++++++++++ dev/test/rate-limiter.ts | 6 ++ types/firestore.d.ts | 26 +++++++-- 6 files changed, 257 insertions(+), 20 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 34b18b1ac..7a1a1dab3 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -27,9 +27,14 @@ import { import {RateLimiter} from './rate-limiter'; import {DocumentReference} from './reference'; import {Timestamp} from './timestamp'; -import {Deferred, getRetryCodes, wrapError} from './util'; +import {Deferred, getRetryCodes, isObject, wrapError} from './util'; import {BatchWriteResult, WriteBatch, WriteResult} from './write-batch'; import {logger} from './logger'; +import { + invalidArgumentMessage, + validateInteger, + validateOptional, +} from './validate'; /*! * The maximum number of writes that can be in a single batch. @@ -42,7 +47,7 @@ const MAX_BATCH_SIZE = 20; * * https://cloud.google.com/datastore/docs/best-practices#ramping_up_traffic. */ -const STARTING_MAXIMUM_OPS_PER_SECOND = 500; +export const DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND = 500; /*! * The rate by which to increase the capacity as specified by the 500/50/5 rule. @@ -351,22 +356,46 @@ export class BulkWriter { constructor( private readonly firestore: Firestore, - enableThrottling: boolean + options?: firestore.BulkWriterOptions ) { this.firestore._incrementBulkWritersCount(); + validateBulkWriterOptions(options); - if (enableThrottling) { - this.rateLimiter = new RateLimiter( - STARTING_MAXIMUM_OPS_PER_SECOND, - RATE_LIMITER_MULTIPLIER, - RATE_LIMITER_MULTIPLIER_MILLIS - ); - } else { + if (options?.throttling === false) { this.rateLimiter = new RateLimiter( + Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY ); + } else { + let startingRate = DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND; + let maxRate = Number.POSITIVE_INFINITY; + + if (typeof options?.throttling !== 'boolean') { + if (options?.throttling?.maxOpsPerSecond !== undefined) { + maxRate = options.throttling.maxOpsPerSecond; + } + + if (options?.throttling?.initialOpsPerSecond !== undefined) { + startingRate = options.throttling.initialOpsPerSecond; + } + + // The initial validation step ensures that the maxOpsPerSecond is + // greater than initialOpsPerSecond. If this inequality is true, that + // means initialOpsPerSecond was not set and maxOpsPerSecond is less + // than the default starting rate. + if (maxRate < startingRate) { + startingRate = maxRate; + } + } + + this.rateLimiter = new RateLimiter( + startingRate, + RATE_LIMITER_MULTIPLIER, + RATE_LIMITER_MULTIPLIER_MILLIS, + maxRate + ); } } @@ -727,4 +756,75 @@ export class BulkWriter { _setMaxBatchSize(size: number): void { this.maxBatchSize = size; } + + /** + * Returns the rate limiter for testing. + * + * @private + */ + // Visible for testing. + _getRateLimiter(): RateLimiter { + return this.rateLimiter; + } +} + +/** + * Validates the use of 'value' as BulkWriterOptions. + * + * @private + * @param value The BulkWriterOptions object to validate. + * @throws if the input is not a valid BulkWriterOptions object. + */ +function validateBulkWriterOptions(value: unknown): void { + if (validateOptional(value, {optional: true})) { + return; + } + const argName = 'options'; + + if (!isObject(value)) { + throw new Error( + `${invalidArgumentMessage( + argName, + 'bulkWriter() options argument' + )} Input is not an object.` + ); + } + + const options = value as firestore.BulkWriterOptions; + + if ( + options.throttling === undefined || + typeof options.throttling === 'boolean' + ) { + return; + } + + if (options.throttling.initialOpsPerSecond !== undefined) { + validateInteger( + 'initialOpsPerSecond', + options.throttling.initialOpsPerSecond, + { + minValue: 1, + } + ); + } + + if (options.throttling.maxOpsPerSecond !== undefined) { + validateInteger('maxOpsPerSecond', options.throttling.maxOpsPerSecond, { + minValue: 1, + }); + + if ( + options.throttling.initialOpsPerSecond !== undefined && + options.throttling.initialOpsPerSecond > + options.throttling.maxOpsPerSecond + ) { + throw new Error( + `${invalidArgumentMessage( + argName, + 'bulkWriter() options argument' + )} "maxOpsPerSecond" cannot be less than "initialOpsPerSecond".` + ); + } + } } diff --git a/dev/src/index.ts b/dev/src/index.ts index 4f26a91fd..fde09a6f8 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -712,7 +712,7 @@ export class Firestore implements firestore.Firestore { * }); */ bulkWriter(options?: firestore.BulkWriterOptions): BulkWriter { - return new BulkWriter(this, !options?.disableThrottling); + return new BulkWriter(this, options); } /** diff --git a/dev/src/rate-limiter.ts b/dev/src/rate-limiter.ts index 2265fc975..28b5e9fc9 100644 --- a/dev/src/rate-limiter.ts +++ b/dev/src/rate-limiter.ts @@ -46,6 +46,8 @@ export class RateLimiter { * @param multiplier Rate by which to increase the capacity. * @param multiplierMillis How often the capacity should increase in * milliseconds. + * @param maximumCapacity Maximum number of allowed operations per second. + * The number of tokens added per second will never exceed this number. * @param startTimeMillis The starting time in epoch milliseconds that the * rate limit is based on. Used for testing the limiter. */ @@ -53,6 +55,7 @@ export class RateLimiter { private readonly initialCapacity: number, private readonly multiplier: number, private readonly multiplierMillis: number, + readonly maximumCapacity: number, private readonly startTimeMillis = Date.now() ) { this.availableTokens = initialCapacity; @@ -147,11 +150,14 @@ export class RateLimiter { 'startTime cannot be after currentTime' ); const millisElapsed = requestTimeMillis - this.startTimeMillis; - const operationsPerSecond = Math.floor( - Math.pow( - this.multiplier, - Math.floor(millisElapsed / this.multiplierMillis) - ) * this.initialCapacity + const operationsPerSecond = Math.min( + Math.floor( + Math.pow( + this.multiplier, + Math.floor(millisElapsed / this.multiplierMillis) + ) * this.initialCapacity + ), + this.maximumCapacity ); if (operationsPerSecond !== this.previousCapacity) { diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index a6442fa0c..a65a2f471 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -32,6 +32,7 @@ import { create, createInstance, document, + InvalidApiUsage, remove, response, set, @@ -41,6 +42,7 @@ import { } from './util/helpers'; import api = proto.google.firestore.v1; +import {DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND} from '../src/bulk-writer'; // Change the argument to 'console.log' to enable debug output. setLogFunction(null); @@ -178,6 +180,111 @@ describe('BulkWriter', () => { setTimeoutHandler(setTimeout); }); + describe('options', () => { + it('requires object', async () => { + const firestore = await createInstance(); + expect(() => firestore.bulkWriter(42 as InvalidApiUsage)).to.throw( + 'Value for argument "options" is not a valid bulkWriter() options argument. Input is not an object.' + ); + }); + + it('initialOpsPerSecond requires positive integer', async () => { + const firestore = await createInstance(); + expect(() => + firestore.bulkWriter({throttling: {initialOpsPerSecond: -1}}) + ).to.throw( + 'Value for argument "initialOpsPerSecond" must be within [1, Infinity] inclusive, but was: -1' + ); + + expect(() => + firestore.bulkWriter({throttling: {initialOpsPerSecond: 500.5}}) + ).to.throw( + 'Value for argument "initialOpsPerSecond" is not a valid integer.' + ); + }); + + it('maxOpsPerSecond requires positive integer', async () => { + const firestore = await createInstance(); + expect(() => + firestore.bulkWriter({throttling: {maxOpsPerSecond: -1}}) + ).to.throw( + 'Value for argument "maxOpsPerSecond" must be within [1, Infinity] inclusive, but was: -1' + ); + + expect(() => + firestore.bulkWriter({throttling: {maxOpsPerSecond: 500.5}}) + ).to.throw( + 'Value for argument "maxOpsPerSecond" is not a valid integer.' + ); + }); + + it('maxOpsPerSecond must be greater than initial ops per second', async () => { + const firestore = await createInstance(); + + expect(() => + firestore.bulkWriter({ + throttling: {initialOpsPerSecond: 550, maxOpsPerSecond: 500}, + }) + ).to.throw( + 'Value for argument "options" is not a valid bulkWriter() options argument. "maxOpsPerSecond" cannot be less than "initialOpsPerSecond".' + ); + }); + + it('initial and max rates are properly set', async () => { + const firestore = await createInstance(); + + let bulkWriter = firestore.bulkWriter({ + throttling: {initialOpsPerSecond: 500, maxOpsPerSecond: 550}, + }); + expect(bulkWriter._getRateLimiter().availableTokens).to.equal(500); + expect(bulkWriter._getRateLimiter().maximumCapacity).to.equal(550); + + bulkWriter = firestore.bulkWriter({ + throttling: {maxOpsPerSecond: 1000}, + }); + expect(bulkWriter._getRateLimiter().availableTokens).to.equal(500); + expect(bulkWriter._getRateLimiter().maximumCapacity).to.equal(1000); + + bulkWriter = firestore.bulkWriter({ + throttling: {initialOpsPerSecond: 100}, + }); + expect(bulkWriter._getRateLimiter().availableTokens).to.equal(100); + expect(bulkWriter._getRateLimiter().maximumCapacity).to.equal( + Number.POSITIVE_INFINITY + ); + + bulkWriter = firestore.bulkWriter({ + throttling: {maxOpsPerSecond: 100}, + }); + expect(bulkWriter._getRateLimiter().availableTokens).to.equal(100); + expect(bulkWriter._getRateLimiter().maximumCapacity).to.equal(100); + + bulkWriter = firestore.bulkWriter(); + expect(bulkWriter._getRateLimiter().availableTokens).to.equal( + DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND + ); + expect(bulkWriter._getRateLimiter().maximumCapacity).to.equal( + Number.POSITIVE_INFINITY + ); + + bulkWriter = firestore.bulkWriter({throttling: true}); + expect(bulkWriter._getRateLimiter().availableTokens).to.equal( + DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND + ); + expect(bulkWriter._getRateLimiter().maximumCapacity).to.equal( + Number.POSITIVE_INFINITY + ); + + bulkWriter = firestore.bulkWriter({throttling: false}); + expect(bulkWriter._getRateLimiter().availableTokens).to.equal( + Number.POSITIVE_INFINITY + ); + expect(bulkWriter._getRateLimiter().maximumCapacity).to.equal( + Number.POSITIVE_INFINITY + ); + }); + }); + it('has a set() method', async () => { const bulkWriter = await instantiateInstance([ { diff --git a/dev/test/rate-limiter.ts b/dev/test/rate-limiter.ts index 24061c5b0..9d6126c76 100644 --- a/dev/test/rate-limiter.ts +++ b/dev/test/rate-limiter.ts @@ -25,6 +25,7 @@ describe('RateLimiter', () => { /* initialCapacity= */ 500, /* multiplier= */ 1.5, /* multiplierMillis= */ 5 * 60 * 1000, + /* maximumCapacity= */ 1000000, /* startTime= */ new Date(0).getTime() ); }); @@ -106,5 +107,10 @@ describe('RateLimiter', () => { expect( limiter.calculateCapacity(new Date(90 * 60 * 1000).getTime()) ).to.equal(738945); + + // Check that maximum rate limit is enforced. + expect( + limiter.calculateCapacity(new Date(1000 * 60 * 1000).getTime()) + ).to.equal(1000000); }); }); diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 222e9304a..7ffe79280 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -291,6 +291,9 @@ declare namespace FirebaseFirestore { * Creates a [BulkWriter]{@link BulkWriter}, used for performing * multiple writes in parallel. Gradually ramps up writes as specified * by the 500/50/5 rule. + * + * @param options An options object used to configure the throttling + * behavior for the underlying BulkWriter. */ bulkWriter(options?: BulkWriterOptions): BulkWriter; } @@ -613,12 +616,27 @@ declare namespace FirebaseFirestore { } /** - * An options object that can be used to disable request throttling in - * BulkWriter. + * An options object to configure throttling on BulkWriter. */ export interface BulkWriterOptions { - /** Whether to disable throttling. */ - readonly disableThrottling?: boolean; + /** + * Whether to disable or configure throttling. By default, throttling is + * enabled. This field can be set to either a boolean or a config + * object. Setting it to `true` will use default values. You can override + * the defaults by setting it to `false` to disable throttling, or by + * setting the config values to enable throttling with the provided values. + * + * @param initialOpsPerSecond The initial maximum number of operations per + * second allowed by the throttler. If this field is not set, the default + * is 500 operations per second. + * @param maxOpsPerSecond The maximum number of operations per second + * allowed by the throttler. If this field is set, the throttler's allowed + * operations per second does not ramp up past the specified operations per + * second. + */ + readonly throttling?: + | boolean + | {initialOpsPerSecond?: number; maxOpsPerSecond?: number}; } /** From 56a8455332aae6265c2761a95a370b666d9776bf Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Fri, 25 Sep 2020 12:33:35 -0500 Subject: [PATCH 185/337] fix: fix flaky BulkWriter rate limiter test (#1307) --- dev/src/bulk-writer.ts | 6 ++++++ dev/test/bulk-writer.ts | 41 ++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 7a1a1dab3..371b5ff7e 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -388,6 +388,12 @@ export class BulkWriter { if (maxRate < startingRate) { startingRate = maxRate; } + + // Ensure that the batch size is not larger than the number of allowed + // operations per second. + if (startingRate < this.maxBatchSize) { + this.maxBatchSize = startingRate; + } } this.rateLimiter = new RateLimiter( diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index a65a2f471..bf82e529a 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {DocumentData} from '@google-cloud/firestore'; +import {BulkWriterOptions, DocumentData} from '@google-cloud/firestore'; import {afterEach, beforeEach, describe, it} from 'mocha'; import {expect} from 'chai'; @@ -641,7 +641,9 @@ describe('BulkWriter', () => { describe('Timeout handler tests', () => { // Return success responses for all requests. - function instantiateInstance(): Promise { + function instantiateInstance( + options?: BulkWriterOptions + ): Promise { const overrides: ApiOverride = { batchWrite: request => { const requestLength = request.writes?.length || 0; @@ -656,29 +658,30 @@ describe('BulkWriter', () => { }; return createInstance(overrides).then(firestoreClient => { firestore = firestoreClient; - return firestore.bulkWriter(); + return firestore.bulkWriter(options); }); } it('does not send batches if doing so exceeds the rate limit', done => { - instantiateInstance().then(bulkWriter => { - let timeoutCalled = false; - setTimeoutHandler((_, timeout) => { - if (!timeoutCalled && timeout > 0) { - timeoutCalled = true; - done(); + instantiateInstance({throttling: {maxOpsPerSecond: 5}}).then( + bulkWriter => { + let timeoutCalled = false; + setTimeoutHandler((_, timeout) => { + if (!timeoutCalled && timeout > 0) { + timeoutCalled = true; + done(); + } + }); + for (let i = 0; i < 500; i++) { + bulkWriter.set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}); } - }); - - for (let i = 0; i < 600; i++) { - bulkWriter.set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}); + // The close() promise will never resolve. Since we do not call the + // callback function in the overridden handler, subsequent requests + // after the timeout will not be made. The close() call is used to + // ensure that the final batch is sent. + bulkWriter.close(); } - // The close() promise will never resolve. Since we do not call the - // callback function in the overridden handler, subsequent requests - // after the timeout will not be made. The close() call is used to - // ensure that the final batch is sent. - bulkWriter.close(); - }); + ); }); }); From 17b163d8d237b021794c1321747bb0ea6646f7ae Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Tue, 29 Sep 2020 09:44:11 -0700 Subject: [PATCH 186/337] build: generate config (#1311) --- .github/publish.yml | 0 .github/workflows/ci.yaml | 2 +- .kokoro/release/docs-devsite.cfg | 26 +++++++++++++ .kokoro/release/docs-devsite.sh | 67 ++++++++++++++++++++++++++++++++ .kokoro/release/publish.cfg | 17 ++------ .mocharc.js | 3 +- 6 files changed, 100 insertions(+), 15 deletions(-) delete mode 100644 .github/publish.yml create mode 100644 .kokoro/release/docs-devsite.cfg create mode 100755 .kokoro/release/docs-devsite.sh diff --git a/.github/publish.yml b/.github/publish.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5e73bb3d8..7dd110e3f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,7 +16,7 @@ jobs: with: node-version: ${{ matrix.node }} - run: node --version - - run: npm install + - run: npm install --engine-strict - run: npm test - name: coverage uses: codecov/codecov-action@v1 diff --git a/.kokoro/release/docs-devsite.cfg b/.kokoro/release/docs-devsite.cfg new file mode 100644 index 000000000..525699f56 --- /dev/null +++ b/.kokoro/release/docs-devsite.cfg @@ -0,0 +1,26 @@ +# service account used to publish up-to-date docs. +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "docuploader_service_account" + } + } +} + +# doc publications use a Python image. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "nodejs-firestore/.kokoro/trampoline.sh" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/nodejs-firestore/.kokoro/release/docs-devsite.sh" +} diff --git a/.kokoro/release/docs-devsite.sh b/.kokoro/release/docs-devsite.sh new file mode 100755 index 000000000..fa089cf29 --- /dev/null +++ b/.kokoro/release/docs-devsite.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# Copyright 2019 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 +# +# https://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. + +set -eo pipefail + +# build jsdocs (Python is installed on the Node 10 docker image). +if [[ -z "$CREDENTIALS" ]]; then + # if CREDENTIALS are explicitly set, assume we're testing locally + # and don't set NPM_CONFIG_PREFIX. + export NPM_CONFIG_PREFIX=/home/node/.npm-global + export PATH="$PATH:/home/node/.npm-global/bin" + cd $(dirname $0)/../.. +fi + +mkdir ./etc + +npm install +npm run api-extractor +npm run api-documenter + +npm i json@9.0.6 -g +NAME=$(cat .repo-metadata.json | json name) + +mkdir ./_devsite +cp ./yaml/$NAME/* ./_devsite + +# Delete SharePoint item, see https://github.com/microsoft/rushstack/issues/1229 +sed -i -e '1,3d' ./yaml/toc.yml +sed -i -e 's/^ //' ./yaml/toc.yml + +cp ./yaml/toc.yml ./_devsite/toc.yml + +# create docs.metadata, based on package.json and .repo-metadata.json. +pip install -U pip +python3 -m pip install --user gcp-docuploader +python3 -m docuploader create-metadata \ + --name=$NAME \ + --version=$(cat package.json | json version) \ + --language=$(cat .repo-metadata.json | json language) \ + --distribution-name=$(cat .repo-metadata.json | json distribution_name) \ + --product-page=$(cat .repo-metadata.json | json product_documentation) \ + --github-repository=$(cat .repo-metadata.json | json repo) \ + --issue-tracker=$(cat .repo-metadata.json | json issue_tracker) +cp docs.metadata ./_devsite/docs.metadata + +# deploy the docs. +if [[ -z "$CREDENTIALS" ]]; then + CREDENTIALS=${KOKORO_KEYSTORE_DIR}/73713_docuploader_service_account +fi +if [[ -z "$BUCKET" ]]; then + BUCKET=docs-staging-v2-staging +fi + +python3 -m docuploader upload ./_devsite --destination-prefix docfx --credentials $CREDENTIALS --staging-bucket $BUCKET diff --git a/.kokoro/release/publish.cfg b/.kokoro/release/publish.cfg index 3b4b5a5fd..833af8054 100644 --- a/.kokoro/release/publish.cfg +++ b/.kokoro/release/publish.cfg @@ -47,13 +47,9 @@ before_action { } } -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "google-cloud-firestore-npm-token" - } - } +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "npm_publish_token,releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem" } # Download trampoline resources. @@ -65,15 +61,10 @@ build_file: "nodejs-firestore/.kokoro/trampoline.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:8-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user" } env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/nodejs-firestore/.kokoro/publish.sh" } - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "npm_publish_token" -} \ No newline at end of file diff --git a/.mocharc.js b/.mocharc.js index ff7b34fa5..0b600509b 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -14,7 +14,8 @@ const config = { "enable-source-maps": true, "throw-deprecation": true, - "timeout": 10000 + "timeout": 10000, + "recursive": true } if (process.env.MOCHA_THROW_DEPRECATION === 'false') { delete config['throw-deprecation']; From c098c6afbb45313be35871d2da674c9c61385338 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 29 Sep 2020 14:54:12 -0700 Subject: [PATCH 187/337] chore: formatting (#1291) --- synth.metadata | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/synth.metadata b/synth.metadata index 0cad1e959..b1d1dbd2d 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "befe625f35b7c96e9a90399a1ca71a8a049224ad" + "sha": "388583bae74e0daead296974beaee9c230f770ef" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "05de3e1e14a0b07eab8b474e669164dbd31f81fb" + "sha": "8cf6d2834ad14318e64429c3b94f6443ae83daf9" } } ], @@ -59,7 +59,6 @@ ".github/ISSUE_TEMPLATE/feature_request.md", ".github/ISSUE_TEMPLATE/support_request.md", ".github/PULL_REQUEST_TEMPLATE.md", - ".github/publish.yml", ".github/release-please.yml", ".github/workflows/ci.yaml", ".gitignore", @@ -117,6 +116,7 @@ "dev/protos/protos.d.ts", "dev/protos/protos.js", "dev/protos/protos.json", + "dev/src/reference.ts", "dev/src/v1/firestore_admin_client.ts", "dev/src/v1/firestore_admin_client_config.json", "dev/src/v1/firestore_admin_proto_list.json", @@ -132,9 +132,7 @@ "dev/test/gapic_firestore_admin_v1.ts", "dev/test/gapic_firestore_v1.ts", "dev/test/gapic_firestore_v1beta1.ts", - "package-lock.json.3261340735", "renovate.json", - "samples/README.md", - "samples/package-lock.json.3433869271" + "samples/README.md" ] } \ No newline at end of file From 881ab5ba6b9fe5da5afcf780bcdf17a2242a70e8 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 30 Sep 2020 10:30:14 -0700 Subject: [PATCH 188/337] chore: release 4.4.0 (#1310) --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e451c103..1fccf847e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [4.4.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.3.0...v4.4.0) (2020-09-29) + + +### Features + +* add starting/max rates to BulkWriterOptions ([#1305](https://www.github.com/googleapis/nodejs-firestore/issues/1305)) ([57dcf1c](https://www.github.com/googleapis/nodejs-firestore/commit/57dcf1c42b406a15ecb960059d67d99a97d42547)) + + ## [4.3.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.2.0...v4.3.0) (2020-09-22) diff --git a/package.json b/package.json index 2f66fe856..6b0a51517 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.3.0", + "version": "4.4.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 13032037a..54f4f2d51 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.3.0" + "@google-cloud/firestore": "^4.4.0" }, "devDependencies": { "chai": "^4.2.0", From b493baf44e729fa584b29881ef83f7821967a97b Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Thu, 1 Oct 2020 17:09:21 -0500 Subject: [PATCH 189/337] fix: simplify BulkWriter logic (#1321) --- dev/src/write-batch.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 46e70b69f..b954a4b09 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -104,7 +104,6 @@ export class WriteResult implements firestore.WriteResult { */ export class BatchWriteResult { constructor( - readonly key: string, readonly writeTime: Timestamp | null, readonly status: GoogleError ) {} @@ -165,9 +164,9 @@ export class WriteBatch implements firestore.WriteBatch { if (retryBatch) { // Creates a new WriteBatch containing only the indexes from the provided // indexes to retry. - this._ops = retryBatch._ops.filter((op, index) => - indexesToRetry!.has(index) - ); + for (const index of indexesToRetry!.values()) { + this._ops.push(retryBatch._ops[index]); + } } } @@ -613,7 +612,7 @@ export class WriteBatch implements firestore.WriteBatch { error.code === Status.OK ? Timestamp.fromProto(result.updateTime || DELETE_TIMESTAMP_SENTINEL) : null; - return new BatchWriteResult(this._ops[i].docPath, updateTime, error); + return new BatchWriteResult(updateTime, error); }); } From 51961c3b39ff9c532214eb783458f83da98eb485 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 13 Oct 2020 11:15:32 -0700 Subject: [PATCH 190/337] feat: add support for Partition API (#1320) --- dev/src/bulk-writer.ts | 2 +- dev/src/collection-group.ts | 185 +++++++++++++++++++++++++ dev/src/document-change.ts | 2 +- dev/src/document.ts | 4 +- dev/src/field-value.ts | 2 +- dev/src/index.ts | 11 +- dev/src/query-partition.ts | 157 +++++++++++++++++++++ dev/src/reference.ts | 21 +-- dev/src/transaction.ts | 2 +- dev/src/types.ts | 5 + dev/src/write-batch.ts | 4 +- dev/system-test/firestore.ts | 134 +++++++++++++++++- dev/test/partition-query.ts | 258 +++++++++++++++++++++++++++++++++++ types/firestore.d.ts | 112 ++++++++++++++- 14 files changed, 874 insertions(+), 25 deletions(-) create mode 100644 dev/src/collection-group.ts create mode 100644 dev/src/query-partition.ts create mode 100644 dev/test/partition-query.ts diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 371b5ff7e..6a16cfcca 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -330,7 +330,7 @@ class BulkCommitBatch { * A Firestore BulkWriter than can be used to perform a large number of writes * in parallel. Writes to the same document will be executed sequentially. * - * @class + * @class BulkWriter */ export class BulkWriter { /** diff --git a/dev/src/collection-group.ts b/dev/src/collection-group.ts new file mode 100644 index 000000000..73e6cb742 --- /dev/null +++ b/dev/src/collection-group.ts @@ -0,0 +1,185 @@ +/* + * 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 * as protos from '../protos/firestore_v1_proto_api'; + +import {QueryPartition} from './query-partition'; +import {requestTag} from './util'; +import {logger} from './logger'; +import {Query, QueryOptions} from './reference'; +import {FieldPath} from './path'; +import {Firestore} from './index'; +import {validateInteger} from './validate'; + +import api = protos.google.firestore.v1; + +/** + * A `CollectionGroup` refers to all documents that are contained in a + * collection or subcollection with a specific collection ID. + * + * @class CollectionGroup + */ +export class CollectionGroup + extends Query + implements firestore.CollectionGroup { + /** @hideconstructor */ + constructor( + firestore: Firestore, + collectionId: string, + converter: firestore.FirestoreDataConverter | undefined + ) { + super( + firestore, + QueryOptions.forCollectionGroupQuery(collectionId, converter) + ); + } + + /** + * Partitions a query by returning partition cursors that can be used to run + * the query in parallel. The returned cursors are split points that can be + * used as starting and end points for individual query invocations. + * + * @example + * const query = firestore.collectionGroup('collectionId'); + * for await (const partition of query.getPartitions(42)) { + * const partitionedQuery = partition.toQuery(); + * const querySnapshot = await partitionedQuery.get(); + * console.log(`Partition contained ${querySnapshot.length} documents`); + * } + * + * @param {number} desiredPartitionCount The desired maximum number of + * partition points. The number must be strictly positive. The actual number + * of partitions returned may be fewer. + * @return {AsyncIterable} An AsyncIterable of + * `QueryPartition`s. + */ + async *getPartitions( + desiredPartitionCount: number + ): AsyncIterable> { + validateInteger('desiredPartitionCount', desiredPartitionCount, { + minValue: 1, + }); + + const tag = requestTag(); + await this.firestore.initializeIfNeeded(tag); + + let lastValues: api.IValue[] | undefined = undefined; + let partitionCount = 0; + + if (desiredPartitionCount > 1) { + // Partition queries require explicit ordering by __name__. + const queryWithDefaultOrder = this.orderBy(FieldPath.documentId()); + const request: api.IPartitionQueryRequest = queryWithDefaultOrder.toProto(); + + // Since we are always returning an extra partition (with an empty endBefore + // cursor), we reduce the desired partition count by one. + request.partitionCount = desiredPartitionCount - 1; + + const stream = await this.firestore.requestStream( + 'partitionQueryStream', + request, + tag + ); + stream.resume(); + + for await (const currentCursor of stream) { + ++partitionCount; + const currentValues = currentCursor.values ?? []; + yield new QueryPartition( + this._firestore, + this._queryOptions.collectionId, + this._queryOptions.converter, + lastValues, + currentValues + ); + lastValues = currentValues; + } + } + + logger( + 'Firestore.getPartitions', + tag, + 'Received %d partitions', + partitionCount + ); + + // Return the extra partition with the empty cursor. + yield new QueryPartition( + this._firestore, + this._queryOptions.collectionId, + this._queryOptions.converter, + lastValues, + undefined + ); + } + + /** + * Applies a custom data converter to this `CollectionGroup`, allowing you + * to use your own custom model objects with Firestore. When you call get() + * on the returned `CollectionGroup`, the provided converter will convert + * between Firestore data and your custom type U. + * + * 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( + * snapshot: FirebaseFirestore.QueryDocumentSnapshot + * ): Post { + * const data = snapshot.data(); + * return new Post(data.title, data.author); + * } + * }; + * + * const querySnapshot = await Firestore() + * .collectionGroup('posts') + * .withConverter(postConverter) + * .get(); + * for (const doc of querySnapshot.docs) { + * const post = doc.data(); + * post.title; // string + * post.toString(); // Should be defined + * post.someNonExistentProperty; // TS error + * } + * + * @param {FirestoreDataConverter} converter Converts objects to and from + * Firestore. + * @return {CollectionGroup} A `CollectionGroup` that uses the provided + * converter. + */ + withConverter( + converter: firestore.FirestoreDataConverter + ): CollectionGroup { + return new CollectionGroup( + this.firestore, + this._queryOptions.collectionId, + converter + ); + } +} diff --git a/dev/src/document-change.ts b/dev/src/document-change.ts index 0125783b9..57595b8b2 100644 --- a/dev/src/document-change.ts +++ b/dev/src/document-change.ts @@ -24,7 +24,7 @@ export type DocumentChangeType = 'added' | 'removed' | 'modified'; * A DocumentChange represents a change to the documents matching a query. * It contains the document affected and the type of change that occurred. * - * @class + * @class DocumentChange */ export class DocumentChange implements firestore.DocumentChange { diff --git a/dev/src/document.ts b/dev/src/document.ts index 970169d45..d136bedf2 100644 --- a/dev/src/document.ts +++ b/dev/src/document.ts @@ -94,7 +94,7 @@ export class DocumentSnapshotBuilder { * [exists]{@link DocumentSnapshot#exists} property to explicitly verify a * document's existence. * - * @class + * @class DocumentSnapshot */ export class DocumentSnapshot implements firestore.DocumentSnapshot { @@ -534,7 +534,7 @@ export class DocumentSnapshot * always be true and [data()]{@link QueryDocumentSnapshot#data} will never * return 'undefined'. * - * @class + * @class QueryDocumentSnapshot * @extends DocumentSnapshot */ export class QueryDocumentSnapshot diff --git a/dev/src/field-value.ts b/dev/src/field-value.ts index d894d8e35..64ea6df49 100644 --- a/dev/src/field-value.ts +++ b/dev/src/field-value.ts @@ -34,7 +34,7 @@ import api = proto.google.firestore.v1; * Sentinel values that can be used when writing documents with set(), create() * or update(). * - * @class + * @class FieldValue */ export class FieldValue implements firestore.FieldValue { /** diff --git a/dev/src/index.ts b/dev/src/index.ts index fde09a6f8..b8c5a2283 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -40,7 +40,7 @@ import { validateResourcePath, } from './path'; import {ClientPool} from './pool'; -import {CollectionReference, Query, QueryOptions} from './reference'; +import {CollectionReference} from './reference'; import {DocumentReference} from './reference'; import {Serializer} from './serializer'; import {Timestamp} from './timestamp'; @@ -75,6 +75,7 @@ import {interfaces} from './v1/firestore_client_config.json'; const serviceConfig = interfaces['google.firestore.v1.Firestore']; import api = google.firestore.v1; +import {CollectionGroup} from './collection-group'; export { CollectionReference, @@ -91,6 +92,8 @@ export {Timestamp} from './timestamp'; export {DocumentChange} from './document-change'; export {FieldPath} from './path'; export {GeoPoint} from './geo-point'; +export {CollectionGroup}; +export {QueryPartition} from './query-partition'; export {setLogFunction} from './logger'; export {Status as GrpcStatus} from 'google-gax'; @@ -632,7 +635,7 @@ export class Firestore implements firestore.Firestore { * @param {string} collectionId Identifies the collections to query over. * Every collection or subcollection with this ID as the last segment of its * path will be included. Cannot contain a slash. - * @returns {Query} The created Query. + * @returns {CollectionGroup} The created CollectionGroup. * * @example * let docA = firestore.doc('mygroup/docA').set({foo: 'bar'}); @@ -646,14 +649,14 @@ export class Firestore implements firestore.Firestore { * }); * }); */ - collectionGroup(collectionId: string): Query { + collectionGroup(collectionId: string): CollectionGroup { if (collectionId.indexOf('/') !== -1) { throw new Error( `Invalid collectionId '${collectionId}'. Collection IDs must not contain '/'.` ); } - return new Query(this, QueryOptions.forCollectionGroupQuery(collectionId)); + return new CollectionGroup(this, collectionId, /* converter= */ undefined); } /** diff --git a/dev/src/query-partition.ts b/dev/src/query-partition.ts new file mode 100644 index 000000000..04cf2f6e5 --- /dev/null +++ b/dev/src/query-partition.ts @@ -0,0 +1,157 @@ +/* + * 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 * as protos from '../protos/firestore_v1_proto_api'; + +import {FieldOrder, Query, QueryOptions} from './reference'; +import {FieldPath} from './path'; +import {Serializer} from './serializer'; +import {Firestore} from './index'; + +import api = protos.google.firestore.v1; + +/** + * A split point that can be used in a query as a starting and/or end point for + * the query results. The cursors returned by {@link #startAt} and {@link + * #endBefore} can only be used in a query that matches the constraint of query + * that produced this partition. + * + * @class QueryPartition + */ +export class QueryPartition + implements firestore.QueryPartition { + private readonly _serializer: Serializer; + private _memoizedStartAt: unknown[] | undefined; + private _memoizedEndBefore: unknown[] | undefined; + + /** @hideconstructor */ + constructor( + private readonly _firestore: Firestore, + private readonly _collectionId: string, + private readonly _converter: firestore.FirestoreDataConverter, + private readonly _startAt: api.IValue[] | undefined, + private readonly _endBefore: api.IValue[] | undefined + ) { + this._serializer = new Serializer(_firestore); + } + + /** + * The cursor that defines the first result for this partition or `undefined` + * if this is the first partition. The cursor value must be + * destructured when passed to `startAt()` (for example with + * `query.startAt(...queryPartition.startAt)`). + * + * @example + * const query = firestore.collectionGroup('collectionId'); + * for await (const partition of query.getPartitions(42)) { + * let partitionedQuery = query.orderBy(FieldPath.documentId()); + * if (partition.startAt) { + * partitionedQuery = partitionedQuery.startAt(...partition.startAt); + * } + * if (partition.endBefore) { + * partitionedQuery = partitionedQuery.endBefore(...partition.endBefore); + * } + * const querySnapshot = await partitionedQuery.get(); + * console.log(`Partition contained ${querySnapshot.length} documents`); + * } + * + * @type {Array<*>} + * @return {Array<*>} A cursor value that can be used with {@link + * Query#startAt} or `undefined` if this is the first partition. + */ + get startAt(): unknown[] | undefined { + if (this._startAt && !this._memoizedStartAt) { + this._memoizedStartAt = this._startAt.map(v => + this._serializer.decodeValue(v) + ); + } + + return this._memoizedStartAt; + } + + /** + * The cursor that defines the first result after this partition or + * `undefined` if this is the last partition. The cursor value must be + * destructured when passed to `endBefore()` (for example with + * `query.endBefore(...queryPartition.endBefore)`). + * + * @example + * const query = firestore.collectionGroup('collectionId'); + * for await (const partition of query.getPartitions(42)) { + * let partitionedQuery = query.orderBy(FieldPath.documentId()); + * if (partition.startAt) { + * partitionedQuery = partitionedQuery.startAt(...partition.startAt); + * } + * if (partition.endBefore) { + * partitionedQuery = partitionedQuery.endBefore(...partition.endBefore); + * } + * const querySnapshot = await partitionedQuery.get(); + * console.log(`Partition contained ${querySnapshot.length} documents`); + * } + * + * @type {Array<*>} + * @return {Array<*>} A cursor value that can be used with {@link + * Query#endBefore} or `undefined` if this is the last partition. + */ + get endBefore(): unknown[] | undefined { + if (this._endBefore && !this._memoizedEndBefore) { + this._memoizedEndBefore = this._endBefore.map(v => + this._serializer.decodeValue(v) + ); + } + + return this._memoizedEndBefore; + } + + /** + * Returns a query that only encapsulates the documents for this partition. + * + * @example + * const query = firestore.collectionGroup('collectionId'); + * for await (const partition of query.getPartitions(42)) { + * const partitionedQuery = partition.toQuery(); + * const querySnapshot = await partitionedQuery.get(); + * console.log(`Partition contained ${querySnapshot.length} documents`); + * } + * + * @return {Query} A query partitioned by a {@link Query#startAt} and + * {@link Query#endBefore} cursor. + */ + toQuery(): Query { + // Since the api.Value to JavaScript type conversion can be lossy (unless + // `useBigInt` is used), we pass the original protobuf representaion to the + // created query. + let queryOptions = QueryOptions.forCollectionGroupQuery( + this._collectionId, + this._converter + ); + queryOptions = queryOptions.with({ + fieldOrders: [new FieldOrder(FieldPath.documentId())], + }); + if (this._startAt !== undefined) { + queryOptions = queryOptions.with({ + startAt: {before: true, values: this._startAt}, + }); + } + if (this._endBefore !== undefined) { + queryOptions = queryOptions.with({ + endAt: {before: true, values: this._endBefore}, + }); + } + return new Query(this._firestore, queryOptions); + } +} diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 6166d2328..01bbee7ee 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -121,7 +121,7 @@ const comparisonOperators: { * [CollectionReference]{@link CollectionReference} to a * subcollection. * - * @class + * @class DocumentReference */ export class DocumentReference implements Serializable, firestore.DocumentReference { @@ -601,7 +601,7 @@ export class DocumentReference * @private * @class */ -class FieldOrder { +export class FieldOrder { /** * @param field The name of a document field (member) on which to order query * results. @@ -954,7 +954,7 @@ export class QuerySnapshot /** Internal representation of a query cursor before serialization. */ interface QueryCursor { before: boolean; - values: unknown[]; + values: api.IValue[]; } /*! @@ -1107,7 +1107,7 @@ export class Query implements firestore.Query { * @param _queryOptions Options that define the query. */ constructor( - private readonly _firestore: Firestore, + readonly _firestore: Firestore, protected readonly _queryOptions: QueryOptions ) { this._serializer = new Serializer(_firestore); @@ -1553,7 +1553,7 @@ export class Query implements firestore.Query { } validateQueryValue(i, fieldValue, this._allowUndefined); - options.values!.push(fieldValue); + options.values!.push(this._serializer.encodeValue(fieldValue)!); } return options; @@ -1922,10 +1922,9 @@ export class Query implements firestore.Query { */ private toCursor(cursor: QueryCursor | undefined): api.ICursor | undefined { if (cursor) { - const values = cursor.values.map( - val => this._serializer.encodeValue(val) as api.IValue - ); - return cursor.before ? {before: true, values} : {values}; + return cursor.before + ? {before: true, values: cursor.values} + : {values: cursor.values}; } return undefined; @@ -1997,6 +1996,8 @@ export class Query implements firestore.Query { /** * Converts current Query to an IBundledQuery. + * + * @private */ _toBundledQuery(): protos.firestore.IBundledQuery { const projectId = this.firestore.projectId; @@ -2311,7 +2312,7 @@ export class Query implements firestore.Query { * document references, and querying for documents (using the methods * inherited from [Query]{@link Query}). * - * @class + * @class CollectionReference * @extends Query */ export class CollectionReference diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index 12b3716de..c6721d8bb 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -55,7 +55,7 @@ const READ_AFTER_WRITE_ERROR_MSG = * the methods to read and write data within the transaction context. See * [runTransaction()]{@link Firestore#runTransaction}. * - * @class + * @class Transaction */ export class Transaction implements firestore.Transaction { private _firestore: Firestore; diff --git a/dev/src/types.ts b/dev/src/types.ts index ab5a359fa..2b62b03e9 100644 --- a/dev/src/types.ts +++ b/dev/src/types.ts @@ -70,6 +70,10 @@ export interface GapicClient { options?: CallOptions ): Promise<[string[], unknown, unknown]>; listen(options?: CallOptions): Duplex; + partitionQueryStream( + request?: api.IPartitionQueryRequest, + options?: CallOptions + ): Duplex; close(): Promise; } @@ -85,6 +89,7 @@ export type FirestoreUnaryMethod = /** Streaming methods used in the Firestore SDK. */ export type FirestoreStreamingMethod = | 'listen' + | 'partitionQueryStream' | 'runQuery' | 'batchGetDocuments'; diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index b954a4b09..d6ebcb504 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -53,7 +53,7 @@ import {GoogleError, Status} from 'google-gax'; * A WriteResult wraps the write time set by the Firestore servers on sets(), * updates(), and creates(). * - * @class + * @class WriteResult */ export class WriteResult implements firestore.WriteResult { /** @@ -120,7 +120,7 @@ type PendingWriteOp = () => api.IWrite; * A Firestore WriteBatch that can be used to atomically commit multiple write * operations at once. * - * @class + * @class WriteBatch */ export class WriteBatch implements firestore.WriteBatch { private readonly _firestore: Firestore; diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 11072e010..7178a7f37 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -14,7 +14,7 @@ import {QuerySnapshot, DocumentData} from '@google-cloud/firestore'; -import {describe, it, beforeEach, afterEach} from 'mocha'; +import {describe, it, before, beforeEach, afterEach} from 'mocha'; import {expect, use} from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; import * as extend from 'extend'; @@ -45,6 +45,8 @@ import { } from '../test/util/helpers'; import IBundleElement = firestore.IBundleElement; import {BulkWriter} from '../src/bulk-writer'; +import {QueryPartition} from '../src/query-partition'; +import {CollectionGroup} from '../src/collection-group'; use(chaiAsPromised); @@ -194,6 +196,126 @@ describe('Firestore class', () => { }); }); +describe('CollectionGroup class', () => { + const desiredPartitionCount = 3; + const documentCount = 2 * 128 + 127; // Minimum partition size is 128. + + let firestore: Firestore; + let randomColl: CollectionReference; + let collectionGroup: CollectionGroup; + + before(async () => { + firestore = new Firestore({}); + randomColl = getTestRoot(firestore); + collectionGroup = firestore.collectionGroup(randomColl.id); + + const batch = firestore.batch(); + for (let i = 0; i < documentCount; ++i) { + batch.create(randomColl.doc(), {title: 'post', author: 'author'}); + } + await batch.commit(); + }); + + async function getPartitions( + collectionGroup: CollectionGroup, + desiredPartitionsCount: number + ): Promise[]> { + const partitions: QueryPartition[] = []; + for await (const partition of collectionGroup.getPartitions( + desiredPartitionsCount + )) { + partitions.push(partition); + } + return partitions; + } + + async function verifyPartitions( + partitions: QueryPartition[] + ): Promise[]> { + expect(partitions.length).to.not.be.greaterThan(desiredPartitionCount); + + expect(partitions[0].startAt).to.be.undefined; + for (let i = 0; i < partitions.length - 1; ++i) { + // The cursor value is a single DocumentReference + expect( + (partitions[i].endBefore![0] as DocumentReference).isEqual( + partitions[i + 1].startAt![0] as DocumentReference + ) + ).to.be.true; + } + expect(partitions[partitions.length - 1].endBefore).to.be.undefined; + + // Validate that we can use the partitions to read the original documents. + const documents: QueryDocumentSnapshot[] = []; + for (const partition of partitions) { + documents.push(...(await partition.toQuery().get()).docs); + } + expect(documents.length).to.equal(documentCount); + + return documents; + } + + it('partition query', async () => { + const partitions = await getPartitions( + collectionGroup, + desiredPartitionCount + ); + await verifyPartitions(partitions); + }); + + it('partition query with manual cursors', async () => { + const partitions = await getPartitions( + collectionGroup, + desiredPartitionCount + ); + + const documents: QueryDocumentSnapshot[] = []; + for (const partition of partitions) { + // TODO(mrschmidt); Remove the need to add an `orderBy` here + let partitionedQuery = collectionGroup.orderBy(FieldPath.documentId()); + if (partition.startAt) { + partitionedQuery = partitionedQuery.startAt(...partition.startAt); + } + if (partition.endBefore) { + partitionedQuery = partitionedQuery.endBefore(...partition.endBefore); + } + documents.push(...(await partitionedQuery.get()).docs); + } + + expect(documents.length).to.equal(documentCount); + }); + + it('partition query with converter', async () => { + const collectionGroupWithConverter = collectionGroup.withConverter( + postConverter + ); + const partitions = await getPartitions( + collectionGroupWithConverter, + desiredPartitionCount + ); + const documents = await verifyPartitions(partitions); + + for (const document of documents) { + expect(document.data()).to.be.an.instanceOf(Post); + } + }); + + it('empty partition query', async () => { + const desiredPartitionCount = 3; + + const collectionGroupId = randomColl.doc().id; + const collectionGroup = firestore.collectionGroup(collectionGroupId); + const partitions = await getPartitions( + collectionGroup, + desiredPartitionCount + ); + + expect(partitions.length).to.equal(1); + expect(partitions[0].startAt).to.be.undefined; + expect(partitions[0].endBefore).to.be.undefined; + }); +}); + describe('CollectionReference class', () => { let firestore: Firestore; let randomCol: CollectionReference; @@ -2547,6 +2669,16 @@ describe('Client initialization', () => { return deferred.promise; }, ], + [ + 'CollectionGroup.getPartitions()', + async randomColl => { + const partitions = randomColl.firestore + .collectionGroup('id') + .getPartitions(2); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + for await (const _ of partitions); + }, + ], [ 'Firestore.runTransaction()', randomColl => randomColl.firestore.runTransaction(t => t.get(randomColl)), diff --git a/dev/test/partition-query.ts b/dev/test/partition-query.ts new file mode 100644 index 000000000..647c3d391 --- /dev/null +++ b/dev/test/partition-query.ts @@ -0,0 +1,258 @@ +// 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 { + CollectionGroup, + DocumentData, + QueryPartition, +} from '@google-cloud/firestore'; + +import {describe, it, beforeEach, afterEach} from 'mocha'; +import {expect, use} from 'chai'; +import * as chaiAsPromised from 'chai-as-promised'; +import * as extend from 'extend'; + +import {google} from '../protos/firestore_v1_proto_api'; +import {Firestore} from '../src'; +import {setTimeoutHandler} from '../src/backoff'; +import { + ApiOverride, + createInstance, + stream, + verifyInstance, +} from './util/helpers'; + +use(chaiAsPromised); + +import api = google.firestore.v1; + +const PROJECT_ID = 'test-project'; +const DATABASE_ROOT = `projects/${PROJECT_ID}/databases/(default)`; + +export function partitionQueryEquals( + actual: api.IPartitionQueryRequest | undefined, + partitionCount: number +) { + expect(actual).to.not.be.undefined; + + const query: api.IPartitionQueryRequest = { + parent: DATABASE_ROOT + '/documents', + structuredQuery: { + from: [ + { + allDescendants: true, + collectionId: 'collectionId', + }, + ], + orderBy: [ + { + direction: 'ASCENDING', + field: { + fieldPath: '__name__', + }, + }, + ], + }, + partitionCount, + }; + + // 'extend' removes undefined fields in the request object. The backend + // ignores these fields, but we need to manually strip them before we compare + // the expected and the actual request. + actual = extend(true, {}, actual); + expect(actual).to.deep.eq(query); +} + +describe('Partition Query', () => { + let firestore: Firestore; + + beforeEach(() => { + setTimeoutHandler(setImmediate); + return createInstance().then(firestoreInstance => { + firestore = firestoreInstance; + }); + }); + + afterEach(() => { + verifyInstance(firestore); + setTimeoutHandler(setTimeout); + }); + + async function getPartitions( + collectionGroup: CollectionGroup, + desiredPartitionsCount: number + ): Promise[]> { + const partitions: QueryPartition[] = []; + for await (const partition of collectionGroup.getPartitions( + desiredPartitionsCount + )) { + partitions.push(partition); + } + return partitions; + } + + it('requests one less than desired partitions', () => { + const desiredPartitionsCount = 2; + const cursorValue = { + values: [{referenceValue: 'projects/p1/databases/d1/documents/coll/doc'}], + }; + + const overrides: ApiOverride = { + partitionQueryStream: request => { + partitionQueryEquals( + request, + /* partitionCount= */ desiredPartitionsCount - 1 + ); + + return stream(cursorValue); + }, + }; + return createInstance(overrides).then(async firestore => { + const query = firestore.collectionGroup('collectionId'); + + const result = await getPartitions(query, desiredPartitionsCount); + expect(result.length).to.equal(2); + expect(result[0].startAt).to.be.undefined; + expect(result[0].endBefore).to.deep.equal(result[1].startAt); + expect(result[1].endBefore).to.be.undefined; + }); + }); + + it('does not issue RPC if only a single partition is requested', () => { + const desiredPartitionsCount = 1; + + return createInstance().then(async firestore => { + const query = firestore.collectionGroup('collectionId'); + + const result = await getPartitions(query, desiredPartitionsCount); + expect(result.length).to.equal(1); + expect(result[0].startAt).to.be.undefined; + expect(result[0].endBefore).to.be.undefined; + }); + }); + + it('validates partition count', () => { + return createInstance().then(firestore => { + const query = firestore.collectionGroup('collectionId'); + return expect(getPartitions(query, 0)).to.eventually.be.rejectedWith( + 'Value for argument "desiredPartitionCount" must be within [1, Infinity] inclusive, but was: 0' + ); + }); + }); + + it('converts partitions to queries', () => { + const desiredPartitionsCount = 3; + + const expectedStartAt: Array = [ + undefined, + {referenceValue: 'coll/doc1'}, + {referenceValue: 'coll/doc2'}, + ]; + const expectedEndBefore: Array = [ + {referenceValue: 'coll/doc1'}, + {referenceValue: 'coll/doc2'}, + undefined, + ]; + + const overrides: ApiOverride = { + partitionQueryStream: request => { + partitionQueryEquals( + request, + /* partitionCount= */ desiredPartitionsCount - 1 + ); + + return stream( + { + values: [{referenceValue: 'coll/doc1'}], + }, + { + values: [{referenceValue: 'coll/doc2'}], + } + ); + }, + runQuery: request => { + const startAt = expectedStartAt.shift(); + if (startAt) { + expect(request!.structuredQuery!.startAt).to.deep.equal({ + before: true, + values: [startAt], + }); + } else { + expect(request!.structuredQuery!.startAt).to.be.undefined; + } + + const endBefore = expectedEndBefore.shift(); + if (endBefore) { + expect(request!.structuredQuery!.endAt).to.deep.equal({ + before: true, + values: [endBefore], + }); + } else { + expect(request!.structuredQuery!.endAt).to.be.undefined; + } + return stream(); + }, + }; + return createInstance(overrides).then(async firestore => { + const query = firestore.collectionGroup('collectionId'); + + const partitions = await getPartitions(query, desiredPartitionsCount); + expect(partitions.length).to.equal(3); + + for (const partition of partitions) { + await partition.toQuery().get(); + } + }); + }); + + it("doesn't truncate large numbers", () => { + // JavaScript by default truncates large numbers. If partition data were + // to include truncated numbers, using them as cursors could skip or + // duplicate results. Note that the backend API currently only returns + // DocumentReferences as partitions, but this may change in the future. + const bigIntValue = BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1); + const desiredPartitionsCount = 2; + + const overrides: ApiOverride = { + partitionQueryStream: request => { + partitionQueryEquals( + request, + /* partitionCount= */ desiredPartitionsCount - 1 + ); + + return stream({ + values: [{integerValue: bigIntValue.toString()}], + }); + }, + runQuery: request => { + expect( + request!.structuredQuery!.endAt!.values![0].integerValue + ).to.equal(bigIntValue.toString()); + return stream(); + }, + }; + return createInstance(overrides).then(async firestore => { + const query = firestore.collectionGroup('collectionId'); + + const result = await getPartitions(query, desiredPartitionsCount); + expect(result.length).to.equal(2); + + // If the user uses the cursor directly, we follow the `useBigInt` + // setting. By default, we return a truncated number. + expect(result[0].endBefore![0]).to.be.a('number'); + expect(result[1].startAt![0]).to.be.a('number'); + return result[0].toQuery().get(); + }); + }); +}); diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 7ffe79280..a5fc485bc 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -219,9 +219,9 @@ declare namespace FirebaseFirestore { * @param collectionId Identifies the collections to query over. Every * collection or subcollection with this ID as the last segment of its path * will be included. Cannot contain a slash. - * @return The created Query. + * @return The created `CollectionGroup`. */ - collectionGroup(collectionId: string): Query; + collectionGroup(collectionId: string): CollectionGroup; /** * Retrieves multiple documents from Firestore. @@ -1532,6 +1532,114 @@ declare namespace FirebaseFirestore { ): CollectionReference; } + /** + * A `CollectionGroup` refers to all documents that are contained in a + * collection or subcollection with a specific collection ID. + */ + export class CollectionGroup extends Query { + private constructor(); + + /** + * Partitions a query by returning partition cursors that can be used to run + * the query in parallel. The returned cursors are split points that can be + * used as starting and end points for individual query invocations. + * + * @param desiredPartitionCount The desired maximum number of partition + * points. The number must be strictly positive. The actual number of + * partitions returned may be fewer. + * @return An AsyncIterable of `QueryPartition`s. + */ + getPartitions( + desiredPartitionCount: number + ): AsyncIterable>; + + /** + * Applies a custom data converter to this `CollectionGroup`, allowing you + * to use your own custom model objects with Firestore. When you call get() + * on the returned `CollectionGroup`, the provided converter will convert + * between Firestore data and your custom type U. + * + * 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( + * snapshot: FirebaseFirestore.QueryDocumentSnapshot + * ): Post { + * const data = snapshot.data(); + * return new Post(data.title, data.author); + * } + * }; + * + * const querySnapshot = await Firestore() + * .collectionGroup('posts') + * .withConverter(postConverter) + * .get(); + * for (const doc of querySnapshot.docs) { + * const post = doc.data(); + * post.title; // string + * post.toString(); // Should be defined + * post.someNonExistentProperty; // TS error + * } + * + * @param converter Converts objects to and from Firestore. + * @return A `CollectionGroup` that uses the provided converter. + */ + withConverter(converter: FirestoreDataConverter): CollectionGroup; + } + + /** + * A split point that can be used in a query as a starting and/or end point for + * the query results. The cursors returned by {@link #startAt} and {@link + * #endBefore} can only be used in a query that matches the constraint of query + * that produced this partition. + */ + export class QueryPartition { + private constructor(); + + /** + * The cursor that defines the first result for this partition or + * `undefined` if this is the first partition. The cursor value must be + * destructured when passed to `startAt()` (for example with + * `query.startAt(...queryPartition.startAt)`). + * + * @return Cursor values that can be used with {@link Query#startAt} or + * `undefined` if this is the first partition. + */ + get startAt(): unknown[] | undefined; + + /** + * The cursor that defines the first result after this partition or + * `undefined` if this is the last partition. The cursor value must be + * destructured when passed to `endBefore()` (for example with + * `query.endBefore(...queryPartition.endBefore)`). + * + * @return Cursor values that can be used with {@link Query#endBefore} or + * `undefined` if this is the last partition. + */ + get endBefore(): unknown[] | undefined; + + /** + * Returns a query that only returns the documents for this partition. + * + * @return A query partitioned by a {@link Query#startAt} and {@link + * Query#endBefore} cursor. + */ + toQuery(): Query; + } + /** * Sentinel values that can be used when writing document fields with set(), * create() or update(). From 183b2a208cfe044f8f2724c75417c4fec266f7d5 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 14 Oct 2020 15:27:21 -0700 Subject: [PATCH 191/337] chore: stop Synthtool from deleting reference.ts (#1329) --- synth.metadata | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/synth.metadata b/synth.metadata index b1d1dbd2d..5efbc1492 100644 --- a/synth.metadata +++ b/synth.metadata @@ -116,7 +116,6 @@ "dev/protos/protos.d.ts", "dev/protos/protos.js", "dev/protos/protos.json", - "dev/src/reference.ts", "dev/src/v1/firestore_admin_client.ts", "dev/src/v1/firestore_admin_client_config.json", "dev/src/v1/firestore_admin_proto_list.json", @@ -135,4 +134,4 @@ "renovate.json", "samples/README.md" ] -} \ No newline at end of file +} From ca2433ff2910b50c5c7b8268ae43469331309e83 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 15 Oct 2020 12:20:13 -0700 Subject: [PATCH 192/337] chore: update generated Proto code (#1333) * changes without context autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. * build(test): recursively find test files; fail on unsupported dependency versions Source-Author: Megan Potter <57276408+feywind@users.noreply.github.com> Source-Date: Fri Sep 11 18:47:00 2020 -0700 Source-Repo: googleapis/synthtool Source-Sha: fdd03c161003ab97657cc0218f25c82c89ddf4b6 Source-Link: https://github.com/googleapis/synthtool/commit/fdd03c161003ab97657cc0218f25c82c89ddf4b6 * build(node_library): migrate to Trampoline V2 Source-Author: Takashi Matsuo Source-Date: Fri Oct 2 12:13:27 2020 -0700 Source-Repo: googleapis/synthtool Source-Sha: 0c868d49b8e05bc1f299bc773df9eb4ef9ed96e9 Source-Link: https://github.com/googleapis/synthtool/commit/0c868d49b8e05bc1f299bc773df9eb4ef9ed96e9 --- .trampolinerc | 51 ++++++++++++++++++++ dev/protos/firestore_admin_v1_proto_api.d.ts | 10 ++++ dev/protos/firestore_admin_v1_proto_api.js | 50 ++++++++++++++++++- dev/protos/firestore_v1_proto_api.d.ts | 10 ++++ dev/protos/firestore_v1_proto_api.js | 50 ++++++++++++++++++- dev/protos/firestore_v1beta1_proto_api.d.ts | 10 ++++ dev/protos/firestore_v1beta1_proto_api.js | 50 ++++++++++++++++++- dev/protos/google/api/resource.proto | 21 ++++++++ synth.metadata | 7 +-- 9 files changed, 253 insertions(+), 6 deletions(-) create mode 100644 .trampolinerc diff --git a/.trampolinerc b/.trampolinerc new file mode 100644 index 000000000..164613b9e --- /dev/null +++ b/.trampolinerc @@ -0,0 +1,51 @@ +# 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. + +# Template for .trampolinerc + +# Add required env vars here. +required_envvars+=( +) + +# Add env vars which are passed down into the container here. +pass_down_envvars+=( + "AUTORELEASE_PR" +) + +# Prevent unintentional override on the default image. +if [[ "${TRAMPOLINE_IMAGE_UPLOAD:-false}" == "true" ]] && \ + [[ -z "${TRAMPOLINE_IMAGE:-}" ]]; then + echo "Please set TRAMPOLINE_IMAGE if you want to upload the Docker image." + exit 1 +fi + +# Define the default value if it makes sense. +if [[ -z "${TRAMPOLINE_IMAGE_UPLOAD:-}" ]]; then + TRAMPOLINE_IMAGE_UPLOAD="" +fi + +if [[ -z "${TRAMPOLINE_IMAGE:-}" ]]; then + TRAMPOLINE_IMAGE="" +fi + +if [[ -z "${TRAMPOLINE_DOCKERFILE:-}" ]]; then + TRAMPOLINE_DOCKERFILE="" +fi + +if [[ -z "${TRAMPOLINE_BUILD_FILE:-}" ]]; then + TRAMPOLINE_BUILD_FILE="" +fi + +# Secret Manager secrets. +source ${PROJECT_ROOT}/.kokoro/populate-secrets.sh diff --git a/dev/protos/firestore_admin_v1_proto_api.d.ts b/dev/protos/firestore_admin_v1_proto_api.d.ts index 1f9753f2b..f751574e3 100644 --- a/dev/protos/firestore_admin_v1_proto_api.d.ts +++ b/dev/protos/firestore_admin_v1_proto_api.d.ts @@ -1708,6 +1708,9 @@ export namespace google { /** ResourceDescriptor singular */ singular?: (string|null); + + /** ResourceDescriptor style */ + style?: (google.api.ResourceDescriptor.Style[]|null); } /** Represents a ResourceDescriptor. */ @@ -1737,6 +1740,9 @@ export namespace google { /** ResourceDescriptor singular. */ public singular: string; + /** ResourceDescriptor style. */ + public style: google.api.ResourceDescriptor.Style[]; + /** * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. * @param object Plain object @@ -1764,6 +1770,10 @@ export namespace google { /** History enum. */ type History = "HISTORY_UNSPECIFIED"| "ORIGINALLY_SINGLE_PATTERN"| "FUTURE_MULTI_PATTERN"; + + /** Style enum. */ + type Style = + "STYLE_UNSPECIFIED"| "DECLARATIVE_FRIENDLY"; } /** Properties of a ResourceReference. */ diff --git a/dev/protos/firestore_admin_v1_proto_api.js b/dev/protos/firestore_admin_v1_proto_api.js index d13a0b98a..92a195249 100644 --- a/dev/protos/firestore_admin_v1_proto_api.js +++ b/dev/protos/firestore_admin_v1_proto_api.js @@ -3954,6 +3954,7 @@ * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history * @property {string|null} [plural] ResourceDescriptor plural * @property {string|null} [singular] ResourceDescriptor singular + * @property {Array.|null} [style] ResourceDescriptor style */ /** @@ -3966,6 +3967,7 @@ */ function ResourceDescriptor(properties) { this.pattern = []; + this.style = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -4020,6 +4022,14 @@ */ ResourceDescriptor.prototype.singular = ""; + /** + * ResourceDescriptor style. + * @member {Array.} style + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.style = $util.emptyArray; + /** * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. * @function fromObject @@ -4061,6 +4071,23 @@ message.plural = String(object.plural); if (object.singular != null) message.singular = String(object.singular); + if (object.style) { + if (!Array.isArray(object.style)) + throw TypeError(".google.api.ResourceDescriptor.style: array expected"); + message.style = []; + for (var i = 0; i < object.style.length; ++i) + switch (object.style[i]) { + default: + case "STYLE_UNSPECIFIED": + case 0: + message.style[i] = 0; + break; + case "DECLARATIVE_FRIENDLY": + case 1: + message.style[i] = 1; + break; + } + } return message; }; @@ -4077,8 +4104,10 @@ if (!options) options = {}; var object = {}; - if (options.arrays || options.defaults) + if (options.arrays || options.defaults) { object.pattern = []; + object.style = []; + } if (options.defaults) { object.type = ""; object.nameField = ""; @@ -4101,6 +4130,11 @@ object.plural = message.plural; if (message.singular != null && message.hasOwnProperty("singular")) object.singular = message.singular; + if (message.style && message.style.length) { + object.style = []; + for (var j = 0; j < message.style.length; ++j) + object.style[j] = options.enums === String ? $root.google.api.ResourceDescriptor.Style[message.style[j]] : message.style[j]; + } return object; }; @@ -4131,6 +4165,20 @@ return values; })(); + /** + * Style enum. + * @name google.api.ResourceDescriptor.Style + * @enum {string} + * @property {string} STYLE_UNSPECIFIED=STYLE_UNSPECIFIED STYLE_UNSPECIFIED value + * @property {string} DECLARATIVE_FRIENDLY=DECLARATIVE_FRIENDLY DECLARATIVE_FRIENDLY value + */ + ResourceDescriptor.Style = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STYLE_UNSPECIFIED"] = "STYLE_UNSPECIFIED"; + values[valuesById[1] = "DECLARATIVE_FRIENDLY"] = "DECLARATIVE_FRIENDLY"; + return values; + })(); + return ResourceDescriptor; })(); diff --git a/dev/protos/firestore_v1_proto_api.d.ts b/dev/protos/firestore_v1_proto_api.d.ts index 2e07e21c9..5757a58ec 100644 --- a/dev/protos/firestore_v1_proto_api.d.ts +++ b/dev/protos/firestore_v1_proto_api.d.ts @@ -6391,6 +6391,9 @@ export namespace google { /** ResourceDescriptor singular */ singular?: (string|null); + + /** ResourceDescriptor style */ + style?: (google.api.ResourceDescriptor.Style[]|null); } /** Represents a ResourceDescriptor. */ @@ -6420,6 +6423,9 @@ export namespace google { /** ResourceDescriptor singular. */ public singular: string; + /** ResourceDescriptor style. */ + public style: google.api.ResourceDescriptor.Style[]; + /** * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. * @param object Plain object @@ -6447,6 +6453,10 @@ export namespace google { /** History enum. */ type History = "HISTORY_UNSPECIFIED"| "ORIGINALLY_SINGLE_PATTERN"| "FUTURE_MULTI_PATTERN"; + + /** Style enum. */ + type Style = + "STYLE_UNSPECIFIED"| "DECLARATIVE_FRIENDLY"; } /** Properties of a ResourceReference. */ diff --git a/dev/protos/firestore_v1_proto_api.js b/dev/protos/firestore_v1_proto_api.js index ded2d07c8..f85efa164 100644 --- a/dev/protos/firestore_v1_proto_api.js +++ b/dev/protos/firestore_v1_proto_api.js @@ -15411,6 +15411,7 @@ * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history * @property {string|null} [plural] ResourceDescriptor plural * @property {string|null} [singular] ResourceDescriptor singular + * @property {Array.|null} [style] ResourceDescriptor style */ /** @@ -15423,6 +15424,7 @@ */ function ResourceDescriptor(properties) { this.pattern = []; + this.style = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -15477,6 +15479,14 @@ */ ResourceDescriptor.prototype.singular = ""; + /** + * ResourceDescriptor style. + * @member {Array.} style + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.style = $util.emptyArray; + /** * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. * @function fromObject @@ -15518,6 +15528,23 @@ message.plural = String(object.plural); if (object.singular != null) message.singular = String(object.singular); + if (object.style) { + if (!Array.isArray(object.style)) + throw TypeError(".google.api.ResourceDescriptor.style: array expected"); + message.style = []; + for (var i = 0; i < object.style.length; ++i) + switch (object.style[i]) { + default: + case "STYLE_UNSPECIFIED": + case 0: + message.style[i] = 0; + break; + case "DECLARATIVE_FRIENDLY": + case 1: + message.style[i] = 1; + break; + } + } return message; }; @@ -15534,8 +15561,10 @@ if (!options) options = {}; var object = {}; - if (options.arrays || options.defaults) + if (options.arrays || options.defaults) { object.pattern = []; + object.style = []; + } if (options.defaults) { object.type = ""; object.nameField = ""; @@ -15558,6 +15587,11 @@ object.plural = message.plural; if (message.singular != null && message.hasOwnProperty("singular")) object.singular = message.singular; + if (message.style && message.style.length) { + object.style = []; + for (var j = 0; j < message.style.length; ++j) + object.style[j] = options.enums === String ? $root.google.api.ResourceDescriptor.Style[message.style[j]] : message.style[j]; + } return object; }; @@ -15588,6 +15622,20 @@ return values; })(); + /** + * Style enum. + * @name google.api.ResourceDescriptor.Style + * @enum {string} + * @property {string} STYLE_UNSPECIFIED=STYLE_UNSPECIFIED STYLE_UNSPECIFIED value + * @property {string} DECLARATIVE_FRIENDLY=DECLARATIVE_FRIENDLY DECLARATIVE_FRIENDLY value + */ + ResourceDescriptor.Style = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STYLE_UNSPECIFIED"] = "STYLE_UNSPECIFIED"; + values[valuesById[1] = "DECLARATIVE_FRIENDLY"] = "DECLARATIVE_FRIENDLY"; + return values; + })(); + return ResourceDescriptor; })(); diff --git a/dev/protos/firestore_v1beta1_proto_api.d.ts b/dev/protos/firestore_v1beta1_proto_api.d.ts index 467a4eade..772eedff8 100644 --- a/dev/protos/firestore_v1beta1_proto_api.d.ts +++ b/dev/protos/firestore_v1beta1_proto_api.d.ts @@ -5822,6 +5822,9 @@ export namespace google { /** ResourceDescriptor singular */ singular?: (string|null); + + /** ResourceDescriptor style */ + style?: (google.api.ResourceDescriptor.Style[]|null); } /** Represents a ResourceDescriptor. */ @@ -5851,6 +5854,9 @@ export namespace google { /** ResourceDescriptor singular. */ public singular: string; + /** ResourceDescriptor style. */ + public style: google.api.ResourceDescriptor.Style[]; + /** * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. * @param object Plain object @@ -5878,6 +5884,10 @@ export namespace google { /** History enum. */ type History = "HISTORY_UNSPECIFIED"| "ORIGINALLY_SINGLE_PATTERN"| "FUTURE_MULTI_PATTERN"; + + /** Style enum. */ + type Style = + "STYLE_UNSPECIFIED"| "DECLARATIVE_FRIENDLY"; } /** Properties of a ResourceReference. */ diff --git a/dev/protos/firestore_v1beta1_proto_api.js b/dev/protos/firestore_v1beta1_proto_api.js index 35a0681fa..4887a4bcd 100644 --- a/dev/protos/firestore_v1beta1_proto_api.js +++ b/dev/protos/firestore_v1beta1_proto_api.js @@ -14017,6 +14017,7 @@ * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history * @property {string|null} [plural] ResourceDescriptor plural * @property {string|null} [singular] ResourceDescriptor singular + * @property {Array.|null} [style] ResourceDescriptor style */ /** @@ -14029,6 +14030,7 @@ */ function ResourceDescriptor(properties) { this.pattern = []; + this.style = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -14083,6 +14085,14 @@ */ ResourceDescriptor.prototype.singular = ""; + /** + * ResourceDescriptor style. + * @member {Array.} style + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.style = $util.emptyArray; + /** * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. * @function fromObject @@ -14124,6 +14134,23 @@ message.plural = String(object.plural); if (object.singular != null) message.singular = String(object.singular); + if (object.style) { + if (!Array.isArray(object.style)) + throw TypeError(".google.api.ResourceDescriptor.style: array expected"); + message.style = []; + for (var i = 0; i < object.style.length; ++i) + switch (object.style[i]) { + default: + case "STYLE_UNSPECIFIED": + case 0: + message.style[i] = 0; + break; + case "DECLARATIVE_FRIENDLY": + case 1: + message.style[i] = 1; + break; + } + } return message; }; @@ -14140,8 +14167,10 @@ if (!options) options = {}; var object = {}; - if (options.arrays || options.defaults) + if (options.arrays || options.defaults) { object.pattern = []; + object.style = []; + } if (options.defaults) { object.type = ""; object.nameField = ""; @@ -14164,6 +14193,11 @@ object.plural = message.plural; if (message.singular != null && message.hasOwnProperty("singular")) object.singular = message.singular; + if (message.style && message.style.length) { + object.style = []; + for (var j = 0; j < message.style.length; ++j) + object.style[j] = options.enums === String ? $root.google.api.ResourceDescriptor.Style[message.style[j]] : message.style[j]; + } return object; }; @@ -14194,6 +14228,20 @@ return values; })(); + /** + * Style enum. + * @name google.api.ResourceDescriptor.Style + * @enum {string} + * @property {string} STYLE_UNSPECIFIED=STYLE_UNSPECIFIED STYLE_UNSPECIFIED value + * @property {string} DECLARATIVE_FRIENDLY=DECLARATIVE_FRIENDLY DECLARATIVE_FRIENDLY value + */ + ResourceDescriptor.Style = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STYLE_UNSPECIFIED"] = "STYLE_UNSPECIFIED"; + values[valuesById[1] = "DECLARATIVE_FRIENDLY"] = "DECLARATIVE_FRIENDLY"; + return values; + })(); + return ResourceDescriptor; })(); diff --git a/dev/protos/google/api/resource.proto b/dev/protos/google/api/resource.proto index 22611d243..fd9ee66de 100644 --- a/dev/protos/google/api/resource.proto +++ b/dev/protos/google/api/resource.proto @@ -168,6 +168,22 @@ message ResourceDescriptor { FUTURE_MULTI_PATTERN = 2; } + // A flag representing a specific style that a resource claims to conform to. + enum Style { + // The unspecified value. Do not use. + STYLE_UNSPECIFIED = 0; + + // This resource is intended to be "declarative-friendly". + // + // Declarative-friendly resources must be more strictly consistent, and + // setting this to true communicates to tools that this resource should + // adhere to declarative-friendly expectations. + // + // Note: This is used by the API linter (linter.aip.dev) to enable + // additional checks. + DECLARATIVE_FRIENDLY = 1; + } + // The resource type. It must be in the format of // {service_name}/{resource_type_kind}. The `resource_type_kind` must be // singular and must not include version numbers. @@ -236,6 +252,11 @@ message ResourceDescriptor { // https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ // Such as "project" for the `resourcemanager.googleapis.com/Project` type. string singular = 6; + + // Style flag(s) for this resource. + // These indicate that a resource is expected to conform to a given + // style. See the specific style flags for additional information. + repeated Style style = 10; } // Defines a proto annotation that describes a string field that refers to diff --git a/synth.metadata b/synth.metadata index 5efbc1492..ffe1c3b51 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "388583bae74e0daead296974beaee9c230f770ef" + "sha": "183b2a208cfe044f8f2724c75417c4fec266f7d5" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "8cf6d2834ad14318e64429c3b94f6443ae83daf9" + "sha": "0c868d49b8e05bc1f299bc773df9eb4ef9ed96e9" } } ], @@ -67,6 +67,7 @@ ".nycrc", ".prettierignore", ".prettierrc.js", + ".trampolinerc", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "LICENSE", @@ -134,4 +135,4 @@ "renovate.json", "samples/README.md" ] -} +} \ No newline at end of file From a8789b95e357795ad30498e9f4198491a14aed0e Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 16 Oct 2020 10:08:14 -0700 Subject: [PATCH 193/337] build: only check --engine-strict for production deps (#1335) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/02b30105-142c-418e-95f6-025914ce48a3/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: https://github.com/googleapis/synthtool/commit/5451633881133e5573cc271a18e73b18caca8b1b --- .github/workflows/ci.yaml | 6 +++++- synth.metadata | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7dd110e3f..06067a8c7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,7 +16,11 @@ jobs: with: node-version: ${{ matrix.node }} - run: node --version - - run: npm install --engine-strict + # The first installation step ensures that all of our production + # dependencies work on the given Node.js version, this helps us find + # dependencies that don't match our engines field: + - run: npm install --production --engine-strict + - run: npm install - run: npm test - name: coverage uses: codecov/codecov-action@v1 diff --git a/synth.metadata b/synth.metadata index ffe1c3b51..0b178321f 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "183b2a208cfe044f8f2724c75417c4fec266f7d5" + "sha": "ca2433ff2910b50c5c7b8268ae43469331309e83" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "0c868d49b8e05bc1f299bc773df9eb4ef9ed96e9" + "sha": "5451633881133e5573cc271a18e73b18caca8b1b" } } ], From 39a30c24a54078e53ad9c746ee8ae5a4a9471349 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 16 Oct 2020 15:39:30 -0700 Subject: [PATCH 194/337] fix(firestore/v1): give PartitionQuery retry/timeout config (#1334) PiperOrigin-RevId: 335655077 Source-Author: Google APIs Source-Date: Tue Oct 6 09:23:11 2020 -0700 Source-Repo: googleapis/googleapis Source-Sha: 610bf8f0262846bd1bc045a2913631c00e5e0199 Source-Link: https://github.com/googleapis/googleapis/commit/610bf8f0262846bd1bc045a2913631c00e5e0199 Co-authored-by: sofisl <55454395+sofisl@users.noreply.github.com> --- dev/src/v1/firestore_client_config.json | 3 ++- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dev/src/v1/firestore_client_config.json b/dev/src/v1/firestore_client_config.json index f3f8938bb..0a899963b 100644 --- a/dev/src/v1/firestore_client_config.json +++ b/dev/src/v1/firestore_client_config.json @@ -78,7 +78,8 @@ "retry_params_name": "default" }, "PartitionQuery": { - "retry_codes_name": "non_idempotent", + "timeout_millis": 60000, + "retry_codes_name": "unavailable", "retry_params_name": "default" }, "Write": { diff --git a/synth.metadata b/synth.metadata index 0b178321f..f37e40c11 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "6db0bbeb6e959dc4a401f7be17ce2fb79e164a5e", - "internalRef": "327771486" + "sha": "610bf8f0262846bd1bc045a2913631c00e5e0199", + "internalRef": "335655077" } }, { From fdf5462917e322cc04bf47ebc337d5a76a4a8b18 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Mon, 19 Oct 2020 13:47:32 -0700 Subject: [PATCH 195/337] fix: retry PartitionQuery for INTERNAL and DEADLINE_EXCEEDED (#1336) PiperOrigin-RevId: 337565369 Source-Author: Google APIs Source-Date: Fri Oct 16 13:17:26 2020 -0700 Source-Repo: googleapis/googleapis Source-Sha: 4f3ef93916730f1639179ad623c65279ff5799e7 Source-Link: https://github.com/googleapis/googleapis/commit/4f3ef93916730f1639179ad623c65279ff5799e7 --- dev/src/v1/firestore_client_config.json | 4 ++-- synth.metadata | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dev/src/v1/firestore_client_config.json b/dev/src/v1/firestore_client_config.json index 0a899963b..9a0b3025b 100644 --- a/dev/src/v1/firestore_client_config.json +++ b/dev/src/v1/firestore_client_config.json @@ -78,8 +78,8 @@ "retry_params_name": "default" }, "PartitionQuery": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", + "timeout_millis": 300000, + "retry_codes_name": "deadline_exceeded_internal_unavailable", "retry_params_name": "default" }, "Write": { diff --git a/synth.metadata b/synth.metadata index f37e40c11..a92dc453d 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "ca2433ff2910b50c5c7b8268ae43469331309e83" + "sha": "39a30c24a54078e53ad9c746ee8ae5a4a9471349" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "610bf8f0262846bd1bc045a2913631c00e5e0199", - "internalRef": "335655077" + "sha": "4f3ef93916730f1639179ad623c65279ff5799e7", + "internalRef": "337565369" } }, { From e9afa38592b3cc324a8d4685244ee4b249eeedfc Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 20 Oct 2020 10:42:22 -0700 Subject: [PATCH 196/337] feat: add implicit ordering for startAt(DocumentReference) calls (#1328) --- dev/src/reference.ts | 32 +++++++++++++------------------- dev/system-test/firestore.ts | 9 +++++++-- dev/test/query.ts | 26 ++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 01bbee7ee..0b7a69a7e 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -1115,23 +1115,6 @@ export class Query implements firestore.Query { .ignoreUndefinedProperties; } - /** - * Detects the argument type for Firestore cursors. - * - * @private - * @param fieldValuesOrDocumentSnapshot A snapshot of the document or a set - * of field values. - * @returns 'true' if the input is a single DocumentSnapshot.. - */ - static _isDocumentSnapshot( - fieldValuesOrDocumentSnapshot: Array | unknown> - ): boolean { - return ( - fieldValuesOrDocumentSnapshot.length === 1 && - fieldValuesOrDocumentSnapshot[0] instanceof DocumentSnapshot - ); - } - /** * Extracts field values from the DocumentSnapshot based on the provided * field order. @@ -1471,7 +1454,15 @@ export class Query implements firestore.Query { private createImplicitOrderBy( cursorValuesOrDocumentSnapshot: Array | unknown> ): FieldOrder[] { - if (!Query._isDocumentSnapshot(cursorValuesOrDocumentSnapshot)) { + // Add an implicit orderBy if the only cursor value is a DocumentSnapshot + // or a DocumentReference. + if ( + cursorValuesOrDocumentSnapshot.length !== 1 || + !( + cursorValuesOrDocumentSnapshot[0] instanceof DocumentSnapshot || + cursorValuesOrDocumentSnapshot[0] instanceof DocumentReference + ) + ) { return this._queryOptions.fieldOrders; } @@ -1527,7 +1518,10 @@ export class Query implements firestore.Query { ): QueryCursor { let fieldValues; - if (Query._isDocumentSnapshot(cursorValuesOrDocumentSnapshot)) { + if ( + cursorValuesOrDocumentSnapshot.length === 1 && + cursorValuesOrDocumentSnapshot[0] instanceof DocumentSnapshot + ) { fieldValues = Query._extractFieldValues( cursorValuesOrDocumentSnapshot[0] as DocumentSnapshot, fieldOrders diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 7178a7f37..35c1642c9 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -271,8 +271,7 @@ describe('CollectionGroup class', () => { const documents: QueryDocumentSnapshot[] = []; for (const partition of partitions) { - // TODO(mrschmidt); Remove the need to add an `orderBy` here - let partitionedQuery = collectionGroup.orderBy(FieldPath.documentId()); + let partitionedQuery: Query = collectionGroup; if (partition.startAt) { partitionedQuery = partitionedQuery.startAt(...partition.startAt); } @@ -1623,6 +1622,12 @@ describe('Query class', () => { expectDocs(res, {foo: 'b'}); }); + it('startAt() adds implicit order by for DocumentReference', async () => { + const references = await addDocs({foo: 'a'}, {foo: 'b'}); + const res = await randomCol.startAt(references[1]).get(); + expectDocs(res, {foo: 'b'}); + }); + it('has startAfter() method', async () => { await addDocs({foo: 'a'}, {foo: 'b'}); const res = await randomCol.orderBy('foo').startAfter('a').get(); diff --git a/dev/test/query.ts b/dev/test/query.ts index 23222e1e0..111189a7f 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -1852,6 +1852,32 @@ describe('startAt() interface', () => { }); }); + it('appends orderBy for DocumentReference cursors', () => { + const overrides: ApiOverride = { + runQuery: request => { + queryEquals( + request, + orderBy('__name__', 'ASCENDING'), + startAt(true, { + referenceValue: + `projects/${PROJECT_ID}/databases/(default)/` + + 'documents/collectionId/doc', + }) + ); + + return stream(); + }, + }; + + return createInstance(overrides).then(firestore => { + return snapshot('collectionId/doc', {foo: 'bar'}).then(doc => { + let query: Query = firestore.collection('collectionId'); + query = query.startAt(doc.ref); + return query.get(); + }); + }); + }); + it('can extract implicit direction for document snapshot', () => { const overrides: ApiOverride = { runQuery: request => { From 721fce02440fde39e8a5c2d379b2254079e15201 Mon Sep 17 00:00:00 2001 From: "|\\|370" Date: Tue, 20 Oct 2020 15:18:43 -0300 Subject: [PATCH 197/337] fix: Update getAll example in documentation (#1326) --- dev/src/reference.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 0b7a69a7e..7ea377f85 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -2407,7 +2407,7 @@ export class CollectionReference * let collectionRef = firestore.collection('col'); * * return collectionRef.listDocuments().then(documentRefs => { - * return firestore.getAll(documentRefs); + * return firestore.getAll(...documentRefs); * }).then(documentSnapshots => { * for (let documentSnapshot of documentSnapshots) { * if (documentSnapshot.exists) { From 6b7371b4511a7cf039f85519a9d4b8be1bff8930 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 21 Oct 2020 17:31:50 -0500 Subject: [PATCH 198/337] fix: update required field to implement NodeJS.Timeout (#1338) --- dev/src/backoff.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dev/src/backoff.ts b/dev/src/backoff.ts index 74365ae65..defba9621 100644 --- a/dev/src/backoff.ts +++ b/dev/src/backoff.ts @@ -89,6 +89,9 @@ export function setTimeoutHandler( unref: () => { throw new Error('For tests only. Not Implemented'); }, + [Symbol.toPrimitive]: () => { + throw new Error('For tests only. Not Implemented'); + }, }; return timeout; }; From 860b003c6ec6f9b50307cdcd5bcc329607adcdff Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 22 Oct 2020 09:59:17 -0700 Subject: [PATCH 199/337] docs: update to comments in protos (#1340) * docs: update to comments in protos * build: only check --engine-strict for production deps Co-authored-by: Justin Beckwith Source-Author: Benjamin E. Coe Source-Date: Thu Oct 15 17:40:52 2020 -0700 Source-Repo: googleapis/synthtool Source-Sha: 5451633881133e5573cc271a18e73b18caca8b1b Source-Link: https://github.com/googleapis/synthtool/commit/5451633881133e5573cc271a18e73b18caca8b1b --- dev/protos/google/type/latlng.proto | 4 ++-- synth.metadata | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/protos/google/type/latlng.proto b/dev/protos/google/type/latlng.proto index e5d45f1eb..a90b7c23d 100644 --- a/dev/protos/google/type/latlng.proto +++ b/dev/protos/google/type/latlng.proto @@ -23,8 +23,8 @@ option java_outer_classname = "LatLngProto"; option java_package = "com.google.type"; option objc_class_prefix = "GTP"; -// An object representing a latitude/longitude pair. This is expressed as a pair -// of doubles representing degrees latitude and degrees longitude. Unless +// An object that represents a latitude/longitude pair. This is expressed as a +// pair of doubles to represent degrees latitude and degrees longitude. Unless // specified otherwise, this must conform to the // WGS84 // standard. Values must be within normalized ranges. diff --git a/synth.metadata b/synth.metadata index a92dc453d..655b7b99c 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "39a30c24a54078e53ad9c746ee8ae5a4a9471349" + "sha": "6b7371b4511a7cf039f85519a9d4b8be1bff8930" } }, { From 6139b5f83feed3957ea769ccf2f639d5b9d73d36 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 22 Oct 2020 15:38:03 -0700 Subject: [PATCH 200/337] docs: update comments in latlng.proto (#1339) --- synth.metadata | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/synth.metadata b/synth.metadata index 655b7b99c..276c09534 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,7 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "4f3ef93916730f1639179ad623c65279ff5799e7", - "internalRef": "337565369" + "sha": "34c5a5c5132a2c5ef46f599550a1195e07f01f80" } }, { From 498301dc06bdd5a1eccaadd7ffb1b470749488f7 Mon Sep 17 00:00:00 2001 From: Sebastian Kreft Date: Mon, 26 Oct 2020 20:44:08 -0300 Subject: [PATCH 201/337] fix: speed up listDocuments pagination (#1344) --- dev/src/reference.ts | 7 ++++--- dev/test/collection.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 7ea377f85..6adb08251 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -2429,9 +2429,10 @@ export class CollectionReference parent: parentPath.formattedName, collectionId: this.id, showMissing: true, - // Setting `pageSize` to the maximum allowed value lets the backend cap - // the page size (currently to 300). - pageSize: Math.pow(2, 32) - 1, + // Setting `pageSize` to an arbitrarily large value lets the backend cap + // the page size (currently to 300). Note that the backend rejects + // MAX_INT32 (b/146883794). + pageSize: Math.pow(2, 16) - 1, mask: {fieldPaths: []}, }; diff --git a/dev/test/collection.ts b/dev/test/collection.ts index 1a94899f7..d25e11e90 100644 --- a/dev/test/collection.ts +++ b/dev/test/collection.ts @@ -155,7 +155,7 @@ describe('Collection interface', () => { parent: `${DATABASE_ROOT}/documents/a/b`, collectionId: 'c', showMissing: true, - pageSize: 4294967295, + pageSize: 65535, mask: {fieldPaths: []}, }); From fd832e67f96be0c7a81bc3a98a1f3b3e006c1dd0 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 26 Oct 2020 16:56:24 -0700 Subject: [PATCH 202/337] chore: release 4.5.0 (#1327) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 18 ++++++++++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fccf847e..0be392ef7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,24 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [4.5.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.4.0...v4.5.0) (2020-10-26) + + +### Features + +* add implicit ordering for startAt(DocumentReference) calls ([#1328](https://www.github.com/googleapis/nodejs-firestore/issues/1328)) ([e9afa38](https://www.github.com/googleapis/nodejs-firestore/commit/e9afa38592b3cc324a8d4685244ee4b249eeedfc)) +* add support for Partition API ([#1320](https://www.github.com/googleapis/nodejs-firestore/issues/1320)) ([51961c3](https://www.github.com/googleapis/nodejs-firestore/commit/51961c3b39ff9c532214eb783458f83da98eb485)) + + +### Bug Fixes + +* retry PartitionQuery for INTERNAL and DEADLINE_EXCEEDED ([#1336](https://www.github.com/googleapis/nodejs-firestore/issues/1336)) ([fdf5462](https://www.github.com/googleapis/nodejs-firestore/commit/fdf5462917e322cc04bf47ebc337d5a76a4a8b18)) +* simplify BulkWriter logic ([#1321](https://www.github.com/googleapis/nodejs-firestore/issues/1321)) ([b493baf](https://www.github.com/googleapis/nodejs-firestore/commit/b493baf44e729fa584b29881ef83f7821967a97b)) +* speed up listDocuments pagination ([#1344](https://www.github.com/googleapis/nodejs-firestore/issues/1344)) ([498301d](https://www.github.com/googleapis/nodejs-firestore/commit/498301dc06bdd5a1eccaadd7ffb1b470749488f7)) +* Update getAll example in documentation ([#1326](https://www.github.com/googleapis/nodejs-firestore/issues/1326)) ([721fce0](https://www.github.com/googleapis/nodejs-firestore/commit/721fce02440fde39e8a5c2d379b2254079e15201)) +* update required field to implement NodeJS.Timeout ([#1338](https://www.github.com/googleapis/nodejs-firestore/issues/1338)) ([6b7371b](https://www.github.com/googleapis/nodejs-firestore/commit/6b7371b4511a7cf039f85519a9d4b8be1bff8930)) +* **firestore/v1:** give PartitionQuery retry/timeout config ([#1334](https://www.github.com/googleapis/nodejs-firestore/issues/1334)) ([39a30c2](https://www.github.com/googleapis/nodejs-firestore/commit/39a30c24a54078e53ad9c746ee8ae5a4a9471349)) + ## [4.4.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.3.0...v4.4.0) (2020-09-29) diff --git a/package.json b/package.json index 6b0a51517..9e53c61da 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.4.0", + "version": "4.5.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 54f4f2d51..6231433e2 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.4.0" + "@google-cloud/firestore": "^4.5.0" }, "devDependencies": { "chai": "^4.2.0", From 8717bf25161cd56e6dfd3fae6a7c86b7b00a58c1 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 27 Oct 2020 08:38:08 -0700 Subject: [PATCH 203/337] docs: updated code of conduct (includes update to actions) (#1346) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/6be78fc1-147d-40e3-a003-ed65fa912e63/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: https://github.com/googleapis/synthtool/commit/89c849ba5013e45e8fb688b138f33c2ec6083dc5 Source-Link: https://github.com/googleapis/synthtool/commit/a783321fd55f010709294455584a553f4b24b944 Source-Link: https://github.com/googleapis/synthtool/commit/b7413d38b763827c72c0360f0a3d286c84656eeb Source-Link: https://github.com/googleapis/synthtool/commit/5f6ef0ec5501d33c4667885b37a7685a30d41a76 --- .github/workflows/ci.yaml | 12 ++-- CODE_OF_CONDUCT.md | 123 +++++++++++++++++++++++++++----------- synth.metadata | 4 +- 3 files changed, 96 insertions(+), 43 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 06067a8c7..891c92531 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [10, 12, 13] + node: [10, 12, 14, 15] steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 @@ -19,7 +19,9 @@ jobs: # The first installation step ensures that all of our production # dependencies work on the given Node.js version, this helps us find # dependencies that don't match our engines field: - - run: npm install --production --engine-strict + - run: npm install --production --engine-strict --ignore-scripts --no-package-lock + # Clean up the production install, before installing dev/production: + - run: rm -rf node_modules - run: npm install - run: npm test - name: coverage @@ -33,7 +35,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 12 + node-version: 14 - run: npm install - run: npm test - name: coverage @@ -47,7 +49,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 12 + node-version: 14 - run: npm install - run: npm run lint docs: @@ -56,6 +58,6 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 12 + node-version: 14 - run: npm install - run: npm run docs-test diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 46b2a08ea..2add2547a 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,43 +1,94 @@ -# Contributor Code of Conduct + +# Code of Conduct -As contributors and maintainers of this project, -and in the interest of fostering an open and welcoming community, -we pledge to respect all people who contribute through reporting issues, -posting feature requests, updating documentation, -submitting pull requests or patches, and other activities. +## Our Pledge -We are committed to making participation in this project -a harassment-free experience for everyone, -regardless of level of experience, gender, gender identity and expression, -sexual orientation, disability, personal appearance, -body size, race, ethnicity, age, religion, or nationality. +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of +experience, education, socio-economic status, nationality, personal appearance, +race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery -* Personal attacks -* Trolling or insulting/derogatory comments -* Public or private harassment -* Publishing other's private information, -such as physical or electronic -addresses, without explicit permission -* Other unethical or unprofessional conduct. +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct. -By adopting this Code of Conduct, -project maintainers commit themselves to fairly and consistently -applying these principles to every aspect of managing this project. -Project maintainers who do not follow or enforce the Code of Conduct -may be permanently removed from the project team. - -This code of conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. - -Instances of abusive, harassing, or otherwise unacceptable behavior -may be reported by opening an issue -or contacting one or more of the project maintainers. - -This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, -available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +This Code of Conduct also applies outside the project spaces when the Project +Steward has a reasonable belief that an individual's behavior may have a +negative impact on the project or its community. + +## Conflict Resolution + +We do not believe that all conflict is bad; healthy debate and disagreement +often yield positive results. However, it is never okay to be disrespectful or +to engage in behavior that violates the project’s code of conduct. + +If you see someone violating the code of conduct, you are encouraged to address +the behavior directly with those involved. Many issues can be resolved quickly +and easily, and this gives people more control over the outcome of their +dispute. If you are unable to resolve the matter for any reason, or if the +behavior is threatening or harassing, report it. We are dedicated to providing +an environment where participants feel welcome and safe. + +Reports should be directed to *googleapis-stewards@google.com*, the +Project Steward(s) for *Google Cloud Client Libraries*. It is the Project Steward’s duty to +receive and address reported violations of the code of conduct. They will then +work with a committee consisting of representatives from the Open Source +Programs Office and the Google Open Source Strategy team. If for any reason you +are uncomfortable reaching out to the Project Steward, please email +opensource@google.com. + +We will investigate every complaint, but you may not receive a direct response. +We will use our discretion in determining when and how to follow up on reported +incidents, which may range from not taking action to permanent expulsion from +the project and project-sponsored spaces. We will notify the accused of the +report and provide them an opportunity to discuss it before any action is taken. +The identity of the reporter will be omitted from the details of the report +supplied to the accused. In potentially harmful situations, such as ongoing +harassment or threats to anyone's safety, we may take action without notice. + +## Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, +available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html \ No newline at end of file diff --git a/synth.metadata b/synth.metadata index 276c09534..d86160c58 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "6b7371b4511a7cf039f85519a9d4b8be1bff8930" + "sha": "fd832e67f96be0c7a81bc3a98a1f3b3e006c1dd0" } }, { @@ -18,7 +18,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "5451633881133e5573cc271a18e73b18caca8b1b" + "sha": "89c849ba5013e45e8fb688b138f33c2ec6083dc5" } } ], From a18ab50f3304f1154caaaab9768b736bdb3d8442 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 2 Nov 2020 09:49:49 -0800 Subject: [PATCH 204/337] fix: retry transactions that fail with expired transaction IDs (#1347) --- dev/src/transaction.ts | 40 +++++++++++++----------- dev/test/transaction.ts | 67 +++++++++++++++++++++++++++++++++-------- 2 files changed, 77 insertions(+), 30 deletions(-) diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index c6721d8bb..3ad7a56eb 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -423,21 +423,22 @@ export class Transaction implements firestore.Transaction { let lastError: GoogleError | undefined = undefined; for (let attempt = 0; attempt < maxAttempts; ++attempt) { - if (lastError) { - logger( - 'Firestore.runTransaction', - this._requestTag, - 'Retrying transaction after error:', - lastError - ); - } + try { + if (lastError) { + logger( + 'Firestore.runTransaction', + this._requestTag, + 'Retrying transaction after error:', + lastError + ); + await this.rollback(); + } - this._writeBatch._reset(); - await this.maybeBackoff(lastError); + this._writeBatch._reset(); + await this.maybeBackoff(lastError); - await this.begin(); + await this.begin(); - try { const promise = updateFunction(this); if (!(promise instanceof Promise)) { throw new Error( @@ -455,12 +456,10 @@ export class Transaction implements firestore.Transaction { err ); - await this.rollback(); + lastError = err; - if (isRetryableTransactionError(err)) { - lastError = err; - } else { - return Promise.reject(err); // Callback failed w/ non-retryable error + if (!this._transactionId || !isRetryableTransactionError(err)) { + break; } } } @@ -471,6 +470,8 @@ export class Transaction implements firestore.Transaction { 'Transaction not eligible for retry, returning error: %s', lastError ); + + await this.rollback(); return Promise.reject(lastError); } @@ -599,6 +600,11 @@ function isRetryableTransactionError(error: GoogleError): boolean { case Status.UNAUTHENTICATED: case Status.RESOURCE_EXHAUSTED: return true; + case Status.INVALID_ARGUMENT: + // The Firestore backend uses "INVALID_ARGUMENT" for transactions + // IDs that have expired. While INVALID_ARGUMENT is generally not + // retryable, we retry this specific case. + return !!error.message.match(/transaction has expired/); default: return false; } diff --git a/dev/test/transaction.ts b/dev/test/transaction.ts index 0177b99f2..5434c86ff 100644 --- a/dev/test/transaction.ts +++ b/dev/test/transaction.ts @@ -355,7 +355,10 @@ function runTransaction( }); } finally { setTimeoutHandler(setTimeout); - expect(expectedRequests.length).to.equal(0); + expect(expectedRequests.length).to.equal( + 0, + 'Missing requests: ' + expectedRequests.map(r => r.type).join(', ') + ); } }); } @@ -433,6 +436,25 @@ describe('failed transactions', () => { } }); + it('retries commit for expired transaction', async () => { + const transactionFunction = () => Promise.resolve(); + + const serverError = new GoogleError( + 'The referenced transaction has expired or is no longer valid.' + ); + serverError.code = Status.INVALID_ARGUMENT; + + await runTransaction( + transactionFunction, + begin('foo1'), + commit('foo1', undefined, serverError), + rollback('foo1'), + backoff(), + begin('foo2', 'foo1'), + commit('foo2') + ); + }); + it('retries runQuery based on error code', async () => { const transactionFunction = ( transaction: Transaction, @@ -506,6 +528,37 @@ describe('failed transactions', () => { } }); + it('retries rollback based on error code', async () => { + const transactionFunction = () => Promise.resolve(); + + for (const [errorCode, retry] of Object.entries(retryBehavior)) { + const serverError = new GoogleError('Test Error'); + serverError.code = Number(errorCode) as Status; + + if (retry) { + await runTransaction( + transactionFunction, + begin('foo1'), + commit('foo1', /* writes=*/ undefined, serverError), + rollback('foo1', serverError), + rollback('foo1'), + backoff(), + begin('foo2', 'foo1'), + commit('foo2') + ); + } else { + await expect( + runTransaction( + transactionFunction, + begin('foo1'), + commit('foo1', /* writes=*/ undefined, serverError), + rollback('foo1', serverError) + ) + ).to.eventually.be.rejected; + } + } + }); + it('requires update function', () => { const overrides: ApiOverride = { beginTransaction: () => Promise.reject(), @@ -618,18 +671,6 @@ describe('failed transactions', () => { commit('foo2') ); }); - - it('fails on rollback', () => { - return expect( - runTransaction( - () => { - return Promise.reject(); - }, - begin(), - rollback('foo', new Error('Fails on rollback')) - ) - ).to.eventually.be.rejectedWith('Fails on rollback'); - }); }); describe('transaction operations', () => { From a173f4defab7a6e750907fcb86431c56fcb3d4cf Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 3 Nov 2020 11:23:12 -0600 Subject: [PATCH 205/337] feat: add onWriteError() and onWriteResult() handlers to BulkWriter (#1315) --- dev/src/bulk-writer.ts | 530 +++++++++++++++++++++++------------ dev/src/util.ts | 14 + dev/src/write-batch.ts | 27 +- dev/system-test/firestore.ts | 19 ++ dev/test/bulk-writer.ts | 287 ++++++++++++++++++- types/firestore.d.ts | 76 ++++- 6 files changed, 729 insertions(+), 224 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 6a16cfcca..5600819b1 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -27,14 +27,23 @@ import { import {RateLimiter} from './rate-limiter'; import {DocumentReference} from './reference'; import {Timestamp} from './timestamp'; -import {Deferred, getRetryCodes, isObject, wrapError} from './util'; +import { + Deferred, + getRetryCodes, + isObject, + silencePromise, + wrapError, +} from './util'; import {BatchWriteResult, WriteBatch, WriteResult} from './write-batch'; -import {logger} from './logger'; import { invalidArgumentMessage, validateInteger, validateOptional, } from './validate'; +import {logger} from './logger'; + +// eslint-disable-next-line no-undef +import GrpcStatus = FirebaseFirestore.GrpcStatus; /*! * The maximum number of writes that can be in a single batch. @@ -76,18 +85,6 @@ enum BatchState { SENT, } -/*! - * Used to represent a pending write operation. - * - * Contains a pending write's WriteBatch index, document path, and the - * corresponding result. - */ -interface PendingOp { - writeBatchIndex: number; - key: string; - deferred: Deferred; -} - /** * Used to represent a batch on the BatchQueue. * @@ -99,13 +96,9 @@ class BulkCommitBatch { */ state = BatchState.OPEN; - // A deferred promise that is resolved after the batch has been sent, and a - // response is received. - private completedDeferred = new Deferred(); - // An array of pending write operations. Only contains writes that have not // been resolved. - private pendingOps: Array = []; + private pendingOps: Array> = []; private readonly backoff: ExponentialBackoff; @@ -133,7 +126,7 @@ class BulkCommitBatch { data: T ): Promise { this.writeBatch.create(documentRef, data); - return this.processOperation(documentRef); + return this.processLastOperation(); } /** @@ -145,7 +138,7 @@ class BulkCommitBatch { precondition?: firestore.Precondition ): Promise { this.writeBatch.delete(documentRef, precondition); - return this.processOperation(documentRef); + return this.processLastOperation(); } set( @@ -172,7 +165,7 @@ class BulkCommitBatch { options?: firestore.SetOptions ): Promise { this.writeBatch.set(documentRef, data, options); - return this.processOperation(documentRef); + return this.processLastOperation(); } /** @@ -187,26 +180,20 @@ class BulkCommitBatch { > ): Promise { this.writeBatch.update(documentRef, dataOrField, ...preconditionOrValues); - return this.processOperation(documentRef); + return this.processLastOperation(); } /** * Helper to update data structures associated with the operation and * return the result. */ - private processOperation( - documentRef: firestore.DocumentReference - ): Promise { + private processLastOperation(): Promise { assert( this.state === BatchState.OPEN, 'Batch should be OPEN when adding writes' ); const deferred = new Deferred(); - this.pendingOps.push({ - writeBatchIndex: this.opCount, - key: documentRef.path, - deferred: deferred, - }); + this.pendingOps.push(deferred); if (this.opCount === this.maxBatchSize) { this.state = BatchState.READY_TO_SEND; @@ -239,84 +226,35 @@ class BulkCommitBatch { const stack = Error().stack!; let results: BatchWriteResult[] = []; - for (let attempt = 0; attempt < MAX_RETRY_ATTEMPTS; attempt++) { - await this.backoff.backoffAndWait(); - - try { - results = await this.writeBatch.bulkCommit(); - } catch (err) { - // Map the failure to each individual write's result. - results = this.pendingOps.map(op => { - return {key: op.key, writeTime: null, status: wrapError(err, stack)}; - }); - } - this.processResults(results, /* allowRetry= */ true); - - if (this.pendingOps.length > 0) { - logger( - 'BulkWriter.bulkCommit', - null, - `Current batch failed at retry #${attempt}. Num failures: ` + - `${this.pendingOps.length}.` - ); - - this.writeBatch = new WriteBatch( - this.firestore, - this.writeBatch, - new Set(this.pendingOps.map(op => op.writeBatchIndex)) - ); - } else { - this.completedDeferred.resolve(); - return; - } + try { + results = await this.writeBatch.bulkCommit(); + } catch (err) { + // Map the failure to each individual write's result. + results = this.pendingOps.map(() => { + return { + writeTime: null, + status: wrapError(err, stack), + }; + }); } - - this.processResults(results); - this.completedDeferred.resolve(); + return this.processResults(results); } /** * Resolves the individual operations in the batch with the results. */ - private processResults( - results: BatchWriteResult[], - allowRetry = false - ): void { - const newPendingOps: Array = []; - for (let i = 0; i < results.length; i++) { - const result = results[i]; - const op = this.pendingOps[i]; - if (result.status.code === Status.OK) { - op.deferred.resolve(result); - } else if (!allowRetry || !this.shouldRetry(result.status.code)) { - op.deferred.reject(result.status); - } else { - // Retry the operation if it has not been processed. - // Store the current index of pendingOps to preserve the mapping of - // this operation's index in the underlying WriteBatch. - newPendingOps.push({ - writeBatchIndex: i, - key: op.key, - deferred: op.deferred, - }); - } - } - - this.pendingOps = newPendingOps; - } - - private shouldRetry(code: Status | undefined): boolean { - const retryCodes = getRetryCodes('batchWrite'); - return code !== undefined && retryCodes.includes(code); - } - - /** - * Returns a promise that resolves when the batch has been sent, and a - * response is received. - */ - awaitBulkCommit(): Promise { - this.markReadyToSend(); - return this.completedDeferred.promise; + private async processResults(results: BatchWriteResult[]): Promise { + await Promise.all( + results.map((result, i) => { + const op = this.pendingOps[i]; + if (result.status.code === Status.OK) { + op.resolve(result); + } else { + op.reject(result.status); + } + return silencePromise(op.promise); + }) + ); } markReadyToSend(): void { @@ -326,6 +264,33 @@ class BulkCommitBatch { } } +/** + * The error thrown when a BulkWriter operation fails. + * + * @class BulkWriterError + */ +export class BulkWriterError extends Error { + /** @hideconstructor */ + constructor( + /** The status code of the error. */ + readonly code: GrpcStatus, + + /** The error message of the error. */ + readonly message: string, + + /** The document reference the operation was performed on. */ + readonly documentRef: firestore.DocumentReference, + + /** The type of operation performed. */ + readonly operationType: 'create' | 'set' | 'update' | 'delete', + + /** How many times this operation has been attempted unsuccessfully. */ + readonly failedAttempts: number + ) { + super(message); + } +} + /** * A Firestore BulkWriter than can be used to perform a large number of writes * in parallel. Writes to the same document will be executed sequentially. @@ -336,24 +301,68 @@ export class BulkWriter { /** * The maximum number of writes that can be in a single batch. */ - private maxBatchSize = MAX_BATCH_SIZE; + private _maxBatchSize = MAX_BATCH_SIZE; /** * A queue of batches to be written. */ - private batchQueue: BulkCommitBatch[] = []; + private _batchQueue: BulkCommitBatch[] = []; /** - * Whether this BulkWriter instance is closed. Once closed, it cannot be - * opened again. + * A queue of batches containing operations that need to be retried. */ - private closed = false; + private _retryBatchQueue: BulkCommitBatch[] = []; + + /** + * A list of promises that represent sent batches. Each promise is resolved + * when the batch's response is received. This includes batches from both the + * batchQueue and retryBatchQueue. + */ + private _pendingBatches: Set> = new Set(); + + /** + * A list of promises that represent pending BulkWriter operations. Each + * promise is resolved when the BulkWriter operation resolves. This set + * includes retries. Each retry's promise is added, attempted, and removed + * from this set before scheduling the next retry. + */ + private _pendingOps: Set> = new Set(); + + /** + * Whether this BulkWriter instance has started to close. Afterwards, no + * new operations can be enqueued, except for retry operations scheduled by + * the error handler. + */ + private _closing = false; /** * Rate limiter used to throttle requests as per the 500/50/5 rule. */ - private rateLimiter: RateLimiter; + private readonly _rateLimiter: RateLimiter; + + /** + * The user-provided callback to be run every time a BulkWriter operation + * successfully completes. + */ + private _successFn: ( + document: firestore.DocumentReference, + result: WriteResult + ) => void = () => {}; + + /** + * The user-provided callback to be run every time a BulkWriter operation + * fails. + */ + private _errorFn: (error: BulkWriterError) => boolean = error => { + const retryCodes = getRetryCodes('batchWrite'); + return ( + error.code !== undefined && + retryCodes.includes(error.code) && + error.failedAttempts < MAX_RETRY_ATTEMPTS + ); + }; + /** @hideconstructor */ constructor( private readonly firestore: Firestore, options?: firestore.BulkWriterOptions @@ -362,7 +371,7 @@ export class BulkWriter { validateBulkWriterOptions(options); if (options?.throttling === false) { - this.rateLimiter = new RateLimiter( + this._rateLimiter = new RateLimiter( Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, @@ -391,12 +400,12 @@ export class BulkWriter { // Ensure that the batch size is not larger than the number of allowed // operations per second. - if (startingRate < this.maxBatchSize) { - this.maxBatchSize = startingRate; + if (startingRate < this._maxBatchSize) { + this._maxBatchSize = startingRate; } } - this.rateLimiter = new RateLimiter( + this._rateLimiter = new RateLimiter( startingRate, RATE_LIMITER_MULTIPLIER, RATE_LIMITER_MULTIPLIER_MILLIS, @@ -413,7 +422,8 @@ export class BulkWriter { * created. * @param {T} data The object to serialize as the document. * @returns {Promise} A promise that resolves with the result of - * the write. Throws an error if the write fails. + * the write. If the write fails, the promise is rejected with a + * [BulkWriterError]{@link BulkWriterError}. * * @example * let bulkWriter = firestore.bulkWriter(); @@ -434,10 +444,11 @@ export class BulkWriter { data: T ): Promise { this.verifyNotClosed(); - const bulkCommitBatch = this.getEligibleBatch(); - const resultPromise = bulkCommitBatch.create(documentRef, data); - this.sendReadyBatches(); - return resultPromise; + const op = this._executeWrite(documentRef, 'create', bulkCommitBatch => + bulkCommitBatch.create(documentRef, data) + ); + silencePromise(op); + return op; } /** @@ -450,9 +461,9 @@ export class BulkWriter { * @param {Timestamp=} precondition.lastUpdateTime If set, enforces that the * document was last updated at lastUpdateTime. Fails the batch if the * document doesn't exist or was last updated at a different time. - * @returns {Promise} A promise that resolves with a sentinel - * Timestamp indicating that the delete was successful. Throws an error if - * the write fails. + * @returns {Promise} A promise that resolves with the result of + * the delete. If the delete fails, the promise is rejected with a + * [BulkWriterError]{@link BulkWriterError}. * * @example * let bulkWriter = firestore.bulkWriter(); @@ -473,10 +484,11 @@ export class BulkWriter { precondition?: firestore.Precondition ): Promise { this.verifyNotClosed(); - const bulkCommitBatch = this.getEligibleBatch(); - const resultPromise = bulkCommitBatch.delete(documentRef, precondition); - this.sendReadyBatches(); - return resultPromise; + const op = this._executeWrite(documentRef, 'delete', bulkCommitBatch => + bulkCommitBatch.delete(documentRef, precondition) + ); + silencePromise(op); + return op; } set( @@ -505,7 +517,8 @@ export class BulkWriter { * only replaces the specified field paths. Any field path that is not * specified is ignored and remains untouched. * @returns {Promise} A promise that resolves with the result of - * the write. Throws an error if the write fails. + * the write. If the write fails, the promise is rejected with a + * [BulkWriterError]{@link BulkWriterError}. * * * @example @@ -528,10 +541,11 @@ export class BulkWriter { options?: firestore.SetOptions ): Promise { this.verifyNotClosed(); - const bulkCommitBatch = this.getEligibleBatch(); - const resultPromise = bulkCommitBatch.set(documentRef, data, options); - this.sendReadyBatches(); - return resultPromise; + const op = this._executeWrite(documentRef, 'set', bulkCommitBatch => + bulkCommitBatch.set(documentRef, data, options) + ); + silencePromise(op); + return op; } /** @@ -558,8 +572,8 @@ export class BulkWriter { * alternating list of field paths and values to update or a Precondition to * restrict this update * @returns {Promise} A promise that resolves with the result of - * the write. Throws an error if the write fails. - * + * the write. If the write fails, the promise is rejected with a + * [BulkWriterError]{@link BulkWriterError}. * * @example * let bulkWriter = firestore.bulkWriter(); @@ -583,14 +597,70 @@ export class BulkWriter { > ): Promise { this.verifyNotClosed(); - const bulkCommitBatch = this.getEligibleBatch(); - const resultPromise = bulkCommitBatch.update( - documentRef, - dataOrField, - ...preconditionOrValues + const op = this._executeWrite(documentRef, 'update', bulkCommitBatch => + bulkCommitBatch.update(documentRef, dataOrField, ...preconditionOrValues) ); - this.sendReadyBatches(); - return resultPromise; + silencePromise(op); + return op; + } + + /** + * Attaches a listener that is run every time a BulkWriter operation + * successfully completes. + * + * @param callback A callback to be called every time a BulkWriter operation + * successfully completes. + * @example + * let bulkWriter = firestore.bulkWriter(); + * + * bulkWriter + * .onWriteResult((documentRef, result) => { + * console.log( + * 'Successfully executed write on document: ', + * documentRef, + * ' at: ', + * result + * ); + * }); + */ + onWriteResult( + callback: ( + documentRef: firestore.DocumentReference, + result: WriteResult + ) => void + ): void { + this._successFn = callback; + } + + /** + * Attaches an error handler listener that is run every time a BulkWriter + * operation fails. + * + * BulkWriter has a default error handler that retries UNAVAILABLE and + * ABORTED errors up to a maximum of 10 failed attempts. When an error + * handler is specified, the default error handler will be overwritten. + * + * @param shouldRetryCallback A callback to be called every time a BulkWriter + * operation fails. Returning `true` will retry the operation. Returning + * `false` will stop the retry loop. + * @example + * let bulkWriter = firestore.bulkWriter(); + * + * bulkWriter + * .onWriteError((error) => { + * if ( + * error.code === GrpcStatus.UNAVAILABLE && + * error.failedAttempts < MAX_RETRY_ATTEMPTS + * ) { + * return true; + * } else { + * console.log('Failed write at document: ', error.documentRef); + * return false; + * } + * }); + */ + onWriteError(shouldRetryCallback: (error: BulkWriterError) => boolean): void { + this._errorFn = shouldRetryCallback; } /** @@ -618,18 +688,39 @@ export class BulkWriter { * console.log('Executed all writes'); * }); */ - async flush(): Promise { + flush(): Promise { this.verifyNotClosed(); - const trackedBatches = this.batchQueue; - const writePromises = trackedBatches.map(batch => batch.awaitBulkCommit()); - this.sendReadyBatches(); - await Promise.all(writePromises); + + // Copy the pending ops at the time flush() was called. + return this._flush(Array.from(this._pendingOps)); + } + + private async _flush(pendingOps: Array>): Promise { + let batchQueue = this._batchQueue; + batchQueue.forEach(batch => batch.markReadyToSend()); + + // Send all scheduled operations on the BatchQueue first. + this.sendReadyBatches(batchQueue); + await Promise.all(this._pendingBatches); + + // Afterwards, send all accumulated retry operations. Wait until the + // retryBatchQueue is cleared. This way, operations scheduled after + // flush() will not be sent until the retries are completed. + batchQueue = this._retryBatchQueue; + if (batchQueue.length > 0) { + batchQueue.forEach(batch => batch.markReadyToSend()); + this.sendReadyBatches(batchQueue); + } + // Make sure user promises resolve before flush() resolves. + return silencePromise(Promise.all(pendingOps)); } /** * Commits all enqueued writes and marks the BulkWriter instance as closed. * - * After calling `close()`, calling any method wil throw an error. + * After calling `close()`, calling any method wil throw an error. Any + * retries scheduled as part of an `onWriteError()` handler will be run + * before the `close()` promise resolves. * * Returns a Promise that resolves when there are no more pending writes. The * Promise will never be rejected. Calling this method will send all requests. @@ -652,12 +743,15 @@ export class BulkWriter { this.verifyNotClosed(); this.firestore._decrementBulkWritersCount(); const flushPromise = this.flush(); - this.closed = true; + this._closing = true; return flushPromise; } + /** + * Throws an error if the BulkWriter instance has been closed. + */ private verifyNotClosed(): void { - if (this.closed) { + if (this._closing) { throw new Error('BulkWriter has already been closed.'); } } @@ -668,68 +762,74 @@ export class BulkWriter { * * @private */ - private getEligibleBatch(): BulkCommitBatch { - if (this.batchQueue.length > 0) { - const lastBatch = this.batchQueue[this.batchQueue.length - 1]; + private getEligibleBatch(batchQueue: BulkCommitBatch[]): BulkCommitBatch { + if (batchQueue.length > 0) { + const lastBatch = batchQueue[batchQueue.length - 1]; if (lastBatch.state === BatchState.OPEN) { return lastBatch; } } - return this.createNewBatch(); + + return this.createNewBatch(batchQueue); } /** - * Creates a new batch and adds it to the BatchQueue. If there is already a - * batch enqueued, sends the batch after a new one is created. + * Creates a new batch and adds it to the appropriate batch queue. If there + * is already a batch enqueued, sends the batch after a new one is created. * * @private */ - private createNewBatch(): BulkCommitBatch { + private createNewBatch(batchQueue: BulkCommitBatch[]): BulkCommitBatch { const newBatch = new BulkCommitBatch( this.firestore, this.firestore.batch(), - this.maxBatchSize + this._maxBatchSize ); - if (this.batchQueue.length > 0) { - this.batchQueue[this.batchQueue.length - 1].markReadyToSend(); - this.sendReadyBatches(); + if (batchQueue.length > 0) { + batchQueue[batchQueue.length - 1].markReadyToSend(); + this.sendReadyBatches(batchQueue); } - this.batchQueue.push(newBatch); + + batchQueue.push(newBatch); return newBatch; } /** - * Attempts to send batches starting from the front of the BatchQueue until a - * batch cannot be sent. + * Attempts to send batches starting from the front of the provided batch + * queue until a batch cannot be sent. * * After a batch is complete, try sending batches again. * * @private */ - private sendReadyBatches(): void { - const unsentBatches = this.batchQueue.filter( - batch => batch.state === BatchState.READY_TO_SEND - ); - + private sendReadyBatches(batchQueue: BulkCommitBatch[]): void { let index = 0; while ( - index < unsentBatches.length && - unsentBatches[index].state === BatchState.READY_TO_SEND + index < batchQueue.length && + batchQueue[index].state === BatchState.READY_TO_SEND ) { - const batch = unsentBatches[index]; + const batch = batchQueue[index]; + + // Deferred promise that resolves when the current batch or its + // scheduling attempt completes. + const batchCompletedDeferred = new Deferred(); + this._pendingBatches.add(batchCompletedDeferred.promise); // Send the batch if it is under the rate limit, or schedule another // attempt after the appropriate timeout. - const delayMs = this.rateLimiter.getNextRequestDelayMs(batch.opCount); + const delayMs = this._rateLimiter.getNextRequestDelayMs(batch.opCount); assert(delayMs !== -1, 'Batch size should be under capacity'); if (delayMs === 0) { - this.sendBatch(batch); + this.sendBatch(batch, batchQueue, batchCompletedDeferred); } else { - delayExecution(() => this.sendReadyBatches(), delayMs); + delayExecution(() => { + this.sendReadyBatches(batchQueue); + batchCompletedDeferred.resolve(); + this._pendingBatches.delete(batchCompletedDeferred.promise); + }, delayMs); break; } - index++; } } @@ -738,21 +838,89 @@ export class BulkWriter { * Sends the provided batch and processes the results. After the batch is * committed, sends the next group of ready batches. * + * @param batchCompletedDeferred A deferred promise that resolves when the + * batch has been sent and received. * @private */ - private sendBatch(batch: BulkCommitBatch): void { - const success = this.rateLimiter.tryMakeRequest(batch.opCount); + private sendBatch( + batch: BulkCommitBatch, + batchQueue: BulkCommitBatch[], + batchCompletedDeferred: Deferred + ): Promise { + const success = this._rateLimiter.tryMakeRequest(batch.opCount); assert(success, 'Batch should be under rate limit to be sent.'); - batch.bulkCommit().then(() => { + return batch.bulkCommit().then(() => { // Remove the batch from the BatchQueue after it has been processed. - const batchIndex = this.batchQueue.indexOf(batch); + const batchIndex = batchQueue.indexOf(batch); assert(batchIndex !== -1, 'The batch should be in the BatchQueue'); - this.batchQueue.splice(batchIndex, 1); + batchQueue.splice(batchIndex, 1); - this.sendReadyBatches(); + if (batchQueue === this._retryBatchQueue) { + batchQueue.forEach(batch => batch.markReadyToSend()); + } + + batchCompletedDeferred.resolve(); + this._pendingBatches.delete(batchCompletedDeferred.promise); + + this.sendReadyBatches(batchQueue); }); } + /** + * Schedules and runs the provided operation. + */ + private async _executeWrite( + documentRef: firestore.DocumentReference, + operationType: 'create' | 'set' | 'update' | 'delete', + operationFn: (bulkCommitBatch: BulkCommitBatch) => Promise + ): Promise { + // A deferred promise that resolves when operationFn completes. + const operationCompletedDeferred = new Deferred(); + this._pendingOps.add(operationCompletedDeferred.promise); + try { + for (let failedAttempts = 0; ; ++failedAttempts) { + const batchQueue = + failedAttempts > 0 ? this._retryBatchQueue : this._batchQueue; + const bulkCommitBatch = this.getEligibleBatch(batchQueue); + + // Send ready batches if this is the first attempt. Subsequent retry + // batches are scheduled after the initial batch returns. + if (failedAttempts === 0) { + this.sendReadyBatches(batchQueue); + } + + try { + const operationResult = await operationFn(bulkCommitBatch); + this._successFn(documentRef, operationResult); + return operationResult; + } catch (error) { + const bulkWriterError = new BulkWriterError( + error.code, + error.message, + documentRef, + operationType, + failedAttempts + ); + const shouldRetry = this._errorFn(bulkWriterError); + logger( + 'BulkWriter.errorFn', + null, + 'Running error callback on error code:', + error.code, + ', shouldRetry:', + shouldRetry + ); + if (!shouldRetry) { + throw bulkWriterError; + } + } + } + } finally { + operationCompletedDeferred.resolve(); + this._pendingOps.delete(operationCompletedDeferred.promise); + } + } + /** * Sets the maximum number of allowed operations in a batch. * @@ -760,7 +928,7 @@ export class BulkWriter { */ // Visible for testing. _setMaxBatchSize(size: number): void { - this.maxBatchSize = size; + this._maxBatchSize = size; } /** @@ -770,7 +938,7 @@ export class BulkWriter { */ // Visible for testing. _getRateLimiter(): RateLimiter { - return this.rateLimiter; + return this._rateLimiter; } } diff --git a/dev/src/util.ts b/dev/src/util.ts index 408c50224..49cf24a63 100644 --- a/dev/src/util.ts +++ b/dev/src/util.ts @@ -174,6 +174,20 @@ export function getRetryParams(methodName: string): BackoffSettings { ); } +/** + * Returns a promise with a void return type. The returned promise swallows all + * errors and never throws. + * + * This is primarily used to wait for a promise to complete when the result of + * the promise will be discarded. + */ +export function silencePromise(promise: Promise): Promise { + return promise.then( + () => {}, + () => {} + ); +} + /** * Wraps the provided error in a new error that includes the provided stack. * diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index d6ebcb504..65b6d0d8c 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -114,7 +114,7 @@ export class BatchWriteResult { * serializing the request. * @private */ -type PendingWriteOp = () => api.IWrite; +export type PendingWriteOp = () => api.IWrite; /** * A Firestore WriteBatch that can be used to atomically commit multiple write @@ -140,34 +140,11 @@ export class WriteBatch implements firestore.WriteBatch { /** * @hideconstructor - * - * @param firestore The Firestore Database client. - * @param retryBatch The WriteBatch that needs to be retried. - * @param indexesToRetry The indexes of the operations from the provided - * WriteBatch that need to be retried. */ - constructor( - firestore: Firestore, - retryBatch: WriteBatch, - indexesToRetry: Set - ); - constructor(firestore: Firestore); - constructor( - firestore: Firestore, - retryBatch?: WriteBatch, - indexesToRetry?: Set - ) { + constructor(firestore: Firestore) { this._firestore = firestore; this._serializer = new Serializer(firestore); this._allowUndefined = !!firestore._settings.ignoreUndefinedProperties; - - if (retryBatch) { - // Creates a new WriteBatch containing only the indexes from the provided - // indexes to retry. - for (const index of indexesToRetry!.values()) { - this._ops.push(retryBatch._ops[index]); - } - } } /** diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 35c1642c9..71af48c73 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -45,6 +45,7 @@ import { } from '../test/util/helpers'; import IBundleElement = firestore.IBundleElement; import {BulkWriter} from '../src/bulk-writer'; +import {Status} from 'google-gax'; import {QueryPartition} from '../src/query-partition'; import {CollectionGroup} from '../src/collection-group'; @@ -2612,6 +2613,24 @@ describe('BulkWriter class', () => { await writer.close(); return firestore.terminate(); }); + + it('can retry failed writes with a provided callback', async () => { + let retryCount = 0; + let code: Status = -1; + writer.onWriteError(error => { + retryCount = error.failedAttempts; + return error.failedAttempts < 3; + }); + + // Use an invalid document name that the backend will reject. + const ref = randomCol.doc('__doc__'); + writer.create(ref, {foo: 'bar'}).catch(err => { + code = err.code; + }); + await writer.close(); + expect(retryCount).to.equal(3); + expect(code).to.equal(Status.INVALID_ARGUMENT); + }); }); describe('Client initialization', () => { diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index bf82e529a..ee8b5277a 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -27,6 +27,10 @@ import { WriteResult, } from '../src'; import {setTimeoutHandler} from '../src/backoff'; +import { + BulkWriterError, + DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND, +} from '../src/bulk-writer'; import { ApiOverride, create, @@ -42,7 +46,6 @@ import { } from './util/helpers'; import api = proto.google.firestore.v1; -import {DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND} from '../src/bulk-writer'; // Change the argument to 'console.log' to enable debug output. setLogFunction(null); @@ -372,12 +375,26 @@ describe('BulkWriter', () => { const doc = firestore.doc('collectionId/doc'); bulkWriter.set(doc, {foo: 'bar'}).catch(err => { incrementOpCount(); + expect(err instanceof BulkWriterError).to.be.true; expect(err.code).to.equal(Status.DEADLINE_EXCEEDED); }); return bulkWriter.close().then(async () => verifyOpCount(1)); }); + it('swallows UnhandledPromiseRejections even if the error is not caught', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([setOp('doc', 'bar')]), + response: failedResponse(), + }, + ]); + + const doc = firestore.doc('collectionId/doc'); + bulkWriter.set(doc, {foo: 'bar'}); + return bulkWriter.close(); + }); + it('flush() resolves immediately if there are no writes', async () => { const bulkWriter = await instantiateInstance([]); return bulkWriter.flush().then(() => verifyOpCount(0)); @@ -434,8 +451,7 @@ describe('BulkWriter', () => { expect(() => bulkWriter.set(doc, {})).to.throw(expected); expect(() => bulkWriter.create(doc, {})).to.throw(expected); expect(() => bulkWriter.update(doc, {})).to.throw(expected); - expect(() => bulkWriter.delete(doc)).to.throw(expected); - expect(bulkWriter.flush()).to.eventually.be.rejectedWith(expected); + expect(() => bulkWriter.flush()).to.throw(expected); expect(() => bulkWriter.close()).to.throw(expected); }); @@ -477,6 +493,261 @@ describe('BulkWriter', () => { }); }); + it('runs the success handler', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([ + createOp('doc', 'bar'), + setOp('doc', 'bar'), + updateOp('doc', 'bar'), + deleteOp('doc'), + ]), + response: mergeResponses([ + successResponse(1), + successResponse(2), + successResponse(3), + successResponse(4), + ]), + }, + ]); + const writeResults: number[] = []; + bulkWriter.onWriteResult((documentRef, result) => { + writeResults.push(result.writeTime.seconds); + }); + bulkWriter.create(firestore.doc('collectionId/doc'), {foo: 'bar'}); + bulkWriter.set(firestore.doc('collectionId/doc'), {foo: 'bar'}); + bulkWriter.update(firestore.doc('collectionId/doc'), {foo: 'bar'}); + bulkWriter.delete(firestore.doc('collectionId/doc')); + return bulkWriter.close().then(() => { + expect(writeResults).to.deep.equal([1, 2, 3, 4]); + }); + }); + + it('can retry failed operations with global error callback', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([ + createOp('doc', 'bar'), + setOp('doc', 'bar'), + updateOp('doc', 'bar'), + deleteOp('doc'), + ]), + response: mergeResponses([ + successResponse(1), + failedResponse(Status.INTERNAL), + failedResponse(Status.INTERNAL), + failedResponse(Status.INTERNAL), + ]), + }, + { + request: createRequest([ + setOp('doc', 'bar'), + updateOp('doc', 'bar'), + deleteOp('doc'), + ]), + response: mergeResponses([ + successResponse(2), + successResponse(3), + successResponse(4), + ]), + }, + ]); + const ops: string[] = []; + const writeResults: number[] = []; + bulkWriter.onWriteError(error => { + ops.push(error.operationType); + return true; + }); + bulkWriter.onWriteResult((documentRef, result) => { + ops.push('success'); + writeResults.push(result.writeTime.seconds); + }); + bulkWriter.create(firestore.doc('collectionId/doc'), {foo: 'bar'}); + bulkWriter.set(firestore.doc('collectionId/doc'), {foo: 'bar'}); + bulkWriter.update(firestore.doc('collectionId/doc'), {foo: 'bar'}); + bulkWriter.delete(firestore.doc('collectionId/doc')); + return bulkWriter.close().then(() => { + expect(ops).to.deep.equal([ + 'success', + 'set', + 'update', + 'delete', + 'success', + 'success', + 'success', + ]); + expect(writeResults).to.deep.equal([1, 2, 3, 4]); + }); + }); + + it('errors are still surfaced even if a retry function is specified', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([setOp('doc', 'bar')]), + response: failedResponse(Status.INTERNAL), + }, + ]); + let onWriteErrorCalled = false; + let catchCalled = false; + bulkWriter.onWriteError(() => { + onWriteErrorCalled = true; + return false; + }); + bulkWriter + .set(firestore.doc('collectionId/doc'), {foo: 'bar'}) + .catch(err => { + expect(err.code).to.equal(Status.INTERNAL); + catchCalled = true; + }); + await bulkWriter.flush(); + expect(catchCalled).to.be.true; + expect(onWriteErrorCalled).to.be.true; + }); + + it('surfaces errors thrown by user-provided error callback', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([setOp('doc', 'bar')]), + response: failedResponse(Status.INTERNAL), + }, + ]); + let errorCaught = false; + bulkWriter.onWriteError(() => { + throw new Error('User provided error callback failed'); + }); + bulkWriter + .set(firestore.doc('collectionId/doc'), {foo: 'bar'}) + .catch(err => { + expect(err.message).to.equal('User provided error callback failed'); + errorCaught = true; + }); + await bulkWriter.flush(); + expect(errorCaught).to.be.true; + }); + + it('write fails if user-provided success callback fails', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([setOp('doc', 'bar')]), + response: successResponse(1), + }, + ]); + let errorCaught = false; + bulkWriter.onWriteResult(() => { + throw new Error('User provided success callback failed'); + }); + bulkWriter + .set(firestore.doc('collectionId/doc'), {foo: 'bar'}) + .catch(err => { + expect(err.message).to.equal('User provided success callback failed'); + errorCaught = true; + }); + await bulkWriter.flush(); + expect(errorCaught).to.be.true; + }); + + it('retries multiple times', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([setOp('doc', 'bar')]), + response: failedResponse(Status.INTERNAL), + }, + { + request: createRequest([setOp('doc', 'bar')]), + response: failedResponse(Status.INTERNAL), + }, + { + request: createRequest([setOp('doc', 'bar')]), + response: failedResponse(Status.INTERNAL), + }, + { + request: createRequest([setOp('doc', 'bar')]), + response: successResponse(1), + }, + ]); + let writeResult = 0; + bulkWriter.onWriteError(() => { + return true; + }); + bulkWriter + .set(firestore.doc('collectionId/doc'), {foo: 'bar'}) + .then(res => { + writeResult = res.writeTime.seconds; + }); + await bulkWriter.close(); + expect(writeResult).to.equal(1); + }); + + it('retries maintain correct write resolution ordering', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([setOp('doc', 'bar')]), + response: failedResponse(Status.INTERNAL), + }, + { + request: createRequest([setOp('doc', 'bar')]), + response: successResponse(1), + }, + { + request: createRequest([setOp('doc2', 'bar')]), + response: successResponse(2), + }, + ]); + const ops: string[] = []; + bulkWriter.onWriteError(() => { + return true; + }); + bulkWriter.set(firestore.doc('collectionId/doc'), {foo: 'bar'}).then(() => { + ops.push('before_flush'); + }); + const flush = bulkWriter.flush().then(() => { + ops.push('flush'); + }); + bulkWriter + .set(firestore.doc('collectionId/doc2'), {foo: 'bar'}) + .then(() => { + ops.push('after_flush'); + }); + + await flush; + expect(ops).to.deep.equal(['before_flush', 'flush']); + return bulkWriter.close().then(() => { + expect(ops).to.deep.equal(['before_flush', 'flush', 'after_flush']); + }); + }); + + it('returns the error if no retry is specified', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([setOp('doc', 'bar')]), + response: failedResponse(Status.INTERNAL), + }, + { + request: createRequest([setOp('doc', 'bar')]), + response: failedResponse(Status.INTERNAL), + }, + { + request: createRequest([setOp('doc', 'bar')]), + response: failedResponse(Status.INTERNAL), + }, + { + request: createRequest([setOp('doc', 'bar')]), + response: failedResponse(Status.INTERNAL), + }, + ]); + let code: Status = -1; + bulkWriter.onWriteError(error => { + return error.failedAttempts < 3; + }); + bulkWriter + .set(firestore.doc('collectionId/doc'), {foo: 'bar'}) + .catch(err => { + code = err.code; + }); + await bulkWriter.close(); + expect(code).to.equal(Status.INTERNAL); + }); + it('splits into multiple batches after exceeding maximum batch size', async () => { const arrayRange = Array.from(new Array(6), (_, i) => i); const requests = arrayRange.map(i => setOp('doc' + i, 'bar')); @@ -588,7 +859,7 @@ describe('BulkWriter', () => { return bulkWriter.close().then(() => verifyOpCount(2)); }); - it('retries individual rites that fail with ABORTED errors', async () => { + it('retries individual writes that fail with ABORTED errors', async () => { setTimeoutHandler(setImmediate); // Create mock responses that simulate one successful write followed by // failed responses. @@ -746,11 +1017,13 @@ describe('BulkWriter', () => { foo: 'bar', }) .catch(err => { - expect(err instanceof GoogleError && err.code === Status.ABORTED).to.be - .true; + expect(err instanceof BulkWriterError).to.be.true; + expect(err.code).to.equal(Status.ABORTED); incrementOpCount(); }); - return bulkWriter.close().then(() => verifyOpCount(1)); + return bulkWriter.close().then(() => { + verifyOpCount(1); + }); }); describe('if bulkCommit() fails', async () => { diff --git a/types/firestore.d.ts b/types/firestore.d.ts index a5fc485bc..45a61913a 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -474,8 +474,9 @@ declare namespace FirebaseFirestore { * @param documentRef A reference to the document to be * created. * @param data The object to serialize as the document. - * @returns A promise that resolves with the result - * of the write. Throws an error if the write fails. + * @returns A promise that resolves with the result of the write. If the + * write fails, the promise is rejected with a + * [BulkWriterError]{@link BulkWriterError}. */ create(documentRef: DocumentReference, data: T): Promise; @@ -489,8 +490,9 @@ declare namespace FirebaseFirestore { * @param precondition.lastUpdateTime If set, enforces that the * document was last updated at lastUpdateTime. Fails the batch if the * document doesn't exist or was last updated at a different time. - * @returns A promise that resolves with the result - * of the write. Throws an error if the write fails. + * @returns A promise that resolves with the result of the delete. If the + * delete fails, the promise is rejected with a + * [BulkWriterError]{@link BulkWriterError}. */ delete( documentRef: DocumentReference, @@ -514,8 +516,9 @@ declare namespace FirebaseFirestore { * @param options.mergeFields - If provided, * set() only replaces the specified field paths. Any field path that is not * specified is ignored and remains untouched. - * @returns A promise that resolves with the result - * of the write. Throws an error if the write fails. + * @returns A promise that resolves with the result of the write. If the + * write fails, the promise is rejected with a + * [BulkWriterError]{@link BulkWriterError}. */ set( documentRef: DocumentReference, @@ -543,8 +546,9 @@ declare namespace FirebaseFirestore { * @param data An object containing the fields and values with which to * update the document. * @param precondition A Precondition to enforce on this update. - * @returns A promise that resolves with the result of the write. Throws - * an error if the write fails. + * @returns A promise that resolves with the result of the write. If the + * write fails, the promise is rejected with a + * [BulkWriterError]{@link BulkWriterError}. */ update( documentRef: DocumentReference, @@ -572,8 +576,9 @@ declare namespace FirebaseFirestore { * @param value The first value * @param fieldsOrPrecondition An alternating list of field paths and values * to update, optionally followed a `Precondition` to enforce on this update. - * @returns A promise that resolves with the result of the write. Throws - * an error if the write fails. + * @returns A promise that resolves with the result of the write. If the + * write fails, the promise is rejected with a + * [BulkWriterError]{@link BulkWriterError}. */ update( documentRef: DocumentReference, @@ -582,6 +587,33 @@ declare namespace FirebaseFirestore { ...fieldsOrPrecondition: any[] ): Promise; + /** + * Attaches a listener that is run every time a BulkWriter operation + * successfully completes. + * + * @param callback A callback to be called every time a BulkWriter operation + * successfully completes. + */ + onWriteResult( + callback: (documentRef: DocumentReference, result: WriteResult) => void + ): void; + + /** + * Attaches an error handler listener that is run every time a BulkWriter + * operation fails. + * + * BulkWriter has a default error handler that retries UNAVAILABLE and + * ABORTED errors up to a maximum of 10 failed attempts. When an error + * handler is specified, the default error handler will be overwritten. + * + * @param shouldRetryCallback A callback to be called every time a BulkWriter + * operation fails. Returning `true` will retry the operation. Returning + * `false` will stop the retry loop. + */ + onWriteError( + shouldRetryCallback: (error: BulkWriterError) => boolean + ): void; + /** * Commits all writes that have been enqueued up to this point in parallel. * @@ -602,7 +634,9 @@ declare namespace FirebaseFirestore { /** * Commits all enqueued writes and marks the BulkWriter instance as closed. * - * After calling `close()`, calling any method wil throw an error. + * After calling `close()`, calling any method wil throw an error. Any + * retries scheduled as part of an `onWriteError()` handler will be run + * before the `close()` promise resolves. * * Returns a Promise that resolves when all writes have been committed. The * Promise will never be rejected. Calling this method will send all @@ -639,6 +673,26 @@ declare namespace FirebaseFirestore { | {initialOpsPerSecond?: number; maxOpsPerSecond?: number}; } + /** + * The error thrown when a BulkWriter operation fails. + */ + export class BulkWriterError extends Error { + /** The status code of the error. */ + readonly code: GrpcStatus; + + /** The error message of the error. */ + readonly message: string; + + /** The document reference the operation was performed on. */ + readonly documentRef: DocumentReference; + + /** The type of operation performed. */ + readonly operationType: 'create' | 'set' | 'update' | 'delete'; + + /** How many times this operation has been attempted unsuccessfully. */ + readonly failedAttempts: number; + } + /** * A write batch, used to perform multiple writes as a single atomic unit. * From 6fb360c0ed2dbb86382e65fd96fa29cd070393bb Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2020 10:18:16 -0800 Subject: [PATCH 206/337] chore: release 4.6.0 (#1351) --- CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0be392ef7..ff580f00b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [4.6.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.5.0...v4.6.0) (2020-11-03) + + +### Features + +* add onWriteError() and onWriteResult() handlers to BulkWriter ([#1315](https://www.github.com/googleapis/nodejs-firestore/issues/1315)) ([a173f4d](https://www.github.com/googleapis/nodejs-firestore/commit/a173f4defab7a6e750907fcb86431c56fcb3d4cf)) + + +### Bug Fixes + +* retry transactions that fail with expired transaction IDs ([#1347](https://www.github.com/googleapis/nodejs-firestore/issues/1347)) ([a18ab50](https://www.github.com/googleapis/nodejs-firestore/commit/a18ab50f3304f1154caaaab9768b736bdb3d8442)) + ## [4.5.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.4.0...v4.5.0) (2020-10-26) diff --git a/package.json b/package.json index 9e53c61da..795c7c484 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.5.0", + "version": "4.6.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 6231433e2..5a15241f2 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.5.0" + "@google-cloud/firestore": "^4.6.0" }, "devDependencies": { "chai": "^4.2.0", From bd5adc35ea1f662ee762ac8b9048556e78a54f35 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 3 Nov 2020 14:18:52 -0600 Subject: [PATCH 207/337] fix: create new batch for writes to the same doc (#1352) * fix: create new batch for writes to the same doc * fix test naming --- dev/src/bulk-writer.ts | 32 ++++++++++++++++------ dev/system-test/firestore.ts | 13 +++++++++ dev/test/bulk-writer.ts | 53 ++++++++++++++++++------------------ 3 files changed, 64 insertions(+), 34 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 5600819b1..f1327767d 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -96,6 +96,9 @@ class BulkCommitBatch { */ state = BatchState.OPEN; + // The set of document reference paths present in the WriteBatch. + readonly docPaths = new Set(); + // An array of pending write operations. Only contains writes that have not // been resolved. private pendingOps: Array> = []; @@ -126,7 +129,7 @@ class BulkCommitBatch { data: T ): Promise { this.writeBatch.create(documentRef, data); - return this.processLastOperation(); + return this.processLastOperation(documentRef); } /** @@ -138,7 +141,7 @@ class BulkCommitBatch { precondition?: firestore.Precondition ): Promise { this.writeBatch.delete(documentRef, precondition); - return this.processLastOperation(); + return this.processLastOperation(documentRef); } set( @@ -165,7 +168,7 @@ class BulkCommitBatch { options?: firestore.SetOptions ): Promise { this.writeBatch.set(documentRef, data, options); - return this.processLastOperation(); + return this.processLastOperation(documentRef); } /** @@ -180,14 +183,21 @@ class BulkCommitBatch { > ): Promise { this.writeBatch.update(documentRef, dataOrField, ...preconditionOrValues); - return this.processLastOperation(); + return this.processLastOperation(documentRef); } /** * Helper to update data structures associated with the operation and * return the result. */ - private processLastOperation(): Promise { + private processLastOperation( + documentRef: firestore.DocumentReference + ): Promise { + assert( + !this.docPaths.has(documentRef.path), + 'Batch should not contain writes to the same document' + ); + this.docPaths.add(documentRef.path); assert( this.state === BatchState.OPEN, 'Batch should be OPEN when adding writes' @@ -762,10 +772,16 @@ export class BulkWriter { * * @private */ - private getEligibleBatch(batchQueue: BulkCommitBatch[]): BulkCommitBatch { + private getEligibleBatch( + documentRef: firestore.DocumentReference, + batchQueue: BulkCommitBatch[] + ): BulkCommitBatch { if (batchQueue.length > 0) { const lastBatch = batchQueue[batchQueue.length - 1]; - if (lastBatch.state === BatchState.OPEN) { + if ( + lastBatch.state === BatchState.OPEN && + !lastBatch.docPaths.has(documentRef.path) + ) { return lastBatch; } } @@ -881,7 +897,7 @@ export class BulkWriter { for (let failedAttempts = 0; ; ++failedAttempts) { const batchQueue = failedAttempts > 0 ? this._retryBatchQueue : this._batchQueue; - const bulkCommitBatch = this.getEligibleBatch(batchQueue); + const bulkCommitBatch = this.getEligibleBatch(documentRef, batchQueue); // Send ready batches if this is the first attempt. Subsequent retry // batches are scheduled after the initial batch returns. diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 71af48c73..7a639edd6 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -2607,6 +2607,19 @@ describe('BulkWriter class', () => { expect(deleteResult.writeTime).to.deep.equal(new Timestamp(0, 0)); }); + it('can write to the same document twice', async () => { + const ref = randomCol.doc('doc1'); + const op1 = writer.set(ref, {foo: 'bar'}); + const op2 = writer.set(ref, {foo: 'bar2'}); + await writer.close(); + const result = await ref.get(); + expect(result.data()).to.deep.equal({foo: 'bar2'}); + const writeTime1 = (await op1).writeTime; + const writeTime2 = (await op2).writeTime; + expect(writeTime1).to.not.be.null; + expect(writeTime2).to.not.be.null; + }); + it('can terminate once BulkWriter is closed', async () => { const ref = randomCol.doc('doc1'); writer.set(ref, {foo: 'bar'}); diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index ee8b5277a..6e2b35256 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -455,14 +455,15 @@ describe('BulkWriter', () => { expect(() => bulkWriter.close()).to.throw(expected); }); - it('can send writes to the same documents in the same batch', async () => { + it('send writes to the same documents in the different batches', async () => { const bulkWriter = await instantiateInstance([ { - request: createRequest([ - setOp('doc1', 'bar'), - updateOp('doc1', 'bar2'), - ]), - response: mergeResponses([successResponse(1), successResponse(2)]), + request: createRequest([setOp('doc1', 'bar')]), + response: successResponse(1), + }, + { + request: createRequest([updateOp('doc1', 'bar2')]), + response: successResponse(2), }, ]); @@ -497,10 +498,10 @@ describe('BulkWriter', () => { const bulkWriter = await instantiateInstance([ { request: createRequest([ - createOp('doc', 'bar'), - setOp('doc', 'bar'), - updateOp('doc', 'bar'), - deleteOp('doc'), + createOp('doc1', 'bar'), + setOp('doc2', 'bar'), + updateOp('doc3', 'bar'), + deleteOp('doc4'), ]), response: mergeResponses([ successResponse(1), @@ -514,10 +515,10 @@ describe('BulkWriter', () => { bulkWriter.onWriteResult((documentRef, result) => { writeResults.push(result.writeTime.seconds); }); - bulkWriter.create(firestore.doc('collectionId/doc'), {foo: 'bar'}); - bulkWriter.set(firestore.doc('collectionId/doc'), {foo: 'bar'}); - bulkWriter.update(firestore.doc('collectionId/doc'), {foo: 'bar'}); - bulkWriter.delete(firestore.doc('collectionId/doc')); + bulkWriter.create(firestore.doc('collectionId/doc1'), {foo: 'bar'}); + bulkWriter.set(firestore.doc('collectionId/doc2'), {foo: 'bar'}); + bulkWriter.update(firestore.doc('collectionId/doc3'), {foo: 'bar'}); + bulkWriter.delete(firestore.doc('collectionId/doc4')); return bulkWriter.close().then(() => { expect(writeResults).to.deep.equal([1, 2, 3, 4]); }); @@ -528,9 +529,9 @@ describe('BulkWriter', () => { { request: createRequest([ createOp('doc', 'bar'), - setOp('doc', 'bar'), - updateOp('doc', 'bar'), - deleteOp('doc'), + setOp('doc1', 'bar'), + updateOp('doc2', 'bar'), + deleteOp('doc3'), ]), response: mergeResponses([ successResponse(1), @@ -541,9 +542,9 @@ describe('BulkWriter', () => { }, { request: createRequest([ - setOp('doc', 'bar'), - updateOp('doc', 'bar'), - deleteOp('doc'), + setOp('doc1', 'bar'), + updateOp('doc2', 'bar'), + deleteOp('doc3'), ]), response: mergeResponses([ successResponse(2), @@ -563,9 +564,9 @@ describe('BulkWriter', () => { writeResults.push(result.writeTime.seconds); }); bulkWriter.create(firestore.doc('collectionId/doc'), {foo: 'bar'}); - bulkWriter.set(firestore.doc('collectionId/doc'), {foo: 'bar'}); - bulkWriter.update(firestore.doc('collectionId/doc'), {foo: 'bar'}); - bulkWriter.delete(firestore.doc('collectionId/doc')); + bulkWriter.set(firestore.doc('collectionId/doc1'), {foo: 'bar'}); + bulkWriter.update(firestore.doc('collectionId/doc2'), {foo: 'bar'}); + bulkWriter.delete(firestore.doc('collectionId/doc3')); return bulkWriter.close().then(() => { expect(ops).to.deep.equal([ 'success', @@ -867,7 +868,7 @@ describe('BulkWriter', () => { { request: createRequest([ setOp('doc1', 'bar'), - setOp('doc1', 'bar2'), + setOp('doc2', 'bar2'), setOp('doc3', 'bar'), ]), response: mergeResponses([ @@ -877,7 +878,7 @@ describe('BulkWriter', () => { ]), }, { - request: createRequest([setOp('doc1', 'bar2'), setOp('doc3', 'bar')]), + request: createRequest([setOp('doc2', 'bar2'), setOp('doc3', 'bar')]), response: mergeResponses([ successResponse(2), failedResponse(Status.ABORTED), @@ -896,7 +897,7 @@ describe('BulkWriter', () => { foo: 'bar', }) .catch(incrementOpCount); - const set2 = bulkWriter.set(firestore.doc('collectionId/doc1'), { + const set2 = bulkWriter.set(firestore.doc('collectionId/doc2'), { foo: 'bar2', }); const set3 = bulkWriter.set(firestore.doc('collectionId/doc3'), { From 72232815962b7cec3d8ce6f2e7ffaf7ab031c455 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2020 12:29:29 -0800 Subject: [PATCH 208/337] chore: release 4.6.1 (#1353) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff580f00b..733c99d95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.6.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.6.0...v4.6.1) (2020-11-03) + + +### Bug Fixes + +* create new batch for writes to the same doc ([#1352](https://www.github.com/googleapis/nodejs-firestore/issues/1352)) ([bd5adc3](https://www.github.com/googleapis/nodejs-firestore/commit/bd5adc35ea1f662ee762ac8b9048556e78a54f35)) + ## [4.6.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.5.0...v4.6.0) (2020-11-03) diff --git a/package.json b/package.json index 795c7c484..cf8e4bdff 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.6.0", + "version": "4.6.1", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 5a15241f2..062539412 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.6.0" + "@google-cloud/firestore": "^4.6.1" }, "devDependencies": { "chai": "^4.2.0", From 0900379e9853a8c2c7c36418dce8beb7ce966889 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 4 Nov 2020 16:11:31 -0800 Subject: [PATCH 209/337] feat: add ability to specify custom headers for individual RPC types (#1355) --- dev/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/src/index.ts b/dev/src/index.ts index b8c5a2283..dfaf2a579 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -1224,6 +1224,7 @@ export class Firestore implements firestore.Firestore { headers: { [CLOUD_RESOURCE_HEADER]: this.formattedName, ...this._settings.customHeaders, + ...this._settings[methodName]?.customHeaders, }, }, }; From dedaeb1a918ea5e70e8f8040f3de0ea68123e8ce Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 4 Nov 2020 16:53:09 -0800 Subject: [PATCH 210/337] chore: release 4.7.0 (#1356) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 733c99d95..da67826a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [4.7.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.6.1...v4.7.0) (2020-11-05) + + +### Features + +* add ability to specify custom headers for individual RPC types ([#1355](https://www.github.com/googleapis/nodejs-firestore/issues/1355)) ([0900379](https://www.github.com/googleapis/nodejs-firestore/commit/0900379e9853a8c2c7c36418dce8beb7ce966889)) + ### [4.6.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.6.0...v4.6.1) (2020-11-03) diff --git a/package.json b/package.json index cf8e4bdff..189c9a60f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.6.1", + "version": "4.7.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 062539412..6c959a7f7 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.6.1" + "@google-cloud/firestore": "^4.7.0" }, "devDependencies": { "chai": "^4.2.0", From dc94946f261db527f913d1ff89a2572cd9539f70 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Thu, 5 Nov 2020 13:19:44 -0600 Subject: [PATCH 211/337] chore: refactor BulkCommitBatch (#1354) --- dev/src/bulk-writer.ts | 215 ++++++++++++++-------------------------- dev/src/write-batch.ts | 114 ++++++++------------- dev/test/write-batch.ts | 86 ---------------- 3 files changed, 116 insertions(+), 299 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index f1327767d..ca7cd8165 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -14,16 +14,12 @@ * limitations under the License. */ import * as firestore from '@google-cloud/firestore'; -import {Status} from 'google-gax'; import * as assert from 'assert'; +import {google} from '../protos/firestore_v1_proto_api'; import {FieldPath, Firestore} from '.'; -import { - delayExecution, - ExponentialBackoff, - MAX_RETRY_ATTEMPTS, -} from './backoff'; +import {delayExecution, MAX_RETRY_ATTEMPTS} from './backoff'; import {RateLimiter} from './rate-limiter'; import {DocumentReference} from './reference'; import {Timestamp} from './timestamp'; @@ -41,9 +37,11 @@ import { validateOptional, } from './validate'; import {logger} from './logger'; +import {GoogleError, Status} from 'google-gax'; // eslint-disable-next-line no-undef import GrpcStatus = FirebaseFirestore.GrpcStatus; +import api = google.firestore.v1; /*! * The maximum number of writes that can be in a single batch. @@ -90,11 +88,11 @@ enum BatchState { * * @private */ -class BulkCommitBatch { +class BulkCommitBatch extends WriteBatch { /** * The state of the batch. */ - state = BatchState.OPEN; + private state = BatchState.OPEN; // The set of document reference paths present in the WriteBatch. readonly docPaths = new Set(); @@ -103,94 +101,80 @@ class BulkCommitBatch { // been resolved. private pendingOps: Array> = []; - private readonly backoff: ExponentialBackoff; - - constructor( - private readonly firestore: Firestore, - private writeBatch: WriteBatch, - private readonly maxBatchSize: number - ) { - this.backoff = new ExponentialBackoff(); + constructor(firestore: Firestore, readonly maxBatchSize: number) { + super(firestore); } - /** - * The number of writes in this batch. - */ - get opCount(): number { - return this.pendingOps.length; + has(documentRef: firestore.DocumentReference): boolean { + return this.docPaths.has(documentRef.path); } - /** - * Adds a `create` operation to the WriteBatch. Returns a promise that - * resolves with the result of the write. - */ - create( - documentRef: firestore.DocumentReference, - data: T - ): Promise { - this.writeBatch.create(documentRef, data); - return this.processLastOperation(documentRef); + markReadyToSend(): void { + if (this.state === BatchState.OPEN) { + this.state = BatchState.READY_TO_SEND; + } } - /** - * Adds a `delete` operation to the WriteBatch. Returns a promise that - * resolves with the sentinel value (Timestamp(0)) for the delete operation. - */ - delete( - documentRef: firestore.DocumentReference, - precondition?: firestore.Precondition - ): Promise { - this.writeBatch.delete(documentRef, precondition); - return this.processLastOperation(documentRef); + isOpen(): boolean { + return this.state === BatchState.OPEN; } - set( - documentRef: firestore.DocumentReference, - data: Partial, - options: firestore.SetOptions - ): Promise; - set( - documentRef: firestore.DocumentReference, - data: T - ): Promise; - set( - documentRef: firestore.DocumentReference, - data: T | Partial, - options?: firestore.SetOptions - ): Promise; - /** - * Adds a `set` operation to the WriteBatch. Returns a promise that - * resolves with the result of the write. - */ - set( - documentRef: firestore.DocumentReference, - data: T | Partial, - options?: firestore.SetOptions - ): Promise { - this.writeBatch.set(documentRef, data, options); - return this.processLastOperation(documentRef); + isReadyToSend(): boolean { + return this.state === BatchState.READY_TO_SEND; } - /** - * Adds an `update` operation to the WriteBatch. Returns a promise that - * resolves with the result of the write. - */ - update( - documentRef: firestore.DocumentReference, - dataOrField: firestore.UpdateData | string | firestore.FieldPath, - ...preconditionOrValues: Array< - {lastUpdateTime?: Timestamp} | unknown | string | FieldPath - > - ): Promise { - this.writeBatch.update(documentRef, dataOrField, ...preconditionOrValues); - return this.processLastOperation(documentRef); + async bulkCommit(): Promise { + assert( + this.state === BatchState.READY_TO_SEND, + 'The batch should be marked as READY_TO_SEND before committing' + ); + this.state = BatchState.SENT; + + // Capture the error stack to preserve stack tracing across async calls. + const stack = Error().stack!; + + let results: BatchWriteResult[] = []; + try { + const retryCodes = getRetryCodes('batchWrite'); + const response = await this._commit< + api.BatchWriteRequest, + api.BatchWriteResponse + >({retryCodes, methodName: 'batchWrite'}); + + results = response.writeResults.map((result, i) => { + const status = response.status[i]; + const error = new GoogleError(status.message || undefined); + error.code = status.code as Status; + + // 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.fromMillis(0); + const updateTime = + error.code === Status.OK + ? Timestamp.fromProto( + result.updateTime || DELETE_TIMESTAMP_SENTINEL + ) + : null; + return new BatchWriteResult(updateTime, error); + }); + } catch (err) { + // Map the failure to each individual write's result. + results = this.pendingOps.map(() => { + return { + writeTime: null, + status: wrapError(err, stack), + }; + }); + } + return this.processResults(results); } /** - * Helper to update data structures associated with the operation and - * return the result. + * Helper to update data structures associated with the operation and returns + * the result. */ - private processLastOperation( + processLastOperation( documentRef: firestore.DocumentReference ): Promise { assert( @@ -205,7 +189,7 @@ class BulkCommitBatch { const deferred = new Deferred(); this.pendingOps.push(deferred); - if (this.opCount === this.maxBatchSize) { + if (this._opCount === this.maxBatchSize) { this.state = BatchState.READY_TO_SEND; } @@ -218,38 +202,6 @@ class BulkCommitBatch { }); } - /** - * Commits the batch and returns a promise that resolves when all the writes - * in the batch have finished. - * - * If any writes in the batch fail with a retryable error, this method will - * retry the failed writes. - */ - async bulkCommit(): Promise { - assert( - this.state === BatchState.READY_TO_SEND, - 'The batch should be marked as READY_TO_SEND before committing' - ); - this.state = BatchState.SENT; - - // Capture the error stack to preserve stack tracing across async calls. - const stack = Error().stack!; - - let results: BatchWriteResult[] = []; - try { - results = await this.writeBatch.bulkCommit(); - } catch (err) { - // Map the failure to each individual write's result. - results = this.pendingOps.map(() => { - return { - writeTime: null, - status: wrapError(err, stack), - }; - }); - } - return this.processResults(results); - } - /** * Resolves the individual operations in the batch with the results. */ @@ -266,12 +218,6 @@ class BulkCommitBatch { }) ); } - - markReadyToSend(): void { - if (this.state === BatchState.OPEN) { - this.state = BatchState.READY_TO_SEND; - } - } } /** @@ -778,10 +724,7 @@ export class BulkWriter { ): BulkCommitBatch { if (batchQueue.length > 0) { const lastBatch = batchQueue[batchQueue.length - 1]; - if ( - lastBatch.state === BatchState.OPEN && - !lastBatch.docPaths.has(documentRef.path) - ) { + if (lastBatch.isOpen() && !lastBatch.has(documentRef)) { return lastBatch; } } @@ -796,11 +739,7 @@ export class BulkWriter { * @private */ private createNewBatch(batchQueue: BulkCommitBatch[]): BulkCommitBatch { - const newBatch = new BulkCommitBatch( - this.firestore, - this.firestore.batch(), - this._maxBatchSize - ); + const newBatch = new BulkCommitBatch(this.firestore, this._maxBatchSize); if (batchQueue.length > 0) { batchQueue[batchQueue.length - 1].markReadyToSend(); @@ -821,10 +760,7 @@ export class BulkWriter { */ private sendReadyBatches(batchQueue: BulkCommitBatch[]): void { let index = 0; - while ( - index < batchQueue.length && - batchQueue[index].state === BatchState.READY_TO_SEND - ) { + while (index < batchQueue.length && batchQueue[index].isReadyToSend()) { const batch = batchQueue[index]; // Deferred promise that resolves when the current batch or its @@ -834,7 +770,7 @@ export class BulkWriter { // Send the batch if it is under the rate limit, or schedule another // attempt after the appropriate timeout. - const delayMs = this._rateLimiter.getNextRequestDelayMs(batch.opCount); + const delayMs = this._rateLimiter.getNextRequestDelayMs(batch._opCount); assert(delayMs !== -1, 'Batch size should be under capacity'); if (delayMs === 0) { this.sendBatch(batch, batchQueue, batchCompletedDeferred); @@ -863,7 +799,7 @@ export class BulkWriter { batchQueue: BulkCommitBatch[], batchCompletedDeferred: Deferred ): Promise { - const success = this._rateLimiter.tryMakeRequest(batch.opCount); + const success = this._rateLimiter.tryMakeRequest(batch._opCount); assert(success, 'Batch should be under rate limit to be sent.'); return batch.bulkCommit().then(() => { // Remove the batch from the BatchQueue after it has been processed. @@ -888,7 +824,7 @@ export class BulkWriter { private async _executeWrite( documentRef: firestore.DocumentReference, operationType: 'create' | 'set' | 'update' | 'delete', - operationFn: (bulkCommitBatch: BulkCommitBatch) => Promise + operationFn: (bulkCommitBatch: BulkCommitBatch) => void ): Promise { // A deferred promise that resolves when operationFn completes. const operationCompletedDeferred = new Deferred(); @@ -906,7 +842,10 @@ export class BulkWriter { } try { - const operationResult = await operationFn(bulkCommitBatch); + operationFn(bulkCommitBatch); + const operationResult = await bulkCommitBatch.processLastOperation( + documentRef + ); this._successFn(documentRef, operationResult); return operationResult; } catch (error) { diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 65b6d0d8c..f164b1f61 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -29,7 +29,7 @@ import {FieldPath, validateFieldPath} from './path'; import {validateDocumentReference} from './reference'; import {Serializer, validateUserInput} from './serializer'; import {Timestamp} from './timestamp'; -import {UpdateMap} from './types'; +import {FirestoreUnaryMethod, UpdateMap} from './types'; import { getRetryCodes, isObject, @@ -138,6 +138,13 @@ export class WriteBatch implements firestore.WriteBatch { private _committed = false; + /** + * The number of writes in this batch. + */ + get _opCount(): number { + return this._ops.length; + } + /** * @hideconstructor */ @@ -544,53 +551,23 @@ export class WriteBatch implements firestore.WriteBatch { // Capture the error stack to preserve stack tracing across async calls. const stack = Error().stack!; - return this._commit().catch(err => { - throw wrapError(err, stack); - }); - } - - /** - * Commits all pending operations to the database and verifies all - * preconditions. - * - * The writes in the batch are not applied atomically and can be applied out - * of order. - * - * @private - */ - async bulkCommit(): Promise { - this._committed = true; - const tag = requestTag(); - await this._firestore.initializeIfNeeded(tag); - - const database = this._firestore.formattedName; - const request: api.IBatchWriteRequest = { - database, - writes: this._ops.map(op => op.op()), - }; - - const retryCodes = getRetryCodes('batchWrite'); - - const response = await this._firestore.request< - api.IBatchWriteRequest, - api.BatchWriteResponse - >('batchWrite', request, tag, retryCodes); - - return response.writeResults.map((result, i) => { - const status = response.status[i]; - const error = new GoogleError(status.message || undefined); - error.code = status.code as Status; - - // 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.fromMillis(0); - const updateTime = - error.code === Status.OK - ? Timestamp.fromProto(result.updateTime || DELETE_TIMESTAMP_SENTINEL) - : null; - return new BatchWriteResult(updateTime, error); - }); + // Commits should also be retried when they fail with status code ABORTED. + const retryCodes = [Status.ABORTED, ...getRetryCodes('commit')]; + + return this._commit({retryCodes}) + .then(response => { + return (response.writeResults || []).map( + writeResult => + new WriteResult( + Timestamp.fromProto( + writeResult.updateTime || response.commitTime! + ) + ) + ); + }) + .catch(err => { + throw wrapError(err, stack); + }); } /** @@ -603,23 +580,25 @@ export class WriteBatch implements firestore.WriteBatch { * this request. * @returns A Promise that resolves when this batch completes. */ - async _commit(commitOptions?: { + async _commit(commitOptions?: { transactionId?: Uint8Array; requestTag?: string; - }): Promise { + retryCodes?: number[]; + methodName?: FirestoreUnaryMethod; + }): Promise { // Note: We don't call `verifyNotCommitted()` to allow for retries. this._committed = true; - const tag = (commitOptions && commitOptions.requestTag) || requestTag(); + const tag = commitOptions?.requestTag ?? requestTag(); await this._firestore.initializeIfNeeded(tag); - const database = this._firestore.formattedName; - const explicitTransaction = commitOptions && commitOptions.transactionId; - + // Note that the request may not always be of type ICommitRequest. This is + // just here to ensure type safety. const request: api.ICommitRequest = { - database, + database: this._firestore.formattedName, writes: this._ops.map(op => op.op()), }; + if (commitOptions?.transactionId) { request.transaction = commitOptions.transactionId; } @@ -631,26 +610,11 @@ export class WriteBatch implements firestore.WriteBatch { request.writes!.length ); - let retryCodes: number[] | undefined; - - if (explicitTransaction) { - request.transaction = explicitTransaction; - } else { - // Commits outside of transaction should also be retried when they fail - // with status code ABORTED. - retryCodes = [Status.ABORTED, ...getRetryCodes('commit')]; - } - - const response = await this._firestore.request< - api.ICommitRequest, - api.CommitResponse - >('commit', request, tag, retryCodes); - - return (response.writeResults || []).map( - writeResult => - new WriteResult( - Timestamp.fromProto(writeResult.updateTime || response.commitTime!) - ) + return this._firestore.request( + commitOptions?.methodName || 'commit', + request as Req, + tag, + commitOptions?.retryCodes ); } diff --git a/dev/test/write-batch.ts b/dev/test/write-batch.ts index beb304a24..b8ab95fa1 100644 --- a/dev/test/write-batch.ts +++ b/dev/test/write-batch.ts @@ -27,7 +27,6 @@ import { WriteResult, QueryDocumentSnapshot, } from '../src'; -import {BatchWriteResult} from '../src/write-batch'; import { ApiOverride, createInstance, @@ -436,88 +435,3 @@ describe('batch support', () => { }); }); }); - -describe('bulkCommit support', () => { - const documentName = `projects/${PROJECT_ID}/databases/(default)/documents/col/doc`; - - let firestore: Firestore; - let writeBatch: WriteBatch; - - beforeEach(() => { - const overrides: ApiOverride = { - batchWrite: request => { - expect(request).to.deep.eq({ - database: `projects/${PROJECT_ID}/databases/(default)`, - writes: [ - { - update: { - fields: {}, - name: documentName, - }, - updateTransforms: [ - { - fieldPath: 'foo', - setToServerValue: REQUEST_TIME, - }, - ], - }, - { - currentDocument: { - exists: true, - }, - update: { - fields: { - foo: { - stringValue: 'bar', - }, - }, - name: documentName, - }, - updateMask: { - fieldPaths: ['foo'], - }, - }, - ], - }); - return response({ - writeResults: [ - { - updateTime: { - nanos: 0, - seconds: 0, - }, - }, - { - updateTime: null, - }, - ], - status: [{code: 0}, {code: 4}], - }); - }, - }; - return createInstance(overrides).then(firestoreClient => { - firestore = firestoreClient; - writeBatch = firestore.batch(); - }); - }); - - afterEach(() => verifyInstance(firestore)); - - function verifyResponse(writeResults: BatchWriteResult[]) { - expect(writeResults[0].writeTime!.isEqual(new Timestamp(0, 0))).to.be.true; - expect(writeResults[1].writeTime).to.be.null; - expect(writeResults[0].status.code).to.equal(Status.OK); - expect(writeResults[1].status.code).to.equal(Status.DEADLINE_EXCEEDED); - } - - it('bulkCommit', () => { - const documentName = firestore.doc('col/doc'); - - writeBatch.set(documentName, {foo: FieldValue.serverTimestamp()}); - writeBatch.update(documentName, {foo: 'bar'}); - - return writeBatch.bulkCommit().then(resp => { - verifyResponse(resp); - }); - }); -}); From b5cf4499724ff41e626a69f2db66be22167a7223 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Fri, 6 Nov 2020 17:31:00 -0600 Subject: [PATCH 212/337] fix: remove unneeded async signature from BulkWriter.sendBatch() (#1361) --- dev/src/bulk-writer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index ca7cd8165..6477a9f87 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -798,10 +798,10 @@ export class BulkWriter { batch: BulkCommitBatch, batchQueue: BulkCommitBatch[], batchCompletedDeferred: Deferred - ): Promise { + ): void { const success = this._rateLimiter.tryMakeRequest(batch._opCount); assert(success, 'Batch should be under rate limit to be sent.'); - return batch.bulkCommit().then(() => { + batch.bulkCommit().then(() => { // Remove the batch from the BatchQueue after it has been processed. const batchIndex = batchQueue.indexOf(batch); assert(batchIndex !== -1, 'The batch should be in the BatchQueue'); From bd40d3ae73cfd0a8e2503fca8d0aa28cb3bbcb86 Mon Sep 17 00:00:00 2001 From: Alexander Fenster Date: Fri, 6 Nov 2020 17:04:50 -0800 Subject: [PATCH 213/337] fix: do not modify options object, use defaultScopes (#1360) * fix: do not modify options object, use defaultScopes Regenerated the library using gapic-generator-typescript v1.2.1. * fix(deps): require google-gax ^2.9.2 --- dev/src/v1/firestore_admin_client.ts | 310 +++++++++++++++----------- dev/src/v1/firestore_client.ts | 317 ++++++++++++++++----------- dev/src/v1beta1/firestore_client.ts | 254 +++++++++++++-------- package.json | 2 +- synth.metadata | 20 +- 5 files changed, 541 insertions(+), 362 deletions(-) diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index 6c0694e63..9231c5add 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -63,8 +63,10 @@ export class FirestoreAdminClient { /** * Construct an instance of FirestoreAdminClient. * - * @param {object} [options] - The configuration object. See the subsequent - * parameters for more details. + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: * @param {object} [options.credentials] - Credentials object. * @param {string} [options.credentials.client_email] * @param {string} [options.credentials.private_key] @@ -84,42 +86,33 @@ export class FirestoreAdminClient { * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - client configuration override. + * TODO(@alexander-fenster): link to gax documentation. + * @param {boolean} fallback - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. */ - constructor(opts?: ClientOptions) { - // Ensure that options include the service address and port. + // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof FirestoreAdminClient; const servicePath = - opts && opts.servicePath - ? opts.servicePath - : opts && opts.apiEndpoint - ? opts.apiEndpoint - : staticMembers.servicePath; - const port = opts && opts.port ? opts.port : staticMembers.port; + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? typeof window !== 'undefined'; + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - if (!opts) { - opts = {servicePath, port}; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; } - opts.servicePath = opts.servicePath || servicePath; - 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 || {}; - // 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. + // Choose either gRPC or proto-over-HTTP implementation of google-gax. this._gaxModule = opts.fallback ? gax.fallback : gax; - // Create a `gaxGrpc` object, with any grpc-specific options - // sent to the client. - opts.scopes = (this.constructor as typeof FirestoreAdminClient).scopes; + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); // Save options to use in initialize() method. @@ -128,6 +121,11 @@ export class FirestoreAdminClient { // Save the auth object to the client, for use by other methods. this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { @@ -345,6 +343,7 @@ export class FirestoreAdminClient { /** * The DNS address for this API service. + * @returns {string} The DNS address for this service. */ static get servicePath() { return 'firestore.googleapis.com'; @@ -353,6 +352,7 @@ export class FirestoreAdminClient { /** * The DNS address for this API service - same as servicePath(), * exists for compatibility reasons. + * @returns {string} The DNS address for this service. */ static get apiEndpoint() { return 'firestore.googleapis.com'; @@ -360,6 +360,7 @@ export class FirestoreAdminClient { /** * The port for this API service. + * @returns {number} The default port for this service. */ static get port() { return 443; @@ -368,6 +369,7 @@ export class FirestoreAdminClient { /** * The scopes needed to make gRPC calls for every method defined * in this service. + * @returns {string[]} List of default scopes. */ static get scopes() { return [ @@ -380,8 +382,7 @@ export class FirestoreAdminClient { getProjectId(callback: Callback): void; /** * Return the project ID used by this class. - * @param {function(Error, string)} callback - the callback to - * be called with the current project Id. + * @returns {Promise} A promise that resolves to string containing the project ID. */ getProjectId( callback?: Callback @@ -435,7 +436,11 @@ export class FirestoreAdminClient { * 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 [Index]{@link google.firestore.admin.v1.Index}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getIndex(request); */ getIndex( request: protos.google.firestore.admin.v1.IGetIndexRequest, @@ -516,7 +521,11 @@ export class FirestoreAdminClient { * 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 [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteIndex(request); */ deleteIndex( request: protos.google.firestore.admin.v1.IDeleteIndexRequest, @@ -599,7 +608,11 @@ export class FirestoreAdminClient { * 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 [Field]{@link google.firestore.admin.v1.Field}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getField(request); */ getField( request: protos.google.firestore.admin.v1.IGetFieldRequest, @@ -693,8 +706,15 @@ export class FirestoreAdminClient { * @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 [Operation]{@link google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.createIndex(request); + * const [response] = await operation.promise(); */ createIndex( request: protos.google.firestore.admin.v1.ICreateIndexRequest, @@ -746,18 +766,19 @@ export class FirestoreAdminClient { return this.innerApiCalls.createIndex(request, options, callback); } /** - * Check the status of the long running operation returned by the createIndex() method. + * Check the status of the long running operation returned by `createIndex()`. * @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); - * + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkCreateIndexProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); */ async checkCreateIndexProgress( name: string @@ -842,8 +863,15 @@ export class FirestoreAdminClient { * @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 [Operation]{@link google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.updateField(request); + * const [response] = await operation.promise(); */ updateField( request: protos.google.firestore.admin.v1.IUpdateFieldRequest, @@ -895,18 +923,19 @@ export class FirestoreAdminClient { return this.innerApiCalls.updateField(request, options, callback); } /** - * Check the status of the long running operation returned by the updateField() method. + * Check the status of the long running operation returned by `updateField()`. * @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); - * + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkUpdateFieldProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); */ async checkUpdateFieldProgress( name: string @@ -995,8 +1024,15 @@ export class FirestoreAdminClient { * @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 [Operation]{@link google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.exportDocuments(request); + * const [response] = await operation.promise(); */ exportDocuments( request: protos.google.firestore.admin.v1.IExportDocumentsRequest, @@ -1048,18 +1084,19 @@ export class FirestoreAdminClient { return this.innerApiCalls.exportDocuments(request, options, callback); } /** - * Check the status of the long running operation returned by the exportDocuments() method. + * Check the status of the long running operation returned by `exportDocuments()`. * @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); - * + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkExportDocumentsProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); */ async checkExportDocumentsProgress( name: string @@ -1143,8 +1180,15 @@ export class FirestoreAdminClient { * @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 [Operation]{@link google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.importDocuments(request); + * const [response] = await operation.promise(); */ importDocuments( request: protos.google.firestore.admin.v1.IImportDocumentsRequest, @@ -1196,18 +1240,19 @@ export class FirestoreAdminClient { return this.innerApiCalls.importDocuments(request, options, callback); } /** - * Check the status of the long running operation returned by the importDocuments() method. + * Check the status of the long running operation returned by `importDocuments()`. * @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); - * + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkImportDocumentsProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); */ async checkImportDocumentsProgress( name: string @@ -1278,19 +1323,14 @@ export class FirestoreAdminClient { * 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 [Index]{@link google.firestore.admin.v1.Index}. - * The client library support auto-pagination by default: it will call the API as many + * The client library will perform 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 [Index]{@link google.firestore.admin.v1.Index} 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 [ListIndexesRequest]{@link google.firestore.admin.v1.ListIndexesRequest} - * 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 - * [ListIndexesResponse]{@link google.firestore.admin.v1.ListIndexesResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. + * Note that it can affect your quota. + * We recommend using `listIndexesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listIndexes( request: protos.google.firestore.admin.v1.IListIndexesRequest, @@ -1336,18 +1376,7 @@ export class FirestoreAdminClient { } /** - * Equivalent to {@link listIndexes}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listIndexes} 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} - * + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. * @param {Object} request * The request object that will be sent. * @param {string} request.parent @@ -1365,6 +1394,13 @@ export class FirestoreAdminClient { * 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 [Index]{@link google.firestore.admin.v1.Index} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listIndexesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listIndexesStream( request?: protos.google.firestore.admin.v1.IListIndexesRequest, @@ -1389,10 +1425,9 @@ export class FirestoreAdminClient { } /** - * 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. + * Equivalent to `listIndexes`, but returns an iterable object. * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. * @param {Object} request * The request object that will be sent. * @param {string} request.parent @@ -1409,7 +1444,18 @@ export class FirestoreAdminClient { * @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. + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Index]{@link google.firestore.admin.v1.Index}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listIndexesAsync(request); + * for await (const response of iterable) { + * // process response + * } */ listIndexesAsync( request?: protos.google.firestore.admin.v1.IListIndexesRequest, @@ -1489,19 +1535,14 @@ export class FirestoreAdminClient { * 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 [Field]{@link google.firestore.admin.v1.Field}. - * The client library support auto-pagination by default: it will call the API as many + * The client library will perform 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 [Field]{@link google.firestore.admin.v1.Field} 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 [ListFieldsRequest]{@link google.firestore.admin.v1.ListFieldsRequest} - * 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 - * [ListFieldsResponse]{@link google.firestore.admin.v1.ListFieldsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. + * Note that it can affect your quota. + * We recommend using `listFieldsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listFields( request: protos.google.firestore.admin.v1.IListFieldsRequest, @@ -1547,18 +1588,7 @@ export class FirestoreAdminClient { } /** - * Equivalent to {@link listFields}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listFields} 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} - * + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. * @param {Object} request * The request object that will be sent. * @param {string} request.parent @@ -1580,6 +1610,13 @@ export class FirestoreAdminClient { * 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 [Field]{@link google.firestore.admin.v1.Field} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listFieldsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listFieldsStream( request?: protos.google.firestore.admin.v1.IListFieldsRequest, @@ -1604,10 +1641,9 @@ export class FirestoreAdminClient { } /** - * 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. + * Equivalent to `listFields`, but returns an iterable object. * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. * @param {Object} request * The request object that will be sent. * @param {string} request.parent @@ -1628,7 +1664,18 @@ export class FirestoreAdminClient { * @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. + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Field]{@link google.firestore.admin.v1.Field}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listFieldsAsync(request); + * for await (const response of iterable) { + * // process response + * } */ listFieldsAsync( request?: protos.google.firestore.admin.v1.IListFieldsRequest, @@ -1882,9 +1929,10 @@ export class FirestoreAdminClient { } /** - * Terminate the GRPC channel and close the client. + * Terminate the gRPC channel and close the client. * * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. */ close(): Promise { this.initialize(); diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 194b26f83..2cffca02b 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -66,8 +66,10 @@ export class FirestoreClient { /** * Construct an instance of FirestoreClient. * - * @param {object} [options] - The configuration object. See the subsequent - * parameters for more details. + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: * @param {object} [options.credentials] - Credentials object. * @param {string} [options.credentials.client_email] * @param {string} [options.credentials.private_key] @@ -87,42 +89,33 @@ export class FirestoreClient { * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - client configuration override. + * TODO(@alexander-fenster): link to gax documentation. + * @param {boolean} fallback - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. */ - constructor(opts?: ClientOptions) { - // Ensure that options include the service address and port. + // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof FirestoreClient; const servicePath = - opts && opts.servicePath - ? opts.servicePath - : opts && opts.apiEndpoint - ? opts.apiEndpoint - : staticMembers.servicePath; - const port = opts && opts.port ? opts.port : staticMembers.port; + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? typeof window !== 'undefined'; + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - if (!opts) { - opts = {servicePath, port}; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; } - opts.servicePath = opts.servicePath || servicePath; - 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 || {}; - // 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. + // Choose either gRPC or proto-over-HTTP implementation of google-gax. this._gaxModule = opts.fallback ? gax.fallback : gax; - // Create a `gaxGrpc` object, with any grpc-specific options - // sent to the client. - opts.scopes = (this.constructor as typeof FirestoreClient).scopes; + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); // Save options to use in initialize() method. @@ -131,6 +124,11 @@ export class FirestoreClient { // Save the auth object to the client, for use by other methods. this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { @@ -294,6 +292,7 @@ export class FirestoreClient { /** * The DNS address for this API service. + * @returns {string} The DNS address for this service. */ static get servicePath() { return 'firestore.googleapis.com'; @@ -302,6 +301,7 @@ export class FirestoreClient { /** * The DNS address for this API service - same as servicePath(), * exists for compatibility reasons. + * @returns {string} The DNS address for this service. */ static get apiEndpoint() { return 'firestore.googleapis.com'; @@ -309,6 +309,7 @@ export class FirestoreClient { /** * The port for this API service. + * @returns {number} The default port for this service. */ static get port() { return 443; @@ -317,6 +318,7 @@ export class FirestoreClient { /** * The scopes needed to make gRPC calls for every method defined * in this service. + * @returns {string[]} List of default scopes. */ static get scopes() { return [ @@ -329,8 +331,7 @@ export class FirestoreClient { getProjectId(callback: Callback): void; /** * Return the project ID used by this class. - * @param {function(Error, string)} callback - the callback to - * be called with the current project Id. + * @returns {Promise} A promise that resolves to string containing the project ID. */ getProjectId( callback?: Callback @@ -394,7 +395,11 @@ export class FirestoreClient { * 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 [Document]{@link google.firestore.v1.Document}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getDocument(request); */ getDocument( request: protos.google.firestore.v1.IGetDocumentRequest, @@ -491,7 +496,11 @@ export class FirestoreClient { * 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 [Document]{@link google.firestore.v1.Document}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updateDocument(request); */ updateDocument( request: protos.google.firestore.v1.IUpdateDocumentRequest, @@ -575,7 +584,11 @@ export class FirestoreClient { * 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 [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteDocument(request); */ deleteDocument( request: protos.google.firestore.v1.IDeleteDocumentRequest, @@ -659,7 +672,11 @@ export class FirestoreClient { * 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 [BeginTransactionResponse]{@link google.firestore.v1.BeginTransactionResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.beginTransaction(request); */ beginTransaction( request: protos.google.firestore.v1.IBeginTransactionRequest, @@ -748,7 +765,11 @@ export class FirestoreClient { * 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 [CommitResponse]{@link google.firestore.v1.CommitResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.commit(request); */ commit( request: protos.google.firestore.v1.ICommitRequest, @@ -831,7 +852,11 @@ export class FirestoreClient { * 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 [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.rollback(request); */ rollback( request: protos.google.firestore.v1.IRollbackRequest, @@ -928,7 +953,11 @@ export class FirestoreClient { * 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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.batchWrite(request); */ batchWrite( request: protos.google.firestore.v1.IBatchWriteRequest, @@ -1023,7 +1052,11 @@ export class FirestoreClient { * 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 [Document]{@link google.firestore.v1.Document}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createDocument(request); */ createDocument( request: protos.google.firestore.v1.ICreateDocumentRequest, @@ -1101,6 +1134,13 @@ export class FirestoreClient { * 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 [BatchGetDocumentsResponse]{@link google.firestore.v1.BatchGetDocumentsResponse} on 'data' event. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) + * for more details and examples. + * @example + * const stream = client.batchGetDocuments(request); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); */ batchGetDocuments( request?: protos.google.firestore.v1.IBatchGetDocumentsRequest, @@ -1147,6 +1187,13 @@ export class FirestoreClient { * 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 [RunQueryResponse]{@link google.firestore.v1.RunQueryResponse} on 'data' event. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) + * for more details and examples. + * @example + * const stream = client.runQuery(request); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); */ runQuery( request?: protos.google.firestore.v1.IRunQueryRequest, @@ -1174,6 +1221,15 @@ export class FirestoreClient { * An object stream which is both readable and writable. It accepts objects * representing [WriteRequest]{@link google.firestore.v1.WriteRequest} for write() method, and * will emit objects representing [WriteResponse]{@link google.firestore.v1.WriteResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example + * const stream = client.write(); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); + * stream.write(request); + * stream.end(); */ write(options?: gax.CallOptions): gax.CancellableStream { this.initialize(); @@ -1189,6 +1245,15 @@ export class FirestoreClient { * An object stream which is both readable and writable. It accepts objects * representing [ListenRequest]{@link google.firestore.v1.ListenRequest} for write() method, and * will emit objects representing [ListenResponse]{@link google.firestore.v1.ListenResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example + * const stream = client.listen(); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); + * stream.write(request); + * stream.end(); */ listen(options?: gax.CallOptions): gax.CancellableStream { this.initialize(); @@ -1265,19 +1330,14 @@ export class FirestoreClient { * 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 [Document]{@link google.firestore.v1.Document}. - * The client library support auto-pagination by default: it will call the API as many + * The client library will perform 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 [Document]{@link google.firestore.v1.Document} 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 [ListDocumentsRequest]{@link google.firestore.v1.ListDocumentsRequest} - * 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 - * [ListDocumentsResponse]{@link google.firestore.v1.ListDocumentsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. + * Note that it can affect your quota. + * We recommend using `listDocumentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listDocuments( request: protos.google.firestore.v1.IListDocumentsRequest, @@ -1321,18 +1381,7 @@ export class FirestoreClient { } /** - * Equivalent to {@link listDocuments}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listDocuments} 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} - * + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. * @param {Object} request * The request object that will be sent. * @param {string} request.parent @@ -1373,6 +1422,13 @@ export class FirestoreClient { * 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 [Document]{@link google.firestore.v1.Document} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDocumentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listDocumentsStream( request?: protos.google.firestore.v1.IListDocumentsRequest, @@ -1397,10 +1453,9 @@ export class FirestoreClient { } /** - * 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. + * Equivalent to `listDocuments`, but returns an iterable object. * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. * @param {Object} request * The request object that will be sent. * @param {string} request.parent @@ -1440,7 +1495,18 @@ export class FirestoreClient { * @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. + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Document]{@link google.firestore.v1.Document}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listDocumentsAsync(request); + * for await (const response of iterable) { + * // process response + * } */ listDocumentsAsync( request?: protos.google.firestore.v1.IListDocumentsRequest, @@ -1543,19 +1609,14 @@ export class FirestoreClient { * 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 + * The client library will perform 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. + * Note that it can affect your quota. + * We recommend using `partitionQueryAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ partitionQuery( request: protos.google.firestore.v1.IPartitionQueryRequest, @@ -1599,18 +1660,7 @@ export class FirestoreClient { } /** - * 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} - * + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. * @param {Object} request * The request object that will be sent. * @param {string} request.parent @@ -1658,6 +1708,13 @@ export class FirestoreClient { * 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. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `partitionQueryAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ partitionQueryStream( request?: protos.google.firestore.v1.IPartitionQueryRequest, @@ -1682,10 +1739,9 @@ export class FirestoreClient { } /** - * 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. + * Equivalent to `partitionQuery`, but returns an iterable object. * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. * @param {Object} request * The request object that will be sent. * @param {string} request.parent @@ -1732,7 +1788,18 @@ export class FirestoreClient { * @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. + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Cursor]{@link google.firestore.v1.Cursor}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.partitionQueryAsync(request); + * for await (const response of iterable) { + * // process response + * } */ partitionQueryAsync( request?: protos.google.firestore.v1.IPartitionQueryRequest, @@ -1802,19 +1869,14 @@ export class FirestoreClient { * 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 string. - * The client library support auto-pagination by default: it will call the API as many + * The client library will perform 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 string 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 [ListCollectionIdsRequest]{@link google.firestore.v1.ListCollectionIdsRequest} - * 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 - * [ListCollectionIdsResponse]{@link google.firestore.v1.ListCollectionIdsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. + * Note that it can affect your quota. + * We recommend using `listCollectionIdsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listCollectionIds( request: protos.google.firestore.v1.IListCollectionIdsRequest, @@ -1860,18 +1922,7 @@ export class FirestoreClient { } /** - * Equivalent to {@link listCollectionIds}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listCollectionIds} 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} - * + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. * @param {Object} request * The request object that will be sent. * @param {string} request.parent @@ -1888,6 +1939,13 @@ export class FirestoreClient { * 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 string on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCollectionIdsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listCollectionIdsStream( request?: protos.google.firestore.v1.IListCollectionIdsRequest, @@ -1912,10 +1970,9 @@ export class FirestoreClient { } /** - * 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. + * Equivalent to `listCollectionIds`, but returns an iterable object. * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. * @param {Object} request * The request object that will be sent. * @param {string} request.parent @@ -1931,7 +1988,18 @@ export class FirestoreClient { * @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. + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * string. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listCollectionIdsAsync(request); + * for await (const response of iterable) { + * // process response + * } */ listCollectionIdsAsync( request?: protos.google.firestore.v1.IListCollectionIdsRequest, @@ -1957,9 +2025,10 @@ export class FirestoreClient { } /** - * Terminate the GRPC channel and close the client. + * Terminate the gRPC channel and close the client. * * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. */ close(): Promise { this.initialize(); diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index 125dee107..d72eb6b66 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -77,8 +77,10 @@ export class FirestoreClient { /** * Construct an instance of FirestoreClient. * - * @param {object} [options] - The configuration object. See the subsequent - * parameters for more details. + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: * @param {object} [options.credentials] - Credentials object. * @param {string} [options.credentials.client_email] * @param {string} [options.credentials.private_key] @@ -98,42 +100,33 @@ export class FirestoreClient { * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - client configuration override. + * TODO(@alexander-fenster): link to gax documentation. + * @param {boolean} fallback - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. */ - constructor(opts?: ClientOptions) { - // Ensure that options include the service address and port. + // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof FirestoreClient; const servicePath = - opts && opts.servicePath - ? opts.servicePath - : opts && opts.apiEndpoint - ? opts.apiEndpoint - : staticMembers.servicePath; - const port = opts && opts.port ? opts.port : staticMembers.port; + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? typeof window !== 'undefined'; + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - if (!opts) { - opts = {servicePath, port}; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; } - opts.servicePath = opts.servicePath || servicePath; - 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 || {}; - // 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. + // Choose either gRPC or proto-over-HTTP implementation of google-gax. this._gaxModule = opts.fallback ? gax.fallback : gax; - // Create a `gaxGrpc` object, with any grpc-specific options - // sent to the client. - opts.scopes = (this.constructor as typeof FirestoreClient).scopes; + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); // Save options to use in initialize() method. @@ -142,6 +135,11 @@ export class FirestoreClient { // Save the auth object to the client, for use by other methods. this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { @@ -298,6 +296,7 @@ export class FirestoreClient { /** * The DNS address for this API service. + * @returns {string} The DNS address for this service. */ static get servicePath() { return 'firestore.googleapis.com'; @@ -306,6 +305,7 @@ export class FirestoreClient { /** * The DNS address for this API service - same as servicePath(), * exists for compatibility reasons. + * @returns {string} The DNS address for this service. */ static get apiEndpoint() { return 'firestore.googleapis.com'; @@ -313,6 +313,7 @@ export class FirestoreClient { /** * The port for this API service. + * @returns {number} The default port for this service. */ static get port() { return 443; @@ -321,6 +322,7 @@ export class FirestoreClient { /** * The scopes needed to make gRPC calls for every method defined * in this service. + * @returns {string[]} List of default scopes. */ static get scopes() { return [ @@ -333,8 +335,7 @@ export class FirestoreClient { getProjectId(callback: Callback): void; /** * Return the project ID used by this class. - * @param {function(Error, string)} callback - the callback to - * be called with the current project Id. + * @returns {Promise} A promise that resolves to string containing the project ID. */ getProjectId( callback?: Callback @@ -398,7 +399,11 @@ export class FirestoreClient { * 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 [Document]{@link google.firestore.v1beta1.Document}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getDocument(request); */ getDocument( request: protos.google.firestore.v1beta1.IGetDocumentRequest, @@ -495,7 +500,11 @@ export class FirestoreClient { * 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 [Document]{@link google.firestore.v1beta1.Document}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createDocument(request); */ createDocument( request: protos.google.firestore.v1beta1.ICreateDocumentRequest, @@ -594,7 +603,11 @@ export class FirestoreClient { * 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 [Document]{@link google.firestore.v1beta1.Document}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updateDocument(request); */ updateDocument( request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, @@ -680,7 +693,11 @@ export class FirestoreClient { * 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 [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteDocument(request); */ deleteDocument( request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, @@ -770,7 +787,11 @@ export class FirestoreClient { * 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 [BeginTransactionResponse]{@link google.firestore.v1beta1.BeginTransactionResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.beginTransaction(request); */ beginTransaction( request: protos.google.firestore.v1beta1.IBeginTransactionRequest, @@ -861,7 +882,11 @@ export class FirestoreClient { * 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 [CommitResponse]{@link google.firestore.v1beta1.CommitResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.commit(request); */ commit( request: protos.google.firestore.v1beta1.ICommitRequest, @@ -944,7 +969,11 @@ export class FirestoreClient { * 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 [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.rollback(request); */ rollback( request: protos.google.firestore.v1beta1.IRollbackRequest, @@ -1022,6 +1051,13 @@ export class FirestoreClient { * 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 [BatchGetDocumentsResponse]{@link google.firestore.v1beta1.BatchGetDocumentsResponse} on 'data' event. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) + * for more details and examples. + * @example + * const stream = client.batchGetDocuments(request); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); */ batchGetDocuments( request?: protos.google.firestore.v1beta1.IBatchGetDocumentsRequest, @@ -1068,6 +1104,13 @@ export class FirestoreClient { * 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 [RunQueryResponse]{@link google.firestore.v1beta1.RunQueryResponse} on 'data' event. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) + * for more details and examples. + * @example + * const stream = client.runQuery(request); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); */ runQuery( request?: protos.google.firestore.v1beta1.IRunQueryRequest, @@ -1095,6 +1138,15 @@ export class FirestoreClient { * An object stream which is both readable and writable. It accepts objects * representing [WriteRequest]{@link google.firestore.v1beta1.WriteRequest} for write() method, and * will emit objects representing [WriteResponse]{@link google.firestore.v1beta1.WriteResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example + * const stream = client.write(); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); + * stream.write(request); + * stream.end(); */ write(options?: gax.CallOptions): gax.CancellableStream { this.initialize(); @@ -1110,6 +1162,15 @@ export class FirestoreClient { * An object stream which is both readable and writable. It accepts objects * representing [ListenRequest]{@link google.firestore.v1beta1.ListenRequest} for write() method, and * will emit objects representing [ListenResponse]{@link google.firestore.v1beta1.ListenResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example + * const stream = client.listen(); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); + * stream.write(request); + * stream.end(); */ listen(options?: gax.CallOptions): gax.CancellableStream { this.initialize(); @@ -1186,19 +1247,14 @@ export class FirestoreClient { * 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 [Document]{@link google.firestore.v1beta1.Document}. - * The client library support auto-pagination by default: it will call the API as many + * The client library will perform 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 [Document]{@link google.firestore.v1beta1.Document} 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 [ListDocumentsRequest]{@link google.firestore.v1beta1.ListDocumentsRequest} - * 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 - * [ListDocumentsResponse]{@link google.firestore.v1beta1.ListDocumentsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. + * Note that it can affect your quota. + * We recommend using `listDocumentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listDocuments( request: protos.google.firestore.v1beta1.IListDocumentsRequest, @@ -1244,18 +1300,7 @@ export class FirestoreClient { } /** - * Equivalent to {@link listDocuments}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listDocuments} 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} - * + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. * @param {Object} request * The request object that will be sent. * @param {string} request.parent @@ -1296,6 +1341,13 @@ export class FirestoreClient { * 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 [Document]{@link google.firestore.v1beta1.Document} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDocumentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listDocumentsStream( request?: protos.google.firestore.v1beta1.IListDocumentsRequest, @@ -1320,10 +1372,9 @@ export class FirestoreClient { } /** - * 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. + * Equivalent to `listDocuments`, but returns an iterable object. * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. * @param {Object} request * The request object that will be sent. * @param {string} request.parent @@ -1363,7 +1414,18 @@ export class FirestoreClient { * @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. + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Document]{@link google.firestore.v1beta1.Document}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listDocumentsAsync(request); + * for await (const response of iterable) { + * // process response + * } */ listDocumentsAsync( request?: protos.google.firestore.v1beta1.IListDocumentsRequest, @@ -1437,19 +1499,14 @@ export class FirestoreClient { * 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 string. - * The client library support auto-pagination by default: it will call the API as many + * The client library will perform 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 string 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 [ListCollectionIdsRequest]{@link google.firestore.v1beta1.ListCollectionIdsRequest} - * 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 - * [ListCollectionIdsResponse]{@link google.firestore.v1beta1.ListCollectionIdsResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. + * Note that it can affect your quota. + * We recommend using `listCollectionIdsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listCollectionIds( request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, @@ -1497,18 +1554,7 @@ export class FirestoreClient { } /** - * Equivalent to {@link listCollectionIds}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listCollectionIds} 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} - * + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. * @param {Object} request * The request object that will be sent. * @param {string} request.parent @@ -1525,6 +1571,13 @@ export class FirestoreClient { * 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 string on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCollectionIdsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. */ listCollectionIdsStream( request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, @@ -1549,10 +1602,9 @@ export class FirestoreClient { } /** - * 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. + * Equivalent to `listCollectionIds`, but returns an iterable object. * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. * @param {Object} request * The request object that will be sent. * @param {string} request.parent @@ -1568,7 +1620,18 @@ export class FirestoreClient { * @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. + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * string. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listCollectionIdsAsync(request); + * for await (const response of iterable) { + * // process response + * } */ listCollectionIdsAsync( request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, @@ -1594,9 +1657,10 @@ export class FirestoreClient { } /** - * Terminate the GRPC channel and close the client. + * Terminate the gRPC channel and close the client. * * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. */ close(): Promise { this.initialize(); diff --git a/package.json b/package.json index 189c9a60f..a1795fa94 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "dependencies": { "fast-deep-equal": "^3.1.1", "functional-red-black-tree": "^1.0.1", - "google-gax": "^2.2.0" + "google-gax": "^2.9.2" }, "devDependencies": { "@types/assert": "^1.4.0", diff --git a/synth.metadata b/synth.metadata index d86160c58..b9f519736 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,22 +3,15 @@ { "git": { "name": ".", - "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "fd832e67f96be0c7a81bc3a98a1f3b3e006c1dd0" - } - }, - { - "git": { - "name": "googleapis", - "remote": "https://github.com/googleapis/googleapis.git", - "sha": "34c5a5c5132a2c5ef46f599550a1195e07f01f80" + "remote": "git@github.com:googleapis/nodejs-firestore.git", + "sha": "dc94946f261db527f913d1ff89a2572cd9539f70" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "89c849ba5013e45e8fb688b138f33c2ec6083dc5" + "sha": "1f1148d3c7a7a52f0c98077f976bd9b3c948ee2b" } } ], @@ -78,6 +71,9 @@ "dev/.jsdoc.js", "dev/.mocharc.js", "dev/.prettierrc.js", + "dev/protos/XX0HTtLI", + "dev/protos/XX9QNuAf", + "dev/protos/XXb5TB9Z", "dev/protos/firestore_admin_v1_proto_api.d.ts", "dev/protos/firestore_admin_v1_proto_api.js", "dev/protos/firestore_v1_proto_api.d.ts", @@ -131,7 +127,9 @@ "dev/test/gapic_firestore_admin_v1.ts", "dev/test/gapic_firestore_v1.ts", "dev/test/gapic_firestore_v1beta1.ts", + "package-lock.json.3706087594", "renovate.json", - "samples/README.md" + "samples/README.md", + "samples/package-lock.json.1776925415" ] } \ No newline at end of file From 9bad804205ab886c1a80351a8e7a7726e3d242ec Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 10 Nov 2020 10:54:20 -0800 Subject: [PATCH 214/337] fix: ignore 'undefined' in update() with UpdateMap (#1363) --- dev/src/serializer.ts | 23 +++++++++++++++++------ dev/src/write-batch.ts | 25 ++++++++++--------------- dev/test/ignore-undefined.ts | 36 +++++++++++++++++++++++++++--------- 3 files changed, 54 insertions(+), 30 deletions(-) diff --git a/dev/src/serializer.ts b/dev/src/serializer.ts index c1de7a289..a69edc303 100644 --- a/dev/src/serializer.ts +++ b/dev/src/serializer.ts @@ -348,7 +348,7 @@ export function validateUserInput( `${invalidArgumentMessage( arg, desc - )} "undefined" values are only ignored in object properties.` + )} "undefined" values are only ignored inside of objects.` ); } else if (!options.allowUndefined) { throw new Error( @@ -366,15 +366,26 @@ export function validateUserInput( value.methodName }() cannot be used inside of an array${fieldPathMessage}.` ); - } else if ( - (options.allowDeletes === 'root' && level !== 0) || - options.allowDeletes === 'none' - ) { + } else if (options.allowDeletes === 'none') { throw new Error( `${invalidArgumentMessage(arg, desc)} ${ value.methodName - }() must appear at the top-level and can only be used in update() or set() with {merge:true}${fieldPathMessage}.` + }() must appear at the top-level and can only be used in update() ` + + `or set() with {merge:true}${fieldPathMessage}.` ); + } else if (options.allowDeletes === 'root') { + if (level === 0) { + // Ok (update() with UpdateData). + } else if (level === 1 && path?.size === 1) { + // Ok (update with varargs). + } else { + throw new Error( + `${invalidArgumentMessage(arg, desc)} ${ + value.methodName + }() must appear at the top-level and can only be used in update() ` + + `or set() with {merge:true}${fieldPathMessage}.` + ); + } } } else if (value instanceof FieldTransform) { if (inArray) { diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index f164b1f61..08f5b2825 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -45,9 +45,8 @@ import { validateMinNumberOfArguments, validateOptional, } from './validate'; - -import api = google.firestore.v1; import {GoogleError, Status} from 'google-gax'; +import api = google.firestore.v1; /** * A WriteResult wraps the write time set by the Firestore servers on sets(), @@ -478,9 +477,13 @@ export class WriteBatch implements firestore.WriteBatch { validateMaxNumberOfArguments('update', arguments, 3); const data = dataOrField as firestore.UpdateData; - Object.keys(data).forEach(key => { - validateFieldPath(key, key); - updateMap.set(FieldPath.fromArgument(key), data[key]); + Object.entries(data).forEach(([key, value]) => { + // Skip `undefined` values (can be hit if `ignoreUndefinedProperties` + // is set) + if (value !== undefined) { + validateFieldPath(key, key); + updateMap.set(FieldPath.fromArgument(key), value); + } }); if (preconditionOrValues.length > 0) { @@ -900,16 +903,8 @@ function validateUpdateMap( if (!isPlainObject(obj)) { throw new Error(customObjectMessage(arg, obj)); } - - let isEmpty = true; - if (obj) { - for (const prop of Object.keys(obj)) { - isEmpty = false; - validateFieldValue(arg, obj[prop], allowUndefined, new FieldPath(prop)); - } - } - - if (isEmpty) { + if (Object.keys(obj).length === 0) { throw new Error('At least one field must be updated.'); } + validateFieldValue(arg, obj, allowUndefined); } diff --git a/dev/test/ignore-undefined.ts b/dev/test/ignore-undefined.ts index 8f63f051e..878b36701 100644 --- a/dev/test/ignore-undefined.ts +++ b/dev/test/ignore-undefined.ts @@ -114,6 +114,30 @@ describe('ignores undefined values', () => { ); }); + it('with top-level field in update()', () => { + const overrides: ApiOverride = { + commit: request => { + requestEquals( + request, + update({ + document: document('documentId', 'foo', 'bar'), + mask: updateMask('foo'), + }) + ); + return response(writeResult(1)); + }, + }; + + return createInstance(overrides, {ignoreUndefinedProperties: true}).then( + async firestore => { + await firestore.doc('collectionId/documentId').update({ + foo: 'bar', + ignored: undefined, + }); + } + ); + }); + it('in query filters', () => { const overrides: ApiOverride = { runQuery: request => { @@ -191,9 +215,7 @@ describe('rejects undefined values', () => { firestore => { expect(() => { firestore.doc('collectionId/documentId').update('foo', undefined); - }).to.throw( - '"undefined" values are only ignored in object properties.' - ); + }).to.throw('"undefined" values are only ignored inside of objects.'); } ); }); @@ -206,9 +228,7 @@ describe('rejects undefined values', () => { .doc('collectionId/documentId') .collection('collectionId') .where('foo', '==', undefined); - }).to.throw( - '"undefined" values are only ignored in object properties.' - ); + }).to.throw('"undefined" values are only ignored inside of objects.'); } ); }); @@ -222,9 +242,7 @@ describe('rejects undefined values', () => { .collection('collectionId') .orderBy('foo') .startAt(undefined); - }).to.throw( - '"undefined" values are only ignored in object properties.' - ); + }).to.throw('"undefined" values are only ignored inside of objects.'); } ); }); From 08af0a3d0a945b2590eef33f2b22fe90993cca34 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2020 11:26:33 -0800 Subject: [PATCH 215/337] chore: release 4.7.1 (#1362) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da67826a5..a395d7536 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.7.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.7.0...v4.7.1) (2020-11-10) + + +### Bug Fixes + +* do not modify options object, use defaultScopes ([#1360](https://www.github.com/googleapis/nodejs-firestore/issues/1360)) ([bd40d3a](https://www.github.com/googleapis/nodejs-firestore/commit/bd40d3ae73cfd0a8e2503fca8d0aa28cb3bbcb86)) +* ignore 'undefined' in update() with UpdateMap ([#1363](https://www.github.com/googleapis/nodejs-firestore/issues/1363)) ([9bad804](https://www.github.com/googleapis/nodejs-firestore/commit/9bad804205ab886c1a80351a8e7a7726e3d242ec)) +* remove unneeded async signature from BulkWriter.sendBatch() ([#1361](https://www.github.com/googleapis/nodejs-firestore/issues/1361)) ([b5cf449](https://www.github.com/googleapis/nodejs-firestore/commit/b5cf4499724ff41e626a69f2db66be22167a7223)) + ## [4.7.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.6.1...v4.7.0) (2020-11-05) diff --git a/package.json b/package.json index a1795fa94..d66ffb326 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.7.0", + "version": "4.7.1", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 6c959a7f7..4a40153f1 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.7.0" + "@google-cloud/firestore": "^4.7.1" }, "devDependencies": { "chai": "^4.2.0", From 11042d32038d4cff64d33069ed302d71791cd749 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 12 Nov 2020 12:33:50 -0800 Subject: [PATCH 216/337] docs: add GrpcStatus to JSDoc, hide other private APIs (#1364) --- dev/src/bulk-writer.ts | 4 ++++ dev/src/index.ts | 29 +++++++++++++++++++++++++++++ dev/src/util.ts | 8 +++++++- dev/src/watch.ts | 2 +- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 6477a9f87..3021c099b 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -299,6 +299,7 @@ export class BulkWriter { /** * The user-provided callback to be run every time a BulkWriter operation * successfully completes. + * @private */ private _successFn: ( document: firestore.DocumentReference, @@ -308,6 +309,7 @@ export class BulkWriter { /** * The user-provided callback to be run every time a BulkWriter operation * fails. + * @private */ private _errorFn: (error: BulkWriterError) => boolean = error => { const retryCodes = getRetryCodes('batchWrite'); @@ -705,6 +707,7 @@ export class BulkWriter { /** * Throws an error if the BulkWriter instance has been closed. + * @private */ private verifyNotClosed(): void { if (this._closing) { @@ -820,6 +823,7 @@ export class BulkWriter { /** * Schedules and runs the provided operation. + * @private */ private async _executeWrite( documentRef: firestore.DocumentReference, diff --git a/dev/src/index.ts b/dev/src/index.ts index dfaf2a579..2d1a32ed3 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -278,6 +278,35 @@ const MAX_CONCURRENT_REQUESTS_PER_CLIENT = 100; * @typedef {Object} ReadOptions */ +/** + * An options object to configure throttling on BulkWriter. + * + * Whether to disable or configure throttling. By default, throttling is + * enabled. `throttling` can be set to either a boolean or a config object. + * Setting it to `true` will use default values. You can override the defaults + * by setting it to `false` to disable throttling, or by setting the config + * values to enable throttling with the provided values. + * + * @property {boolean|Object} throttling Whether to disable or enable + * throttling. Throttling is enabled by default, if the field is set to `true` + * or if any custom throttling options are provided. `{ initialOpsPerSecond: + * number }` sets the initial maximum number of operations per second allowed by + * the throttler. If `initialOpsPerSecond` is not set, the default is 500 + * operations per second. `{ maxOpsPerSecond: number }` sets the maximum number + * of operations per second allowed by the throttler. If `maxOpsPerSecond` is + * not set, no maximum is enforced. + * @typedef {Object} BulkWriterOptions + */ + +/** + * Status codes returned by GRPC operations. + * + * @see https://github.com/grpc/grpc/blob/master/doc/statuscodes.md + * + * @enum {number} + * @typedef {Object} GrpcStatus + */ + /** * The Firestore client represents a Firestore Database and is the entry point * for all Firestore operations. diff --git a/dev/src/util.ts b/dev/src/util.ts index 49cf24a63..d61306558 100644 --- a/dev/src/util.ts +++ b/dev/src/util.ts @@ -161,12 +161,16 @@ export function isPermanentRpcError( /** * Returns the list of retryable error codes specified in the service * configuration. + * @private */ export function getRetryCodes(methodName: string): number[] { return serviceConfig[methodName]?.retry?.retryCodes ?? []; } -/** Returns the backoff setting from the service configuration. */ +/** + * Returns the backoff setting from the service configuration. + * @private + */ export function getRetryParams(methodName: string): BackoffSettings { return ( serviceConfig[methodName]?.retry?.backoffSettings ?? @@ -180,6 +184,8 @@ export function getRetryParams(methodName: string): BackoffSettings { * * This is primarily used to wait for a promise to complete when the result of * the promise will be discarded. + * + * @private */ export function silencePromise(promise: Promise): Promise { return promise.then( diff --git a/dev/src/watch.ts b/dev/src/watch.ts index ab97aab14..23b1b6f69 100644 --- a/dev/src/watch.ts +++ b/dev/src/watch.ts @@ -41,7 +41,7 @@ import api = google.firestore.v1; */ const WATCH_TARGET_ID = 0x1; -/** +/*! * Idle timeout used to detect Watch streams that stall (see * https://github.com/googleapis/nodejs-firestore/issues/1057, b/156308554). * Under normal load, the Watch backend will send a TARGET_CHANGE message From 4b881d640415438bb7d70a8e700f31d3f85b9adf Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 19 Nov 2020 17:34:02 +0100 Subject: [PATCH 217/337] chore(deps): update dependency gts to v3 (#1367) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d66ffb326..6f812b9ca 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "codecov": "^3.6.1", "duplexify": "^4.0.0", "extend": "^3.0.2", - "gts": "^2.0.0-alpha.9", + "gts": "^3.0.0", "jsdoc": "^3.6.2", "jsdoc-fresh": "^1.0.2", "jsdoc-region-tag": "^1.0.2", From 3cd29d22073cff8d0ca072057c63dfe0a2144841 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Mon, 23 Nov 2020 13:12:59 -0800 Subject: [PATCH 218/337] fix(browser): check for fetch on window (#1368) --- dev/protos/protos.json | 515 ++++++++++++++++++++++++--- dev/src/reference.ts | 6 +- dev/src/v1/firestore_admin_client.ts | 114 +++--- dev/src/v1/firestore_client.ts | 146 ++++---- dev/src/v1beta1/firestore_client.ts | 122 ++++--- dev/system-test/firestore.ts | 7 +- dev/test/watch.ts | 4 +- synth.metadata | 19 +- types/firestore.d.ts | 6 +- 9 files changed, 698 insertions(+), 241 deletions(-) diff --git a/dev/protos/protos.json b/dev/protos/protos.json index 5de9ba2e7..bc184dfa1 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -155,7 +155,24 @@ "(google.api.method_signature)": "parent,index", "(google.longrunning.operation_info).response_type": "Index", "(google.longrunning.operation_info).metadata_type": "IndexOperationMetadata" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes", + "body": "index" + } + }, + { + "(google.api.method_signature)": "parent,index" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "Index", + "metadata_type": "IndexOperationMetadata" + } + } + ] }, "ListIndexes": { "requestType": "ListIndexesRequest", @@ -163,7 +180,17 @@ "options": { "(google.api.http).get": "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes", "(google.api.method_signature)": "parent" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] }, "GetIndex": { "requestType": "GetIndexRequest", @@ -171,7 +198,17 @@ "options": { "(google.api.http).get": "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}", "(google.api.method_signature)": "name" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] }, "DeleteIndex": { "requestType": "DeleteIndexRequest", @@ -179,7 +216,17 @@ "options": { "(google.api.http).delete": "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}", "(google.api.method_signature)": "name" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] }, "GetField": { "requestType": "GetFieldRequest", @@ -187,7 +234,17 @@ "options": { "(google.api.http).get": "/v1/{name=projects/*/databases/*/collectionGroups/*/fields/*}", "(google.api.method_signature)": "name" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{name=projects/*/databases/*/collectionGroups/*/fields/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] }, "UpdateField": { "requestType": "UpdateFieldRequest", @@ -198,7 +255,24 @@ "(google.api.method_signature)": "field", "(google.longrunning.operation_info).response_type": "Field", "(google.longrunning.operation_info).metadata_type": "FieldOperationMetadata" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v1/{field.name=projects/*/databases/*/collectionGroups/*/fields/*}", + "body": "field" + } + }, + { + "(google.api.method_signature)": "field" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "Field", + "metadata_type": "FieldOperationMetadata" + } + } + ] }, "ListFields": { "requestType": "ListFieldsRequest", @@ -206,7 +280,17 @@ "options": { "(google.api.http).get": "/v1/{parent=projects/*/databases/*/collectionGroups/*}/fields", "(google.api.method_signature)": "parent" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{parent=projects/*/databases/*/collectionGroups/*}/fields" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] }, "ExportDocuments": { "requestType": "ExportDocumentsRequest", @@ -217,7 +301,24 @@ "(google.api.method_signature)": "name", "(google.longrunning.operation_info).response_type": "ExportDocumentsResponse", "(google.longrunning.operation_info).metadata_type": "ExportDocumentsMetadata" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{name=projects/*/databases/*}:exportDocuments", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "ExportDocumentsResponse", + "metadata_type": "ExportDocumentsMetadata" + } + } + ] }, "ImportDocuments": { "requestType": "ImportDocumentsRequest", @@ -228,7 +329,24 @@ "(google.api.method_signature)": "name", "(google.longrunning.operation_info).response_type": "google.protobuf.Empty", "(google.longrunning.operation_info).metadata_type": "ImportDocumentsMetadata" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{name=projects/*/databases/*}:importDocuments", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.protobuf.Empty", + "metadata_type": "ImportDocumentsMetadata" + } + } + ] } } }, @@ -808,14 +926,28 @@ "responseType": "Document", "options": { "(google.api.http).get": "/v1/{name=projects/*/databases/*/documents/*/**}" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{name=projects/*/databases/*/documents/*/**}" + } + } + ] }, "ListDocuments": { "requestType": "ListDocumentsRequest", "responseType": "ListDocumentsResponse", "options": { "(google.api.http).get": "/v1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" + } + } + ] }, "UpdateDocument": { "requestType": "UpdateDocumentRequest", @@ -824,7 +956,18 @@ "(google.api.http).patch": "/v1/{document.name=projects/*/databases/*/documents/*/**}", "(google.api.http).body": "document", "(google.api.method_signature)": "document,update_mask" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v1/{document.name=projects/*/databases/*/documents/*/**}", + "body": "document" + } + }, + { + "(google.api.method_signature)": "document,update_mask" + } + ] }, "DeleteDocument": { "requestType": "DeleteDocumentRequest", @@ -832,7 +975,17 @@ "options": { "(google.api.http).delete": "/v1/{name=projects/*/databases/*/documents/*/**}", "(google.api.method_signature)": "name" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v1/{name=projects/*/databases/*/documents/*/**}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] }, "BatchGetDocuments": { "requestType": "BatchGetDocumentsRequest", @@ -841,7 +994,15 @@ "options": { "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:batchGet", "(google.api.http).body": "*" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{database=projects/*/databases/*}/documents:batchGet", + "body": "*" + } + } + ] }, "BeginTransaction": { "requestType": "BeginTransactionRequest", @@ -850,7 +1011,18 @@ "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:beginTransaction", "(google.api.http).body": "*", "(google.api.method_signature)": "database" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{database=projects/*/databases/*}/documents:beginTransaction", + "body": "*" + } + }, + { + "(google.api.method_signature)": "database" + } + ] }, "Commit": { "requestType": "CommitRequest", @@ -859,7 +1031,18 @@ "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:commit", "(google.api.http).body": "*", "(google.api.method_signature)": "database,writes" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{database=projects/*/databases/*}/documents:commit", + "body": "*" + } + }, + { + "(google.api.method_signature)": "database,writes" + } + ] }, "Rollback": { "requestType": "RollbackRequest", @@ -868,7 +1051,18 @@ "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:rollback", "(google.api.http).body": "*", "(google.api.method_signature)": "database,transaction" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{database=projects/*/databases/*}/documents:rollback", + "body": "*" + } + }, + { + "(google.api.method_signature)": "database,transaction" + } + ] }, "RunQuery": { "requestType": "RunQueryRequest", @@ -879,7 +1073,19 @@ "(google.api.http).body": "*", "(google.api.http).additional_bindings.post": "/v1/{parent=projects/*/databases/*/documents/*/**}:runQuery", "(google.api.http).additional_bindings.body": "*" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{parent=projects/*/databases/*/documents}:runQuery", + "body": "*", + "additional_bindings": { + "post": "/v1/{parent=projects/*/databases/*/documents/*/**}:runQuery", + "body": "*" + } + } + } + ] }, "PartitionQuery": { "requestType": "PartitionQueryRequest", @@ -889,7 +1095,19 @@ "(google.api.http).body": "*", "(google.api.http).additional_bindings.post": "/v1/{parent=projects/*/databases/*/documents/*/**}:partitionQuery", "(google.api.http).additional_bindings.body": "*" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{parent=projects/*/databases/*/documents}:partitionQuery", + "body": "*", + "additional_bindings": { + "post": "/v1/{parent=projects/*/databases/*/documents/*/**}:partitionQuery", + "body": "*" + } + } + } + ] }, "Write": { "requestType": "WriteRequest", @@ -899,7 +1117,15 @@ "options": { "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:write", "(google.api.http).body": "*" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{database=projects/*/databases/*}/documents:write", + "body": "*" + } + } + ] }, "Listen": { "requestType": "ListenRequest", @@ -909,7 +1135,15 @@ "options": { "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:listen", "(google.api.http).body": "*" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{database=projects/*/databases/*}/documents:listen", + "body": "*" + } + } + ] }, "ListCollectionIds": { "requestType": "ListCollectionIdsRequest", @@ -920,7 +1154,22 @@ "(google.api.http).additional_bindings.post": "/v1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds", "(google.api.http).additional_bindings.body": "*", "(google.api.method_signature)": "parent" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{parent=projects/*/databases/*/documents}:listCollectionIds", + "body": "*", + "additional_bindings": { + "post": "/v1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds", + "body": "*" + } + } + }, + { + "(google.api.method_signature)": "parent" + } + ] }, "BatchWrite": { "requestType": "BatchWriteRequest", @@ -928,7 +1177,15 @@ "options": { "(google.api.http).post": "/v1/{database=projects/*/databases/*}/documents:batchWrite", "(google.api.http).body": "*" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{database=projects/*/databases/*}/documents:batchWrite", + "body": "*" + } + } + ] }, "CreateDocument": { "requestType": "CreateDocumentRequest", @@ -936,7 +1193,15 @@ "options": { "(google.api.http).post": "/v1/{parent=projects/*/databases/*/documents/**}/{collection_id}", "(google.api.http).body": "document" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{parent=projects/*/databases/*/documents/**}/{collection_id}", + "body": "document" + } + } + ] } } }, @@ -2247,14 +2512,28 @@ "responseType": "Document", "options": { "(google.api.http).get": "/v1beta1/{name=projects/*/databases/*/documents/*/**}" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1beta1/{name=projects/*/databases/*/documents/*/**}" + } + } + ] }, "ListDocuments": { "requestType": "ListDocumentsRequest", "responseType": "ListDocumentsResponse", "options": { "(google.api.http).get": "/v1beta1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1beta1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" + } + } + ] }, "CreateDocument": { "requestType": "CreateDocumentRequest", @@ -2262,7 +2541,15 @@ "options": { "(google.api.http).post": "/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}", "(google.api.http).body": "document" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}", + "body": "document" + } + } + ] }, "UpdateDocument": { "requestType": "UpdateDocumentRequest", @@ -2271,7 +2558,18 @@ "(google.api.http).patch": "/v1beta1/{document.name=projects/*/databases/*/documents/*/**}", "(google.api.http).body": "document", "(google.api.method_signature)": "document,update_mask" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v1beta1/{document.name=projects/*/databases/*/documents/*/**}", + "body": "document" + } + }, + { + "(google.api.method_signature)": "document,update_mask" + } + ] }, "DeleteDocument": { "requestType": "DeleteDocumentRequest", @@ -2279,7 +2577,17 @@ "options": { "(google.api.http).delete": "/v1beta1/{name=projects/*/databases/*/documents/*/**}", "(google.api.method_signature)": "name" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v1beta1/{name=projects/*/databases/*/documents/*/**}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] }, "BatchGetDocuments": { "requestType": "BatchGetDocumentsRequest", @@ -2288,7 +2596,15 @@ "options": { "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:batchGet", "(google.api.http).body": "*" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta1/{database=projects/*/databases/*}/documents:batchGet", + "body": "*" + } + } + ] }, "BeginTransaction": { "requestType": "BeginTransactionRequest", @@ -2297,7 +2613,18 @@ "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:beginTransaction", "(google.api.http).body": "*", "(google.api.method_signature)": "database" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta1/{database=projects/*/databases/*}/documents:beginTransaction", + "body": "*" + } + }, + { + "(google.api.method_signature)": "database" + } + ] }, "Commit": { "requestType": "CommitRequest", @@ -2306,7 +2633,18 @@ "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:commit", "(google.api.http).body": "*", "(google.api.method_signature)": "database,writes" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta1/{database=projects/*/databases/*}/documents:commit", + "body": "*" + } + }, + { + "(google.api.method_signature)": "database,writes" + } + ] }, "Rollback": { "requestType": "RollbackRequest", @@ -2315,7 +2653,18 @@ "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:rollback", "(google.api.http).body": "*", "(google.api.method_signature)": "database,transaction" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta1/{database=projects/*/databases/*}/documents:rollback", + "body": "*" + } + }, + { + "(google.api.method_signature)": "database,transaction" + } + ] }, "RunQuery": { "requestType": "RunQueryRequest", @@ -2326,7 +2675,19 @@ "(google.api.http).body": "*", "(google.api.http).additional_bindings.post": "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:runQuery", "(google.api.http).additional_bindings.body": "*" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta1/{parent=projects/*/databases/*/documents}:runQuery", + "body": "*", + "additional_bindings": { + "post": "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:runQuery", + "body": "*" + } + } + } + ] }, "Write": { "requestType": "WriteRequest", @@ -2336,7 +2697,15 @@ "options": { "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:write", "(google.api.http).body": "*" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta1/{database=projects/*/databases/*}/documents:write", + "body": "*" + } + } + ] }, "Listen": { "requestType": "ListenRequest", @@ -2346,7 +2715,15 @@ "options": { "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:listen", "(google.api.http).body": "*" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta1/{database=projects/*/databases/*}/documents:listen", + "body": "*" + } + } + ] }, "ListCollectionIds": { "requestType": "ListCollectionIdsRequest", @@ -2357,7 +2734,22 @@ "(google.api.http).additional_bindings.post": "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds", "(google.api.http).additional_bindings.body": "*", "(google.api.method_signature)": "parent" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta1/{parent=projects/*/databases/*/documents}:listCollectionIds", + "body": "*", + "additional_bindings": { + "post": "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds", + "body": "*" + } + } + }, + { + "(google.api.method_signature)": "parent" + } + ] } } }, @@ -4682,7 +5074,17 @@ "options": { "(google.api.http).get": "/v1/{name=operations}", "(google.api.method_signature)": "name,filter" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{name=operations}" + } + }, + { + "(google.api.method_signature)": "name,filter" + } + ] }, "GetOperation": { "requestType": "GetOperationRequest", @@ -4690,7 +5092,17 @@ "options": { "(google.api.http).get": "/v1/{name=operations/**}", "(google.api.method_signature)": "name" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{name=operations/**}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] }, "DeleteOperation": { "requestType": "DeleteOperationRequest", @@ -4698,7 +5110,17 @@ "options": { "(google.api.http).delete": "/v1/{name=operations/**}", "(google.api.method_signature)": "name" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v1/{name=operations/**}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] }, "CancelOperation": { "requestType": "CancelOperationRequest", @@ -4707,7 +5129,18 @@ "(google.api.http).post": "/v1/{name=operations/**}:cancel", "(google.api.http).body": "*", "(google.api.method_signature)": "name" - } + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{name=operations/**}:cancel", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name" + } + ] }, "WaitOperation": { "requestType": "WaitOperationRequest", diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 6adb08251..2c83227b0 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -309,9 +309,9 @@ export class DocumentReference tag ) .then(collectionIds => { - const collections: Array> = []; + const collections: Array< + CollectionReference + > = []; // We can just sort this list using the default comparator since it // will only contain collection ids. diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index 9231c5add..9a17482e1 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -16,6 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** +/* global window */ import * as gax from 'google-gax'; import { Callback, @@ -31,6 +32,11 @@ import * as path from 'path'; import {Transform} from 'stream'; import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/firestore_admin_v1_proto_api'; +/** + * Client JSON configuration object, loaded from + * `src/v1/firestore_admin_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ import * as gapicConfig from './firestore_admin_client_config.json'; import {operationsProtos} from 'google-gax'; const version = require('../../../package.json').version; @@ -86,9 +92,9 @@ export class FirestoreAdminClient { * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - client configuration override. - * TODO(@alexander-fenster): link to gax documentation. - * @param {boolean} fallback - Use HTTP fallback mode. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. * In fallback mode, a special browser-compatible transport implementation is used * instead of gRPC transport. In browser context (if the `window` object is defined) * the fallback mode is enabled automatically; set `options.fallback` to `false` @@ -101,7 +107,9 @@ export class FirestoreAdminClient { opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? typeof window !== 'undefined'; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. @@ -399,7 +407,7 @@ export class FirestoreAdminClient { // ------------------- getIndex( request: protos.google.firestore.admin.v1.IGetIndexRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.admin.v1.IIndex, @@ -409,7 +417,7 @@ export class FirestoreAdminClient { >; getIndex( request: protos.google.firestore.admin.v1.IGetIndexRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.firestore.admin.v1.IIndex, protos.google.firestore.admin.v1.IGetIndexRequest | null | undefined, @@ -445,7 +453,7 @@ export class FirestoreAdminClient { getIndex( request: protos.google.firestore.admin.v1.IGetIndexRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.firestore.admin.v1.IIndex, protos.google.firestore.admin.v1.IGetIndexRequest | null | undefined, @@ -464,12 +472,12 @@ export class FirestoreAdminClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -484,7 +492,7 @@ export class FirestoreAdminClient { } deleteIndex( request: protos.google.firestore.admin.v1.IDeleteIndexRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.protobuf.IEmpty, @@ -494,7 +502,7 @@ export class FirestoreAdminClient { >; deleteIndex( request: protos.google.firestore.admin.v1.IDeleteIndexRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.protobuf.IEmpty, protos.google.firestore.admin.v1.IDeleteIndexRequest | null | undefined, @@ -530,7 +538,7 @@ export class FirestoreAdminClient { deleteIndex( request: protos.google.firestore.admin.v1.IDeleteIndexRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.protobuf.IEmpty, | protos.google.firestore.admin.v1.IDeleteIndexRequest @@ -551,12 +559,12 @@ export class FirestoreAdminClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -571,7 +579,7 @@ export class FirestoreAdminClient { } getField( request: protos.google.firestore.admin.v1.IGetFieldRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.admin.v1.IField, @@ -581,7 +589,7 @@ export class FirestoreAdminClient { >; getField( request: protos.google.firestore.admin.v1.IGetFieldRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.firestore.admin.v1.IField, protos.google.firestore.admin.v1.IGetFieldRequest | null | undefined, @@ -617,7 +625,7 @@ export class FirestoreAdminClient { getField( request: protos.google.firestore.admin.v1.IGetFieldRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.firestore.admin.v1.IField, protos.google.firestore.admin.v1.IGetFieldRequest | null | undefined, @@ -636,12 +644,12 @@ export class FirestoreAdminClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -657,7 +665,7 @@ export class FirestoreAdminClient { createIndex( request: protos.google.firestore.admin.v1.ICreateIndexRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ LROperation< @@ -670,7 +678,7 @@ export class FirestoreAdminClient { >; createIndex( request: protos.google.firestore.admin.v1.ICreateIndexRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< LROperation< protos.google.firestore.admin.v1.IIndex, @@ -719,7 +727,7 @@ export class FirestoreAdminClient { createIndex( request: protos.google.firestore.admin.v1.ICreateIndexRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< LROperation< protos.google.firestore.admin.v1.IIndex, @@ -747,12 +755,12 @@ export class FirestoreAdminClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -804,7 +812,7 @@ export class FirestoreAdminClient { } updateField( request: protos.google.firestore.admin.v1.IUpdateFieldRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ LROperation< @@ -817,7 +825,7 @@ export class FirestoreAdminClient { >; updateField( request: protos.google.firestore.admin.v1.IUpdateFieldRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< LROperation< protos.google.firestore.admin.v1.IField, @@ -876,7 +884,7 @@ export class FirestoreAdminClient { updateField( request: protos.google.firestore.admin.v1.IUpdateFieldRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< LROperation< protos.google.firestore.admin.v1.IField, @@ -904,12 +912,12 @@ export class FirestoreAdminClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -961,7 +969,7 @@ export class FirestoreAdminClient { } exportDocuments( request: protos.google.firestore.admin.v1.IExportDocumentsRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ LROperation< @@ -974,7 +982,7 @@ export class FirestoreAdminClient { >; exportDocuments( request: protos.google.firestore.admin.v1.IExportDocumentsRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< LROperation< protos.google.firestore.admin.v1.IExportDocumentsResponse, @@ -1037,7 +1045,7 @@ export class FirestoreAdminClient { exportDocuments( request: protos.google.firestore.admin.v1.IExportDocumentsRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< LROperation< protos.google.firestore.admin.v1.IExportDocumentsResponse, @@ -1065,12 +1073,12 @@ export class FirestoreAdminClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1122,7 +1130,7 @@ export class FirestoreAdminClient { } importDocuments( request: protos.google.firestore.admin.v1.IImportDocumentsRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ LROperation< @@ -1135,7 +1143,7 @@ export class FirestoreAdminClient { >; importDocuments( request: protos.google.firestore.admin.v1.IImportDocumentsRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< LROperation< protos.google.protobuf.IEmpty, @@ -1193,7 +1201,7 @@ export class FirestoreAdminClient { importDocuments( request: protos.google.firestore.admin.v1.IImportDocumentsRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< LROperation< protos.google.protobuf.IEmpty, @@ -1221,12 +1229,12 @@ export class FirestoreAdminClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1278,7 +1286,7 @@ export class FirestoreAdminClient { } listIndexes( request: protos.google.firestore.admin.v1.IListIndexesRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.admin.v1.IIndex[], @@ -1288,7 +1296,7 @@ export class FirestoreAdminClient { >; listIndexes( request: protos.google.firestore.admin.v1.IListIndexesRequest, - options: gax.CallOptions, + options: CallOptions, callback: PaginationCallback< protos.google.firestore.admin.v1.IListIndexesRequest, protos.google.firestore.admin.v1.IListIndexesResponse | null | undefined, @@ -1335,7 +1343,7 @@ export class FirestoreAdminClient { listIndexes( request: protos.google.firestore.admin.v1.IListIndexesRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | PaginationCallback< protos.google.firestore.admin.v1.IListIndexesRequest, | protos.google.firestore.admin.v1.IListIndexesResponse @@ -1356,12 +1364,12 @@ export class FirestoreAdminClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1404,7 +1412,7 @@ export class FirestoreAdminClient { */ listIndexesStream( request?: protos.google.firestore.admin.v1.IListIndexesRequest, - options?: gax.CallOptions + options?: CallOptions ): Transform { request = request || {}; options = options || {}; @@ -1459,7 +1467,7 @@ export class FirestoreAdminClient { */ listIndexesAsync( request?: protos.google.firestore.admin.v1.IListIndexesRequest, - options?: gax.CallOptions + options?: CallOptions ): AsyncIterable { request = request || {}; options = options || {}; @@ -1481,7 +1489,7 @@ export class FirestoreAdminClient { } listFields( request: protos.google.firestore.admin.v1.IListFieldsRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.admin.v1.IField[], @@ -1491,7 +1499,7 @@ export class FirestoreAdminClient { >; listFields( request: protos.google.firestore.admin.v1.IListFieldsRequest, - options: gax.CallOptions, + options: CallOptions, callback: PaginationCallback< protos.google.firestore.admin.v1.IListFieldsRequest, protos.google.firestore.admin.v1.IListFieldsResponse | null | undefined, @@ -1547,7 +1555,7 @@ export class FirestoreAdminClient { listFields( request: protos.google.firestore.admin.v1.IListFieldsRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | PaginationCallback< protos.google.firestore.admin.v1.IListFieldsRequest, | protos.google.firestore.admin.v1.IListFieldsResponse @@ -1568,12 +1576,12 @@ export class FirestoreAdminClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1620,7 +1628,7 @@ export class FirestoreAdminClient { */ listFieldsStream( request?: protos.google.firestore.admin.v1.IListFieldsRequest, - options?: gax.CallOptions + options?: CallOptions ): Transform { request = request || {}; options = options || {}; @@ -1679,7 +1687,7 @@ export class FirestoreAdminClient { */ listFieldsAsync( request?: protos.google.firestore.admin.v1.IListFieldsRequest, - options?: gax.CallOptions + options?: CallOptions ): AsyncIterable { request = request || {}; options = options || {}; diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 2cffca02b..0c6a737e5 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -16,6 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** +/* global window */ import * as gax from 'google-gax'; import { Callback, @@ -30,6 +31,11 @@ import * as path from 'path'; import {Transform} from 'stream'; import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/firestore_v1_proto_api'; +/** + * Client JSON configuration object, loaded from + * `src/v1/firestore_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ import * as gapicConfig from './firestore_client_config.json'; const version = require('../../../package.json').version; @@ -89,9 +95,9 @@ export class FirestoreClient { * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - client configuration override. - * TODO(@alexander-fenster): link to gax documentation. - * @param {boolean} fallback - Use HTTP fallback mode. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. * In fallback mode, a special browser-compatible transport implementation is used * instead of gRPC transport. In browser context (if the `window` object is defined) * the fallback mode is enabled automatically; set `options.fallback` to `false` @@ -104,7 +110,9 @@ export class FirestoreClient { opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? typeof window !== 'undefined'; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. @@ -348,7 +356,7 @@ export class FirestoreClient { // ------------------- getDocument( request: protos.google.firestore.v1.IGetDocumentRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.v1.IDocument, @@ -358,7 +366,7 @@ export class FirestoreClient { >; getDocument( request: protos.google.firestore.v1.IGetDocumentRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.firestore.v1.IDocument, protos.google.firestore.v1.IGetDocumentRequest | null | undefined, @@ -404,7 +412,7 @@ export class FirestoreClient { getDocument( request: protos.google.firestore.v1.IGetDocumentRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.firestore.v1.IDocument, protos.google.firestore.v1.IGetDocumentRequest | null | undefined, @@ -423,12 +431,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -443,7 +451,7 @@ export class FirestoreClient { } updateDocument( request: protos.google.firestore.v1.IUpdateDocumentRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.v1.IDocument, @@ -453,7 +461,7 @@ export class FirestoreClient { >; updateDocument( request: protos.google.firestore.v1.IUpdateDocumentRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.firestore.v1.IDocument, protos.google.firestore.v1.IUpdateDocumentRequest | null | undefined, @@ -505,7 +513,7 @@ export class FirestoreClient { updateDocument( request: protos.google.firestore.v1.IUpdateDocumentRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.firestore.v1.IDocument, protos.google.firestore.v1.IUpdateDocumentRequest | null | undefined, @@ -524,12 +532,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -544,7 +552,7 @@ export class FirestoreClient { } deleteDocument( request: protos.google.firestore.v1.IDeleteDocumentRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.protobuf.IEmpty, @@ -554,7 +562,7 @@ export class FirestoreClient { >; deleteDocument( request: protos.google.firestore.v1.IDeleteDocumentRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.protobuf.IEmpty, protos.google.firestore.v1.IDeleteDocumentRequest | null | undefined, @@ -593,7 +601,7 @@ export class FirestoreClient { deleteDocument( request: protos.google.firestore.v1.IDeleteDocumentRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.protobuf.IEmpty, protos.google.firestore.v1.IDeleteDocumentRequest | null | undefined, @@ -612,12 +620,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -632,7 +640,7 @@ export class FirestoreClient { } beginTransaction( request: protos.google.firestore.v1.IBeginTransactionRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.v1.IBeginTransactionResponse, @@ -642,7 +650,7 @@ export class FirestoreClient { >; beginTransaction( request: protos.google.firestore.v1.IBeginTransactionRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.firestore.v1.IBeginTransactionResponse, protos.google.firestore.v1.IBeginTransactionRequest | null | undefined, @@ -681,7 +689,7 @@ export class FirestoreClient { beginTransaction( request: protos.google.firestore.v1.IBeginTransactionRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.firestore.v1.IBeginTransactionResponse, | protos.google.firestore.v1.IBeginTransactionRequest @@ -702,12 +710,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -722,7 +730,7 @@ export class FirestoreClient { } commit( request: protos.google.firestore.v1.ICommitRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.v1.ICommitResponse, @@ -732,7 +740,7 @@ export class FirestoreClient { >; commit( request: protos.google.firestore.v1.ICommitRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.firestore.v1.ICommitResponse, protos.google.firestore.v1.ICommitRequest | null | undefined, @@ -774,7 +782,7 @@ export class FirestoreClient { commit( request: protos.google.firestore.v1.ICommitRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.firestore.v1.ICommitResponse, protos.google.firestore.v1.ICommitRequest | null | undefined, @@ -793,12 +801,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -813,7 +821,7 @@ export class FirestoreClient { } rollback( request: protos.google.firestore.v1.IRollbackRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.protobuf.IEmpty, @@ -823,7 +831,7 @@ export class FirestoreClient { >; rollback( request: protos.google.firestore.v1.IRollbackRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.protobuf.IEmpty, protos.google.firestore.v1.IRollbackRequest | null | undefined, @@ -861,7 +869,7 @@ export class FirestoreClient { rollback( request: protos.google.firestore.v1.IRollbackRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.protobuf.IEmpty, protos.google.firestore.v1.IRollbackRequest | null | undefined, @@ -880,12 +888,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -900,7 +908,7 @@ export class FirestoreClient { } batchWrite( request: protos.google.firestore.v1.IBatchWriteRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.v1.IBatchWriteResponse, @@ -910,7 +918,7 @@ export class FirestoreClient { >; batchWrite( request: protos.google.firestore.v1.IBatchWriteRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.firestore.v1.IBatchWriteResponse, protos.google.firestore.v1.IBatchWriteRequest | null | undefined, @@ -962,7 +970,7 @@ export class FirestoreClient { batchWrite( request: protos.google.firestore.v1.IBatchWriteRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.firestore.v1.IBatchWriteResponse, protos.google.firestore.v1.IBatchWriteRequest | null | undefined, @@ -981,12 +989,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1001,7 +1009,7 @@ export class FirestoreClient { } createDocument( request: protos.google.firestore.v1.ICreateDocumentRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.v1.IDocument, @@ -1011,7 +1019,7 @@ export class FirestoreClient { >; createDocument( request: protos.google.firestore.v1.ICreateDocumentRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.firestore.v1.IDocument, protos.google.firestore.v1.ICreateDocumentRequest | null | undefined, @@ -1061,7 +1069,7 @@ export class FirestoreClient { createDocument( request: protos.google.firestore.v1.ICreateDocumentRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.firestore.v1.IDocument, protos.google.firestore.v1.ICreateDocumentRequest | null | undefined, @@ -1080,12 +1088,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1144,7 +1152,7 @@ export class FirestoreClient { */ batchGetDocuments( request?: protos.google.firestore.v1.IBatchGetDocumentsRequest, - options?: gax.CallOptions + options?: CallOptions ): gax.CancellableStream { request = request || {}; options = options || {}; @@ -1197,7 +1205,7 @@ export class FirestoreClient { */ runQuery( request?: protos.google.firestore.v1.IRunQueryRequest, - options?: gax.CallOptions + options?: CallOptions ): gax.CancellableStream { request = request || {}; options = options || {}; @@ -1231,7 +1239,7 @@ export class FirestoreClient { * stream.write(request); * stream.end(); */ - write(options?: gax.CallOptions): gax.CancellableStream { + write(options?: CallOptions): gax.CancellableStream { this.initialize(); return this.innerApiCalls.write({}, options); } @@ -1255,14 +1263,14 @@ export class FirestoreClient { * stream.write(request); * stream.end(); */ - listen(options?: gax.CallOptions): gax.CancellableStream { + listen(options?: CallOptions): gax.CancellableStream { this.initialize(); return this.innerApiCalls.listen({}, options); } listDocuments( request: protos.google.firestore.v1.IListDocumentsRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.v1.IDocument[], @@ -1272,7 +1280,7 @@ export class FirestoreClient { >; listDocuments( request: protos.google.firestore.v1.IListDocumentsRequest, - options: gax.CallOptions, + options: CallOptions, callback: PaginationCallback< protos.google.firestore.v1.IListDocumentsRequest, protos.google.firestore.v1.IListDocumentsResponse | null | undefined, @@ -1342,7 +1350,7 @@ export class FirestoreClient { listDocuments( request: protos.google.firestore.v1.IListDocumentsRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | PaginationCallback< protos.google.firestore.v1.IListDocumentsRequest, protos.google.firestore.v1.IListDocumentsResponse | null | undefined, @@ -1361,12 +1369,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1432,7 +1440,7 @@ export class FirestoreClient { */ listDocumentsStream( request?: protos.google.firestore.v1.IListDocumentsRequest, - options?: gax.CallOptions + options?: CallOptions ): Transform { request = request || {}; options = options || {}; @@ -1510,7 +1518,7 @@ export class FirestoreClient { */ listDocumentsAsync( request?: protos.google.firestore.v1.IListDocumentsRequest, - options?: gax.CallOptions + options?: CallOptions ): AsyncIterable { request = request || {}; options = options || {}; @@ -1532,7 +1540,7 @@ export class FirestoreClient { } partitionQuery( request: protos.google.firestore.v1.IPartitionQueryRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.v1.ICursor[], @@ -1542,7 +1550,7 @@ export class FirestoreClient { >; partitionQuery( request: protos.google.firestore.v1.IPartitionQueryRequest, - options: gax.CallOptions, + options: CallOptions, callback: PaginationCallback< protos.google.firestore.v1.IPartitionQueryRequest, protos.google.firestore.v1.IPartitionQueryResponse | null | undefined, @@ -1621,7 +1629,7 @@ export class FirestoreClient { partitionQuery( request: protos.google.firestore.v1.IPartitionQueryRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | PaginationCallback< protos.google.firestore.v1.IPartitionQueryRequest, protos.google.firestore.v1.IPartitionQueryResponse | null | undefined, @@ -1640,12 +1648,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1718,7 +1726,7 @@ export class FirestoreClient { */ partitionQueryStream( request?: protos.google.firestore.v1.IPartitionQueryRequest, - options?: gax.CallOptions + options?: CallOptions ): Transform { request = request || {}; options = options || {}; @@ -1803,7 +1811,7 @@ export class FirestoreClient { */ partitionQueryAsync( request?: protos.google.firestore.v1.IPartitionQueryRequest, - options?: gax.CallOptions + options?: CallOptions ): AsyncIterable { request = request || {}; options = options || {}; @@ -1825,7 +1833,7 @@ export class FirestoreClient { } listCollectionIds( request: protos.google.firestore.v1.IListCollectionIdsRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ string[], @@ -1835,7 +1843,7 @@ export class FirestoreClient { >; listCollectionIds( request: protos.google.firestore.v1.IListCollectionIdsRequest, - options: gax.CallOptions, + options: CallOptions, callback: PaginationCallback< protos.google.firestore.v1.IListCollectionIdsRequest, protos.google.firestore.v1.IListCollectionIdsResponse | null | undefined, @@ -1881,7 +1889,7 @@ export class FirestoreClient { listCollectionIds( request: protos.google.firestore.v1.IListCollectionIdsRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | PaginationCallback< protos.google.firestore.v1.IListCollectionIdsRequest, | protos.google.firestore.v1.IListCollectionIdsResponse @@ -1902,12 +1910,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1949,7 +1957,7 @@ export class FirestoreClient { */ listCollectionIdsStream( request?: protos.google.firestore.v1.IListCollectionIdsRequest, - options?: gax.CallOptions + options?: CallOptions ): Transform { request = request || {}; options = options || {}; @@ -2003,7 +2011,7 @@ export class FirestoreClient { */ listCollectionIdsAsync( request?: protos.google.firestore.v1.IListCollectionIdsRequest, - options?: gax.CallOptions + options?: CallOptions ): AsyncIterable { request = request || {}; options = options || {}; diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index d72eb6b66..4e87302f7 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -16,6 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** +/* global window */ import * as gax from 'google-gax'; import { Callback, @@ -30,6 +31,11 @@ import * as path from 'path'; import {Transform} from 'stream'; import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/firestore_v1beta1_proto_api'; +/** + * Client JSON configuration object, loaded from + * `src/v1beta1/firestore_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ import * as gapicConfig from './firestore_client_config.json'; // tslint:disable deprecation @@ -100,9 +106,9 @@ export class FirestoreClient { * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - client configuration override. - * TODO(@alexander-fenster): link to gax documentation. - * @param {boolean} fallback - Use HTTP fallback mode. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. * In fallback mode, a special browser-compatible transport implementation is used * instead of gRPC transport. In browser context (if the `window` object is defined) * the fallback mode is enabled automatically; set `options.fallback` to `false` @@ -115,7 +121,9 @@ export class FirestoreClient { opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? typeof window !== 'undefined'; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. @@ -352,7 +360,7 @@ export class FirestoreClient { // ------------------- getDocument( request: protos.google.firestore.v1beta1.IGetDocumentRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.v1beta1.IDocument, @@ -362,7 +370,7 @@ export class FirestoreClient { >; getDocument( request: protos.google.firestore.v1beta1.IGetDocumentRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.firestore.v1beta1.IDocument, protos.google.firestore.v1beta1.IGetDocumentRequest | null | undefined, @@ -408,7 +416,7 @@ export class FirestoreClient { getDocument( request: protos.google.firestore.v1beta1.IGetDocumentRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.firestore.v1beta1.IDocument, | protos.google.firestore.v1beta1.IGetDocumentRequest @@ -429,12 +437,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -449,7 +457,7 @@ export class FirestoreClient { } createDocument( request: protos.google.firestore.v1beta1.ICreateDocumentRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.v1beta1.IDocument, @@ -459,7 +467,7 @@ export class FirestoreClient { >; createDocument( request: protos.google.firestore.v1beta1.ICreateDocumentRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.firestore.v1beta1.IDocument, protos.google.firestore.v1beta1.ICreateDocumentRequest | null | undefined, @@ -509,7 +517,7 @@ export class FirestoreClient { createDocument( request: protos.google.firestore.v1beta1.ICreateDocumentRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.firestore.v1beta1.IDocument, | protos.google.firestore.v1beta1.ICreateDocumentRequest @@ -530,12 +538,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -550,7 +558,7 @@ export class FirestoreClient { } updateDocument( request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.v1beta1.IDocument, @@ -560,7 +568,7 @@ export class FirestoreClient { >; updateDocument( request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.firestore.v1beta1.IDocument, protos.google.firestore.v1beta1.IUpdateDocumentRequest | null | undefined, @@ -612,7 +620,7 @@ export class FirestoreClient { updateDocument( request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.firestore.v1beta1.IDocument, | protos.google.firestore.v1beta1.IUpdateDocumentRequest @@ -633,12 +641,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -653,7 +661,7 @@ export class FirestoreClient { } deleteDocument( request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.protobuf.IEmpty, @@ -663,7 +671,7 @@ export class FirestoreClient { >; deleteDocument( request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.protobuf.IEmpty, protos.google.firestore.v1beta1.IDeleteDocumentRequest | null | undefined, @@ -702,7 +710,7 @@ export class FirestoreClient { deleteDocument( request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.protobuf.IEmpty, | protos.google.firestore.v1beta1.IDeleteDocumentRequest @@ -723,12 +731,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -743,7 +751,7 @@ export class FirestoreClient { } beginTransaction( request: protos.google.firestore.v1beta1.IBeginTransactionRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.v1beta1.IBeginTransactionResponse, @@ -753,7 +761,7 @@ export class FirestoreClient { >; beginTransaction( request: protos.google.firestore.v1beta1.IBeginTransactionRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.firestore.v1beta1.IBeginTransactionResponse, | protos.google.firestore.v1beta1.IBeginTransactionRequest @@ -796,7 +804,7 @@ export class FirestoreClient { beginTransaction( request: protos.google.firestore.v1beta1.IBeginTransactionRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.firestore.v1beta1.IBeginTransactionResponse, | protos.google.firestore.v1beta1.IBeginTransactionRequest @@ -819,12 +827,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -839,7 +847,7 @@ export class FirestoreClient { } commit( request: protos.google.firestore.v1beta1.ICommitRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.v1beta1.ICommitResponse, @@ -849,7 +857,7 @@ export class FirestoreClient { >; commit( request: protos.google.firestore.v1beta1.ICommitRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.firestore.v1beta1.ICommitResponse, protos.google.firestore.v1beta1.ICommitRequest | null | undefined, @@ -891,7 +899,7 @@ export class FirestoreClient { commit( request: protos.google.firestore.v1beta1.ICommitRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.firestore.v1beta1.ICommitResponse, protos.google.firestore.v1beta1.ICommitRequest | null | undefined, @@ -910,12 +918,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -930,7 +938,7 @@ export class FirestoreClient { } rollback( request: protos.google.firestore.v1beta1.IRollbackRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.protobuf.IEmpty, @@ -940,7 +948,7 @@ export class FirestoreClient { >; rollback( request: protos.google.firestore.v1beta1.IRollbackRequest, - options: gax.CallOptions, + options: CallOptions, callback: Callback< protos.google.protobuf.IEmpty, protos.google.firestore.v1beta1.IRollbackRequest | null | undefined, @@ -978,7 +986,7 @@ export class FirestoreClient { rollback( request: protos.google.firestore.v1beta1.IRollbackRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | Callback< protos.google.protobuf.IEmpty, protos.google.firestore.v1beta1.IRollbackRequest | null | undefined, @@ -997,12 +1005,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1061,7 +1069,7 @@ export class FirestoreClient { */ batchGetDocuments( request?: protos.google.firestore.v1beta1.IBatchGetDocumentsRequest, - options?: gax.CallOptions + options?: CallOptions ): gax.CancellableStream { request = request || {}; options = options || {}; @@ -1114,7 +1122,7 @@ export class FirestoreClient { */ runQuery( request?: protos.google.firestore.v1beta1.IRunQueryRequest, - options?: gax.CallOptions + options?: CallOptions ): gax.CancellableStream { request = request || {}; options = options || {}; @@ -1148,7 +1156,7 @@ export class FirestoreClient { * stream.write(request); * stream.end(); */ - write(options?: gax.CallOptions): gax.CancellableStream { + write(options?: CallOptions): gax.CancellableStream { this.initialize(); return this.innerApiCalls.write({}, options); } @@ -1172,14 +1180,14 @@ export class FirestoreClient { * stream.write(request); * stream.end(); */ - listen(options?: gax.CallOptions): gax.CancellableStream { + listen(options?: CallOptions): gax.CancellableStream { this.initialize(); return this.innerApiCalls.listen({}, options); } listDocuments( request: protos.google.firestore.v1beta1.IListDocumentsRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ protos.google.firestore.v1beta1.IDocument[], @@ -1189,7 +1197,7 @@ export class FirestoreClient { >; listDocuments( request: protos.google.firestore.v1beta1.IListDocumentsRequest, - options: gax.CallOptions, + options: CallOptions, callback: PaginationCallback< protos.google.firestore.v1beta1.IListDocumentsRequest, protos.google.firestore.v1beta1.IListDocumentsResponse | null | undefined, @@ -1259,7 +1267,7 @@ export class FirestoreClient { listDocuments( request: protos.google.firestore.v1beta1.IListDocumentsRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | PaginationCallback< protos.google.firestore.v1beta1.IListDocumentsRequest, | protos.google.firestore.v1beta1.IListDocumentsResponse @@ -1280,12 +1288,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1351,7 +1359,7 @@ export class FirestoreClient { */ listDocumentsStream( request?: protos.google.firestore.v1beta1.IListDocumentsRequest, - options?: gax.CallOptions + options?: CallOptions ): Transform { request = request || {}; options = options || {}; @@ -1429,7 +1437,7 @@ export class FirestoreClient { */ listDocumentsAsync( request?: protos.google.firestore.v1beta1.IListDocumentsRequest, - options?: gax.CallOptions + options?: CallOptions ): AsyncIterable { request = request || {}; options = options || {}; @@ -1451,7 +1459,7 @@ export class FirestoreClient { } listCollectionIds( request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, - options?: gax.CallOptions + options?: CallOptions ): Promise< [ string[], @@ -1461,7 +1469,7 @@ export class FirestoreClient { >; listCollectionIds( request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, - options: gax.CallOptions, + options: CallOptions, callback: PaginationCallback< protos.google.firestore.v1beta1.IListCollectionIdsRequest, | protos.google.firestore.v1beta1.IListCollectionIdsResponse @@ -1511,7 +1519,7 @@ export class FirestoreClient { listCollectionIds( request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, optionsOrCallback?: - | gax.CallOptions + | CallOptions | PaginationCallback< protos.google.firestore.v1beta1.IListCollectionIdsRequest, | protos.google.firestore.v1beta1.IListCollectionIdsResponse @@ -1534,12 +1542,12 @@ export class FirestoreClient { ] > | void { request = request || {}; - let options: gax.CallOptions; + let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; } else { - options = optionsOrCallback as gax.CallOptions; + options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1581,7 +1589,7 @@ export class FirestoreClient { */ listCollectionIdsStream( request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, - options?: gax.CallOptions + options?: CallOptions ): Transform { request = request || {}; options = options || {}; @@ -1635,7 +1643,7 @@ export class FirestoreClient { */ listCollectionIdsAsync( request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, - options?: gax.CallOptions + options?: CallOptions ): AsyncIterable { request = request || {}; options = options || {}; diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 7a639edd6..4bd976ae3 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -2647,10 +2647,9 @@ describe('BulkWriter class', () => { }); describe('Client initialization', () => { - const ops: Array<[ - string, - (coll: CollectionReference) => Promise - ]> = [ + const ops: Array< + [string, (coll: CollectionReference) => Promise] + > = [ ['CollectionReference.get()', randomColl => randomColl.get()], ['CollectionReference.add()', randomColl => randomColl.add({})], [ diff --git a/dev/test/watch.ts b/dev/test/watch.ts index 3ac3a9681..94cdc6a12 100644 --- a/dev/test/watch.ts +++ b/dev/test/watch.ts @@ -242,9 +242,7 @@ class DeferredListener { * sequential invocations of the Listen API. */ class StreamHelper { - private readonly deferredListener = new DeferredListener< - api.IListenRequest - >(); + private readonly deferredListener = new DeferredListener(); private backendStream: Duplex | null = null; streamCount = 0; // The number of streams that the client has requested diff --git a/synth.metadata b/synth.metadata index b9f519736..16d55d5c8 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,8 +3,16 @@ { "git": { "name": ".", - "remote": "git@github.com:googleapis/nodejs-firestore.git", - "sha": "dc94946f261db527f913d1ff89a2572cd9539f70" + "remote": "https://github.com/googleapis/nodejs-firestore.git", + "sha": "11042d32038d4cff64d33069ed302d71791cd749" + } + }, + { + "git": { + "name": "googleapis", + "remote": "https://github.com/googleapis/googleapis.git", + "sha": "2f019bf70bfe06f1e2af1b04011b0a2405190e43", + "internalRef": "343202295" } }, { @@ -71,9 +79,6 @@ "dev/.jsdoc.js", "dev/.mocharc.js", "dev/.prettierrc.js", - "dev/protos/XX0HTtLI", - "dev/protos/XX9QNuAf", - "dev/protos/XXb5TB9Z", "dev/protos/firestore_admin_v1_proto_api.d.ts", "dev/protos/firestore_admin_v1_proto_api.js", "dev/protos/firestore_v1_proto_api.d.ts", @@ -127,9 +132,7 @@ "dev/test/gapic_firestore_admin_v1.ts", "dev/test/gapic_firestore_v1.ts", "dev/test/gapic_firestore_v1beta1.ts", - "package-lock.json.3706087594", "renovate.json", - "samples/README.md", - "samples/package-lock.json.1776925415" + "samples/README.md" ] } \ No newline at end of file diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 45a61913a..2df9c91ec 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -1112,9 +1112,9 @@ declare namespace FirebaseFirestore { * `exists` property will always be true and `data()` will never return * 'undefined'. */ - export class QueryDocumentSnapshot extends DocumentSnapshot< - T - > { + export class QueryDocumentSnapshot< + T = DocumentData + > extends DocumentSnapshot { private constructor(); /** From 208b31ea189e7cfd26f27f6acedce0529e9fee75 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 25 Nov 2020 08:33:24 -0800 Subject: [PATCH 219/337] docs: spelling correction for "targetting" (#1371) Co-authored-by: Benjamin E. Coe Source-Author: Samyak Jain Source-Date: Tue Nov 24 20:27:51 2020 +0530 Source-Repo: googleapis/synthtool Source-Sha: 15013eff642a7e7e855aed5a29e6e83c39beba2a Source-Link: https://github.com/googleapis/synthtool/commit/15013eff642a7e7e855aed5a29e6e83c39beba2a --- README.md | 2 +- synth.metadata | 87 ++------------------------------------------------ 2 files changed, 3 insertions(+), 86 deletions(-) diff --git a/README.md b/README.md index 13a2bdefa..24e116781 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ Our client libraries follow the [Node.js release schedule](https://nodejs.org/en Libraries are compatible with all current _active_ and _maintenance_ versions of Node.js. -Client libraries targetting some end-of-life versions of Node.js are available, and +Client libraries targeting some end-of-life versions of Node.js are available, and can be installed via npm [dist-tags](https://docs.npmjs.com/cli/dist-tag). The dist-tags follow the naming convention `legacy-(version)`. diff --git a/synth.metadata b/synth.metadata index 16d55d5c8..e051976de 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "11042d32038d4cff64d33069ed302d71791cd749" + "sha": "3cd29d22073cff8d0ca072057c63dfe0a2144841" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "1f1148d3c7a7a52f0c98077f976bd9b3c948ee2b" + "sha": "15013eff642a7e7e855aed5a29e6e83c39beba2a" } } ], @@ -51,88 +51,5 @@ "generator": "bazel" } } - ], - "generatedFiles": [ - ".eslintignore", - ".gitattributes", - ".github/ISSUE_TEMPLATE/bug_report.md", - ".github/ISSUE_TEMPLATE/feature_request.md", - ".github/ISSUE_TEMPLATE/support_request.md", - ".github/PULL_REQUEST_TEMPLATE.md", - ".github/release-please.yml", - ".github/workflows/ci.yaml", - ".gitignore", - ".jsdoc.js", - ".mocharc.js", - ".nycrc", - ".prettierignore", - ".prettierrc.js", - ".trampolinerc", - "CODE_OF_CONDUCT.md", - "CONTRIBUTING.md", - "LICENSE", - "README.md", - "api-extractor.json", - "dev/.eslintignore", - "dev/.eslintrc.json", - "dev/.gitignore", - "dev/.jsdoc.js", - "dev/.mocharc.js", - "dev/.prettierrc.js", - "dev/protos/firestore_admin_v1_proto_api.d.ts", - "dev/protos/firestore_admin_v1_proto_api.js", - "dev/protos/firestore_v1_proto_api.d.ts", - "dev/protos/firestore_v1_proto_api.js", - "dev/protos/firestore_v1beta1_proto_api.d.ts", - "dev/protos/firestore_v1beta1_proto_api.js", - "dev/protos/google/api/annotations.proto", - "dev/protos/google/api/client.proto", - "dev/protos/google/api/field_behavior.proto", - "dev/protos/google/api/http.proto", - "dev/protos/google/api/resource.proto", - "dev/protos/google/firestore/admin/v1/field.proto", - "dev/protos/google/firestore/admin/v1/firestore_admin.proto", - "dev/protos/google/firestore/admin/v1/index.proto", - "dev/protos/google/firestore/admin/v1/location.proto", - "dev/protos/google/firestore/admin/v1/operation.proto", - "dev/protos/google/firestore/v1/common.proto", - "dev/protos/google/firestore/v1/document.proto", - "dev/protos/google/firestore/v1/firestore.proto", - "dev/protos/google/firestore/v1/query.proto", - "dev/protos/google/firestore/v1/write.proto", - "dev/protos/google/firestore/v1beta1/common.proto", - "dev/protos/google/firestore/v1beta1/document.proto", - "dev/protos/google/firestore/v1beta1/firestore.proto", - "dev/protos/google/firestore/v1beta1/query.proto", - "dev/protos/google/firestore/v1beta1/write.proto", - "dev/protos/google/longrunning/operations.proto", - "dev/protos/google/protobuf/any.proto", - "dev/protos/google/protobuf/empty.proto", - "dev/protos/google/protobuf/field_mask.proto", - "dev/protos/google/protobuf/struct.proto", - "dev/protos/google/protobuf/timestamp.proto", - "dev/protos/google/protobuf/wrappers.proto", - "dev/protos/google/rpc/status.proto", - "dev/protos/google/type/latlng.proto", - "dev/protos/protos.d.ts", - "dev/protos/protos.js", - "dev/protos/protos.json", - "dev/src/v1/firestore_admin_client.ts", - "dev/src/v1/firestore_admin_client_config.json", - "dev/src/v1/firestore_admin_proto_list.json", - "dev/src/v1/firestore_client.ts", - "dev/src/v1/firestore_client_config.json", - "dev/src/v1/firestore_proto_list.json", - "dev/src/v1beta1/firestore_client.ts", - "dev/src/v1beta1/firestore_client_config.json", - "dev/src/v1beta1/firestore_proto_list.json", - "dev/system-test/fixtures/sample/src/index.js", - "dev/system-test/fixtures/sample/src/index.ts", - "dev/system-test/install.ts", - "dev/test/gapic_firestore_admin_v1.ts", - "dev/test/gapic_firestore_v1.ts", - "dev/test/gapic_firestore_v1beta1.ts", - "renovate.json", - "samples/README.md" ] } \ No newline at end of file From 4acc5ddb45285c144e5831ef457fe0cf53567c88 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 2 Dec 2020 09:44:11 -0800 Subject: [PATCH 220/337] chore: release 4.7.2 (#1370) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a395d7536..f6cf13fb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.7.2](https://www.github.com/googleapis/nodejs-firestore/compare/v4.7.1...v4.7.2) (2020-11-25) + + +### Bug Fixes + +* **browser:** check for fetch on window ([#1368](https://www.github.com/googleapis/nodejs-firestore/issues/1368)) ([3cd29d2](https://www.github.com/googleapis/nodejs-firestore/commit/3cd29d22073cff8d0ca072057c63dfe0a2144841)) + ### [4.7.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.7.0...v4.7.1) (2020-11-10) diff --git a/package.json b/package.json index 6f812b9ca..52973a185 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.7.1", + "version": "4.7.2", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 4a40153f1..46de55442 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.7.1" + "@google-cloud/firestore": "^4.7.2" }, "devDependencies": { "chai": "^4.2.0", From bae82dd4438ac03107c221c62dbce8cf6d20a4b1 Mon Sep 17 00:00:00 2001 From: wu-hui <53845758+wu-hui@users.noreply.github.com> Date: Wed, 2 Dec 2020 14:48:11 -0500 Subject: [PATCH 221/337] feat: Release Bundles (#1365) * feat: Release Bundles --- dev/src/bundle.ts | 4 +-- dev/src/index.ts | 4 +-- dev/system-test/firestore.ts | 6 ++-- dev/test/bundle.ts | 8 +++--- types/firestore.d.ts | 53 ++++++++++++++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 13 deletions(-) diff --git a/dev/src/bundle.ts b/dev/src/bundle.ts index eb511bb01..81f23a4d6 100644 --- a/dev/src/bundle.ts +++ b/dev/src/bundle.ts @@ -30,8 +30,6 @@ const BUNDLE_VERSION = 1; /** * Builds a Firestore data bundle with results from the given document and query snapshots. - * - * @private */ export class BundleBuilder { // Resulting documents for the bundle, keyed by full document path. @@ -42,7 +40,7 @@ export class BundleBuilder { // The latest read time among all bundled documents and queries. private latestReadTime = new Timestamp(0, 0); - constructor(private bundleId: string) {} + constructor(readonly bundleId: string) {} add(documentSnapshot: DocumentSnapshot): BundleBuilder; add(queryName: string, querySnapshot: QuerySnapshot): BundleBuilder; diff --git a/dev/src/index.ts b/dev/src/index.ts index 2d1a32ed3..81a5d19d7 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -863,10 +863,8 @@ export class Firestore implements firestore.Firestore { * @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 { + bundle(name?: string): BundleBuilder { return new BundleBuilder(name || autoId()); } diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 4bd976ae3..9ea567fec 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -2759,7 +2759,7 @@ describe('Bundle building', () => { afterEach(() => verifyInstance(firestore)); it('succeeds when there are no results', async () => { - const bundle = firestore._bundle(TEST_BUNDLE_ID); + const bundle = firestore.bundle(TEST_BUNDLE_ID); const query = testCol.where('sort', '==', 5); const snap = await query.get(); @@ -2788,7 +2788,7 @@ describe('Bundle building', () => { }); it('succeeds when added document does not exist', async () => { - const bundle = firestore._bundle(TEST_BUNDLE_ID); + const bundle = firestore.bundle(TEST_BUNDLE_ID); const snap = await testCol.doc('doc5-not-exist').get(); bundle.add(snap); @@ -2809,7 +2809,7 @@ describe('Bundle building', () => { }); it('succeeds to save limit and limitToLast queries', async () => { - const bundle = firestore._bundle(TEST_BUNDLE_ID); + const bundle = firestore.bundle(TEST_BUNDLE_ID); const limitQuery = testCol.orderBy('sort', 'desc').limit(1); const limitSnap = await limitQuery.get(); const limitToLastQuery = testCol.orderBy('sort', 'asc').limitToLast(1); diff --git a/dev/test/bundle.ts b/dev/test/bundle.ts index a3d42a572..a131c58a3 100644 --- a/dev/test/bundle.ts +++ b/dev/test/bundle.ts @@ -71,7 +71,7 @@ describe('Bundle Buidler', () => { }); it('succeeds with document snapshots', async () => { - const bundle = firestore._bundle(TEST_BUNDLE_ID); + const bundle = firestore.bundle(TEST_BUNDLE_ID); const snap1 = firestore.snapshot_( { name: `${DATABASE_ROOT}/documents/collectionId/doc1`, @@ -122,7 +122,7 @@ describe('Bundle Buidler', () => { }); it('succeeds with query snapshots', async () => { - const bundle = firestore._bundle(TEST_BUNDLE_ID); + const bundle = firestore.bundle(TEST_BUNDLE_ID); const snap = firestore.snapshot_( { name: `${DATABASE_ROOT}/documents/collectionId/doc1`, @@ -213,7 +213,7 @@ describe('Bundle Buidler', () => { }); it('succeeds with multiple calls to build()', async () => { - const bundle = firestore._bundle(TEST_BUNDLE_ID); + const bundle = firestore.bundle(TEST_BUNDLE_ID); const snap1 = firestore.snapshot_( { name: `${DATABASE_ROOT}/documents/collectionId/doc1`, @@ -289,7 +289,7 @@ describe('Bundle Buidler', () => { }); it('succeeds when nothing is added', async () => { - const bundle = firestore._bundle(TEST_BUNDLE_ID); + const bundle = firestore.bundle(TEST_BUNDLE_ID); // `elements` is expected to be [bundleMeta]. const elements = await bundleToElementArray(bundle.build()); diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 2df9c91ec..34481e923 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -296,6 +296,27 @@ declare namespace FirebaseFirestore { * behavior for the underlying BulkWriter. */ bulkWriter(options?: BulkWriterOptions): BulkWriter; + + /** + * 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 bundle to tell if it has been loaded already. + * If not specified, a random identifier will be used. + * + * + * @example + * const bundle = firestore.bundle('data-bundle'); + * const docSnapshot = await firestore.doc('abc/123').get(); + * const querySnapshot = await firestore.collection('coll').get(); + * + * const bundleBuffer = bundle.add(docSnapshot); // Add a document + * .add('coll-query', querySnapshot) // Add a named query. + * .build() + * // Save `bundleBuffer` to CDN or stream it to clients. + */ + bundle(bundleId?: string): BundleBuilder; } /** @@ -1895,6 +1916,38 @@ declare namespace FirebaseFirestore { valueOf(): string; } + /** + * Builds a Firestore data bundle with results from the given document and query snapshots. + */ + export class BundleBuilder { + /** The ID of this bundle. */ + readonly bundleId: string; + + /** + * Adds a Firestore `DocumentSnapshot` to the bundle. Both the documents data and the document + * read time will be included in the bundle. + * + * @param documentSnapshot A `DocumentSnapshot` to add. + * @returns This instance. + */ + add(documentSnapshot: DocumentSnapshot): BundleBuilder; + + /** + * Adds a Firestore `QuerySnapshot` to the bundle. Both the documents in the query results and + * the query read time will be included in the bundle. + * + * @param queryName The name of the query to add. + * @param querySnapshot A `QuerySnapshot` to add to the bundle. + * @returns This instance. + */ + add(queryName: string, querySnapshot: QuerySnapshot): BundleBuilder; + + /** + * Builds the bundle and returns the result as a `Buffer` instance. + */ + build(): Buffer; + } + /** * The v1beta1 Veneer client. This client provides access to to the underlying * Firestore v1beta1 RPCs. From 504bb5f34159238cd9bed3645591e6c6c810452b Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 3 Dec 2020 16:19:43 -0700 Subject: [PATCH 222/337] fix: stop using GRPC channels after RST_STREAM (#1373) --- dev/src/pool.ts | 30 +++++++++++++++++++++++++++--- dev/test/pool.ts | 20 ++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/dev/src/pool.ts b/dev/src/pool.ts index e46fd0b7a..f5ea9d672 100644 --- a/dev/src/pool.ts +++ b/dev/src/pool.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import {GoogleError} from 'google-gax'; import * as assert from 'assert'; import {logger} from './logger'; @@ -35,9 +36,15 @@ export const CLIENT_TERMINATED_ERROR_MSG = export class ClientPool { /** * Stores each active clients and how many operations it has outstanding. - * @private */ - private activeClients: Map = new Map(); + private activeClients = new Map(); + + /** + * A set of clients that have seen RST_STREAM errors (see + * https://github.com/googleapis/nodejs-firestore/issues/1023) and should + * no longer be used. + */ + private failedClients = new Set(); /** * Whether the Firestore instance has been terminated. Once terminated, the @@ -84,6 +91,7 @@ export class ClientPool { // in order to maximize the number of idle clients as operations start to // complete. if ( + !this.failedClients.has(client) && requestCount > selectedClientRequestCount && requestCount < this.concurrentOperationLimit ) { @@ -129,6 +137,7 @@ export class ClientPool { if (this.shouldGarbageCollectClient(client)) { this.activeClients.delete(client); + this.failedClients.delete(client); await this.clientDestructor(client); logger('ClientPool.release', requestTag, 'Garbage collected 1 client'); } @@ -140,10 +149,19 @@ export class ClientPool { * @private */ private shouldGarbageCollectClient(client: T): boolean { + // Don't garbage collect clients that have active requests. if (this.activeClients.get(client) !== 0) { return false; } + // Idle clients that have received RST_STREAM errors are always garbage + // collected. + if (this.failedClients.has(client)) { + return true; + } + + // Otherwise, only garbage collect if we have too much idle capacity (e.g. + // more than 100 idle capacity with default settings) . let idleCapacityCount = 0; for (const [, count] of this.activeClients) { idleCapacityCount += this.concurrentOperationLimit - count; @@ -195,8 +213,14 @@ export class ClientPool { const client = this.acquire(requestTag); return op(client) - .catch(async err => { + .catch(async (err: GoogleError) => { await this.release(requestTag, client); + if (err.message?.indexOf('RST_STREAM')) { + // Once a client has seen a RST_STREAM error, the GRPC channel can + // no longer be used. We mark the client as failed, which ensures that + // we open a new GRPC channel for the next request. + this.failedClients.add(client); + } return Promise.reject(err); }) .then(async res => { diff --git a/dev/test/pool.ts b/dev/test/pool.ts index 7c50df9fe..8640ffd98 100644 --- a/dev/test/pool.ts +++ b/dev/test/pool.ts @@ -14,6 +14,7 @@ import {describe, it} from 'mocha'; import {expect, use} from 'chai'; +import {GoogleError} from 'google-gax'; import * as chaiAsPromised from 'chai-as-promised'; import {ClientPool, CLIENT_TERMINATED_ERROR_MSG} from '../src/pool'; @@ -263,6 +264,25 @@ describe('Client pool', () => { return expect(op).to.eventually.be.rejectedWith('Generated error'); }); + it('does not re-use clients after RST_STREAM', async () => { + let instanceCount = 0; + const clientPool = new ClientPool<{}>(1, 1, () => { + ++instanceCount; + return {}; + }); + + const op = clientPool.run(REQUEST_TAG, () => + Promise.reject( + new GoogleError('13 INTERNAL: Received RST_STREAM with code 2') + ) + ); + await op.catch(() => {}); + + await clientPool.run(REQUEST_TAG, async () => {}); + + expect(instanceCount).to.equal(2); + }); + it('keeps pool of idle clients', async () => { const clientPool = new ClientPool<{}>( /* concurrentOperationLimit= */ 1, From 30b8a1b2c74dec423ac6b54c8448055deee03053 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 3 Dec 2020 17:04:55 -0700 Subject: [PATCH 223/337] chore: release 4.8.0 (#1372) * chore: release 4.8.0 * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: wu-hui <53845758+wu-hui@users.noreply.github.com> Co-authored-by: Sebastian Schmidt --- CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6cf13fb1..07b22977b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [4.8.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.7.2...v4.8.0) (2020-12-03) + + +### Features + +* Add support to build Firestore bundles ([#1365](https://www.github.com/googleapis/nodejs-firestore/issues/1365)) ([bae82dd](https://www.github.com/googleapis/nodejs-firestore/commit/bae82dd4438ac03107c221c62dbce8cf6d20a4b1)) + + +### Bug Fixes + +* stop using GRPC channels after RST_STREAM ([#1373](https://www.github.com/googleapis/nodejs-firestore/issues/1373)) ([504bb5f](https://www.github.com/googleapis/nodejs-firestore/commit/504bb5f34159238cd9bed3645591e6c6c810452b)) + ### [4.7.2](https://www.github.com/googleapis/nodejs-firestore/compare/v4.7.1...v4.7.2) (2020-11-25) diff --git a/package.json b/package.json index 52973a185..2d4a3c156 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.7.2", + "version": "4.8.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 46de55442..9f6d191c2 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.7.2" + "@google-cloud/firestore": "^4.8.0" }, "devDependencies": { "chai": "^4.2.0", From cb905cefcef68c97a7d94557d9465e3c7acd80db Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 4 Dec 2020 08:56:12 -0800 Subject: [PATCH 224/337] chore: generate GAPIC metadata JSON file (#1374) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/bca0aeb7-d7c6-4e0a-a65e-f13ab3f23aa9/targets - [ ] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 345596855 Source-Link: https://github.com/googleapis/googleapis/commit/d189e871205fea665a9648f7c4676f027495ccaf --- dev/src/v1/gapic_metadata.json | 165 ++++++++++++++++++++++++++++ dev/src/v1beta1/gapic_metadata.json | 141 ++++++++++++++++++++++++ synth.metadata | 6 +- 3 files changed, 309 insertions(+), 3 deletions(-) create mode 100644 dev/src/v1/gapic_metadata.json create mode 100644 dev/src/v1beta1/gapic_metadata.json diff --git a/dev/src/v1/gapic_metadata.json b/dev/src/v1/gapic_metadata.json new file mode 100644 index 000000000..954b6b4de --- /dev/null +++ b/dev/src/v1/gapic_metadata.json @@ -0,0 +1,165 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.firestore.v1", + "libraryPackage": "@google-cloud/firestore", + "services": { + "Firestore": { + "clients": { + "grpc": { + "libraryClient": "FirestoreClient", + "rpcs": { + "GetDocument": { + "methods": [ + "getDocument" + ] + }, + "UpdateDocument": { + "methods": [ + "updateDocument" + ] + }, + "DeleteDocument": { + "methods": [ + "deleteDocument" + ] + }, + "BeginTransaction": { + "methods": [ + "beginTransaction" + ] + }, + "Commit": { + "methods": [ + "commit" + ] + }, + "Rollback": { + "methods": [ + "rollback" + ] + }, + "BatchWrite": { + "methods": [ + "batchWrite" + ] + }, + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, + "BatchGetDocuments": { + "methods": [ + "batchGetDocuments" + ] + }, + "RunQuery": { + "methods": [ + "runQuery" + ] + }, + "Write": { + "methods": [ + "write" + ] + }, + "Listen": { + "methods": [ + "listen" + ] + }, + "ListDocuments": { + "methods": [ + "listDocuments", + "listDocumentsStream", + "listDocumentsAsync" + ] + }, + "PartitionQuery": { + "methods": [ + "partitionQuery", + "partitionQueryStream", + "partitionQueryAsync" + ] + }, + "ListCollectionIds": { + "methods": [ + "listCollectionIds", + "listCollectionIdsStream", + "listCollectionIdsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "FirestoreClient", + "rpcs": { + "GetDocument": { + "methods": [ + "getDocument" + ] + }, + "UpdateDocument": { + "methods": [ + "updateDocument" + ] + }, + "DeleteDocument": { + "methods": [ + "deleteDocument" + ] + }, + "BeginTransaction": { + "methods": [ + "beginTransaction" + ] + }, + "Commit": { + "methods": [ + "commit" + ] + }, + "Rollback": { + "methods": [ + "rollback" + ] + }, + "BatchWrite": { + "methods": [ + "batchWrite" + ] + }, + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, + "ListDocuments": { + "methods": [ + "listDocuments", + "listDocumentsStream", + "listDocumentsAsync" + ] + }, + "PartitionQuery": { + "methods": [ + "partitionQuery", + "partitionQueryStream", + "partitionQueryAsync" + ] + }, + "ListCollectionIds": { + "methods": [ + "listCollectionIds", + "listCollectionIdsStream", + "listCollectionIdsAsync" + ] + } + } + } + } + } + } +} diff --git a/dev/src/v1beta1/gapic_metadata.json b/dev/src/v1beta1/gapic_metadata.json new file mode 100644 index 000000000..ec44c4bac --- /dev/null +++ b/dev/src/v1beta1/gapic_metadata.json @@ -0,0 +1,141 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.firestore.v1beta1", + "libraryPackage": "firestore", + "services": { + "Firestore": { + "clients": { + "grpc": { + "libraryClient": "FirestoreClient", + "rpcs": { + "GetDocument": { + "methods": [ + "getDocument" + ] + }, + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, + "UpdateDocument": { + "methods": [ + "updateDocument" + ] + }, + "DeleteDocument": { + "methods": [ + "deleteDocument" + ] + }, + "BeginTransaction": { + "methods": [ + "beginTransaction" + ] + }, + "Commit": { + "methods": [ + "commit" + ] + }, + "Rollback": { + "methods": [ + "rollback" + ] + }, + "BatchGetDocuments": { + "methods": [ + "batchGetDocuments" + ] + }, + "RunQuery": { + "methods": [ + "runQuery" + ] + }, + "Write": { + "methods": [ + "write" + ] + }, + "Listen": { + "methods": [ + "listen" + ] + }, + "ListDocuments": { + "methods": [ + "listDocuments", + "listDocumentsStream", + "listDocumentsAsync" + ] + }, + "ListCollectionIds": { + "methods": [ + "listCollectionIds", + "listCollectionIdsStream", + "listCollectionIdsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "FirestoreClient", + "rpcs": { + "GetDocument": { + "methods": [ + "getDocument" + ] + }, + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, + "UpdateDocument": { + "methods": [ + "updateDocument" + ] + }, + "DeleteDocument": { + "methods": [ + "deleteDocument" + ] + }, + "BeginTransaction": { + "methods": [ + "beginTransaction" + ] + }, + "Commit": { + "methods": [ + "commit" + ] + }, + "Rollback": { + "methods": [ + "rollback" + ] + }, + "ListDocuments": { + "methods": [ + "listDocuments", + "listDocumentsStream", + "listDocumentsAsync" + ] + }, + "ListCollectionIds": { + "methods": [ + "listCollectionIds", + "listCollectionIdsStream", + "listCollectionIdsAsync" + ] + } + } + } + } + } + } +} diff --git a/synth.metadata b/synth.metadata index e051976de..468ce2d75 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "3cd29d22073cff8d0ca072057c63dfe0a2144841" + "sha": "30b8a1b2c74dec423ac6b54c8448055deee03053" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "2f019bf70bfe06f1e2af1b04011b0a2405190e43", - "internalRef": "343202295" + "sha": "d189e871205fea665a9648f7c4676f027495ccaf", + "internalRef": "345596855" } }, { From 8396dace310a1a70a7d0e225af8b66aba016c883 Mon Sep 17 00:00:00 2001 From: Lalji Kanjareeya <46327204+laljikanjareeya@users.noreply.github.com> Date: Tue, 8 Dec 2020 09:20:46 +0530 Subject: [PATCH 225/337] docs: normalize firestore region tags (#1348) Co-authored-by: Christopher Wilcox --- samples/solution-counters.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/samples/solution-counters.js b/samples/solution-counters.js index 6c6bdbfa7..f487ac1f8 100644 --- a/samples/solution-counters.js +++ b/samples/solution-counters.js @@ -17,14 +17,17 @@ const {Firestore, FieldValue} = require('@google-cloud/firestore'); async function main() { // [START increment_counter] + // [START firestore_solution_sharded_counter_increment] function incrementCounter(docRef, numShards) { const shardId = Math.floor(Math.random() * numShards); const shardRef = docRef.collection('shards').doc(shardId.toString()); return shardRef.set({count: FieldValue.increment(1)}, {merge: true}); } + // [END firestore_solution_sharded_counter_increment] // [END increment_counter] // [START get_count] + // [START firestore_solution_sharded_counter_get] async function getCount(docRef) { const querySnapshot = await docRef.collection('shards').get(); const documents = querySnapshot.docs; @@ -35,9 +38,11 @@ async function main() { } return count; } + // [END firestore_solution_sharded_counter_get] // [END get_count] // [START delete_Docs] + // [START firestore_data_delete_doc] async function deleteDocs(docRef) { const shardsCollectionRef = docRef.collection('shards'); const shardDocs = await shardsCollectionRef.select('id').get(); @@ -47,6 +52,7 @@ async function main() { }); return Promise.all(promises); } + // [END firestore_data_delete_doc] // [END delete_Docs] // Create a new client From 0296dd65d135f5b809547c69dec03dcc8f4bd071 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 16 Dec 2020 08:40:25 -0700 Subject: [PATCH 226/337] fix: release clients that received a RST_STREAM error (#1380) * fix: release clients that received a RST_STREAM error * Fix test --- dev/src/pool.ts | 4 ++-- dev/test/pool.ts | 25 +++++++++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/dev/src/pool.ts b/dev/src/pool.ts index f5ea9d672..54638dc28 100644 --- a/dev/src/pool.ts +++ b/dev/src/pool.ts @@ -214,13 +214,13 @@ export class ClientPool { return op(client) .catch(async (err: GoogleError) => { - await this.release(requestTag, client); - if (err.message?.indexOf('RST_STREAM')) { + if (err.message?.match(/RST_STREAM/)) { // Once a client has seen a RST_STREAM error, the GRPC channel can // no longer be used. We mark the client as failed, which ensures that // we open a new GRPC channel for the next request. this.failedClients.add(client); } + await this.release(requestTag, client); return Promise.reject(err); }) .then(async res => { diff --git a/dev/test/pool.ts b/dev/test/pool.ts index 8640ffd98..ce8a45e54 100644 --- a/dev/test/pool.ts +++ b/dev/test/pool.ts @@ -214,13 +214,11 @@ describe('Client pool', () => { ); expect(clientPool.size).to.equal(2); - operationPromises.forEach(deferred => deferred.reject()); + operationPromises.forEach(deferred => deferred.reject(new Error())); - return Promise.all(completionPromises.map(p => p.catch(() => {}))).then( - () => { - expect(clientPool.size).to.equal(0); - } - ); + return Promise.all( + completionPromises.map(p => p.catch(() => {})) + ).then(() => expect(clientPool.size).to.equal(0)); }); it('garbage collection calls destructor', () => { @@ -283,6 +281,21 @@ describe('Client pool', () => { expect(instanceCount).to.equal(2); }); + it('garbage collects after RST_STREAM', async () => { + const clientPool = new ClientPool<{}>(1, 1, () => { + return {}; + }); + + const op = clientPool.run(REQUEST_TAG, () => + Promise.reject( + new GoogleError('13 INTERNAL: Received RST_STREAM with code 2') + ) + ); + await op.catch(() => {}); + + expect(clientPool.size).to.equal(0); + }); + it('keeps pool of idle clients', async () => { const clientPool = new ClientPool<{}>( /* concurrentOperationLimit= */ 1, From 7ff23453d8b7cf817de61f4291a81e2217d741ca Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 16 Dec 2020 08:49:57 -0700 Subject: [PATCH 227/337] chore: release 4.8.1 (#1381) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07b22977b..0e5ae91ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.8.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.8.0...v4.8.1) (2020-12-16) + + +### Bug Fixes + +* release clients that received a RST_STREAM error ([#1380](https://www.github.com/googleapis/nodejs-firestore/issues/1380)) ([0296dd6](https://www.github.com/googleapis/nodejs-firestore/commit/0296dd65d135f5b809547c69dec03dcc8f4bd071)) + ## [4.8.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.7.2...v4.8.0) (2020-12-03) diff --git a/package.json b/package.json index 2d4a3c156..00e4f88f3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.8.0", + "version": "4.8.1", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 9f6d191c2..10f6f17fe 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.8.0" + "@google-cloud/firestore": "^4.8.1" }, "devDependencies": { "chai": "^4.2.0", From f4899ce04a63a8feec4f372d0a36f875d70cfa75 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 17 Dec 2020 20:07:27 -0700 Subject: [PATCH 228/337] chore: simplify Bulk Writer (#1379) * chore: Simpify BulkWriter * Add test back * Use tail pointer * Doc fixes * Update write-batch.ts * Update bulk-writer.ts * Deflake test * Update docs * Docs * Lint * Feedback --- dev/src/bulk-writer.ts | 542 ++++++++++++++--------------------- dev/src/write-batch.ts | 15 +- dev/system-test/firestore.ts | 3 +- dev/test/bulk-writer.ts | 35 ++- types/firestore.d.ts | 5 +- 5 files changed, 240 insertions(+), 360 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 3021c099b..03187ed53 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -27,10 +27,11 @@ import { Deferred, getRetryCodes, isObject, + requestTag, silencePromise, wrapError, } from './util'; -import {BatchWriteResult, WriteBatch, WriteResult} from './write-batch'; +import {WriteBatch, WriteResult} from './write-batch'; import { invalidArgumentMessage, validateInteger, @@ -71,16 +72,85 @@ const RATE_LIMITER_MULTIPLIER = 1.5; */ const RATE_LIMITER_MULTIPLIER_MILLIS = 5 * 60 * 1000; -/*! - * Used to represent the state of batch. - * - * Writes can only be added while the batch is OPEN. For a batch to be sent, - * the batch must be READY_TO_SEND. After a batch is sent, it is marked as SENT. +/** + * Represents a single write for BulkWriter, encapsulating operation dispatch + * and error handling. + * @private */ -enum BatchState { - OPEN, - READY_TO_SEND, - SENT, +class BulkWriterOperation { + private deferred = new Deferred(); + private failedAttempts = 0; + + /** + * @param ref The document reference being written to. + * @param type The type of operation that created this write. + * @param op A closure that encapsulates the API call which adds this write to + * a BulkCommitBatch. + * @param sendFn A callback to invoke when the operation should be sent. + * @param errorFn The user provided global error callback. + * @param successFn The user provided global success callback. + */ + constructor( + readonly ref: firestore.DocumentReference, + private readonly type: 'create' | 'set' | 'update' | 'delete', + private readonly op: (bulkCommitBatch: BulkCommitBatch) => void, + private readonly sendFn: (op: BulkWriterOperation) => void, + private readonly errorFn: (error: BulkWriterError) => boolean, + private readonly successFn: ( + ref: firestore.DocumentReference, + result: WriteResult + ) => void + ) {} + + get promise(): Promise { + return this.deferred.promise; + } + + run(batch: BulkCommitBatch): void { + this.op(batch); + } + + onError(error: GoogleError): void { + ++this.failedAttempts; + + try { + const bulkWriterError = new BulkWriterError( + (error.code as number) as GrpcStatus, + error.message, + this.ref, + this.type, + this.failedAttempts + ); + const shouldRetry = this.errorFn(bulkWriterError); + logger( + 'BulkWriter.errorFn', + null, + 'Ran error callback on error code:', + error.code, + ', shouldRetry:', + shouldRetry, + ' for document:', + this.ref.path + ); + + if (shouldRetry) { + this.sendFn(this); + } else { + this.deferred.reject(bulkWriterError); + } + } catch (userCallbackError) { + this.deferred.reject(userCallbackError); + } + } + + onSuccess(result: WriteResult): void { + try { + this.successFn(this.ref, result); + this.deferred.resolve(result); + } catch (userCallbackError) { + this.deferred.reject(userCallbackError); + } + } } /** @@ -89,134 +159,77 @@ enum BatchState { * @private */ class BulkCommitBatch extends WriteBatch { - /** - * The state of the batch. - */ - private state = BatchState.OPEN; - // The set of document reference paths present in the WriteBatch. readonly docPaths = new Set(); // An array of pending write operations. Only contains writes that have not // been resolved. - private pendingOps: Array> = []; - - constructor(firestore: Firestore, readonly maxBatchSize: number) { - super(firestore); - } + private pendingOps: Array = []; - has(documentRef: firestore.DocumentReference): boolean { + has(documentRef: firestore.DocumentReference): boolean { return this.docPaths.has(documentRef.path); } - markReadyToSend(): void { - if (this.state === BatchState.OPEN) { - this.state = BatchState.READY_TO_SEND; - } - } - - isOpen(): boolean { - return this.state === BatchState.OPEN; - } - - isReadyToSend(): boolean { - return this.state === BatchState.READY_TO_SEND; - } - - async bulkCommit(): Promise { - assert( - this.state === BatchState.READY_TO_SEND, - 'The batch should be marked as READY_TO_SEND before committing' - ); - this.state = BatchState.SENT; + async bulkCommit(options: {requestTag?: string} = {}): Promise { + const tag = options?.requestTag ?? requestTag(); // Capture the error stack to preserve stack tracing across async calls. const stack = Error().stack!; - let results: BatchWriteResult[] = []; + let response: api.IBatchWriteResponse; try { + logger( + 'BulkCommitBatch.bulkCommit', + tag, + `Sending next batch with ${this._opCount} writes` + ); const retryCodes = getRetryCodes('batchWrite'); - const response = await this._commit< + response = await this._commit< api.BatchWriteRequest, api.BatchWriteResponse - >({retryCodes, methodName: 'batchWrite'}); + >({retryCodes, methodName: 'batchWrite', requestTag: tag}); + } catch (err) { + // Map the failure to each individual write's result. + const ops = Array.from({length: this.pendingOps.length}); + response = { + writeResults: ops.map(() => { + return {}; + }), + status: ops.map(() => err), + }; + } - results = response.writeResults.map((result, i) => { - const status = response.status[i]; + for (let i = 0; i < (response.writeResults || []).length; ++i) { + // 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.fromMillis(0); + + const status = (response.status || [])[i]; + if (status.code === Status.OK) { + const updateTime = Timestamp.fromProto( + response.writeResults![i].updateTime || DELETE_TIMESTAMP_SENTINEL + ); + this.pendingOps[i].onSuccess(new WriteResult(updateTime)); + } else { const error = new GoogleError(status.message || undefined); error.code = status.code as Status; - - // 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.fromMillis(0); - const updateTime = - error.code === Status.OK - ? Timestamp.fromProto( - result.updateTime || DELETE_TIMESTAMP_SENTINEL - ) - : null; - return new BatchWriteResult(updateTime, error); - }); - } catch (err) { - // Map the failure to each individual write's result. - results = this.pendingOps.map(() => { - return { - writeTime: null, - status: wrapError(err, stack), - }; - }); + this.pendingOps[i].onError(wrapError(error, stack)); + } } - return this.processResults(results); } /** * Helper to update data structures associated with the operation and returns * the result. */ - processLastOperation( - documentRef: firestore.DocumentReference - ): Promise { + processLastOperation(op: BulkWriterOperation): void { assert( - !this.docPaths.has(documentRef.path), + !this.docPaths.has(op.ref.path), 'Batch should not contain writes to the same document' ); - this.docPaths.add(documentRef.path); - assert( - this.state === BatchState.OPEN, - 'Batch should be OPEN when adding writes' - ); - const deferred = new Deferred(); - this.pendingOps.push(deferred); - - if (this._opCount === this.maxBatchSize) { - this.state = BatchState.READY_TO_SEND; - } - - return deferred.promise.then(result => { - if (result.writeTime) { - return new WriteResult(result.writeTime); - } else { - throw result.status; - } - }); - } - - /** - * Resolves the individual operations in the batch with the results. - */ - private async processResults(results: BatchWriteResult[]): Promise { - await Promise.all( - results.map((result, i) => { - const op = this.pendingOps[i]; - if (result.status.code === Status.OK) { - op.resolve(result); - } else { - op.reject(result.status); - } - return silencePromise(op.promise); - }) - ); + this.docPaths.add(op.ref.path); + this.pendingOps.push(op); } } @@ -235,7 +248,7 @@ export class BulkWriterError extends Error { readonly message: string, /** The document reference the operation was performed on. */ - readonly documentRef: firestore.DocumentReference, + readonly documentRef: firestore.DocumentReference, /** The type of operation performed. */ readonly operationType: 'create' | 'set' | 'update' | 'delete', @@ -256,45 +269,39 @@ export class BulkWriterError extends Error { export class BulkWriter { /** * The maximum number of writes that can be in a single batch. + * Visible for testing. + * @private */ - private _maxBatchSize = MAX_BATCH_SIZE; - - /** - * A queue of batches to be written. - */ - private _batchQueue: BulkCommitBatch[] = []; - - /** - * A queue of batches containing operations that need to be retried. - */ - private _retryBatchQueue: BulkCommitBatch[] = []; + _maxBatchSize = MAX_BATCH_SIZE; /** - * A list of promises that represent sent batches. Each promise is resolved - * when the batch's response is received. This includes batches from both the - * batchQueue and retryBatchQueue. + * The batch that is currently used to schedule operations. Once this batch + * reaches maximum capacity, a new batch is created. + * @private */ - private _pendingBatches: Set> = new Set(); + private _bulkCommitBatch = new BulkCommitBatch(this.firestore); /** - * A list of promises that represent pending BulkWriter operations. Each - * promise is resolved when the BulkWriter operation resolves. This set - * includes retries. Each retry's promise is added, attempted, and removed - * from this set before scheduling the next retry. + * A pointer to the tail of all active BulkWriter applications. This pointer + * is advanced every time a new write is enqueued. + * @private */ - private _pendingOps: Set> = new Set(); + private _lastOp: Promise = Promise.resolve(); /** * Whether this BulkWriter instance has started to close. Afterwards, no * new operations can be enqueued, except for retry operations scheduled by * the error handler. + * @private */ private _closing = false; /** * Rate limiter used to throttle requests as per the 500/50/5 rule. + * Visible for testing. + * @private */ - private readonly _rateLimiter: RateLimiter; + readonly _rateLimiter: RateLimiter; /** * The user-provided callback to be run every time a BulkWriter operation @@ -302,7 +309,7 @@ export class BulkWriter { * @private */ private _successFn: ( - document: firestore.DocumentReference, + document: firestore.DocumentReference, result: WriteResult ) => void = () => {}; @@ -401,8 +408,8 @@ export class BulkWriter { documentRef: firestore.DocumentReference, data: T ): Promise { - this.verifyNotClosed(); - const op = this._executeWrite(documentRef, 'create', bulkCommitBatch => + this._verifyNotClosed(); + const op = this._enqueue(documentRef, 'create', bulkCommitBatch => bulkCommitBatch.create(documentRef, data) ); silencePromise(op); @@ -441,8 +448,8 @@ export class BulkWriter { documentRef: firestore.DocumentReference, precondition?: firestore.Precondition ): Promise { - this.verifyNotClosed(); - const op = this._executeWrite(documentRef, 'delete', bulkCommitBatch => + this._verifyNotClosed(); + const op = this._enqueue(documentRef, 'delete', bulkCommitBatch => bulkCommitBatch.delete(documentRef, precondition) ); silencePromise(op); @@ -498,8 +505,8 @@ export class BulkWriter { data: T | Partial, options?: firestore.SetOptions ): Promise { - this.verifyNotClosed(); - const op = this._executeWrite(documentRef, 'set', bulkCommitBatch => + this._verifyNotClosed(); + const op = this._enqueue(documentRef, 'set', bulkCommitBatch => bulkCommitBatch.set(documentRef, data, options) ); silencePromise(op); @@ -548,14 +555,14 @@ export class BulkWriter { * }); */ update( - documentRef: firestore.DocumentReference, + documentRef: firestore.DocumentReference, dataOrField: firestore.UpdateData | string | FieldPath, ...preconditionOrValues: Array< {lastUpdateTime?: Timestamp} | unknown | string | FieldPath > ): Promise { - this.verifyNotClosed(); - const op = this._executeWrite(documentRef, 'update', bulkCommitBatch => + this._verifyNotClosed(); + const op = this._enqueue(documentRef, 'update', bulkCommitBatch => bulkCommitBatch.update(documentRef, dataOrField, ...preconditionOrValues) ); silencePromise(op); @@ -583,7 +590,7 @@ export class BulkWriter { */ onWriteResult( callback: ( - documentRef: firestore.DocumentReference, + documentRef: firestore.DocumentReference, result: WriteResult ) => void ): void { @@ -647,30 +654,9 @@ export class BulkWriter { * }); */ flush(): Promise { - this.verifyNotClosed(); - - // Copy the pending ops at the time flush() was called. - return this._flush(Array.from(this._pendingOps)); - } - - private async _flush(pendingOps: Array>): Promise { - let batchQueue = this._batchQueue; - batchQueue.forEach(batch => batch.markReadyToSend()); - - // Send all scheduled operations on the BatchQueue first. - this.sendReadyBatches(batchQueue); - await Promise.all(this._pendingBatches); - - // Afterwards, send all accumulated retry operations. Wait until the - // retryBatchQueue is cleared. This way, operations scheduled after - // flush() will not be sent until the retries are completed. - batchQueue = this._retryBatchQueue; - if (batchQueue.length > 0) { - batchQueue.forEach(batch => batch.markReadyToSend()); - this.sendReadyBatches(batchQueue); - } - // Make sure user promises resolve before flush() resolves. - return silencePromise(Promise.all(pendingOps)); + this._verifyNotClosed(); + this._sendCurrentBatch(/* flush= */ true); + return this._lastOp; } /** @@ -698,7 +684,7 @@ export class BulkWriter { * }); */ close(): Promise { - this.verifyNotClosed(); + this._verifyNotClosed(); this.firestore._decrementBulkWritersCount(); const flushPromise = this.flush(); this._closing = true; @@ -709,195 +695,99 @@ export class BulkWriter { * Throws an error if the BulkWriter instance has been closed. * @private */ - private verifyNotClosed(): void { + private _verifyNotClosed(): void { if (this._closing) { throw new Error('BulkWriter has already been closed.'); } } /** - * Return the first eligible batch that can hold a write to the provided - * reference, or creates one if no eligible batches are found. + * Sends the current batch and resets `this._bulkCommitBatch`. * + * @param flush If provided, keeps re-sending operations until no more + * operations are enqueued. This allows retries to resolve as part of a + * `flush()` or `close()` call. * @private */ - private getEligibleBatch( - documentRef: firestore.DocumentReference, - batchQueue: BulkCommitBatch[] - ): BulkCommitBatch { - if (batchQueue.length > 0) { - const lastBatch = batchQueue[batchQueue.length - 1]; - if (lastBatch.isOpen() && !lastBatch.has(documentRef)) { - return lastBatch; - } - } + private _sendCurrentBatch(flush = false): void { + if (this._bulkCommitBatch._opCount === 0) return; - return this.createNewBatch(batchQueue); - } - - /** - * Creates a new batch and adds it to the appropriate batch queue. If there - * is already a batch enqueued, sends the batch after a new one is created. - * - * @private - */ - private createNewBatch(batchQueue: BulkCommitBatch[]): BulkCommitBatch { - const newBatch = new BulkCommitBatch(this.firestore, this._maxBatchSize); + const tag = requestTag(); + const pendingBatch = this._bulkCommitBatch; - if (batchQueue.length > 0) { - batchQueue[batchQueue.length - 1].markReadyToSend(); - this.sendReadyBatches(batchQueue); - } + this._bulkCommitBatch = new BulkCommitBatch(this.firestore); - batchQueue.push(newBatch); - return newBatch; - } + // Send the batch if it is under the rate limit, or schedule another + // attempt after the appropriate timeout. + const underRateLimit = this._rateLimiter.tryMakeRequest( + pendingBatch._opCount + ); - /** - * Attempts to send batches starting from the front of the provided batch - * queue until a batch cannot be sent. - * - * After a batch is complete, try sending batches again. - * - * @private - */ - private sendReadyBatches(batchQueue: BulkCommitBatch[]): void { - let index = 0; - while (index < batchQueue.length && batchQueue[index].isReadyToSend()) { - const batch = batchQueue[index]; - - // Deferred promise that resolves when the current batch or its - // scheduling attempt completes. - const batchCompletedDeferred = new Deferred(); - this._pendingBatches.add(batchCompletedDeferred.promise); - - // Send the batch if it is under the rate limit, or schedule another - // attempt after the appropriate timeout. - const delayMs = this._rateLimiter.getNextRequestDelayMs(batch._opCount); - assert(delayMs !== -1, 'Batch size should be under capacity'); - if (delayMs === 0) { - this.sendBatch(batch, batchQueue, batchCompletedDeferred); - } else { - delayExecution(() => { - this.sendReadyBatches(batchQueue); - batchCompletedDeferred.resolve(); - this._pendingBatches.delete(batchCompletedDeferred.promise); - }, delayMs); - break; - } - index++; + const delayedExecution = new Deferred(); + if (underRateLimit) { + delayedExecution.resolve(); + } else { + const delayMs = this._rateLimiter.getNextRequestDelayMs( + pendingBatch._opCount + ); + logger( + 'BulkWriter._sendCurrentBatch', + tag, + `Backing off for ${delayMs} seconds` + ); + delayExecution(() => delayedExecution.resolve(), delayMs); } - } - - /** - * Sends the provided batch and processes the results. After the batch is - * committed, sends the next group of ready batches. - * - * @param batchCompletedDeferred A deferred promise that resolves when the - * batch has been sent and received. - * @private - */ - private sendBatch( - batch: BulkCommitBatch, - batchQueue: BulkCommitBatch[], - batchCompletedDeferred: Deferred - ): void { - const success = this._rateLimiter.tryMakeRequest(batch._opCount); - assert(success, 'Batch should be under rate limit to be sent.'); - batch.bulkCommit().then(() => { - // Remove the batch from the BatchQueue after it has been processed. - const batchIndex = batchQueue.indexOf(batch); - assert(batchIndex !== -1, 'The batch should be in the BatchQueue'); - batchQueue.splice(batchIndex, 1); - - if (batchQueue === this._retryBatchQueue) { - batchQueue.forEach(batch => batch.markReadyToSend()); - } - - batchCompletedDeferred.resolve(); - this._pendingBatches.delete(batchCompletedDeferred.promise); - this.sendReadyBatches(batchQueue); + delayedExecution.promise.then(async () => { + await pendingBatch.bulkCommit({requestTag: tag}); + if (flush) this._sendCurrentBatch(flush); }); } /** - * Schedules and runs the provided operation. + * Schedules and runs the provided operation on the next available batch. * @private */ - private async _executeWrite( - documentRef: firestore.DocumentReference, - operationType: 'create' | 'set' | 'update' | 'delete', - operationFn: (bulkCommitBatch: BulkCommitBatch) => void + private _enqueue( + ref: firestore.DocumentReference, + type: 'create' | 'set' | 'update' | 'delete', + op: (bulkCommitBatch: BulkCommitBatch) => void ): Promise { - // A deferred promise that resolves when operationFn completes. - const operationCompletedDeferred = new Deferred(); - this._pendingOps.add(operationCompletedDeferred.promise); - try { - for (let failedAttempts = 0; ; ++failedAttempts) { - const batchQueue = - failedAttempts > 0 ? this._retryBatchQueue : this._batchQueue; - const bulkCommitBatch = this.getEligibleBatch(documentRef, batchQueue); - - // Send ready batches if this is the first attempt. Subsequent retry - // batches are scheduled after the initial batch returns. - if (failedAttempts === 0) { - this.sendReadyBatches(batchQueue); - } - - try { - operationFn(bulkCommitBatch); - const operationResult = await bulkCommitBatch.processLastOperation( - documentRef - ); - this._successFn(documentRef, operationResult); - return operationResult; - } catch (error) { - const bulkWriterError = new BulkWriterError( - error.code, - error.message, - documentRef, - operationType, - failedAttempts - ); - const shouldRetry = this._errorFn(bulkWriterError); - logger( - 'BulkWriter.errorFn', - null, - 'Running error callback on error code:', - error.code, - ', shouldRetry:', - shouldRetry - ); - if (!shouldRetry) { - throw bulkWriterError; - } - } - } - } finally { - operationCompletedDeferred.resolve(); - this._pendingOps.delete(operationCompletedDeferred.promise); - } + const bulkWriterOp = new BulkWriterOperation( + ref, + type, + op, + this._sendFn.bind(this), + this._errorFn.bind(this), + this._successFn.bind(this) + ); + this._sendFn(bulkWriterOp); + return bulkWriterOp.promise; } /** - * Sets the maximum number of allowed operations in a batch. + * Schedules the provided operations on current BulkCommitBatch. + * Sends the BulkCommitBatch if it reaches maximum capacity. * * @private */ - // Visible for testing. - _setMaxBatchSize(size: number): void { - this._maxBatchSize = size; - } + _sendFn(op: BulkWriterOperation): void { + if (this._bulkCommitBatch.has(op.ref)) { + // Create a new batch since the backend doesn't support batches with two + // writes to the same document. + this._sendCurrentBatch(); + } - /** - * Returns the rate limiter for testing. - * - * @private - */ - // Visible for testing. - _getRateLimiter(): RateLimiter { - return this._rateLimiter; + // Run the operation on the current batch and advance the `_lastOp` pointer. + // This ensures that `_lastOp` only resolves when both the previous and the + // current write resolves. + op.run(this._bulkCommitBatch); + this._bulkCommitBatch.processLastOperation(op); + this._lastOp = this._lastOp.then(() => silencePromise(op.promise)); + + if (this._bulkCommitBatch._opCount === this._maxBatchSize) { + this._sendCurrentBatch(); + } } } diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 08f5b2825..60e721772 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -45,7 +45,7 @@ import { validateMinNumberOfArguments, validateOptional, } from './validate'; -import {GoogleError, Status} from 'google-gax'; +import {Status} from 'google-gax'; import api = google.firestore.v1; /** @@ -95,19 +95,6 @@ export class WriteResult implements firestore.WriteResult { } } -/** - * A BatchWriteResult wraps the write time and status returned by Firestore - * when making BatchWriteRequests. - * - * @private - */ -export class BatchWriteResult { - constructor( - readonly writeTime: Timestamp | null, - readonly status: GoogleError - ) {} -} - /** * A lazily-evaluated write that allows us to detect the Project ID before * serializing the request. diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 9ea567fec..b12a5a4c4 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -2613,7 +2613,8 @@ describe('BulkWriter class', () => { const op2 = writer.set(ref, {foo: 'bar2'}); await writer.close(); const result = await ref.get(); - expect(result.data()).to.deep.equal({foo: 'bar2'}); + // The order of writes is not guaranteed. + expect(result.get('foo')).to.not.be.undefined; const writeTime1 = (await op1).writeTime; const writeTime2 = (await op2).writeTime; expect(writeTime1).to.not.be.null; diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index 6e2b35256..2fa241734 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -239,50 +239,50 @@ describe('BulkWriter', () => { let bulkWriter = firestore.bulkWriter({ throttling: {initialOpsPerSecond: 500, maxOpsPerSecond: 550}, }); - expect(bulkWriter._getRateLimiter().availableTokens).to.equal(500); - expect(bulkWriter._getRateLimiter().maximumCapacity).to.equal(550); + expect(bulkWriter._rateLimiter.availableTokens).to.equal(500); + expect(bulkWriter._rateLimiter.maximumCapacity).to.equal(550); bulkWriter = firestore.bulkWriter({ throttling: {maxOpsPerSecond: 1000}, }); - expect(bulkWriter._getRateLimiter().availableTokens).to.equal(500); - expect(bulkWriter._getRateLimiter().maximumCapacity).to.equal(1000); + expect(bulkWriter._rateLimiter.availableTokens).to.equal(500); + expect(bulkWriter._rateLimiter.maximumCapacity).to.equal(1000); bulkWriter = firestore.bulkWriter({ throttling: {initialOpsPerSecond: 100}, }); - expect(bulkWriter._getRateLimiter().availableTokens).to.equal(100); - expect(bulkWriter._getRateLimiter().maximumCapacity).to.equal( + expect(bulkWriter._rateLimiter.availableTokens).to.equal(100); + expect(bulkWriter._rateLimiter.maximumCapacity).to.equal( Number.POSITIVE_INFINITY ); bulkWriter = firestore.bulkWriter({ throttling: {maxOpsPerSecond: 100}, }); - expect(bulkWriter._getRateLimiter().availableTokens).to.equal(100); - expect(bulkWriter._getRateLimiter().maximumCapacity).to.equal(100); + expect(bulkWriter._rateLimiter.availableTokens).to.equal(100); + expect(bulkWriter._rateLimiter.maximumCapacity).to.equal(100); bulkWriter = firestore.bulkWriter(); - expect(bulkWriter._getRateLimiter().availableTokens).to.equal( + expect(bulkWriter._rateLimiter.availableTokens).to.equal( DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND ); - expect(bulkWriter._getRateLimiter().maximumCapacity).to.equal( + expect(bulkWriter._rateLimiter.maximumCapacity).to.equal( Number.POSITIVE_INFINITY ); bulkWriter = firestore.bulkWriter({throttling: true}); - expect(bulkWriter._getRateLimiter().availableTokens).to.equal( + expect(bulkWriter._rateLimiter.availableTokens).to.equal( DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND ); - expect(bulkWriter._getRateLimiter().maximumCapacity).to.equal( + expect(bulkWriter._rateLimiter.maximumCapacity).to.equal( Number.POSITIVE_INFINITY ); bulkWriter = firestore.bulkWriter({throttling: false}); - expect(bulkWriter._getRateLimiter().availableTokens).to.equal( + expect(bulkWriter._rateLimiter.availableTokens).to.equal( Number.POSITIVE_INFINITY ); - expect(bulkWriter._getRateLimiter().maximumCapacity).to.equal( + expect(bulkWriter._rateLimiter.maximumCapacity).to.equal( Number.POSITIVE_INFINITY ); }); @@ -701,7 +701,7 @@ describe('BulkWriter', () => { bulkWriter.set(firestore.doc('collectionId/doc'), {foo: 'bar'}).then(() => { ops.push('before_flush'); }); - const flush = bulkWriter.flush().then(() => { + await bulkWriter.flush().then(() => { ops.push('flush'); }); bulkWriter @@ -710,7 +710,6 @@ describe('BulkWriter', () => { ops.push('after_flush'); }); - await flush; expect(ops).to.deep.equal(['before_flush', 'flush']); return bulkWriter.close().then(() => { expect(ops).to.deep.equal(['before_flush', 'flush', 'after_flush']); @@ -768,7 +767,7 @@ describe('BulkWriter', () => { }, ]); - bulkWriter._setMaxBatchSize(2); + bulkWriter._maxBatchSize = 2; for (let i = 0; i < 6; i++) { bulkWriter .set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}) @@ -800,7 +799,7 @@ describe('BulkWriter', () => { }, ]); - bulkWriter._setMaxBatchSize(3); + bulkWriter._maxBatchSize = 3; const promise1 = bulkWriter .set(firestore.doc('collectionId/doc1'), {foo: 'bar'}) .then(incrementOpCount); diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 34481e923..d4cf4ca5b 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -616,7 +616,10 @@ declare namespace FirebaseFirestore { * successfully completes. */ onWriteResult( - callback: (documentRef: DocumentReference, result: WriteResult) => void + callback: ( + documentRef: DocumentReference, + result: WriteResult + ) => void ): void; /** From 5b43e7bcb2ea9c014587c84164f9ba8a0ed05397 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Mon, 21 Dec 2020 10:58:02 -0800 Subject: [PATCH 229/337] feat: adds UNORDERED_LIST type (#1382) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/87402f31-167a-4401-921b-ef7b42214066/targets - [ ] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 348046114 Source-Link: https://github.com/googleapis/googleapis/commit/15af12eb717cd30175825ad412045b9e59b133b4 --- dev/protos/firestore_admin_v1_proto_api.d.ts | 2 +- dev/protos/firestore_admin_v1_proto_api.js | 6 +++++ dev/protos/firestore_v1_proto_api.d.ts | 2 +- dev/protos/firestore_v1_proto_api.js | 6 +++++ dev/protos/firestore_v1beta1_proto_api.d.ts | 2 +- dev/protos/firestore_v1beta1_proto_api.js | 6 +++++ dev/protos/google/api/field_behavior.proto | 6 +++++ dev/src/v1beta1/firestore_client_config.json | 23 ++++++++++++-------- synth.metadata | 6 ++--- 9 files changed, 44 insertions(+), 15 deletions(-) diff --git a/dev/protos/firestore_admin_v1_proto_api.d.ts b/dev/protos/firestore_admin_v1_proto_api.d.ts index f751574e3..343b4cf63 100644 --- a/dev/protos/firestore_admin_v1_proto_api.d.ts +++ b/dev/protos/firestore_admin_v1_proto_api.d.ts @@ -1686,7 +1686,7 @@ export namespace google { /** FieldBehavior enum. */ type FieldBehavior = - "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"; + "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"; /** Properties of a ResourceDescriptor. */ interface IResourceDescriptor { diff --git a/dev/protos/firestore_admin_v1_proto_api.js b/dev/protos/firestore_admin_v1_proto_api.js index 92a195249..8fe6ecefd 100644 --- a/dev/protos/firestore_admin_v1_proto_api.js +++ b/dev/protos/firestore_admin_v1_proto_api.js @@ -3930,6 +3930,7 @@ * @property {string} OUTPUT_ONLY=OUTPUT_ONLY OUTPUT_ONLY value * @property {string} INPUT_ONLY=INPUT_ONLY INPUT_ONLY value * @property {string} IMMUTABLE=IMMUTABLE IMMUTABLE value + * @property {string} UNORDERED_LIST=UNORDERED_LIST UNORDERED_LIST value */ api.FieldBehavior = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -3939,6 +3940,7 @@ values[valuesById[3] = "OUTPUT_ONLY"] = "OUTPUT_ONLY"; values[valuesById[4] = "INPUT_ONLY"] = "INPUT_ONLY"; values[valuesById[5] = "IMMUTABLE"] = "IMMUTABLE"; + values[valuesById[6] = "UNORDERED_LIST"] = "UNORDERED_LIST"; return values; })(); @@ -6913,6 +6915,10 @@ case 5: message[".google.api.fieldBehavior"][i] = 5; break; + case "UNORDERED_LIST": + case 6: + message[".google.api.fieldBehavior"][i] = 6; + break; } } if (object[".google.api.resourceReference"] != null) { diff --git a/dev/protos/firestore_v1_proto_api.d.ts b/dev/protos/firestore_v1_proto_api.d.ts index 5757a58ec..1578badfd 100644 --- a/dev/protos/firestore_v1_proto_api.d.ts +++ b/dev/protos/firestore_v1_proto_api.d.ts @@ -6369,7 +6369,7 @@ export namespace google { /** FieldBehavior enum. */ type FieldBehavior = - "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"; + "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"; /** Properties of a ResourceDescriptor. */ interface IResourceDescriptor { diff --git a/dev/protos/firestore_v1_proto_api.js b/dev/protos/firestore_v1_proto_api.js index f85efa164..b6f971dc4 100644 --- a/dev/protos/firestore_v1_proto_api.js +++ b/dev/protos/firestore_v1_proto_api.js @@ -3520,6 +3520,10 @@ case 5: message[".google.api.fieldBehavior"][i] = 5; break; + case "UNORDERED_LIST": + case 6: + message[".google.api.fieldBehavior"][i] = 6; + break; } } if (object[".google.api.resourceReference"] != null) { @@ -15387,6 +15391,7 @@ * @property {string} OUTPUT_ONLY=OUTPUT_ONLY OUTPUT_ONLY value * @property {string} INPUT_ONLY=INPUT_ONLY INPUT_ONLY value * @property {string} IMMUTABLE=IMMUTABLE IMMUTABLE value + * @property {string} UNORDERED_LIST=UNORDERED_LIST UNORDERED_LIST value */ api.FieldBehavior = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -15396,6 +15401,7 @@ values[valuesById[3] = "OUTPUT_ONLY"] = "OUTPUT_ONLY"; values[valuesById[4] = "INPUT_ONLY"] = "INPUT_ONLY"; values[valuesById[5] = "IMMUTABLE"] = "IMMUTABLE"; + values[valuesById[6] = "UNORDERED_LIST"] = "UNORDERED_LIST"; return values; })(); diff --git a/dev/protos/firestore_v1beta1_proto_api.d.ts b/dev/protos/firestore_v1beta1_proto_api.d.ts index 772eedff8..d05faadbb 100644 --- a/dev/protos/firestore_v1beta1_proto_api.d.ts +++ b/dev/protos/firestore_v1beta1_proto_api.d.ts @@ -5800,7 +5800,7 @@ export namespace google { /** FieldBehavior enum. */ type FieldBehavior = - "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"; + "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"; /** Properties of a ResourceDescriptor. */ interface IResourceDescriptor { diff --git a/dev/protos/firestore_v1beta1_proto_api.js b/dev/protos/firestore_v1beta1_proto_api.js index 4887a4bcd..aae7c0d9e 100644 --- a/dev/protos/firestore_v1beta1_proto_api.js +++ b/dev/protos/firestore_v1beta1_proto_api.js @@ -2783,6 +2783,10 @@ case 5: message[".google.api.fieldBehavior"][i] = 5; break; + case "UNORDERED_LIST": + case 6: + message[".google.api.fieldBehavior"][i] = 6; + break; } } if (object[".google.api.resourceReference"] != null) { @@ -13993,6 +13997,7 @@ * @property {string} OUTPUT_ONLY=OUTPUT_ONLY OUTPUT_ONLY value * @property {string} INPUT_ONLY=INPUT_ONLY INPUT_ONLY value * @property {string} IMMUTABLE=IMMUTABLE IMMUTABLE value + * @property {string} UNORDERED_LIST=UNORDERED_LIST UNORDERED_LIST value */ api.FieldBehavior = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -14002,6 +14007,7 @@ values[valuesById[3] = "OUTPUT_ONLY"] = "OUTPUT_ONLY"; values[valuesById[4] = "INPUT_ONLY"] = "INPUT_ONLY"; values[valuesById[5] = "IMMUTABLE"] = "IMMUTABLE"; + values[valuesById[6] = "UNORDERED_LIST"] = "UNORDERED_LIST"; return values; })(); diff --git a/dev/protos/google/api/field_behavior.proto b/dev/protos/google/api/field_behavior.proto index aa7127bf8..686667954 100644 --- a/dev/protos/google/api/field_behavior.proto +++ b/dev/protos/google/api/field_behavior.proto @@ -75,4 +75,10 @@ enum FieldBehavior { // This indicates that the field may be set once in a request to create a // resource, but may not be changed thereafter. IMMUTABLE = 5; + + // Denotes that a (repeated) field is an unordered list. + // This indicates that the service may provide the elements of the list + // in any arbitrary order, rather than the order the user originally + // provided. Additionally, the list's order may or may not be stable. + UNORDERED_LIST = 6; } diff --git a/dev/src/v1beta1/firestore_client_config.json b/dev/src/v1beta1/firestore_client_config.json index 85e682aff..f180f8359 100644 --- a/dev/src/v1beta1/firestore_client_config.json +++ b/dev/src/v1beta1/firestore_client_config.json @@ -6,6 +6,11 @@ "idempotent": [ "DEADLINE_EXCEEDED", "UNAVAILABLE" + ], + "deadline_exceeded_resource_exhausted_unavailable": [ + "DEADLINE_EXCEEDED", + "RESOURCE_EXHAUSTED", + "UNAVAILABLE" ] }, "retry_params": { @@ -22,12 +27,12 @@ "methods": { "GetDocument": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", "retry_params_name": "default" }, "ListDocuments": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", "retry_params_name": "default" }, "CreateDocument": { @@ -42,17 +47,17 @@ }, "DeleteDocument": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", "retry_params_name": "default" }, "BatchGetDocuments": { "timeout_millis": 300000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", "retry_params_name": "default" }, "BeginTransaction": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", "retry_params_name": "default" }, "Commit": { @@ -62,12 +67,12 @@ }, "Rollback": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", "retry_params_name": "default" }, "RunQuery": { "timeout_millis": 300000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", "retry_params_name": "default" }, "Write": { @@ -77,12 +82,12 @@ }, "Listen": { "timeout_millis": 86400000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", "retry_params_name": "default" }, "ListCollectionIds": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", + "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", "retry_params_name": "default" } } diff --git a/synth.metadata b/synth.metadata index 468ce2d75..2ac2b1437 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "30b8a1b2c74dec423ac6b54c8448055deee03053" + "sha": "f4899ce04a63a8feec4f372d0a36f875d70cfa75" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "d189e871205fea665a9648f7c4676f027495ccaf", - "internalRef": "345596855" + "sha": "15af12eb717cd30175825ad412045b9e59b133b4", + "internalRef": "348046114" } }, { From 5af24cd2633ab5841a25ad698cbb1ef91cdc4142 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 22 Dec 2020 11:42:16 -0800 Subject: [PATCH 230/337] docs: add instructions for authenticating for system tests (#1384) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/9610e861-65a2-4035-85ab-1303620c4597/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: https://github.com/googleapis/synthtool/commit/363fe305e9ce34a6cd53951c6ee5f997094b54ee --- CONTRIBUTING.md | 14 ++++++++++++-- README.md | 3 +-- synth.metadata | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f6c4cf010..29f371096 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,6 +37,14 @@ accept your pull requests. 1. Title your pull request following [Conventional Commits](https://www.conventionalcommits.org/) styling. 1. Submit a pull request. +### Before you begin + +1. [Select or create a Cloud Platform project][projects]. +1. [Enable the Cloud Firestore API][enable_api]. +1. [Set up authentication with a service account][auth] so you can access the + API from your local workstation. + + ## Running the tests 1. [Prepare your environment for Node.js setup][setup]. @@ -51,11 +59,9 @@ accept your pull requests. npm test # Run sample integration tests. - gcloud auth application-default login npm run samples-test # Run all system tests. - gcloud auth application-default login npm run system-test 1. Lint (and maybe fix) any changes: @@ -63,3 +69,7 @@ accept your pull requests. npm run fix [setup]: https://cloud.google.com/nodejs/docs/setup +[projects]: https://console.cloud.google.com/project +[billing]: https://support.google.com/cloud/answer/6293499#enable-billing +[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=firestore.googleapis.com +[auth]: https://cloud.google.com/docs/authentication/getting-started \ No newline at end of file diff --git a/README.md b/README.md index 24e116781..7591b996d 100644 --- a/README.md +++ b/README.md @@ -103,8 +103,7 @@ quickstart(); ## Samples -Samples are in the [`samples/`](https://github.com/googleapis/nodejs-firestore/tree/master/samples) directory. The samples' `README.md` -has instructions for running the samples. +Samples are in the [`samples/`](https://github.com/googleapis/nodejs-firestore/tree/master/samples) directory. Each sample's `README.md` has instructions for running its sample. | Sample | Source Code | Try it | | --------------------------- | --------------------------------- | ------ | diff --git a/synth.metadata b/synth.metadata index 2ac2b1437..c00e71c13 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "f4899ce04a63a8feec4f372d0a36f875d70cfa75" + "sha": "5b43e7bcb2ea9c014587c84164f9ba8a0ed05397" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "15013eff642a7e7e855aed5a29e6e83c39beba2a" + "sha": "363fe305e9ce34a6cd53951c6ee5f997094b54ee" } } ], From 75d9ece19bb4a9228d004b8fe4851422b6996ca7 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 1 Jan 2021 19:43:43 -0800 Subject: [PATCH 231/337] chore: update license headers (#1386) --- .jsdoc.js | 4 ++-- dev/src/v1/firestore_admin_client.ts | 2 +- dev/src/v1/firestore_client.ts | 2 +- dev/src/v1beta1/firestore_client.ts | 2 +- dev/test/gapic_firestore_admin_v1.ts | 2 +- dev/test/gapic_firestore_v1.ts | 2 +- dev/test/gapic_firestore_v1beta1.ts | 2 +- synth.metadata | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.jsdoc.js b/.jsdoc.js index 37e8492fa..c796b7836 100644 --- a/.jsdoc.js +++ b/.jsdoc.js @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ module.exports = { includePattern: '\\.js$' }, templates: { - copyright: 'Copyright 2020 Google LLC', + copyright: 'Copyright 2021 Google LLC', includeDate: false, sourceFiles: false, systemName: '@google-cloud/firestore', diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index 9a17482e1..e533909e2 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 0c6a737e5..867c933ec 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index 4e87302f7..d3834a18d 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/dev/test/gapic_firestore_admin_v1.ts b/dev/test/gapic_firestore_admin_v1.ts index 2f87b5d7f..b33525580 100644 --- a/dev/test/gapic_firestore_admin_v1.ts +++ b/dev/test/gapic_firestore_admin_v1.ts @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/dev/test/gapic_firestore_v1.ts b/dev/test/gapic_firestore_v1.ts index a0791a441..0b53c4062 100644 --- a/dev/test/gapic_firestore_v1.ts +++ b/dev/test/gapic_firestore_v1.ts @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/dev/test/gapic_firestore_v1beta1.ts b/dev/test/gapic_firestore_v1beta1.ts index 3b762c5e7..157dea64d 100644 --- a/dev/test/gapic_firestore_v1beta1.ts +++ b/dev/test/gapic_firestore_v1beta1.ts @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/synth.metadata b/synth.metadata index c00e71c13..61f6ad962 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "5b43e7bcb2ea9c014587c84164f9ba8a0ed05397" + "sha": "5af24cd2633ab5841a25ad698cbb1ef91cdc4142" } }, { From eb1b4dccf52b09ce395ba2ceabe02e84ee8e4dfd Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 8 Jan 2021 18:40:14 -0800 Subject: [PATCH 232/337] feat: introduces style enumeration (#1388) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/b142be3b-2141-4cc7-a8b9-761c589f1ba5/targets - [ ] To automatically regenerate this PR, check this box. --- dev/protos/protos.json | 13 ++++++++++++- synth.metadata | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dev/protos/protos.json b/dev/protos/protos.json index bc184dfa1..753b9b1f9 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -3822,6 +3822,11 @@ "singular": { "type": "string", "id": 6 + }, + "style": { + "rule": "repeated", + "type": "Style", + "id": 10 } }, "nested": { @@ -3831,6 +3836,12 @@ "ORIGINALLY_SINGLE_PATTERN": 1, "FUTURE_MULTI_PATTERN": 2 } + }, + "Style": { + "values": { + "STYLE_UNSPECIFIED": 0, + "DECLARATIVE_FRIENDLY": 1 + } } } }, @@ -3969,7 +3980,7 @@ }, "protobuf": { "options": { - "go_package": "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor", + "go_package": "google.golang.org/protobuf/types/descriptorpb", "java_package": "com.google.protobuf", "java_outer_classname": "DescriptorProtos", "csharp_namespace": "Google.Protobuf.Reflection", diff --git a/synth.metadata b/synth.metadata index 61f6ad962..358bb1e03 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "5af24cd2633ab5841a25ad698cbb1ef91cdc4142" + "sha": "75d9ece19bb4a9228d004b8fe4851422b6996ca7" } }, { From ab057f7b362a2929ebffa19e570d3e9cd23bc964 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Mon, 25 Jan 2021 14:39:52 -0800 Subject: [PATCH 233/337] feat: add support for applying default converter in withConverter() (#1394) --- dev/src/bulk-writer.ts | 4 ++-- dev/src/collection-group.ts | 14 +++++++++--- dev/src/reference.ts | 45 ++++++++++++++++++++++++++++--------- dev/test/collection.ts | 11 +++++++++ dev/test/document.ts | 11 +++++++++ dev/test/query.ts | 22 ++++++++++++++++++ types/firestore.d.ts | 16 +++++++++---- 7 files changed, 104 insertions(+), 19 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 03187ed53..69b6f745e 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -261,8 +261,8 @@ export class BulkWriterError extends Error { } /** - * A Firestore BulkWriter than can be used to perform a large number of writes - * in parallel. Writes to the same document will be executed sequentially. + * A Firestore BulkWriter that can be used to perform a large number of writes + * in parallel. * * @class BulkWriter */ diff --git a/dev/src/collection-group.ts b/dev/src/collection-group.ts index 73e6cb742..f3b2537db 100644 --- a/dev/src/collection-group.ts +++ b/dev/src/collection-group.ts @@ -26,6 +26,7 @@ import {Firestore} from './index'; import {validateInteger} from './validate'; import api = protos.google.firestore.v1; +import {defaultConverter} from './types'; /** * A `CollectionGroup` refers to all documents that are contained in a @@ -136,6 +137,9 @@ export class CollectionGroup * Using the converter allows you to specify generic type arguments when * storing and retrieving objects from Firestore. * + * Passing in `null` as the converter parameter removes the current + * converter. + * * @example * class Post { * constructor(readonly title: string, readonly author: string) {} @@ -168,18 +172,22 @@ export class CollectionGroup * post.someNonExistentProperty; // TS error * } * - * @param {FirestoreDataConverter} converter Converts objects to and from - * Firestore. + * @param {FirestoreDataConverter | null} converter Converts objects to and + * from Firestore. Passing in `null` removes the current converter. * @return {CollectionGroup} A `CollectionGroup` that uses the provided * converter. */ + withConverter(converter: null): CollectionGroup; withConverter( converter: firestore.FirestoreDataConverter + ): CollectionGroup; + withConverter( + converter: firestore.FirestoreDataConverter | null ): CollectionGroup { return new CollectionGroup( this.firestore, this._queryOptions.collectionId, - converter + converter ?? defaultConverter() ); } } diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 2c83227b0..c815dfc93 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -552,6 +552,9 @@ export class DocumentReference * Using the converter allows you to specify generic type arguments when * storing and retrieving objects from Firestore. * + * Passing in `null` as the converter parameter removes the current + * converter. + * * @example * class Post { * constructor(readonly title: string, readonly author: string) {} @@ -584,14 +587,22 @@ export class DocumentReference * post.someNonExistentProperty; // TS error * } * - * @param {FirestoreDataConverter} converter Converts objects to and from - * Firestore. + * @param {FirestoreDataConverter | null} converter Converts objects to and + * from Firestore. Passing in `null` removes the current converter. * @return A DocumentReference that uses the provided converter. */ + withConverter(converter: null): DocumentReference; withConverter( converter: firestore.FirestoreDataConverter + ): DocumentReference; + withConverter( + converter: firestore.FirestoreDataConverter | null ): DocumentReference { - return new DocumentReference(this.firestore, this._path, converter); + return new DocumentReference( + this.firestore, + this._path, + converter ?? defaultConverter() + ); } } @@ -2257,6 +2268,9 @@ export class Query implements firestore.Query { * Using the converter allows you to specify generic type arguments when * storing and retrieving objects from Firestore. * + * Passing in `null` as the converter parameter removes the current + * converter. + * * @example * class Post { * constructor(readonly title: string, readonly author: string) {} @@ -2289,14 +2303,18 @@ export class Query implements firestore.Query { * post.someNonExistentProperty; // TS error * } * - * @param {FirestoreDataConverter} converter Converts objects to and from - * Firestore. + * @param {FirestoreDataConverter | null} converter Converts objects to and + * from Firestore. Passing in `null` removes the current converter. * @return A Query that uses the provided converter. */ - withConverter(converter: firestore.FirestoreDataConverter): Query { + withConverter(converter: null): Query; + withConverter(converter: firestore.FirestoreDataConverter): Query; + withConverter( + converter: firestore.FirestoreDataConverter | null + ): Query { return new Query( this.firestore, - this._queryOptions.withConverter(converter) + this._queryOptions.withConverter(converter ?? defaultConverter()) ); } } @@ -2547,6 +2565,9 @@ export class CollectionReference * Using the converter allows you to specify generic type arguments when * storing and retrieving objects from Firestore. * + * Passing in `null` as the converter parameter removes the current + * converter. + * * @example * class Post { * constructor(readonly title: string, readonly author: string) {} @@ -2579,17 +2600,21 @@ export class CollectionReference * post.someNonExistentProperty; // TS error * } * - * @param {FirestoreDataConverter} converter Converts objects to and from - * Firestore. + * @param {FirestoreDataConverter | null} converter Converts objects to and + * from Firestore. Passing in `null` removes the current converter. * @return A CollectionReference that uses the provided converter. */ + withConverter(converter: null): CollectionReference; withConverter( converter: firestore.FirestoreDataConverter + ): CollectionReference; + withConverter( + converter: firestore.FirestoreDataConverter | null ): CollectionReference { return new CollectionReference( this.firestore, this.resourcePath, - converter + converter ?? defaultConverter() ); } } diff --git a/dev/test/collection.ts b/dev/test/collection.ts index d25e11e90..fb46e925d 100644 --- a/dev/test/collection.ts +++ b/dev/test/collection.ts @@ -277,6 +277,17 @@ describe('Collection interface', () => { }); }); + it('withConverter(null) applies the default converter', async () => { + return createInstance().then(async firestore => { + const docRef = firestore + .collection('collectionId') + .withConverter(postConverter) + .withConverter(null) + .doc('documentId'); + expect(() => docRef.set(new Post('post', 'author'))).to.throw(); + }); + }); + it('drops the converter when calling CollectionReference.parent()', () => { return createInstance().then(async firestore => { const postsCollection = firestore diff --git a/dev/test/document.ts b/dev/test/document.ts index 3a861b32e..4992af7c2 100644 --- a/dev/test/document.ts +++ b/dev/test/document.ts @@ -2194,4 +2194,15 @@ describe('withConverter() support', () => { expect(post!.toString()).to.equal('post, by author'); }); }); + + it('withConverter(null) applies the default converter', async () => { + return createInstance().then(async firestore => { + const docRef = firestore + .collection('collectionId') + .doc('documentId') + .withConverter(postConverter) + .withConverter(null); + expect(() => docRef.set(new Post('post', 'author'))).to.throw(); + }); + }); }); diff --git a/dev/test/query.ts b/dev/test/query.ts index 111189a7f..1c7264504 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -38,6 +38,7 @@ import { createInstance, document, InvalidApiUsage, + Post, postConverter, requestEquals, response, @@ -723,6 +724,27 @@ describe('query interface', () => { expect(posts.docs[0].data().toString()).to.equal('post, by author'); }); }); + + it('withConverter(null) applies the default converter', async () => { + const doc = document('documentId', 'author', 'author', 'title', 'post'); + const overrides: ApiOverride = { + runQuery: request => { + queryEquals(request, fieldFilters('title', 'EQUAL', 'post')); + return stream({document: doc, readTime: {seconds: 5, nanos: 6}}); + }, + }; + + return createInstance(overrides).then(async firestore => { + const coll = await firestore + .collection('collectionId') + .withConverter(postConverter) + .withConverter(null); + + const posts = await coll.where('title', '==', 'post').get(); + expect(posts.size).to.equal(1); + expect(posts.docs[0].data()).to.not.be.instanceOf(Post); + }); + }); }); describe('where() interface', () => { diff --git a/types/firestore.d.ts b/types/firestore.d.ts index d4cf4ca5b..f43d90a6b 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -1050,12 +1050,14 @@ declare namespace FirebaseFirestore { * provided converter will convert between Firestore data and your custom * type U. * - * @param converter Converts objects to and from Firestore. + * @param converter Converts objects to and from Firestore. Passing in + * `null` removes the current converter. * @return A DocumentReference that uses the provided converter. */ withConverter( converter: FirestoreDataConverter ): DocumentReference; + withConverter(converter: null): DocumentReference; } /** @@ -1419,10 +1421,12 @@ declare namespace FirebaseFirestore { * returned Query, the provided converter will convert between Firestore * data and your custom type U. * - * @param converter Converts objects to and from Firestore. + * @param converter Converts objects to and from Firestore. Passing in + * `null` removes the current converter. * @return A Query that uses the provided converter. */ withConverter(converter: FirestoreDataConverter): Query; + withConverter(converter: null): Query; } /** @@ -1602,12 +1606,14 @@ declare namespace FirebaseFirestore { * on the returned CollectionReference instance, the provided converter will * convert between Firestore data and your custom type U. * - * @param converter Converts objects to and from Firestore. + * @param converter Converts objects to and from Firestore. Passing in + * `null` removes the current converter. * @return A CollectionReference that uses the provided converter. */ withConverter( converter: FirestoreDataConverter ): CollectionReference; + withConverter(converter: null): CollectionReference; } /** @@ -1672,10 +1678,12 @@ declare namespace FirebaseFirestore { * post.someNonExistentProperty; // TS error * } * - * @param converter Converts objects to and from Firestore. + * @param converter Converts objects to and from Firestore. Passing in + * `null` removes the current converter. * @return A `CollectionGroup` that uses the provided converter. */ withConverter(converter: FirestoreDataConverter): CollectionGroup; + withConverter(converter: null): CollectionGroup; } /** From ea60d71466c70869fd2252d348fda9f509f4fc0f Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 26 Jan 2021 12:14:15 -0700 Subject: [PATCH 234/337] chore: release 4.9.0 (#1383) --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e5ae91ff..bfdd5e73a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [4.9.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.8.1...v4.9.0) (2021-01-25) + + +### Features + +* add support for applying default converter in withConverter() ([#1394](https://www.github.com/googleapis/nodejs-firestore/issues/1394)) ([ab057f7](https://www.github.com/googleapis/nodejs-firestore/commit/ab057f7b362a2929ebffa19e570d3e9cd23bc964)) +* adds UNORDERED_LIST type ([#1382](https://www.github.com/googleapis/nodejs-firestore/issues/1382)) ([5b43e7b](https://www.github.com/googleapis/nodejs-firestore/commit/5b43e7bcb2ea9c014587c84164f9ba8a0ed05397)) +* introduces style enumeration ([#1388](https://www.github.com/googleapis/nodejs-firestore/issues/1388)) ([eb1b4dc](https://www.github.com/googleapis/nodejs-firestore/commit/eb1b4dccf52b09ce395ba2ceabe02e84ee8e4dfd)) + ### [4.8.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.8.0...v4.8.1) (2020-12-16) diff --git a/package.json b/package.json index 00e4f88f3..655308ede 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.8.1", + "version": "4.9.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 10f6f17fe..4b2a1e273 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.8.1" + "@google-cloud/firestore": "^4.9.0" }, "devDependencies": { "chai": "^4.2.0", From d870c9de75a2c67ffc48d1205a5929df4c57f3cb Mon Sep 17 00:00:00 2001 From: Gil Date: Tue, 26 Jan 2021 14:05:29 -0800 Subject: [PATCH 235/337] fix: handle ignoreUndefinedProperties in set(merge: true) (#1396) Previously any field in the document would be propagated into the DocumentMask regardless of whether or not it had an undefined value, which led to the client acting as if the user had passed `FieldValue.delete()`, which wasn't intended. --- dev/src/document.ts | 6 +++++- dev/test/ignore-undefined.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/dev/src/document.ts b/dev/src/document.ts index d136bedf2..3d7f754ab 100644 --- a/dev/src/document.ts +++ b/dev/src/document.ts @@ -694,7 +694,11 @@ export class DocumentMask { } } else if (isPlainObject(value)) { extractFieldPaths(value, childPath); - } else { + } else if (value !== undefined) { + // If the value is undefined it can never participate in the document + // mask. With `ignoreUndefinedProperties` set to false, + // `validateDocumentData` will reject an undefined value before even + // computing the document mask. fieldPaths.push(childPath); } } diff --git a/dev/test/ignore-undefined.ts b/dev/test/ignore-undefined.ts index 878b36701..9bdf7dea2 100644 --- a/dev/test/ignore-undefined.ts +++ b/dev/test/ignore-undefined.ts @@ -64,6 +64,33 @@ describe('ignores undefined values', () => { ); }); + it('in set({ merge: true })', () => { + const overrides: ApiOverride = { + commit: request => { + requestEquals( + request, + set({ + document: document('documentId', 'foo', 'foo'), + mask: updateMask('foo'), + }) + ); + return response(writeResult(1)); + }, + }; + + return createInstance(overrides, {ignoreUndefinedProperties: true}).then( + firestore => { + return firestore.doc('collectionId/documentId').set( + { + foo: 'foo', + bar: undefined, + }, + {merge: true} + ); + } + ); + }); + it('in create()', () => { const overrides: ApiOverride = { commit: request => { From 0538d90f2c9defb9938ce3851d8283390a6fdc34 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 26 Jan 2021 16:38:01 -0700 Subject: [PATCH 236/337] chore: release 4.9.1 (#1397) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfdd5e73a..125d3037a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.9.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.0...v4.9.1) (2021-01-26) + + +### Bug Fixes + +* handle ignoreUndefinedProperties in set(merge: true) ([#1396](https://www.github.com/googleapis/nodejs-firestore/issues/1396)) ([d870c9d](https://www.github.com/googleapis/nodejs-firestore/commit/d870c9de75a2c67ffc48d1205a5929df4c57f3cb)) + ## [4.9.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.8.1...v4.9.0) (2021-01-25) diff --git a/package.json b/package.json index 655308ede..37cec3eb9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.9.0", + "version": "4.9.1", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 4b2a1e273..a5691769f 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.9.0" + "@google-cloud/firestore": "^4.9.1" }, "devDependencies": { "chai": "^4.2.0", From 3342d53b7ddd2117a186c39749daf739916a1ab9 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Mon, 1 Feb 2021 08:22:04 -0800 Subject: [PATCH 237/337] changes without context (#1403) --- dev/protos/google/longrunning/operations.proto | 2 +- synth.metadata | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/protos/google/longrunning/operations.proto b/dev/protos/google/longrunning/operations.proto index 299eefb2e..49842d4bc 100644 --- a/dev/protos/google/longrunning/operations.proto +++ b/dev/protos/google/longrunning/operations.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// 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. diff --git a/synth.metadata b/synth.metadata index 358bb1e03..ac354f431 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "75d9ece19bb4a9228d004b8fe4851422b6996ca7" + "sha": "0538d90f2c9defb9938ce3851d8283390a6fdc34" } }, { From 116cc84b8d58a454ab36d6761e639eac19db1996 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Mon, 1 Feb 2021 09:50:21 -0800 Subject: [PATCH 238/337] docs: Add callback details for updateFunction in runTransaction() (#1404) --- dev/src/index.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index 81a5d19d7..1ce26905e 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -868,6 +868,19 @@ export class Firestore implements firestore.Firestore { return new BundleBuilder(name || autoId()); } + /** + * Function executed by {@link Firestore#runTransaction} within the transaction + * context. + * + * @callback Firestore~updateFunction + * @template T + * @param {Transaction} transaction The transaction object for this + * transaction. + * @returns {Promise} The promise returned at the end of the transaction. + * This promise will be returned by {@link Firestore#runTransaction} if the + * transaction completed successfully. + */ + /** * Executes the given updateFunction and commits the changes applied within * the transaction. @@ -876,12 +889,13 @@ export class Firestore implements firestore.Firestore { * modify Firestore documents under lock. Transactions are committed once * 'updateFunction' resolves and attempted up to five times on failure. * - * @param {function(Transaction)} updateFunction The function to execute - * within the transaction context. + * @template T + * @param {Firestore~updateFunction} updateFunction The user function to + * execute within the transaction context. * @param {object=} transactionOptions Transaction options. * @param {number=} transactionOptions.maxAttempts - The maximum number of * attempts for this transaction. - * @returns {Promise} If the transaction completed successfully or was + * @returns {Promise} If the transaction completed successfully or was * explicitly aborted (by the updateFunction returning a failed Promise), the * Promise returned by the updateFunction will be returned here. Else if the * transaction failed, a rejected Promise with the corresponding failure From bd15996c82967e5d90ed761c5c1225992fbc2625 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Tue, 2 Feb 2021 17:52:05 -0800 Subject: [PATCH 239/337] chore: update CODEOWNERS config (#1405) --- .repo-metadata.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.repo-metadata.json b/.repo-metadata.json index f61e8d76b..2514639b0 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -9,5 +9,6 @@ "repo": "googleapis/nodejs-firestore", "distribution_name": "@google-cloud/firestore", "api_id": "firestore.googleapis.com", - "requires_billing ": false -} \ No newline at end of file + "requires_billing ": false, + "codeowner_team": "@googleapis/firestore-dpe" +} From b8a132a280bd2eb1423ad24d0dfe51d21c43c0a9 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 3 Feb 2021 12:09:37 -0800 Subject: [PATCH 240/337] changes without context (#1407) autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. --- dev/protos/google/api/field_behavior.proto | 2 +- dev/protos/protos.json | 3 ++- synth.metadata | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dev/protos/google/api/field_behavior.proto b/dev/protos/google/api/field_behavior.proto index 686667954..614b31a00 100644 --- a/dev/protos/google/api/field_behavior.proto +++ b/dev/protos/google/api/field_behavior.proto @@ -78,7 +78,7 @@ enum FieldBehavior { // Denotes that a (repeated) field is an unordered list. // This indicates that the service may provide the elements of the list - // in any arbitrary order, rather than the order the user originally + // in any arbitrary order, rather than the order the user originally // provided. Additionally, the list's order may or may not be stable. UNORDERED_LIST = 6; } diff --git a/dev/protos/protos.json b/dev/protos/protos.json index 753b9b1f9..3c9a3370f 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -3973,7 +3973,8 @@ "REQUIRED": 2, "OUTPUT_ONLY": 3, "INPUT_ONLY": 4, - "IMMUTABLE": 5 + "IMMUTABLE": 5, + "UNORDERED_LIST": 6 } } } diff --git a/synth.metadata b/synth.metadata index ac354f431..b3adb4e71 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "0538d90f2c9defb9938ce3851d8283390a6fdc34" + "sha": "bd15996c82967e5d90ed761c5c1225992fbc2625" } }, { From e632e949cf57fc55b73c1a88c4837b01bca39061 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Wed, 3 Feb 2021 12:20:07 -0800 Subject: [PATCH 241/337] build: migrate to flakybot (#1400) --- .kokoro/samples-test.sh | 6 +++--- .kokoro/system-test.sh | 6 +++--- .kokoro/test.sh | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.kokoro/samples-test.sh b/.kokoro/samples-test.sh index f72fa8c69..4c25e4828 100755 --- a/.kokoro/samples-test.sh +++ b/.kokoro/samples-test.sh @@ -39,14 +39,14 @@ if [ -f samples/package.json ]; then npm link ../ npm install cd .. - # If tests are running against master, configure Build Cop + # If tests are running against master, configure FlakyBot # to open issues on failures: if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]] || [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"nightly"* ]]; then export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml export MOCHA_REPORTER=xunit cleanup() { - chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop - $KOKORO_GFILE_DIR/linux_amd64/buildcop + chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot + $KOKORO_GFILE_DIR/linux_amd64/flakybot } trap cleanup EXIT HUP fi diff --git a/.kokoro/system-test.sh b/.kokoro/system-test.sh index 18a6a40fd..ee582e3d3 100755 --- a/.kokoro/system-test.sh +++ b/.kokoro/system-test.sh @@ -33,14 +33,14 @@ fi npm install -# If tests are running against master, configure Build Cop +# If tests are running against master, configure FlakyBot # to open issues on failures: if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]] || [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"nightly"* ]]; then export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml export MOCHA_REPORTER=xunit cleanup() { - chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop - $KOKORO_GFILE_DIR/linux_amd64/buildcop + chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot + $KOKORO_GFILE_DIR/linux_amd64/flakybot } trap cleanup EXIT HUP fi diff --git a/.kokoro/test.sh b/.kokoro/test.sh index 47be59b98..f18c82863 100755 --- a/.kokoro/test.sh +++ b/.kokoro/test.sh @@ -21,14 +21,14 @@ export NPM_CONFIG_PREFIX=/home/node/.npm-global cd $(dirname $0)/.. npm install -# If tests are running against master, configure Build Cop +# If tests are running against master, configure FlakyBot # to open issues on failures: if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]] || [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"nightly"* ]]; then export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml export MOCHA_REPORTER=xunit cleanup() { - chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop - $KOKORO_GFILE_DIR/linux_amd64/buildcop + chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot + $KOKORO_GFILE_DIR/linux_amd64/flakybot } trap cleanup EXIT HUP fi From fa6721f2b5be5bab57b62e0f09fe10987567b81f Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 4 Feb 2021 08:46:07 -0800 Subject: [PATCH 242/337] chore: use repo metadata to populate nodejs CODEOWNERS (#1411) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/c1ab1c4d-e170-4bc8-a09f-3d1e8b476d04/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: https://github.com/googleapis/synthtool/commit/318e351e26ba65b2b3cfa3f61b3b64e3540c3525 --- .github/CODEOWNERS | 5 ++--- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5f7bc27be..7fea4c1e2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,6 +5,5 @@ # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax -# The firestore-dpe team is the default owner for anything not -# explicitly taken by someone else. -* @googleapis/firestore-dpe @googleapis/yoshi-nodejs @googleapis/api-firestore +# The yoshi-nodejs team is the default owner for nodejs repositories. +* @googleapis/yoshi-nodejs @googleapis/firestore-dpe diff --git a/synth.metadata b/synth.metadata index b3adb4e71..3b881a412 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "bd15996c82967e5d90ed761c5c1225992fbc2625" + "sha": "e632e949cf57fc55b73c1a88c4837b01bca39061" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "363fe305e9ce34a6cd53951c6ee5f997094b54ee" + "sha": "318e351e26ba65b2b3cfa3f61b3b64e3540c3525" } } ], From 8cf53a92dc13324562ca1a1e841312e43f5c383e Mon Sep 17 00:00:00 2001 From: wu-hui <53845758+wu-hui@users.noreply.github.com> Date: Thu, 4 Feb 2021 17:31:28 -0500 Subject: [PATCH 243/337] fix: support byte values in Bundles (#1395) --- dev/src/bundle.ts | 7 ++++- dev/src/document.ts | 4 +-- dev/src/timestamp.ts | 2 +- dev/system-test/firestore.ts | 16 +++++++--- dev/test/bundle.ts | 60 +++++++++++++++++++++++++++++------- dev/test/document.ts | 4 +-- dev/test/index.ts | 2 +- dev/test/util/helpers.ts | 2 +- 8 files changed, 74 insertions(+), 23 deletions(-) diff --git a/dev/src/bundle.ts b/dev/src/bundle.ts index 81f23a4d6..4f134404f 100644 --- a/dev/src/bundle.ts +++ b/dev/src/bundle.ts @@ -25,6 +25,7 @@ import { } from './validate'; import api = google.firestore.v1; +import BundleElement = firestore.BundleElement; const BUNDLE_VERSION = 1; @@ -142,7 +143,11 @@ export class BundleBuilder { private elementToLengthPrefixedBuffer( bundleElement: firestore.IBundleElement ): Buffer { - const buffer = Buffer.from(JSON.stringify(bundleElement), 'utf-8'); + // Convert to a valid proto message object then take its JSON representation. + // This take cares of stuff like converting internal byte array fields + // to Base64 encodings. + const message = BundleElement.fromObject(bundleElement).toJSON(); + const buffer = Buffer.from(JSON.stringify(message), 'utf-8'); const lengthBuffer = Buffer.from(buffer.length.toString()); return Buffer.concat([lengthBuffer, buffer]); } diff --git a/dev/src/document.ts b/dev/src/document.ts index 3d7f754ab..ca73ce2c9 100644 --- a/dev/src/document.ts +++ b/dev/src/document.ts @@ -496,8 +496,8 @@ export class DocumentSnapshot toDocumentProto(): api.IDocument { return { name: this._ref.formattedName, - createTime: this.createTime, - updateTime: this.updateTime, + createTime: this.createTime?.toProto().timestampValue, + updateTime: this.updateTime?.toProto().timestampValue, fields: this._fieldsProto, }; } diff --git a/dev/src/timestamp.ts b/dev/src/timestamp.ts index 4d3a57415..bbc10aa98 100644 --- a/dev/src/timestamp.ts +++ b/dev/src/timestamp.ts @@ -259,7 +259,7 @@ export class Timestamp implements firestore.Timestamp { const timestamp: google.protobuf.ITimestamp = {}; if (this.seconds) { - timestamp.seconds = this.seconds; + timestamp.seconds = this.seconds.toString(); } if (this.nanoseconds) { diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index b12a5a4c4..facb52ca5 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -43,12 +43,13 @@ import { postConverterMerge, verifyInstance, } from '../test/util/helpers'; -import IBundleElement = firestore.IBundleElement; import {BulkWriter} from '../src/bulk-writer'; import {Status} from 'google-gax'; import {QueryPartition} from '../src/query-partition'; import {CollectionGroup} from '../src/collection-group'; +import IBundleElement = firestore.IBundleElement; + use(chaiAsPromised); const version = require('../../package.json').version; @@ -2761,7 +2762,7 @@ describe('Bundle building', () => { it('succeeds when there are no results', async () => { const bundle = firestore.bundle(TEST_BUNDLE_ID); - const query = testCol.where('sort', '==', 5); + const query = testCol.where('value', '==', '42'); const snap = await query.get(); bundle.add('query', snap); @@ -2805,7 +2806,6 @@ describe('Bundle building', () => { name: snap.toDocumentProto().name, readTime: snap.readTime.toProto().timestampValue, exists: false, - queries: [], }); }); @@ -2880,6 +2880,14 @@ describe('Bundle building', () => { }); const bundledDoc = (elements[4] as IBundleElement).document; - expect(bundledDoc).to.deep.equal(limitToLastSnap.docs[0].toDocumentProto()); + // The `valueType` is auxiliary and does not exist in proto. + const expected = limitToLastSnap.docs[0].toDocumentProto(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete (expected.fields!.name as any).valueType; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete (expected.fields!.sort as any).valueType; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete (expected.fields!.value as any).valueType; + expect(bundledDoc).to.deep.equal(expected); }); }); diff --git a/dev/test/bundle.ts b/dev/test/bundle.ts index a131c58a3..3f1f11792 100644 --- a/dev/test/bundle.ts +++ b/dev/test/bundle.ts @@ -23,6 +23,7 @@ import { DATABASE_ROOT, verifyInstance, } from './util/helpers'; + import IBundleElement = firestore.IBundleElement; import IBundleMetadata = firestore.IBundleMetadata; import ITimestamp = google.protobuf.ITimestamp; @@ -37,9 +38,9 @@ export function verifyMetadata( expectEmptyContent = false ): void { if (!expectEmptyContent) { - expect(meta.totalBytes).greaterThan(0); + expect(parseInt(meta.totalBytes!.toString())).greaterThan(0); } else { - expect(meta.totalBytes).to.equal(0); + expect(parseInt(meta.totalBytes!.toString())).to.equal(0); } expect(meta.id).to.equal(TEST_BUNDLE_ID); expect(meta.version).to.equal(TEST_BUNDLE_VERSION); @@ -47,7 +48,7 @@ export function verifyMetadata( expect(meta.createTime).to.deep.equal(createTime); } -describe('Bundle Buidler', () => { +describe('Bundle Builder', () => { let firestore: Firestore; beforeEach(() => { @@ -75,7 +76,7 @@ describe('Bundle Buidler', () => { const snap1 = firestore.snapshot_( { name: `${DATABASE_ROOT}/documents/collectionId/doc1`, - fields: {foo: {stringValue: 'value'}, bar: {integerValue: 42}}, + fields: {foo: {stringValue: 'value'}, bar: {integerValue: '42'}}, createTime: '1970-01-01T00:00:01.002Z', updateTime: '1970-01-01T00:00:03.000004Z', }, @@ -87,7 +88,7 @@ describe('Bundle Buidler', () => { const snap2 = firestore.snapshot_( { name: `${DATABASE_ROOT}/documents/collectionId/doc1`, - fields: {foo: {stringValue: 'value'}, bar: {integerValue: -42}}, + fields: {foo: {stringValue: 'value'}, bar: {integerValue: '-42'}}, createTime: '1970-01-01T00:00:01.002Z', updateTime: '1970-01-01T00:00:03.000004Z', }, @@ -116,7 +117,6 @@ describe('Bundle Buidler', () => { name: snap1.toDocumentProto().name, readTime: snap1.readTime.toProto().timestampValue, exists: true, - queries: [], }); expect(docSnap).to.deep.equal(snap1.toDocumentProto()); }); @@ -126,7 +126,7 @@ describe('Bundle Buidler', () => { const snap = firestore.snapshot_( { name: `${DATABASE_ROOT}/documents/collectionId/doc1`, - value: 'string', + fields: {foo: {stringValue: 'value'}}, createTime: '1970-01-01T00:00:01.002Z', updateTime: '1970-01-01T00:00:03.000004Z', }, @@ -217,7 +217,7 @@ describe('Bundle Buidler', () => { const snap1 = firestore.snapshot_( { name: `${DATABASE_ROOT}/documents/collectionId/doc1`, - fields: {foo: {stringValue: 'value'}, bar: {integerValue: 42}}, + fields: {foo: {stringValue: 'value'}, bar: {integerValue: '42'}}, createTime: '1970-01-01T00:00:01.002Z', updateTime: '1970-01-01T00:00:03.000004Z', }, @@ -246,7 +246,6 @@ describe('Bundle Buidler', () => { name: snap1.toDocumentProto().name, readTime: snap1.readTime.toProto().timestampValue, exists: true, - queries: [], }); expect(doc1Snap).to.deep.equal(snap1.toDocumentProto()); @@ -254,7 +253,7 @@ describe('Bundle Buidler', () => { const snap2 = firestore.snapshot_( { name: `${DATABASE_ROOT}/documents/collectionId/doc2`, - fields: {foo: {stringValue: 'value'}, bar: {integerValue: -42}}, + fields: {foo: {stringValue: 'value'}, bar: {integerValue: '-42'}}, createTime: '1970-01-01T00:00:01.002Z', updateTime: '1970-01-01T00:00:03.000004Z', }, @@ -283,7 +282,6 @@ describe('Bundle Buidler', () => { name: snap2.toDocumentProto().name, readTime: snap2.readTime.toProto().timestampValue, exists: true, - queries: [], }); expect(doc2Snap).to.deep.equal(snap2.toDocumentProto()); }); @@ -304,3 +302,43 @@ describe('Bundle Buidler', () => { ); }); }); + +describe('Bundle Builder using BigInt', () => { + let firestore: Firestore; + + beforeEach(() => { + return createInstance(undefined, {useBigInt: true}).then( + firestoreInstance => { + firestore = firestoreInstance; + } + ); + }); + + it('succeeds with document snapshots with BigInt field', async () => { + const bundle = firestore.bundle(TEST_BUNDLE_ID); + const bigIntValue = + BigInt(Number.MAX_SAFE_INTEGER) + BigInt(Number.MAX_SAFE_INTEGER); + const snap = firestore.snapshot_( + { + name: `${DATABASE_ROOT}/documents/collectionId/doc1`, + fields: {foo: {integerValue: bigIntValue.toString()}}, + createTime: '1970-01-01T00:00:01.002Z', + updateTime: '1970-01-01T00:00:03.000004Z', + }, + // This should be the bundle read time. + '2020-01-01T00:00:05.000000006Z', + 'json' + ); + bundle.add(snap); + + // Bundle is expected to be [bundleMeta, snapMeta, snap] + const elements = await bundleToElementArray(bundle.build()); + // The point is to make sure BigInt gets encoded correctly into a string without losing + // precision. + expect(elements[2].document?.fields).to.deep.equal({ + foo: {integerValue: bigIntValue.toString()}, + }); + }); + + afterEach(() => verifyInstance(firestore)); +}); diff --git a/dev/test/document.ts b/dev/test/document.ts index 4992af7c2..042d0d418 100644 --- a/dev/test/document.ts +++ b/dev/test/document.ts @@ -845,7 +845,7 @@ describe('delete document', () => { remove('documentId', { updateTime: { nanos: 123000000, - seconds: 479978400, + seconds: '479978400', }, }) ); @@ -1682,7 +1682,7 @@ describe('update document', () => { precondition: { updateTime: { nanos: 123000000, - seconds: 479978400, + seconds: '479978400', }, }, }) diff --git a/dev/test/index.ts b/dev/test/index.ts index 7095001df..4355e1131 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -88,7 +88,7 @@ const allSupportedTypesProtobufJs = document( { timestampValue: { nanos: 123000000, - seconds: 479978400, + seconds: '479978400', }, }, 'doubleValue', diff --git a/dev/test/util/helpers.ts b/dev/test/util/helpers.ts index 54678d7be..04922661e 100644 --- a/dev/test/util/helpers.ts +++ b/dev/test/util/helpers.ts @@ -20,7 +20,7 @@ import {grpc} from 'google-gax'; import {JSONStreamIterator} from 'length-prefixed-json-stream'; import {Duplex, PassThrough} from 'stream'; import * as through2 from 'through2'; -import {firestore} from '../../protos/firestore_v1_proto_api'; +import {firestore, google} from '../../protos/firestore_v1_proto_api'; import * as proto from '../../protos/firestore_v1_proto_api'; import * as v1 from '../../src/v1'; From ae86fc60eac2b507dbb018dc9c38ea37a61077ca Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Thu, 4 Feb 2021 16:55:36 -0800 Subject: [PATCH 244/337] chore: update custom CODEOWNERS (#1414) --- .github/CODEOWNERS | 2 +- synth.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 7fea4c1e2..4fd35e007 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -6,4 +6,4 @@ # The yoshi-nodejs team is the default owner for nodejs repositories. -* @googleapis/yoshi-nodejs @googleapis/firestore-dpe +* @googleapis/yoshi-nodejs @googleapis/firestore-dpe @googleapis/api-firestore diff --git a/synth.py b/synth.py index a8e649a2d..543c23948 100644 --- a/synth.py +++ b/synth.py @@ -23,7 +23,7 @@ ) # skip index, protos, package.json, and README.md -s.copy(v1_admin_library, "dev", excludes=["package.json", "README.md", "src/index.ts", "src/v1/index.ts", +s.copy(v1_admin_library, "dev", excludes=["package.json", "README.md", "src/index.ts", "src/v1/index.ts", "tsconfig.json", "linkinator.config.json", "webpack.config.js"]) s.copy(v1beta1_library, "dev", excludes=["package.json", "README.md", "src/index.ts", "src/v1beta1/index.ts", "tsconfig.json", "linkinator.config.json", "webpack.config.js"]) @@ -153,7 +153,7 @@ source_location="build/src", test_project="node-gcloud-ci" ) -s.copy(templates, excludes=[".eslintrc.json", ".kokoro/**/*"]) +s.copy(templates, excludes=[".eslintrc.json", ".kokoro/**/*", ".github/CODEOWNERS"]) # Remove auto-generated packaging tests os.system('rm -rf dev/system-test/fixtures dev/system-test/install.ts') From 7924023020633a8af28d2c3383c7d0aa78ca2e2c Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Fri, 5 Feb 2021 09:36:01 -0700 Subject: [PATCH 245/337] chore: release 4.9.2 (#1413) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 125d3037a..b23556464 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.9.2](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.1...v4.9.2) (2021-02-05) + + +### Bug Fixes + +* support byte values in Bundles ([#1395](https://www.github.com/googleapis/nodejs-firestore/issues/1395)) ([8cf53a9](https://www.github.com/googleapis/nodejs-firestore/commit/8cf53a92dc13324562ca1a1e841312e43f5c383e)) + ### [4.9.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.0...v4.9.1) (2021-01-26) diff --git a/package.json b/package.json index 37cec3eb9..11cf96ecf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.9.1", + "version": "4.9.2", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index a5691769f..963ced19e 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.9.1" + "@google-cloud/firestore": "^4.9.2" }, "devDependencies": { "chai": "^4.2.0", From 39b13ce6546a599b17ecea79b42e3eb7ad4c9962 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Fri, 5 Feb 2021 10:12:03 -0700 Subject: [PATCH 246/337] chore: small BulkWriter cleanup (#1410) This removes an indirection between BulkWriter and BulkWriterOperation. --- dev/src/bulk-writer.ts | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 69b6f745e..694824b87 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -84,8 +84,6 @@ class BulkWriterOperation { /** * @param ref The document reference being written to. * @param type The type of operation that created this write. - * @param op A closure that encapsulates the API call which adds this write to - * a BulkCommitBatch. * @param sendFn A callback to invoke when the operation should be sent. * @param errorFn The user provided global error callback. * @param successFn The user provided global success callback. @@ -93,7 +91,6 @@ class BulkWriterOperation { constructor( readonly ref: firestore.DocumentReference, private readonly type: 'create' | 'set' | 'update' | 'delete', - private readonly op: (bulkCommitBatch: BulkCommitBatch) => void, private readonly sendFn: (op: BulkWriterOperation) => void, private readonly errorFn: (error: BulkWriterError) => boolean, private readonly successFn: ( @@ -106,10 +103,6 @@ class BulkWriterOperation { return this.deferred.promise; } - run(batch: BulkCommitBatch): void { - this.op(batch); - } - onError(error: GoogleError): void { ++this.failedAttempts; @@ -751,17 +744,16 @@ export class BulkWriter { private _enqueue( ref: firestore.DocumentReference, type: 'create' | 'set' | 'update' | 'delete', - op: (bulkCommitBatch: BulkCommitBatch) => void + enqueueOnBatchCallback: (bulkCommitBatch: BulkCommitBatch) => void ): Promise { const bulkWriterOp = new BulkWriterOperation( ref, type, - op, - this._sendFn.bind(this), + this._sendFn.bind(this, enqueueOnBatchCallback), this._errorFn.bind(this), this._successFn.bind(this) ); - this._sendFn(bulkWriterOp); + this._sendFn(enqueueOnBatchCallback, bulkWriterOp); return bulkWriterOp.promise; } @@ -771,7 +763,10 @@ export class BulkWriter { * * @private */ - _sendFn(op: BulkWriterOperation): void { + _sendFn( + enqueueOnBatchCallback: (bulkCommitBatch: BulkCommitBatch) => void, + op: BulkWriterOperation + ): void { if (this._bulkCommitBatch.has(op.ref)) { // Create a new batch since the backend doesn't support batches with two // writes to the same document. @@ -781,7 +776,7 @@ export class BulkWriter { // Run the operation on the current batch and advance the `_lastOp` pointer. // This ensures that `_lastOp` only resolves when both the previous and the // current write resolves. - op.run(this._bulkCommitBatch); + enqueueOnBatchCallback(this._bulkCommitBatch); this._bulkCommitBatch.processLastOperation(op); this._lastOp = this._lastOp.then(() => silencePromise(op.promise)); From 4a8c3cfcaf57ed600da094ab0275a5f32fb1ea30 Mon Sep 17 00:00:00 2001 From: Konstantin Varlamov Date: Mon, 8 Feb 2021 10:59:02 -0500 Subject: [PATCH 247/337] fix: use `Array.isArray` instead of an `instanceof` check (#1417) --- dev/src/serializer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/src/serializer.ts b/dev/src/serializer.ts index a69edc303..5460ebcf8 100644 --- a/dev/src/serializer.ts +++ b/dev/src/serializer.ts @@ -169,7 +169,7 @@ export class Serializer { } } - if (val instanceof Array) { + if (Array.isArray(val)) { const array: api.IValue = { arrayValue: {}, }; From d90e4be2decb06748479cfcecdc2d4b470c80be4 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 9 Feb 2021 10:55:35 -0700 Subject: [PATCH 248/337] chore: clean up before Sample test (#1416) Co-authored-by: Justin Beckwith --- samples/solution-counters.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/solution-counters.js b/samples/solution-counters.js index f487ac1f8..970204fc6 100644 --- a/samples/solution-counters.js +++ b/samples/solution-counters.js @@ -60,6 +60,8 @@ async function main() { const docRef = firestore.doc( 'distributed_counter_samples/distributed_counter' ); + // Clean up documents from potential prior test runs + await deleteDocs(docRef); const numberOfShards = 10; // Increase the document count return incrementCounter(docRef, numberOfShards).then(async () => { From 60539e485b8a88984c60ced3ae1ea8fbe3a565a2 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 9 Feb 2021 18:04:04 +0000 Subject: [PATCH 249/337] chore: release 4.9.3 (#1419) :robot: I have created a release \*beep\* \*boop\* --- ### [4.9.3](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.2...v4.9.3) (2021-02-09) ### Bug Fixes * use `Array.isArray` instead of an `instanceof` check ([#1417](https://www.github.com/googleapis/nodejs-firestore/issues/1417)) ([4a8c3cf](https://www.github.com/googleapis/nodejs-firestore/commit/4a8c3cfcaf57ed600da094ab0275a5f32fb1ea30)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b23556464..ca43057a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.9.3](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.2...v4.9.3) (2021-02-09) + + +### Bug Fixes + +* use `Array.isArray` instead of an `instanceof` check ([#1417](https://www.github.com/googleapis/nodejs-firestore/issues/1417)) ([4a8c3cf](https://www.github.com/googleapis/nodejs-firestore/commit/4a8c3cfcaf57ed600da094ab0275a5f32fb1ea30)) + ### [4.9.2](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.1...v4.9.2) (2021-02-05) diff --git a/package.json b/package.json index 11cf96ecf..ebd213bdb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.9.2", + "version": "4.9.3", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 963ced19e..81dcaa296 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.9.2" + "@google-cloud/firestore": "^4.9.3" }, "devDependencies": { "chai": "^4.2.0", From 1f8dc26032ef20ab874b70b1ae74988df484aec4 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 9 Feb 2021 10:17:32 -0800 Subject: [PATCH 250/337] chore: add option to fetch all descendants (#1412) --- dev/src/index.ts | 61 +++++++++++++++++++++++++++++- dev/src/path.ts | 12 ++++++ dev/src/reference.ts | 73 +++++++++++++++++++++++++++--------- dev/system-test/firestore.ts | 65 ++++++++++++++++++++++++++++++++ 4 files changed, 193 insertions(+), 18 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index 1ce26905e..8bb15d0f7 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -40,7 +40,7 @@ import { validateResourcePath, } from './path'; import {ClientPool} from './pool'; -import {CollectionReference} from './reference'; +import {CollectionReference, Query, QueryOptions} from './reference'; import {DocumentReference} from './reference'; import {Serializer} from './serializer'; import {Timestamp} from './timestamp'; @@ -156,6 +156,18 @@ const DEFAULT_MAX_IDLE_CHANNELS = 1; */ const MAX_CONCURRENT_REQUESTS_PER_CLIENT = 100; +/** + * Datastore allowed numeric IDs where Firestore only allows strings. Numeric + * IDs are exposed to Firestore as __idNUM__, so this is the lowest possible + * negative numeric value expressed in that format. + * + * This constant is used to specify startAt/endAt values when querying for all + * descendants in a single collection. + * + * @private + */ +const REFERENCE_NAME_MIN_ID = '__id-9223372036854775808__'; + /** * Document data (e.g. for use with * [set()]{@link DocumentReference#set}) consisting of fields mapped @@ -1186,6 +1198,53 @@ export class Firestore implements firestore.Firestore { this.bulkWritersCount -= 1; } + /** + * Retrieves all descendant documents nested under the provided reference. + * + * @private + * @return {Stream} Stream of descendant documents. + */ + // TODO(chenbrian): Make this a private method after adding recursive delete. + _getAllDescendants( + ref: CollectionReference | DocumentReference + ): NodeJS.ReadableStream { + // The parent is the closest ancestor document to the location we're + // deleting. If we are deleting a document, the parent is the path of that + // document. If we are deleting a collection, the parent is the path of the + // document containing that collection (or the database root, if it is a + // root collection). + let parentPath = ref._resourcePath; + if (ref instanceof CollectionReference) { + parentPath = parentPath.popLast(); + } + const collectionId = + ref instanceof CollectionReference ? ref.id : ref.parent.id; + + let query: Query = new Query( + this, + QueryOptions.forKindlessAllDescendants(parentPath, collectionId) + ); + + // Query for names only to fetch empty snapshots. + query = query.select(FieldPath.documentId()); + + if (ref instanceof CollectionReference) { + // To find all descendants of a collection reference, we need to use a + // composite filter that captures all documents that start with the + // collection prefix. The MIN_KEY constant represents the minimum key in + // this collection, and a null byte + the MIN_KEY represents the minimum + // key is the next possible collection. + const nullChar = String.fromCharCode(0); + const startAt = collectionId + '/' + REFERENCE_NAME_MIN_ID; + const endAt = collectionId + nullChar + '/' + REFERENCE_NAME_MIN_ID; + query = query + .where(FieldPath.documentId(), '>=', startAt) + .where(FieldPath.documentId(), '<', endAt); + } + + return query.stream(); + } + /** * Terminates the Firestore client and closes all open streams. * diff --git a/dev/src/path.ts b/dev/src/path.ts index 388fc86c1..2a6709628 100644 --- a/dev/src/path.ts +++ b/dev/src/path.ts @@ -177,6 +177,18 @@ abstract class Path { return this.segments.slice(); } + /** + * Pops the last segment from this `Path` and returns a newly constructed + * `Path`. + * + * @private + * @returns The newly created Path. + */ + popLast(): T { + this.segments.pop(); + return this.construct(this.segments); + } + /** * Returns true if this `Path` is equal to the provided value. * diff --git a/dev/src/reference.ts b/dev/src/reference.ts index c815dfc93..ae1050fee 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -15,7 +15,6 @@ */ import * as firestore from '@google-cloud/firestore'; - import {Transform} from 'stream'; import * as deepEqual from 'fast-deep-equal'; @@ -206,8 +205,16 @@ export class DocumentReference } /** - * A reference to the collection to which this DocumentReference belongs. - * + * Returns a resource path for this document. + * @private + */ + get _resourcePath(): ResourcePath { + return this._path; + } + + /** + * A reference to the collection to which this DocumentRference belongs. + *e * @name DocumentReference#parent * @type {CollectionReference} * @readonly @@ -996,14 +1003,17 @@ export class QueryOptions { readonly limit?: number, readonly limitType?: LimitType, readonly offset?: number, - readonly projection?: api.StructuredQuery.IProjection + readonly projection?: api.StructuredQuery.IProjection, + // Whether to select all documents under `parentPath`. By default, only + // collections that match `collectionId` are selected. + readonly kindless = false ) {} /** * Returns query options for a collection group query. * @private */ - static forCollectionGroupQuery( + static forCollectionGroupQuery( collectionId: string, converter = defaultConverter() ): QueryOptions { @@ -1021,7 +1031,7 @@ export class QueryOptions { * Returns query options for a single-collection query. * @private */ - static forCollectionQuery( + static forCollectionQuery( collectionRef: ResourcePath, converter = defaultConverter() ): QueryOptions { @@ -1035,6 +1045,31 @@ export class QueryOptions { ); } + /** + * Returns query options for a query that fetches all descendants under the + * specified reference. + * + * @private + */ + static forKindlessAllDescendants( + parent: ResourcePath, + id: string + ): QueryOptions { + let options = new QueryOptions( + parent, + id, + defaultConverter(), + /*allDescendants=*/ true, + /*fieldFilters=*/ [], + /*fieldOrders=*/ [] + ); + + options = options.with({ + kindless: true, + }); + return options; + } + /** * Returns the union of the current and the provided options. * @private @@ -1052,7 +1087,8 @@ export class QueryOptions { coalesce(settings.limit, this.limit), coalesce(settings.limitType, this.limitType), coalesce(settings.offset, this.offset), - coalesce(settings.projection, this.projection) + coalesce(settings.projection, this.projection), + coalesce(settings.kindless, this.kindless) ); } @@ -1096,7 +1132,8 @@ export class QueryOptions { deepEqual(this.fieldOrders, other.fieldOrders) && deepEqual(this.startAt, other.startAt) && deepEqual(this.endAt, other.endAt) && - deepEqual(this.projection, other.projection) + deepEqual(this.projection, other.projection) && + this.kindless === other.kindless ); } } @@ -2026,17 +2063,19 @@ export class Query implements firestore.Query { private toStructuredQuery(): api.IStructuredQuery { const structuredQuery: api.IStructuredQuery = { - from: [ - { - collectionId: this._queryOptions.collectionId, - }, - ], + from: [{}], }; if (this._queryOptions.allDescendants) { structuredQuery.from![0].allDescendants = true; } + // Kindless queries select all descendant documents, so we remove the + // collectionId field. + if (!this._queryOptions.kindless) { + structuredQuery.from![0].collectionId = this._queryOptions.collectionId; + } + if (this._queryOptions.fieldFilters.length === 1) { structuredQuery.where = this._queryOptions.fieldFilters[0].toProto(); } else if (this._queryOptions.fieldFilters.length > 1) { @@ -2348,7 +2387,7 @@ export class CollectionReference * Returns a resource path for this collection. * @private */ - private get resourcePath(): ResourcePath { + get _resourcePath(): ResourcePath { return this._queryOptions.parentPath.append( this._queryOptions.collectionId ); @@ -2406,7 +2445,7 @@ export class CollectionReference * console.log(`Path of the subcollection: ${collectionRef.path}`); */ get path(): string { - return this.resourcePath.relativeName; + return this._resourcePath.relativeName; } /** @@ -2499,7 +2538,7 @@ export class CollectionReference validateResourcePath('documentPath', documentPath!); } - const path = this.resourcePath.append(documentPath!); + const path = this._resourcePath.append(documentPath!); if (!path.isDocument) { throw new Error( `Value for argument "documentPath" must point to a document, but was "${documentPath}". Your path does not contain an even number of components.` @@ -2613,7 +2652,7 @@ export class CollectionReference ): CollectionReference { return new CollectionReference( this.firestore, - this.resourcePath, + this._resourcePath, converter ?? defaultConverter() ); } diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index facb52ca5..6a388b6d8 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -2629,6 +2629,71 @@ describe('BulkWriter class', () => { return firestore.terminate(); }); + // TODO(chenbrian): This is a temporary test used to validate that the + // StructuredQuery calls work properly. Remove these tests after adding + // recursive delete tests. + it('finds nested documents and collection', async () => { + // ROOT-DB + // └── randomCol + // ├── anna + // └── bob + // └── parentsCol + // ├── charlie + // └── daniel + // └── childCol + // ├── ernie + // └── francis + const batch = firestore.batch(); + batch.set(randomCol.doc('anna'), {name: 'anna'}); + batch.set(randomCol.doc('bob'), {name: 'bob'}); + batch.set(randomCol.doc('bob/parentsCol/charlie'), {name: 'charlie'}); + batch.set(randomCol.doc('bob/parentsCol/daniel'), {name: 'daniel'}); + batch.set(randomCol.doc('bob/parentsCol/daniel/childCol/ernie'), { + name: 'ernie', + }); + batch.set(randomCol.doc('bob/parentsCol/daniel/childCol/francis'), { + name: 'francis', + }); + await batch.commit(); + + const numStreamItems = async ( + stream: NodeJS.ReadableStream + ): Promise => { + let count = 0; + // eslint-disable-next-line @typescript-eslint/no-unused-vars + for await (const _ of stream) { + ++count; + } + return count; + }; + + // Query all descendants of collections. + let descendantsStream = await firestore._getAllDescendants(randomCol); + expect(await numStreamItems(descendantsStream)).to.equal(6); + descendantsStream = await firestore._getAllDescendants( + randomCol.doc('bob').collection('parentsCol') + ); + expect(await numStreamItems(descendantsStream)).to.equal(4); + descendantsStream = await firestore._getAllDescendants( + randomCol.doc('bob').collection('parentsCol/daniel/childCol') + ); + expect(await numStreamItems(descendantsStream)).to.equal(2); + + // Query all descendants of documents. + descendantsStream = await firestore._getAllDescendants( + randomCol.doc('bob') + ); + expect(await numStreamItems(descendantsStream)).to.equal(4); + descendantsStream = await firestore._getAllDescendants( + randomCol.doc('bob/parentsCol/daniel') + ); + expect(await numStreamItems(descendantsStream)).to.equal(2); + descendantsStream = await firestore._getAllDescendants( + randomCol.doc('anna') + ); + expect(await numStreamItems(descendantsStream)).to.equal(0); + }); + it('can retry failed writes with a provided callback', async () => { let retryCount = 0; let code: Status = -1; From 6a3904f37bcbddf1286a44dc9201a90c5fb851a4 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 12 Feb 2021 14:20:55 -0800 Subject: [PATCH 251/337] docs: tweak wording of jsdoc --- dev/protos/google/longrunning/operations.proto | 6 +++--- synth.metadata | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dev/protos/google/longrunning/operations.proto b/dev/protos/google/longrunning/operations.proto index 49842d4bc..c1fdc6f52 100644 --- a/dev/protos/google/longrunning/operations.proto +++ b/dev/protos/google/longrunning/operations.proto @@ -110,9 +110,9 @@ service Operations { option (google.api.method_signature) = "name"; } - // Waits for the specified long-running operation until it is done or reaches - // at most a specified timeout, returning the latest state. If the operation - // is already done, the latest state is immediately returned. If the timeout + // Waits until the specified long-running operation is done or reaches at most + // a specified timeout, returning the latest state. If the operation is + // already done, the latest state is immediately returned. If the timeout // specified is greater than the default HTTP/RPC timeout, the HTTP/RPC // timeout is used. If the server does not support this method, it returns // `google.rpc.Code.UNIMPLEMENTED`. diff --git a/synth.metadata b/synth.metadata index 3b881a412..437a49c84 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "e632e949cf57fc55b73c1a88c4837b01bca39061" + "sha": "1f8dc26032ef20ab874b70b1ae74988df484aec4" } }, { From d960fbb5ca20a7eb9594e8c0b2dfabdb0cb473e3 Mon Sep 17 00:00:00 2001 From: Robin Hellemans Date: Mon, 15 Feb 2021 22:24:49 +0100 Subject: [PATCH 252/337] fix: update "protobufjs" to be a dependency (#1425) --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ebd213bdb..f0240ec23 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,8 @@ "dependencies": { "fast-deep-equal": "^3.1.1", "functional-red-black-tree": "^1.0.1", - "google-gax": "^2.9.2" + "google-gax": "^2.9.2", + "protobufjs": "^6.8.6" }, "devDependencies": { "@types/assert": "^1.4.0", @@ -79,7 +80,6 @@ "length-prefixed-json-stream": "^1.0.1", "linkinator": "^2.0.0", "mocha": "^7.0.0", - "protobufjs": "^6.8.6", "proxyquire": "^2.1.3", "sinon": "^9.0.2", "ts-node": "^9.0.0", From 685e75cf447b80679fc5a94731f5307d4601b750 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 15 Feb 2021 17:56:11 -0700 Subject: [PATCH 253/337] chore: release 4.9.4 (#1426) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca43057a2..5d32def85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.9.4](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.3...v4.9.4) (2021-02-15) + + +### Bug Fixes + +* update "protobufjs" to be a dependency ([#1425](https://www.github.com/googleapis/nodejs-firestore/issues/1425)) ([d960fbb](https://www.github.com/googleapis/nodejs-firestore/commit/d960fbb5ca20a7eb9594e8c0b2dfabdb0cb473e3)) + ### [4.9.3](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.2...v4.9.3) (2021-02-09) diff --git a/package.json b/package.json index f0240ec23..d4a681581 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.9.3", + "version": "4.9.4", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 81dcaa296..3a1843af7 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.9.3" + "@google-cloud/firestore": "^4.9.4" }, "devDependencies": { "chai": "^4.2.0", From 5f6683c2177aa7bd80ec81c3942443453b834529 Mon Sep 17 00:00:00 2001 From: CamWass <11511964+CamWass@users.noreply.github.com> Date: Mon, 1 Mar 2021 21:27:04 +1300 Subject: [PATCH 254/337] chore: Fix typos (#1432) * Fis spelling * Fix .d.ts as well --- dev/src/bulk-writer.ts | 2 +- dev/src/query-partition.ts | 2 +- dev/src/reference.ts | 4 ++-- dev/src/timestamp.ts | 4 ++-- dev/test/watch.ts | 2 +- types/firestore.d.ts | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 694824b87..02585c3b3 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -655,7 +655,7 @@ export class BulkWriter { /** * Commits all enqueued writes and marks the BulkWriter instance as closed. * - * After calling `close()`, calling any method wil throw an error. Any + * After calling `close()`, calling any method will throw an error. Any * retries scheduled as part of an `onWriteError()` handler will be run * before the `close()` promise resolves. * diff --git a/dev/src/query-partition.ts b/dev/src/query-partition.ts index 04cf2f6e5..34cb21a97 100644 --- a/dev/src/query-partition.ts +++ b/dev/src/query-partition.ts @@ -133,7 +133,7 @@ export class QueryPartition */ toQuery(): Query { // Since the api.Value to JavaScript type conversion can be lossy (unless - // `useBigInt` is used), we pass the original protobuf representaion to the + // `useBigInt` is used), we pass the original protobuf representation to the // created query. let queryOptions = QueryOptions.forCollectionGroupQuery( this._collectionId, diff --git a/dev/src/reference.ts b/dev/src/reference.ts index ae1050fee..40953c5c9 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -213,8 +213,8 @@ export class DocumentReference } /** - * A reference to the collection to which this DocumentRference belongs. - *e + * A reference to the collection to which this DocumentReference belongs. + * * @name DocumentReference#parent * @type {CollectionReference} * @readonly diff --git a/dev/src/timestamp.ts b/dev/src/timestamp.ts index bbc10aa98..a50e62bb2 100644 --- a/dev/src/timestamp.ts +++ b/dev/src/timestamp.ts @@ -278,10 +278,10 @@ export class Timestamp implements firestore.Timestamp { valueOf(): string { // This method returns a string of the form . where is // translated to have a non-negative value and both and are left-padded - // with zeroes to be a consistent length. Strings with this format then have a lexiographical + // with zeroes to be a consistent length. Strings with this format then have a lexicographical // ordering that matches the expected ordering. The translation is done to avoid // having a leading negative sign (i.e. a leading '-' character) in its string representation, - // which would affect its lexiographical ordering. + // which would affect its lexicographical ordering. const adjustedSeconds = this.seconds - MIN_SECONDS; // Note: Up to 12 decimal digits are required to represent all valid 'seconds' values. const formattedSeconds = String(adjustedSeconds).padStart(12, '0'); diff --git a/dev/test/watch.ts b/dev/test/watch.ts index 94cdc6a12..65cfea72f 100644 --- a/dev/test/watch.ts +++ b/dev/test/watch.ts @@ -2281,7 +2281,7 @@ describe('DocumentReference watch', () => { beforeEach(() => { // We are intentionally skipping the delays to ensure fast test execution. - // The retry semantics are uneffected by this, as we maintain their + // The retry semantics are unaffected by this, as we maintain their // asynchronous behavior. setTimeoutHandler((op, timeout) => { if (timeout !== WATCH_IDLE_TIMEOUT_MS) { diff --git a/types/firestore.d.ts b/types/firestore.d.ts index f43d90a6b..e0802ea51 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -658,7 +658,7 @@ declare namespace FirebaseFirestore { /** * Commits all enqueued writes and marks the BulkWriter instance as closed. * - * After calling `close()`, calling any method wil throw an error. Any + * After calling `close()`, calling any method will throw an error. Any * retries scheduled as part of an `onWriteError()` handler will be run * before the `close()` promise resolves. * From b1409efac8c769d5858fcb938bae2dbff3fb9b59 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Mon, 1 Mar 2021 15:19:06 -0800 Subject: [PATCH 255/337] chore: update license.js to 2021 (#1434) --- scripts/license.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/license.js b/scripts/license.js index 828e91906..2a58fb5a7 100755 --- a/scripts/license.js +++ b/scripts/license.js @@ -17,7 +17,7 @@ const fs = require('fs'); const LICENSE_HEADER = `/*! - * Copyright 2020 Google LLC + * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 071c27b5d32e33c3e7033ce977978f3bb6aaa5f2 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 2 Mar 2021 08:29:44 -0800 Subject: [PATCH 256/337] [CHANGE ME] Re-generated to pick up changes from self. (#1435) --- dev/protos/firestore_admin_v1_proto_api.d.ts | 2 +- dev/protos/firestore_admin_v1_proto_api.js | 2 +- dev/protos/firestore_v1_proto_api.d.ts | 2 +- dev/protos/firestore_v1_proto_api.js | 2 +- dev/protos/firestore_v1beta1_proto_api.d.ts | 2 +- dev/protos/firestore_v1beta1_proto_api.js | 2 +- synth.metadata | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dev/protos/firestore_admin_v1_proto_api.d.ts b/dev/protos/firestore_admin_v1_proto_api.d.ts index 343b4cf63..37ad40a47 100644 --- a/dev/protos/firestore_admin_v1_proto_api.d.ts +++ b/dev/protos/firestore_admin_v1_proto_api.d.ts @@ -1,5 +1,5 @@ /*! - * Copyright 2020 Google LLC + * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/dev/protos/firestore_admin_v1_proto_api.js b/dev/protos/firestore_admin_v1_proto_api.js index 8fe6ecefd..eebf6ce7d 100644 --- a/dev/protos/firestore_admin_v1_proto_api.js +++ b/dev/protos/firestore_admin_v1_proto_api.js @@ -1,5 +1,5 @@ /*! - * Copyright 2020 Google LLC + * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/dev/protos/firestore_v1_proto_api.d.ts b/dev/protos/firestore_v1_proto_api.d.ts index 1578badfd..8ff113db2 100644 --- a/dev/protos/firestore_v1_proto_api.d.ts +++ b/dev/protos/firestore_v1_proto_api.d.ts @@ -1,5 +1,5 @@ /*! - * Copyright 2020 Google LLC + * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/dev/protos/firestore_v1_proto_api.js b/dev/protos/firestore_v1_proto_api.js index b6f971dc4..a43075136 100644 --- a/dev/protos/firestore_v1_proto_api.js +++ b/dev/protos/firestore_v1_proto_api.js @@ -1,5 +1,5 @@ /*! - * Copyright 2020 Google LLC + * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/dev/protos/firestore_v1beta1_proto_api.d.ts b/dev/protos/firestore_v1beta1_proto_api.d.ts index d05faadbb..0086457e8 100644 --- a/dev/protos/firestore_v1beta1_proto_api.d.ts +++ b/dev/protos/firestore_v1beta1_proto_api.d.ts @@ -1,5 +1,5 @@ /*! - * Copyright 2020 Google LLC + * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/dev/protos/firestore_v1beta1_proto_api.js b/dev/protos/firestore_v1beta1_proto_api.js index aae7c0d9e..cd3bed502 100644 --- a/dev/protos/firestore_v1beta1_proto_api.js +++ b/dev/protos/firestore_v1beta1_proto_api.js @@ -1,5 +1,5 @@ /*! - * Copyright 2020 Google LLC + * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/synth.metadata b/synth.metadata index 437a49c84..c6fe45850 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "1f8dc26032ef20ab874b70b1ae74988df484aec4" + "sha": "b1409efac8c769d5858fcb938bae2dbff3fb9b59" } }, { From 47238a926471dee8bdeaa38bcb5f772c7f20349f Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 2 Mar 2021 14:29:24 -0800 Subject: [PATCH 257/337] fix: add typings to v1 and v1beta in firestore.d.ts (#1433) --- dev/protos/protos.json | 3 +- dev/protos/update.sh | 2 +- synth.metadata | 10 +- synth.py | 26 +- types/firestore.d.ts | 17 +- .../protos/firestore_admin_v1_proto_api.d.ts | 4808 +++++++++++ types/protos/firestore_v1_proto_api.d.ts | 7132 +++++++++++++++++ types/protos/firestore_v1beta1_proto_api.d.ts | 6563 +++++++++++++++ types/v1/firestore_admin_client.d.ts | 810 ++ types/v1/firestore_client.d.ts | 867 ++ types/v1beta1/firestore_client.d.ts | 702 ++ 11 files changed, 20924 insertions(+), 16 deletions(-) create mode 100644 types/protos/firestore_admin_v1_proto_api.d.ts create mode 100644 types/protos/firestore_v1_proto_api.d.ts create mode 100644 types/protos/firestore_v1beta1_proto_api.d.ts create mode 100644 types/v1/firestore_admin_client.d.ts create mode 100644 types/v1/firestore_client.d.ts create mode 100644 types/v1beta1/firestore_client.d.ts diff --git a/dev/protos/protos.json b/dev/protos/protos.json index 3c9a3370f..753b9b1f9 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -3973,8 +3973,7 @@ "REQUIRED": 2, "OUTPUT_ONLY": 3, "INPUT_ONLY": 4, - "IMMUTABLE": 5, - "UNORDERED_LIST": 6 + "IMMUTABLE": 5 } } } diff --git a/dev/protos/update.sh b/dev/protos/update.sh index d5d8587bd..80d03fcf4 100755 --- a/dev/protos/update.sh +++ b/dev/protos/update.sh @@ -86,7 +86,7 @@ PBJS_ARGS=( --proto_path=. \ --no-verify \ --no-delimited \ --force-enum-string) - + "${PBJS}" "${PBJS_ARGS[@]}" -o firestore_v1_proto_api.js \ -r firestore_v1 \ "${PROTOS_DIR}/google/firestore/v1/*.proto" \ diff --git a/synth.metadata b/synth.metadata index c6fe45850..bb17b7df3 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,23 +3,23 @@ { "git": { "name": ".", - "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "b1409efac8c769d5858fcb938bae2dbff3fb9b59" + "remote": "git@github.com:googleapis/nodejs-firestore.git", + "sha": "dec8d221efd14b732f2cd2973439c1fb48067ce2" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "15af12eb717cd30175825ad412045b9e59b133b4", - "internalRef": "348046114" + "sha": "c5435cb4ae272fc2ed9e059c3d035c09c8fd1273", + "internalRef": "360469636" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "318e351e26ba65b2b3cfa3f61b3b64e3540c3525" + "sha": "21da7d9fa02f6916d9f87cf4072b3547b5c72eb5" } } ], diff --git a/synth.py b/synth.py index 543c23948..2dc885617 100644 --- a/synth.py +++ b/synth.py @@ -159,7 +159,6 @@ os.system('rm -rf dev/system-test/fixtures dev/system-test/install.ts') node.install() -node.fix() os.chdir("dev") node.compile_protos() os.chdir("protos") @@ -167,3 +166,28 @@ os.unlink('protos.d.ts') subprocess.run('./update.sh', shell=True) os.chdir("../../") + +# Copy types into types/ +os.system("cp build/src/v1/firestore*.d.ts types/v1") +os.system("cp build/src/v1beta1/firestore_client.d.ts types/v1beta1") +os.system("cp build/protos/firestore*.d.ts types/protos") +s.replace( + "types/v1/firestore_client.d.ts", + "../../protos", + "../protos" +) +s.replace( + "types/v1/firestore_admin_client.d.ts", + "../../protos", + "../protos" +) +s.replace( + "types/v1beta1/firestore_client.d.ts", + "../../protos", + "../protos" +) +node.fix() + +# Add license headers +os.system("node scripts/license.js types/v1/*.d.ts types/v1beta1/*.d.ts") + diff --git a/types/firestore.d.ts b/types/firestore.d.ts index e0802ea51..8f5c00c20 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -1,13 +1,11 @@ -/** - * @fileoverview Firestore Server API. - * - * Copyright 2017 Google Inc. All Rights Reserved. +/*! + * 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 + * 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, @@ -1964,13 +1962,18 @@ declare namespace FirebaseFirestore { * Firestore v1beta1 RPCs. * @deprecated Use v1 instead. */ - export const v1beta1: any; + export const v1beta1: { + FirestoreClient: import('./v1beta1/firestore_client').FirestoreClient; + }; /** * The v1 Veneer clients. These clients provide access to the Firestore Admin * API and the underlying Firestore v1 RPCs. */ - export const v1: {FirestoreClient: any; FirestoreAdminClient: any}; + export const v1: { + FirestoreClient: import('./v1/firestore_client').FirestoreClient; + FirestoreAdminClient: import('./v1/firestore_admin_client').FirestoreAdminClient; + }; /** * Status codes returned by Firestore's gRPC calls. diff --git a/types/protos/firestore_admin_v1_proto_api.d.ts b/types/protos/firestore_admin_v1_proto_api.d.ts new file mode 100644 index 000000000..37ad40a47 --- /dev/null +++ b/types/protos/firestore_admin_v1_proto_api.d.ts @@ -0,0 +1,4808 @@ +/*! + * Copyright 2021 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 $protobuf from "protobufjs"; +/** Namespace google. */ +export namespace google { + + /** Namespace firestore. */ + namespace firestore { + + /** Namespace admin. */ + namespace admin { + + /** Namespace v1. */ + namespace v1 { + + /** Properties of a Field. */ + interface IField { + + /** Field name */ + name?: (string|null); + + /** Field indexConfig */ + indexConfig?: (google.firestore.admin.v1.Field.IIndexConfig|null); + } + + /** Represents a Field. */ + class Field implements IField { + + /** + * Constructs a new Field. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IField); + + /** Field name. */ + public name: string; + + /** Field indexConfig. */ + public indexConfig?: (google.firestore.admin.v1.Field.IIndexConfig|null); + + /** + * Creates a Field message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Field + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.Field; + + /** + * Creates a plain object from a Field message. Also converts values to other types if specified. + * @param message Field + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.Field, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Field to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace Field { + + /** Properties of an IndexConfig. */ + interface IIndexConfig { + + /** IndexConfig indexes */ + indexes?: (google.firestore.admin.v1.IIndex[]|null); + + /** IndexConfig usesAncestorConfig */ + usesAncestorConfig?: (boolean|null); + + /** IndexConfig ancestorField */ + ancestorField?: (string|null); + + /** IndexConfig reverting */ + reverting?: (boolean|null); + } + + /** Represents an IndexConfig. */ + class IndexConfig implements IIndexConfig { + + /** + * Constructs a new IndexConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.Field.IIndexConfig); + + /** IndexConfig indexes. */ + public indexes: google.firestore.admin.v1.IIndex[]; + + /** IndexConfig usesAncestorConfig. */ + public usesAncestorConfig: boolean; + + /** IndexConfig ancestorField. */ + public ancestorField: string; + + /** IndexConfig reverting. */ + public reverting: boolean; + + /** + * Creates an IndexConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns IndexConfig + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.Field.IndexConfig; + + /** + * Creates a plain object from an IndexConfig message. Also converts values to other types if specified. + * @param message IndexConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.Field.IndexConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this IndexConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Represents a FirestoreAdmin */ + class FirestoreAdmin extends $protobuf.rpc.Service { + + /** + * Constructs a new FirestoreAdmin service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Calls CreateIndex. + * @param request CreateIndexRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public createIndex(request: google.firestore.admin.v1.ICreateIndexRequest, callback: google.firestore.admin.v1.FirestoreAdmin.CreateIndexCallback): void; + + /** + * Calls CreateIndex. + * @param request CreateIndexRequest message or plain object + * @returns Promise + */ + public createIndex(request: google.firestore.admin.v1.ICreateIndexRequest): Promise; + + /** + * Calls ListIndexes. + * @param request ListIndexesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListIndexesResponse + */ + public listIndexes(request: google.firestore.admin.v1.IListIndexesRequest, callback: google.firestore.admin.v1.FirestoreAdmin.ListIndexesCallback): void; + + /** + * Calls ListIndexes. + * @param request ListIndexesRequest message or plain object + * @returns Promise + */ + public listIndexes(request: google.firestore.admin.v1.IListIndexesRequest): Promise; + + /** + * Calls GetIndex. + * @param request GetIndexRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Index + */ + public getIndex(request: google.firestore.admin.v1.IGetIndexRequest, callback: google.firestore.admin.v1.FirestoreAdmin.GetIndexCallback): void; + + /** + * Calls GetIndex. + * @param request GetIndexRequest message or plain object + * @returns Promise + */ + public getIndex(request: google.firestore.admin.v1.IGetIndexRequest): Promise; + + /** + * Calls DeleteIndex. + * @param request DeleteIndexRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteIndex(request: google.firestore.admin.v1.IDeleteIndexRequest, callback: google.firestore.admin.v1.FirestoreAdmin.DeleteIndexCallback): void; + + /** + * Calls DeleteIndex. + * @param request DeleteIndexRequest message or plain object + * @returns Promise + */ + public deleteIndex(request: google.firestore.admin.v1.IDeleteIndexRequest): Promise; + + /** + * Calls GetField. + * @param request GetFieldRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Field + */ + public getField(request: google.firestore.admin.v1.IGetFieldRequest, callback: google.firestore.admin.v1.FirestoreAdmin.GetFieldCallback): void; + + /** + * Calls GetField. + * @param request GetFieldRequest message or plain object + * @returns Promise + */ + public getField(request: google.firestore.admin.v1.IGetFieldRequest): Promise; + + /** + * Calls UpdateField. + * @param request UpdateFieldRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public updateField(request: google.firestore.admin.v1.IUpdateFieldRequest, callback: google.firestore.admin.v1.FirestoreAdmin.UpdateFieldCallback): void; + + /** + * Calls UpdateField. + * @param request UpdateFieldRequest message or plain object + * @returns Promise + */ + public updateField(request: google.firestore.admin.v1.IUpdateFieldRequest): Promise; + + /** + * Calls ListFields. + * @param request ListFieldsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListFieldsResponse + */ + public listFields(request: google.firestore.admin.v1.IListFieldsRequest, callback: google.firestore.admin.v1.FirestoreAdmin.ListFieldsCallback): void; + + /** + * Calls ListFields. + * @param request ListFieldsRequest message or plain object + * @returns Promise + */ + public listFields(request: google.firestore.admin.v1.IListFieldsRequest): Promise; + + /** + * Calls ExportDocuments. + * @param request ExportDocumentsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public exportDocuments(request: google.firestore.admin.v1.IExportDocumentsRequest, callback: google.firestore.admin.v1.FirestoreAdmin.ExportDocumentsCallback): void; + + /** + * Calls ExportDocuments. + * @param request ExportDocumentsRequest message or plain object + * @returns Promise + */ + public exportDocuments(request: google.firestore.admin.v1.IExportDocumentsRequest): Promise; + + /** + * Calls ImportDocuments. + * @param request ImportDocumentsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public importDocuments(request: google.firestore.admin.v1.IImportDocumentsRequest, callback: google.firestore.admin.v1.FirestoreAdmin.ImportDocumentsCallback): void; + + /** + * Calls ImportDocuments. + * @param request ImportDocumentsRequest message or plain object + * @returns Promise + */ + public importDocuments(request: google.firestore.admin.v1.IImportDocumentsRequest): Promise; + } + + namespace FirestoreAdmin { + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#createIndex}. + * @param error Error, if any + * @param [response] Operation + */ + type CreateIndexCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#listIndexes}. + * @param error Error, if any + * @param [response] ListIndexesResponse + */ + type ListIndexesCallback = (error: (Error|null), response?: google.firestore.admin.v1.ListIndexesResponse) => void; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#getIndex}. + * @param error Error, if any + * @param [response] Index + */ + type GetIndexCallback = (error: (Error|null), response?: google.firestore.admin.v1.Index) => void; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#deleteIndex}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteIndexCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#getField}. + * @param error Error, if any + * @param [response] Field + */ + type GetFieldCallback = (error: (Error|null), response?: google.firestore.admin.v1.Field) => void; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#updateField}. + * @param error Error, if any + * @param [response] Operation + */ + type UpdateFieldCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#listFields}. + * @param error Error, if any + * @param [response] ListFieldsResponse + */ + type ListFieldsCallback = (error: (Error|null), response?: google.firestore.admin.v1.ListFieldsResponse) => void; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#exportDocuments}. + * @param error Error, if any + * @param [response] Operation + */ + type ExportDocumentsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.firestore.admin.v1.FirestoreAdmin#importDocuments}. + * @param error Error, if any + * @param [response] Operation + */ + type ImportDocumentsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of a CreateIndexRequest. */ + interface ICreateIndexRequest { + + /** CreateIndexRequest parent */ + parent?: (string|null); + + /** CreateIndexRequest index */ + index?: (google.firestore.admin.v1.IIndex|null); + } + + /** Represents a CreateIndexRequest. */ + class CreateIndexRequest implements ICreateIndexRequest { + + /** + * Constructs a new CreateIndexRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.ICreateIndexRequest); + + /** CreateIndexRequest parent. */ + public parent: string; + + /** CreateIndexRequest index. */ + public index?: (google.firestore.admin.v1.IIndex|null); + + /** + * Creates a CreateIndexRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateIndexRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.CreateIndexRequest; + + /** + * Creates a plain object from a CreateIndexRequest message. Also converts values to other types if specified. + * @param message CreateIndexRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.CreateIndexRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateIndexRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListIndexesRequest. */ + interface IListIndexesRequest { + + /** ListIndexesRequest parent */ + parent?: (string|null); + + /** ListIndexesRequest filter */ + filter?: (string|null); + + /** ListIndexesRequest pageSize */ + pageSize?: (number|null); + + /** ListIndexesRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListIndexesRequest. */ + class ListIndexesRequest implements IListIndexesRequest { + + /** + * Constructs a new ListIndexesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IListIndexesRequest); + + /** ListIndexesRequest parent. */ + public parent: string; + + /** ListIndexesRequest filter. */ + public filter: string; + + /** ListIndexesRequest pageSize. */ + public pageSize: number; + + /** ListIndexesRequest pageToken. */ + public pageToken: string; + + /** + * Creates a ListIndexesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListIndexesRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ListIndexesRequest; + + /** + * Creates a plain object from a ListIndexesRequest message. Also converts values to other types if specified. + * @param message ListIndexesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ListIndexesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListIndexesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListIndexesResponse. */ + interface IListIndexesResponse { + + /** ListIndexesResponse indexes */ + indexes?: (google.firestore.admin.v1.IIndex[]|null); + + /** ListIndexesResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListIndexesResponse. */ + class ListIndexesResponse implements IListIndexesResponse { + + /** + * Constructs a new ListIndexesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IListIndexesResponse); + + /** ListIndexesResponse indexes. */ + public indexes: google.firestore.admin.v1.IIndex[]; + + /** ListIndexesResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a ListIndexesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListIndexesResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ListIndexesResponse; + + /** + * Creates a plain object from a ListIndexesResponse message. Also converts values to other types if specified. + * @param message ListIndexesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ListIndexesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListIndexesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a GetIndexRequest. */ + interface IGetIndexRequest { + + /** GetIndexRequest name */ + name?: (string|null); + } + + /** Represents a GetIndexRequest. */ + class GetIndexRequest implements IGetIndexRequest { + + /** + * Constructs a new GetIndexRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IGetIndexRequest); + + /** GetIndexRequest name. */ + public name: string; + + /** + * Creates a GetIndexRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetIndexRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.GetIndexRequest; + + /** + * Creates a plain object from a GetIndexRequest message. Also converts values to other types if specified. + * @param message GetIndexRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.GetIndexRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetIndexRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DeleteIndexRequest. */ + interface IDeleteIndexRequest { + + /** DeleteIndexRequest name */ + name?: (string|null); + } + + /** Represents a DeleteIndexRequest. */ + class DeleteIndexRequest implements IDeleteIndexRequest { + + /** + * Constructs a new DeleteIndexRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IDeleteIndexRequest); + + /** DeleteIndexRequest name. */ + public name: string; + + /** + * Creates a DeleteIndexRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteIndexRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.DeleteIndexRequest; + + /** + * Creates a plain object from a DeleteIndexRequest message. Also converts values to other types if specified. + * @param message DeleteIndexRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.DeleteIndexRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteIndexRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an UpdateFieldRequest. */ + interface IUpdateFieldRequest { + + /** UpdateFieldRequest field */ + field?: (google.firestore.admin.v1.IField|null); + + /** UpdateFieldRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateFieldRequest. */ + class UpdateFieldRequest implements IUpdateFieldRequest { + + /** + * Constructs a new UpdateFieldRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IUpdateFieldRequest); + + /** UpdateFieldRequest field. */ + public field?: (google.firestore.admin.v1.IField|null); + + /** UpdateFieldRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates an UpdateFieldRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateFieldRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.UpdateFieldRequest; + + /** + * Creates a plain object from an UpdateFieldRequest message. Also converts values to other types if specified. + * @param message UpdateFieldRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.UpdateFieldRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateFieldRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a GetFieldRequest. */ + interface IGetFieldRequest { + + /** GetFieldRequest name */ + name?: (string|null); + } + + /** Represents a GetFieldRequest. */ + class GetFieldRequest implements IGetFieldRequest { + + /** + * Constructs a new GetFieldRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IGetFieldRequest); + + /** GetFieldRequest name. */ + public name: string; + + /** + * Creates a GetFieldRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetFieldRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.GetFieldRequest; + + /** + * Creates a plain object from a GetFieldRequest message. Also converts values to other types if specified. + * @param message GetFieldRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.GetFieldRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetFieldRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListFieldsRequest. */ + interface IListFieldsRequest { + + /** ListFieldsRequest parent */ + parent?: (string|null); + + /** ListFieldsRequest filter */ + filter?: (string|null); + + /** ListFieldsRequest pageSize */ + pageSize?: (number|null); + + /** ListFieldsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListFieldsRequest. */ + class ListFieldsRequest implements IListFieldsRequest { + + /** + * Constructs a new ListFieldsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IListFieldsRequest); + + /** ListFieldsRequest parent. */ + public parent: string; + + /** ListFieldsRequest filter. */ + public filter: string; + + /** ListFieldsRequest pageSize. */ + public pageSize: number; + + /** ListFieldsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a ListFieldsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListFieldsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ListFieldsRequest; + + /** + * Creates a plain object from a ListFieldsRequest message. Also converts values to other types if specified. + * @param message ListFieldsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ListFieldsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListFieldsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListFieldsResponse. */ + interface IListFieldsResponse { + + /** ListFieldsResponse fields */ + fields?: (google.firestore.admin.v1.IField[]|null); + + /** ListFieldsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListFieldsResponse. */ + class ListFieldsResponse implements IListFieldsResponse { + + /** + * Constructs a new ListFieldsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IListFieldsResponse); + + /** ListFieldsResponse fields. */ + public fields: google.firestore.admin.v1.IField[]; + + /** ListFieldsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a ListFieldsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListFieldsResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ListFieldsResponse; + + /** + * Creates a plain object from a ListFieldsResponse message. Also converts values to other types if specified. + * @param message ListFieldsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ListFieldsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListFieldsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an ExportDocumentsRequest. */ + interface IExportDocumentsRequest { + + /** ExportDocumentsRequest name */ + name?: (string|null); + + /** ExportDocumentsRequest collectionIds */ + collectionIds?: (string[]|null); + + /** ExportDocumentsRequest outputUriPrefix */ + outputUriPrefix?: (string|null); + } + + /** Represents an ExportDocumentsRequest. */ + class ExportDocumentsRequest implements IExportDocumentsRequest { + + /** + * Constructs a new ExportDocumentsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IExportDocumentsRequest); + + /** ExportDocumentsRequest name. */ + public name: string; + + /** ExportDocumentsRequest collectionIds. */ + public collectionIds: string[]; + + /** ExportDocumentsRequest outputUriPrefix. */ + public outputUriPrefix: string; + + /** + * Creates an ExportDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportDocumentsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ExportDocumentsRequest; + + /** + * Creates a plain object from an ExportDocumentsRequest message. Also converts values to other types if specified. + * @param message ExportDocumentsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ExportDocumentsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportDocumentsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an ImportDocumentsRequest. */ + interface IImportDocumentsRequest { + + /** ImportDocumentsRequest name */ + name?: (string|null); + + /** ImportDocumentsRequest collectionIds */ + collectionIds?: (string[]|null); + + /** ImportDocumentsRequest inputUriPrefix */ + inputUriPrefix?: (string|null); + } + + /** Represents an ImportDocumentsRequest. */ + class ImportDocumentsRequest implements IImportDocumentsRequest { + + /** + * Constructs a new ImportDocumentsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IImportDocumentsRequest); + + /** ImportDocumentsRequest name. */ + public name: string; + + /** ImportDocumentsRequest collectionIds. */ + public collectionIds: string[]; + + /** ImportDocumentsRequest inputUriPrefix. */ + public inputUriPrefix: string; + + /** + * Creates an ImportDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportDocumentsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ImportDocumentsRequest; + + /** + * Creates a plain object from an ImportDocumentsRequest message. Also converts values to other types if specified. + * @param message ImportDocumentsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ImportDocumentsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportDocumentsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an Index. */ + interface IIndex { + + /** Index name */ + name?: (string|null); + + /** Index queryScope */ + queryScope?: (google.firestore.admin.v1.Index.QueryScope|null); + + /** Index fields */ + fields?: (google.firestore.admin.v1.Index.IIndexField[]|null); + + /** Index state */ + state?: (google.firestore.admin.v1.Index.State|null); + } + + /** Represents an Index. */ + class Index implements IIndex { + + /** + * Constructs a new Index. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IIndex); + + /** Index name. */ + public name: string; + + /** Index queryScope. */ + public queryScope: google.firestore.admin.v1.Index.QueryScope; + + /** Index fields. */ + public fields: google.firestore.admin.v1.Index.IIndexField[]; + + /** Index state. */ + public state: google.firestore.admin.v1.Index.State; + + /** + * Creates an Index message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Index + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.Index; + + /** + * Creates a plain object from an Index message. Also converts values to other types if specified. + * @param message Index + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.Index, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Index to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace Index { + + /** Properties of an IndexField. */ + interface IIndexField { + + /** IndexField fieldPath */ + fieldPath?: (string|null); + + /** IndexField order */ + order?: (google.firestore.admin.v1.Index.IndexField.Order|null); + + /** IndexField arrayConfig */ + arrayConfig?: (google.firestore.admin.v1.Index.IndexField.ArrayConfig|null); + } + + /** Represents an IndexField. */ + class IndexField implements IIndexField { + + /** + * Constructs a new IndexField. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.Index.IIndexField); + + /** IndexField fieldPath. */ + public fieldPath: string; + + /** IndexField order. */ + public order: google.firestore.admin.v1.Index.IndexField.Order; + + /** IndexField arrayConfig. */ + public arrayConfig: google.firestore.admin.v1.Index.IndexField.ArrayConfig; + + /** IndexField valueMode. */ + public valueMode?: ("order"|"arrayConfig"); + + /** + * Creates an IndexField message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns IndexField + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.Index.IndexField; + + /** + * Creates a plain object from an IndexField message. Also converts values to other types if specified. + * @param message IndexField + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.Index.IndexField, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this IndexField to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace IndexField { + + /** Order enum. */ + type Order = + "ORDER_UNSPECIFIED"| "ASCENDING"| "DESCENDING"; + + /** ArrayConfig enum. */ + type ArrayConfig = + "ARRAY_CONFIG_UNSPECIFIED"| "CONTAINS"; + } + + /** QueryScope enum. */ + type QueryScope = + "QUERY_SCOPE_UNSPECIFIED"| "COLLECTION"| "COLLECTION_GROUP"; + + /** State enum. */ + type State = + "STATE_UNSPECIFIED"| "CREATING"| "READY"| "NEEDS_REPAIR"; + } + + /** Properties of a LocationMetadata. */ + interface ILocationMetadata { + } + + /** Represents a LocationMetadata. */ + class LocationMetadata implements ILocationMetadata { + + /** + * Constructs a new LocationMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.ILocationMetadata); + + /** + * Creates a LocationMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LocationMetadata + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.LocationMetadata; + + /** + * Creates a plain object from a LocationMetadata message. Also converts values to other types if specified. + * @param message LocationMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.LocationMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LocationMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an IndexOperationMetadata. */ + interface IIndexOperationMetadata { + + /** IndexOperationMetadata startTime */ + startTime?: (google.protobuf.ITimestamp|null); + + /** IndexOperationMetadata endTime */ + endTime?: (google.protobuf.ITimestamp|null); + + /** IndexOperationMetadata index */ + index?: (string|null); + + /** IndexOperationMetadata state */ + state?: (google.firestore.admin.v1.OperationState|null); + + /** IndexOperationMetadata progressDocuments */ + progressDocuments?: (google.firestore.admin.v1.IProgress|null); + + /** IndexOperationMetadata progressBytes */ + progressBytes?: (google.firestore.admin.v1.IProgress|null); + } + + /** Represents an IndexOperationMetadata. */ + class IndexOperationMetadata implements IIndexOperationMetadata { + + /** + * Constructs a new IndexOperationMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IIndexOperationMetadata); + + /** IndexOperationMetadata startTime. */ + public startTime?: (google.protobuf.ITimestamp|null); + + /** IndexOperationMetadata endTime. */ + public endTime?: (google.protobuf.ITimestamp|null); + + /** IndexOperationMetadata index. */ + public index: string; + + /** IndexOperationMetadata state. */ + public state: google.firestore.admin.v1.OperationState; + + /** IndexOperationMetadata progressDocuments. */ + public progressDocuments?: (google.firestore.admin.v1.IProgress|null); + + /** IndexOperationMetadata progressBytes. */ + public progressBytes?: (google.firestore.admin.v1.IProgress|null); + + /** + * Creates an IndexOperationMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns IndexOperationMetadata + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.IndexOperationMetadata; + + /** + * Creates a plain object from an IndexOperationMetadata message. Also converts values to other types if specified. + * @param message IndexOperationMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.IndexOperationMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this IndexOperationMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FieldOperationMetadata. */ + interface IFieldOperationMetadata { + + /** FieldOperationMetadata startTime */ + startTime?: (google.protobuf.ITimestamp|null); + + /** FieldOperationMetadata endTime */ + endTime?: (google.protobuf.ITimestamp|null); + + /** FieldOperationMetadata field */ + field?: (string|null); + + /** FieldOperationMetadata indexConfigDeltas */ + indexConfigDeltas?: (google.firestore.admin.v1.FieldOperationMetadata.IIndexConfigDelta[]|null); + + /** FieldOperationMetadata state */ + state?: (google.firestore.admin.v1.OperationState|null); + + /** FieldOperationMetadata progressDocuments */ + progressDocuments?: (google.firestore.admin.v1.IProgress|null); + + /** FieldOperationMetadata progressBytes */ + progressBytes?: (google.firestore.admin.v1.IProgress|null); + } + + /** Represents a FieldOperationMetadata. */ + class FieldOperationMetadata implements IFieldOperationMetadata { + + /** + * Constructs a new FieldOperationMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IFieldOperationMetadata); + + /** FieldOperationMetadata startTime. */ + public startTime?: (google.protobuf.ITimestamp|null); + + /** FieldOperationMetadata endTime. */ + public endTime?: (google.protobuf.ITimestamp|null); + + /** FieldOperationMetadata field. */ + public field: string; + + /** FieldOperationMetadata indexConfigDeltas. */ + public indexConfigDeltas: google.firestore.admin.v1.FieldOperationMetadata.IIndexConfigDelta[]; + + /** FieldOperationMetadata state. */ + public state: google.firestore.admin.v1.OperationState; + + /** FieldOperationMetadata progressDocuments. */ + public progressDocuments?: (google.firestore.admin.v1.IProgress|null); + + /** FieldOperationMetadata progressBytes. */ + public progressBytes?: (google.firestore.admin.v1.IProgress|null); + + /** + * Creates a FieldOperationMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldOperationMetadata + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.FieldOperationMetadata; + + /** + * Creates a plain object from a FieldOperationMetadata message. Also converts values to other types if specified. + * @param message FieldOperationMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.FieldOperationMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldOperationMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace FieldOperationMetadata { + + /** Properties of an IndexConfigDelta. */ + interface IIndexConfigDelta { + + /** IndexConfigDelta changeType */ + changeType?: (google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType|null); + + /** IndexConfigDelta index */ + index?: (google.firestore.admin.v1.IIndex|null); + } + + /** Represents an IndexConfigDelta. */ + class IndexConfigDelta implements IIndexConfigDelta { + + /** + * Constructs a new IndexConfigDelta. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.FieldOperationMetadata.IIndexConfigDelta); + + /** IndexConfigDelta changeType. */ + public changeType: google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType; + + /** IndexConfigDelta index. */ + public index?: (google.firestore.admin.v1.IIndex|null); + + /** + * Creates an IndexConfigDelta message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns IndexConfigDelta + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta; + + /** + * Creates a plain object from an IndexConfigDelta message. Also converts values to other types if specified. + * @param message IndexConfigDelta + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this IndexConfigDelta to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace IndexConfigDelta { + + /** ChangeType enum. */ + type ChangeType = + "CHANGE_TYPE_UNSPECIFIED"| "ADD"| "REMOVE"; + } + } + + /** Properties of an ExportDocumentsMetadata. */ + interface IExportDocumentsMetadata { + + /** ExportDocumentsMetadata startTime */ + startTime?: (google.protobuf.ITimestamp|null); + + /** ExportDocumentsMetadata endTime */ + endTime?: (google.protobuf.ITimestamp|null); + + /** ExportDocumentsMetadata operationState */ + operationState?: (google.firestore.admin.v1.OperationState|null); + + /** ExportDocumentsMetadata progressDocuments */ + progressDocuments?: (google.firestore.admin.v1.IProgress|null); + + /** ExportDocumentsMetadata progressBytes */ + progressBytes?: (google.firestore.admin.v1.IProgress|null); + + /** ExportDocumentsMetadata collectionIds */ + collectionIds?: (string[]|null); + + /** ExportDocumentsMetadata outputUriPrefix */ + outputUriPrefix?: (string|null); + } + + /** Represents an ExportDocumentsMetadata. */ + class ExportDocumentsMetadata implements IExportDocumentsMetadata { + + /** + * Constructs a new ExportDocumentsMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IExportDocumentsMetadata); + + /** ExportDocumentsMetadata startTime. */ + public startTime?: (google.protobuf.ITimestamp|null); + + /** ExportDocumentsMetadata endTime. */ + public endTime?: (google.protobuf.ITimestamp|null); + + /** ExportDocumentsMetadata operationState. */ + public operationState: google.firestore.admin.v1.OperationState; + + /** ExportDocumentsMetadata progressDocuments. */ + public progressDocuments?: (google.firestore.admin.v1.IProgress|null); + + /** ExportDocumentsMetadata progressBytes. */ + public progressBytes?: (google.firestore.admin.v1.IProgress|null); + + /** ExportDocumentsMetadata collectionIds. */ + public collectionIds: string[]; + + /** ExportDocumentsMetadata outputUriPrefix. */ + public outputUriPrefix: string; + + /** + * Creates an ExportDocumentsMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportDocumentsMetadata + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ExportDocumentsMetadata; + + /** + * Creates a plain object from an ExportDocumentsMetadata message. Also converts values to other types if specified. + * @param message ExportDocumentsMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ExportDocumentsMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportDocumentsMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an ImportDocumentsMetadata. */ + interface IImportDocumentsMetadata { + + /** ImportDocumentsMetadata startTime */ + startTime?: (google.protobuf.ITimestamp|null); + + /** ImportDocumentsMetadata endTime */ + endTime?: (google.protobuf.ITimestamp|null); + + /** ImportDocumentsMetadata operationState */ + operationState?: (google.firestore.admin.v1.OperationState|null); + + /** ImportDocumentsMetadata progressDocuments */ + progressDocuments?: (google.firestore.admin.v1.IProgress|null); + + /** ImportDocumentsMetadata progressBytes */ + progressBytes?: (google.firestore.admin.v1.IProgress|null); + + /** ImportDocumentsMetadata collectionIds */ + collectionIds?: (string[]|null); + + /** ImportDocumentsMetadata inputUriPrefix */ + inputUriPrefix?: (string|null); + } + + /** Represents an ImportDocumentsMetadata. */ + class ImportDocumentsMetadata implements IImportDocumentsMetadata { + + /** + * Constructs a new ImportDocumentsMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IImportDocumentsMetadata); + + /** ImportDocumentsMetadata startTime. */ + public startTime?: (google.protobuf.ITimestamp|null); + + /** ImportDocumentsMetadata endTime. */ + public endTime?: (google.protobuf.ITimestamp|null); + + /** ImportDocumentsMetadata operationState. */ + public operationState: google.firestore.admin.v1.OperationState; + + /** ImportDocumentsMetadata progressDocuments. */ + public progressDocuments?: (google.firestore.admin.v1.IProgress|null); + + /** ImportDocumentsMetadata progressBytes. */ + public progressBytes?: (google.firestore.admin.v1.IProgress|null); + + /** ImportDocumentsMetadata collectionIds. */ + public collectionIds: string[]; + + /** ImportDocumentsMetadata inputUriPrefix. */ + public inputUriPrefix: string; + + /** + * Creates an ImportDocumentsMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportDocumentsMetadata + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ImportDocumentsMetadata; + + /** + * Creates a plain object from an ImportDocumentsMetadata message. Also converts values to other types if specified. + * @param message ImportDocumentsMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ImportDocumentsMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportDocumentsMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an ExportDocumentsResponse. */ + interface IExportDocumentsResponse { + + /** ExportDocumentsResponse outputUriPrefix */ + outputUriPrefix?: (string|null); + } + + /** Represents an ExportDocumentsResponse. */ + class ExportDocumentsResponse implements IExportDocumentsResponse { + + /** + * Constructs a new ExportDocumentsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IExportDocumentsResponse); + + /** ExportDocumentsResponse outputUriPrefix. */ + public outputUriPrefix: string; + + /** + * Creates an ExportDocumentsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportDocumentsResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.ExportDocumentsResponse; + + /** + * Creates a plain object from an ExportDocumentsResponse message. Also converts values to other types if specified. + * @param message ExportDocumentsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.ExportDocumentsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportDocumentsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Progress. */ + interface IProgress { + + /** Progress estimatedWork */ + estimatedWork?: (number|string|null); + + /** Progress completedWork */ + completedWork?: (number|string|null); + } + + /** Represents a Progress. */ + class Progress implements IProgress { + + /** + * Constructs a new Progress. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.admin.v1.IProgress); + + /** Progress estimatedWork. */ + public estimatedWork: (number|string); + + /** Progress completedWork. */ + public completedWork: (number|string); + + /** + * Creates a Progress message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Progress + */ + public static fromObject(object: { [k: string]: any }): google.firestore.admin.v1.Progress; + + /** + * Creates a plain object from a Progress message. Also converts values to other types if specified. + * @param message Progress + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.admin.v1.Progress, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Progress to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** OperationState enum. */ + type OperationState = + "OPERATION_STATE_UNSPECIFIED"| "INITIALIZING"| "PROCESSING"| "CANCELLING"| "FINALIZING"| "SUCCESSFUL"| "FAILED"| "CANCELLED"; + } + } + } + + /** Namespace api. */ + namespace api { + + /** Properties of a Http. */ + interface IHttp { + + /** Http rules */ + rules?: (google.api.IHttpRule[]|null); + } + + /** Represents a Http. */ + class Http implements IHttp { + + /** + * Constructs a new Http. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IHttp); + + /** Http rules. */ + public rules: google.api.IHttpRule[]; + + /** + * Creates a Http message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Http + */ + public static fromObject(object: { [k: string]: any }): google.api.Http; + + /** + * Creates a plain object from a Http message. Also converts values to other types if specified. + * @param message Http + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.Http, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Http to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a HttpRule. */ + interface IHttpRule { + + /** HttpRule get */ + get?: (string|null); + + /** HttpRule put */ + put?: (string|null); + + /** HttpRule post */ + post?: (string|null); + + /** HttpRule delete */ + "delete"?: (string|null); + + /** HttpRule patch */ + patch?: (string|null); + + /** HttpRule custom */ + custom?: (google.api.ICustomHttpPattern|null); + + /** HttpRule selector */ + selector?: (string|null); + + /** HttpRule body */ + body?: (string|null); + + /** HttpRule additionalBindings */ + additionalBindings?: (google.api.IHttpRule[]|null); + } + + /** Represents a HttpRule. */ + class HttpRule implements IHttpRule { + + /** + * Constructs a new HttpRule. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IHttpRule); + + /** HttpRule get. */ + public get: string; + + /** HttpRule put. */ + public put: string; + + /** HttpRule post. */ + public post: string; + + /** HttpRule delete. */ + public delete: string; + + /** HttpRule patch. */ + public patch: string; + + /** HttpRule custom. */ + public custom?: (google.api.ICustomHttpPattern|null); + + /** HttpRule selector. */ + public selector: string; + + /** HttpRule body. */ + public body: string; + + /** HttpRule additionalBindings. */ + public additionalBindings: google.api.IHttpRule[]; + + /** HttpRule pattern. */ + public pattern?: ("get"|"put"|"post"|"delete"|"patch"|"custom"); + + /** + * Creates a HttpRule message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns HttpRule + */ + public static fromObject(object: { [k: string]: any }): google.api.HttpRule; + + /** + * Creates a plain object from a HttpRule message. Also converts values to other types if specified. + * @param message HttpRule + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.HttpRule, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this HttpRule to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CustomHttpPattern. */ + interface ICustomHttpPattern { + + /** CustomHttpPattern kind */ + kind?: (string|null); + + /** CustomHttpPattern path */ + path?: (string|null); + } + + /** Represents a CustomHttpPattern. */ + class CustomHttpPattern implements ICustomHttpPattern { + + /** + * Constructs a new CustomHttpPattern. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ICustomHttpPattern); + + /** CustomHttpPattern kind. */ + public kind: string; + + /** CustomHttpPattern path. */ + public path: string; + + /** + * Creates a CustomHttpPattern message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CustomHttpPattern + */ + public static fromObject(object: { [k: string]: any }): google.api.CustomHttpPattern; + + /** + * Creates a plain object from a CustomHttpPattern message. Also converts values to other types if specified. + * @param message CustomHttpPattern + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.CustomHttpPattern, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CustomHttpPattern to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** FieldBehavior enum. */ + type FieldBehavior = + "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"; + + /** Properties of a ResourceDescriptor. */ + interface IResourceDescriptor { + + /** ResourceDescriptor type */ + type?: (string|null); + + /** ResourceDescriptor pattern */ + pattern?: (string[]|null); + + /** ResourceDescriptor nameField */ + nameField?: (string|null); + + /** ResourceDescriptor history */ + history?: (google.api.ResourceDescriptor.History|null); + + /** ResourceDescriptor plural */ + plural?: (string|null); + + /** ResourceDescriptor singular */ + singular?: (string|null); + + /** ResourceDescriptor style */ + style?: (google.api.ResourceDescriptor.Style[]|null); + } + + /** Represents a ResourceDescriptor. */ + class ResourceDescriptor implements IResourceDescriptor { + + /** + * Constructs a new ResourceDescriptor. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IResourceDescriptor); + + /** ResourceDescriptor type. */ + public type: string; + + /** ResourceDescriptor pattern. */ + public pattern: string[]; + + /** ResourceDescriptor nameField. */ + public nameField: string; + + /** ResourceDescriptor history. */ + public history: google.api.ResourceDescriptor.History; + + /** ResourceDescriptor plural. */ + public plural: string; + + /** ResourceDescriptor singular. */ + public singular: string; + + /** ResourceDescriptor style. */ + public style: google.api.ResourceDescriptor.Style[]; + + /** + * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ResourceDescriptor + */ + public static fromObject(object: { [k: string]: any }): google.api.ResourceDescriptor; + + /** + * Creates a plain object from a ResourceDescriptor message. Also converts values to other types if specified. + * @param message ResourceDescriptor + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.ResourceDescriptor, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ResourceDescriptor to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace ResourceDescriptor { + + /** History enum. */ + type History = + "HISTORY_UNSPECIFIED"| "ORIGINALLY_SINGLE_PATTERN"| "FUTURE_MULTI_PATTERN"; + + /** Style enum. */ + type Style = + "STYLE_UNSPECIFIED"| "DECLARATIVE_FRIENDLY"; + } + + /** Properties of a ResourceReference. */ + interface IResourceReference { + + /** ResourceReference type */ + type?: (string|null); + + /** ResourceReference childType */ + childType?: (string|null); + } + + /** Represents a ResourceReference. */ + class ResourceReference implements IResourceReference { + + /** + * Constructs a new ResourceReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IResourceReference); + + /** ResourceReference type. */ + public type: string; + + /** ResourceReference childType. */ + public childType: string; + + /** + * Creates a ResourceReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ResourceReference + */ + public static fromObject(object: { [k: string]: any }): google.api.ResourceReference; + + /** + * Creates a plain object from a ResourceReference message. Also converts values to other types if specified. + * @param message ResourceReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.ResourceReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ResourceReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Namespace protobuf. */ + namespace protobuf { + + /** Properties of a FileDescriptorSet. */ + interface IFileDescriptorSet { + + /** FileDescriptorSet file */ + file?: (google.protobuf.IFileDescriptorProto[]|null); + } + + /** Represents a FileDescriptorSet. */ + class FileDescriptorSet implements IFileDescriptorSet { + + /** + * Constructs a new FileDescriptorSet. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileDescriptorSet); + + /** FileDescriptorSet file. */ + public file: google.protobuf.IFileDescriptorProto[]; + + /** + * Creates a FileDescriptorSet message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileDescriptorSet + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileDescriptorSet; + + /** + * Creates a plain object from a FileDescriptorSet message. Also converts values to other types if specified. + * @param message FileDescriptorSet + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileDescriptorSet, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileDescriptorSet to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FileDescriptorProto. */ + interface IFileDescriptorProto { + + /** FileDescriptorProto name */ + name?: (string|null); + + /** FileDescriptorProto package */ + "package"?: (string|null); + + /** FileDescriptorProto dependency */ + dependency?: (string[]|null); + + /** FileDescriptorProto publicDependency */ + publicDependency?: (number[]|null); + + /** FileDescriptorProto weakDependency */ + weakDependency?: (number[]|null); + + /** FileDescriptorProto messageType */ + messageType?: (google.protobuf.IDescriptorProto[]|null); + + /** FileDescriptorProto enumType */ + enumType?: (google.protobuf.IEnumDescriptorProto[]|null); + + /** FileDescriptorProto service */ + service?: (google.protobuf.IServiceDescriptorProto[]|null); + + /** FileDescriptorProto extension */ + extension?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** FileDescriptorProto options */ + options?: (google.protobuf.IFileOptions|null); + + /** FileDescriptorProto sourceCodeInfo */ + sourceCodeInfo?: (google.protobuf.ISourceCodeInfo|null); + + /** FileDescriptorProto syntax */ + syntax?: (string|null); + } + + /** Represents a FileDescriptorProto. */ + class FileDescriptorProto implements IFileDescriptorProto { + + /** + * Constructs a new FileDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileDescriptorProto); + + /** FileDescriptorProto name. */ + public name: string; + + /** FileDescriptorProto package. */ + public package: string; + + /** FileDescriptorProto dependency. */ + public dependency: string[]; + + /** FileDescriptorProto publicDependency. */ + public publicDependency: number[]; + + /** FileDescriptorProto weakDependency. */ + public weakDependency: number[]; + + /** FileDescriptorProto messageType. */ + public messageType: google.protobuf.IDescriptorProto[]; + + /** FileDescriptorProto enumType. */ + public enumType: google.protobuf.IEnumDescriptorProto[]; + + /** FileDescriptorProto service. */ + public service: google.protobuf.IServiceDescriptorProto[]; + + /** FileDescriptorProto extension. */ + public extension: google.protobuf.IFieldDescriptorProto[]; + + /** FileDescriptorProto options. */ + public options?: (google.protobuf.IFileOptions|null); + + /** FileDescriptorProto sourceCodeInfo. */ + public sourceCodeInfo?: (google.protobuf.ISourceCodeInfo|null); + + /** FileDescriptorProto syntax. */ + public syntax: string; + + /** + * Creates a FileDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileDescriptorProto; + + /** + * Creates a plain object from a FileDescriptorProto message. Also converts values to other types if specified. + * @param message FileDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DescriptorProto. */ + interface IDescriptorProto { + + /** DescriptorProto name */ + name?: (string|null); + + /** DescriptorProto field */ + field?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** DescriptorProto extension */ + extension?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** DescriptorProto nestedType */ + nestedType?: (google.protobuf.IDescriptorProto[]|null); + + /** DescriptorProto enumType */ + enumType?: (google.protobuf.IEnumDescriptorProto[]|null); + + /** DescriptorProto extensionRange */ + extensionRange?: (google.protobuf.DescriptorProto.IExtensionRange[]|null); + + /** DescriptorProto oneofDecl */ + oneofDecl?: (google.protobuf.IOneofDescriptorProto[]|null); + + /** DescriptorProto options */ + options?: (google.protobuf.IMessageOptions|null); + + /** DescriptorProto reservedRange */ + reservedRange?: (google.protobuf.DescriptorProto.IReservedRange[]|null); + + /** DescriptorProto reservedName */ + reservedName?: (string[]|null); + } + + /** Represents a DescriptorProto. */ + class DescriptorProto implements IDescriptorProto { + + /** + * Constructs a new DescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDescriptorProto); + + /** DescriptorProto name. */ + public name: string; + + /** DescriptorProto field. */ + public field: google.protobuf.IFieldDescriptorProto[]; + + /** DescriptorProto extension. */ + public extension: google.protobuf.IFieldDescriptorProto[]; + + /** DescriptorProto nestedType. */ + public nestedType: google.protobuf.IDescriptorProto[]; + + /** DescriptorProto enumType. */ + public enumType: google.protobuf.IEnumDescriptorProto[]; + + /** DescriptorProto extensionRange. */ + public extensionRange: google.protobuf.DescriptorProto.IExtensionRange[]; + + /** DescriptorProto oneofDecl. */ + public oneofDecl: google.protobuf.IOneofDescriptorProto[]; + + /** DescriptorProto options. */ + public options?: (google.protobuf.IMessageOptions|null); + + /** DescriptorProto reservedRange. */ + public reservedRange: google.protobuf.DescriptorProto.IReservedRange[]; + + /** DescriptorProto reservedName. */ + public reservedName: string[]; + + /** + * Creates a DescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto; + + /** + * Creates a plain object from a DescriptorProto message. Also converts values to other types if specified. + * @param message DescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace DescriptorProto { + + /** Properties of an ExtensionRange. */ + interface IExtensionRange { + + /** ExtensionRange start */ + start?: (number|null); + + /** ExtensionRange end */ + end?: (number|null); + } + + /** Represents an ExtensionRange. */ + class ExtensionRange implements IExtensionRange { + + /** + * Constructs a new ExtensionRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.DescriptorProto.IExtensionRange); + + /** ExtensionRange start. */ + public start: number; + + /** ExtensionRange end. */ + public end: number; + + /** + * Creates an ExtensionRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExtensionRange + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto.ExtensionRange; + + /** + * Creates a plain object from an ExtensionRange message. Also converts values to other types if specified. + * @param message ExtensionRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto.ExtensionRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExtensionRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ReservedRange. */ + interface IReservedRange { + + /** ReservedRange start */ + start?: (number|null); + + /** ReservedRange end */ + end?: (number|null); + } + + /** Represents a ReservedRange. */ + class ReservedRange implements IReservedRange { + + /** + * Constructs a new ReservedRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.DescriptorProto.IReservedRange); + + /** ReservedRange start. */ + public start: number; + + /** ReservedRange end. */ + public end: number; + + /** + * Creates a ReservedRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReservedRange + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto.ReservedRange; + + /** + * Creates a plain object from a ReservedRange message. Also converts values to other types if specified. + * @param message ReservedRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto.ReservedRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReservedRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a FieldDescriptorProto. */ + interface IFieldDescriptorProto { + + /** FieldDescriptorProto name */ + name?: (string|null); + + /** FieldDescriptorProto number */ + number?: (number|null); + + /** FieldDescriptorProto label */ + label?: (google.protobuf.FieldDescriptorProto.Label|null); + + /** FieldDescriptorProto type */ + type?: (google.protobuf.FieldDescriptorProto.Type|null); + + /** FieldDescriptorProto typeName */ + typeName?: (string|null); + + /** FieldDescriptorProto extendee */ + extendee?: (string|null); + + /** FieldDescriptorProto defaultValue */ + defaultValue?: (string|null); + + /** FieldDescriptorProto oneofIndex */ + oneofIndex?: (number|null); + + /** FieldDescriptorProto jsonName */ + jsonName?: (string|null); + + /** FieldDescriptorProto options */ + options?: (google.protobuf.IFieldOptions|null); + } + + /** Represents a FieldDescriptorProto. */ + class FieldDescriptorProto implements IFieldDescriptorProto { + + /** + * Constructs a new FieldDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldDescriptorProto); + + /** FieldDescriptorProto name. */ + public name: string; + + /** FieldDescriptorProto number. */ + public number: number; + + /** FieldDescriptorProto label. */ + public label: google.protobuf.FieldDescriptorProto.Label; + + /** FieldDescriptorProto type. */ + public type: google.protobuf.FieldDescriptorProto.Type; + + /** FieldDescriptorProto typeName. */ + public typeName: string; + + /** FieldDescriptorProto extendee. */ + public extendee: string; + + /** FieldDescriptorProto defaultValue. */ + public defaultValue: string; + + /** FieldDescriptorProto oneofIndex. */ + public oneofIndex: number; + + /** FieldDescriptorProto jsonName. */ + public jsonName: string; + + /** FieldDescriptorProto options. */ + public options?: (google.protobuf.IFieldOptions|null); + + /** + * Creates a FieldDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldDescriptorProto; + + /** + * Creates a plain object from a FieldDescriptorProto message. Also converts values to other types if specified. + * @param message FieldDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace FieldDescriptorProto { + + /** Type enum. */ + type Type = + "TYPE_DOUBLE"| "TYPE_FLOAT"| "TYPE_INT64"| "TYPE_UINT64"| "TYPE_INT32"| "TYPE_FIXED64"| "TYPE_FIXED32"| "TYPE_BOOL"| "TYPE_STRING"| "TYPE_GROUP"| "TYPE_MESSAGE"| "TYPE_BYTES"| "TYPE_UINT32"| "TYPE_ENUM"| "TYPE_SFIXED32"| "TYPE_SFIXED64"| "TYPE_SINT32"| "TYPE_SINT64"; + + /** Label enum. */ + type Label = + "LABEL_OPTIONAL"| "LABEL_REQUIRED"| "LABEL_REPEATED"; + } + + /** Properties of an OneofDescriptorProto. */ + interface IOneofDescriptorProto { + + /** OneofDescriptorProto name */ + name?: (string|null); + + /** OneofDescriptorProto options */ + options?: (google.protobuf.IOneofOptions|null); + } + + /** Represents an OneofDescriptorProto. */ + class OneofDescriptorProto implements IOneofDescriptorProto { + + /** + * Constructs a new OneofDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IOneofDescriptorProto); + + /** OneofDescriptorProto name. */ + public name: string; + + /** OneofDescriptorProto options. */ + public options?: (google.protobuf.IOneofOptions|null); + + /** + * Creates an OneofDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OneofDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.OneofDescriptorProto; + + /** + * Creates a plain object from an OneofDescriptorProto message. Also converts values to other types if specified. + * @param message OneofDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.OneofDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OneofDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an EnumDescriptorProto. */ + interface IEnumDescriptorProto { + + /** EnumDescriptorProto name */ + name?: (string|null); + + /** EnumDescriptorProto value */ + value?: (google.protobuf.IEnumValueDescriptorProto[]|null); + + /** EnumDescriptorProto options */ + options?: (google.protobuf.IEnumOptions|null); + } + + /** Represents an EnumDescriptorProto. */ + class EnumDescriptorProto implements IEnumDescriptorProto { + + /** + * Constructs a new EnumDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumDescriptorProto); + + /** EnumDescriptorProto name. */ + public name: string; + + /** EnumDescriptorProto value. */ + public value: google.protobuf.IEnumValueDescriptorProto[]; + + /** EnumDescriptorProto options. */ + public options?: (google.protobuf.IEnumOptions|null); + + /** + * Creates an EnumDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumDescriptorProto; + + /** + * Creates a plain object from an EnumDescriptorProto message. Also converts values to other types if specified. + * @param message EnumDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an EnumValueDescriptorProto. */ + interface IEnumValueDescriptorProto { + + /** EnumValueDescriptorProto name */ + name?: (string|null); + + /** EnumValueDescriptorProto number */ + number?: (number|null); + + /** EnumValueDescriptorProto options */ + options?: (google.protobuf.IEnumValueOptions|null); + } + + /** Represents an EnumValueDescriptorProto. */ + class EnumValueDescriptorProto implements IEnumValueDescriptorProto { + + /** + * Constructs a new EnumValueDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumValueDescriptorProto); + + /** EnumValueDescriptorProto name. */ + public name: string; + + /** EnumValueDescriptorProto number. */ + public number: number; + + /** EnumValueDescriptorProto options. */ + public options?: (google.protobuf.IEnumValueOptions|null); + + /** + * Creates an EnumValueDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumValueDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumValueDescriptorProto; + + /** + * Creates a plain object from an EnumValueDescriptorProto message. Also converts values to other types if specified. + * @param message EnumValueDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumValueDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumValueDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ServiceDescriptorProto. */ + interface IServiceDescriptorProto { + + /** ServiceDescriptorProto name */ + name?: (string|null); + + /** ServiceDescriptorProto method */ + method?: (google.protobuf.IMethodDescriptorProto[]|null); + + /** ServiceDescriptorProto options */ + options?: (google.protobuf.IServiceOptions|null); + } + + /** Represents a ServiceDescriptorProto. */ + class ServiceDescriptorProto implements IServiceDescriptorProto { + + /** + * Constructs a new ServiceDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IServiceDescriptorProto); + + /** ServiceDescriptorProto name. */ + public name: string; + + /** ServiceDescriptorProto method. */ + public method: google.protobuf.IMethodDescriptorProto[]; + + /** ServiceDescriptorProto options. */ + public options?: (google.protobuf.IServiceOptions|null); + + /** + * Creates a ServiceDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServiceDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ServiceDescriptorProto; + + /** + * Creates a plain object from a ServiceDescriptorProto message. Also converts values to other types if specified. + * @param message ServiceDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ServiceDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServiceDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a MethodDescriptorProto. */ + interface IMethodDescriptorProto { + + /** MethodDescriptorProto name */ + name?: (string|null); + + /** MethodDescriptorProto inputType */ + inputType?: (string|null); + + /** MethodDescriptorProto outputType */ + outputType?: (string|null); + + /** MethodDescriptorProto options */ + options?: (google.protobuf.IMethodOptions|null); + + /** MethodDescriptorProto clientStreaming */ + clientStreaming?: (boolean|null); + + /** MethodDescriptorProto serverStreaming */ + serverStreaming?: (boolean|null); + } + + /** Represents a MethodDescriptorProto. */ + class MethodDescriptorProto implements IMethodDescriptorProto { + + /** + * Constructs a new MethodDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMethodDescriptorProto); + + /** MethodDescriptorProto name. */ + public name: string; + + /** MethodDescriptorProto inputType. */ + public inputType: string; + + /** MethodDescriptorProto outputType. */ + public outputType: string; + + /** MethodDescriptorProto options. */ + public options?: (google.protobuf.IMethodOptions|null); + + /** MethodDescriptorProto clientStreaming. */ + public clientStreaming: boolean; + + /** MethodDescriptorProto serverStreaming. */ + public serverStreaming: boolean; + + /** + * Creates a MethodDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MethodDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MethodDescriptorProto; + + /** + * Creates a plain object from a MethodDescriptorProto message. Also converts values to other types if specified. + * @param message MethodDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MethodDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MethodDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FileOptions. */ + interface IFileOptions { + + /** FileOptions javaPackage */ + javaPackage?: (string|null); + + /** FileOptions javaOuterClassname */ + javaOuterClassname?: (string|null); + + /** FileOptions javaMultipleFiles */ + javaMultipleFiles?: (boolean|null); + + /** FileOptions javaGenerateEqualsAndHash */ + javaGenerateEqualsAndHash?: (boolean|null); + + /** FileOptions javaStringCheckUtf8 */ + javaStringCheckUtf8?: (boolean|null); + + /** FileOptions optimizeFor */ + optimizeFor?: (google.protobuf.FileOptions.OptimizeMode|null); + + /** FileOptions goPackage */ + goPackage?: (string|null); + + /** FileOptions ccGenericServices */ + ccGenericServices?: (boolean|null); + + /** FileOptions javaGenericServices */ + javaGenericServices?: (boolean|null); + + /** FileOptions pyGenericServices */ + pyGenericServices?: (boolean|null); + + /** FileOptions deprecated */ + deprecated?: (boolean|null); + + /** FileOptions ccEnableArenas */ + ccEnableArenas?: (boolean|null); + + /** FileOptions objcClassPrefix */ + objcClassPrefix?: (string|null); + + /** FileOptions csharpNamespace */ + csharpNamespace?: (string|null); + + /** FileOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** FileOptions .google.api.resourceDefinition */ + ".google.api.resourceDefinition"?: (google.api.IResourceDescriptor[]|null); + } + + /** Represents a FileOptions. */ + class FileOptions implements IFileOptions { + + /** + * Constructs a new FileOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileOptions); + + /** FileOptions javaPackage. */ + public javaPackage: string; + + /** FileOptions javaOuterClassname. */ + public javaOuterClassname: string; + + /** FileOptions javaMultipleFiles. */ + public javaMultipleFiles: boolean; + + /** FileOptions javaGenerateEqualsAndHash. */ + public javaGenerateEqualsAndHash: boolean; + + /** FileOptions javaStringCheckUtf8. */ + public javaStringCheckUtf8: boolean; + + /** FileOptions optimizeFor. */ + public optimizeFor: google.protobuf.FileOptions.OptimizeMode; + + /** FileOptions goPackage. */ + public goPackage: string; + + /** FileOptions ccGenericServices. */ + public ccGenericServices: boolean; + + /** FileOptions javaGenericServices. */ + public javaGenericServices: boolean; + + /** FileOptions pyGenericServices. */ + public pyGenericServices: boolean; + + /** FileOptions deprecated. */ + public deprecated: boolean; + + /** FileOptions ccEnableArenas. */ + public ccEnableArenas: boolean; + + /** FileOptions objcClassPrefix. */ + public objcClassPrefix: string; + + /** FileOptions csharpNamespace. */ + public csharpNamespace: string; + + /** FileOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a FileOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileOptions; + + /** + * Creates a plain object from a FileOptions message. Also converts values to other types if specified. + * @param message FileOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace FileOptions { + + /** OptimizeMode enum. */ + type OptimizeMode = + "SPEED"| "CODE_SIZE"| "LITE_RUNTIME"; + } + + /** Properties of a MessageOptions. */ + interface IMessageOptions { + + /** MessageOptions messageSetWireFormat */ + messageSetWireFormat?: (boolean|null); + + /** MessageOptions noStandardDescriptorAccessor */ + noStandardDescriptorAccessor?: (boolean|null); + + /** MessageOptions deprecated */ + deprecated?: (boolean|null); + + /** MessageOptions mapEntry */ + mapEntry?: (boolean|null); + + /** MessageOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** MessageOptions .google.api.resource */ + ".google.api.resource"?: (google.api.IResourceDescriptor|null); + } + + /** Represents a MessageOptions. */ + class MessageOptions implements IMessageOptions { + + /** + * Constructs a new MessageOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMessageOptions); + + /** MessageOptions messageSetWireFormat. */ + public messageSetWireFormat: boolean; + + /** MessageOptions noStandardDescriptorAccessor. */ + public noStandardDescriptorAccessor: boolean; + + /** MessageOptions deprecated. */ + public deprecated: boolean; + + /** MessageOptions mapEntry. */ + public mapEntry: boolean; + + /** MessageOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a MessageOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MessageOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MessageOptions; + + /** + * Creates a plain object from a MessageOptions message. Also converts values to other types if specified. + * @param message MessageOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MessageOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MessageOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FieldOptions. */ + interface IFieldOptions { + + /** FieldOptions ctype */ + ctype?: (google.protobuf.FieldOptions.CType|null); + + /** FieldOptions packed */ + packed?: (boolean|null); + + /** FieldOptions jstype */ + jstype?: (google.protobuf.FieldOptions.JSType|null); + + /** FieldOptions lazy */ + lazy?: (boolean|null); + + /** FieldOptions deprecated */ + deprecated?: (boolean|null); + + /** FieldOptions weak */ + weak?: (boolean|null); + + /** FieldOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** FieldOptions .google.api.fieldBehavior */ + ".google.api.fieldBehavior"?: (google.api.FieldBehavior[]|null); + + /** FieldOptions .google.api.resourceReference */ + ".google.api.resourceReference"?: (google.api.IResourceReference|null); + } + + /** Represents a FieldOptions. */ + class FieldOptions implements IFieldOptions { + + /** + * Constructs a new FieldOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldOptions); + + /** FieldOptions ctype. */ + public ctype: google.protobuf.FieldOptions.CType; + + /** FieldOptions packed. */ + public packed: boolean; + + /** FieldOptions jstype. */ + public jstype: google.protobuf.FieldOptions.JSType; + + /** FieldOptions lazy. */ + public lazy: boolean; + + /** FieldOptions deprecated. */ + public deprecated: boolean; + + /** FieldOptions weak. */ + public weak: boolean; + + /** FieldOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a FieldOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions; + + /** + * Creates a plain object from a FieldOptions message. Also converts values to other types if specified. + * @param message FieldOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace FieldOptions { + + /** CType enum. */ + type CType = + "STRING"| "CORD"| "STRING_PIECE"; + + /** JSType enum. */ + type JSType = + "JS_NORMAL"| "JS_STRING"| "JS_NUMBER"; + } + + /** Properties of an OneofOptions. */ + interface IOneofOptions { + + /** OneofOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an OneofOptions. */ + class OneofOptions implements IOneofOptions { + + /** + * Constructs a new OneofOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IOneofOptions); + + /** OneofOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an OneofOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OneofOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.OneofOptions; + + /** + * Creates a plain object from an OneofOptions message. Also converts values to other types if specified. + * @param message OneofOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.OneofOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OneofOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an EnumOptions. */ + interface IEnumOptions { + + /** EnumOptions allowAlias */ + allowAlias?: (boolean|null); + + /** EnumOptions deprecated */ + deprecated?: (boolean|null); + + /** EnumOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an EnumOptions. */ + class EnumOptions implements IEnumOptions { + + /** + * Constructs a new EnumOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumOptions); + + /** EnumOptions allowAlias. */ + public allowAlias: boolean; + + /** EnumOptions deprecated. */ + public deprecated: boolean; + + /** EnumOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an EnumOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumOptions; + + /** + * Creates a plain object from an EnumOptions message. Also converts values to other types if specified. + * @param message EnumOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an EnumValueOptions. */ + interface IEnumValueOptions { + + /** EnumValueOptions deprecated */ + deprecated?: (boolean|null); + + /** EnumValueOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an EnumValueOptions. */ + class EnumValueOptions implements IEnumValueOptions { + + /** + * Constructs a new EnumValueOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumValueOptions); + + /** EnumValueOptions deprecated. */ + public deprecated: boolean; + + /** EnumValueOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an EnumValueOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumValueOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumValueOptions; + + /** + * Creates a plain object from an EnumValueOptions message. Also converts values to other types if specified. + * @param message EnumValueOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumValueOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumValueOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ServiceOptions. */ + interface IServiceOptions { + + /** ServiceOptions deprecated */ + deprecated?: (boolean|null); + + /** ServiceOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** ServiceOptions .google.api.defaultHost */ + ".google.api.defaultHost"?: (string|null); + + /** ServiceOptions .google.api.oauthScopes */ + ".google.api.oauthScopes"?: (string|null); + } + + /** Represents a ServiceOptions. */ + class ServiceOptions implements IServiceOptions { + + /** + * Constructs a new ServiceOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IServiceOptions); + + /** ServiceOptions deprecated. */ + public deprecated: boolean; + + /** ServiceOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a ServiceOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServiceOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ServiceOptions; + + /** + * Creates a plain object from a ServiceOptions message. Also converts values to other types if specified. + * @param message ServiceOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ServiceOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServiceOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a MethodOptions. */ + interface IMethodOptions { + + /** MethodOptions deprecated */ + deprecated?: (boolean|null); + + /** MethodOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** MethodOptions .google.api.http */ + ".google.api.http"?: (google.api.IHttpRule|null); + + /** MethodOptions .google.api.methodSignature */ + ".google.api.methodSignature"?: (string[]|null); + + /** MethodOptions .google.longrunning.operationInfo */ + ".google.longrunning.operationInfo"?: (google.longrunning.IOperationInfo|null); + } + + /** Represents a MethodOptions. */ + class MethodOptions implements IMethodOptions { + + /** + * Constructs a new MethodOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMethodOptions); + + /** MethodOptions deprecated. */ + public deprecated: boolean; + + /** MethodOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a MethodOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MethodOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MethodOptions; + + /** + * Creates a plain object from a MethodOptions message. Also converts values to other types if specified. + * @param message MethodOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MethodOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MethodOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an UninterpretedOption. */ + interface IUninterpretedOption { + + /** UninterpretedOption name */ + name?: (google.protobuf.UninterpretedOption.INamePart[]|null); + + /** UninterpretedOption identifierValue */ + identifierValue?: (string|null); + + /** UninterpretedOption positiveIntValue */ + positiveIntValue?: (number|string|null); + + /** UninterpretedOption negativeIntValue */ + negativeIntValue?: (number|string|null); + + /** UninterpretedOption doubleValue */ + doubleValue?: (number|null); + + /** UninterpretedOption stringValue */ + stringValue?: (Uint8Array|null); + + /** UninterpretedOption aggregateValue */ + aggregateValue?: (string|null); + } + + /** Represents an UninterpretedOption. */ + class UninterpretedOption implements IUninterpretedOption { + + /** + * Constructs a new UninterpretedOption. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUninterpretedOption); + + /** UninterpretedOption name. */ + public name: google.protobuf.UninterpretedOption.INamePart[]; + + /** UninterpretedOption identifierValue. */ + public identifierValue: string; + + /** UninterpretedOption positiveIntValue. */ + public positiveIntValue: (number|string); + + /** UninterpretedOption negativeIntValue. */ + public negativeIntValue: (number|string); + + /** UninterpretedOption doubleValue. */ + public doubleValue: number; + + /** UninterpretedOption stringValue. */ + public stringValue: Uint8Array; + + /** UninterpretedOption aggregateValue. */ + public aggregateValue: string; + + /** + * Creates an UninterpretedOption message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UninterpretedOption + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UninterpretedOption; + + /** + * Creates a plain object from an UninterpretedOption message. Also converts values to other types if specified. + * @param message UninterpretedOption + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UninterpretedOption, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UninterpretedOption to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace UninterpretedOption { + + /** Properties of a NamePart. */ + interface INamePart { + + /** NamePart namePart */ + namePart: string; + + /** NamePart isExtension */ + isExtension: boolean; + } + + /** Represents a NamePart. */ + class NamePart implements INamePart { + + /** + * Constructs a new NamePart. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.UninterpretedOption.INamePart); + + /** NamePart namePart. */ + public namePart: string; + + /** NamePart isExtension. */ + public isExtension: boolean; + + /** + * Creates a NamePart message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns NamePart + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UninterpretedOption.NamePart; + + /** + * Creates a plain object from a NamePart message. Also converts values to other types if specified. + * @param message NamePart + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UninterpretedOption.NamePart, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this NamePart to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a SourceCodeInfo. */ + interface ISourceCodeInfo { + + /** SourceCodeInfo location */ + location?: (google.protobuf.SourceCodeInfo.ILocation[]|null); + } + + /** Represents a SourceCodeInfo. */ + class SourceCodeInfo implements ISourceCodeInfo { + + /** + * Constructs a new SourceCodeInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.ISourceCodeInfo); + + /** SourceCodeInfo location. */ + public location: google.protobuf.SourceCodeInfo.ILocation[]; + + /** + * Creates a SourceCodeInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SourceCodeInfo + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.SourceCodeInfo; + + /** + * Creates a plain object from a SourceCodeInfo message. Also converts values to other types if specified. + * @param message SourceCodeInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.SourceCodeInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SourceCodeInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace SourceCodeInfo { + + /** Properties of a Location. */ + interface ILocation { + + /** Location path */ + path?: (number[]|null); + + /** Location span */ + span?: (number[]|null); + + /** Location leadingComments */ + leadingComments?: (string|null); + + /** Location trailingComments */ + trailingComments?: (string|null); + + /** Location leadingDetachedComments */ + leadingDetachedComments?: (string[]|null); + } + + /** Represents a Location. */ + class Location implements ILocation { + + /** + * Constructs a new Location. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.SourceCodeInfo.ILocation); + + /** Location path. */ + public path: number[]; + + /** Location span. */ + public span: number[]; + + /** Location leadingComments. */ + public leadingComments: string; + + /** Location trailingComments. */ + public trailingComments: string; + + /** Location leadingDetachedComments. */ + public leadingDetachedComments: string[]; + + /** + * Creates a Location message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Location + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.SourceCodeInfo.Location; + + /** + * Creates a plain object from a Location message. Also converts values to other types if specified. + * @param message Location + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.SourceCodeInfo.Location, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Location to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a GeneratedCodeInfo. */ + interface IGeneratedCodeInfo { + + /** GeneratedCodeInfo annotation */ + annotation?: (google.protobuf.GeneratedCodeInfo.IAnnotation[]|null); + } + + /** Represents a GeneratedCodeInfo. */ + class GeneratedCodeInfo implements IGeneratedCodeInfo { + + /** + * Constructs a new GeneratedCodeInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IGeneratedCodeInfo); + + /** GeneratedCodeInfo annotation. */ + public annotation: google.protobuf.GeneratedCodeInfo.IAnnotation[]; + + /** + * Creates a GeneratedCodeInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GeneratedCodeInfo + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.GeneratedCodeInfo; + + /** + * Creates a plain object from a GeneratedCodeInfo message. Also converts values to other types if specified. + * @param message GeneratedCodeInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.GeneratedCodeInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GeneratedCodeInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace GeneratedCodeInfo { + + /** Properties of an Annotation. */ + interface IAnnotation { + + /** Annotation path */ + path?: (number[]|null); + + /** Annotation sourceFile */ + sourceFile?: (string|null); + + /** Annotation begin */ + begin?: (number|null); + + /** Annotation end */ + end?: (number|null); + } + + /** Represents an Annotation. */ + class Annotation implements IAnnotation { + + /** + * Constructs a new Annotation. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.GeneratedCodeInfo.IAnnotation); + + /** Annotation path. */ + public path: number[]; + + /** Annotation sourceFile. */ + public sourceFile: string; + + /** Annotation begin. */ + public begin: number; + + /** Annotation end. */ + public end: number; + + /** + * Creates an Annotation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Annotation + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.GeneratedCodeInfo.Annotation; + + /** + * Creates a plain object from an Annotation message. Also converts values to other types if specified. + * @param message Annotation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.GeneratedCodeInfo.Annotation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Annotation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of an Empty. */ + interface IEmpty { + } + + /** Represents an Empty. */ + class Empty implements IEmpty { + + /** + * Constructs a new Empty. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEmpty); + + /** + * Creates an Empty message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Empty + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Empty; + + /** + * Creates a plain object from an Empty message. Also converts values to other types if specified. + * @param message Empty + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Empty, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Empty to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FieldMask. */ + interface IFieldMask { + + /** FieldMask paths */ + paths?: (string[]|null); + } + + /** Represents a FieldMask. */ + class FieldMask implements IFieldMask { + + /** + * Constructs a new FieldMask. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldMask); + + /** FieldMask paths. */ + public paths: string[]; + + /** + * Creates a FieldMask message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldMask + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldMask; + + /** + * Creates a plain object from a FieldMask message. Also converts values to other types if specified. + * @param message FieldMask + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldMask, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldMask to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Timestamp. */ + interface ITimestamp { + + /** Timestamp seconds */ + seconds?: (number|string|null); + + /** Timestamp nanos */ + nanos?: (number|null); + } + + /** Represents a Timestamp. */ + class Timestamp implements ITimestamp { + + /** + * Constructs a new Timestamp. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.ITimestamp); + + /** Timestamp seconds. */ + public seconds: (number|string); + + /** Timestamp nanos. */ + public nanos: number; + + /** + * Creates a Timestamp message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Timestamp + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Timestamp; + + /** + * Creates a plain object from a Timestamp message. Also converts values to other types if specified. + * @param message Timestamp + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Timestamp, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Timestamp to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an Any. */ + interface IAny { + + /** Any type_url */ + type_url?: (string|null); + + /** Any value */ + value?: (Uint8Array|null); + } + + /** Represents an Any. */ + class Any implements IAny { + + /** + * Constructs a new Any. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IAny); + + /** Any type_url. */ + public type_url: string; + + /** Any value. */ + public value: Uint8Array; + + /** + * Creates an Any message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Any + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Any; + + /** + * Creates a plain object from an Any message. Also converts values to other types if specified. + * @param message Any + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Any, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Any to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Struct. */ + interface IStruct { + + /** Struct fields */ + fields?: ({ [k: string]: google.protobuf.IValue }|null); + } + + /** Represents a Struct. */ + class Struct implements IStruct { + + /** + * Constructs a new Struct. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IStruct); + + /** Struct fields. */ + public fields: { [k: string]: google.protobuf.IValue }; + + /** + * Creates a Struct message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Struct + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Struct; + + /** + * Creates a plain object from a Struct message. Also converts values to other types if specified. + * @param message Struct + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Struct, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Struct to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Value. */ + interface IValue { + + /** Value nullValue */ + nullValue?: (google.protobuf.NullValue|null); + + /** Value numberValue */ + numberValue?: (number|null); + + /** Value stringValue */ + stringValue?: (string|null); + + /** Value boolValue */ + boolValue?: (boolean|null); + + /** Value structValue */ + structValue?: (google.protobuf.IStruct|null); + + /** Value listValue */ + listValue?: (google.protobuf.IListValue|null); + } + + /** Represents a Value. */ + class Value implements IValue { + + /** + * Constructs a new Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IValue); + + /** Value nullValue. */ + public nullValue: google.protobuf.NullValue; + + /** Value numberValue. */ + public numberValue: number; + + /** Value stringValue. */ + public stringValue: string; + + /** Value boolValue. */ + public boolValue: boolean; + + /** Value structValue. */ + public structValue?: (google.protobuf.IStruct|null); + + /** Value listValue. */ + public listValue?: (google.protobuf.IListValue|null); + + /** Value kind. */ + public kind?: ("nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"); + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Value; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @param message Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** NullValue enum. */ + type NullValue = + "NULL_VALUE"; + + /** Properties of a ListValue. */ + interface IListValue { + + /** ListValue values */ + values?: (google.protobuf.IValue[]|null); + } + + /** Represents a ListValue. */ + class ListValue implements IListValue { + + /** + * Constructs a new ListValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IListValue); + + /** ListValue values. */ + public values: google.protobuf.IValue[]; + + /** + * Creates a ListValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ListValue; + + /** + * Creates a plain object from a ListValue message. Also converts values to other types if specified. + * @param message ListValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ListValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DoubleValue. */ + interface IDoubleValue { + + /** DoubleValue value */ + value?: (number|null); + } + + /** Represents a DoubleValue. */ + class DoubleValue implements IDoubleValue { + + /** + * Constructs a new DoubleValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDoubleValue); + + /** DoubleValue value. */ + public value: number; + + /** + * Creates a DoubleValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DoubleValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DoubleValue; + + /** + * Creates a plain object from a DoubleValue message. Also converts values to other types if specified. + * @param message DoubleValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DoubleValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DoubleValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FloatValue. */ + interface IFloatValue { + + /** FloatValue value */ + value?: (number|null); + } + + /** Represents a FloatValue. */ + class FloatValue implements IFloatValue { + + /** + * Constructs a new FloatValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFloatValue); + + /** FloatValue value. */ + public value: number; + + /** + * Creates a FloatValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FloatValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FloatValue; + + /** + * Creates a plain object from a FloatValue message. Also converts values to other types if specified. + * @param message FloatValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FloatValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FloatValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an Int64Value. */ + interface IInt64Value { + + /** Int64Value value */ + value?: (number|string|null); + } + + /** Represents an Int64Value. */ + class Int64Value implements IInt64Value { + + /** + * Constructs a new Int64Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IInt64Value); + + /** Int64Value value. */ + public value: (number|string); + + /** + * Creates an Int64Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Int64Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Int64Value; + + /** + * Creates a plain object from an Int64Value message. Also converts values to other types if specified. + * @param message Int64Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Int64Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Int64Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a UInt64Value. */ + interface IUInt64Value { + + /** UInt64Value value */ + value?: (number|string|null); + } + + /** Represents a UInt64Value. */ + class UInt64Value implements IUInt64Value { + + /** + * Constructs a new UInt64Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUInt64Value); + + /** UInt64Value value. */ + public value: (number|string); + + /** + * Creates a UInt64Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UInt64Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UInt64Value; + + /** + * Creates a plain object from a UInt64Value message. Also converts values to other types if specified. + * @param message UInt64Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UInt64Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UInt64Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an Int32Value. */ + interface IInt32Value { + + /** Int32Value value */ + value?: (number|null); + } + + /** Represents an Int32Value. */ + class Int32Value implements IInt32Value { + + /** + * Constructs a new Int32Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IInt32Value); + + /** Int32Value value. */ + public value: number; + + /** + * Creates an Int32Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Int32Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Int32Value; + + /** + * Creates a plain object from an Int32Value message. Also converts values to other types if specified. + * @param message Int32Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Int32Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Int32Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a UInt32Value. */ + interface IUInt32Value { + + /** UInt32Value value */ + value?: (number|null); + } + + /** Represents a UInt32Value. */ + class UInt32Value implements IUInt32Value { + + /** + * Constructs a new UInt32Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUInt32Value); + + /** UInt32Value value. */ + public value: number; + + /** + * Creates a UInt32Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UInt32Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UInt32Value; + + /** + * Creates a plain object from a UInt32Value message. Also converts values to other types if specified. + * @param message UInt32Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UInt32Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UInt32Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BoolValue. */ + interface IBoolValue { + + /** BoolValue value */ + value?: (boolean|null); + } + + /** Represents a BoolValue. */ + class BoolValue implements IBoolValue { + + /** + * Constructs a new BoolValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IBoolValue); + + /** BoolValue value. */ + public value: boolean; + + /** + * Creates a BoolValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BoolValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.BoolValue; + + /** + * Creates a plain object from a BoolValue message. Also converts values to other types if specified. + * @param message BoolValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.BoolValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BoolValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a StringValue. */ + interface IStringValue { + + /** StringValue value */ + value?: (string|null); + } + + /** Represents a StringValue. */ + class StringValue implements IStringValue { + + /** + * Constructs a new StringValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IStringValue); + + /** StringValue value. */ + public value: string; + + /** + * Creates a StringValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StringValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.StringValue; + + /** + * Creates a plain object from a StringValue message. Also converts values to other types if specified. + * @param message StringValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.StringValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StringValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BytesValue. */ + interface IBytesValue { + + /** BytesValue value */ + value?: (Uint8Array|null); + } + + /** Represents a BytesValue. */ + class BytesValue implements IBytesValue { + + /** + * Constructs a new BytesValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IBytesValue); + + /** BytesValue value. */ + public value: Uint8Array; + + /** + * Creates a BytesValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BytesValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.BytesValue; + + /** + * Creates a plain object from a BytesValue message. Also converts values to other types if specified. + * @param message BytesValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.BytesValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BytesValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Duration. */ + interface IDuration { + + /** Duration seconds */ + seconds?: (number|string|null); + + /** Duration nanos */ + nanos?: (number|null); + } + + /** Represents a Duration. */ + class Duration implements IDuration { + + /** + * Constructs a new Duration. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDuration); + + /** Duration seconds. */ + public seconds: (number|string); + + /** Duration nanos. */ + public nanos: number; + + /** + * Creates a Duration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Duration + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Duration; + + /** + * Creates a plain object from a Duration message. Also converts values to other types if specified. + * @param message Duration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Duration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Duration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Namespace type. */ + namespace type { + + /** Properties of a LatLng. */ + interface ILatLng { + + /** LatLng latitude */ + latitude?: (number|null); + + /** LatLng longitude */ + longitude?: (number|null); + } + + /** Represents a LatLng. */ + class LatLng implements ILatLng { + + /** + * Constructs a new LatLng. + * @param [properties] Properties to set + */ + constructor(properties?: google.type.ILatLng); + + /** LatLng latitude. */ + public latitude: number; + + /** LatLng longitude. */ + public longitude: number; + + /** + * Creates a LatLng message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LatLng + */ + public static fromObject(object: { [k: string]: any }): google.type.LatLng; + + /** + * Creates a plain object from a LatLng message. Also converts values to other types if specified. + * @param message LatLng + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.type.LatLng, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LatLng to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Namespace rpc. */ + namespace rpc { + + /** Properties of a Status. */ + interface IStatus { + + /** Status code */ + code?: (number|null); + + /** Status message */ + message?: (string|null); + + /** Status details */ + details?: (google.protobuf.IAny[]|null); + } + + /** Represents a Status. */ + class Status implements IStatus { + + /** + * Constructs a new Status. + * @param [properties] Properties to set + */ + constructor(properties?: google.rpc.IStatus); + + /** Status code. */ + public code: number; + + /** Status message. */ + public message: string; + + /** Status details. */ + public details: google.protobuf.IAny[]; + + /** + * Creates a Status message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Status + */ + public static fromObject(object: { [k: string]: any }): google.rpc.Status; + + /** + * Creates a plain object from a Status message. Also converts values to other types if specified. + * @param message Status + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.rpc.Status, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Status to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Namespace longrunning. */ + namespace longrunning { + + /** Represents an Operations */ + class Operations extends $protobuf.rpc.Service { + + /** + * Constructs a new Operations service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Calls ListOperations. + * @param request ListOperationsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListOperationsResponse + */ + public listOperations(request: google.longrunning.IListOperationsRequest, callback: google.longrunning.Operations.ListOperationsCallback): void; + + /** + * Calls ListOperations. + * @param request ListOperationsRequest message or plain object + * @returns Promise + */ + public listOperations(request: google.longrunning.IListOperationsRequest): Promise; + + /** + * Calls GetOperation. + * @param request GetOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public getOperation(request: google.longrunning.IGetOperationRequest, callback: google.longrunning.Operations.GetOperationCallback): void; + + /** + * Calls GetOperation. + * @param request GetOperationRequest message or plain object + * @returns Promise + */ + public getOperation(request: google.longrunning.IGetOperationRequest): Promise; + + /** + * Calls DeleteOperation. + * @param request DeleteOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteOperation(request: google.longrunning.IDeleteOperationRequest, callback: google.longrunning.Operations.DeleteOperationCallback): void; + + /** + * Calls DeleteOperation. + * @param request DeleteOperationRequest message or plain object + * @returns Promise + */ + public deleteOperation(request: google.longrunning.IDeleteOperationRequest): Promise; + + /** + * Calls CancelOperation. + * @param request CancelOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public cancelOperation(request: google.longrunning.ICancelOperationRequest, callback: google.longrunning.Operations.CancelOperationCallback): void; + + /** + * Calls CancelOperation. + * @param request CancelOperationRequest message or plain object + * @returns Promise + */ + public cancelOperation(request: google.longrunning.ICancelOperationRequest): Promise; + + /** + * Calls WaitOperation. + * @param request WaitOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public waitOperation(request: google.longrunning.IWaitOperationRequest, callback: google.longrunning.Operations.WaitOperationCallback): void; + + /** + * Calls WaitOperation. + * @param request WaitOperationRequest message or plain object + * @returns Promise + */ + public waitOperation(request: google.longrunning.IWaitOperationRequest): Promise; + } + + namespace Operations { + + /** + * Callback as used by {@link google.longrunning.Operations#listOperations}. + * @param error Error, if any + * @param [response] ListOperationsResponse + */ + type ListOperationsCallback = (error: (Error|null), response?: google.longrunning.ListOperationsResponse) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#getOperation}. + * @param error Error, if any + * @param [response] Operation + */ + type GetOperationCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#deleteOperation}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteOperationCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#cancelOperation}. + * @param error Error, if any + * @param [response] Empty + */ + type CancelOperationCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#waitOperation}. + * @param error Error, if any + * @param [response] Operation + */ + type WaitOperationCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of an Operation. */ + interface IOperation { + + /** Operation name */ + name?: (string|null); + + /** Operation metadata */ + metadata?: (google.protobuf.IAny|null); + + /** Operation done */ + done?: (boolean|null); + + /** Operation error */ + error?: (google.rpc.IStatus|null); + + /** Operation response */ + response?: (google.protobuf.IAny|null); + } + + /** Represents an Operation. */ + class Operation implements IOperation { + + /** + * Constructs a new Operation. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IOperation); + + /** Operation name. */ + public name: string; + + /** Operation metadata. */ + public metadata?: (google.protobuf.IAny|null); + + /** Operation done. */ + public done: boolean; + + /** Operation error. */ + public error?: (google.rpc.IStatus|null); + + /** Operation response. */ + public response?: (google.protobuf.IAny|null); + + /** Operation result. */ + public result?: ("error"|"response"); + + /** + * Creates an Operation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Operation + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.Operation; + + /** + * Creates a plain object from an Operation message. Also converts values to other types if specified. + * @param message Operation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.Operation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Operation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a GetOperationRequest. */ + interface IGetOperationRequest { + + /** GetOperationRequest name */ + name?: (string|null); + } + + /** Represents a GetOperationRequest. */ + class GetOperationRequest implements IGetOperationRequest { + + /** + * Constructs a new GetOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IGetOperationRequest); + + /** GetOperationRequest name. */ + public name: string; + + /** + * Creates a GetOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.GetOperationRequest; + + /** + * Creates a plain object from a GetOperationRequest message. Also converts values to other types if specified. + * @param message GetOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.GetOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListOperationsRequest. */ + interface IListOperationsRequest { + + /** ListOperationsRequest name */ + name?: (string|null); + + /** ListOperationsRequest filter */ + filter?: (string|null); + + /** ListOperationsRequest pageSize */ + pageSize?: (number|null); + + /** ListOperationsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListOperationsRequest. */ + class ListOperationsRequest implements IListOperationsRequest { + + /** + * Constructs a new ListOperationsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IListOperationsRequest); + + /** ListOperationsRequest name. */ + public name: string; + + /** ListOperationsRequest filter. */ + public filter: string; + + /** ListOperationsRequest pageSize. */ + public pageSize: number; + + /** ListOperationsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a ListOperationsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListOperationsRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.ListOperationsRequest; + + /** + * Creates a plain object from a ListOperationsRequest message. Also converts values to other types if specified. + * @param message ListOperationsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.ListOperationsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListOperationsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListOperationsResponse. */ + interface IListOperationsResponse { + + /** ListOperationsResponse operations */ + operations?: (google.longrunning.IOperation[]|null); + + /** ListOperationsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListOperationsResponse. */ + class ListOperationsResponse implements IListOperationsResponse { + + /** + * Constructs a new ListOperationsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IListOperationsResponse); + + /** ListOperationsResponse operations. */ + public operations: google.longrunning.IOperation[]; + + /** ListOperationsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a ListOperationsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListOperationsResponse + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.ListOperationsResponse; + + /** + * Creates a plain object from a ListOperationsResponse message. Also converts values to other types if specified. + * @param message ListOperationsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.ListOperationsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListOperationsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CancelOperationRequest. */ + interface ICancelOperationRequest { + + /** CancelOperationRequest name */ + name?: (string|null); + } + + /** Represents a CancelOperationRequest. */ + class CancelOperationRequest implements ICancelOperationRequest { + + /** + * Constructs a new CancelOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.ICancelOperationRequest); + + /** CancelOperationRequest name. */ + public name: string; + + /** + * Creates a CancelOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CancelOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.CancelOperationRequest; + + /** + * Creates a plain object from a CancelOperationRequest message. Also converts values to other types if specified. + * @param message CancelOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.CancelOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CancelOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DeleteOperationRequest. */ + interface IDeleteOperationRequest { + + /** DeleteOperationRequest name */ + name?: (string|null); + } + + /** Represents a DeleteOperationRequest. */ + class DeleteOperationRequest implements IDeleteOperationRequest { + + /** + * Constructs a new DeleteOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IDeleteOperationRequest); + + /** DeleteOperationRequest name. */ + public name: string; + + /** + * Creates a DeleteOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.DeleteOperationRequest; + + /** + * Creates a plain object from a DeleteOperationRequest message. Also converts values to other types if specified. + * @param message DeleteOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.DeleteOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a WaitOperationRequest. */ + interface IWaitOperationRequest { + + /** WaitOperationRequest name */ + name?: (string|null); + + /** WaitOperationRequest timeout */ + timeout?: (google.protobuf.IDuration|null); + } + + /** Represents a WaitOperationRequest. */ + class WaitOperationRequest implements IWaitOperationRequest { + + /** + * Constructs a new WaitOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IWaitOperationRequest); + + /** WaitOperationRequest name. */ + public name: string; + + /** WaitOperationRequest timeout. */ + public timeout?: (google.protobuf.IDuration|null); + + /** + * Creates a WaitOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WaitOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.WaitOperationRequest; + + /** + * Creates a plain object from a WaitOperationRequest message. Also converts values to other types if specified. + * @param message WaitOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.WaitOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WaitOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an OperationInfo. */ + interface IOperationInfo { + + /** OperationInfo responseType */ + responseType?: (string|null); + + /** OperationInfo metadataType */ + metadataType?: (string|null); + } + + /** Represents an OperationInfo. */ + class OperationInfo implements IOperationInfo { + + /** + * Constructs a new OperationInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IOperationInfo); + + /** OperationInfo responseType. */ + public responseType: string; + + /** OperationInfo metadataType. */ + public metadataType: string; + + /** + * Creates an OperationInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OperationInfo + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.OperationInfo; + + /** + * Creates a plain object from an OperationInfo message. Also converts values to other types if specified. + * @param message OperationInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.OperationInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OperationInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } +} diff --git a/types/protos/firestore_v1_proto_api.d.ts b/types/protos/firestore_v1_proto_api.d.ts new file mode 100644 index 000000000..8ff113db2 --- /dev/null +++ b/types/protos/firestore_v1_proto_api.d.ts @@ -0,0 +1,7132 @@ +/*! + * Copyright 2021 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 $protobuf from "protobufjs"; +/** Namespace firestore. */ +export namespace firestore { + + /** Properties of a BundledQuery. */ + interface IBundledQuery { + + /** BundledQuery parent */ + parent?: (string|null); + + /** BundledQuery structuredQuery */ + structuredQuery?: (google.firestore.v1.IStructuredQuery|null); + + /** BundledQuery limitType */ + limitType?: (firestore.BundledQuery.LimitType|null); + } + + /** Represents a BundledQuery. */ + class BundledQuery implements IBundledQuery { + + /** + * Constructs a new BundledQuery. + * @param [properties] Properties to set + */ + constructor(properties?: firestore.IBundledQuery); + + /** BundledQuery parent. */ + public parent: string; + + /** BundledQuery structuredQuery. */ + public structuredQuery?: (google.firestore.v1.IStructuredQuery|null); + + /** BundledQuery limitType. */ + public limitType: firestore.BundledQuery.LimitType; + + /** BundledQuery queryType. */ + public queryType?: "structuredQuery"; + + /** + * Creates a BundledQuery message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BundledQuery + */ + public static fromObject(object: { [k: string]: any }): firestore.BundledQuery; + + /** + * Creates a plain object from a BundledQuery message. Also converts values to other types if specified. + * @param message BundledQuery + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: firestore.BundledQuery, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BundledQuery to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace BundledQuery { + + /** LimitType enum. */ + type LimitType = + "FIRST"| "LAST"; + } + + /** Properties of a NamedQuery. */ + interface INamedQuery { + + /** NamedQuery name */ + name?: (string|null); + + /** NamedQuery bundledQuery */ + bundledQuery?: (firestore.IBundledQuery|null); + + /** NamedQuery readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a NamedQuery. */ + class NamedQuery implements INamedQuery { + + /** + * Constructs a new NamedQuery. + * @param [properties] Properties to set + */ + constructor(properties?: firestore.INamedQuery); + + /** NamedQuery name. */ + public name: string; + + /** NamedQuery bundledQuery. */ + public bundledQuery?: (firestore.IBundledQuery|null); + + /** NamedQuery readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a NamedQuery message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns NamedQuery + */ + public static fromObject(object: { [k: string]: any }): firestore.NamedQuery; + + /** + * Creates a plain object from a NamedQuery message. Also converts values to other types if specified. + * @param message NamedQuery + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: firestore.NamedQuery, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this NamedQuery to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BundledDocumentMetadata. */ + interface IBundledDocumentMetadata { + + /** BundledDocumentMetadata name */ + name?: (string|null); + + /** BundledDocumentMetadata readTime */ + readTime?: (google.protobuf.ITimestamp|null); + + /** BundledDocumentMetadata exists */ + exists?: (boolean|null); + + /** BundledDocumentMetadata queries */ + queries?: (string[]|null); + } + + /** Represents a BundledDocumentMetadata. */ + class BundledDocumentMetadata implements IBundledDocumentMetadata { + + /** + * Constructs a new BundledDocumentMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: firestore.IBundledDocumentMetadata); + + /** BundledDocumentMetadata name. */ + public name: string; + + /** BundledDocumentMetadata readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** BundledDocumentMetadata exists. */ + public exists: boolean; + + /** BundledDocumentMetadata queries. */ + public queries: string[]; + + /** + * Creates a BundledDocumentMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BundledDocumentMetadata + */ + public static fromObject(object: { [k: string]: any }): firestore.BundledDocumentMetadata; + + /** + * Creates a plain object from a BundledDocumentMetadata message. Also converts values to other types if specified. + * @param message BundledDocumentMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: firestore.BundledDocumentMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BundledDocumentMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BundleMetadata. */ + interface IBundleMetadata { + + /** BundleMetadata id */ + id?: (string|null); + + /** BundleMetadata createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** BundleMetadata version */ + version?: (number|null); + + /** BundleMetadata totalDocuments */ + totalDocuments?: (number|null); + + /** BundleMetadata totalBytes */ + totalBytes?: (number|string|null); + } + + /** Represents a BundleMetadata. */ + class BundleMetadata implements IBundleMetadata { + + /** + * Constructs a new BundleMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: firestore.IBundleMetadata); + + /** BundleMetadata id. */ + public id: string; + + /** BundleMetadata createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** BundleMetadata version. */ + public version: number; + + /** BundleMetadata totalDocuments. */ + public totalDocuments: number; + + /** BundleMetadata totalBytes. */ + public totalBytes: (number|string); + + /** + * Creates a BundleMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BundleMetadata + */ + public static fromObject(object: { [k: string]: any }): firestore.BundleMetadata; + + /** + * Creates a plain object from a BundleMetadata message. Also converts values to other types if specified. + * @param message BundleMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: firestore.BundleMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BundleMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BundleElement. */ + interface IBundleElement { + + /** BundleElement metadata */ + metadata?: (firestore.IBundleMetadata|null); + + /** BundleElement namedQuery */ + namedQuery?: (firestore.INamedQuery|null); + + /** BundleElement documentMetadata */ + documentMetadata?: (firestore.IBundledDocumentMetadata|null); + + /** BundleElement document */ + document?: (google.firestore.v1.IDocument|null); + } + + /** Represents a BundleElement. */ + class BundleElement implements IBundleElement { + + /** + * Constructs a new BundleElement. + * @param [properties] Properties to set + */ + constructor(properties?: firestore.IBundleElement); + + /** BundleElement metadata. */ + public metadata?: (firestore.IBundleMetadata|null); + + /** BundleElement namedQuery. */ + public namedQuery?: (firestore.INamedQuery|null); + + /** BundleElement documentMetadata. */ + public documentMetadata?: (firestore.IBundledDocumentMetadata|null); + + /** BundleElement document. */ + public document?: (google.firestore.v1.IDocument|null); + + /** BundleElement elementType. */ + public elementType?: ("metadata"|"namedQuery"|"documentMetadata"|"document"); + + /** + * Creates a BundleElement message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BundleElement + */ + public static fromObject(object: { [k: string]: any }): firestore.BundleElement; + + /** + * Creates a plain object from a BundleElement message. Also converts values to other types if specified. + * @param message BundleElement + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: firestore.BundleElement, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BundleElement to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } +} + +/** Namespace google. */ +export namespace google { + + /** Namespace protobuf. */ + namespace protobuf { + + /** Properties of a Timestamp. */ + interface ITimestamp { + + /** Timestamp seconds */ + seconds?: (number|string|null); + + /** Timestamp nanos */ + nanos?: (number|null); + } + + /** Represents a Timestamp. */ + class Timestamp implements ITimestamp { + + /** + * Constructs a new Timestamp. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.ITimestamp); + + /** Timestamp seconds. */ + public seconds: (number|string); + + /** Timestamp nanos. */ + public nanos: number; + + /** + * Creates a Timestamp message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Timestamp + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Timestamp; + + /** + * Creates a plain object from a Timestamp message. Also converts values to other types if specified. + * @param message Timestamp + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Timestamp, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Timestamp to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FileDescriptorSet. */ + interface IFileDescriptorSet { + + /** FileDescriptorSet file */ + file?: (google.protobuf.IFileDescriptorProto[]|null); + } + + /** Represents a FileDescriptorSet. */ + class FileDescriptorSet implements IFileDescriptorSet { + + /** + * Constructs a new FileDescriptorSet. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileDescriptorSet); + + /** FileDescriptorSet file. */ + public file: google.protobuf.IFileDescriptorProto[]; + + /** + * Creates a FileDescriptorSet message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileDescriptorSet + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileDescriptorSet; + + /** + * Creates a plain object from a FileDescriptorSet message. Also converts values to other types if specified. + * @param message FileDescriptorSet + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileDescriptorSet, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileDescriptorSet to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FileDescriptorProto. */ + interface IFileDescriptorProto { + + /** FileDescriptorProto name */ + name?: (string|null); + + /** FileDescriptorProto package */ + "package"?: (string|null); + + /** FileDescriptorProto dependency */ + dependency?: (string[]|null); + + /** FileDescriptorProto publicDependency */ + publicDependency?: (number[]|null); + + /** FileDescriptorProto weakDependency */ + weakDependency?: (number[]|null); + + /** FileDescriptorProto messageType */ + messageType?: (google.protobuf.IDescriptorProto[]|null); + + /** FileDescriptorProto enumType */ + enumType?: (google.protobuf.IEnumDescriptorProto[]|null); + + /** FileDescriptorProto service */ + service?: (google.protobuf.IServiceDescriptorProto[]|null); + + /** FileDescriptorProto extension */ + extension?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** FileDescriptorProto options */ + options?: (google.protobuf.IFileOptions|null); + + /** FileDescriptorProto sourceCodeInfo */ + sourceCodeInfo?: (google.protobuf.ISourceCodeInfo|null); + + /** FileDescriptorProto syntax */ + syntax?: (string|null); + } + + /** Represents a FileDescriptorProto. */ + class FileDescriptorProto implements IFileDescriptorProto { + + /** + * Constructs a new FileDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileDescriptorProto); + + /** FileDescriptorProto name. */ + public name: string; + + /** FileDescriptorProto package. */ + public package: string; + + /** FileDescriptorProto dependency. */ + public dependency: string[]; + + /** FileDescriptorProto publicDependency. */ + public publicDependency: number[]; + + /** FileDescriptorProto weakDependency. */ + public weakDependency: number[]; + + /** FileDescriptorProto messageType. */ + public messageType: google.protobuf.IDescriptorProto[]; + + /** FileDescriptorProto enumType. */ + public enumType: google.protobuf.IEnumDescriptorProto[]; + + /** FileDescriptorProto service. */ + public service: google.protobuf.IServiceDescriptorProto[]; + + /** FileDescriptorProto extension. */ + public extension: google.protobuf.IFieldDescriptorProto[]; + + /** FileDescriptorProto options. */ + public options?: (google.protobuf.IFileOptions|null); + + /** FileDescriptorProto sourceCodeInfo. */ + public sourceCodeInfo?: (google.protobuf.ISourceCodeInfo|null); + + /** FileDescriptorProto syntax. */ + public syntax: string; + + /** + * Creates a FileDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileDescriptorProto; + + /** + * Creates a plain object from a FileDescriptorProto message. Also converts values to other types if specified. + * @param message FileDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DescriptorProto. */ + interface IDescriptorProto { + + /** DescriptorProto name */ + name?: (string|null); + + /** DescriptorProto field */ + field?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** DescriptorProto extension */ + extension?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** DescriptorProto nestedType */ + nestedType?: (google.protobuf.IDescriptorProto[]|null); + + /** DescriptorProto enumType */ + enumType?: (google.protobuf.IEnumDescriptorProto[]|null); + + /** DescriptorProto extensionRange */ + extensionRange?: (google.protobuf.DescriptorProto.IExtensionRange[]|null); + + /** DescriptorProto oneofDecl */ + oneofDecl?: (google.protobuf.IOneofDescriptorProto[]|null); + + /** DescriptorProto options */ + options?: (google.protobuf.IMessageOptions|null); + + /** DescriptorProto reservedRange */ + reservedRange?: (google.protobuf.DescriptorProto.IReservedRange[]|null); + + /** DescriptorProto reservedName */ + reservedName?: (string[]|null); + } + + /** Represents a DescriptorProto. */ + class DescriptorProto implements IDescriptorProto { + + /** + * Constructs a new DescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDescriptorProto); + + /** DescriptorProto name. */ + public name: string; + + /** DescriptorProto field. */ + public field: google.protobuf.IFieldDescriptorProto[]; + + /** DescriptorProto extension. */ + public extension: google.protobuf.IFieldDescriptorProto[]; + + /** DescriptorProto nestedType. */ + public nestedType: google.protobuf.IDescriptorProto[]; + + /** DescriptorProto enumType. */ + public enumType: google.protobuf.IEnumDescriptorProto[]; + + /** DescriptorProto extensionRange. */ + public extensionRange: google.protobuf.DescriptorProto.IExtensionRange[]; + + /** DescriptorProto oneofDecl. */ + public oneofDecl: google.protobuf.IOneofDescriptorProto[]; + + /** DescriptorProto options. */ + public options?: (google.protobuf.IMessageOptions|null); + + /** DescriptorProto reservedRange. */ + public reservedRange: google.protobuf.DescriptorProto.IReservedRange[]; + + /** DescriptorProto reservedName. */ + public reservedName: string[]; + + /** + * Creates a DescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto; + + /** + * Creates a plain object from a DescriptorProto message. Also converts values to other types if specified. + * @param message DescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace DescriptorProto { + + /** Properties of an ExtensionRange. */ + interface IExtensionRange { + + /** ExtensionRange start */ + start?: (number|null); + + /** ExtensionRange end */ + end?: (number|null); + } + + /** Represents an ExtensionRange. */ + class ExtensionRange implements IExtensionRange { + + /** + * Constructs a new ExtensionRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.DescriptorProto.IExtensionRange); + + /** ExtensionRange start. */ + public start: number; + + /** ExtensionRange end. */ + public end: number; + + /** + * Creates an ExtensionRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExtensionRange + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto.ExtensionRange; + + /** + * Creates a plain object from an ExtensionRange message. Also converts values to other types if specified. + * @param message ExtensionRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto.ExtensionRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExtensionRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ReservedRange. */ + interface IReservedRange { + + /** ReservedRange start */ + start?: (number|null); + + /** ReservedRange end */ + end?: (number|null); + } + + /** Represents a ReservedRange. */ + class ReservedRange implements IReservedRange { + + /** + * Constructs a new ReservedRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.DescriptorProto.IReservedRange); + + /** ReservedRange start. */ + public start: number; + + /** ReservedRange end. */ + public end: number; + + /** + * Creates a ReservedRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReservedRange + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto.ReservedRange; + + /** + * Creates a plain object from a ReservedRange message. Also converts values to other types if specified. + * @param message ReservedRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto.ReservedRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReservedRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a FieldDescriptorProto. */ + interface IFieldDescriptorProto { + + /** FieldDescriptorProto name */ + name?: (string|null); + + /** FieldDescriptorProto number */ + number?: (number|null); + + /** FieldDescriptorProto label */ + label?: (google.protobuf.FieldDescriptorProto.Label|null); + + /** FieldDescriptorProto type */ + type?: (google.protobuf.FieldDescriptorProto.Type|null); + + /** FieldDescriptorProto typeName */ + typeName?: (string|null); + + /** FieldDescriptorProto extendee */ + extendee?: (string|null); + + /** FieldDescriptorProto defaultValue */ + defaultValue?: (string|null); + + /** FieldDescriptorProto oneofIndex */ + oneofIndex?: (number|null); + + /** FieldDescriptorProto jsonName */ + jsonName?: (string|null); + + /** FieldDescriptorProto options */ + options?: (google.protobuf.IFieldOptions|null); + } + + /** Represents a FieldDescriptorProto. */ + class FieldDescriptorProto implements IFieldDescriptorProto { + + /** + * Constructs a new FieldDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldDescriptorProto); + + /** FieldDescriptorProto name. */ + public name: string; + + /** FieldDescriptorProto number. */ + public number: number; + + /** FieldDescriptorProto label. */ + public label: google.protobuf.FieldDescriptorProto.Label; + + /** FieldDescriptorProto type. */ + public type: google.protobuf.FieldDescriptorProto.Type; + + /** FieldDescriptorProto typeName. */ + public typeName: string; + + /** FieldDescriptorProto extendee. */ + public extendee: string; + + /** FieldDescriptorProto defaultValue. */ + public defaultValue: string; + + /** FieldDescriptorProto oneofIndex. */ + public oneofIndex: number; + + /** FieldDescriptorProto jsonName. */ + public jsonName: string; + + /** FieldDescriptorProto options. */ + public options?: (google.protobuf.IFieldOptions|null); + + /** + * Creates a FieldDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldDescriptorProto; + + /** + * Creates a plain object from a FieldDescriptorProto message. Also converts values to other types if specified. + * @param message FieldDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace FieldDescriptorProto { + + /** Type enum. */ + type Type = + "TYPE_DOUBLE"| "TYPE_FLOAT"| "TYPE_INT64"| "TYPE_UINT64"| "TYPE_INT32"| "TYPE_FIXED64"| "TYPE_FIXED32"| "TYPE_BOOL"| "TYPE_STRING"| "TYPE_GROUP"| "TYPE_MESSAGE"| "TYPE_BYTES"| "TYPE_UINT32"| "TYPE_ENUM"| "TYPE_SFIXED32"| "TYPE_SFIXED64"| "TYPE_SINT32"| "TYPE_SINT64"; + + /** Label enum. */ + type Label = + "LABEL_OPTIONAL"| "LABEL_REQUIRED"| "LABEL_REPEATED"; + } + + /** Properties of an OneofDescriptorProto. */ + interface IOneofDescriptorProto { + + /** OneofDescriptorProto name */ + name?: (string|null); + + /** OneofDescriptorProto options */ + options?: (google.protobuf.IOneofOptions|null); + } + + /** Represents an OneofDescriptorProto. */ + class OneofDescriptorProto implements IOneofDescriptorProto { + + /** + * Constructs a new OneofDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IOneofDescriptorProto); + + /** OneofDescriptorProto name. */ + public name: string; + + /** OneofDescriptorProto options. */ + public options?: (google.protobuf.IOneofOptions|null); + + /** + * Creates an OneofDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OneofDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.OneofDescriptorProto; + + /** + * Creates a plain object from an OneofDescriptorProto message. Also converts values to other types if specified. + * @param message OneofDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.OneofDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OneofDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an EnumDescriptorProto. */ + interface IEnumDescriptorProto { + + /** EnumDescriptorProto name */ + name?: (string|null); + + /** EnumDescriptorProto value */ + value?: (google.protobuf.IEnumValueDescriptorProto[]|null); + + /** EnumDescriptorProto options */ + options?: (google.protobuf.IEnumOptions|null); + } + + /** Represents an EnumDescriptorProto. */ + class EnumDescriptorProto implements IEnumDescriptorProto { + + /** + * Constructs a new EnumDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumDescriptorProto); + + /** EnumDescriptorProto name. */ + public name: string; + + /** EnumDescriptorProto value. */ + public value: google.protobuf.IEnumValueDescriptorProto[]; + + /** EnumDescriptorProto options. */ + public options?: (google.protobuf.IEnumOptions|null); + + /** + * Creates an EnumDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumDescriptorProto; + + /** + * Creates a plain object from an EnumDescriptorProto message. Also converts values to other types if specified. + * @param message EnumDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an EnumValueDescriptorProto. */ + interface IEnumValueDescriptorProto { + + /** EnumValueDescriptorProto name */ + name?: (string|null); + + /** EnumValueDescriptorProto number */ + number?: (number|null); + + /** EnumValueDescriptorProto options */ + options?: (google.protobuf.IEnumValueOptions|null); + } + + /** Represents an EnumValueDescriptorProto. */ + class EnumValueDescriptorProto implements IEnumValueDescriptorProto { + + /** + * Constructs a new EnumValueDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumValueDescriptorProto); + + /** EnumValueDescriptorProto name. */ + public name: string; + + /** EnumValueDescriptorProto number. */ + public number: number; + + /** EnumValueDescriptorProto options. */ + public options?: (google.protobuf.IEnumValueOptions|null); + + /** + * Creates an EnumValueDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumValueDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumValueDescriptorProto; + + /** + * Creates a plain object from an EnumValueDescriptorProto message. Also converts values to other types if specified. + * @param message EnumValueDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumValueDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumValueDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ServiceDescriptorProto. */ + interface IServiceDescriptorProto { + + /** ServiceDescriptorProto name */ + name?: (string|null); + + /** ServiceDescriptorProto method */ + method?: (google.protobuf.IMethodDescriptorProto[]|null); + + /** ServiceDescriptorProto options */ + options?: (google.protobuf.IServiceOptions|null); + } + + /** Represents a ServiceDescriptorProto. */ + class ServiceDescriptorProto implements IServiceDescriptorProto { + + /** + * Constructs a new ServiceDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IServiceDescriptorProto); + + /** ServiceDescriptorProto name. */ + public name: string; + + /** ServiceDescriptorProto method. */ + public method: google.protobuf.IMethodDescriptorProto[]; + + /** ServiceDescriptorProto options. */ + public options?: (google.protobuf.IServiceOptions|null); + + /** + * Creates a ServiceDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServiceDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ServiceDescriptorProto; + + /** + * Creates a plain object from a ServiceDescriptorProto message. Also converts values to other types if specified. + * @param message ServiceDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ServiceDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServiceDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a MethodDescriptorProto. */ + interface IMethodDescriptorProto { + + /** MethodDescriptorProto name */ + name?: (string|null); + + /** MethodDescriptorProto inputType */ + inputType?: (string|null); + + /** MethodDescriptorProto outputType */ + outputType?: (string|null); + + /** MethodDescriptorProto options */ + options?: (google.protobuf.IMethodOptions|null); + + /** MethodDescriptorProto clientStreaming */ + clientStreaming?: (boolean|null); + + /** MethodDescriptorProto serverStreaming */ + serverStreaming?: (boolean|null); + } + + /** Represents a MethodDescriptorProto. */ + class MethodDescriptorProto implements IMethodDescriptorProto { + + /** + * Constructs a new MethodDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMethodDescriptorProto); + + /** MethodDescriptorProto name. */ + public name: string; + + /** MethodDescriptorProto inputType. */ + public inputType: string; + + /** MethodDescriptorProto outputType. */ + public outputType: string; + + /** MethodDescriptorProto options. */ + public options?: (google.protobuf.IMethodOptions|null); + + /** MethodDescriptorProto clientStreaming. */ + public clientStreaming: boolean; + + /** MethodDescriptorProto serverStreaming. */ + public serverStreaming: boolean; + + /** + * Creates a MethodDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MethodDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MethodDescriptorProto; + + /** + * Creates a plain object from a MethodDescriptorProto message. Also converts values to other types if specified. + * @param message MethodDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MethodDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MethodDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FileOptions. */ + interface IFileOptions { + + /** FileOptions javaPackage */ + javaPackage?: (string|null); + + /** FileOptions javaOuterClassname */ + javaOuterClassname?: (string|null); + + /** FileOptions javaMultipleFiles */ + javaMultipleFiles?: (boolean|null); + + /** FileOptions javaGenerateEqualsAndHash */ + javaGenerateEqualsAndHash?: (boolean|null); + + /** FileOptions javaStringCheckUtf8 */ + javaStringCheckUtf8?: (boolean|null); + + /** FileOptions optimizeFor */ + optimizeFor?: (google.protobuf.FileOptions.OptimizeMode|null); + + /** FileOptions goPackage */ + goPackage?: (string|null); + + /** FileOptions ccGenericServices */ + ccGenericServices?: (boolean|null); + + /** FileOptions javaGenericServices */ + javaGenericServices?: (boolean|null); + + /** FileOptions pyGenericServices */ + pyGenericServices?: (boolean|null); + + /** FileOptions deprecated */ + deprecated?: (boolean|null); + + /** FileOptions ccEnableArenas */ + ccEnableArenas?: (boolean|null); + + /** FileOptions objcClassPrefix */ + objcClassPrefix?: (string|null); + + /** FileOptions csharpNamespace */ + csharpNamespace?: (string|null); + + /** FileOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** FileOptions .google.api.resourceDefinition */ + ".google.api.resourceDefinition"?: (google.api.IResourceDescriptor[]|null); + } + + /** Represents a FileOptions. */ + class FileOptions implements IFileOptions { + + /** + * Constructs a new FileOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileOptions); + + /** FileOptions javaPackage. */ + public javaPackage: string; + + /** FileOptions javaOuterClassname. */ + public javaOuterClassname: string; + + /** FileOptions javaMultipleFiles. */ + public javaMultipleFiles: boolean; + + /** FileOptions javaGenerateEqualsAndHash. */ + public javaGenerateEqualsAndHash: boolean; + + /** FileOptions javaStringCheckUtf8. */ + public javaStringCheckUtf8: boolean; + + /** FileOptions optimizeFor. */ + public optimizeFor: google.protobuf.FileOptions.OptimizeMode; + + /** FileOptions goPackage. */ + public goPackage: string; + + /** FileOptions ccGenericServices. */ + public ccGenericServices: boolean; + + /** FileOptions javaGenericServices. */ + public javaGenericServices: boolean; + + /** FileOptions pyGenericServices. */ + public pyGenericServices: boolean; + + /** FileOptions deprecated. */ + public deprecated: boolean; + + /** FileOptions ccEnableArenas. */ + public ccEnableArenas: boolean; + + /** FileOptions objcClassPrefix. */ + public objcClassPrefix: string; + + /** FileOptions csharpNamespace. */ + public csharpNamespace: string; + + /** FileOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a FileOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileOptions; + + /** + * Creates a plain object from a FileOptions message. Also converts values to other types if specified. + * @param message FileOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace FileOptions { + + /** OptimizeMode enum. */ + type OptimizeMode = + "SPEED"| "CODE_SIZE"| "LITE_RUNTIME"; + } + + /** Properties of a MessageOptions. */ + interface IMessageOptions { + + /** MessageOptions messageSetWireFormat */ + messageSetWireFormat?: (boolean|null); + + /** MessageOptions noStandardDescriptorAccessor */ + noStandardDescriptorAccessor?: (boolean|null); + + /** MessageOptions deprecated */ + deprecated?: (boolean|null); + + /** MessageOptions mapEntry */ + mapEntry?: (boolean|null); + + /** MessageOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** MessageOptions .google.api.resource */ + ".google.api.resource"?: (google.api.IResourceDescriptor|null); + } + + /** Represents a MessageOptions. */ + class MessageOptions implements IMessageOptions { + + /** + * Constructs a new MessageOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMessageOptions); + + /** MessageOptions messageSetWireFormat. */ + public messageSetWireFormat: boolean; + + /** MessageOptions noStandardDescriptorAccessor. */ + public noStandardDescriptorAccessor: boolean; + + /** MessageOptions deprecated. */ + public deprecated: boolean; + + /** MessageOptions mapEntry. */ + public mapEntry: boolean; + + /** MessageOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a MessageOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MessageOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MessageOptions; + + /** + * Creates a plain object from a MessageOptions message. Also converts values to other types if specified. + * @param message MessageOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MessageOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MessageOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FieldOptions. */ + interface IFieldOptions { + + /** FieldOptions ctype */ + ctype?: (google.protobuf.FieldOptions.CType|null); + + /** FieldOptions packed */ + packed?: (boolean|null); + + /** FieldOptions jstype */ + jstype?: (google.protobuf.FieldOptions.JSType|null); + + /** FieldOptions lazy */ + lazy?: (boolean|null); + + /** FieldOptions deprecated */ + deprecated?: (boolean|null); + + /** FieldOptions weak */ + weak?: (boolean|null); + + /** FieldOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** FieldOptions .google.api.fieldBehavior */ + ".google.api.fieldBehavior"?: (google.api.FieldBehavior[]|null); + + /** FieldOptions .google.api.resourceReference */ + ".google.api.resourceReference"?: (google.api.IResourceReference|null); + } + + /** Represents a FieldOptions. */ + class FieldOptions implements IFieldOptions { + + /** + * Constructs a new FieldOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldOptions); + + /** FieldOptions ctype. */ + public ctype: google.protobuf.FieldOptions.CType; + + /** FieldOptions packed. */ + public packed: boolean; + + /** FieldOptions jstype. */ + public jstype: google.protobuf.FieldOptions.JSType; + + /** FieldOptions lazy. */ + public lazy: boolean; + + /** FieldOptions deprecated. */ + public deprecated: boolean; + + /** FieldOptions weak. */ + public weak: boolean; + + /** FieldOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a FieldOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions; + + /** + * Creates a plain object from a FieldOptions message. Also converts values to other types if specified. + * @param message FieldOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace FieldOptions { + + /** CType enum. */ + type CType = + "STRING"| "CORD"| "STRING_PIECE"; + + /** JSType enum. */ + type JSType = + "JS_NORMAL"| "JS_STRING"| "JS_NUMBER"; + } + + /** Properties of an OneofOptions. */ + interface IOneofOptions { + + /** OneofOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an OneofOptions. */ + class OneofOptions implements IOneofOptions { + + /** + * Constructs a new OneofOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IOneofOptions); + + /** OneofOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an OneofOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OneofOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.OneofOptions; + + /** + * Creates a plain object from an OneofOptions message. Also converts values to other types if specified. + * @param message OneofOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.OneofOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OneofOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an EnumOptions. */ + interface IEnumOptions { + + /** EnumOptions allowAlias */ + allowAlias?: (boolean|null); + + /** EnumOptions deprecated */ + deprecated?: (boolean|null); + + /** EnumOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an EnumOptions. */ + class EnumOptions implements IEnumOptions { + + /** + * Constructs a new EnumOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumOptions); + + /** EnumOptions allowAlias. */ + public allowAlias: boolean; + + /** EnumOptions deprecated. */ + public deprecated: boolean; + + /** EnumOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an EnumOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumOptions; + + /** + * Creates a plain object from an EnumOptions message. Also converts values to other types if specified. + * @param message EnumOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an EnumValueOptions. */ + interface IEnumValueOptions { + + /** EnumValueOptions deprecated */ + deprecated?: (boolean|null); + + /** EnumValueOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an EnumValueOptions. */ + class EnumValueOptions implements IEnumValueOptions { + + /** + * Constructs a new EnumValueOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumValueOptions); + + /** EnumValueOptions deprecated. */ + public deprecated: boolean; + + /** EnumValueOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an EnumValueOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumValueOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumValueOptions; + + /** + * Creates a plain object from an EnumValueOptions message. Also converts values to other types if specified. + * @param message EnumValueOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumValueOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumValueOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ServiceOptions. */ + interface IServiceOptions { + + /** ServiceOptions deprecated */ + deprecated?: (boolean|null); + + /** ServiceOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** ServiceOptions .google.api.defaultHost */ + ".google.api.defaultHost"?: (string|null); + + /** ServiceOptions .google.api.oauthScopes */ + ".google.api.oauthScopes"?: (string|null); + } + + /** Represents a ServiceOptions. */ + class ServiceOptions implements IServiceOptions { + + /** + * Constructs a new ServiceOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IServiceOptions); + + /** ServiceOptions deprecated. */ + public deprecated: boolean; + + /** ServiceOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a ServiceOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServiceOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ServiceOptions; + + /** + * Creates a plain object from a ServiceOptions message. Also converts values to other types if specified. + * @param message ServiceOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ServiceOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServiceOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a MethodOptions. */ + interface IMethodOptions { + + /** MethodOptions deprecated */ + deprecated?: (boolean|null); + + /** MethodOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** MethodOptions .google.api.http */ + ".google.api.http"?: (google.api.IHttpRule|null); + + /** MethodOptions .google.api.methodSignature */ + ".google.api.methodSignature"?: (string[]|null); + + /** MethodOptions .google.longrunning.operationInfo */ + ".google.longrunning.operationInfo"?: (google.longrunning.IOperationInfo|null); + } + + /** Represents a MethodOptions. */ + class MethodOptions implements IMethodOptions { + + /** + * Constructs a new MethodOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMethodOptions); + + /** MethodOptions deprecated. */ + public deprecated: boolean; + + /** MethodOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a MethodOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MethodOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MethodOptions; + + /** + * Creates a plain object from a MethodOptions message. Also converts values to other types if specified. + * @param message MethodOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MethodOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MethodOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an UninterpretedOption. */ + interface IUninterpretedOption { + + /** UninterpretedOption name */ + name?: (google.protobuf.UninterpretedOption.INamePart[]|null); + + /** UninterpretedOption identifierValue */ + identifierValue?: (string|null); + + /** UninterpretedOption positiveIntValue */ + positiveIntValue?: (number|string|null); + + /** UninterpretedOption negativeIntValue */ + negativeIntValue?: (number|string|null); + + /** UninterpretedOption doubleValue */ + doubleValue?: (number|null); + + /** UninterpretedOption stringValue */ + stringValue?: (Uint8Array|null); + + /** UninterpretedOption aggregateValue */ + aggregateValue?: (string|null); + } + + /** Represents an UninterpretedOption. */ + class UninterpretedOption implements IUninterpretedOption { + + /** + * Constructs a new UninterpretedOption. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUninterpretedOption); + + /** UninterpretedOption name. */ + public name: google.protobuf.UninterpretedOption.INamePart[]; + + /** UninterpretedOption identifierValue. */ + public identifierValue: string; + + /** UninterpretedOption positiveIntValue. */ + public positiveIntValue: (number|string); + + /** UninterpretedOption negativeIntValue. */ + public negativeIntValue: (number|string); + + /** UninterpretedOption doubleValue. */ + public doubleValue: number; + + /** UninterpretedOption stringValue. */ + public stringValue: Uint8Array; + + /** UninterpretedOption aggregateValue. */ + public aggregateValue: string; + + /** + * Creates an UninterpretedOption message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UninterpretedOption + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UninterpretedOption; + + /** + * Creates a plain object from an UninterpretedOption message. Also converts values to other types if specified. + * @param message UninterpretedOption + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UninterpretedOption, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UninterpretedOption to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace UninterpretedOption { + + /** Properties of a NamePart. */ + interface INamePart { + + /** NamePart namePart */ + namePart: string; + + /** NamePart isExtension */ + isExtension: boolean; + } + + /** Represents a NamePart. */ + class NamePart implements INamePart { + + /** + * Constructs a new NamePart. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.UninterpretedOption.INamePart); + + /** NamePart namePart. */ + public namePart: string; + + /** NamePart isExtension. */ + public isExtension: boolean; + + /** + * Creates a NamePart message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns NamePart + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UninterpretedOption.NamePart; + + /** + * Creates a plain object from a NamePart message. Also converts values to other types if specified. + * @param message NamePart + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UninterpretedOption.NamePart, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this NamePart to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a SourceCodeInfo. */ + interface ISourceCodeInfo { + + /** SourceCodeInfo location */ + location?: (google.protobuf.SourceCodeInfo.ILocation[]|null); + } + + /** Represents a SourceCodeInfo. */ + class SourceCodeInfo implements ISourceCodeInfo { + + /** + * Constructs a new SourceCodeInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.ISourceCodeInfo); + + /** SourceCodeInfo location. */ + public location: google.protobuf.SourceCodeInfo.ILocation[]; + + /** + * Creates a SourceCodeInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SourceCodeInfo + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.SourceCodeInfo; + + /** + * Creates a plain object from a SourceCodeInfo message. Also converts values to other types if specified. + * @param message SourceCodeInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.SourceCodeInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SourceCodeInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace SourceCodeInfo { + + /** Properties of a Location. */ + interface ILocation { + + /** Location path */ + path?: (number[]|null); + + /** Location span */ + span?: (number[]|null); + + /** Location leadingComments */ + leadingComments?: (string|null); + + /** Location trailingComments */ + trailingComments?: (string|null); + + /** Location leadingDetachedComments */ + leadingDetachedComments?: (string[]|null); + } + + /** Represents a Location. */ + class Location implements ILocation { + + /** + * Constructs a new Location. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.SourceCodeInfo.ILocation); + + /** Location path. */ + public path: number[]; + + /** Location span. */ + public span: number[]; + + /** Location leadingComments. */ + public leadingComments: string; + + /** Location trailingComments. */ + public trailingComments: string; + + /** Location leadingDetachedComments. */ + public leadingDetachedComments: string[]; + + /** + * Creates a Location message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Location + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.SourceCodeInfo.Location; + + /** + * Creates a plain object from a Location message. Also converts values to other types if specified. + * @param message Location + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.SourceCodeInfo.Location, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Location to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a GeneratedCodeInfo. */ + interface IGeneratedCodeInfo { + + /** GeneratedCodeInfo annotation */ + annotation?: (google.protobuf.GeneratedCodeInfo.IAnnotation[]|null); + } + + /** Represents a GeneratedCodeInfo. */ + class GeneratedCodeInfo implements IGeneratedCodeInfo { + + /** + * Constructs a new GeneratedCodeInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IGeneratedCodeInfo); + + /** GeneratedCodeInfo annotation. */ + public annotation: google.protobuf.GeneratedCodeInfo.IAnnotation[]; + + /** + * Creates a GeneratedCodeInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GeneratedCodeInfo + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.GeneratedCodeInfo; + + /** + * Creates a plain object from a GeneratedCodeInfo message. Also converts values to other types if specified. + * @param message GeneratedCodeInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.GeneratedCodeInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GeneratedCodeInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace GeneratedCodeInfo { + + /** Properties of an Annotation. */ + interface IAnnotation { + + /** Annotation path */ + path?: (number[]|null); + + /** Annotation sourceFile */ + sourceFile?: (string|null); + + /** Annotation begin */ + begin?: (number|null); + + /** Annotation end */ + end?: (number|null); + } + + /** Represents an Annotation. */ + class Annotation implements IAnnotation { + + /** + * Constructs a new Annotation. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.GeneratedCodeInfo.IAnnotation); + + /** Annotation path. */ + public path: number[]; + + /** Annotation sourceFile. */ + public sourceFile: string; + + /** Annotation begin. */ + public begin: number; + + /** Annotation end. */ + public end: number; + + /** + * Creates an Annotation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Annotation + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.GeneratedCodeInfo.Annotation; + + /** + * Creates a plain object from an Annotation message. Also converts values to other types if specified. + * @param message Annotation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.GeneratedCodeInfo.Annotation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Annotation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a Struct. */ + interface IStruct { + + /** Struct fields */ + fields?: ({ [k: string]: google.protobuf.IValue }|null); + } + + /** Represents a Struct. */ + class Struct implements IStruct { + + /** + * Constructs a new Struct. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IStruct); + + /** Struct fields. */ + public fields: { [k: string]: google.protobuf.IValue }; + + /** + * Creates a Struct message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Struct + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Struct; + + /** + * Creates a plain object from a Struct message. Also converts values to other types if specified. + * @param message Struct + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Struct, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Struct to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Value. */ + interface IValue { + + /** Value nullValue */ + nullValue?: (google.protobuf.NullValue|null); + + /** Value numberValue */ + numberValue?: (number|null); + + /** Value stringValue */ + stringValue?: (string|null); + + /** Value boolValue */ + boolValue?: (boolean|null); + + /** Value structValue */ + structValue?: (google.protobuf.IStruct|null); + + /** Value listValue */ + listValue?: (google.protobuf.IListValue|null); + } + + /** Represents a Value. */ + class Value implements IValue { + + /** + * Constructs a new Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IValue); + + /** Value nullValue. */ + public nullValue: google.protobuf.NullValue; + + /** Value numberValue. */ + public numberValue: number; + + /** Value stringValue. */ + public stringValue: string; + + /** Value boolValue. */ + public boolValue: boolean; + + /** Value structValue. */ + public structValue?: (google.protobuf.IStruct|null); + + /** Value listValue. */ + public listValue?: (google.protobuf.IListValue|null); + + /** Value kind. */ + public kind?: ("nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"); + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Value; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @param message Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** NullValue enum. */ + type NullValue = + "NULL_VALUE"; + + /** Properties of a ListValue. */ + interface IListValue { + + /** ListValue values */ + values?: (google.protobuf.IValue[]|null); + } + + /** Represents a ListValue. */ + class ListValue implements IListValue { + + /** + * Constructs a new ListValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IListValue); + + /** ListValue values. */ + public values: google.protobuf.IValue[]; + + /** + * Creates a ListValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ListValue; + + /** + * Creates a plain object from a ListValue message. Also converts values to other types if specified. + * @param message ListValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ListValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an Empty. */ + interface IEmpty { + } + + /** Represents an Empty. */ + class Empty implements IEmpty { + + /** + * Constructs a new Empty. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEmpty); + + /** + * Creates an Empty message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Empty + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Empty; + + /** + * Creates a plain object from an Empty message. Also converts values to other types if specified. + * @param message Empty + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Empty, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Empty to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DoubleValue. */ + interface IDoubleValue { + + /** DoubleValue value */ + value?: (number|null); + } + + /** Represents a DoubleValue. */ + class DoubleValue implements IDoubleValue { + + /** + * Constructs a new DoubleValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDoubleValue); + + /** DoubleValue value. */ + public value: number; + + /** + * Creates a DoubleValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DoubleValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DoubleValue; + + /** + * Creates a plain object from a DoubleValue message. Also converts values to other types if specified. + * @param message DoubleValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DoubleValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DoubleValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FloatValue. */ + interface IFloatValue { + + /** FloatValue value */ + value?: (number|null); + } + + /** Represents a FloatValue. */ + class FloatValue implements IFloatValue { + + /** + * Constructs a new FloatValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFloatValue); + + /** FloatValue value. */ + public value: number; + + /** + * Creates a FloatValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FloatValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FloatValue; + + /** + * Creates a plain object from a FloatValue message. Also converts values to other types if specified. + * @param message FloatValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FloatValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FloatValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an Int64Value. */ + interface IInt64Value { + + /** Int64Value value */ + value?: (number|string|null); + } + + /** Represents an Int64Value. */ + class Int64Value implements IInt64Value { + + /** + * Constructs a new Int64Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IInt64Value); + + /** Int64Value value. */ + public value: (number|string); + + /** + * Creates an Int64Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Int64Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Int64Value; + + /** + * Creates a plain object from an Int64Value message. Also converts values to other types if specified. + * @param message Int64Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Int64Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Int64Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a UInt64Value. */ + interface IUInt64Value { + + /** UInt64Value value */ + value?: (number|string|null); + } + + /** Represents a UInt64Value. */ + class UInt64Value implements IUInt64Value { + + /** + * Constructs a new UInt64Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUInt64Value); + + /** UInt64Value value. */ + public value: (number|string); + + /** + * Creates a UInt64Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UInt64Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UInt64Value; + + /** + * Creates a plain object from a UInt64Value message. Also converts values to other types if specified. + * @param message UInt64Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UInt64Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UInt64Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an Int32Value. */ + interface IInt32Value { + + /** Int32Value value */ + value?: (number|null); + } + + /** Represents an Int32Value. */ + class Int32Value implements IInt32Value { + + /** + * Constructs a new Int32Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IInt32Value); + + /** Int32Value value. */ + public value: number; + + /** + * Creates an Int32Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Int32Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Int32Value; + + /** + * Creates a plain object from an Int32Value message. Also converts values to other types if specified. + * @param message Int32Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Int32Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Int32Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a UInt32Value. */ + interface IUInt32Value { + + /** UInt32Value value */ + value?: (number|null); + } + + /** Represents a UInt32Value. */ + class UInt32Value implements IUInt32Value { + + /** + * Constructs a new UInt32Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUInt32Value); + + /** UInt32Value value. */ + public value: number; + + /** + * Creates a UInt32Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UInt32Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UInt32Value; + + /** + * Creates a plain object from a UInt32Value message. Also converts values to other types if specified. + * @param message UInt32Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UInt32Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UInt32Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BoolValue. */ + interface IBoolValue { + + /** BoolValue value */ + value?: (boolean|null); + } + + /** Represents a BoolValue. */ + class BoolValue implements IBoolValue { + + /** + * Constructs a new BoolValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IBoolValue); + + /** BoolValue value. */ + public value: boolean; + + /** + * Creates a BoolValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BoolValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.BoolValue; + + /** + * Creates a plain object from a BoolValue message. Also converts values to other types if specified. + * @param message BoolValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.BoolValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BoolValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a StringValue. */ + interface IStringValue { + + /** StringValue value */ + value?: (string|null); + } + + /** Represents a StringValue. */ + class StringValue implements IStringValue { + + /** + * Constructs a new StringValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IStringValue); + + /** StringValue value. */ + public value: string; + + /** + * Creates a StringValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StringValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.StringValue; + + /** + * Creates a plain object from a StringValue message. Also converts values to other types if specified. + * @param message StringValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.StringValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StringValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BytesValue. */ + interface IBytesValue { + + /** BytesValue value */ + value?: (Uint8Array|null); + } + + /** Represents a BytesValue. */ + class BytesValue implements IBytesValue { + + /** + * Constructs a new BytesValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IBytesValue); + + /** BytesValue value. */ + public value: Uint8Array; + + /** + * Creates a BytesValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BytesValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.BytesValue; + + /** + * Creates a plain object from a BytesValue message. Also converts values to other types if specified. + * @param message BytesValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.BytesValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BytesValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an Any. */ + interface IAny { + + /** Any type_url */ + type_url?: (string|null); + + /** Any value */ + value?: (Uint8Array|null); + } + + /** Represents an Any. */ + class Any implements IAny { + + /** + * Constructs a new Any. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IAny); + + /** Any type_url. */ + public type_url: string; + + /** Any value. */ + public value: Uint8Array; + + /** + * Creates an Any message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Any + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Any; + + /** + * Creates a plain object from an Any message. Also converts values to other types if specified. + * @param message Any + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Any, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Any to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FieldMask. */ + interface IFieldMask { + + /** FieldMask paths */ + paths?: (string[]|null); + } + + /** Represents a FieldMask. */ + class FieldMask implements IFieldMask { + + /** + * Constructs a new FieldMask. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldMask); + + /** FieldMask paths. */ + public paths: string[]; + + /** + * Creates a FieldMask message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldMask + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldMask; + + /** + * Creates a plain object from a FieldMask message. Also converts values to other types if specified. + * @param message FieldMask + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldMask, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldMask to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Duration. */ + interface IDuration { + + /** Duration seconds */ + seconds?: (number|string|null); + + /** Duration nanos */ + nanos?: (number|null); + } + + /** Represents a Duration. */ + class Duration implements IDuration { + + /** + * Constructs a new Duration. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDuration); + + /** Duration seconds. */ + public seconds: (number|string); + + /** Duration nanos. */ + public nanos: number; + + /** + * Creates a Duration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Duration + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Duration; + + /** + * Creates a plain object from a Duration message. Also converts values to other types if specified. + * @param message Duration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Duration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Duration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Namespace firestore. */ + namespace firestore { + + /** Namespace v1. */ + namespace v1 { + + /** Properties of a DocumentMask. */ + interface IDocumentMask { + + /** DocumentMask fieldPaths */ + fieldPaths?: (string[]|null); + } + + /** Represents a DocumentMask. */ + class DocumentMask implements IDocumentMask { + + /** + * Constructs a new DocumentMask. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IDocumentMask); + + /** DocumentMask fieldPaths. */ + public fieldPaths: string[]; + + /** + * Creates a DocumentMask message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentMask + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.DocumentMask; + + /** + * Creates a plain object from a DocumentMask message. Also converts values to other types if specified. + * @param message DocumentMask + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.DocumentMask, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentMask to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Precondition. */ + interface IPrecondition { + + /** Precondition exists */ + exists?: (boolean|null); + + /** Precondition updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a Precondition. */ + class Precondition implements IPrecondition { + + /** + * Constructs a new Precondition. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IPrecondition); + + /** Precondition exists. */ + public exists: boolean; + + /** Precondition updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** Precondition conditionType. */ + public conditionType?: ("exists"|"updateTime"); + + /** + * Creates a Precondition message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Precondition + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.Precondition; + + /** + * Creates a plain object from a Precondition message. Also converts values to other types if specified. + * @param message Precondition + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.Precondition, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Precondition to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a TransactionOptions. */ + interface ITransactionOptions { + + /** TransactionOptions readOnly */ + readOnly?: (google.firestore.v1.TransactionOptions.IReadOnly|null); + + /** TransactionOptions readWrite */ + readWrite?: (google.firestore.v1.TransactionOptions.IReadWrite|null); + } + + /** Represents a TransactionOptions. */ + class TransactionOptions implements ITransactionOptions { + + /** + * Constructs a new TransactionOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.ITransactionOptions); + + /** TransactionOptions readOnly. */ + public readOnly?: (google.firestore.v1.TransactionOptions.IReadOnly|null); + + /** TransactionOptions readWrite. */ + public readWrite?: (google.firestore.v1.TransactionOptions.IReadWrite|null); + + /** TransactionOptions mode. */ + public mode?: ("readOnly"|"readWrite"); + + /** + * Creates a TransactionOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TransactionOptions + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.TransactionOptions; + + /** + * Creates a plain object from a TransactionOptions message. Also converts values to other types if specified. + * @param message TransactionOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.TransactionOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TransactionOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace TransactionOptions { + + /** Properties of a ReadWrite. */ + interface IReadWrite { + + /** ReadWrite retryTransaction */ + retryTransaction?: (Uint8Array|null); + } + + /** Represents a ReadWrite. */ + class ReadWrite implements IReadWrite { + + /** + * Constructs a new ReadWrite. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.TransactionOptions.IReadWrite); + + /** ReadWrite retryTransaction. */ + public retryTransaction: Uint8Array; + + /** + * Creates a ReadWrite message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReadWrite + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.TransactionOptions.ReadWrite; + + /** + * Creates a plain object from a ReadWrite message. Also converts values to other types if specified. + * @param message ReadWrite + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.TransactionOptions.ReadWrite, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReadWrite to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ReadOnly. */ + interface IReadOnly { + + /** ReadOnly readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a ReadOnly. */ + class ReadOnly implements IReadOnly { + + /** + * Constructs a new ReadOnly. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.TransactionOptions.IReadOnly); + + /** ReadOnly readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** ReadOnly consistencySelector. */ + public consistencySelector?: "readTime"; + + /** + * Creates a ReadOnly message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReadOnly + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.TransactionOptions.ReadOnly; + + /** + * Creates a plain object from a ReadOnly message. Also converts values to other types if specified. + * @param message ReadOnly + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.TransactionOptions.ReadOnly, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReadOnly to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a Document. */ + interface IDocument { + + /** Document name */ + name?: (string|null); + + /** Document fields */ + fields?: ({ [k: string]: google.firestore.v1.IValue }|null); + + /** Document createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** Document updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a Document. */ + class Document implements IDocument { + + /** + * Constructs a new Document. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IDocument); + + /** Document name. */ + public name: string; + + /** Document fields. */ + public fields: { [k: string]: google.firestore.v1.IValue }; + + /** Document createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** Document updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a Document message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Document + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.Document; + + /** + * Creates a plain object from a Document message. Also converts values to other types if specified. + * @param message Document + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.Document, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Document to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Value. */ + interface IValue { + + /** Value nullValue */ + nullValue?: (google.protobuf.NullValue|null); + + /** Value booleanValue */ + booleanValue?: (boolean|null); + + /** Value integerValue */ + integerValue?: (number|string|null); + + /** Value doubleValue */ + doubleValue?: (number|null); + + /** Value timestampValue */ + timestampValue?: (google.protobuf.ITimestamp|null); + + /** Value stringValue */ + stringValue?: (string|null); + + /** Value bytesValue */ + bytesValue?: (Uint8Array|null); + + /** Value referenceValue */ + referenceValue?: (string|null); + + /** Value geoPointValue */ + geoPointValue?: (google.type.ILatLng|null); + + /** Value arrayValue */ + arrayValue?: (google.firestore.v1.IArrayValue|null); + + /** Value mapValue */ + mapValue?: (google.firestore.v1.IMapValue|null); + } + + /** Represents a Value. */ + class Value implements IValue { + + /** + * Constructs a new Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IValue); + + /** Value nullValue. */ + public nullValue: google.protobuf.NullValue; + + /** Value booleanValue. */ + public booleanValue: boolean; + + /** Value integerValue. */ + public integerValue: (number|string); + + /** Value doubleValue. */ + public doubleValue: number; + + /** Value timestampValue. */ + public timestampValue?: (google.protobuf.ITimestamp|null); + + /** Value stringValue. */ + public stringValue: string; + + /** Value bytesValue. */ + public bytesValue: Uint8Array; + + /** Value referenceValue. */ + public referenceValue: string; + + /** Value geoPointValue. */ + public geoPointValue?: (google.type.ILatLng|null); + + /** Value arrayValue. */ + public arrayValue?: (google.firestore.v1.IArrayValue|null); + + /** Value mapValue. */ + public mapValue?: (google.firestore.v1.IMapValue|null); + + /** Value valueType. */ + public valueType?: ("nullValue"|"booleanValue"|"integerValue"|"doubleValue"|"timestampValue"|"stringValue"|"bytesValue"|"referenceValue"|"geoPointValue"|"arrayValue"|"mapValue"); + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Value + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.Value; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @param message Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an ArrayValue. */ + interface IArrayValue { + + /** ArrayValue values */ + values?: (google.firestore.v1.IValue[]|null); + } + + /** Represents an ArrayValue. */ + class ArrayValue implements IArrayValue { + + /** + * Constructs a new ArrayValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IArrayValue); + + /** ArrayValue values. */ + public values: google.firestore.v1.IValue[]; + + /** + * Creates an ArrayValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ArrayValue + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.ArrayValue; + + /** + * Creates a plain object from an ArrayValue message. Also converts values to other types if specified. + * @param message ArrayValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.ArrayValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ArrayValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a MapValue. */ + interface IMapValue { + + /** MapValue fields */ + fields?: ({ [k: string]: google.firestore.v1.IValue }|null); + } + + /** Represents a MapValue. */ + class MapValue implements IMapValue { + + /** + * Constructs a new MapValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IMapValue); + + /** MapValue fields. */ + public fields: { [k: string]: google.firestore.v1.IValue }; + + /** + * Creates a MapValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MapValue + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.MapValue; + + /** + * Creates a plain object from a MapValue message. Also converts values to other types if specified. + * @param message MapValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.MapValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MapValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Represents a Firestore */ + class Firestore extends $protobuf.rpc.Service { + + /** + * Constructs a new Firestore service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Calls GetDocument. + * @param request GetDocumentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Document + */ + public getDocument(request: google.firestore.v1.IGetDocumentRequest, callback: google.firestore.v1.Firestore.GetDocumentCallback): void; + + /** + * Calls GetDocument. + * @param request GetDocumentRequest message or plain object + * @returns Promise + */ + public getDocument(request: google.firestore.v1.IGetDocumentRequest): Promise; + + /** + * Calls ListDocuments. + * @param request ListDocumentsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListDocumentsResponse + */ + public listDocuments(request: google.firestore.v1.IListDocumentsRequest, callback: google.firestore.v1.Firestore.ListDocumentsCallback): void; + + /** + * Calls ListDocuments. + * @param request ListDocumentsRequest message or plain object + * @returns Promise + */ + public listDocuments(request: google.firestore.v1.IListDocumentsRequest): Promise; + + /** + * Calls UpdateDocument. + * @param request UpdateDocumentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Document + */ + public updateDocument(request: google.firestore.v1.IUpdateDocumentRequest, callback: google.firestore.v1.Firestore.UpdateDocumentCallback): void; + + /** + * Calls UpdateDocument. + * @param request UpdateDocumentRequest message or plain object + * @returns Promise + */ + public updateDocument(request: google.firestore.v1.IUpdateDocumentRequest): Promise; + + /** + * Calls DeleteDocument. + * @param request DeleteDocumentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteDocument(request: google.firestore.v1.IDeleteDocumentRequest, callback: google.firestore.v1.Firestore.DeleteDocumentCallback): void; + + /** + * Calls DeleteDocument. + * @param request DeleteDocumentRequest message or plain object + * @returns Promise + */ + public deleteDocument(request: google.firestore.v1.IDeleteDocumentRequest): Promise; + + /** + * Calls BatchGetDocuments. + * @param request BatchGetDocumentsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and BatchGetDocumentsResponse + */ + public batchGetDocuments(request: google.firestore.v1.IBatchGetDocumentsRequest, callback: google.firestore.v1.Firestore.BatchGetDocumentsCallback): void; + + /** + * Calls BatchGetDocuments. + * @param request BatchGetDocumentsRequest message or plain object + * @returns Promise + */ + public batchGetDocuments(request: google.firestore.v1.IBatchGetDocumentsRequest): Promise; + + /** + * Calls BeginTransaction. + * @param request BeginTransactionRequest message or plain object + * @param callback Node-style callback called with the error, if any, and BeginTransactionResponse + */ + public beginTransaction(request: google.firestore.v1.IBeginTransactionRequest, callback: google.firestore.v1.Firestore.BeginTransactionCallback): void; + + /** + * Calls BeginTransaction. + * @param request BeginTransactionRequest message or plain object + * @returns Promise + */ + public beginTransaction(request: google.firestore.v1.IBeginTransactionRequest): Promise; + + /** + * Calls Commit. + * @param request CommitRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CommitResponse + */ + public commit(request: google.firestore.v1.ICommitRequest, callback: google.firestore.v1.Firestore.CommitCallback): void; + + /** + * Calls Commit. + * @param request CommitRequest message or plain object + * @returns Promise + */ + public commit(request: google.firestore.v1.ICommitRequest): Promise; + + /** + * Calls Rollback. + * @param request RollbackRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public rollback(request: google.firestore.v1.IRollbackRequest, callback: google.firestore.v1.Firestore.RollbackCallback): void; + + /** + * Calls Rollback. + * @param request RollbackRequest message or plain object + * @returns Promise + */ + public rollback(request: google.firestore.v1.IRollbackRequest): Promise; + + /** + * Calls RunQuery. + * @param request RunQueryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and RunQueryResponse + */ + public runQuery(request: google.firestore.v1.IRunQueryRequest, callback: google.firestore.v1.Firestore.RunQueryCallback): void; + + /** + * Calls RunQuery. + * @param request RunQueryRequest message or plain object + * @returns Promise + */ + public runQuery(request: google.firestore.v1.IRunQueryRequest): Promise; + + /** + * Calls PartitionQuery. + * @param request PartitionQueryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and PartitionQueryResponse + */ + public partitionQuery(request: google.firestore.v1.IPartitionQueryRequest, callback: google.firestore.v1.Firestore.PartitionQueryCallback): void; + + /** + * Calls PartitionQuery. + * @param request PartitionQueryRequest message or plain object + * @returns Promise + */ + public partitionQuery(request: google.firestore.v1.IPartitionQueryRequest): Promise; + + /** + * Calls Write. + * @param request WriteRequest message or plain object + * @param callback Node-style callback called with the error, if any, and WriteResponse + */ + public write(request: google.firestore.v1.IWriteRequest, callback: google.firestore.v1.Firestore.WriteCallback): void; + + /** + * Calls Write. + * @param request WriteRequest message or plain object + * @returns Promise + */ + public write(request: google.firestore.v1.IWriteRequest): Promise; + + /** + * Calls Listen. + * @param request ListenRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListenResponse + */ + public listen(request: google.firestore.v1.IListenRequest, callback: google.firestore.v1.Firestore.ListenCallback): void; + + /** + * Calls Listen. + * @param request ListenRequest message or plain object + * @returns Promise + */ + public listen(request: google.firestore.v1.IListenRequest): Promise; + + /** + * Calls ListCollectionIds. + * @param request ListCollectionIdsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListCollectionIdsResponse + */ + public listCollectionIds(request: google.firestore.v1.IListCollectionIdsRequest, callback: google.firestore.v1.Firestore.ListCollectionIdsCallback): void; + + /** + * Calls ListCollectionIds. + * @param request ListCollectionIdsRequest message or plain object + * @returns Promise + */ + public listCollectionIds(request: google.firestore.v1.IListCollectionIdsRequest): Promise; + + /** + * Calls BatchWrite. + * @param request BatchWriteRequest message or plain object + * @param callback Node-style callback called with the error, if any, and BatchWriteResponse + */ + public batchWrite(request: google.firestore.v1.IBatchWriteRequest, callback: google.firestore.v1.Firestore.BatchWriteCallback): void; + + /** + * Calls BatchWrite. + * @param request BatchWriteRequest message or plain object + * @returns Promise + */ + public batchWrite(request: google.firestore.v1.IBatchWriteRequest): Promise; + + /** + * Calls CreateDocument. + * @param request CreateDocumentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Document + */ + public createDocument(request: google.firestore.v1.ICreateDocumentRequest, callback: google.firestore.v1.Firestore.CreateDocumentCallback): void; + + /** + * Calls CreateDocument. + * @param request CreateDocumentRequest message or plain object + * @returns Promise + */ + public createDocument(request: google.firestore.v1.ICreateDocumentRequest): Promise; + } + + namespace Firestore { + + /** + * Callback as used by {@link google.firestore.v1.Firestore#getDocument}. + * @param error Error, if any + * @param [response] Document + */ + type GetDocumentCallback = (error: (Error|null), response?: google.firestore.v1.Document) => void; + + /** + * Callback as used by {@link google.firestore.v1.Firestore#listDocuments}. + * @param error Error, if any + * @param [response] ListDocumentsResponse + */ + type ListDocumentsCallback = (error: (Error|null), response?: google.firestore.v1.ListDocumentsResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1.Firestore#updateDocument}. + * @param error Error, if any + * @param [response] Document + */ + type UpdateDocumentCallback = (error: (Error|null), response?: google.firestore.v1.Document) => void; + + /** + * Callback as used by {@link google.firestore.v1.Firestore#deleteDocument}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteDocumentCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.firestore.v1.Firestore#batchGetDocuments}. + * @param error Error, if any + * @param [response] BatchGetDocumentsResponse + */ + type BatchGetDocumentsCallback = (error: (Error|null), response?: google.firestore.v1.BatchGetDocumentsResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1.Firestore#beginTransaction}. + * @param error Error, if any + * @param [response] BeginTransactionResponse + */ + type BeginTransactionCallback = (error: (Error|null), response?: google.firestore.v1.BeginTransactionResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1.Firestore#commit}. + * @param error Error, if any + * @param [response] CommitResponse + */ + type CommitCallback = (error: (Error|null), response?: google.firestore.v1.CommitResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1.Firestore#rollback}. + * @param error Error, if any + * @param [response] Empty + */ + type RollbackCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.firestore.v1.Firestore#runQuery}. + * @param error Error, if any + * @param [response] RunQueryResponse + */ + type RunQueryCallback = (error: (Error|null), response?: google.firestore.v1.RunQueryResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1.Firestore#partitionQuery}. + * @param error Error, if any + * @param [response] PartitionQueryResponse + */ + type PartitionQueryCallback = (error: (Error|null), response?: google.firestore.v1.PartitionQueryResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1.Firestore#write}. + * @param error Error, if any + * @param [response] WriteResponse + */ + type WriteCallback = (error: (Error|null), response?: google.firestore.v1.WriteResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1.Firestore#listen}. + * @param error Error, if any + * @param [response] ListenResponse + */ + type ListenCallback = (error: (Error|null), response?: google.firestore.v1.ListenResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1.Firestore#listCollectionIds}. + * @param error Error, if any + * @param [response] ListCollectionIdsResponse + */ + type ListCollectionIdsCallback = (error: (Error|null), response?: google.firestore.v1.ListCollectionIdsResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1.Firestore#batchWrite}. + * @param error Error, if any + * @param [response] BatchWriteResponse + */ + type BatchWriteCallback = (error: (Error|null), response?: google.firestore.v1.BatchWriteResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1.Firestore#createDocument}. + * @param error Error, if any + * @param [response] Document + */ + type CreateDocumentCallback = (error: (Error|null), response?: google.firestore.v1.Document) => void; + } + + /** Properties of a GetDocumentRequest. */ + interface IGetDocumentRequest { + + /** GetDocumentRequest name */ + name?: (string|null); + + /** GetDocumentRequest mask */ + mask?: (google.firestore.v1.IDocumentMask|null); + + /** GetDocumentRequest transaction */ + transaction?: (Uint8Array|null); + + /** GetDocumentRequest readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a GetDocumentRequest. */ + class GetDocumentRequest implements IGetDocumentRequest { + + /** + * Constructs a new GetDocumentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IGetDocumentRequest); + + /** GetDocumentRequest name. */ + public name: string; + + /** GetDocumentRequest mask. */ + public mask?: (google.firestore.v1.IDocumentMask|null); + + /** GetDocumentRequest transaction. */ + public transaction: Uint8Array; + + /** GetDocumentRequest readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** GetDocumentRequest consistencySelector. */ + public consistencySelector?: ("transaction"|"readTime"); + + /** + * Creates a GetDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.GetDocumentRequest; + + /** + * Creates a plain object from a GetDocumentRequest message. Also converts values to other types if specified. + * @param message GetDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.GetDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetDocumentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListDocumentsRequest. */ + interface IListDocumentsRequest { + + /** ListDocumentsRequest parent */ + parent?: (string|null); + + /** ListDocumentsRequest collectionId */ + collectionId?: (string|null); + + /** ListDocumentsRequest pageSize */ + pageSize?: (number|null); + + /** ListDocumentsRequest pageToken */ + pageToken?: (string|null); + + /** ListDocumentsRequest orderBy */ + orderBy?: (string|null); + + /** ListDocumentsRequest mask */ + mask?: (google.firestore.v1.IDocumentMask|null); + + /** ListDocumentsRequest transaction */ + transaction?: (Uint8Array|null); + + /** ListDocumentsRequest readTime */ + readTime?: (google.protobuf.ITimestamp|null); + + /** ListDocumentsRequest showMissing */ + showMissing?: (boolean|null); + } + + /** Represents a ListDocumentsRequest. */ + class ListDocumentsRequest implements IListDocumentsRequest { + + /** + * Constructs a new ListDocumentsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IListDocumentsRequest); + + /** ListDocumentsRequest parent. */ + public parent: string; + + /** ListDocumentsRequest collectionId. */ + public collectionId: string; + + /** ListDocumentsRequest pageSize. */ + public pageSize: number; + + /** ListDocumentsRequest pageToken. */ + public pageToken: string; + + /** ListDocumentsRequest orderBy. */ + public orderBy: string; + + /** ListDocumentsRequest mask. */ + public mask?: (google.firestore.v1.IDocumentMask|null); + + /** ListDocumentsRequest transaction. */ + public transaction: Uint8Array; + + /** ListDocumentsRequest readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** ListDocumentsRequest showMissing. */ + public showMissing: boolean; + + /** ListDocumentsRequest consistencySelector. */ + public consistencySelector?: ("transaction"|"readTime"); + + /** + * Creates a ListDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListDocumentsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.ListDocumentsRequest; + + /** + * Creates a plain object from a ListDocumentsRequest message. Also converts values to other types if specified. + * @param message ListDocumentsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.ListDocumentsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListDocumentsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListDocumentsResponse. */ + interface IListDocumentsResponse { + + /** ListDocumentsResponse documents */ + documents?: (google.firestore.v1.IDocument[]|null); + + /** ListDocumentsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListDocumentsResponse. */ + class ListDocumentsResponse implements IListDocumentsResponse { + + /** + * Constructs a new ListDocumentsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IListDocumentsResponse); + + /** ListDocumentsResponse documents. */ + public documents: google.firestore.v1.IDocument[]; + + /** ListDocumentsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a ListDocumentsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListDocumentsResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.ListDocumentsResponse; + + /** + * Creates a plain object from a ListDocumentsResponse message. Also converts values to other types if specified. + * @param message ListDocumentsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.ListDocumentsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListDocumentsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CreateDocumentRequest. */ + interface ICreateDocumentRequest { + + /** CreateDocumentRequest parent */ + parent?: (string|null); + + /** CreateDocumentRequest collectionId */ + collectionId?: (string|null); + + /** CreateDocumentRequest documentId */ + documentId?: (string|null); + + /** CreateDocumentRequest document */ + document?: (google.firestore.v1.IDocument|null); + + /** CreateDocumentRequest mask */ + mask?: (google.firestore.v1.IDocumentMask|null); + } + + /** Represents a CreateDocumentRequest. */ + class CreateDocumentRequest implements ICreateDocumentRequest { + + /** + * Constructs a new CreateDocumentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.ICreateDocumentRequest); + + /** CreateDocumentRequest parent. */ + public parent: string; + + /** CreateDocumentRequest collectionId. */ + public collectionId: string; + + /** CreateDocumentRequest documentId. */ + public documentId: string; + + /** CreateDocumentRequest document. */ + public document?: (google.firestore.v1.IDocument|null); + + /** CreateDocumentRequest mask. */ + public mask?: (google.firestore.v1.IDocumentMask|null); + + /** + * Creates a CreateDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.CreateDocumentRequest; + + /** + * Creates a plain object from a CreateDocumentRequest message. Also converts values to other types if specified. + * @param message CreateDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.CreateDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateDocumentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an UpdateDocumentRequest. */ + interface IUpdateDocumentRequest { + + /** UpdateDocumentRequest document */ + document?: (google.firestore.v1.IDocument|null); + + /** UpdateDocumentRequest updateMask */ + updateMask?: (google.firestore.v1.IDocumentMask|null); + + /** UpdateDocumentRequest mask */ + mask?: (google.firestore.v1.IDocumentMask|null); + + /** UpdateDocumentRequest currentDocument */ + currentDocument?: (google.firestore.v1.IPrecondition|null); + } + + /** Represents an UpdateDocumentRequest. */ + class UpdateDocumentRequest implements IUpdateDocumentRequest { + + /** + * Constructs a new UpdateDocumentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IUpdateDocumentRequest); + + /** UpdateDocumentRequest document. */ + public document?: (google.firestore.v1.IDocument|null); + + /** UpdateDocumentRequest updateMask. */ + public updateMask?: (google.firestore.v1.IDocumentMask|null); + + /** UpdateDocumentRequest mask. */ + public mask?: (google.firestore.v1.IDocumentMask|null); + + /** UpdateDocumentRequest currentDocument. */ + public currentDocument?: (google.firestore.v1.IPrecondition|null); + + /** + * Creates an UpdateDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.UpdateDocumentRequest; + + /** + * Creates a plain object from an UpdateDocumentRequest message. Also converts values to other types if specified. + * @param message UpdateDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.UpdateDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateDocumentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DeleteDocumentRequest. */ + interface IDeleteDocumentRequest { + + /** DeleteDocumentRequest name */ + name?: (string|null); + + /** DeleteDocumentRequest currentDocument */ + currentDocument?: (google.firestore.v1.IPrecondition|null); + } + + /** Represents a DeleteDocumentRequest. */ + class DeleteDocumentRequest implements IDeleteDocumentRequest { + + /** + * Constructs a new DeleteDocumentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IDeleteDocumentRequest); + + /** DeleteDocumentRequest name. */ + public name: string; + + /** DeleteDocumentRequest currentDocument. */ + public currentDocument?: (google.firestore.v1.IPrecondition|null); + + /** + * Creates a DeleteDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.DeleteDocumentRequest; + + /** + * Creates a plain object from a DeleteDocumentRequest message. Also converts values to other types if specified. + * @param message DeleteDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.DeleteDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteDocumentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BatchGetDocumentsRequest. */ + interface IBatchGetDocumentsRequest { + + /** BatchGetDocumentsRequest database */ + database?: (string|null); + + /** BatchGetDocumentsRequest documents */ + documents?: (string[]|null); + + /** BatchGetDocumentsRequest mask */ + mask?: (google.firestore.v1.IDocumentMask|null); + + /** BatchGetDocumentsRequest transaction */ + transaction?: (Uint8Array|null); + + /** BatchGetDocumentsRequest newTransaction */ + newTransaction?: (google.firestore.v1.ITransactionOptions|null); + + /** BatchGetDocumentsRequest readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a BatchGetDocumentsRequest. */ + class BatchGetDocumentsRequest implements IBatchGetDocumentsRequest { + + /** + * Constructs a new BatchGetDocumentsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IBatchGetDocumentsRequest); + + /** BatchGetDocumentsRequest database. */ + public database: string; + + /** BatchGetDocumentsRequest documents. */ + public documents: string[]; + + /** BatchGetDocumentsRequest mask. */ + public mask?: (google.firestore.v1.IDocumentMask|null); + + /** BatchGetDocumentsRequest transaction. */ + public transaction: Uint8Array; + + /** BatchGetDocumentsRequest newTransaction. */ + public newTransaction?: (google.firestore.v1.ITransactionOptions|null); + + /** BatchGetDocumentsRequest readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** BatchGetDocumentsRequest consistencySelector. */ + public consistencySelector?: ("transaction"|"newTransaction"|"readTime"); + + /** + * Creates a BatchGetDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchGetDocumentsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.BatchGetDocumentsRequest; + + /** + * Creates a plain object from a BatchGetDocumentsRequest message. Also converts values to other types if specified. + * @param message BatchGetDocumentsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.BatchGetDocumentsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchGetDocumentsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BatchGetDocumentsResponse. */ + interface IBatchGetDocumentsResponse { + + /** BatchGetDocumentsResponse found */ + found?: (google.firestore.v1.IDocument|null); + + /** BatchGetDocumentsResponse missing */ + missing?: (string|null); + + /** BatchGetDocumentsResponse transaction */ + transaction?: (Uint8Array|null); + + /** BatchGetDocumentsResponse readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a BatchGetDocumentsResponse. */ + class BatchGetDocumentsResponse implements IBatchGetDocumentsResponse { + + /** + * Constructs a new BatchGetDocumentsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IBatchGetDocumentsResponse); + + /** BatchGetDocumentsResponse found. */ + public found?: (google.firestore.v1.IDocument|null); + + /** BatchGetDocumentsResponse missing. */ + public missing: string; + + /** BatchGetDocumentsResponse transaction. */ + public transaction: Uint8Array; + + /** BatchGetDocumentsResponse readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** BatchGetDocumentsResponse result. */ + public result?: ("found"|"missing"); + + /** + * Creates a BatchGetDocumentsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchGetDocumentsResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.BatchGetDocumentsResponse; + + /** + * Creates a plain object from a BatchGetDocumentsResponse message. Also converts values to other types if specified. + * @param message BatchGetDocumentsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.BatchGetDocumentsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchGetDocumentsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BeginTransactionRequest. */ + interface IBeginTransactionRequest { + + /** BeginTransactionRequest database */ + database?: (string|null); + + /** BeginTransactionRequest options */ + options?: (google.firestore.v1.ITransactionOptions|null); + } + + /** Represents a BeginTransactionRequest. */ + class BeginTransactionRequest implements IBeginTransactionRequest { + + /** + * Constructs a new BeginTransactionRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IBeginTransactionRequest); + + /** BeginTransactionRequest database. */ + public database: string; + + /** BeginTransactionRequest options. */ + public options?: (google.firestore.v1.ITransactionOptions|null); + + /** + * Creates a BeginTransactionRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BeginTransactionRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.BeginTransactionRequest; + + /** + * Creates a plain object from a BeginTransactionRequest message. Also converts values to other types if specified. + * @param message BeginTransactionRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.BeginTransactionRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BeginTransactionRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BeginTransactionResponse. */ + interface IBeginTransactionResponse { + + /** BeginTransactionResponse transaction */ + transaction?: (Uint8Array|null); + } + + /** Represents a BeginTransactionResponse. */ + class BeginTransactionResponse implements IBeginTransactionResponse { + + /** + * Constructs a new BeginTransactionResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IBeginTransactionResponse); + + /** BeginTransactionResponse transaction. */ + public transaction: Uint8Array; + + /** + * Creates a BeginTransactionResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BeginTransactionResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.BeginTransactionResponse; + + /** + * Creates a plain object from a BeginTransactionResponse message. Also converts values to other types if specified. + * @param message BeginTransactionResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.BeginTransactionResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BeginTransactionResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CommitRequest. */ + interface ICommitRequest { + + /** CommitRequest database */ + database?: (string|null); + + /** CommitRequest writes */ + writes?: (google.firestore.v1.IWrite[]|null); + + /** CommitRequest transaction */ + transaction?: (Uint8Array|null); + } + + /** Represents a CommitRequest. */ + class CommitRequest implements ICommitRequest { + + /** + * Constructs a new CommitRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.ICommitRequest); + + /** CommitRequest database. */ + public database: string; + + /** CommitRequest writes. */ + public writes: google.firestore.v1.IWrite[]; + + /** CommitRequest transaction. */ + public transaction: Uint8Array; + + /** + * Creates a CommitRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CommitRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.CommitRequest; + + /** + * Creates a plain object from a CommitRequest message. Also converts values to other types if specified. + * @param message CommitRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.CommitRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CommitRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CommitResponse. */ + interface ICommitResponse { + + /** CommitResponse writeResults */ + writeResults?: (google.firestore.v1.IWriteResult[]|null); + + /** CommitResponse commitTime */ + commitTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a CommitResponse. */ + class CommitResponse implements ICommitResponse { + + /** + * Constructs a new CommitResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.ICommitResponse); + + /** CommitResponse writeResults. */ + public writeResults: google.firestore.v1.IWriteResult[]; + + /** CommitResponse commitTime. */ + public commitTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a CommitResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CommitResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.CommitResponse; + + /** + * Creates a plain object from a CommitResponse message. Also converts values to other types if specified. + * @param message CommitResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.CommitResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CommitResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a RollbackRequest. */ + interface IRollbackRequest { + + /** RollbackRequest database */ + database?: (string|null); + + /** RollbackRequest transaction */ + transaction?: (Uint8Array|null); + } + + /** Represents a RollbackRequest. */ + class RollbackRequest implements IRollbackRequest { + + /** + * Constructs a new RollbackRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IRollbackRequest); + + /** RollbackRequest database. */ + public database: string; + + /** RollbackRequest transaction. */ + public transaction: Uint8Array; + + /** + * Creates a RollbackRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RollbackRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.RollbackRequest; + + /** + * Creates a plain object from a RollbackRequest message. Also converts values to other types if specified. + * @param message RollbackRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.RollbackRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RollbackRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a RunQueryRequest. */ + interface IRunQueryRequest { + + /** RunQueryRequest parent */ + parent?: (string|null); + + /** RunQueryRequest structuredQuery */ + structuredQuery?: (google.firestore.v1.IStructuredQuery|null); + + /** RunQueryRequest transaction */ + transaction?: (Uint8Array|null); + + /** RunQueryRequest newTransaction */ + newTransaction?: (google.firestore.v1.ITransactionOptions|null); + + /** RunQueryRequest readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a RunQueryRequest. */ + class RunQueryRequest implements IRunQueryRequest { + + /** + * Constructs a new RunQueryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IRunQueryRequest); + + /** RunQueryRequest parent. */ + public parent: string; + + /** RunQueryRequest structuredQuery. */ + public structuredQuery?: (google.firestore.v1.IStructuredQuery|null); + + /** RunQueryRequest transaction. */ + public transaction: Uint8Array; + + /** RunQueryRequest newTransaction. */ + public newTransaction?: (google.firestore.v1.ITransactionOptions|null); + + /** RunQueryRequest readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** RunQueryRequest queryType. */ + public queryType?: "structuredQuery"; + + /** RunQueryRequest consistencySelector. */ + public consistencySelector?: ("transaction"|"newTransaction"|"readTime"); + + /** + * Creates a RunQueryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RunQueryRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.RunQueryRequest; + + /** + * Creates a plain object from a RunQueryRequest message. Also converts values to other types if specified. + * @param message RunQueryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.RunQueryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RunQueryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a RunQueryResponse. */ + interface IRunQueryResponse { + + /** RunQueryResponse transaction */ + transaction?: (Uint8Array|null); + + /** RunQueryResponse document */ + document?: (google.firestore.v1.IDocument|null); + + /** RunQueryResponse readTime */ + readTime?: (google.protobuf.ITimestamp|null); + + /** RunQueryResponse skippedResults */ + skippedResults?: (number|null); + } + + /** Represents a RunQueryResponse. */ + class RunQueryResponse implements IRunQueryResponse { + + /** + * Constructs a new RunQueryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IRunQueryResponse); + + /** RunQueryResponse transaction. */ + public transaction: Uint8Array; + + /** RunQueryResponse document. */ + public document?: (google.firestore.v1.IDocument|null); + + /** RunQueryResponse readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** RunQueryResponse skippedResults. */ + public skippedResults: number; + + /** + * Creates a RunQueryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RunQueryResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.RunQueryResponse; + + /** + * Creates a plain object from a RunQueryResponse message. Also converts values to other types if specified. + * @param message RunQueryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.RunQueryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RunQueryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a PartitionQueryRequest. */ + interface IPartitionQueryRequest { + + /** PartitionQueryRequest parent */ + parent?: (string|null); + + /** PartitionQueryRequest structuredQuery */ + structuredQuery?: (google.firestore.v1.IStructuredQuery|null); + + /** PartitionQueryRequest partitionCount */ + partitionCount?: (number|string|null); + + /** PartitionQueryRequest pageToken */ + pageToken?: (string|null); + + /** PartitionQueryRequest pageSize */ + pageSize?: (number|null); + } + + /** Represents a PartitionQueryRequest. */ + class PartitionQueryRequest implements IPartitionQueryRequest { + + /** + * Constructs a new PartitionQueryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IPartitionQueryRequest); + + /** PartitionQueryRequest parent. */ + public parent: string; + + /** PartitionQueryRequest structuredQuery. */ + public structuredQuery?: (google.firestore.v1.IStructuredQuery|null); + + /** PartitionQueryRequest partitionCount. */ + public partitionCount: (number|string); + + /** PartitionQueryRequest pageToken. */ + public pageToken: string; + + /** PartitionQueryRequest pageSize. */ + public pageSize: number; + + /** PartitionQueryRequest queryType. */ + public queryType?: "structuredQuery"; + + /** + * Creates a PartitionQueryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PartitionQueryRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.PartitionQueryRequest; + + /** + * Creates a plain object from a PartitionQueryRequest message. Also converts values to other types if specified. + * @param message PartitionQueryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.PartitionQueryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PartitionQueryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a PartitionQueryResponse. */ + interface IPartitionQueryResponse { + + /** PartitionQueryResponse partitions */ + partitions?: (google.firestore.v1.ICursor[]|null); + + /** PartitionQueryResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a PartitionQueryResponse. */ + class PartitionQueryResponse implements IPartitionQueryResponse { + + /** + * Constructs a new PartitionQueryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IPartitionQueryResponse); + + /** PartitionQueryResponse partitions. */ + public partitions: google.firestore.v1.ICursor[]; + + /** PartitionQueryResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a PartitionQueryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PartitionQueryResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.PartitionQueryResponse; + + /** + * Creates a plain object from a PartitionQueryResponse message. Also converts values to other types if specified. + * @param message PartitionQueryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.PartitionQueryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PartitionQueryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a WriteRequest. */ + interface IWriteRequest { + + /** WriteRequest database */ + database?: (string|null); + + /** WriteRequest streamId */ + streamId?: (string|null); + + /** WriteRequest writes */ + writes?: (google.firestore.v1.IWrite[]|null); + + /** WriteRequest streamToken */ + streamToken?: (Uint8Array|null); + + /** WriteRequest labels */ + labels?: ({ [k: string]: string }|null); + } + + /** Represents a WriteRequest. */ + class WriteRequest implements IWriteRequest { + + /** + * Constructs a new WriteRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IWriteRequest); + + /** WriteRequest database. */ + public database: string; + + /** WriteRequest streamId. */ + public streamId: string; + + /** WriteRequest writes. */ + public writes: google.firestore.v1.IWrite[]; + + /** WriteRequest streamToken. */ + public streamToken: Uint8Array; + + /** WriteRequest labels. */ + public labels: { [k: string]: string }; + + /** + * Creates a WriteRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WriteRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.WriteRequest; + + /** + * Creates a plain object from a WriteRequest message. Also converts values to other types if specified. + * @param message WriteRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.WriteRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WriteRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a WriteResponse. */ + interface IWriteResponse { + + /** WriteResponse streamId */ + streamId?: (string|null); + + /** WriteResponse streamToken */ + streamToken?: (Uint8Array|null); + + /** WriteResponse writeResults */ + writeResults?: (google.firestore.v1.IWriteResult[]|null); + + /** WriteResponse commitTime */ + commitTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a WriteResponse. */ + class WriteResponse implements IWriteResponse { + + /** + * Constructs a new WriteResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IWriteResponse); + + /** WriteResponse streamId. */ + public streamId: string; + + /** WriteResponse streamToken. */ + public streamToken: Uint8Array; + + /** WriteResponse writeResults. */ + public writeResults: google.firestore.v1.IWriteResult[]; + + /** WriteResponse commitTime. */ + public commitTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a WriteResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WriteResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.WriteResponse; + + /** + * Creates a plain object from a WriteResponse message. Also converts values to other types if specified. + * @param message WriteResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.WriteResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WriteResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListenRequest. */ + interface IListenRequest { + + /** ListenRequest database */ + database?: (string|null); + + /** ListenRequest addTarget */ + addTarget?: (google.firestore.v1.ITarget|null); + + /** ListenRequest removeTarget */ + removeTarget?: (number|null); + + /** ListenRequest labels */ + labels?: ({ [k: string]: string }|null); + } + + /** Represents a ListenRequest. */ + class ListenRequest implements IListenRequest { + + /** + * Constructs a new ListenRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IListenRequest); + + /** ListenRequest database. */ + public database: string; + + /** ListenRequest addTarget. */ + public addTarget?: (google.firestore.v1.ITarget|null); + + /** ListenRequest removeTarget. */ + public removeTarget: number; + + /** ListenRequest labels. */ + public labels: { [k: string]: string }; + + /** ListenRequest targetChange. */ + public targetChange?: ("addTarget"|"removeTarget"); + + /** + * Creates a ListenRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListenRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.ListenRequest; + + /** + * Creates a plain object from a ListenRequest message. Also converts values to other types if specified. + * @param message ListenRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.ListenRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListenRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListenResponse. */ + interface IListenResponse { + + /** ListenResponse targetChange */ + targetChange?: (google.firestore.v1.ITargetChange|null); + + /** ListenResponse documentChange */ + documentChange?: (google.firestore.v1.IDocumentChange|null); + + /** ListenResponse documentDelete */ + documentDelete?: (google.firestore.v1.IDocumentDelete|null); + + /** ListenResponse documentRemove */ + documentRemove?: (google.firestore.v1.IDocumentRemove|null); + + /** ListenResponse filter */ + filter?: (google.firestore.v1.IExistenceFilter|null); + } + + /** Represents a ListenResponse. */ + class ListenResponse implements IListenResponse { + + /** + * Constructs a new ListenResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IListenResponse); + + /** ListenResponse targetChange. */ + public targetChange?: (google.firestore.v1.ITargetChange|null); + + /** ListenResponse documentChange. */ + public documentChange?: (google.firestore.v1.IDocumentChange|null); + + /** ListenResponse documentDelete. */ + public documentDelete?: (google.firestore.v1.IDocumentDelete|null); + + /** ListenResponse documentRemove. */ + public documentRemove?: (google.firestore.v1.IDocumentRemove|null); + + /** ListenResponse filter. */ + public filter?: (google.firestore.v1.IExistenceFilter|null); + + /** ListenResponse responseType. */ + public responseType?: ("targetChange"|"documentChange"|"documentDelete"|"documentRemove"|"filter"); + + /** + * Creates a ListenResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListenResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.ListenResponse; + + /** + * Creates a plain object from a ListenResponse message. Also converts values to other types if specified. + * @param message ListenResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.ListenResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListenResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Target. */ + interface ITarget { + + /** Target query */ + query?: (google.firestore.v1.Target.IQueryTarget|null); + + /** Target documents */ + documents?: (google.firestore.v1.Target.IDocumentsTarget|null); + + /** Target resumeToken */ + resumeToken?: (Uint8Array|null); + + /** Target readTime */ + readTime?: (google.protobuf.ITimestamp|null); + + /** Target targetId */ + targetId?: (number|null); + + /** Target once */ + once?: (boolean|null); + } + + /** Represents a Target. */ + class Target implements ITarget { + + /** + * Constructs a new Target. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.ITarget); + + /** Target query. */ + public query?: (google.firestore.v1.Target.IQueryTarget|null); + + /** Target documents. */ + public documents?: (google.firestore.v1.Target.IDocumentsTarget|null); + + /** Target resumeToken. */ + public resumeToken: Uint8Array; + + /** Target readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** Target targetId. */ + public targetId: number; + + /** Target once. */ + public once: boolean; + + /** Target targetType. */ + public targetType?: ("query"|"documents"); + + /** Target resumeType. */ + public resumeType?: ("resumeToken"|"readTime"); + + /** + * Creates a Target message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Target + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.Target; + + /** + * Creates a plain object from a Target message. Also converts values to other types if specified. + * @param message Target + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.Target, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Target to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace Target { + + /** Properties of a DocumentsTarget. */ + interface IDocumentsTarget { + + /** DocumentsTarget documents */ + documents?: (string[]|null); + } + + /** Represents a DocumentsTarget. */ + class DocumentsTarget implements IDocumentsTarget { + + /** + * Constructs a new DocumentsTarget. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.Target.IDocumentsTarget); + + /** DocumentsTarget documents. */ + public documents: string[]; + + /** + * Creates a DocumentsTarget message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentsTarget + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.Target.DocumentsTarget; + + /** + * Creates a plain object from a DocumentsTarget message. Also converts values to other types if specified. + * @param message DocumentsTarget + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.Target.DocumentsTarget, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentsTarget to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a QueryTarget. */ + interface IQueryTarget { + + /** QueryTarget parent */ + parent?: (string|null); + + /** QueryTarget structuredQuery */ + structuredQuery?: (google.firestore.v1.IStructuredQuery|null); + } + + /** Represents a QueryTarget. */ + class QueryTarget implements IQueryTarget { + + /** + * Constructs a new QueryTarget. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.Target.IQueryTarget); + + /** QueryTarget parent. */ + public parent: string; + + /** QueryTarget structuredQuery. */ + public structuredQuery?: (google.firestore.v1.IStructuredQuery|null); + + /** QueryTarget queryType. */ + public queryType?: "structuredQuery"; + + /** + * Creates a QueryTarget message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns QueryTarget + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.Target.QueryTarget; + + /** + * Creates a plain object from a QueryTarget message. Also converts values to other types if specified. + * @param message QueryTarget + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.Target.QueryTarget, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this QueryTarget to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a TargetChange. */ + interface ITargetChange { + + /** TargetChange targetChangeType */ + targetChangeType?: (google.firestore.v1.TargetChange.TargetChangeType|null); + + /** TargetChange targetIds */ + targetIds?: (number[]|null); + + /** TargetChange cause */ + cause?: (google.rpc.IStatus|null); + + /** TargetChange resumeToken */ + resumeToken?: (Uint8Array|null); + + /** TargetChange readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a TargetChange. */ + class TargetChange implements ITargetChange { + + /** + * Constructs a new TargetChange. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.ITargetChange); + + /** TargetChange targetChangeType. */ + public targetChangeType: google.firestore.v1.TargetChange.TargetChangeType; + + /** TargetChange targetIds. */ + public targetIds: number[]; + + /** TargetChange cause. */ + public cause?: (google.rpc.IStatus|null); + + /** TargetChange resumeToken. */ + public resumeToken: Uint8Array; + + /** TargetChange readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a TargetChange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TargetChange + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.TargetChange; + + /** + * Creates a plain object from a TargetChange message. Also converts values to other types if specified. + * @param message TargetChange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.TargetChange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TargetChange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace TargetChange { + + /** TargetChangeType enum. */ + type TargetChangeType = + "NO_CHANGE"| "ADD"| "REMOVE"| "CURRENT"| "RESET"; + } + + /** Properties of a ListCollectionIdsRequest. */ + interface IListCollectionIdsRequest { + + /** ListCollectionIdsRequest parent */ + parent?: (string|null); + + /** ListCollectionIdsRequest pageSize */ + pageSize?: (number|null); + + /** ListCollectionIdsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListCollectionIdsRequest. */ + class ListCollectionIdsRequest implements IListCollectionIdsRequest { + + /** + * Constructs a new ListCollectionIdsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IListCollectionIdsRequest); + + /** ListCollectionIdsRequest parent. */ + public parent: string; + + /** ListCollectionIdsRequest pageSize. */ + public pageSize: number; + + /** ListCollectionIdsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a ListCollectionIdsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCollectionIdsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.ListCollectionIdsRequest; + + /** + * Creates a plain object from a ListCollectionIdsRequest message. Also converts values to other types if specified. + * @param message ListCollectionIdsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.ListCollectionIdsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCollectionIdsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListCollectionIdsResponse. */ + interface IListCollectionIdsResponse { + + /** ListCollectionIdsResponse collectionIds */ + collectionIds?: (string[]|null); + + /** ListCollectionIdsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListCollectionIdsResponse. */ + class ListCollectionIdsResponse implements IListCollectionIdsResponse { + + /** + * Constructs a new ListCollectionIdsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IListCollectionIdsResponse); + + /** ListCollectionIdsResponse collectionIds. */ + public collectionIds: string[]; + + /** ListCollectionIdsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a ListCollectionIdsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCollectionIdsResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.ListCollectionIdsResponse; + + /** + * Creates a plain object from a ListCollectionIdsResponse message. Also converts values to other types if specified. + * @param message ListCollectionIdsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.ListCollectionIdsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCollectionIdsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BatchWriteRequest. */ + interface IBatchWriteRequest { + + /** BatchWriteRequest database */ + database?: (string|null); + + /** BatchWriteRequest writes */ + writes?: (google.firestore.v1.IWrite[]|null); + + /** BatchWriteRequest labels */ + labels?: ({ [k: string]: string }|null); + } + + /** Represents a BatchWriteRequest. */ + class BatchWriteRequest implements IBatchWriteRequest { + + /** + * Constructs a new BatchWriteRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IBatchWriteRequest); + + /** BatchWriteRequest database. */ + public database: string; + + /** BatchWriteRequest writes. */ + public writes: google.firestore.v1.IWrite[]; + + /** BatchWriteRequest labels. */ + public labels: { [k: string]: string }; + + /** + * Creates a BatchWriteRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchWriteRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.BatchWriteRequest; + + /** + * Creates a plain object from a BatchWriteRequest message. Also converts values to other types if specified. + * @param message BatchWriteRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.BatchWriteRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchWriteRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BatchWriteResponse. */ + interface IBatchWriteResponse { + + /** BatchWriteResponse writeResults */ + writeResults?: (google.firestore.v1.IWriteResult[]|null); + + /** BatchWriteResponse status */ + status?: (google.rpc.IStatus[]|null); + } + + /** Represents a BatchWriteResponse. */ + class BatchWriteResponse implements IBatchWriteResponse { + + /** + * Constructs a new BatchWriteResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IBatchWriteResponse); + + /** BatchWriteResponse writeResults. */ + public writeResults: google.firestore.v1.IWriteResult[]; + + /** BatchWriteResponse status. */ + public status: google.rpc.IStatus[]; + + /** + * Creates a BatchWriteResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchWriteResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.BatchWriteResponse; + + /** + * Creates a plain object from a BatchWriteResponse message. Also converts values to other types if specified. + * @param message BatchWriteResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.BatchWriteResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchWriteResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a StructuredQuery. */ + interface IStructuredQuery { + + /** StructuredQuery select */ + select?: (google.firestore.v1.StructuredQuery.IProjection|null); + + /** StructuredQuery from */ + from?: (google.firestore.v1.StructuredQuery.ICollectionSelector[]|null); + + /** StructuredQuery where */ + where?: (google.firestore.v1.StructuredQuery.IFilter|null); + + /** StructuredQuery orderBy */ + orderBy?: (google.firestore.v1.StructuredQuery.IOrder[]|null); + + /** StructuredQuery startAt */ + startAt?: (google.firestore.v1.ICursor|null); + + /** StructuredQuery endAt */ + endAt?: (google.firestore.v1.ICursor|null); + + /** StructuredQuery offset */ + offset?: (number|null); + + /** StructuredQuery limit */ + limit?: (google.protobuf.IInt32Value|null); + } + + /** Represents a StructuredQuery. */ + class StructuredQuery implements IStructuredQuery { + + /** + * Constructs a new StructuredQuery. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IStructuredQuery); + + /** StructuredQuery select. */ + public select?: (google.firestore.v1.StructuredQuery.IProjection|null); + + /** StructuredQuery from. */ + public from: google.firestore.v1.StructuredQuery.ICollectionSelector[]; + + /** StructuredQuery where. */ + public where?: (google.firestore.v1.StructuredQuery.IFilter|null); + + /** StructuredQuery orderBy. */ + public orderBy: google.firestore.v1.StructuredQuery.IOrder[]; + + /** StructuredQuery startAt. */ + public startAt?: (google.firestore.v1.ICursor|null); + + /** StructuredQuery endAt. */ + public endAt?: (google.firestore.v1.ICursor|null); + + /** StructuredQuery offset. */ + public offset: number; + + /** StructuredQuery limit. */ + public limit?: (google.protobuf.IInt32Value|null); + + /** + * Creates a StructuredQuery message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StructuredQuery + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery; + + /** + * Creates a plain object from a StructuredQuery message. Also converts values to other types if specified. + * @param message StructuredQuery + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StructuredQuery to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace StructuredQuery { + + /** Properties of a CollectionSelector. */ + interface ICollectionSelector { + + /** CollectionSelector collectionId */ + collectionId?: (string|null); + + /** CollectionSelector allDescendants */ + allDescendants?: (boolean|null); + } + + /** Represents a CollectionSelector. */ + class CollectionSelector implements ICollectionSelector { + + /** + * Constructs a new CollectionSelector. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.StructuredQuery.ICollectionSelector); + + /** CollectionSelector collectionId. */ + public collectionId: string; + + /** CollectionSelector allDescendants. */ + public allDescendants: boolean; + + /** + * Creates a CollectionSelector message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CollectionSelector + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.CollectionSelector; + + /** + * Creates a plain object from a CollectionSelector message. Also converts values to other types if specified. + * @param message CollectionSelector + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.CollectionSelector, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CollectionSelector to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Filter. */ + interface IFilter { + + /** Filter compositeFilter */ + compositeFilter?: (google.firestore.v1.StructuredQuery.ICompositeFilter|null); + + /** Filter fieldFilter */ + fieldFilter?: (google.firestore.v1.StructuredQuery.IFieldFilter|null); + + /** Filter unaryFilter */ + unaryFilter?: (google.firestore.v1.StructuredQuery.IUnaryFilter|null); + } + + /** Represents a Filter. */ + class Filter implements IFilter { + + /** + * Constructs a new Filter. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.StructuredQuery.IFilter); + + /** Filter compositeFilter. */ + public compositeFilter?: (google.firestore.v1.StructuredQuery.ICompositeFilter|null); + + /** Filter fieldFilter. */ + public fieldFilter?: (google.firestore.v1.StructuredQuery.IFieldFilter|null); + + /** Filter unaryFilter. */ + public unaryFilter?: (google.firestore.v1.StructuredQuery.IUnaryFilter|null); + + /** Filter filterType. */ + public filterType?: ("compositeFilter"|"fieldFilter"|"unaryFilter"); + + /** + * Creates a Filter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Filter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.Filter; + + /** + * Creates a plain object from a Filter message. Also converts values to other types if specified. + * @param message Filter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.Filter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Filter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CompositeFilter. */ + interface ICompositeFilter { + + /** CompositeFilter op */ + op?: (google.firestore.v1.StructuredQuery.CompositeFilter.Operator|null); + + /** CompositeFilter filters */ + filters?: (google.firestore.v1.StructuredQuery.IFilter[]|null); + } + + /** Represents a CompositeFilter. */ + class CompositeFilter implements ICompositeFilter { + + /** + * Constructs a new CompositeFilter. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.StructuredQuery.ICompositeFilter); + + /** CompositeFilter op. */ + public op: google.firestore.v1.StructuredQuery.CompositeFilter.Operator; + + /** CompositeFilter filters. */ + public filters: google.firestore.v1.StructuredQuery.IFilter[]; + + /** + * Creates a CompositeFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompositeFilter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.CompositeFilter; + + /** + * Creates a plain object from a CompositeFilter message. Also converts values to other types if specified. + * @param message CompositeFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.CompositeFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompositeFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace CompositeFilter { + + /** Operator enum. */ + type Operator = + "OPERATOR_UNSPECIFIED"| "AND"; + } + + /** Properties of a FieldFilter. */ + interface IFieldFilter { + + /** FieldFilter field */ + field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); + + /** FieldFilter op */ + op?: (google.firestore.v1.StructuredQuery.FieldFilter.Operator|null); + + /** FieldFilter value */ + value?: (google.firestore.v1.IValue|null); + } + + /** Represents a FieldFilter. */ + class FieldFilter implements IFieldFilter { + + /** + * Constructs a new FieldFilter. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.StructuredQuery.IFieldFilter); + + /** FieldFilter field. */ + public field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); + + /** FieldFilter op. */ + public op: google.firestore.v1.StructuredQuery.FieldFilter.Operator; + + /** FieldFilter value. */ + public value?: (google.firestore.v1.IValue|null); + + /** + * Creates a FieldFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldFilter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.FieldFilter; + + /** + * Creates a plain object from a FieldFilter message. Also converts values to other types if specified. + * @param message FieldFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.FieldFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace FieldFilter { + + /** Operator enum. */ + type Operator = + "OPERATOR_UNSPECIFIED"| "LESS_THAN"| "LESS_THAN_OR_EQUAL"| "GREATER_THAN"| "GREATER_THAN_OR_EQUAL"| "EQUAL"| "NOT_EQUAL"| "ARRAY_CONTAINS"| "IN"| "ARRAY_CONTAINS_ANY"| "NOT_IN"; + } + + /** Properties of an UnaryFilter. */ + interface IUnaryFilter { + + /** UnaryFilter op */ + op?: (google.firestore.v1.StructuredQuery.UnaryFilter.Operator|null); + + /** UnaryFilter field */ + field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); + } + + /** Represents an UnaryFilter. */ + class UnaryFilter implements IUnaryFilter { + + /** + * Constructs a new UnaryFilter. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.StructuredQuery.IUnaryFilter); + + /** UnaryFilter op. */ + public op: google.firestore.v1.StructuredQuery.UnaryFilter.Operator; + + /** UnaryFilter field. */ + public field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); + + /** UnaryFilter operandType. */ + public operandType?: "field"; + + /** + * Creates an UnaryFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UnaryFilter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.UnaryFilter; + + /** + * Creates a plain object from an UnaryFilter message. Also converts values to other types if specified. + * @param message UnaryFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.UnaryFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UnaryFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace UnaryFilter { + + /** Operator enum. */ + type Operator = + "OPERATOR_UNSPECIFIED"| "IS_NAN"| "IS_NULL"| "IS_NOT_NAN"| "IS_NOT_NULL"; + } + + /** Properties of an Order. */ + interface IOrder { + + /** Order field */ + field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); + + /** Order direction */ + direction?: (google.firestore.v1.StructuredQuery.Direction|null); + } + + /** Represents an Order. */ + class Order implements IOrder { + + /** + * Constructs a new Order. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.StructuredQuery.IOrder); + + /** Order field. */ + public field?: (google.firestore.v1.StructuredQuery.IFieldReference|null); + + /** Order direction. */ + public direction: google.firestore.v1.StructuredQuery.Direction; + + /** + * Creates an Order message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Order + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.Order; + + /** + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @param message Order + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.Order, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Order to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FieldReference. */ + interface IFieldReference { + + /** FieldReference fieldPath */ + fieldPath?: (string|null); + } + + /** Represents a FieldReference. */ + class FieldReference implements IFieldReference { + + /** + * Constructs a new FieldReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.StructuredQuery.IFieldReference); + + /** FieldReference fieldPath. */ + public fieldPath: string; + + /** + * Creates a FieldReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldReference + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.FieldReference; + + /** + * Creates a plain object from a FieldReference message. Also converts values to other types if specified. + * @param message FieldReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.FieldReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Projection. */ + interface IProjection { + + /** Projection fields */ + fields?: (google.firestore.v1.StructuredQuery.IFieldReference[]|null); + } + + /** Represents a Projection. */ + class Projection implements IProjection { + + /** + * Constructs a new Projection. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.StructuredQuery.IProjection); + + /** Projection fields. */ + public fields: google.firestore.v1.StructuredQuery.IFieldReference[]; + + /** + * Creates a Projection message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Projection + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.StructuredQuery.Projection; + + /** + * Creates a plain object from a Projection message. Also converts values to other types if specified. + * @param message Projection + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.StructuredQuery.Projection, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Projection to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Direction enum. */ + type Direction = + "DIRECTION_UNSPECIFIED"| "ASCENDING"| "DESCENDING"; + } + + /** Properties of a Cursor. */ + interface ICursor { + + /** Cursor values */ + values?: (google.firestore.v1.IValue[]|null); + + /** Cursor before */ + before?: (boolean|null); + } + + /** Represents a Cursor. */ + class Cursor implements ICursor { + + /** + * Constructs a new Cursor. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.ICursor); + + /** Cursor values. */ + public values: google.firestore.v1.IValue[]; + + /** Cursor before. */ + public before: boolean; + + /** + * Creates a Cursor message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Cursor + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.Cursor; + + /** + * Creates a plain object from a Cursor message. Also converts values to other types if specified. + * @param message Cursor + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.Cursor, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Cursor to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Write. */ + interface IWrite { + + /** Write update */ + update?: (google.firestore.v1.IDocument|null); + + /** Write delete */ + "delete"?: (string|null); + + /** Write transform */ + transform?: (google.firestore.v1.IDocumentTransform|null); + + /** Write updateMask */ + updateMask?: (google.firestore.v1.IDocumentMask|null); + + /** Write updateTransforms */ + updateTransforms?: (google.firestore.v1.DocumentTransform.IFieldTransform[]|null); + + /** Write currentDocument */ + currentDocument?: (google.firestore.v1.IPrecondition|null); + } + + /** Represents a Write. */ + class Write implements IWrite { + + /** + * Constructs a new Write. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IWrite); + + /** Write update. */ + public update?: (google.firestore.v1.IDocument|null); + + /** Write delete. */ + public delete: string; + + /** Write transform. */ + public transform?: (google.firestore.v1.IDocumentTransform|null); + + /** Write updateMask. */ + public updateMask?: (google.firestore.v1.IDocumentMask|null); + + /** Write updateTransforms. */ + public updateTransforms: google.firestore.v1.DocumentTransform.IFieldTransform[]; + + /** Write currentDocument. */ + public currentDocument?: (google.firestore.v1.IPrecondition|null); + + /** Write operation. */ + public operation?: ("update"|"delete"|"transform"); + + /** + * Creates a Write message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Write + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.Write; + + /** + * Creates a plain object from a Write message. Also converts values to other types if specified. + * @param message Write + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.Write, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Write to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DocumentTransform. */ + interface IDocumentTransform { + + /** DocumentTransform document */ + document?: (string|null); + + /** DocumentTransform fieldTransforms */ + fieldTransforms?: (google.firestore.v1.DocumentTransform.IFieldTransform[]|null); + } + + /** Represents a DocumentTransform. */ + class DocumentTransform implements IDocumentTransform { + + /** + * Constructs a new DocumentTransform. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IDocumentTransform); + + /** DocumentTransform document. */ + public document: string; + + /** DocumentTransform fieldTransforms. */ + public fieldTransforms: google.firestore.v1.DocumentTransform.IFieldTransform[]; + + /** + * Creates a DocumentTransform message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentTransform + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.DocumentTransform; + + /** + * Creates a plain object from a DocumentTransform message. Also converts values to other types if specified. + * @param message DocumentTransform + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.DocumentTransform, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentTransform to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace DocumentTransform { + + /** Properties of a FieldTransform. */ + interface IFieldTransform { + + /** FieldTransform fieldPath */ + fieldPath?: (string|null); + + /** FieldTransform setToServerValue */ + setToServerValue?: (google.firestore.v1.DocumentTransform.FieldTransform.ServerValue|null); + + /** FieldTransform increment */ + increment?: (google.firestore.v1.IValue|null); + + /** FieldTransform maximum */ + maximum?: (google.firestore.v1.IValue|null); + + /** FieldTransform minimum */ + minimum?: (google.firestore.v1.IValue|null); + + /** FieldTransform appendMissingElements */ + appendMissingElements?: (google.firestore.v1.IArrayValue|null); + + /** FieldTransform removeAllFromArray */ + removeAllFromArray?: (google.firestore.v1.IArrayValue|null); + } + + /** Represents a FieldTransform. */ + class FieldTransform implements IFieldTransform { + + /** + * Constructs a new FieldTransform. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.DocumentTransform.IFieldTransform); + + /** FieldTransform fieldPath. */ + public fieldPath: string; + + /** FieldTransform setToServerValue. */ + public setToServerValue: google.firestore.v1.DocumentTransform.FieldTransform.ServerValue; + + /** FieldTransform increment. */ + public increment?: (google.firestore.v1.IValue|null); + + /** FieldTransform maximum. */ + public maximum?: (google.firestore.v1.IValue|null); + + /** FieldTransform minimum. */ + public minimum?: (google.firestore.v1.IValue|null); + + /** FieldTransform appendMissingElements. */ + public appendMissingElements?: (google.firestore.v1.IArrayValue|null); + + /** FieldTransform removeAllFromArray. */ + public removeAllFromArray?: (google.firestore.v1.IArrayValue|null); + + /** FieldTransform transformType. */ + public transformType?: ("setToServerValue"|"increment"|"maximum"|"minimum"|"appendMissingElements"|"removeAllFromArray"); + + /** + * Creates a FieldTransform message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldTransform + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.DocumentTransform.FieldTransform; + + /** + * Creates a plain object from a FieldTransform message. Also converts values to other types if specified. + * @param message FieldTransform + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.DocumentTransform.FieldTransform, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldTransform to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace FieldTransform { + + /** ServerValue enum. */ + type ServerValue = + "SERVER_VALUE_UNSPECIFIED"| "REQUEST_TIME"; + } + } + + /** Properties of a WriteResult. */ + interface IWriteResult { + + /** WriteResult updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** WriteResult transformResults */ + transformResults?: (google.firestore.v1.IValue[]|null); + } + + /** Represents a WriteResult. */ + class WriteResult implements IWriteResult { + + /** + * Constructs a new WriteResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IWriteResult); + + /** WriteResult updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** WriteResult transformResults. */ + public transformResults: google.firestore.v1.IValue[]; + + /** + * Creates a WriteResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WriteResult + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.WriteResult; + + /** + * Creates a plain object from a WriteResult message. Also converts values to other types if specified. + * @param message WriteResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.WriteResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WriteResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DocumentChange. */ + interface IDocumentChange { + + /** DocumentChange document */ + document?: (google.firestore.v1.IDocument|null); + + /** DocumentChange targetIds */ + targetIds?: (number[]|null); + + /** DocumentChange removedTargetIds */ + removedTargetIds?: (number[]|null); + } + + /** Represents a DocumentChange. */ + class DocumentChange implements IDocumentChange { + + /** + * Constructs a new DocumentChange. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IDocumentChange); + + /** DocumentChange document. */ + public document?: (google.firestore.v1.IDocument|null); + + /** DocumentChange targetIds. */ + public targetIds: number[]; + + /** DocumentChange removedTargetIds. */ + public removedTargetIds: number[]; + + /** + * Creates a DocumentChange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentChange + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.DocumentChange; + + /** + * Creates a plain object from a DocumentChange message. Also converts values to other types if specified. + * @param message DocumentChange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.DocumentChange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentChange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DocumentDelete. */ + interface IDocumentDelete { + + /** DocumentDelete document */ + document?: (string|null); + + /** DocumentDelete removedTargetIds */ + removedTargetIds?: (number[]|null); + + /** DocumentDelete readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a DocumentDelete. */ + class DocumentDelete implements IDocumentDelete { + + /** + * Constructs a new DocumentDelete. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IDocumentDelete); + + /** DocumentDelete document. */ + public document: string; + + /** DocumentDelete removedTargetIds. */ + public removedTargetIds: number[]; + + /** DocumentDelete readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a DocumentDelete message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentDelete + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.DocumentDelete; + + /** + * Creates a plain object from a DocumentDelete message. Also converts values to other types if specified. + * @param message DocumentDelete + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.DocumentDelete, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentDelete to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DocumentRemove. */ + interface IDocumentRemove { + + /** DocumentRemove document */ + document?: (string|null); + + /** DocumentRemove removedTargetIds */ + removedTargetIds?: (number[]|null); + + /** DocumentRemove readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a DocumentRemove. */ + class DocumentRemove implements IDocumentRemove { + + /** + * Constructs a new DocumentRemove. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IDocumentRemove); + + /** DocumentRemove document. */ + public document: string; + + /** DocumentRemove removedTargetIds. */ + public removedTargetIds: number[]; + + /** DocumentRemove readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a DocumentRemove message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentRemove + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.DocumentRemove; + + /** + * Creates a plain object from a DocumentRemove message. Also converts values to other types if specified. + * @param message DocumentRemove + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.DocumentRemove, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentRemove to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an ExistenceFilter. */ + interface IExistenceFilter { + + /** ExistenceFilter targetId */ + targetId?: (number|null); + + /** ExistenceFilter count */ + count?: (number|null); + } + + /** Represents an ExistenceFilter. */ + class ExistenceFilter implements IExistenceFilter { + + /** + * Constructs a new ExistenceFilter. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1.IExistenceFilter); + + /** ExistenceFilter targetId. */ + public targetId: number; + + /** ExistenceFilter count. */ + public count: number; + + /** + * Creates an ExistenceFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExistenceFilter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1.ExistenceFilter; + + /** + * Creates a plain object from an ExistenceFilter message. Also converts values to other types if specified. + * @param message ExistenceFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1.ExistenceFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExistenceFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + } + + /** Namespace api. */ + namespace api { + + /** Properties of a Http. */ + interface IHttp { + + /** Http rules */ + rules?: (google.api.IHttpRule[]|null); + } + + /** Represents a Http. */ + class Http implements IHttp { + + /** + * Constructs a new Http. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IHttp); + + /** Http rules. */ + public rules: google.api.IHttpRule[]; + + /** + * Creates a Http message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Http + */ + public static fromObject(object: { [k: string]: any }): google.api.Http; + + /** + * Creates a plain object from a Http message. Also converts values to other types if specified. + * @param message Http + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.Http, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Http to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a HttpRule. */ + interface IHttpRule { + + /** HttpRule get */ + get?: (string|null); + + /** HttpRule put */ + put?: (string|null); + + /** HttpRule post */ + post?: (string|null); + + /** HttpRule delete */ + "delete"?: (string|null); + + /** HttpRule patch */ + patch?: (string|null); + + /** HttpRule custom */ + custom?: (google.api.ICustomHttpPattern|null); + + /** HttpRule selector */ + selector?: (string|null); + + /** HttpRule body */ + body?: (string|null); + + /** HttpRule additionalBindings */ + additionalBindings?: (google.api.IHttpRule[]|null); + } + + /** Represents a HttpRule. */ + class HttpRule implements IHttpRule { + + /** + * Constructs a new HttpRule. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IHttpRule); + + /** HttpRule get. */ + public get: string; + + /** HttpRule put. */ + public put: string; + + /** HttpRule post. */ + public post: string; + + /** HttpRule delete. */ + public delete: string; + + /** HttpRule patch. */ + public patch: string; + + /** HttpRule custom. */ + public custom?: (google.api.ICustomHttpPattern|null); + + /** HttpRule selector. */ + public selector: string; + + /** HttpRule body. */ + public body: string; + + /** HttpRule additionalBindings. */ + public additionalBindings: google.api.IHttpRule[]; + + /** HttpRule pattern. */ + public pattern?: ("get"|"put"|"post"|"delete"|"patch"|"custom"); + + /** + * Creates a HttpRule message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns HttpRule + */ + public static fromObject(object: { [k: string]: any }): google.api.HttpRule; + + /** + * Creates a plain object from a HttpRule message. Also converts values to other types if specified. + * @param message HttpRule + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.HttpRule, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this HttpRule to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CustomHttpPattern. */ + interface ICustomHttpPattern { + + /** CustomHttpPattern kind */ + kind?: (string|null); + + /** CustomHttpPattern path */ + path?: (string|null); + } + + /** Represents a CustomHttpPattern. */ + class CustomHttpPattern implements ICustomHttpPattern { + + /** + * Constructs a new CustomHttpPattern. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ICustomHttpPattern); + + /** CustomHttpPattern kind. */ + public kind: string; + + /** CustomHttpPattern path. */ + public path: string; + + /** + * Creates a CustomHttpPattern message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CustomHttpPattern + */ + public static fromObject(object: { [k: string]: any }): google.api.CustomHttpPattern; + + /** + * Creates a plain object from a CustomHttpPattern message. Also converts values to other types if specified. + * @param message CustomHttpPattern + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.CustomHttpPattern, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CustomHttpPattern to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** FieldBehavior enum. */ + type FieldBehavior = + "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"; + + /** Properties of a ResourceDescriptor. */ + interface IResourceDescriptor { + + /** ResourceDescriptor type */ + type?: (string|null); + + /** ResourceDescriptor pattern */ + pattern?: (string[]|null); + + /** ResourceDescriptor nameField */ + nameField?: (string|null); + + /** ResourceDescriptor history */ + history?: (google.api.ResourceDescriptor.History|null); + + /** ResourceDescriptor plural */ + plural?: (string|null); + + /** ResourceDescriptor singular */ + singular?: (string|null); + + /** ResourceDescriptor style */ + style?: (google.api.ResourceDescriptor.Style[]|null); + } + + /** Represents a ResourceDescriptor. */ + class ResourceDescriptor implements IResourceDescriptor { + + /** + * Constructs a new ResourceDescriptor. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IResourceDescriptor); + + /** ResourceDescriptor type. */ + public type: string; + + /** ResourceDescriptor pattern. */ + public pattern: string[]; + + /** ResourceDescriptor nameField. */ + public nameField: string; + + /** ResourceDescriptor history. */ + public history: google.api.ResourceDescriptor.History; + + /** ResourceDescriptor plural. */ + public plural: string; + + /** ResourceDescriptor singular. */ + public singular: string; + + /** ResourceDescriptor style. */ + public style: google.api.ResourceDescriptor.Style[]; + + /** + * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ResourceDescriptor + */ + public static fromObject(object: { [k: string]: any }): google.api.ResourceDescriptor; + + /** + * Creates a plain object from a ResourceDescriptor message. Also converts values to other types if specified. + * @param message ResourceDescriptor + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.ResourceDescriptor, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ResourceDescriptor to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace ResourceDescriptor { + + /** History enum. */ + type History = + "HISTORY_UNSPECIFIED"| "ORIGINALLY_SINGLE_PATTERN"| "FUTURE_MULTI_PATTERN"; + + /** Style enum. */ + type Style = + "STYLE_UNSPECIFIED"| "DECLARATIVE_FRIENDLY"; + } + + /** Properties of a ResourceReference. */ + interface IResourceReference { + + /** ResourceReference type */ + type?: (string|null); + + /** ResourceReference childType */ + childType?: (string|null); + } + + /** Represents a ResourceReference. */ + class ResourceReference implements IResourceReference { + + /** + * Constructs a new ResourceReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IResourceReference); + + /** ResourceReference type. */ + public type: string; + + /** ResourceReference childType. */ + public childType: string; + + /** + * Creates a ResourceReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ResourceReference + */ + public static fromObject(object: { [k: string]: any }): google.api.ResourceReference; + + /** + * Creates a plain object from a ResourceReference message. Also converts values to other types if specified. + * @param message ResourceReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.ResourceReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ResourceReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Namespace type. */ + namespace type { + + /** Properties of a LatLng. */ + interface ILatLng { + + /** LatLng latitude */ + latitude?: (number|null); + + /** LatLng longitude */ + longitude?: (number|null); + } + + /** Represents a LatLng. */ + class LatLng implements ILatLng { + + /** + * Constructs a new LatLng. + * @param [properties] Properties to set + */ + constructor(properties?: google.type.ILatLng); + + /** LatLng latitude. */ + public latitude: number; + + /** LatLng longitude. */ + public longitude: number; + + /** + * Creates a LatLng message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LatLng + */ + public static fromObject(object: { [k: string]: any }): google.type.LatLng; + + /** + * Creates a plain object from a LatLng message. Also converts values to other types if specified. + * @param message LatLng + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.type.LatLng, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LatLng to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Namespace rpc. */ + namespace rpc { + + /** Properties of a Status. */ + interface IStatus { + + /** Status code */ + code?: (number|null); + + /** Status message */ + message?: (string|null); + + /** Status details */ + details?: (google.protobuf.IAny[]|null); + } + + /** Represents a Status. */ + class Status implements IStatus { + + /** + * Constructs a new Status. + * @param [properties] Properties to set + */ + constructor(properties?: google.rpc.IStatus); + + /** Status code. */ + public code: number; + + /** Status message. */ + public message: string; + + /** Status details. */ + public details: google.protobuf.IAny[]; + + /** + * Creates a Status message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Status + */ + public static fromObject(object: { [k: string]: any }): google.rpc.Status; + + /** + * Creates a plain object from a Status message. Also converts values to other types if specified. + * @param message Status + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.rpc.Status, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Status to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Namespace longrunning. */ + namespace longrunning { + + /** Represents an Operations */ + class Operations extends $protobuf.rpc.Service { + + /** + * Constructs a new Operations service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Calls ListOperations. + * @param request ListOperationsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListOperationsResponse + */ + public listOperations(request: google.longrunning.IListOperationsRequest, callback: google.longrunning.Operations.ListOperationsCallback): void; + + /** + * Calls ListOperations. + * @param request ListOperationsRequest message or plain object + * @returns Promise + */ + public listOperations(request: google.longrunning.IListOperationsRequest): Promise; + + /** + * Calls GetOperation. + * @param request GetOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public getOperation(request: google.longrunning.IGetOperationRequest, callback: google.longrunning.Operations.GetOperationCallback): void; + + /** + * Calls GetOperation. + * @param request GetOperationRequest message or plain object + * @returns Promise + */ + public getOperation(request: google.longrunning.IGetOperationRequest): Promise; + + /** + * Calls DeleteOperation. + * @param request DeleteOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteOperation(request: google.longrunning.IDeleteOperationRequest, callback: google.longrunning.Operations.DeleteOperationCallback): void; + + /** + * Calls DeleteOperation. + * @param request DeleteOperationRequest message or plain object + * @returns Promise + */ + public deleteOperation(request: google.longrunning.IDeleteOperationRequest): Promise; + + /** + * Calls CancelOperation. + * @param request CancelOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public cancelOperation(request: google.longrunning.ICancelOperationRequest, callback: google.longrunning.Operations.CancelOperationCallback): void; + + /** + * Calls CancelOperation. + * @param request CancelOperationRequest message or plain object + * @returns Promise + */ + public cancelOperation(request: google.longrunning.ICancelOperationRequest): Promise; + + /** + * Calls WaitOperation. + * @param request WaitOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public waitOperation(request: google.longrunning.IWaitOperationRequest, callback: google.longrunning.Operations.WaitOperationCallback): void; + + /** + * Calls WaitOperation. + * @param request WaitOperationRequest message or plain object + * @returns Promise + */ + public waitOperation(request: google.longrunning.IWaitOperationRequest): Promise; + } + + namespace Operations { + + /** + * Callback as used by {@link google.longrunning.Operations#listOperations}. + * @param error Error, if any + * @param [response] ListOperationsResponse + */ + type ListOperationsCallback = (error: (Error|null), response?: google.longrunning.ListOperationsResponse) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#getOperation}. + * @param error Error, if any + * @param [response] Operation + */ + type GetOperationCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#deleteOperation}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteOperationCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#cancelOperation}. + * @param error Error, if any + * @param [response] Empty + */ + type CancelOperationCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#waitOperation}. + * @param error Error, if any + * @param [response] Operation + */ + type WaitOperationCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of an Operation. */ + interface IOperation { + + /** Operation name */ + name?: (string|null); + + /** Operation metadata */ + metadata?: (google.protobuf.IAny|null); + + /** Operation done */ + done?: (boolean|null); + + /** Operation error */ + error?: (google.rpc.IStatus|null); + + /** Operation response */ + response?: (google.protobuf.IAny|null); + } + + /** Represents an Operation. */ + class Operation implements IOperation { + + /** + * Constructs a new Operation. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IOperation); + + /** Operation name. */ + public name: string; + + /** Operation metadata. */ + public metadata?: (google.protobuf.IAny|null); + + /** Operation done. */ + public done: boolean; + + /** Operation error. */ + public error?: (google.rpc.IStatus|null); + + /** Operation response. */ + public response?: (google.protobuf.IAny|null); + + /** Operation result. */ + public result?: ("error"|"response"); + + /** + * Creates an Operation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Operation + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.Operation; + + /** + * Creates a plain object from an Operation message. Also converts values to other types if specified. + * @param message Operation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.Operation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Operation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a GetOperationRequest. */ + interface IGetOperationRequest { + + /** GetOperationRequest name */ + name?: (string|null); + } + + /** Represents a GetOperationRequest. */ + class GetOperationRequest implements IGetOperationRequest { + + /** + * Constructs a new GetOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IGetOperationRequest); + + /** GetOperationRequest name. */ + public name: string; + + /** + * Creates a GetOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.GetOperationRequest; + + /** + * Creates a plain object from a GetOperationRequest message. Also converts values to other types if specified. + * @param message GetOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.GetOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListOperationsRequest. */ + interface IListOperationsRequest { + + /** ListOperationsRequest name */ + name?: (string|null); + + /** ListOperationsRequest filter */ + filter?: (string|null); + + /** ListOperationsRequest pageSize */ + pageSize?: (number|null); + + /** ListOperationsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListOperationsRequest. */ + class ListOperationsRequest implements IListOperationsRequest { + + /** + * Constructs a new ListOperationsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IListOperationsRequest); + + /** ListOperationsRequest name. */ + public name: string; + + /** ListOperationsRequest filter. */ + public filter: string; + + /** ListOperationsRequest pageSize. */ + public pageSize: number; + + /** ListOperationsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a ListOperationsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListOperationsRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.ListOperationsRequest; + + /** + * Creates a plain object from a ListOperationsRequest message. Also converts values to other types if specified. + * @param message ListOperationsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.ListOperationsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListOperationsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListOperationsResponse. */ + interface IListOperationsResponse { + + /** ListOperationsResponse operations */ + operations?: (google.longrunning.IOperation[]|null); + + /** ListOperationsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListOperationsResponse. */ + class ListOperationsResponse implements IListOperationsResponse { + + /** + * Constructs a new ListOperationsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IListOperationsResponse); + + /** ListOperationsResponse operations. */ + public operations: google.longrunning.IOperation[]; + + /** ListOperationsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a ListOperationsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListOperationsResponse + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.ListOperationsResponse; + + /** + * Creates a plain object from a ListOperationsResponse message. Also converts values to other types if specified. + * @param message ListOperationsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.ListOperationsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListOperationsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CancelOperationRequest. */ + interface ICancelOperationRequest { + + /** CancelOperationRequest name */ + name?: (string|null); + } + + /** Represents a CancelOperationRequest. */ + class CancelOperationRequest implements ICancelOperationRequest { + + /** + * Constructs a new CancelOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.ICancelOperationRequest); + + /** CancelOperationRequest name. */ + public name: string; + + /** + * Creates a CancelOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CancelOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.CancelOperationRequest; + + /** + * Creates a plain object from a CancelOperationRequest message. Also converts values to other types if specified. + * @param message CancelOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.CancelOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CancelOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DeleteOperationRequest. */ + interface IDeleteOperationRequest { + + /** DeleteOperationRequest name */ + name?: (string|null); + } + + /** Represents a DeleteOperationRequest. */ + class DeleteOperationRequest implements IDeleteOperationRequest { + + /** + * Constructs a new DeleteOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IDeleteOperationRequest); + + /** DeleteOperationRequest name. */ + public name: string; + + /** + * Creates a DeleteOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.DeleteOperationRequest; + + /** + * Creates a plain object from a DeleteOperationRequest message. Also converts values to other types if specified. + * @param message DeleteOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.DeleteOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a WaitOperationRequest. */ + interface IWaitOperationRequest { + + /** WaitOperationRequest name */ + name?: (string|null); + + /** WaitOperationRequest timeout */ + timeout?: (google.protobuf.IDuration|null); + } + + /** Represents a WaitOperationRequest. */ + class WaitOperationRequest implements IWaitOperationRequest { + + /** + * Constructs a new WaitOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IWaitOperationRequest); + + /** WaitOperationRequest name. */ + public name: string; + + /** WaitOperationRequest timeout. */ + public timeout?: (google.protobuf.IDuration|null); + + /** + * Creates a WaitOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WaitOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.WaitOperationRequest; + + /** + * Creates a plain object from a WaitOperationRequest message. Also converts values to other types if specified. + * @param message WaitOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.WaitOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WaitOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an OperationInfo. */ + interface IOperationInfo { + + /** OperationInfo responseType */ + responseType?: (string|null); + + /** OperationInfo metadataType */ + metadataType?: (string|null); + } + + /** Represents an OperationInfo. */ + class OperationInfo implements IOperationInfo { + + /** + * Constructs a new OperationInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IOperationInfo); + + /** OperationInfo responseType. */ + public responseType: string; + + /** OperationInfo metadataType. */ + public metadataType: string; + + /** + * Creates an OperationInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OperationInfo + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.OperationInfo; + + /** + * Creates a plain object from an OperationInfo message. Also converts values to other types if specified. + * @param message OperationInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.OperationInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OperationInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } +} diff --git a/types/protos/firestore_v1beta1_proto_api.d.ts b/types/protos/firestore_v1beta1_proto_api.d.ts new file mode 100644 index 000000000..0086457e8 --- /dev/null +++ b/types/protos/firestore_v1beta1_proto_api.d.ts @@ -0,0 +1,6563 @@ +/*! + * Copyright 2021 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 $protobuf from "protobufjs"; +/** Namespace google. */ +export namespace google { + + /** Namespace protobuf. */ + namespace protobuf { + + /** Properties of a Timestamp. */ + interface ITimestamp { + + /** Timestamp seconds */ + seconds?: (number|string|null); + + /** Timestamp nanos */ + nanos?: (number|null); + } + + /** Represents a Timestamp. */ + class Timestamp implements ITimestamp { + + /** + * Constructs a new Timestamp. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.ITimestamp); + + /** Timestamp seconds. */ + public seconds: (number|string); + + /** Timestamp nanos. */ + public nanos: number; + + /** + * Creates a Timestamp message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Timestamp + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Timestamp; + + /** + * Creates a plain object from a Timestamp message. Also converts values to other types if specified. + * @param message Timestamp + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Timestamp, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Timestamp to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FileDescriptorSet. */ + interface IFileDescriptorSet { + + /** FileDescriptorSet file */ + file?: (google.protobuf.IFileDescriptorProto[]|null); + } + + /** Represents a FileDescriptorSet. */ + class FileDescriptorSet implements IFileDescriptorSet { + + /** + * Constructs a new FileDescriptorSet. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileDescriptorSet); + + /** FileDescriptorSet file. */ + public file: google.protobuf.IFileDescriptorProto[]; + + /** + * Creates a FileDescriptorSet message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileDescriptorSet + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileDescriptorSet; + + /** + * Creates a plain object from a FileDescriptorSet message. Also converts values to other types if specified. + * @param message FileDescriptorSet + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileDescriptorSet, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileDescriptorSet to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FileDescriptorProto. */ + interface IFileDescriptorProto { + + /** FileDescriptorProto name */ + name?: (string|null); + + /** FileDescriptorProto package */ + "package"?: (string|null); + + /** FileDescriptorProto dependency */ + dependency?: (string[]|null); + + /** FileDescriptorProto publicDependency */ + publicDependency?: (number[]|null); + + /** FileDescriptorProto weakDependency */ + weakDependency?: (number[]|null); + + /** FileDescriptorProto messageType */ + messageType?: (google.protobuf.IDescriptorProto[]|null); + + /** FileDescriptorProto enumType */ + enumType?: (google.protobuf.IEnumDescriptorProto[]|null); + + /** FileDescriptorProto service */ + service?: (google.protobuf.IServiceDescriptorProto[]|null); + + /** FileDescriptorProto extension */ + extension?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** FileDescriptorProto options */ + options?: (google.protobuf.IFileOptions|null); + + /** FileDescriptorProto sourceCodeInfo */ + sourceCodeInfo?: (google.protobuf.ISourceCodeInfo|null); + + /** FileDescriptorProto syntax */ + syntax?: (string|null); + } + + /** Represents a FileDescriptorProto. */ + class FileDescriptorProto implements IFileDescriptorProto { + + /** + * Constructs a new FileDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileDescriptorProto); + + /** FileDescriptorProto name. */ + public name: string; + + /** FileDescriptorProto package. */ + public package: string; + + /** FileDescriptorProto dependency. */ + public dependency: string[]; + + /** FileDescriptorProto publicDependency. */ + public publicDependency: number[]; + + /** FileDescriptorProto weakDependency. */ + public weakDependency: number[]; + + /** FileDescriptorProto messageType. */ + public messageType: google.protobuf.IDescriptorProto[]; + + /** FileDescriptorProto enumType. */ + public enumType: google.protobuf.IEnumDescriptorProto[]; + + /** FileDescriptorProto service. */ + public service: google.protobuf.IServiceDescriptorProto[]; + + /** FileDescriptorProto extension. */ + public extension: google.protobuf.IFieldDescriptorProto[]; + + /** FileDescriptorProto options. */ + public options?: (google.protobuf.IFileOptions|null); + + /** FileDescriptorProto sourceCodeInfo. */ + public sourceCodeInfo?: (google.protobuf.ISourceCodeInfo|null); + + /** FileDescriptorProto syntax. */ + public syntax: string; + + /** + * Creates a FileDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileDescriptorProto; + + /** + * Creates a plain object from a FileDescriptorProto message. Also converts values to other types if specified. + * @param message FileDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DescriptorProto. */ + interface IDescriptorProto { + + /** DescriptorProto name */ + name?: (string|null); + + /** DescriptorProto field */ + field?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** DescriptorProto extension */ + extension?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** DescriptorProto nestedType */ + nestedType?: (google.protobuf.IDescriptorProto[]|null); + + /** DescriptorProto enumType */ + enumType?: (google.protobuf.IEnumDescriptorProto[]|null); + + /** DescriptorProto extensionRange */ + extensionRange?: (google.protobuf.DescriptorProto.IExtensionRange[]|null); + + /** DescriptorProto oneofDecl */ + oneofDecl?: (google.protobuf.IOneofDescriptorProto[]|null); + + /** DescriptorProto options */ + options?: (google.protobuf.IMessageOptions|null); + + /** DescriptorProto reservedRange */ + reservedRange?: (google.protobuf.DescriptorProto.IReservedRange[]|null); + + /** DescriptorProto reservedName */ + reservedName?: (string[]|null); + } + + /** Represents a DescriptorProto. */ + class DescriptorProto implements IDescriptorProto { + + /** + * Constructs a new DescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDescriptorProto); + + /** DescriptorProto name. */ + public name: string; + + /** DescriptorProto field. */ + public field: google.protobuf.IFieldDescriptorProto[]; + + /** DescriptorProto extension. */ + public extension: google.protobuf.IFieldDescriptorProto[]; + + /** DescriptorProto nestedType. */ + public nestedType: google.protobuf.IDescriptorProto[]; + + /** DescriptorProto enumType. */ + public enumType: google.protobuf.IEnumDescriptorProto[]; + + /** DescriptorProto extensionRange. */ + public extensionRange: google.protobuf.DescriptorProto.IExtensionRange[]; + + /** DescriptorProto oneofDecl. */ + public oneofDecl: google.protobuf.IOneofDescriptorProto[]; + + /** DescriptorProto options. */ + public options?: (google.protobuf.IMessageOptions|null); + + /** DescriptorProto reservedRange. */ + public reservedRange: google.protobuf.DescriptorProto.IReservedRange[]; + + /** DescriptorProto reservedName. */ + public reservedName: string[]; + + /** + * Creates a DescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto; + + /** + * Creates a plain object from a DescriptorProto message. Also converts values to other types if specified. + * @param message DescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace DescriptorProto { + + /** Properties of an ExtensionRange. */ + interface IExtensionRange { + + /** ExtensionRange start */ + start?: (number|null); + + /** ExtensionRange end */ + end?: (number|null); + } + + /** Represents an ExtensionRange. */ + class ExtensionRange implements IExtensionRange { + + /** + * Constructs a new ExtensionRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.DescriptorProto.IExtensionRange); + + /** ExtensionRange start. */ + public start: number; + + /** ExtensionRange end. */ + public end: number; + + /** + * Creates an ExtensionRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExtensionRange + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto.ExtensionRange; + + /** + * Creates a plain object from an ExtensionRange message. Also converts values to other types if specified. + * @param message ExtensionRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto.ExtensionRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExtensionRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ReservedRange. */ + interface IReservedRange { + + /** ReservedRange start */ + start?: (number|null); + + /** ReservedRange end */ + end?: (number|null); + } + + /** Represents a ReservedRange. */ + class ReservedRange implements IReservedRange { + + /** + * Constructs a new ReservedRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.DescriptorProto.IReservedRange); + + /** ReservedRange start. */ + public start: number; + + /** ReservedRange end. */ + public end: number; + + /** + * Creates a ReservedRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReservedRange + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto.ReservedRange; + + /** + * Creates a plain object from a ReservedRange message. Also converts values to other types if specified. + * @param message ReservedRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto.ReservedRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReservedRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a FieldDescriptorProto. */ + interface IFieldDescriptorProto { + + /** FieldDescriptorProto name */ + name?: (string|null); + + /** FieldDescriptorProto number */ + number?: (number|null); + + /** FieldDescriptorProto label */ + label?: (google.protobuf.FieldDescriptorProto.Label|null); + + /** FieldDescriptorProto type */ + type?: (google.protobuf.FieldDescriptorProto.Type|null); + + /** FieldDescriptorProto typeName */ + typeName?: (string|null); + + /** FieldDescriptorProto extendee */ + extendee?: (string|null); + + /** FieldDescriptorProto defaultValue */ + defaultValue?: (string|null); + + /** FieldDescriptorProto oneofIndex */ + oneofIndex?: (number|null); + + /** FieldDescriptorProto jsonName */ + jsonName?: (string|null); + + /** FieldDescriptorProto options */ + options?: (google.protobuf.IFieldOptions|null); + } + + /** Represents a FieldDescriptorProto. */ + class FieldDescriptorProto implements IFieldDescriptorProto { + + /** + * Constructs a new FieldDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldDescriptorProto); + + /** FieldDescriptorProto name. */ + public name: string; + + /** FieldDescriptorProto number. */ + public number: number; + + /** FieldDescriptorProto label. */ + public label: google.protobuf.FieldDescriptorProto.Label; + + /** FieldDescriptorProto type. */ + public type: google.protobuf.FieldDescriptorProto.Type; + + /** FieldDescriptorProto typeName. */ + public typeName: string; + + /** FieldDescriptorProto extendee. */ + public extendee: string; + + /** FieldDescriptorProto defaultValue. */ + public defaultValue: string; + + /** FieldDescriptorProto oneofIndex. */ + public oneofIndex: number; + + /** FieldDescriptorProto jsonName. */ + public jsonName: string; + + /** FieldDescriptorProto options. */ + public options?: (google.protobuf.IFieldOptions|null); + + /** + * Creates a FieldDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldDescriptorProto; + + /** + * Creates a plain object from a FieldDescriptorProto message. Also converts values to other types if specified. + * @param message FieldDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace FieldDescriptorProto { + + /** Type enum. */ + type Type = + "TYPE_DOUBLE"| "TYPE_FLOAT"| "TYPE_INT64"| "TYPE_UINT64"| "TYPE_INT32"| "TYPE_FIXED64"| "TYPE_FIXED32"| "TYPE_BOOL"| "TYPE_STRING"| "TYPE_GROUP"| "TYPE_MESSAGE"| "TYPE_BYTES"| "TYPE_UINT32"| "TYPE_ENUM"| "TYPE_SFIXED32"| "TYPE_SFIXED64"| "TYPE_SINT32"| "TYPE_SINT64"; + + /** Label enum. */ + type Label = + "LABEL_OPTIONAL"| "LABEL_REQUIRED"| "LABEL_REPEATED"; + } + + /** Properties of an OneofDescriptorProto. */ + interface IOneofDescriptorProto { + + /** OneofDescriptorProto name */ + name?: (string|null); + + /** OneofDescriptorProto options */ + options?: (google.protobuf.IOneofOptions|null); + } + + /** Represents an OneofDescriptorProto. */ + class OneofDescriptorProto implements IOneofDescriptorProto { + + /** + * Constructs a new OneofDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IOneofDescriptorProto); + + /** OneofDescriptorProto name. */ + public name: string; + + /** OneofDescriptorProto options. */ + public options?: (google.protobuf.IOneofOptions|null); + + /** + * Creates an OneofDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OneofDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.OneofDescriptorProto; + + /** + * Creates a plain object from an OneofDescriptorProto message. Also converts values to other types if specified. + * @param message OneofDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.OneofDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OneofDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an EnumDescriptorProto. */ + interface IEnumDescriptorProto { + + /** EnumDescriptorProto name */ + name?: (string|null); + + /** EnumDescriptorProto value */ + value?: (google.protobuf.IEnumValueDescriptorProto[]|null); + + /** EnumDescriptorProto options */ + options?: (google.protobuf.IEnumOptions|null); + } + + /** Represents an EnumDescriptorProto. */ + class EnumDescriptorProto implements IEnumDescriptorProto { + + /** + * Constructs a new EnumDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumDescriptorProto); + + /** EnumDescriptorProto name. */ + public name: string; + + /** EnumDescriptorProto value. */ + public value: google.protobuf.IEnumValueDescriptorProto[]; + + /** EnumDescriptorProto options. */ + public options?: (google.protobuf.IEnumOptions|null); + + /** + * Creates an EnumDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumDescriptorProto; + + /** + * Creates a plain object from an EnumDescriptorProto message. Also converts values to other types if specified. + * @param message EnumDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an EnumValueDescriptorProto. */ + interface IEnumValueDescriptorProto { + + /** EnumValueDescriptorProto name */ + name?: (string|null); + + /** EnumValueDescriptorProto number */ + number?: (number|null); + + /** EnumValueDescriptorProto options */ + options?: (google.protobuf.IEnumValueOptions|null); + } + + /** Represents an EnumValueDescriptorProto. */ + class EnumValueDescriptorProto implements IEnumValueDescriptorProto { + + /** + * Constructs a new EnumValueDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumValueDescriptorProto); + + /** EnumValueDescriptorProto name. */ + public name: string; + + /** EnumValueDescriptorProto number. */ + public number: number; + + /** EnumValueDescriptorProto options. */ + public options?: (google.protobuf.IEnumValueOptions|null); + + /** + * Creates an EnumValueDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumValueDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumValueDescriptorProto; + + /** + * Creates a plain object from an EnumValueDescriptorProto message. Also converts values to other types if specified. + * @param message EnumValueDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumValueDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumValueDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ServiceDescriptorProto. */ + interface IServiceDescriptorProto { + + /** ServiceDescriptorProto name */ + name?: (string|null); + + /** ServiceDescriptorProto method */ + method?: (google.protobuf.IMethodDescriptorProto[]|null); + + /** ServiceDescriptorProto options */ + options?: (google.protobuf.IServiceOptions|null); + } + + /** Represents a ServiceDescriptorProto. */ + class ServiceDescriptorProto implements IServiceDescriptorProto { + + /** + * Constructs a new ServiceDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IServiceDescriptorProto); + + /** ServiceDescriptorProto name. */ + public name: string; + + /** ServiceDescriptorProto method. */ + public method: google.protobuf.IMethodDescriptorProto[]; + + /** ServiceDescriptorProto options. */ + public options?: (google.protobuf.IServiceOptions|null); + + /** + * Creates a ServiceDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServiceDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ServiceDescriptorProto; + + /** + * Creates a plain object from a ServiceDescriptorProto message. Also converts values to other types if specified. + * @param message ServiceDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ServiceDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServiceDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a MethodDescriptorProto. */ + interface IMethodDescriptorProto { + + /** MethodDescriptorProto name */ + name?: (string|null); + + /** MethodDescriptorProto inputType */ + inputType?: (string|null); + + /** MethodDescriptorProto outputType */ + outputType?: (string|null); + + /** MethodDescriptorProto options */ + options?: (google.protobuf.IMethodOptions|null); + + /** MethodDescriptorProto clientStreaming */ + clientStreaming?: (boolean|null); + + /** MethodDescriptorProto serverStreaming */ + serverStreaming?: (boolean|null); + } + + /** Represents a MethodDescriptorProto. */ + class MethodDescriptorProto implements IMethodDescriptorProto { + + /** + * Constructs a new MethodDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMethodDescriptorProto); + + /** MethodDescriptorProto name. */ + public name: string; + + /** MethodDescriptorProto inputType. */ + public inputType: string; + + /** MethodDescriptorProto outputType. */ + public outputType: string; + + /** MethodDescriptorProto options. */ + public options?: (google.protobuf.IMethodOptions|null); + + /** MethodDescriptorProto clientStreaming. */ + public clientStreaming: boolean; + + /** MethodDescriptorProto serverStreaming. */ + public serverStreaming: boolean; + + /** + * Creates a MethodDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MethodDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MethodDescriptorProto; + + /** + * Creates a plain object from a MethodDescriptorProto message. Also converts values to other types if specified. + * @param message MethodDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MethodDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MethodDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FileOptions. */ + interface IFileOptions { + + /** FileOptions javaPackage */ + javaPackage?: (string|null); + + /** FileOptions javaOuterClassname */ + javaOuterClassname?: (string|null); + + /** FileOptions javaMultipleFiles */ + javaMultipleFiles?: (boolean|null); + + /** FileOptions javaGenerateEqualsAndHash */ + javaGenerateEqualsAndHash?: (boolean|null); + + /** FileOptions javaStringCheckUtf8 */ + javaStringCheckUtf8?: (boolean|null); + + /** FileOptions optimizeFor */ + optimizeFor?: (google.protobuf.FileOptions.OptimizeMode|null); + + /** FileOptions goPackage */ + goPackage?: (string|null); + + /** FileOptions ccGenericServices */ + ccGenericServices?: (boolean|null); + + /** FileOptions javaGenericServices */ + javaGenericServices?: (boolean|null); + + /** FileOptions pyGenericServices */ + pyGenericServices?: (boolean|null); + + /** FileOptions deprecated */ + deprecated?: (boolean|null); + + /** FileOptions ccEnableArenas */ + ccEnableArenas?: (boolean|null); + + /** FileOptions objcClassPrefix */ + objcClassPrefix?: (string|null); + + /** FileOptions csharpNamespace */ + csharpNamespace?: (string|null); + + /** FileOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** FileOptions .google.api.resourceDefinition */ + ".google.api.resourceDefinition"?: (google.api.IResourceDescriptor[]|null); + } + + /** Represents a FileOptions. */ + class FileOptions implements IFileOptions { + + /** + * Constructs a new FileOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileOptions); + + /** FileOptions javaPackage. */ + public javaPackage: string; + + /** FileOptions javaOuterClassname. */ + public javaOuterClassname: string; + + /** FileOptions javaMultipleFiles. */ + public javaMultipleFiles: boolean; + + /** FileOptions javaGenerateEqualsAndHash. */ + public javaGenerateEqualsAndHash: boolean; + + /** FileOptions javaStringCheckUtf8. */ + public javaStringCheckUtf8: boolean; + + /** FileOptions optimizeFor. */ + public optimizeFor: google.protobuf.FileOptions.OptimizeMode; + + /** FileOptions goPackage. */ + public goPackage: string; + + /** FileOptions ccGenericServices. */ + public ccGenericServices: boolean; + + /** FileOptions javaGenericServices. */ + public javaGenericServices: boolean; + + /** FileOptions pyGenericServices. */ + public pyGenericServices: boolean; + + /** FileOptions deprecated. */ + public deprecated: boolean; + + /** FileOptions ccEnableArenas. */ + public ccEnableArenas: boolean; + + /** FileOptions objcClassPrefix. */ + public objcClassPrefix: string; + + /** FileOptions csharpNamespace. */ + public csharpNamespace: string; + + /** FileOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a FileOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileOptions; + + /** + * Creates a plain object from a FileOptions message. Also converts values to other types if specified. + * @param message FileOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace FileOptions { + + /** OptimizeMode enum. */ + type OptimizeMode = + "SPEED"| "CODE_SIZE"| "LITE_RUNTIME"; + } + + /** Properties of a MessageOptions. */ + interface IMessageOptions { + + /** MessageOptions messageSetWireFormat */ + messageSetWireFormat?: (boolean|null); + + /** MessageOptions noStandardDescriptorAccessor */ + noStandardDescriptorAccessor?: (boolean|null); + + /** MessageOptions deprecated */ + deprecated?: (boolean|null); + + /** MessageOptions mapEntry */ + mapEntry?: (boolean|null); + + /** MessageOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** MessageOptions .google.api.resource */ + ".google.api.resource"?: (google.api.IResourceDescriptor|null); + } + + /** Represents a MessageOptions. */ + class MessageOptions implements IMessageOptions { + + /** + * Constructs a new MessageOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMessageOptions); + + /** MessageOptions messageSetWireFormat. */ + public messageSetWireFormat: boolean; + + /** MessageOptions noStandardDescriptorAccessor. */ + public noStandardDescriptorAccessor: boolean; + + /** MessageOptions deprecated. */ + public deprecated: boolean; + + /** MessageOptions mapEntry. */ + public mapEntry: boolean; + + /** MessageOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a MessageOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MessageOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MessageOptions; + + /** + * Creates a plain object from a MessageOptions message. Also converts values to other types if specified. + * @param message MessageOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MessageOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MessageOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FieldOptions. */ + interface IFieldOptions { + + /** FieldOptions ctype */ + ctype?: (google.protobuf.FieldOptions.CType|null); + + /** FieldOptions packed */ + packed?: (boolean|null); + + /** FieldOptions jstype */ + jstype?: (google.protobuf.FieldOptions.JSType|null); + + /** FieldOptions lazy */ + lazy?: (boolean|null); + + /** FieldOptions deprecated */ + deprecated?: (boolean|null); + + /** FieldOptions weak */ + weak?: (boolean|null); + + /** FieldOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** FieldOptions .google.api.fieldBehavior */ + ".google.api.fieldBehavior"?: (google.api.FieldBehavior[]|null); + + /** FieldOptions .google.api.resourceReference */ + ".google.api.resourceReference"?: (google.api.IResourceReference|null); + } + + /** Represents a FieldOptions. */ + class FieldOptions implements IFieldOptions { + + /** + * Constructs a new FieldOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldOptions); + + /** FieldOptions ctype. */ + public ctype: google.protobuf.FieldOptions.CType; + + /** FieldOptions packed. */ + public packed: boolean; + + /** FieldOptions jstype. */ + public jstype: google.protobuf.FieldOptions.JSType; + + /** FieldOptions lazy. */ + public lazy: boolean; + + /** FieldOptions deprecated. */ + public deprecated: boolean; + + /** FieldOptions weak. */ + public weak: boolean; + + /** FieldOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a FieldOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions; + + /** + * Creates a plain object from a FieldOptions message. Also converts values to other types if specified. + * @param message FieldOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace FieldOptions { + + /** CType enum. */ + type CType = + "STRING"| "CORD"| "STRING_PIECE"; + + /** JSType enum. */ + type JSType = + "JS_NORMAL"| "JS_STRING"| "JS_NUMBER"; + } + + /** Properties of an OneofOptions. */ + interface IOneofOptions { + + /** OneofOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an OneofOptions. */ + class OneofOptions implements IOneofOptions { + + /** + * Constructs a new OneofOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IOneofOptions); + + /** OneofOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an OneofOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OneofOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.OneofOptions; + + /** + * Creates a plain object from an OneofOptions message. Also converts values to other types if specified. + * @param message OneofOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.OneofOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OneofOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an EnumOptions. */ + interface IEnumOptions { + + /** EnumOptions allowAlias */ + allowAlias?: (boolean|null); + + /** EnumOptions deprecated */ + deprecated?: (boolean|null); + + /** EnumOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an EnumOptions. */ + class EnumOptions implements IEnumOptions { + + /** + * Constructs a new EnumOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumOptions); + + /** EnumOptions allowAlias. */ + public allowAlias: boolean; + + /** EnumOptions deprecated. */ + public deprecated: boolean; + + /** EnumOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an EnumOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumOptions; + + /** + * Creates a plain object from an EnumOptions message. Also converts values to other types if specified. + * @param message EnumOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an EnumValueOptions. */ + interface IEnumValueOptions { + + /** EnumValueOptions deprecated */ + deprecated?: (boolean|null); + + /** EnumValueOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an EnumValueOptions. */ + class EnumValueOptions implements IEnumValueOptions { + + /** + * Constructs a new EnumValueOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumValueOptions); + + /** EnumValueOptions deprecated. */ + public deprecated: boolean; + + /** EnumValueOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates an EnumValueOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumValueOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumValueOptions; + + /** + * Creates a plain object from an EnumValueOptions message. Also converts values to other types if specified. + * @param message EnumValueOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumValueOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumValueOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ServiceOptions. */ + interface IServiceOptions { + + /** ServiceOptions deprecated */ + deprecated?: (boolean|null); + + /** ServiceOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** ServiceOptions .google.api.defaultHost */ + ".google.api.defaultHost"?: (string|null); + + /** ServiceOptions .google.api.oauthScopes */ + ".google.api.oauthScopes"?: (string|null); + } + + /** Represents a ServiceOptions. */ + class ServiceOptions implements IServiceOptions { + + /** + * Constructs a new ServiceOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IServiceOptions); + + /** ServiceOptions deprecated. */ + public deprecated: boolean; + + /** ServiceOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a ServiceOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServiceOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ServiceOptions; + + /** + * Creates a plain object from a ServiceOptions message. Also converts values to other types if specified. + * @param message ServiceOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ServiceOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServiceOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a MethodOptions. */ + interface IMethodOptions { + + /** MethodOptions deprecated */ + deprecated?: (boolean|null); + + /** MethodOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** MethodOptions .google.api.http */ + ".google.api.http"?: (google.api.IHttpRule|null); + + /** MethodOptions .google.api.methodSignature */ + ".google.api.methodSignature"?: (string[]|null); + + /** MethodOptions .google.longrunning.operationInfo */ + ".google.longrunning.operationInfo"?: (google.longrunning.IOperationInfo|null); + } + + /** Represents a MethodOptions. */ + class MethodOptions implements IMethodOptions { + + /** + * Constructs a new MethodOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMethodOptions); + + /** MethodOptions deprecated. */ + public deprecated: boolean; + + /** MethodOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a MethodOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MethodOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MethodOptions; + + /** + * Creates a plain object from a MethodOptions message. Also converts values to other types if specified. + * @param message MethodOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MethodOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MethodOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an UninterpretedOption. */ + interface IUninterpretedOption { + + /** UninterpretedOption name */ + name?: (google.protobuf.UninterpretedOption.INamePart[]|null); + + /** UninterpretedOption identifierValue */ + identifierValue?: (string|null); + + /** UninterpretedOption positiveIntValue */ + positiveIntValue?: (number|string|null); + + /** UninterpretedOption negativeIntValue */ + negativeIntValue?: (number|string|null); + + /** UninterpretedOption doubleValue */ + doubleValue?: (number|null); + + /** UninterpretedOption stringValue */ + stringValue?: (Uint8Array|null); + + /** UninterpretedOption aggregateValue */ + aggregateValue?: (string|null); + } + + /** Represents an UninterpretedOption. */ + class UninterpretedOption implements IUninterpretedOption { + + /** + * Constructs a new UninterpretedOption. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUninterpretedOption); + + /** UninterpretedOption name. */ + public name: google.protobuf.UninterpretedOption.INamePart[]; + + /** UninterpretedOption identifierValue. */ + public identifierValue: string; + + /** UninterpretedOption positiveIntValue. */ + public positiveIntValue: (number|string); + + /** UninterpretedOption negativeIntValue. */ + public negativeIntValue: (number|string); + + /** UninterpretedOption doubleValue. */ + public doubleValue: number; + + /** UninterpretedOption stringValue. */ + public stringValue: Uint8Array; + + /** UninterpretedOption aggregateValue. */ + public aggregateValue: string; + + /** + * Creates an UninterpretedOption message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UninterpretedOption + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UninterpretedOption; + + /** + * Creates a plain object from an UninterpretedOption message. Also converts values to other types if specified. + * @param message UninterpretedOption + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UninterpretedOption, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UninterpretedOption to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace UninterpretedOption { + + /** Properties of a NamePart. */ + interface INamePart { + + /** NamePart namePart */ + namePart: string; + + /** NamePart isExtension */ + isExtension: boolean; + } + + /** Represents a NamePart. */ + class NamePart implements INamePart { + + /** + * Constructs a new NamePart. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.UninterpretedOption.INamePart); + + /** NamePart namePart. */ + public namePart: string; + + /** NamePart isExtension. */ + public isExtension: boolean; + + /** + * Creates a NamePart message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns NamePart + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UninterpretedOption.NamePart; + + /** + * Creates a plain object from a NamePart message. Also converts values to other types if specified. + * @param message NamePart + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UninterpretedOption.NamePart, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this NamePart to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a SourceCodeInfo. */ + interface ISourceCodeInfo { + + /** SourceCodeInfo location */ + location?: (google.protobuf.SourceCodeInfo.ILocation[]|null); + } + + /** Represents a SourceCodeInfo. */ + class SourceCodeInfo implements ISourceCodeInfo { + + /** + * Constructs a new SourceCodeInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.ISourceCodeInfo); + + /** SourceCodeInfo location. */ + public location: google.protobuf.SourceCodeInfo.ILocation[]; + + /** + * Creates a SourceCodeInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SourceCodeInfo + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.SourceCodeInfo; + + /** + * Creates a plain object from a SourceCodeInfo message. Also converts values to other types if specified. + * @param message SourceCodeInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.SourceCodeInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SourceCodeInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace SourceCodeInfo { + + /** Properties of a Location. */ + interface ILocation { + + /** Location path */ + path?: (number[]|null); + + /** Location span */ + span?: (number[]|null); + + /** Location leadingComments */ + leadingComments?: (string|null); + + /** Location trailingComments */ + trailingComments?: (string|null); + + /** Location leadingDetachedComments */ + leadingDetachedComments?: (string[]|null); + } + + /** Represents a Location. */ + class Location implements ILocation { + + /** + * Constructs a new Location. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.SourceCodeInfo.ILocation); + + /** Location path. */ + public path: number[]; + + /** Location span. */ + public span: number[]; + + /** Location leadingComments. */ + public leadingComments: string; + + /** Location trailingComments. */ + public trailingComments: string; + + /** Location leadingDetachedComments. */ + public leadingDetachedComments: string[]; + + /** + * Creates a Location message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Location + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.SourceCodeInfo.Location; + + /** + * Creates a plain object from a Location message. Also converts values to other types if specified. + * @param message Location + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.SourceCodeInfo.Location, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Location to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a GeneratedCodeInfo. */ + interface IGeneratedCodeInfo { + + /** GeneratedCodeInfo annotation */ + annotation?: (google.protobuf.GeneratedCodeInfo.IAnnotation[]|null); + } + + /** Represents a GeneratedCodeInfo. */ + class GeneratedCodeInfo implements IGeneratedCodeInfo { + + /** + * Constructs a new GeneratedCodeInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IGeneratedCodeInfo); + + /** GeneratedCodeInfo annotation. */ + public annotation: google.protobuf.GeneratedCodeInfo.IAnnotation[]; + + /** + * Creates a GeneratedCodeInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GeneratedCodeInfo + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.GeneratedCodeInfo; + + /** + * Creates a plain object from a GeneratedCodeInfo message. Also converts values to other types if specified. + * @param message GeneratedCodeInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.GeneratedCodeInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GeneratedCodeInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace GeneratedCodeInfo { + + /** Properties of an Annotation. */ + interface IAnnotation { + + /** Annotation path */ + path?: (number[]|null); + + /** Annotation sourceFile */ + sourceFile?: (string|null); + + /** Annotation begin */ + begin?: (number|null); + + /** Annotation end */ + end?: (number|null); + } + + /** Represents an Annotation. */ + class Annotation implements IAnnotation { + + /** + * Constructs a new Annotation. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.GeneratedCodeInfo.IAnnotation); + + /** Annotation path. */ + public path: number[]; + + /** Annotation sourceFile. */ + public sourceFile: string; + + /** Annotation begin. */ + public begin: number; + + /** Annotation end. */ + public end: number; + + /** + * Creates an Annotation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Annotation + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.GeneratedCodeInfo.Annotation; + + /** + * Creates a plain object from an Annotation message. Also converts values to other types if specified. + * @param message Annotation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.GeneratedCodeInfo.Annotation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Annotation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a Struct. */ + interface IStruct { + + /** Struct fields */ + fields?: ({ [k: string]: google.protobuf.IValue }|null); + } + + /** Represents a Struct. */ + class Struct implements IStruct { + + /** + * Constructs a new Struct. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IStruct); + + /** Struct fields. */ + public fields: { [k: string]: google.protobuf.IValue }; + + /** + * Creates a Struct message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Struct + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Struct; + + /** + * Creates a plain object from a Struct message. Also converts values to other types if specified. + * @param message Struct + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Struct, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Struct to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Value. */ + interface IValue { + + /** Value nullValue */ + nullValue?: (google.protobuf.NullValue|null); + + /** Value numberValue */ + numberValue?: (number|null); + + /** Value stringValue */ + stringValue?: (string|null); + + /** Value boolValue */ + boolValue?: (boolean|null); + + /** Value structValue */ + structValue?: (google.protobuf.IStruct|null); + + /** Value listValue */ + listValue?: (google.protobuf.IListValue|null); + } + + /** Represents a Value. */ + class Value implements IValue { + + /** + * Constructs a new Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IValue); + + /** Value nullValue. */ + public nullValue: google.protobuf.NullValue; + + /** Value numberValue. */ + public numberValue: number; + + /** Value stringValue. */ + public stringValue: string; + + /** Value boolValue. */ + public boolValue: boolean; + + /** Value structValue. */ + public structValue?: (google.protobuf.IStruct|null); + + /** Value listValue. */ + public listValue?: (google.protobuf.IListValue|null); + + /** Value kind. */ + public kind?: ("nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"); + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Value; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @param message Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** NullValue enum. */ + type NullValue = + "NULL_VALUE"; + + /** Properties of a ListValue. */ + interface IListValue { + + /** ListValue values */ + values?: (google.protobuf.IValue[]|null); + } + + /** Represents a ListValue. */ + class ListValue implements IListValue { + + /** + * Constructs a new ListValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IListValue); + + /** ListValue values. */ + public values: google.protobuf.IValue[]; + + /** + * Creates a ListValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ListValue; + + /** + * Creates a plain object from a ListValue message. Also converts values to other types if specified. + * @param message ListValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ListValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an Empty. */ + interface IEmpty { + } + + /** Represents an Empty. */ + class Empty implements IEmpty { + + /** + * Constructs a new Empty. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEmpty); + + /** + * Creates an Empty message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Empty + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Empty; + + /** + * Creates a plain object from an Empty message. Also converts values to other types if specified. + * @param message Empty + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Empty, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Empty to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DoubleValue. */ + interface IDoubleValue { + + /** DoubleValue value */ + value?: (number|null); + } + + /** Represents a DoubleValue. */ + class DoubleValue implements IDoubleValue { + + /** + * Constructs a new DoubleValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDoubleValue); + + /** DoubleValue value. */ + public value: number; + + /** + * Creates a DoubleValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DoubleValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DoubleValue; + + /** + * Creates a plain object from a DoubleValue message. Also converts values to other types if specified. + * @param message DoubleValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DoubleValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DoubleValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FloatValue. */ + interface IFloatValue { + + /** FloatValue value */ + value?: (number|null); + } + + /** Represents a FloatValue. */ + class FloatValue implements IFloatValue { + + /** + * Constructs a new FloatValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFloatValue); + + /** FloatValue value. */ + public value: number; + + /** + * Creates a FloatValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FloatValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FloatValue; + + /** + * Creates a plain object from a FloatValue message. Also converts values to other types if specified. + * @param message FloatValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FloatValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FloatValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an Int64Value. */ + interface IInt64Value { + + /** Int64Value value */ + value?: (number|string|null); + } + + /** Represents an Int64Value. */ + class Int64Value implements IInt64Value { + + /** + * Constructs a new Int64Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IInt64Value); + + /** Int64Value value. */ + public value: (number|string); + + /** + * Creates an Int64Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Int64Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Int64Value; + + /** + * Creates a plain object from an Int64Value message. Also converts values to other types if specified. + * @param message Int64Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Int64Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Int64Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a UInt64Value. */ + interface IUInt64Value { + + /** UInt64Value value */ + value?: (number|string|null); + } + + /** Represents a UInt64Value. */ + class UInt64Value implements IUInt64Value { + + /** + * Constructs a new UInt64Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUInt64Value); + + /** UInt64Value value. */ + public value: (number|string); + + /** + * Creates a UInt64Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UInt64Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UInt64Value; + + /** + * Creates a plain object from a UInt64Value message. Also converts values to other types if specified. + * @param message UInt64Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UInt64Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UInt64Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an Int32Value. */ + interface IInt32Value { + + /** Int32Value value */ + value?: (number|null); + } + + /** Represents an Int32Value. */ + class Int32Value implements IInt32Value { + + /** + * Constructs a new Int32Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IInt32Value); + + /** Int32Value value. */ + public value: number; + + /** + * Creates an Int32Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Int32Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Int32Value; + + /** + * Creates a plain object from an Int32Value message. Also converts values to other types if specified. + * @param message Int32Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Int32Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Int32Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a UInt32Value. */ + interface IUInt32Value { + + /** UInt32Value value */ + value?: (number|null); + } + + /** Represents a UInt32Value. */ + class UInt32Value implements IUInt32Value { + + /** + * Constructs a new UInt32Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUInt32Value); + + /** UInt32Value value. */ + public value: number; + + /** + * Creates a UInt32Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UInt32Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UInt32Value; + + /** + * Creates a plain object from a UInt32Value message. Also converts values to other types if specified. + * @param message UInt32Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UInt32Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UInt32Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BoolValue. */ + interface IBoolValue { + + /** BoolValue value */ + value?: (boolean|null); + } + + /** Represents a BoolValue. */ + class BoolValue implements IBoolValue { + + /** + * Constructs a new BoolValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IBoolValue); + + /** BoolValue value. */ + public value: boolean; + + /** + * Creates a BoolValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BoolValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.BoolValue; + + /** + * Creates a plain object from a BoolValue message. Also converts values to other types if specified. + * @param message BoolValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.BoolValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BoolValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a StringValue. */ + interface IStringValue { + + /** StringValue value */ + value?: (string|null); + } + + /** Represents a StringValue. */ + class StringValue implements IStringValue { + + /** + * Constructs a new StringValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IStringValue); + + /** StringValue value. */ + public value: string; + + /** + * Creates a StringValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StringValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.StringValue; + + /** + * Creates a plain object from a StringValue message. Also converts values to other types if specified. + * @param message StringValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.StringValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StringValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BytesValue. */ + interface IBytesValue { + + /** BytesValue value */ + value?: (Uint8Array|null); + } + + /** Represents a BytesValue. */ + class BytesValue implements IBytesValue { + + /** + * Constructs a new BytesValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IBytesValue); + + /** BytesValue value. */ + public value: Uint8Array; + + /** + * Creates a BytesValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BytesValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.BytesValue; + + /** + * Creates a plain object from a BytesValue message. Also converts values to other types if specified. + * @param message BytesValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.BytesValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BytesValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an Any. */ + interface IAny { + + /** Any type_url */ + type_url?: (string|null); + + /** Any value */ + value?: (Uint8Array|null); + } + + /** Represents an Any. */ + class Any implements IAny { + + /** + * Constructs a new Any. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IAny); + + /** Any type_url. */ + public type_url: string; + + /** Any value. */ + public value: Uint8Array; + + /** + * Creates an Any message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Any + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Any; + + /** + * Creates a plain object from an Any message. Also converts values to other types if specified. + * @param message Any + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Any, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Any to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FieldMask. */ + interface IFieldMask { + + /** FieldMask paths */ + paths?: (string[]|null); + } + + /** Represents a FieldMask. */ + class FieldMask implements IFieldMask { + + /** + * Constructs a new FieldMask. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldMask); + + /** FieldMask paths. */ + public paths: string[]; + + /** + * Creates a FieldMask message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldMask + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldMask; + + /** + * Creates a plain object from a FieldMask message. Also converts values to other types if specified. + * @param message FieldMask + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldMask, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldMask to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Duration. */ + interface IDuration { + + /** Duration seconds */ + seconds?: (number|string|null); + + /** Duration nanos */ + nanos?: (number|null); + } + + /** Represents a Duration. */ + class Duration implements IDuration { + + /** + * Constructs a new Duration. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDuration); + + /** Duration seconds. */ + public seconds: (number|string); + + /** Duration nanos. */ + public nanos: number; + + /** + * Creates a Duration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Duration + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Duration; + + /** + * Creates a plain object from a Duration message. Also converts values to other types if specified. + * @param message Duration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Duration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Duration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Namespace firestore. */ + namespace firestore { + + /** Namespace v1beta1. */ + namespace v1beta1 { + + /** Properties of a DocumentMask. */ + interface IDocumentMask { + + /** DocumentMask fieldPaths */ + fieldPaths?: (string[]|null); + } + + /** Represents a DocumentMask. */ + class DocumentMask implements IDocumentMask { + + /** + * Constructs a new DocumentMask. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IDocumentMask); + + /** DocumentMask fieldPaths. */ + public fieldPaths: string[]; + + /** + * Creates a DocumentMask message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentMask + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.DocumentMask; + + /** + * Creates a plain object from a DocumentMask message. Also converts values to other types if specified. + * @param message DocumentMask + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.DocumentMask, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentMask to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Precondition. */ + interface IPrecondition { + + /** Precondition exists */ + exists?: (boolean|null); + + /** Precondition updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a Precondition. */ + class Precondition implements IPrecondition { + + /** + * Constructs a new Precondition. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IPrecondition); + + /** Precondition exists. */ + public exists: boolean; + + /** Precondition updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** Precondition conditionType. */ + public conditionType?: ("exists"|"updateTime"); + + /** + * Creates a Precondition message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Precondition + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.Precondition; + + /** + * Creates a plain object from a Precondition message. Also converts values to other types if specified. + * @param message Precondition + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.Precondition, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Precondition to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a TransactionOptions. */ + interface ITransactionOptions { + + /** TransactionOptions readOnly */ + readOnly?: (google.firestore.v1beta1.TransactionOptions.IReadOnly|null); + + /** TransactionOptions readWrite */ + readWrite?: (google.firestore.v1beta1.TransactionOptions.IReadWrite|null); + } + + /** Represents a TransactionOptions. */ + class TransactionOptions implements ITransactionOptions { + + /** + * Constructs a new TransactionOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.ITransactionOptions); + + /** TransactionOptions readOnly. */ + public readOnly?: (google.firestore.v1beta1.TransactionOptions.IReadOnly|null); + + /** TransactionOptions readWrite. */ + public readWrite?: (google.firestore.v1beta1.TransactionOptions.IReadWrite|null); + + /** TransactionOptions mode. */ + public mode?: ("readOnly"|"readWrite"); + + /** + * Creates a TransactionOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TransactionOptions + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.TransactionOptions; + + /** + * Creates a plain object from a TransactionOptions message. Also converts values to other types if specified. + * @param message TransactionOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.TransactionOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TransactionOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace TransactionOptions { + + /** Properties of a ReadWrite. */ + interface IReadWrite { + + /** ReadWrite retryTransaction */ + retryTransaction?: (Uint8Array|null); + } + + /** Represents a ReadWrite. */ + class ReadWrite implements IReadWrite { + + /** + * Constructs a new ReadWrite. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.TransactionOptions.IReadWrite); + + /** ReadWrite retryTransaction. */ + public retryTransaction: Uint8Array; + + /** + * Creates a ReadWrite message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReadWrite + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.TransactionOptions.ReadWrite; + + /** + * Creates a plain object from a ReadWrite message. Also converts values to other types if specified. + * @param message ReadWrite + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.TransactionOptions.ReadWrite, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReadWrite to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ReadOnly. */ + interface IReadOnly { + + /** ReadOnly readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a ReadOnly. */ + class ReadOnly implements IReadOnly { + + /** + * Constructs a new ReadOnly. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.TransactionOptions.IReadOnly); + + /** ReadOnly readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** ReadOnly consistencySelector. */ + public consistencySelector?: "readTime"; + + /** + * Creates a ReadOnly message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReadOnly + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.TransactionOptions.ReadOnly; + + /** + * Creates a plain object from a ReadOnly message. Also converts values to other types if specified. + * @param message ReadOnly + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.TransactionOptions.ReadOnly, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReadOnly to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a Document. */ + interface IDocument { + + /** Document name */ + name?: (string|null); + + /** Document fields */ + fields?: ({ [k: string]: google.firestore.v1beta1.IValue }|null); + + /** Document createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** Document updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a Document. */ + class Document implements IDocument { + + /** + * Constructs a new Document. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IDocument); + + /** Document name. */ + public name: string; + + /** Document fields. */ + public fields: { [k: string]: google.firestore.v1beta1.IValue }; + + /** Document createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** Document updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a Document message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Document + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.Document; + + /** + * Creates a plain object from a Document message. Also converts values to other types if specified. + * @param message Document + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.Document, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Document to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Value. */ + interface IValue { + + /** Value nullValue */ + nullValue?: (google.protobuf.NullValue|null); + + /** Value booleanValue */ + booleanValue?: (boolean|null); + + /** Value integerValue */ + integerValue?: (number|string|null); + + /** Value doubleValue */ + doubleValue?: (number|null); + + /** Value timestampValue */ + timestampValue?: (google.protobuf.ITimestamp|null); + + /** Value stringValue */ + stringValue?: (string|null); + + /** Value bytesValue */ + bytesValue?: (Uint8Array|null); + + /** Value referenceValue */ + referenceValue?: (string|null); + + /** Value geoPointValue */ + geoPointValue?: (google.type.ILatLng|null); + + /** Value arrayValue */ + arrayValue?: (google.firestore.v1beta1.IArrayValue|null); + + /** Value mapValue */ + mapValue?: (google.firestore.v1beta1.IMapValue|null); + } + + /** Represents a Value. */ + class Value implements IValue { + + /** + * Constructs a new Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IValue); + + /** Value nullValue. */ + public nullValue: google.protobuf.NullValue; + + /** Value booleanValue. */ + public booleanValue: boolean; + + /** Value integerValue. */ + public integerValue: (number|string); + + /** Value doubleValue. */ + public doubleValue: number; + + /** Value timestampValue. */ + public timestampValue?: (google.protobuf.ITimestamp|null); + + /** Value stringValue. */ + public stringValue: string; + + /** Value bytesValue. */ + public bytesValue: Uint8Array; + + /** Value referenceValue. */ + public referenceValue: string; + + /** Value geoPointValue. */ + public geoPointValue?: (google.type.ILatLng|null); + + /** Value arrayValue. */ + public arrayValue?: (google.firestore.v1beta1.IArrayValue|null); + + /** Value mapValue. */ + public mapValue?: (google.firestore.v1beta1.IMapValue|null); + + /** Value valueType. */ + public valueType?: ("nullValue"|"booleanValue"|"integerValue"|"doubleValue"|"timestampValue"|"stringValue"|"bytesValue"|"referenceValue"|"geoPointValue"|"arrayValue"|"mapValue"); + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Value + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.Value; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @param message Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an ArrayValue. */ + interface IArrayValue { + + /** ArrayValue values */ + values?: (google.firestore.v1beta1.IValue[]|null); + } + + /** Represents an ArrayValue. */ + class ArrayValue implements IArrayValue { + + /** + * Constructs a new ArrayValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IArrayValue); + + /** ArrayValue values. */ + public values: google.firestore.v1beta1.IValue[]; + + /** + * Creates an ArrayValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ArrayValue + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.ArrayValue; + + /** + * Creates a plain object from an ArrayValue message. Also converts values to other types if specified. + * @param message ArrayValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.ArrayValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ArrayValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a MapValue. */ + interface IMapValue { + + /** MapValue fields */ + fields?: ({ [k: string]: google.firestore.v1beta1.IValue }|null); + } + + /** Represents a MapValue. */ + class MapValue implements IMapValue { + + /** + * Constructs a new MapValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IMapValue); + + /** MapValue fields. */ + public fields: { [k: string]: google.firestore.v1beta1.IValue }; + + /** + * Creates a MapValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MapValue + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.MapValue; + + /** + * Creates a plain object from a MapValue message. Also converts values to other types if specified. + * @param message MapValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.MapValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MapValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Represents a Firestore */ + class Firestore extends $protobuf.rpc.Service { + + /** + * Constructs a new Firestore service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Calls GetDocument. + * @param request GetDocumentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Document + */ + public getDocument(request: google.firestore.v1beta1.IGetDocumentRequest, callback: google.firestore.v1beta1.Firestore.GetDocumentCallback): void; + + /** + * Calls GetDocument. + * @param request GetDocumentRequest message or plain object + * @returns Promise + */ + public getDocument(request: google.firestore.v1beta1.IGetDocumentRequest): Promise; + + /** + * Calls ListDocuments. + * @param request ListDocumentsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListDocumentsResponse + */ + public listDocuments(request: google.firestore.v1beta1.IListDocumentsRequest, callback: google.firestore.v1beta1.Firestore.ListDocumentsCallback): void; + + /** + * Calls ListDocuments. + * @param request ListDocumentsRequest message or plain object + * @returns Promise + */ + public listDocuments(request: google.firestore.v1beta1.IListDocumentsRequest): Promise; + + /** + * Calls CreateDocument. + * @param request CreateDocumentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Document + */ + public createDocument(request: google.firestore.v1beta1.ICreateDocumentRequest, callback: google.firestore.v1beta1.Firestore.CreateDocumentCallback): void; + + /** + * Calls CreateDocument. + * @param request CreateDocumentRequest message or plain object + * @returns Promise + */ + public createDocument(request: google.firestore.v1beta1.ICreateDocumentRequest): Promise; + + /** + * Calls UpdateDocument. + * @param request UpdateDocumentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Document + */ + public updateDocument(request: google.firestore.v1beta1.IUpdateDocumentRequest, callback: google.firestore.v1beta1.Firestore.UpdateDocumentCallback): void; + + /** + * Calls UpdateDocument. + * @param request UpdateDocumentRequest message or plain object + * @returns Promise + */ + public updateDocument(request: google.firestore.v1beta1.IUpdateDocumentRequest): Promise; + + /** + * Calls DeleteDocument. + * @param request DeleteDocumentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteDocument(request: google.firestore.v1beta1.IDeleteDocumentRequest, callback: google.firestore.v1beta1.Firestore.DeleteDocumentCallback): void; + + /** + * Calls DeleteDocument. + * @param request DeleteDocumentRequest message or plain object + * @returns Promise + */ + public deleteDocument(request: google.firestore.v1beta1.IDeleteDocumentRequest): Promise; + + /** + * Calls BatchGetDocuments. + * @param request BatchGetDocumentsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and BatchGetDocumentsResponse + */ + public batchGetDocuments(request: google.firestore.v1beta1.IBatchGetDocumentsRequest, callback: google.firestore.v1beta1.Firestore.BatchGetDocumentsCallback): void; + + /** + * Calls BatchGetDocuments. + * @param request BatchGetDocumentsRequest message or plain object + * @returns Promise + */ + public batchGetDocuments(request: google.firestore.v1beta1.IBatchGetDocumentsRequest): Promise; + + /** + * Calls BeginTransaction. + * @param request BeginTransactionRequest message or plain object + * @param callback Node-style callback called with the error, if any, and BeginTransactionResponse + */ + public beginTransaction(request: google.firestore.v1beta1.IBeginTransactionRequest, callback: google.firestore.v1beta1.Firestore.BeginTransactionCallback): void; + + /** + * Calls BeginTransaction. + * @param request BeginTransactionRequest message or plain object + * @returns Promise + */ + public beginTransaction(request: google.firestore.v1beta1.IBeginTransactionRequest): Promise; + + /** + * Calls Commit. + * @param request CommitRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CommitResponse + */ + public commit(request: google.firestore.v1beta1.ICommitRequest, callback: google.firestore.v1beta1.Firestore.CommitCallback): void; + + /** + * Calls Commit. + * @param request CommitRequest message or plain object + * @returns Promise + */ + public commit(request: google.firestore.v1beta1.ICommitRequest): Promise; + + /** + * Calls Rollback. + * @param request RollbackRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public rollback(request: google.firestore.v1beta1.IRollbackRequest, callback: google.firestore.v1beta1.Firestore.RollbackCallback): void; + + /** + * Calls Rollback. + * @param request RollbackRequest message or plain object + * @returns Promise + */ + public rollback(request: google.firestore.v1beta1.IRollbackRequest): Promise; + + /** + * Calls RunQuery. + * @param request RunQueryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and RunQueryResponse + */ + public runQuery(request: google.firestore.v1beta1.IRunQueryRequest, callback: google.firestore.v1beta1.Firestore.RunQueryCallback): void; + + /** + * Calls RunQuery. + * @param request RunQueryRequest message or plain object + * @returns Promise + */ + public runQuery(request: google.firestore.v1beta1.IRunQueryRequest): Promise; + + /** + * Calls Write. + * @param request WriteRequest message or plain object + * @param callback Node-style callback called with the error, if any, and WriteResponse + */ + public write(request: google.firestore.v1beta1.IWriteRequest, callback: google.firestore.v1beta1.Firestore.WriteCallback): void; + + /** + * Calls Write. + * @param request WriteRequest message or plain object + * @returns Promise + */ + public write(request: google.firestore.v1beta1.IWriteRequest): Promise; + + /** + * Calls Listen. + * @param request ListenRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListenResponse + */ + public listen(request: google.firestore.v1beta1.IListenRequest, callback: google.firestore.v1beta1.Firestore.ListenCallback): void; + + /** + * Calls Listen. + * @param request ListenRequest message or plain object + * @returns Promise + */ + public listen(request: google.firestore.v1beta1.IListenRequest): Promise; + + /** + * Calls ListCollectionIds. + * @param request ListCollectionIdsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListCollectionIdsResponse + */ + public listCollectionIds(request: google.firestore.v1beta1.IListCollectionIdsRequest, callback: google.firestore.v1beta1.Firestore.ListCollectionIdsCallback): void; + + /** + * Calls ListCollectionIds. + * @param request ListCollectionIdsRequest message or plain object + * @returns Promise + */ + public listCollectionIds(request: google.firestore.v1beta1.IListCollectionIdsRequest): Promise; + } + + namespace Firestore { + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#getDocument}. + * @param error Error, if any + * @param [response] Document + */ + type GetDocumentCallback = (error: (Error|null), response?: google.firestore.v1beta1.Document) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#listDocuments}. + * @param error Error, if any + * @param [response] ListDocumentsResponse + */ + type ListDocumentsCallback = (error: (Error|null), response?: google.firestore.v1beta1.ListDocumentsResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#createDocument}. + * @param error Error, if any + * @param [response] Document + */ + type CreateDocumentCallback = (error: (Error|null), response?: google.firestore.v1beta1.Document) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#updateDocument}. + * @param error Error, if any + * @param [response] Document + */ + type UpdateDocumentCallback = (error: (Error|null), response?: google.firestore.v1beta1.Document) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#deleteDocument}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteDocumentCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#batchGetDocuments}. + * @param error Error, if any + * @param [response] BatchGetDocumentsResponse + */ + type BatchGetDocumentsCallback = (error: (Error|null), response?: google.firestore.v1beta1.BatchGetDocumentsResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#beginTransaction}. + * @param error Error, if any + * @param [response] BeginTransactionResponse + */ + type BeginTransactionCallback = (error: (Error|null), response?: google.firestore.v1beta1.BeginTransactionResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#commit}. + * @param error Error, if any + * @param [response] CommitResponse + */ + type CommitCallback = (error: (Error|null), response?: google.firestore.v1beta1.CommitResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#rollback}. + * @param error Error, if any + * @param [response] Empty + */ + type RollbackCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#runQuery}. + * @param error Error, if any + * @param [response] RunQueryResponse + */ + type RunQueryCallback = (error: (Error|null), response?: google.firestore.v1beta1.RunQueryResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#write}. + * @param error Error, if any + * @param [response] WriteResponse + */ + type WriteCallback = (error: (Error|null), response?: google.firestore.v1beta1.WriteResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#listen}. + * @param error Error, if any + * @param [response] ListenResponse + */ + type ListenCallback = (error: (Error|null), response?: google.firestore.v1beta1.ListenResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#listCollectionIds}. + * @param error Error, if any + * @param [response] ListCollectionIdsResponse + */ + type ListCollectionIdsCallback = (error: (Error|null), response?: google.firestore.v1beta1.ListCollectionIdsResponse) => void; + } + + /** Properties of a GetDocumentRequest. */ + interface IGetDocumentRequest { + + /** GetDocumentRequest name */ + name?: (string|null); + + /** GetDocumentRequest mask */ + mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** GetDocumentRequest transaction */ + transaction?: (Uint8Array|null); + + /** GetDocumentRequest readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a GetDocumentRequest. */ + class GetDocumentRequest implements IGetDocumentRequest { + + /** + * Constructs a new GetDocumentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IGetDocumentRequest); + + /** GetDocumentRequest name. */ + public name: string; + + /** GetDocumentRequest mask. */ + public mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** GetDocumentRequest transaction. */ + public transaction: Uint8Array; + + /** GetDocumentRequest readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** GetDocumentRequest consistencySelector. */ + public consistencySelector?: ("transaction"|"readTime"); + + /** + * Creates a GetDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.GetDocumentRequest; + + /** + * Creates a plain object from a GetDocumentRequest message. Also converts values to other types if specified. + * @param message GetDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.GetDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetDocumentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListDocumentsRequest. */ + interface IListDocumentsRequest { + + /** ListDocumentsRequest parent */ + parent?: (string|null); + + /** ListDocumentsRequest collectionId */ + collectionId?: (string|null); + + /** ListDocumentsRequest pageSize */ + pageSize?: (number|null); + + /** ListDocumentsRequest pageToken */ + pageToken?: (string|null); + + /** ListDocumentsRequest orderBy */ + orderBy?: (string|null); + + /** ListDocumentsRequest mask */ + mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** ListDocumentsRequest transaction */ + transaction?: (Uint8Array|null); + + /** ListDocumentsRequest readTime */ + readTime?: (google.protobuf.ITimestamp|null); + + /** ListDocumentsRequest showMissing */ + showMissing?: (boolean|null); + } + + /** Represents a ListDocumentsRequest. */ + class ListDocumentsRequest implements IListDocumentsRequest { + + /** + * Constructs a new ListDocumentsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IListDocumentsRequest); + + /** ListDocumentsRequest parent. */ + public parent: string; + + /** ListDocumentsRequest collectionId. */ + public collectionId: string; + + /** ListDocumentsRequest pageSize. */ + public pageSize: number; + + /** ListDocumentsRequest pageToken. */ + public pageToken: string; + + /** ListDocumentsRequest orderBy. */ + public orderBy: string; + + /** ListDocumentsRequest mask. */ + public mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** ListDocumentsRequest transaction. */ + public transaction: Uint8Array; + + /** ListDocumentsRequest readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** ListDocumentsRequest showMissing. */ + public showMissing: boolean; + + /** ListDocumentsRequest consistencySelector. */ + public consistencySelector?: ("transaction"|"readTime"); + + /** + * Creates a ListDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListDocumentsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.ListDocumentsRequest; + + /** + * Creates a plain object from a ListDocumentsRequest message. Also converts values to other types if specified. + * @param message ListDocumentsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.ListDocumentsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListDocumentsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListDocumentsResponse. */ + interface IListDocumentsResponse { + + /** ListDocumentsResponse documents */ + documents?: (google.firestore.v1beta1.IDocument[]|null); + + /** ListDocumentsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListDocumentsResponse. */ + class ListDocumentsResponse implements IListDocumentsResponse { + + /** + * Constructs a new ListDocumentsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IListDocumentsResponse); + + /** ListDocumentsResponse documents. */ + public documents: google.firestore.v1beta1.IDocument[]; + + /** ListDocumentsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a ListDocumentsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListDocumentsResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.ListDocumentsResponse; + + /** + * Creates a plain object from a ListDocumentsResponse message. Also converts values to other types if specified. + * @param message ListDocumentsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.ListDocumentsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListDocumentsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CreateDocumentRequest. */ + interface ICreateDocumentRequest { + + /** CreateDocumentRequest parent */ + parent?: (string|null); + + /** CreateDocumentRequest collectionId */ + collectionId?: (string|null); + + /** CreateDocumentRequest documentId */ + documentId?: (string|null); + + /** CreateDocumentRequest document */ + document?: (google.firestore.v1beta1.IDocument|null); + + /** CreateDocumentRequest mask */ + mask?: (google.firestore.v1beta1.IDocumentMask|null); + } + + /** Represents a CreateDocumentRequest. */ + class CreateDocumentRequest implements ICreateDocumentRequest { + + /** + * Constructs a new CreateDocumentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.ICreateDocumentRequest); + + /** CreateDocumentRequest parent. */ + public parent: string; + + /** CreateDocumentRequest collectionId. */ + public collectionId: string; + + /** CreateDocumentRequest documentId. */ + public documentId: string; + + /** CreateDocumentRequest document. */ + public document?: (google.firestore.v1beta1.IDocument|null); + + /** CreateDocumentRequest mask. */ + public mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** + * Creates a CreateDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.CreateDocumentRequest; + + /** + * Creates a plain object from a CreateDocumentRequest message. Also converts values to other types if specified. + * @param message CreateDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.CreateDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateDocumentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an UpdateDocumentRequest. */ + interface IUpdateDocumentRequest { + + /** UpdateDocumentRequest document */ + document?: (google.firestore.v1beta1.IDocument|null); + + /** UpdateDocumentRequest updateMask */ + updateMask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** UpdateDocumentRequest mask */ + mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** UpdateDocumentRequest currentDocument */ + currentDocument?: (google.firestore.v1beta1.IPrecondition|null); + } + + /** Represents an UpdateDocumentRequest. */ + class UpdateDocumentRequest implements IUpdateDocumentRequest { + + /** + * Constructs a new UpdateDocumentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IUpdateDocumentRequest); + + /** UpdateDocumentRequest document. */ + public document?: (google.firestore.v1beta1.IDocument|null); + + /** UpdateDocumentRequest updateMask. */ + public updateMask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** UpdateDocumentRequest mask. */ + public mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** UpdateDocumentRequest currentDocument. */ + public currentDocument?: (google.firestore.v1beta1.IPrecondition|null); + + /** + * Creates an UpdateDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.UpdateDocumentRequest; + + /** + * Creates a plain object from an UpdateDocumentRequest message. Also converts values to other types if specified. + * @param message UpdateDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.UpdateDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateDocumentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DeleteDocumentRequest. */ + interface IDeleteDocumentRequest { + + /** DeleteDocumentRequest name */ + name?: (string|null); + + /** DeleteDocumentRequest currentDocument */ + currentDocument?: (google.firestore.v1beta1.IPrecondition|null); + } + + /** Represents a DeleteDocumentRequest. */ + class DeleteDocumentRequest implements IDeleteDocumentRequest { + + /** + * Constructs a new DeleteDocumentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IDeleteDocumentRequest); + + /** DeleteDocumentRequest name. */ + public name: string; + + /** DeleteDocumentRequest currentDocument. */ + public currentDocument?: (google.firestore.v1beta1.IPrecondition|null); + + /** + * Creates a DeleteDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.DeleteDocumentRequest; + + /** + * Creates a plain object from a DeleteDocumentRequest message. Also converts values to other types if specified. + * @param message DeleteDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.DeleteDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteDocumentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BatchGetDocumentsRequest. */ + interface IBatchGetDocumentsRequest { + + /** BatchGetDocumentsRequest database */ + database?: (string|null); + + /** BatchGetDocumentsRequest documents */ + documents?: (string[]|null); + + /** BatchGetDocumentsRequest mask */ + mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** BatchGetDocumentsRequest transaction */ + transaction?: (Uint8Array|null); + + /** BatchGetDocumentsRequest newTransaction */ + newTransaction?: (google.firestore.v1beta1.ITransactionOptions|null); + + /** BatchGetDocumentsRequest readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a BatchGetDocumentsRequest. */ + class BatchGetDocumentsRequest implements IBatchGetDocumentsRequest { + + /** + * Constructs a new BatchGetDocumentsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IBatchGetDocumentsRequest); + + /** BatchGetDocumentsRequest database. */ + public database: string; + + /** BatchGetDocumentsRequest documents. */ + public documents: string[]; + + /** BatchGetDocumentsRequest mask. */ + public mask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** BatchGetDocumentsRequest transaction. */ + public transaction: Uint8Array; + + /** BatchGetDocumentsRequest newTransaction. */ + public newTransaction?: (google.firestore.v1beta1.ITransactionOptions|null); + + /** BatchGetDocumentsRequest readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** BatchGetDocumentsRequest consistencySelector. */ + public consistencySelector?: ("transaction"|"newTransaction"|"readTime"); + + /** + * Creates a BatchGetDocumentsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchGetDocumentsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.BatchGetDocumentsRequest; + + /** + * Creates a plain object from a BatchGetDocumentsRequest message. Also converts values to other types if specified. + * @param message BatchGetDocumentsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.BatchGetDocumentsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchGetDocumentsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BatchGetDocumentsResponse. */ + interface IBatchGetDocumentsResponse { + + /** BatchGetDocumentsResponse found */ + found?: (google.firestore.v1beta1.IDocument|null); + + /** BatchGetDocumentsResponse missing */ + missing?: (string|null); + + /** BatchGetDocumentsResponse transaction */ + transaction?: (Uint8Array|null); + + /** BatchGetDocumentsResponse readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a BatchGetDocumentsResponse. */ + class BatchGetDocumentsResponse implements IBatchGetDocumentsResponse { + + /** + * Constructs a new BatchGetDocumentsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IBatchGetDocumentsResponse); + + /** BatchGetDocumentsResponse found. */ + public found?: (google.firestore.v1beta1.IDocument|null); + + /** BatchGetDocumentsResponse missing. */ + public missing: string; + + /** BatchGetDocumentsResponse transaction. */ + public transaction: Uint8Array; + + /** BatchGetDocumentsResponse readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** BatchGetDocumentsResponse result. */ + public result?: ("found"|"missing"); + + /** + * Creates a BatchGetDocumentsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchGetDocumentsResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.BatchGetDocumentsResponse; + + /** + * Creates a plain object from a BatchGetDocumentsResponse message. Also converts values to other types if specified. + * @param message BatchGetDocumentsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.BatchGetDocumentsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchGetDocumentsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BeginTransactionRequest. */ + interface IBeginTransactionRequest { + + /** BeginTransactionRequest database */ + database?: (string|null); + + /** BeginTransactionRequest options */ + options?: (google.firestore.v1beta1.ITransactionOptions|null); + } + + /** Represents a BeginTransactionRequest. */ + class BeginTransactionRequest implements IBeginTransactionRequest { + + /** + * Constructs a new BeginTransactionRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IBeginTransactionRequest); + + /** BeginTransactionRequest database. */ + public database: string; + + /** BeginTransactionRequest options. */ + public options?: (google.firestore.v1beta1.ITransactionOptions|null); + + /** + * Creates a BeginTransactionRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BeginTransactionRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.BeginTransactionRequest; + + /** + * Creates a plain object from a BeginTransactionRequest message. Also converts values to other types if specified. + * @param message BeginTransactionRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.BeginTransactionRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BeginTransactionRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BeginTransactionResponse. */ + interface IBeginTransactionResponse { + + /** BeginTransactionResponse transaction */ + transaction?: (Uint8Array|null); + } + + /** Represents a BeginTransactionResponse. */ + class BeginTransactionResponse implements IBeginTransactionResponse { + + /** + * Constructs a new BeginTransactionResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IBeginTransactionResponse); + + /** BeginTransactionResponse transaction. */ + public transaction: Uint8Array; + + /** + * Creates a BeginTransactionResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BeginTransactionResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.BeginTransactionResponse; + + /** + * Creates a plain object from a BeginTransactionResponse message. Also converts values to other types if specified. + * @param message BeginTransactionResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.BeginTransactionResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BeginTransactionResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CommitRequest. */ + interface ICommitRequest { + + /** CommitRequest database */ + database?: (string|null); + + /** CommitRequest writes */ + writes?: (google.firestore.v1beta1.IWrite[]|null); + + /** CommitRequest transaction */ + transaction?: (Uint8Array|null); + } + + /** Represents a CommitRequest. */ + class CommitRequest implements ICommitRequest { + + /** + * Constructs a new CommitRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.ICommitRequest); + + /** CommitRequest database. */ + public database: string; + + /** CommitRequest writes. */ + public writes: google.firestore.v1beta1.IWrite[]; + + /** CommitRequest transaction. */ + public transaction: Uint8Array; + + /** + * Creates a CommitRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CommitRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.CommitRequest; + + /** + * Creates a plain object from a CommitRequest message. Also converts values to other types if specified. + * @param message CommitRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.CommitRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CommitRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CommitResponse. */ + interface ICommitResponse { + + /** CommitResponse writeResults */ + writeResults?: (google.firestore.v1beta1.IWriteResult[]|null); + + /** CommitResponse commitTime */ + commitTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a CommitResponse. */ + class CommitResponse implements ICommitResponse { + + /** + * Constructs a new CommitResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.ICommitResponse); + + /** CommitResponse writeResults. */ + public writeResults: google.firestore.v1beta1.IWriteResult[]; + + /** CommitResponse commitTime. */ + public commitTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a CommitResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CommitResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.CommitResponse; + + /** + * Creates a plain object from a CommitResponse message. Also converts values to other types if specified. + * @param message CommitResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.CommitResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CommitResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a RollbackRequest. */ + interface IRollbackRequest { + + /** RollbackRequest database */ + database?: (string|null); + + /** RollbackRequest transaction */ + transaction?: (Uint8Array|null); + } + + /** Represents a RollbackRequest. */ + class RollbackRequest implements IRollbackRequest { + + /** + * Constructs a new RollbackRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IRollbackRequest); + + /** RollbackRequest database. */ + public database: string; + + /** RollbackRequest transaction. */ + public transaction: Uint8Array; + + /** + * Creates a RollbackRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RollbackRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.RollbackRequest; + + /** + * Creates a plain object from a RollbackRequest message. Also converts values to other types if specified. + * @param message RollbackRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.RollbackRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RollbackRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a RunQueryRequest. */ + interface IRunQueryRequest { + + /** RunQueryRequest parent */ + parent?: (string|null); + + /** RunQueryRequest structuredQuery */ + structuredQuery?: (google.firestore.v1beta1.IStructuredQuery|null); + + /** RunQueryRequest transaction */ + transaction?: (Uint8Array|null); + + /** RunQueryRequest newTransaction */ + newTransaction?: (google.firestore.v1beta1.ITransactionOptions|null); + + /** RunQueryRequest readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a RunQueryRequest. */ + class RunQueryRequest implements IRunQueryRequest { + + /** + * Constructs a new RunQueryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IRunQueryRequest); + + /** RunQueryRequest parent. */ + public parent: string; + + /** RunQueryRequest structuredQuery. */ + public structuredQuery?: (google.firestore.v1beta1.IStructuredQuery|null); + + /** RunQueryRequest transaction. */ + public transaction: Uint8Array; + + /** RunQueryRequest newTransaction. */ + public newTransaction?: (google.firestore.v1beta1.ITransactionOptions|null); + + /** RunQueryRequest readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** RunQueryRequest queryType. */ + public queryType?: "structuredQuery"; + + /** RunQueryRequest consistencySelector. */ + public consistencySelector?: ("transaction"|"newTransaction"|"readTime"); + + /** + * Creates a RunQueryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RunQueryRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.RunQueryRequest; + + /** + * Creates a plain object from a RunQueryRequest message. Also converts values to other types if specified. + * @param message RunQueryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.RunQueryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RunQueryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a RunQueryResponse. */ + interface IRunQueryResponse { + + /** RunQueryResponse transaction */ + transaction?: (Uint8Array|null); + + /** RunQueryResponse document */ + document?: (google.firestore.v1beta1.IDocument|null); + + /** RunQueryResponse readTime */ + readTime?: (google.protobuf.ITimestamp|null); + + /** RunQueryResponse skippedResults */ + skippedResults?: (number|null); + } + + /** Represents a RunQueryResponse. */ + class RunQueryResponse implements IRunQueryResponse { + + /** + * Constructs a new RunQueryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IRunQueryResponse); + + /** RunQueryResponse transaction. */ + public transaction: Uint8Array; + + /** RunQueryResponse document. */ + public document?: (google.firestore.v1beta1.IDocument|null); + + /** RunQueryResponse readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** RunQueryResponse skippedResults. */ + public skippedResults: number; + + /** + * Creates a RunQueryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RunQueryResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.RunQueryResponse; + + /** + * Creates a plain object from a RunQueryResponse message. Also converts values to other types if specified. + * @param message RunQueryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.RunQueryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RunQueryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a WriteRequest. */ + interface IWriteRequest { + + /** WriteRequest database */ + database?: (string|null); + + /** WriteRequest streamId */ + streamId?: (string|null); + + /** WriteRequest writes */ + writes?: (google.firestore.v1beta1.IWrite[]|null); + + /** WriteRequest streamToken */ + streamToken?: (Uint8Array|null); + + /** WriteRequest labels */ + labels?: ({ [k: string]: string }|null); + } + + /** Represents a WriteRequest. */ + class WriteRequest implements IWriteRequest { + + /** + * Constructs a new WriteRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IWriteRequest); + + /** WriteRequest database. */ + public database: string; + + /** WriteRequest streamId. */ + public streamId: string; + + /** WriteRequest writes. */ + public writes: google.firestore.v1beta1.IWrite[]; + + /** WriteRequest streamToken. */ + public streamToken: Uint8Array; + + /** WriteRequest labels. */ + public labels: { [k: string]: string }; + + /** + * Creates a WriteRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WriteRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.WriteRequest; + + /** + * Creates a plain object from a WriteRequest message. Also converts values to other types if specified. + * @param message WriteRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.WriteRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WriteRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a WriteResponse. */ + interface IWriteResponse { + + /** WriteResponse streamId */ + streamId?: (string|null); + + /** WriteResponse streamToken */ + streamToken?: (Uint8Array|null); + + /** WriteResponse writeResults */ + writeResults?: (google.firestore.v1beta1.IWriteResult[]|null); + + /** WriteResponse commitTime */ + commitTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a WriteResponse. */ + class WriteResponse implements IWriteResponse { + + /** + * Constructs a new WriteResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IWriteResponse); + + /** WriteResponse streamId. */ + public streamId: string; + + /** WriteResponse streamToken. */ + public streamToken: Uint8Array; + + /** WriteResponse writeResults. */ + public writeResults: google.firestore.v1beta1.IWriteResult[]; + + /** WriteResponse commitTime. */ + public commitTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a WriteResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WriteResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.WriteResponse; + + /** + * Creates a plain object from a WriteResponse message. Also converts values to other types if specified. + * @param message WriteResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.WriteResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WriteResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListenRequest. */ + interface IListenRequest { + + /** ListenRequest database */ + database?: (string|null); + + /** ListenRequest addTarget */ + addTarget?: (google.firestore.v1beta1.ITarget|null); + + /** ListenRequest removeTarget */ + removeTarget?: (number|null); + + /** ListenRequest labels */ + labels?: ({ [k: string]: string }|null); + } + + /** Represents a ListenRequest. */ + class ListenRequest implements IListenRequest { + + /** + * Constructs a new ListenRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IListenRequest); + + /** ListenRequest database. */ + public database: string; + + /** ListenRequest addTarget. */ + public addTarget?: (google.firestore.v1beta1.ITarget|null); + + /** ListenRequest removeTarget. */ + public removeTarget: number; + + /** ListenRequest labels. */ + public labels: { [k: string]: string }; + + /** ListenRequest targetChange. */ + public targetChange?: ("addTarget"|"removeTarget"); + + /** + * Creates a ListenRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListenRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.ListenRequest; + + /** + * Creates a plain object from a ListenRequest message. Also converts values to other types if specified. + * @param message ListenRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.ListenRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListenRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListenResponse. */ + interface IListenResponse { + + /** ListenResponse targetChange */ + targetChange?: (google.firestore.v1beta1.ITargetChange|null); + + /** ListenResponse documentChange */ + documentChange?: (google.firestore.v1beta1.IDocumentChange|null); + + /** ListenResponse documentDelete */ + documentDelete?: (google.firestore.v1beta1.IDocumentDelete|null); + + /** ListenResponse documentRemove */ + documentRemove?: (google.firestore.v1beta1.IDocumentRemove|null); + + /** ListenResponse filter */ + filter?: (google.firestore.v1beta1.IExistenceFilter|null); + } + + /** Represents a ListenResponse. */ + class ListenResponse implements IListenResponse { + + /** + * Constructs a new ListenResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IListenResponse); + + /** ListenResponse targetChange. */ + public targetChange?: (google.firestore.v1beta1.ITargetChange|null); + + /** ListenResponse documentChange. */ + public documentChange?: (google.firestore.v1beta1.IDocumentChange|null); + + /** ListenResponse documentDelete. */ + public documentDelete?: (google.firestore.v1beta1.IDocumentDelete|null); + + /** ListenResponse documentRemove. */ + public documentRemove?: (google.firestore.v1beta1.IDocumentRemove|null); + + /** ListenResponse filter. */ + public filter?: (google.firestore.v1beta1.IExistenceFilter|null); + + /** ListenResponse responseType. */ + public responseType?: ("targetChange"|"documentChange"|"documentDelete"|"documentRemove"|"filter"); + + /** + * Creates a ListenResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListenResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.ListenResponse; + + /** + * Creates a plain object from a ListenResponse message. Also converts values to other types if specified. + * @param message ListenResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.ListenResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListenResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Target. */ + interface ITarget { + + /** Target query */ + query?: (google.firestore.v1beta1.Target.IQueryTarget|null); + + /** Target documents */ + documents?: (google.firestore.v1beta1.Target.IDocumentsTarget|null); + + /** Target resumeToken */ + resumeToken?: (Uint8Array|null); + + /** Target readTime */ + readTime?: (google.protobuf.ITimestamp|null); + + /** Target targetId */ + targetId?: (number|null); + + /** Target once */ + once?: (boolean|null); + } + + /** Represents a Target. */ + class Target implements ITarget { + + /** + * Constructs a new Target. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.ITarget); + + /** Target query. */ + public query?: (google.firestore.v1beta1.Target.IQueryTarget|null); + + /** Target documents. */ + public documents?: (google.firestore.v1beta1.Target.IDocumentsTarget|null); + + /** Target resumeToken. */ + public resumeToken: Uint8Array; + + /** Target readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** Target targetId. */ + public targetId: number; + + /** Target once. */ + public once: boolean; + + /** Target targetType. */ + public targetType?: ("query"|"documents"); + + /** Target resumeType. */ + public resumeType?: ("resumeToken"|"readTime"); + + /** + * Creates a Target message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Target + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.Target; + + /** + * Creates a plain object from a Target message. Also converts values to other types if specified. + * @param message Target + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.Target, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Target to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace Target { + + /** Properties of a DocumentsTarget. */ + interface IDocumentsTarget { + + /** DocumentsTarget documents */ + documents?: (string[]|null); + } + + /** Represents a DocumentsTarget. */ + class DocumentsTarget implements IDocumentsTarget { + + /** + * Constructs a new DocumentsTarget. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.Target.IDocumentsTarget); + + /** DocumentsTarget documents. */ + public documents: string[]; + + /** + * Creates a DocumentsTarget message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentsTarget + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.Target.DocumentsTarget; + + /** + * Creates a plain object from a DocumentsTarget message. Also converts values to other types if specified. + * @param message DocumentsTarget + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.Target.DocumentsTarget, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentsTarget to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a QueryTarget. */ + interface IQueryTarget { + + /** QueryTarget parent */ + parent?: (string|null); + + /** QueryTarget structuredQuery */ + structuredQuery?: (google.firestore.v1beta1.IStructuredQuery|null); + } + + /** Represents a QueryTarget. */ + class QueryTarget implements IQueryTarget { + + /** + * Constructs a new QueryTarget. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.Target.IQueryTarget); + + /** QueryTarget parent. */ + public parent: string; + + /** QueryTarget structuredQuery. */ + public structuredQuery?: (google.firestore.v1beta1.IStructuredQuery|null); + + /** QueryTarget queryType. */ + public queryType?: "structuredQuery"; + + /** + * Creates a QueryTarget message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns QueryTarget + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.Target.QueryTarget; + + /** + * Creates a plain object from a QueryTarget message. Also converts values to other types if specified. + * @param message QueryTarget + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.Target.QueryTarget, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this QueryTarget to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Properties of a TargetChange. */ + interface ITargetChange { + + /** TargetChange targetChangeType */ + targetChangeType?: (google.firestore.v1beta1.TargetChange.TargetChangeType|null); + + /** TargetChange targetIds */ + targetIds?: (number[]|null); + + /** TargetChange cause */ + cause?: (google.rpc.IStatus|null); + + /** TargetChange resumeToken */ + resumeToken?: (Uint8Array|null); + + /** TargetChange readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a TargetChange. */ + class TargetChange implements ITargetChange { + + /** + * Constructs a new TargetChange. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.ITargetChange); + + /** TargetChange targetChangeType. */ + public targetChangeType: google.firestore.v1beta1.TargetChange.TargetChangeType; + + /** TargetChange targetIds. */ + public targetIds: number[]; + + /** TargetChange cause. */ + public cause?: (google.rpc.IStatus|null); + + /** TargetChange resumeToken. */ + public resumeToken: Uint8Array; + + /** TargetChange readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a TargetChange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TargetChange + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.TargetChange; + + /** + * Creates a plain object from a TargetChange message. Also converts values to other types if specified. + * @param message TargetChange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.TargetChange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TargetChange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace TargetChange { + + /** TargetChangeType enum. */ + type TargetChangeType = + "NO_CHANGE"| "ADD"| "REMOVE"| "CURRENT"| "RESET"; + } + + /** Properties of a ListCollectionIdsRequest. */ + interface IListCollectionIdsRequest { + + /** ListCollectionIdsRequest parent */ + parent?: (string|null); + + /** ListCollectionIdsRequest pageSize */ + pageSize?: (number|null); + + /** ListCollectionIdsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListCollectionIdsRequest. */ + class ListCollectionIdsRequest implements IListCollectionIdsRequest { + + /** + * Constructs a new ListCollectionIdsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IListCollectionIdsRequest); + + /** ListCollectionIdsRequest parent. */ + public parent: string; + + /** ListCollectionIdsRequest pageSize. */ + public pageSize: number; + + /** ListCollectionIdsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a ListCollectionIdsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCollectionIdsRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.ListCollectionIdsRequest; + + /** + * Creates a plain object from a ListCollectionIdsRequest message. Also converts values to other types if specified. + * @param message ListCollectionIdsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.ListCollectionIdsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCollectionIdsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListCollectionIdsResponse. */ + interface IListCollectionIdsResponse { + + /** ListCollectionIdsResponse collectionIds */ + collectionIds?: (string[]|null); + + /** ListCollectionIdsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListCollectionIdsResponse. */ + class ListCollectionIdsResponse implements IListCollectionIdsResponse { + + /** + * Constructs a new ListCollectionIdsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IListCollectionIdsResponse); + + /** ListCollectionIdsResponse collectionIds. */ + public collectionIds: string[]; + + /** ListCollectionIdsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a ListCollectionIdsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCollectionIdsResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.ListCollectionIdsResponse; + + /** + * Creates a plain object from a ListCollectionIdsResponse message. Also converts values to other types if specified. + * @param message ListCollectionIdsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.ListCollectionIdsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCollectionIdsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a StructuredQuery. */ + interface IStructuredQuery { + + /** StructuredQuery select */ + select?: (google.firestore.v1beta1.StructuredQuery.IProjection|null); + + /** StructuredQuery from */ + from?: (google.firestore.v1beta1.StructuredQuery.ICollectionSelector[]|null); + + /** StructuredQuery where */ + where?: (google.firestore.v1beta1.StructuredQuery.IFilter|null); + + /** StructuredQuery orderBy */ + orderBy?: (google.firestore.v1beta1.StructuredQuery.IOrder[]|null); + + /** StructuredQuery startAt */ + startAt?: (google.firestore.v1beta1.ICursor|null); + + /** StructuredQuery endAt */ + endAt?: (google.firestore.v1beta1.ICursor|null); + + /** StructuredQuery offset */ + offset?: (number|null); + + /** StructuredQuery limit */ + limit?: (google.protobuf.IInt32Value|null); + } + + /** Represents a StructuredQuery. */ + class StructuredQuery implements IStructuredQuery { + + /** + * Constructs a new StructuredQuery. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IStructuredQuery); + + /** StructuredQuery select. */ + public select?: (google.firestore.v1beta1.StructuredQuery.IProjection|null); + + /** StructuredQuery from. */ + public from: google.firestore.v1beta1.StructuredQuery.ICollectionSelector[]; + + /** StructuredQuery where. */ + public where?: (google.firestore.v1beta1.StructuredQuery.IFilter|null); + + /** StructuredQuery orderBy. */ + public orderBy: google.firestore.v1beta1.StructuredQuery.IOrder[]; + + /** StructuredQuery startAt. */ + public startAt?: (google.firestore.v1beta1.ICursor|null); + + /** StructuredQuery endAt. */ + public endAt?: (google.firestore.v1beta1.ICursor|null); + + /** StructuredQuery offset. */ + public offset: number; + + /** StructuredQuery limit. */ + public limit?: (google.protobuf.IInt32Value|null); + + /** + * Creates a StructuredQuery message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StructuredQuery + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery; + + /** + * Creates a plain object from a StructuredQuery message. Also converts values to other types if specified. + * @param message StructuredQuery + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StructuredQuery to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace StructuredQuery { + + /** Properties of a CollectionSelector. */ + interface ICollectionSelector { + + /** CollectionSelector collectionId */ + collectionId?: (string|null); + + /** CollectionSelector allDescendants */ + allDescendants?: (boolean|null); + } + + /** Represents a CollectionSelector. */ + class CollectionSelector implements ICollectionSelector { + + /** + * Constructs a new CollectionSelector. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.StructuredQuery.ICollectionSelector); + + /** CollectionSelector collectionId. */ + public collectionId: string; + + /** CollectionSelector allDescendants. */ + public allDescendants: boolean; + + /** + * Creates a CollectionSelector message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CollectionSelector + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.CollectionSelector; + + /** + * Creates a plain object from a CollectionSelector message. Also converts values to other types if specified. + * @param message CollectionSelector + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery.CollectionSelector, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CollectionSelector to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Filter. */ + interface IFilter { + + /** Filter compositeFilter */ + compositeFilter?: (google.firestore.v1beta1.StructuredQuery.ICompositeFilter|null); + + /** Filter fieldFilter */ + fieldFilter?: (google.firestore.v1beta1.StructuredQuery.IFieldFilter|null); + + /** Filter unaryFilter */ + unaryFilter?: (google.firestore.v1beta1.StructuredQuery.IUnaryFilter|null); + } + + /** Represents a Filter. */ + class Filter implements IFilter { + + /** + * Constructs a new Filter. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.StructuredQuery.IFilter); + + /** Filter compositeFilter. */ + public compositeFilter?: (google.firestore.v1beta1.StructuredQuery.ICompositeFilter|null); + + /** Filter fieldFilter. */ + public fieldFilter?: (google.firestore.v1beta1.StructuredQuery.IFieldFilter|null); + + /** Filter unaryFilter. */ + public unaryFilter?: (google.firestore.v1beta1.StructuredQuery.IUnaryFilter|null); + + /** Filter filterType. */ + public filterType?: ("compositeFilter"|"fieldFilter"|"unaryFilter"); + + /** + * Creates a Filter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Filter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.Filter; + + /** + * Creates a plain object from a Filter message. Also converts values to other types if specified. + * @param message Filter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery.Filter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Filter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CompositeFilter. */ + interface ICompositeFilter { + + /** CompositeFilter op */ + op?: (google.firestore.v1beta1.StructuredQuery.CompositeFilter.Operator|null); + + /** CompositeFilter filters */ + filters?: (google.firestore.v1beta1.StructuredQuery.IFilter[]|null); + } + + /** Represents a CompositeFilter. */ + class CompositeFilter implements ICompositeFilter { + + /** + * Constructs a new CompositeFilter. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.StructuredQuery.ICompositeFilter); + + /** CompositeFilter op. */ + public op: google.firestore.v1beta1.StructuredQuery.CompositeFilter.Operator; + + /** CompositeFilter filters. */ + public filters: google.firestore.v1beta1.StructuredQuery.IFilter[]; + + /** + * Creates a CompositeFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompositeFilter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.CompositeFilter; + + /** + * Creates a plain object from a CompositeFilter message. Also converts values to other types if specified. + * @param message CompositeFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery.CompositeFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompositeFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace CompositeFilter { + + /** Operator enum. */ + type Operator = + "OPERATOR_UNSPECIFIED"| "AND"; + } + + /** Properties of a FieldFilter. */ + interface IFieldFilter { + + /** FieldFilter field */ + field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + + /** FieldFilter op */ + op?: (google.firestore.v1beta1.StructuredQuery.FieldFilter.Operator|null); + + /** FieldFilter value */ + value?: (google.firestore.v1beta1.IValue|null); + } + + /** Represents a FieldFilter. */ + class FieldFilter implements IFieldFilter { + + /** + * Constructs a new FieldFilter. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.StructuredQuery.IFieldFilter); + + /** FieldFilter field. */ + public field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + + /** FieldFilter op. */ + public op: google.firestore.v1beta1.StructuredQuery.FieldFilter.Operator; + + /** FieldFilter value. */ + public value?: (google.firestore.v1beta1.IValue|null); + + /** + * Creates a FieldFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldFilter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.FieldFilter; + + /** + * Creates a plain object from a FieldFilter message. Also converts values to other types if specified. + * @param message FieldFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery.FieldFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace FieldFilter { + + /** Operator enum. */ + type Operator = + "OPERATOR_UNSPECIFIED"| "LESS_THAN"| "LESS_THAN_OR_EQUAL"| "GREATER_THAN"| "GREATER_THAN_OR_EQUAL"| "EQUAL"| "ARRAY_CONTAINS"| "IN"| "ARRAY_CONTAINS_ANY"; + } + + /** Properties of an UnaryFilter. */ + interface IUnaryFilter { + + /** UnaryFilter op */ + op?: (google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator|null); + + /** UnaryFilter field */ + field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + } + + /** Represents an UnaryFilter. */ + class UnaryFilter implements IUnaryFilter { + + /** + * Constructs a new UnaryFilter. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.StructuredQuery.IUnaryFilter); + + /** UnaryFilter op. */ + public op: google.firestore.v1beta1.StructuredQuery.UnaryFilter.Operator; + + /** UnaryFilter field. */ + public field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + + /** UnaryFilter operandType. */ + public operandType?: "field"; + + /** + * Creates an UnaryFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UnaryFilter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.UnaryFilter; + + /** + * Creates a plain object from an UnaryFilter message. Also converts values to other types if specified. + * @param message UnaryFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery.UnaryFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UnaryFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace UnaryFilter { + + /** Operator enum. */ + type Operator = + "OPERATOR_UNSPECIFIED"| "IS_NAN"| "IS_NULL"; + } + + /** Properties of an Order. */ + interface IOrder { + + /** Order field */ + field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + + /** Order direction */ + direction?: (google.firestore.v1beta1.StructuredQuery.Direction|null); + } + + /** Represents an Order. */ + class Order implements IOrder { + + /** + * Constructs a new Order. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.StructuredQuery.IOrder); + + /** Order field. */ + public field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + + /** Order direction. */ + public direction: google.firestore.v1beta1.StructuredQuery.Direction; + + /** + * Creates an Order message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Order + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.Order; + + /** + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @param message Order + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery.Order, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Order to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a FieldReference. */ + interface IFieldReference { + + /** FieldReference fieldPath */ + fieldPath?: (string|null); + } + + /** Represents a FieldReference. */ + class FieldReference implements IFieldReference { + + /** + * Constructs a new FieldReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.StructuredQuery.IFieldReference); + + /** FieldReference fieldPath. */ + public fieldPath: string; + + /** + * Creates a FieldReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldReference + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.FieldReference; + + /** + * Creates a plain object from a FieldReference message. Also converts values to other types if specified. + * @param message FieldReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery.FieldReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Projection. */ + interface IProjection { + + /** Projection fields */ + fields?: (google.firestore.v1beta1.StructuredQuery.IFieldReference[]|null); + } + + /** Represents a Projection. */ + class Projection implements IProjection { + + /** + * Constructs a new Projection. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.StructuredQuery.IProjection); + + /** Projection fields. */ + public fields: google.firestore.v1beta1.StructuredQuery.IFieldReference[]; + + /** + * Creates a Projection message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Projection + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.Projection; + + /** + * Creates a plain object from a Projection message. Also converts values to other types if specified. + * @param message Projection + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.StructuredQuery.Projection, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Projection to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Direction enum. */ + type Direction = + "DIRECTION_UNSPECIFIED"| "ASCENDING"| "DESCENDING"; + } + + /** Properties of a Cursor. */ + interface ICursor { + + /** Cursor values */ + values?: (google.firestore.v1beta1.IValue[]|null); + + /** Cursor before */ + before?: (boolean|null); + } + + /** Represents a Cursor. */ + class Cursor implements ICursor { + + /** + * Constructs a new Cursor. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.ICursor); + + /** Cursor values. */ + public values: google.firestore.v1beta1.IValue[]; + + /** Cursor before. */ + public before: boolean; + + /** + * Creates a Cursor message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Cursor + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.Cursor; + + /** + * Creates a plain object from a Cursor message. Also converts values to other types if specified. + * @param message Cursor + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.Cursor, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Cursor to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Write. */ + interface IWrite { + + /** Write update */ + update?: (google.firestore.v1beta1.IDocument|null); + + /** Write delete */ + "delete"?: (string|null); + + /** Write transform */ + transform?: (google.firestore.v1beta1.IDocumentTransform|null); + + /** Write updateMask */ + updateMask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** Write currentDocument */ + currentDocument?: (google.firestore.v1beta1.IPrecondition|null); + } + + /** Represents a Write. */ + class Write implements IWrite { + + /** + * Constructs a new Write. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IWrite); + + /** Write update. */ + public update?: (google.firestore.v1beta1.IDocument|null); + + /** Write delete. */ + public delete: string; + + /** Write transform. */ + public transform?: (google.firestore.v1beta1.IDocumentTransform|null); + + /** Write updateMask. */ + public updateMask?: (google.firestore.v1beta1.IDocumentMask|null); + + /** Write currentDocument. */ + public currentDocument?: (google.firestore.v1beta1.IPrecondition|null); + + /** Write operation. */ + public operation?: ("update"|"delete"|"transform"); + + /** + * Creates a Write message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Write + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.Write; + + /** + * Creates a plain object from a Write message. Also converts values to other types if specified. + * @param message Write + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.Write, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Write to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DocumentTransform. */ + interface IDocumentTransform { + + /** DocumentTransform document */ + document?: (string|null); + + /** DocumentTransform fieldTransforms */ + fieldTransforms?: (google.firestore.v1beta1.DocumentTransform.IFieldTransform[]|null); + } + + /** Represents a DocumentTransform. */ + class DocumentTransform implements IDocumentTransform { + + /** + * Constructs a new DocumentTransform. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IDocumentTransform); + + /** DocumentTransform document. */ + public document: string; + + /** DocumentTransform fieldTransforms. */ + public fieldTransforms: google.firestore.v1beta1.DocumentTransform.IFieldTransform[]; + + /** + * Creates a DocumentTransform message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentTransform + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.DocumentTransform; + + /** + * Creates a plain object from a DocumentTransform message. Also converts values to other types if specified. + * @param message DocumentTransform + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.DocumentTransform, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentTransform to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace DocumentTransform { + + /** Properties of a FieldTransform. */ + interface IFieldTransform { + + /** FieldTransform fieldPath */ + fieldPath?: (string|null); + + /** FieldTransform setToServerValue */ + setToServerValue?: (google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue|null); + + /** FieldTransform increment */ + increment?: (google.firestore.v1beta1.IValue|null); + + /** FieldTransform maximum */ + maximum?: (google.firestore.v1beta1.IValue|null); + + /** FieldTransform minimum */ + minimum?: (google.firestore.v1beta1.IValue|null); + + /** FieldTransform appendMissingElements */ + appendMissingElements?: (google.firestore.v1beta1.IArrayValue|null); + + /** FieldTransform removeAllFromArray */ + removeAllFromArray?: (google.firestore.v1beta1.IArrayValue|null); + } + + /** Represents a FieldTransform. */ + class FieldTransform implements IFieldTransform { + + /** + * Constructs a new FieldTransform. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.DocumentTransform.IFieldTransform); + + /** FieldTransform fieldPath. */ + public fieldPath: string; + + /** FieldTransform setToServerValue. */ + public setToServerValue: google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue; + + /** FieldTransform increment. */ + public increment?: (google.firestore.v1beta1.IValue|null); + + /** FieldTransform maximum. */ + public maximum?: (google.firestore.v1beta1.IValue|null); + + /** FieldTransform minimum. */ + public minimum?: (google.firestore.v1beta1.IValue|null); + + /** FieldTransform appendMissingElements. */ + public appendMissingElements?: (google.firestore.v1beta1.IArrayValue|null); + + /** FieldTransform removeAllFromArray. */ + public removeAllFromArray?: (google.firestore.v1beta1.IArrayValue|null); + + /** FieldTransform transformType. */ + public transformType?: ("setToServerValue"|"increment"|"maximum"|"minimum"|"appendMissingElements"|"removeAllFromArray"); + + /** + * Creates a FieldTransform message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldTransform + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.DocumentTransform.FieldTransform; + + /** + * Creates a plain object from a FieldTransform message. Also converts values to other types if specified. + * @param message FieldTransform + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.DocumentTransform.FieldTransform, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldTransform to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace FieldTransform { + + /** ServerValue enum. */ + type ServerValue = + "SERVER_VALUE_UNSPECIFIED"| "REQUEST_TIME"; + } + } + + /** Properties of a WriteResult. */ + interface IWriteResult { + + /** WriteResult updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** WriteResult transformResults */ + transformResults?: (google.firestore.v1beta1.IValue[]|null); + } + + /** Represents a WriteResult. */ + class WriteResult implements IWriteResult { + + /** + * Constructs a new WriteResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IWriteResult); + + /** WriteResult updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** WriteResult transformResults. */ + public transformResults: google.firestore.v1beta1.IValue[]; + + /** + * Creates a WriteResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WriteResult + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.WriteResult; + + /** + * Creates a plain object from a WriteResult message. Also converts values to other types if specified. + * @param message WriteResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.WriteResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WriteResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DocumentChange. */ + interface IDocumentChange { + + /** DocumentChange document */ + document?: (google.firestore.v1beta1.IDocument|null); + + /** DocumentChange targetIds */ + targetIds?: (number[]|null); + + /** DocumentChange removedTargetIds */ + removedTargetIds?: (number[]|null); + } + + /** Represents a DocumentChange. */ + class DocumentChange implements IDocumentChange { + + /** + * Constructs a new DocumentChange. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IDocumentChange); + + /** DocumentChange document. */ + public document?: (google.firestore.v1beta1.IDocument|null); + + /** DocumentChange targetIds. */ + public targetIds: number[]; + + /** DocumentChange removedTargetIds. */ + public removedTargetIds: number[]; + + /** + * Creates a DocumentChange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentChange + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.DocumentChange; + + /** + * Creates a plain object from a DocumentChange message. Also converts values to other types if specified. + * @param message DocumentChange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.DocumentChange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentChange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DocumentDelete. */ + interface IDocumentDelete { + + /** DocumentDelete document */ + document?: (string|null); + + /** DocumentDelete removedTargetIds */ + removedTargetIds?: (number[]|null); + + /** DocumentDelete readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a DocumentDelete. */ + class DocumentDelete implements IDocumentDelete { + + /** + * Constructs a new DocumentDelete. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IDocumentDelete); + + /** DocumentDelete document. */ + public document: string; + + /** DocumentDelete removedTargetIds. */ + public removedTargetIds: number[]; + + /** DocumentDelete readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a DocumentDelete message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentDelete + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.DocumentDelete; + + /** + * Creates a plain object from a DocumentDelete message. Also converts values to other types if specified. + * @param message DocumentDelete + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.DocumentDelete, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentDelete to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DocumentRemove. */ + interface IDocumentRemove { + + /** DocumentRemove document */ + document?: (string|null); + + /** DocumentRemove removedTargetIds */ + removedTargetIds?: (number[]|null); + + /** DocumentRemove readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a DocumentRemove. */ + class DocumentRemove implements IDocumentRemove { + + /** + * Constructs a new DocumentRemove. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IDocumentRemove); + + /** DocumentRemove document. */ + public document: string; + + /** DocumentRemove removedTargetIds. */ + public removedTargetIds: number[]; + + /** DocumentRemove readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a DocumentRemove message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentRemove + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.DocumentRemove; + + /** + * Creates a plain object from a DocumentRemove message. Also converts values to other types if specified. + * @param message DocumentRemove + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.DocumentRemove, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentRemove to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an ExistenceFilter. */ + interface IExistenceFilter { + + /** ExistenceFilter targetId */ + targetId?: (number|null); + + /** ExistenceFilter count */ + count?: (number|null); + } + + /** Represents an ExistenceFilter. */ + class ExistenceFilter implements IExistenceFilter { + + /** + * Constructs a new ExistenceFilter. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IExistenceFilter); + + /** ExistenceFilter targetId. */ + public targetId: number; + + /** ExistenceFilter count. */ + public count: number; + + /** + * Creates an ExistenceFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExistenceFilter + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.ExistenceFilter; + + /** + * Creates a plain object from an ExistenceFilter message. Also converts values to other types if specified. + * @param message ExistenceFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.ExistenceFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExistenceFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + } + + /** Namespace api. */ + namespace api { + + /** Properties of a Http. */ + interface IHttp { + + /** Http rules */ + rules?: (google.api.IHttpRule[]|null); + } + + /** Represents a Http. */ + class Http implements IHttp { + + /** + * Constructs a new Http. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IHttp); + + /** Http rules. */ + public rules: google.api.IHttpRule[]; + + /** + * Creates a Http message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Http + */ + public static fromObject(object: { [k: string]: any }): google.api.Http; + + /** + * Creates a plain object from a Http message. Also converts values to other types if specified. + * @param message Http + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.Http, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Http to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a HttpRule. */ + interface IHttpRule { + + /** HttpRule get */ + get?: (string|null); + + /** HttpRule put */ + put?: (string|null); + + /** HttpRule post */ + post?: (string|null); + + /** HttpRule delete */ + "delete"?: (string|null); + + /** HttpRule patch */ + patch?: (string|null); + + /** HttpRule custom */ + custom?: (google.api.ICustomHttpPattern|null); + + /** HttpRule selector */ + selector?: (string|null); + + /** HttpRule body */ + body?: (string|null); + + /** HttpRule additionalBindings */ + additionalBindings?: (google.api.IHttpRule[]|null); + } + + /** Represents a HttpRule. */ + class HttpRule implements IHttpRule { + + /** + * Constructs a new HttpRule. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IHttpRule); + + /** HttpRule get. */ + public get: string; + + /** HttpRule put. */ + public put: string; + + /** HttpRule post. */ + public post: string; + + /** HttpRule delete. */ + public delete: string; + + /** HttpRule patch. */ + public patch: string; + + /** HttpRule custom. */ + public custom?: (google.api.ICustomHttpPattern|null); + + /** HttpRule selector. */ + public selector: string; + + /** HttpRule body. */ + public body: string; + + /** HttpRule additionalBindings. */ + public additionalBindings: google.api.IHttpRule[]; + + /** HttpRule pattern. */ + public pattern?: ("get"|"put"|"post"|"delete"|"patch"|"custom"); + + /** + * Creates a HttpRule message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns HttpRule + */ + public static fromObject(object: { [k: string]: any }): google.api.HttpRule; + + /** + * Creates a plain object from a HttpRule message. Also converts values to other types if specified. + * @param message HttpRule + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.HttpRule, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this HttpRule to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CustomHttpPattern. */ + interface ICustomHttpPattern { + + /** CustomHttpPattern kind */ + kind?: (string|null); + + /** CustomHttpPattern path */ + path?: (string|null); + } + + /** Represents a CustomHttpPattern. */ + class CustomHttpPattern implements ICustomHttpPattern { + + /** + * Constructs a new CustomHttpPattern. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ICustomHttpPattern); + + /** CustomHttpPattern kind. */ + public kind: string; + + /** CustomHttpPattern path. */ + public path: string; + + /** + * Creates a CustomHttpPattern message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CustomHttpPattern + */ + public static fromObject(object: { [k: string]: any }): google.api.CustomHttpPattern; + + /** + * Creates a plain object from a CustomHttpPattern message. Also converts values to other types if specified. + * @param message CustomHttpPattern + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.CustomHttpPattern, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CustomHttpPattern to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** FieldBehavior enum. */ + type FieldBehavior = + "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"; + + /** Properties of a ResourceDescriptor. */ + interface IResourceDescriptor { + + /** ResourceDescriptor type */ + type?: (string|null); + + /** ResourceDescriptor pattern */ + pattern?: (string[]|null); + + /** ResourceDescriptor nameField */ + nameField?: (string|null); + + /** ResourceDescriptor history */ + history?: (google.api.ResourceDescriptor.History|null); + + /** ResourceDescriptor plural */ + plural?: (string|null); + + /** ResourceDescriptor singular */ + singular?: (string|null); + + /** ResourceDescriptor style */ + style?: (google.api.ResourceDescriptor.Style[]|null); + } + + /** Represents a ResourceDescriptor. */ + class ResourceDescriptor implements IResourceDescriptor { + + /** + * Constructs a new ResourceDescriptor. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IResourceDescriptor); + + /** ResourceDescriptor type. */ + public type: string; + + /** ResourceDescriptor pattern. */ + public pattern: string[]; + + /** ResourceDescriptor nameField. */ + public nameField: string; + + /** ResourceDescriptor history. */ + public history: google.api.ResourceDescriptor.History; + + /** ResourceDescriptor plural. */ + public plural: string; + + /** ResourceDescriptor singular. */ + public singular: string; + + /** ResourceDescriptor style. */ + public style: google.api.ResourceDescriptor.Style[]; + + /** + * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ResourceDescriptor + */ + public static fromObject(object: { [k: string]: any }): google.api.ResourceDescriptor; + + /** + * Creates a plain object from a ResourceDescriptor message. Also converts values to other types if specified. + * @param message ResourceDescriptor + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.ResourceDescriptor, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ResourceDescriptor to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace ResourceDescriptor { + + /** History enum. */ + type History = + "HISTORY_UNSPECIFIED"| "ORIGINALLY_SINGLE_PATTERN"| "FUTURE_MULTI_PATTERN"; + + /** Style enum. */ + type Style = + "STYLE_UNSPECIFIED"| "DECLARATIVE_FRIENDLY"; + } + + /** Properties of a ResourceReference. */ + interface IResourceReference { + + /** ResourceReference type */ + type?: (string|null); + + /** ResourceReference childType */ + childType?: (string|null); + } + + /** Represents a ResourceReference. */ + class ResourceReference implements IResourceReference { + + /** + * Constructs a new ResourceReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IResourceReference); + + /** ResourceReference type. */ + public type: string; + + /** ResourceReference childType. */ + public childType: string; + + /** + * Creates a ResourceReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ResourceReference + */ + public static fromObject(object: { [k: string]: any }): google.api.ResourceReference; + + /** + * Creates a plain object from a ResourceReference message. Also converts values to other types if specified. + * @param message ResourceReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.ResourceReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ResourceReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Namespace type. */ + namespace type { + + /** Properties of a LatLng. */ + interface ILatLng { + + /** LatLng latitude */ + latitude?: (number|null); + + /** LatLng longitude */ + longitude?: (number|null); + } + + /** Represents a LatLng. */ + class LatLng implements ILatLng { + + /** + * Constructs a new LatLng. + * @param [properties] Properties to set + */ + constructor(properties?: google.type.ILatLng); + + /** LatLng latitude. */ + public latitude: number; + + /** LatLng longitude. */ + public longitude: number; + + /** + * Creates a LatLng message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LatLng + */ + public static fromObject(object: { [k: string]: any }): google.type.LatLng; + + /** + * Creates a plain object from a LatLng message. Also converts values to other types if specified. + * @param message LatLng + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.type.LatLng, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LatLng to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Namespace rpc. */ + namespace rpc { + + /** Properties of a Status. */ + interface IStatus { + + /** Status code */ + code?: (number|null); + + /** Status message */ + message?: (string|null); + + /** Status details */ + details?: (google.protobuf.IAny[]|null); + } + + /** Represents a Status. */ + class Status implements IStatus { + + /** + * Constructs a new Status. + * @param [properties] Properties to set + */ + constructor(properties?: google.rpc.IStatus); + + /** Status code. */ + public code: number; + + /** Status message. */ + public message: string; + + /** Status details. */ + public details: google.protobuf.IAny[]; + + /** + * Creates a Status message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Status + */ + public static fromObject(object: { [k: string]: any }): google.rpc.Status; + + /** + * Creates a plain object from a Status message. Also converts values to other types if specified. + * @param message Status + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.rpc.Status, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Status to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } + + /** Namespace longrunning. */ + namespace longrunning { + + /** Represents an Operations */ + class Operations extends $protobuf.rpc.Service { + + /** + * Constructs a new Operations service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Calls ListOperations. + * @param request ListOperationsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListOperationsResponse + */ + public listOperations(request: google.longrunning.IListOperationsRequest, callback: google.longrunning.Operations.ListOperationsCallback): void; + + /** + * Calls ListOperations. + * @param request ListOperationsRequest message or plain object + * @returns Promise + */ + public listOperations(request: google.longrunning.IListOperationsRequest): Promise; + + /** + * Calls GetOperation. + * @param request GetOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public getOperation(request: google.longrunning.IGetOperationRequest, callback: google.longrunning.Operations.GetOperationCallback): void; + + /** + * Calls GetOperation. + * @param request GetOperationRequest message or plain object + * @returns Promise + */ + public getOperation(request: google.longrunning.IGetOperationRequest): Promise; + + /** + * Calls DeleteOperation. + * @param request DeleteOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteOperation(request: google.longrunning.IDeleteOperationRequest, callback: google.longrunning.Operations.DeleteOperationCallback): void; + + /** + * Calls DeleteOperation. + * @param request DeleteOperationRequest message or plain object + * @returns Promise + */ + public deleteOperation(request: google.longrunning.IDeleteOperationRequest): Promise; + + /** + * Calls CancelOperation. + * @param request CancelOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public cancelOperation(request: google.longrunning.ICancelOperationRequest, callback: google.longrunning.Operations.CancelOperationCallback): void; + + /** + * Calls CancelOperation. + * @param request CancelOperationRequest message or plain object + * @returns Promise + */ + public cancelOperation(request: google.longrunning.ICancelOperationRequest): Promise; + + /** + * Calls WaitOperation. + * @param request WaitOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public waitOperation(request: google.longrunning.IWaitOperationRequest, callback: google.longrunning.Operations.WaitOperationCallback): void; + + /** + * Calls WaitOperation. + * @param request WaitOperationRequest message or plain object + * @returns Promise + */ + public waitOperation(request: google.longrunning.IWaitOperationRequest): Promise; + } + + namespace Operations { + + /** + * Callback as used by {@link google.longrunning.Operations#listOperations}. + * @param error Error, if any + * @param [response] ListOperationsResponse + */ + type ListOperationsCallback = (error: (Error|null), response?: google.longrunning.ListOperationsResponse) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#getOperation}. + * @param error Error, if any + * @param [response] Operation + */ + type GetOperationCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#deleteOperation}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteOperationCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#cancelOperation}. + * @param error Error, if any + * @param [response] Empty + */ + type CancelOperationCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.longrunning.Operations#waitOperation}. + * @param error Error, if any + * @param [response] Operation + */ + type WaitOperationCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of an Operation. */ + interface IOperation { + + /** Operation name */ + name?: (string|null); + + /** Operation metadata */ + metadata?: (google.protobuf.IAny|null); + + /** Operation done */ + done?: (boolean|null); + + /** Operation error */ + error?: (google.rpc.IStatus|null); + + /** Operation response */ + response?: (google.protobuf.IAny|null); + } + + /** Represents an Operation. */ + class Operation implements IOperation { + + /** + * Constructs a new Operation. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IOperation); + + /** Operation name. */ + public name: string; + + /** Operation metadata. */ + public metadata?: (google.protobuf.IAny|null); + + /** Operation done. */ + public done: boolean; + + /** Operation error. */ + public error?: (google.rpc.IStatus|null); + + /** Operation response. */ + public response?: (google.protobuf.IAny|null); + + /** Operation result. */ + public result?: ("error"|"response"); + + /** + * Creates an Operation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Operation + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.Operation; + + /** + * Creates a plain object from an Operation message. Also converts values to other types if specified. + * @param message Operation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.Operation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Operation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a GetOperationRequest. */ + interface IGetOperationRequest { + + /** GetOperationRequest name */ + name?: (string|null); + } + + /** Represents a GetOperationRequest. */ + class GetOperationRequest implements IGetOperationRequest { + + /** + * Constructs a new GetOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IGetOperationRequest); + + /** GetOperationRequest name. */ + public name: string; + + /** + * Creates a GetOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.GetOperationRequest; + + /** + * Creates a plain object from a GetOperationRequest message. Also converts values to other types if specified. + * @param message GetOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.GetOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListOperationsRequest. */ + interface IListOperationsRequest { + + /** ListOperationsRequest name */ + name?: (string|null); + + /** ListOperationsRequest filter */ + filter?: (string|null); + + /** ListOperationsRequest pageSize */ + pageSize?: (number|null); + + /** ListOperationsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListOperationsRequest. */ + class ListOperationsRequest implements IListOperationsRequest { + + /** + * Constructs a new ListOperationsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IListOperationsRequest); + + /** ListOperationsRequest name. */ + public name: string; + + /** ListOperationsRequest filter. */ + public filter: string; + + /** ListOperationsRequest pageSize. */ + public pageSize: number; + + /** ListOperationsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a ListOperationsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListOperationsRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.ListOperationsRequest; + + /** + * Creates a plain object from a ListOperationsRequest message. Also converts values to other types if specified. + * @param message ListOperationsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.ListOperationsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListOperationsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListOperationsResponse. */ + interface IListOperationsResponse { + + /** ListOperationsResponse operations */ + operations?: (google.longrunning.IOperation[]|null); + + /** ListOperationsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListOperationsResponse. */ + class ListOperationsResponse implements IListOperationsResponse { + + /** + * Constructs a new ListOperationsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IListOperationsResponse); + + /** ListOperationsResponse operations. */ + public operations: google.longrunning.IOperation[]; + + /** ListOperationsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a ListOperationsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListOperationsResponse + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.ListOperationsResponse; + + /** + * Creates a plain object from a ListOperationsResponse message. Also converts values to other types if specified. + * @param message ListOperationsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.ListOperationsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListOperationsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CancelOperationRequest. */ + interface ICancelOperationRequest { + + /** CancelOperationRequest name */ + name?: (string|null); + } + + /** Represents a CancelOperationRequest. */ + class CancelOperationRequest implements ICancelOperationRequest { + + /** + * Constructs a new CancelOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.ICancelOperationRequest); + + /** CancelOperationRequest name. */ + public name: string; + + /** + * Creates a CancelOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CancelOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.CancelOperationRequest; + + /** + * Creates a plain object from a CancelOperationRequest message. Also converts values to other types if specified. + * @param message CancelOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.CancelOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CancelOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DeleteOperationRequest. */ + interface IDeleteOperationRequest { + + /** DeleteOperationRequest name */ + name?: (string|null); + } + + /** Represents a DeleteOperationRequest. */ + class DeleteOperationRequest implements IDeleteOperationRequest { + + /** + * Constructs a new DeleteOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IDeleteOperationRequest); + + /** DeleteOperationRequest name. */ + public name: string; + + /** + * Creates a DeleteOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.DeleteOperationRequest; + + /** + * Creates a plain object from a DeleteOperationRequest message. Also converts values to other types if specified. + * @param message DeleteOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.DeleteOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a WaitOperationRequest. */ + interface IWaitOperationRequest { + + /** WaitOperationRequest name */ + name?: (string|null); + + /** WaitOperationRequest timeout */ + timeout?: (google.protobuf.IDuration|null); + } + + /** Represents a WaitOperationRequest. */ + class WaitOperationRequest implements IWaitOperationRequest { + + /** + * Constructs a new WaitOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IWaitOperationRequest); + + /** WaitOperationRequest name. */ + public name: string; + + /** WaitOperationRequest timeout. */ + public timeout?: (google.protobuf.IDuration|null); + + /** + * Creates a WaitOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WaitOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.WaitOperationRequest; + + /** + * Creates a plain object from a WaitOperationRequest message. Also converts values to other types if specified. + * @param message WaitOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.WaitOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WaitOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an OperationInfo. */ + interface IOperationInfo { + + /** OperationInfo responseType */ + responseType?: (string|null); + + /** OperationInfo metadataType */ + metadataType?: (string|null); + } + + /** Represents an OperationInfo. */ + class OperationInfo implements IOperationInfo { + + /** + * Constructs a new OperationInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IOperationInfo); + + /** OperationInfo responseType. */ + public responseType: string; + + /** OperationInfo metadataType. */ + public metadataType: string; + + /** + * Creates an OperationInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OperationInfo + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.OperationInfo; + + /** + * Creates a plain object from an OperationInfo message. Also converts values to other types if specified. + * @param message OperationInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.OperationInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OperationInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + } +} diff --git a/types/v1/firestore_admin_client.d.ts b/types/v1/firestore_admin_client.d.ts new file mode 100644 index 000000000..9b5b5ac70 --- /dev/null +++ b/types/v1/firestore_admin_client.d.ts @@ -0,0 +1,810 @@ +/*! + * Copyright 2021 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 gax from 'google-gax'; +import { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LROperation, + PaginationCallback, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../protos/firestore_admin_v1_proto_api'; +/** + * Operations are created by service `FirestoreAdmin`, but are accessed via + * service `google.longrunning.Operations`. + * @class + * @memberof v1 + */ +export declare class FirestoreAdminClient { + private _terminated; + private _opts; + private _gaxModule; + private _gaxGrpc; + private _protos; + private _defaults; + auth: gax.GoogleAuth; + descriptors: Descriptors; + innerApiCalls: { + [name: string]: Function; + }; + pathTemplates: { + [name: string]: gax.PathTemplate; + }; + operationsClient: gax.OperationsClient; + firestoreAdminStub?: Promise<{ + [name: string]: Function; + }>; + /** + * Construct an instance of FirestoreAdminClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions); + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize(): Promise<{ + [name: string]: Function; + }>; + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath(): string; + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint(): string; + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port(): number; + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes(): string[]; + getProjectId(): Promise; + getProjectId(callback: Callback): void; + getIndex( + request: protos.google.firestore.admin.v1.IGetIndexRequest, + options?: 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: 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?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IDeleteIndexRequest | undefined, + {} | undefined + ] + >; + deleteIndex( + request: protos.google.firestore.admin.v1.IDeleteIndexRequest, + options: 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?: 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: 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?: 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: 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 `createIndex()`. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @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?: 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: 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 `updateField()`. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @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?: 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: 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 `exportDocuments()`. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @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?: 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: 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 `importDocuments()`. + * @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. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @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?: 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: 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 `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @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 {Stream} + * An object stream which emits an object representing [Index]{@link google.firestore.admin.v1.Index} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listIndexesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listIndexesStream( + request?: protos.google.firestore.admin.v1.IListIndexesRequest, + options?: CallOptions + ): Transform; + /** + * Equivalent to `listIndexes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Index]{@link google.firestore.admin.v1.Index}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listIndexesAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listIndexesAsync( + request?: protos.google.firestore.admin.v1.IListIndexesRequest, + options?: CallOptions + ): AsyncIterable; + listFields( + request: protos.google.firestore.admin.v1.IListFieldsRequest, + options?: 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: 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 `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @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 {Stream} + * An object stream which emits an object representing [Field]{@link google.firestore.admin.v1.Field} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listFieldsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listFieldsStream( + request?: protos.google.firestore.admin.v1.IListFieldsRequest, + options?: CallOptions + ): Transform; + /** + * Equivalent to `listFields`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Field]{@link google.firestore.admin.v1.Field}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listFieldsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listFieldsAsync( + request?: protos.google.firestore.admin.v1.IListFieldsRequest, + options?: CallOptions + ): AsyncIterable; + /** + * Return a fully-qualified collectionGroup resource name string. + * + * @param {string} project + * @param {string} database + * @param {string} collection + * @returns {string} Resource name string. + */ + collectionGroupPath( + project: string, + database: string, + collection: string + ): string; + /** + * Parse the project from CollectionGroup resource. + * + * @param {string} collectionGroupName + * A fully-qualified path representing CollectionGroup resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCollectionGroupName( + collectionGroupName: string + ): string | number; + /** + * Parse the database from CollectionGroup resource. + * + * @param {string} collectionGroupName + * A fully-qualified path representing CollectionGroup resource. + * @returns {string} A string representing the database. + */ + matchDatabaseFromCollectionGroupName( + collectionGroupName: string + ): string | number; + /** + * Parse the collection from CollectionGroup resource. + * + * @param {string} collectionGroupName + * A fully-qualified path representing CollectionGroup resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromCollectionGroupName( + collectionGroupName: string + ): string | number; + /** + * Return a fully-qualified database resource name string. + * + * @param {string} project + * @param {string} database + * @returns {string} Resource name string. + */ + databasePath(project: string, database: string): string; + /** + * Parse the project from Database resource. + * + * @param {string} databaseName + * A fully-qualified path representing Database resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDatabaseName(databaseName: string): string | number; + /** + * Parse the database from Database resource. + * + * @param {string} databaseName + * A fully-qualified path representing Database resource. + * @returns {string} A string representing the database. + */ + matchDatabaseFromDatabaseName(databaseName: string): string | number; + /** + * Return a fully-qualified field resource name string. + * + * @param {string} project + * @param {string} database + * @param {string} collection + * @param {string} field + * @returns {string} Resource name string. + */ + fieldPath( + project: string, + database: string, + collection: string, + field: string + ): string; + /** + * Parse the project from Field resource. + * + * @param {string} fieldName + * A fully-qualified path representing Field resource. + * @returns {string} A string representing the project. + */ + matchProjectFromFieldName(fieldName: string): string | number; + /** + * Parse the database from Field resource. + * + * @param {string} fieldName + * A fully-qualified path representing Field resource. + * @returns {string} A string representing the database. + */ + matchDatabaseFromFieldName(fieldName: string): string | number; + /** + * Parse the collection from Field resource. + * + * @param {string} fieldName + * A fully-qualified path representing Field resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromFieldName(fieldName: string): string | number; + /** + * Parse the field from Field resource. + * + * @param {string} fieldName + * A fully-qualified path representing Field resource. + * @returns {string} A string representing the field. + */ + matchFieldFromFieldName(fieldName: string): string | number; + /** + * Return a fully-qualified index resource name string. + * + * @param {string} project + * @param {string} database + * @param {string} collection + * @param {string} index + * @returns {string} Resource name string. + */ + indexPath( + project: string, + database: string, + collection: string, + index: string + ): string; + /** + * Parse the project from Index resource. + * + * @param {string} indexName + * A fully-qualified path representing Index resource. + * @returns {string} A string representing the project. + */ + matchProjectFromIndexName(indexName: string): string | number; + /** + * Parse the database from Index resource. + * + * @param {string} indexName + * A fully-qualified path representing Index resource. + * @returns {string} A string representing the database. + */ + matchDatabaseFromIndexName(indexName: string): string | number; + /** + * Parse the collection from Index resource. + * + * @param {string} indexName + * A fully-qualified path representing Index resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromIndexName(indexName: string): string | number; + /** + * Parse the index from Index resource. + * + * @param {string} indexName + * A fully-qualified path representing Index resource. + * @returns {string} A string representing the index. + */ + matchIndexFromIndexName(indexName: string): string | number; + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise; +} diff --git a/types/v1/firestore_client.d.ts b/types/v1/firestore_client.d.ts new file mode 100644 index 000000000..0f44774c0 --- /dev/null +++ b/types/v1/firestore_client.d.ts @@ -0,0 +1,867 @@ +/*! + * Copyright 2021 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 gax from 'google-gax'; +import { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../protos/firestore_v1_proto_api'; +/** + * The Cloud Firestore service. + * + * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL + * document database that simplifies storing, syncing, and querying data for + * your mobile, web, and IoT apps at global scale. Its client libraries provide + * live synchronization and offline support, while its security features and + * integrations with Firebase and Google Cloud Platform (GCP) accelerate + * building truly serverless apps. + * @class + * @memberof v1 + */ +export declare class FirestoreClient { + private _terminated; + private _opts; + private _gaxModule; + private _gaxGrpc; + private _protos; + private _defaults; + auth: gax.GoogleAuth; + descriptors: Descriptors; + innerApiCalls: { + [name: string]: Function; + }; + firestoreStub?: Promise<{ + [name: string]: Function; + }>; + /** + * Construct an instance of FirestoreClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions); + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize(): Promise<{ + [name: string]: Function; + }>; + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath(): string; + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint(): string; + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port(): number; + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes(): string[]; + getProjectId(): Promise; + getProjectId(callback: Callback): void; + getDocument( + request: protos.google.firestore.v1.IGetDocumentRequest, + options?: CallOptions + ): Promise< + [ + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IGetDocumentRequest | undefined, + {} | undefined + ] + >; + getDocument( + request: protos.google.firestore.v1.IGetDocumentRequest, + options: 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?: CallOptions + ): Promise< + [ + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IUpdateDocumentRequest | undefined, + {} | undefined + ] + >; + updateDocument( + request: protos.google.firestore.v1.IUpdateDocumentRequest, + options: 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?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IDeleteDocumentRequest | undefined, + {} | undefined + ] + >; + deleteDocument( + request: protos.google.firestore.v1.IDeleteDocumentRequest, + options: 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?: CallOptions + ): Promise< + [ + protos.google.firestore.v1.IBeginTransactionResponse, + protos.google.firestore.v1.IBeginTransactionRequest | undefined, + {} | undefined + ] + >; + beginTransaction( + request: protos.google.firestore.v1.IBeginTransactionRequest, + options: 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?: CallOptions + ): Promise< + [ + protos.google.firestore.v1.ICommitResponse, + protos.google.firestore.v1.ICommitRequest | undefined, + {} | undefined + ] + >; + commit( + request: protos.google.firestore.v1.ICommitRequest, + options: 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?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IRollbackRequest | undefined, + {} | undefined + ] + >; + rollback( + request: protos.google.firestore.v1.IRollbackRequest, + options: 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?: CallOptions + ): Promise< + [ + protos.google.firestore.v1.IBatchWriteResponse, + protos.google.firestore.v1.IBatchWriteRequest | undefined, + {} | undefined + ] + >; + batchWrite( + request: protos.google.firestore.v1.IBatchWriteRequest, + options: 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?: CallOptions + ): Promise< + [ + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.ICreateDocumentRequest | undefined, + {} | undefined + ] + >; + createDocument( + request: protos.google.firestore.v1.ICreateDocumentRequest, + options: 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; + /** + * Gets multiple documents. + * + * Documents returned by this method are not guaranteed to be returned in the + * same order that they were requested. + * + * @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 {string[]} request.documents + * The names of the documents to retrieve. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * The request will fail if any of the document is not a child resource of the + * given `database`. Duplicate names will be elided. + * @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.firestore.v1.TransactionOptions} request.newTransaction + * Starts a new transaction and reads the documents. + * Defaults to a read-only transaction. + * The new transaction ID will be returned as the first response in the + * stream. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + * @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 [BatchGetDocumentsResponse]{@link google.firestore.v1.BatchGetDocumentsResponse} on 'data' event. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) + * for more details and examples. + * @example + * const stream = client.batchGetDocuments(request); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); + */ + batchGetDocuments( + request?: protos.google.firestore.v1.IBatchGetDocumentsRequest, + options?: CallOptions + ): gax.CancellableStream; + /** + * Runs a query. + * + * @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 {google.firestore.v1.StructuredQuery} request.structuredQuery + * A structured query. + * @param {Buffer} request.transaction + * Reads documents in a transaction. + * @param {google.firestore.v1.TransactionOptions} request.newTransaction + * Starts a new transaction and reads the documents. + * Defaults to a read-only transaction. + * The new transaction ID will be returned as the first response in the + * stream. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + * @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 [RunQueryResponse]{@link google.firestore.v1.RunQueryResponse} on 'data' event. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) + * for more details and examples. + * @example + * const stream = client.runQuery(request); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); + */ + runQuery( + request?: protos.google.firestore.v1.IRunQueryRequest, + options?: CallOptions + ): gax.CancellableStream; + /** + * Streams batches of document updates and deletes, in order. + * + * @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 is both readable and writable. It accepts objects + * representing [WriteRequest]{@link google.firestore.v1.WriteRequest} for write() method, and + * will emit objects representing [WriteResponse]{@link google.firestore.v1.WriteResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example + * const stream = client.write(); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); + * stream.write(request); + * stream.end(); + */ + write(options?: CallOptions): gax.CancellableStream; + /** + * Listens to changes. + * + * @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 is both readable and writable. It accepts objects + * representing [ListenRequest]{@link google.firestore.v1.ListenRequest} for write() method, and + * will emit objects representing [ListenResponse]{@link google.firestore.v1.ListenResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example + * const stream = client.listen(); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); + * stream.write(request); + * stream.end(); + */ + listen(options?: CallOptions): gax.CancellableStream; + listDocuments( + request: protos.google.firestore.v1.IListDocumentsRequest, + options?: 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: 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; + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @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 {Stream} + * An object stream which emits an object representing [Document]{@link google.firestore.v1.Document} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDocumentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listDocumentsStream( + request?: protos.google.firestore.v1.IListDocumentsRequest, + options?: CallOptions + ): Transform; + /** + * Equivalent to `listDocuments`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Document]{@link google.firestore.v1.Document}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listDocumentsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listDocumentsAsync( + request?: protos.google.firestore.v1.IListDocumentsRequest, + options?: CallOptions + ): AsyncIterable; + partitionQuery( + request: protos.google.firestore.v1.IPartitionQueryRequest, + options?: 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: 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 `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @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. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other 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 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. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `partitionQueryAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + partitionQueryStream( + request?: protos.google.firestore.v1.IPartitionQueryRequest, + options?: CallOptions + ): Transform; + /** + * Equivalent to `partitionQuery`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements 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. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other 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 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Cursor]{@link google.firestore.v1.Cursor}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.partitionQueryAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + partitionQueryAsync( + request?: protos.google.firestore.v1.IPartitionQueryRequest, + options?: CallOptions + ): AsyncIterable; + listCollectionIds( + request: protos.google.firestore.v1.IListCollectionIdsRequest, + options?: CallOptions + ): Promise< + [ + string[], + protos.google.firestore.v1.IListCollectionIdsRequest | null, + protos.google.firestore.v1.IListCollectionIdsResponse + ] + >; + listCollectionIds( + request: protos.google.firestore.v1.IListCollectionIdsRequest, + options: 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 `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @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 {Stream} + * An object stream which emits an object representing string on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCollectionIdsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCollectionIdsStream( + request?: protos.google.firestore.v1.IListCollectionIdsRequest, + options?: CallOptions + ): Transform; + /** + * Equivalent to `listCollectionIds`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * string. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listCollectionIdsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listCollectionIdsAsync( + request?: protos.google.firestore.v1.IListCollectionIdsRequest, + options?: CallOptions + ): AsyncIterable; + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise; +} diff --git a/types/v1beta1/firestore_client.d.ts b/types/v1beta1/firestore_client.d.ts new file mode 100644 index 000000000..9402af1da --- /dev/null +++ b/types/v1beta1/firestore_client.d.ts @@ -0,0 +1,702 @@ +/*! + * Copyright 2021 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 gax from 'google-gax'; +import { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../protos/firestore_v1beta1_proto_api'; +/** + * The Cloud Firestore service. + * + * This service exposes several types of comparable timestamps: + * + * * `create_time` - The time at which a document was created. Changes only + * when a document is deleted, then re-created. Increases in a strict + * monotonic fashion. + * * `update_time` - The time at which a document was last updated. Changes + * every time a document is modified. Does not change when a write results + * in no modifications. Increases in a strict monotonic fashion. + * * `read_time` - The time at which a particular state was observed. Used + * to denote a consistent snapshot of the database or the time at which a + * Document was observed to not exist. + * * `commit_time` - The time at which the writes in a transaction were + * committed. Any read with an equal or greater `read_time` is guaranteed + * to see the effects of the transaction. + * @class + * @deprecated Use v1/firestore_client instead. + * @memberof v1beta1 + */ +export declare class FirestoreClient { + private _terminated; + private _opts; + private _gaxModule; + private _gaxGrpc; + private _protos; + private _defaults; + auth: gax.GoogleAuth; + descriptors: Descriptors; + innerApiCalls: { + [name: string]: Function; + }; + firestoreStub?: Promise<{ + [name: string]: Function; + }>; + /** + * Construct an instance of FirestoreClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions); + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize(): Promise<{ + [name: string]: Function; + }>; + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath(): string; + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint(): string; + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port(): number; + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes(): string[]; + getProjectId(): Promise; + getProjectId(callback: Callback): void; + getDocument( + request: protos.google.firestore.v1beta1.IGetDocumentRequest, + options?: CallOptions + ): Promise< + [ + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IGetDocumentRequest | undefined, + {} | undefined + ] + >; + getDocument( + request: protos.google.firestore.v1beta1.IGetDocumentRequest, + options: 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?: CallOptions + ): Promise< + [ + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.ICreateDocumentRequest | undefined, + {} | undefined + ] + >; + createDocument( + request: protos.google.firestore.v1beta1.ICreateDocumentRequest, + options: 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?: CallOptions + ): Promise< + [ + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IUpdateDocumentRequest | undefined, + {} | undefined + ] + >; + updateDocument( + request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, + options: 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?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IDeleteDocumentRequest | undefined, + {} | undefined + ] + >; + deleteDocument( + request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, + options: 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?: CallOptions + ): Promise< + [ + protos.google.firestore.v1beta1.IBeginTransactionResponse, + protos.google.firestore.v1beta1.IBeginTransactionRequest | undefined, + {} | undefined + ] + >; + beginTransaction( + request: protos.google.firestore.v1beta1.IBeginTransactionRequest, + options: 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?: CallOptions + ): Promise< + [ + protos.google.firestore.v1beta1.ICommitResponse, + protos.google.firestore.v1beta1.ICommitRequest | undefined, + {} | undefined + ] + >; + commit( + request: protos.google.firestore.v1beta1.ICommitRequest, + options: 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?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IRollbackRequest | undefined, + {} | undefined + ] + >; + rollback( + request: protos.google.firestore.v1beta1.IRollbackRequest, + options: 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; + /** + * Gets multiple documents. + * + * Documents returned by this method are not guaranteed to be returned in the + * same order that they were requested. + * + * @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 {string[]} request.documents + * The names of the documents to retrieve. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * The request will fail if any of the document is not a child resource of the + * given `database`. Duplicate names will be elided. + * @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.firestore.v1beta1.TransactionOptions} request.newTransaction + * Starts a new transaction and reads the documents. + * Defaults to a read-only transaction. + * The new transaction ID will be returned as the first response in the + * stream. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 60 seconds. + * @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 [BatchGetDocumentsResponse]{@link google.firestore.v1beta1.BatchGetDocumentsResponse} on 'data' event. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) + * for more details and examples. + * @example + * const stream = client.batchGetDocuments(request); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); + */ + batchGetDocuments( + request?: protos.google.firestore.v1beta1.IBatchGetDocumentsRequest, + options?: CallOptions + ): gax.CancellableStream; + /** + * Runs a query. + * + * @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 {google.firestore.v1beta1.StructuredQuery} request.structuredQuery + * A structured query. + * @param {Buffer} request.transaction + * Reads documents in a transaction. + * @param {google.firestore.v1beta1.TransactionOptions} request.newTransaction + * Starts a new transaction and reads the documents. + * Defaults to a read-only transaction. + * The new transaction ID will be returned as the first response in the + * stream. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 60 seconds. + * @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 [RunQueryResponse]{@link google.firestore.v1beta1.RunQueryResponse} on 'data' event. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) + * for more details and examples. + * @example + * const stream = client.runQuery(request); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); + */ + runQuery( + request?: protos.google.firestore.v1beta1.IRunQueryRequest, + options?: CallOptions + ): gax.CancellableStream; + /** + * Streams batches of document updates and deletes, in order. + * + * @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 is both readable and writable. It accepts objects + * representing [WriteRequest]{@link google.firestore.v1beta1.WriteRequest} for write() method, and + * will emit objects representing [WriteResponse]{@link google.firestore.v1beta1.WriteResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example + * const stream = client.write(); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); + * stream.write(request); + * stream.end(); + */ + write(options?: CallOptions): gax.CancellableStream; + /** + * Listens to changes. + * + * @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 is both readable and writable. It accepts objects + * representing [ListenRequest]{@link google.firestore.v1beta1.ListenRequest} for write() method, and + * will emit objects representing [ListenResponse]{@link google.firestore.v1beta1.ListenResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example + * const stream = client.listen(); + * stream.on('data', (response) => { ... }); + * stream.on('end', () => { ... }); + * stream.write(request); + * stream.end(); + */ + listen(options?: CallOptions): gax.CancellableStream; + listDocuments( + request: protos.google.firestore.v1beta1.IListDocumentsRequest, + options?: 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: 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; + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @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 {Stream} + * An object stream which emits an object representing [Document]{@link google.firestore.v1beta1.Document} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDocumentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listDocumentsStream( + request?: protos.google.firestore.v1beta1.IListDocumentsRequest, + options?: CallOptions + ): Transform; + /** + * Equivalent to `listDocuments`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Document]{@link google.firestore.v1beta1.Document}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listDocumentsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listDocumentsAsync( + request?: protos.google.firestore.v1beta1.IListDocumentsRequest, + options?: CallOptions + ): AsyncIterable; + listCollectionIds( + request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, + options?: CallOptions + ): Promise< + [ + string[], + protos.google.firestore.v1beta1.IListCollectionIdsRequest | null, + protos.google.firestore.v1beta1.IListCollectionIdsResponse + ] + >; + listCollectionIds( + request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, + options: 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 `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @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 {Stream} + * An object stream which emits an object representing string on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCollectionIdsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCollectionIdsStream( + request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, + options?: CallOptions + ): Transform; + /** + * Equivalent to `listCollectionIds`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * string. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listCollectionIdsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listCollectionIdsAsync( + request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, + options?: CallOptions + ): AsyncIterable; + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise; +} From e193ae28500227e3b0de43252fb92d21597eadda Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 2 Mar 2021 15:41:06 -0700 Subject: [PATCH 258/337] chore: release 4.9.5 (#1436) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d32def85..64500e455 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.9.5](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.4...v4.9.5) (2021-03-02) + + +### Bug Fixes + +* add typings to v1 and v1beta in firestore.d.ts ([#1433](https://www.github.com/googleapis/nodejs-firestore/issues/1433)) ([47238a9](https://www.github.com/googleapis/nodejs-firestore/commit/47238a926471dee8bdeaa38bcb5f772c7f20349f)) + ### [4.9.4](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.3...v4.9.4) (2021-02-15) diff --git a/package.json b/package.json index d4a681581..c2c50b6e4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.9.4", + "version": "4.9.5", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 3a1843af7..12805970d 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.9.4" + "@google-cloud/firestore": "^4.9.5" }, "devDependencies": { "chai": "^4.2.0", From c25f1d02aa36a9b8cdf63306a680b524f222a1a8 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 3 Mar 2021 09:14:40 -0800 Subject: [PATCH 259/337] changes without context (#1438) --- dev/protos/protos.json | 3 ++- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dev/protos/protos.json b/dev/protos/protos.json index 753b9b1f9..3c9a3370f 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -3973,7 +3973,8 @@ "REQUIRED": 2, "OUTPUT_ONLY": 3, "INPUT_ONLY": 4, - "IMMUTABLE": 5 + "IMMUTABLE": 5, + "UNORDERED_LIST": 6 } } } diff --git a/synth.metadata b/synth.metadata index bb17b7df3..1ccd99e81 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,8 +3,8 @@ { "git": { "name": ".", - "remote": "git@github.com:googleapis/nodejs-firestore.git", - "sha": "dec8d221efd14b732f2cd2973439c1fb48067ce2" + "remote": "https://github.com/googleapis/nodejs-firestore.git", + "sha": "e193ae28500227e3b0de43252fb92d21597eadda" } }, { From c06fb3cc32f94c9058ad8e484333e688967d5a8f Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 3 Mar 2021 14:17:44 -0800 Subject: [PATCH 260/337] fix: set default max ratelimiter throughput to 10k and update docs (#1439) --- dev/src/bulk-writer.ts | 20 ++++++++++++-------- dev/src/index.ts | 11 ++++++----- dev/src/rate-limiter.ts | 2 +- dev/test/bulk-writer.ts | 13 +++++++------ types/firestore.d.ts | 4 ++++ 5 files changed, 30 insertions(+), 20 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 02585c3b3..f8d6b02e5 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -53,22 +53,26 @@ const MAX_BATCH_SIZE = 20; * The starting maximum number of operations per second as allowed by the * 500/50/5 rule. * - * https://cloud.google.com/datastore/docs/best-practices#ramping_up_traffic. + * https://firebase.google.com/docs/firestore/best-practices#ramping_up_traffic. */ -export const DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND = 500; +export const DEFAULT_INITIAL_OPS_PER_SECOND_LIMIT = 500; /*! - * The rate by which to increase the capacity as specified by the 500/50/5 rule. + * The maximum number of operations per second as allowed by the 500/50/5 rule. + * By default the rate limiter will not exceed this value. * - * https://cloud.google.com/datastore/docs/best-practices#ramping_up_traffic. + * https://firebase.google.com/docs/firestore/best-practices#ramping_up_traffic. + */ +export const DEFAULT_MAXIMUM_OPS_PER_SECOND_LIMIT = 10000; + +/*! + * The rate by which to increase the capacity as specified by the 500/50/5 rule. */ const RATE_LIMITER_MULTIPLIER = 1.5; /*! * How often the operations per second capacity should increase in milliseconds * as specified by the 500/50/5 rule. - * - * https://cloud.google.com/datastore/docs/best-practices#ramping_up_traffic. */ const RATE_LIMITER_MULTIPLIER_MILLIS = 5 * 60 * 1000; @@ -336,8 +340,8 @@ export class BulkWriter { Number.POSITIVE_INFINITY ); } else { - let startingRate = DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND; - let maxRate = Number.POSITIVE_INFINITY; + let startingRate = DEFAULT_INITIAL_OPS_PER_SECOND_LIMIT; + let maxRate = DEFAULT_MAXIMUM_OPS_PER_SECOND_LIMIT; if (typeof options?.throttling !== 'boolean') { if (options?.throttling?.maxOpsPerSecond !== undefined) { diff --git a/dev/src/index.ts b/dev/src/index.ts index 8bb15d0f7..c4b6e66b8 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -728,12 +728,13 @@ export class Firestore implements firestore.Firestore { * multiple writes in parallel. Gradually ramps up writes as specified * by the 500/50/5 rule. * - * @see [500/50/5 Documentation]{@link https://cloud.google.com/datastore/docs/best-practices#ramping_up_traffic} + * If you pass [BulkWriterOptions]{@link BulkWriterOptions}, you can + * configure the throttling rates for the created BulkWriter. * - * @param {object=} options BulkWriter options. - * @param {boolean=} options.disableThrottling Whether to disable throttling - * as specified by the 500/50/5 rule. - * @returns {WriteBatch} A BulkWriter that operates on this Firestore + * @see [500/50/5 Documentation]{@link https://firebase.google.com/docs/firestore/best-practices#ramping_up_traffic} + * + * @param {BulkWriterOptions=} options BulkWriter options. + * @returns {BulkWriter} A BulkWriter that operates on this Firestore * client. * * @example diff --git a/dev/src/rate-limiter.ts b/dev/src/rate-limiter.ts index 28b5e9fc9..a92c26106 100644 --- a/dev/src/rate-limiter.ts +++ b/dev/src/rate-limiter.ts @@ -26,7 +26,7 @@ import {logger} from './logger'; * * RateLimiter can also implement a gradually increasing rate limit. This is * used to enforce the 500/50/5 rule - * (https://cloud.google.com/datastore/docs/best-practices#ramping_up_traffic). + * (https://firebase.google.com/docs/firestore/best-practices#ramping_up_traffic). * * @private */ diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index 2fa241734..60af476e7 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -29,7 +29,8 @@ import { import {setTimeoutHandler} from '../src/backoff'; import { BulkWriterError, - DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND, + DEFAULT_INITIAL_OPS_PER_SECOND_LIMIT, + DEFAULT_MAXIMUM_OPS_PER_SECOND_LIMIT, } from '../src/bulk-writer'; import { ApiOverride, @@ -253,7 +254,7 @@ describe('BulkWriter', () => { }); expect(bulkWriter._rateLimiter.availableTokens).to.equal(100); expect(bulkWriter._rateLimiter.maximumCapacity).to.equal( - Number.POSITIVE_INFINITY + DEFAULT_MAXIMUM_OPS_PER_SECOND_LIMIT ); bulkWriter = firestore.bulkWriter({ @@ -264,18 +265,18 @@ describe('BulkWriter', () => { bulkWriter = firestore.bulkWriter(); expect(bulkWriter._rateLimiter.availableTokens).to.equal( - DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND + DEFAULT_INITIAL_OPS_PER_SECOND_LIMIT ); expect(bulkWriter._rateLimiter.maximumCapacity).to.equal( - Number.POSITIVE_INFINITY + DEFAULT_MAXIMUM_OPS_PER_SECOND_LIMIT ); bulkWriter = firestore.bulkWriter({throttling: true}); expect(bulkWriter._rateLimiter.availableTokens).to.equal( - DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND + DEFAULT_INITIAL_OPS_PER_SECOND_LIMIT ); expect(bulkWriter._rateLimiter.maximumCapacity).to.equal( - Number.POSITIVE_INFINITY + DEFAULT_MAXIMUM_OPS_PER_SECOND_LIMIT ); bulkWriter = firestore.bulkWriter({throttling: false}); diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 8f5c00c20..ed6c81ef0 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -290,6 +290,8 @@ declare namespace FirebaseFirestore { * multiple writes in parallel. Gradually ramps up writes as specified * by the 500/50/5 rule. * + * @see https://firebase.google.com/docs/firestore/best-practices#ramping_up_traffic + * * @param options An options object used to configure the throttling * behavior for the underlying BulkWriter. */ @@ -682,6 +684,8 @@ declare namespace FirebaseFirestore { * the defaults by setting it to `false` to disable throttling, or by * setting the config values to enable throttling with the provided values. * + * @see https://firebase.google.com/docs/firestore/best-practices#ramping_up_traffic + * * @param initialOpsPerSecond The initial maximum number of operations per * second allowed by the throttler. If this field is not set, the default * is 500 operations per second. From 7d2a38399fd04251fff318504644a1670c451908 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 3 Mar 2021 23:42:04 +0000 Subject: [PATCH 261/337] chore: release 4.9.6 (#1440) :robot: I have created a release \*beep\* \*boop\* --- ### [4.9.6](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.5...v4.9.6) (2021-03-03) ### Bug Fixes * set default max ratelimiter throughput to 10k for BulkWriter ([#1439](https://www.github.com/googleapis/nodejs-firestore/issues/1439)) ([c06fb3c](https://www.github.com/googleapis/nodejs-firestore/commit/c06fb3cc32f94c9058ad8e484333e688967d5a8f)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64500e455..e38816001 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.9.6](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.5...v4.9.6) (2021-03-03) + + +### Bug Fixes + +* set default max ratelimiter throughput to 10k for BulkWriter ([#1439](https://www.github.com/googleapis/nodejs-firestore/issues/1439)) ([c06fb3c](https://www.github.com/googleapis/nodejs-firestore/commit/c06fb3cc32f94c9058ad8e484333e688967d5a8f)) + ### [4.9.5](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.4...v4.9.5) (2021-03-02) diff --git a/package.json b/package.json index c2c50b6e4..6646f0def 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.9.5", + "version": "4.9.6", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 12805970d..a4a54b2c6 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.9.5" + "@google-cloud/firestore": "^4.9.6" }, "devDependencies": { "chai": "^4.2.0", From 6c9319ed6e2ac0dfe0fcf45853f0b38dc0784686 Mon Sep 17 00:00:00 2001 From: Marc Porciuncula Date: Wed, 10 Mar 2021 02:51:22 +1100 Subject: [PATCH 262/337] fix: export v1 and v1beta1 client class types correctly (#1445) --- types/firestore.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/firestore.d.ts b/types/firestore.d.ts index ed6c81ef0..9181c4fde 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -1967,7 +1967,7 @@ declare namespace FirebaseFirestore { * @deprecated Use v1 instead. */ export const v1beta1: { - FirestoreClient: import('./v1beta1/firestore_client').FirestoreClient; + FirestoreClient: typeof import('./v1beta1/firestore_client').FirestoreClient; }; /** @@ -1975,8 +1975,8 @@ declare namespace FirebaseFirestore { * API and the underlying Firestore v1 RPCs. */ export const v1: { - FirestoreClient: import('./v1/firestore_client').FirestoreClient; - FirestoreAdminClient: import('./v1/firestore_admin_client').FirestoreAdminClient; + FirestoreClient: typeof import('./v1/firestore_client').FirestoreClient; + FirestoreAdminClient: typeof import('./v1/firestore_admin_client').FirestoreAdminClient; }; /** From cccf48de4963403a2e77ba241641a2b77fb993da Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 9 Mar 2021 12:07:48 -0600 Subject: [PATCH 263/337] fix: retry BulkWriter deletes that fail with RST_STREAM error (#1442) * fix: retry BulkWriter deletes that fail with RST_STREAM errors * resolve comments * remove .only on test * remove undefined check * lint --- dev/src/bulk-writer.ts | 6 ++++-- dev/test/bulk-writer.ts | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index f8d6b02e5..33cd78638 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -316,10 +316,12 @@ export class BulkWriter { * @private */ private _errorFn: (error: BulkWriterError) => boolean = error => { + const isRetryableDeleteError = + error.operationType === 'delete' && + (error.code as number) === Status.INTERNAL; const retryCodes = getRetryCodes('batchWrite'); return ( - error.code !== undefined && - retryCodes.includes(error.code) && + (retryCodes.includes(error.code) || isRetryableDeleteError) && error.failedAttempts < MAX_RETRY_ATTEMPTS ); }; diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index 60af476e7..98db720cc 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -536,9 +536,9 @@ describe('BulkWriter', () => { ]), response: mergeResponses([ successResponse(1), - failedResponse(Status.INTERNAL), - failedResponse(Status.INTERNAL), - failedResponse(Status.INTERNAL), + failedResponse(Status.CANCELLED), + failedResponse(Status.CANCELLED), + failedResponse(Status.CANCELLED), ]), }, { @@ -606,6 +606,35 @@ describe('BulkWriter', () => { expect(onWriteErrorCalled).to.be.true; }); + it('retries INTERNAL errors for deletes', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([setOp('doc1', 'bar'), deleteOp('doc2')]), + response: mergeResponses([ + failedResponse(Status.INTERNAL), + failedResponse(Status.INTERNAL), + ]), + }, + { + request: createRequest([deleteOp('doc2')]), + response: successResponse(2), + }, + ]); + + let errorCaught = false; + bulkWriter + .set(firestore.doc('collectionId/doc1'), { + foo: 'bar', + }) + .catch(() => { + errorCaught = true; + }); + const del = bulkWriter.delete(firestore.doc('collectionId/doc2')); + await bulkWriter.close(); + expect((await del).writeTime).to.deep.equal(new Timestamp(2, 0)); + expect(errorCaught).to.be.true; + }); + it('surfaces errors thrown by user-provided error callback', async () => { const bulkWriter = await instantiateInstance([ { @@ -860,7 +889,7 @@ describe('BulkWriter', () => { return bulkWriter.close().then(() => verifyOpCount(2)); }); - it('retries individual writes that fail with ABORTED errors', async () => { + it('retries individual writes that fail with ABORTED and UNAVAILABLE errors', async () => { setTimeoutHandler(setImmediate); // Create mock responses that simulate one successful write followed by // failed responses. From a36bb09e4895aba93b7879b891f0da2e88e99789 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 9 Mar 2021 18:24:02 +0000 Subject: [PATCH 264/337] chore: release 4.9.7 (#1446) :robot: I have created a release \*beep\* \*boop\* --- ### [4.9.7](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.6...v4.9.7) (2021-03-09) ### Bug Fixes * export v1 and v1beta1 client class types correctly ([#1445](https://www.github.com/googleapis/nodejs-firestore/issues/1445)) ([6c9319e](https://www.github.com/googleapis/nodejs-firestore/commit/6c9319ed6e2ac0dfe0fcf45853f0b38dc0784686)) * retry BulkWriter deletes that fail with RST_STREAM error ([#1442](https://www.github.com/googleapis/nodejs-firestore/issues/1442)) ([cccf48d](https://www.github.com/googleapis/nodejs-firestore/commit/cccf48de4963403a2e77ba241641a2b77fb993da)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e38816001..f5d749dc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.9.7](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.6...v4.9.7) (2021-03-09) + + +### Bug Fixes + +* export v1 and v1beta1 client class types correctly ([#1445](https://www.github.com/googleapis/nodejs-firestore/issues/1445)) ([6c9319e](https://www.github.com/googleapis/nodejs-firestore/commit/6c9319ed6e2ac0dfe0fcf45853f0b38dc0784686)) +* retry BulkWriter deletes that fail with RST_STREAM error ([#1442](https://www.github.com/googleapis/nodejs-firestore/issues/1442)) ([cccf48d](https://www.github.com/googleapis/nodejs-firestore/commit/cccf48de4963403a2e77ba241641a2b77fb993da)) + ### [4.9.6](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.5...v4.9.6) (2021-03-03) diff --git a/package.json b/package.json index 6646f0def..d859a9841 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.9.6", + "version": "4.9.7", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index a4a54b2c6..efbe6014c 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.9.6" + "@google-cloud/firestore": "^4.9.7" }, "devDependencies": { "chai": "^4.2.0", From f48308344a90d2da48af99a878f0384b7b93f704 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Mon, 15 Mar 2021 13:46:58 -0500 Subject: [PATCH 265/337] fix: BulkWriter: add backoff on retries (#1447) --- dev/src/backoff.ts | 6 +- dev/src/bulk-writer.ts | 84 ++++++++++++++++++++---- dev/test/bulk-writer.ts | 140 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 209 insertions(+), 21 deletions(-) diff --git a/dev/src/backoff.ts b/dev/src/backoff.ts index defba9621..b7e2669b9 100644 --- a/dev/src/backoff.ts +++ b/dev/src/backoff.ts @@ -30,17 +30,17 @@ import {logger} from './logger'; * The default initial backoff time in milliseconds after an error. * Set to 1s according to https://cloud.google.com/apis/design/errors. */ -const DEFAULT_BACKOFF_INITIAL_DELAY_MS = 1000; +export const DEFAULT_BACKOFF_INITIAL_DELAY_MS = 1000; /*! * The default maximum backoff time in milliseconds. */ -const DEFAULT_BACKOFF_MAX_DELAY_MS = 60 * 1000; +export const DEFAULT_BACKOFF_MAX_DELAY_MS = 60 * 1000; /*! * The default factor to increase the backup by after each failed attempt. */ -const DEFAULT_BACKOFF_FACTOR = 1.5; +export const DEFAULT_BACKOFF_FACTOR = 1.5; /*! * The default jitter to distribute the backoff attempts by (0 means no diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 33cd78638..d4d2ac598 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -19,7 +19,13 @@ import * as assert from 'assert'; import {google} from '../protos/firestore_v1_proto_api'; import {FieldPath, Firestore} from '.'; -import {delayExecution, MAX_RETRY_ATTEMPTS} from './backoff'; +import { + DEFAULT_BACKOFF_FACTOR, + DEFAULT_BACKOFF_INITIAL_DELAY_MS, + DEFAULT_BACKOFF_MAX_DELAY_MS, + delayExecution, + MAX_RETRY_ATTEMPTS, +} from './backoff'; import {RateLimiter} from './rate-limiter'; import {DocumentReference} from './reference'; import {Timestamp} from './timestamp'; @@ -65,6 +71,12 @@ export const DEFAULT_INITIAL_OPS_PER_SECOND_LIMIT = 500; */ export const DEFAULT_MAXIMUM_OPS_PER_SECOND_LIMIT = 10000; +/*! + * The default jitter to apply to the exponential backoff used in retries. For + * example, a factor of 0.3 means a 30% jitter is applied. + */ +export const DEFAULT_JITTER_FACTOR = 0.3; + /*! * The rate by which to increase the capacity as specified by the 500/50/5 rule. */ @@ -84,6 +96,8 @@ const RATE_LIMITER_MULTIPLIER_MILLIS = 5 * 60 * 1000; class BulkWriterOperation { private deferred = new Deferred(); private failedAttempts = 0; + private lastStatus?: Status; + private _backoffDuration = 0; /** * @param ref The document reference being written to. @@ -107,6 +121,10 @@ class BulkWriterOperation { return this.deferred.promise; } + get backoffDuration(): number { + return this._backoffDuration; + } + onError(error: GoogleError): void { ++this.failedAttempts; @@ -131,6 +149,8 @@ class BulkWriterOperation { ); if (shouldRetry) { + this.lastStatus = error.code; + this.updateBackoffDuration(); this.sendFn(this); } else { this.deferred.reject(bulkWriterError); @@ -140,6 +160,16 @@ class BulkWriterOperation { } } + private updateBackoffDuration(): void { + if (this.lastStatus === Status.RESOURCE_EXHAUSTED) { + this._backoffDuration = DEFAULT_BACKOFF_MAX_DELAY_MS; + } else if (this._backoffDuration === 0) { + this._backoffDuration = DEFAULT_BACKOFF_INITIAL_DELAY_MS; + } else { + this._backoffDuration *= DEFAULT_BACKOFF_FACTOR; + } + } + onSuccess(result: WriteResult): void { try { this.successFn(this.ref, result); @@ -161,7 +191,7 @@ class BulkCommitBatch extends WriteBatch { // An array of pending write operations. Only contains writes that have not // been resolved. - private pendingOps: Array = []; + readonly pendingOps: Array = []; has(documentRef: firestore.DocumentReference): boolean { return this.docPaths.has(documentRef.path); @@ -279,7 +309,7 @@ export class BulkWriter { private _bulkCommitBatch = new BulkCommitBatch(this.firestore); /** - * A pointer to the tail of all active BulkWriter applications. This pointer + * A pointer to the tail of all active BulkWriter operations. This pointer * is advanced every time a new write is enqueued. * @private */ @@ -714,35 +744,61 @@ export class BulkWriter { const tag = requestTag(); const pendingBatch = this._bulkCommitBatch; - this._bulkCommitBatch = new BulkCommitBatch(this.firestore); - - // Send the batch if it is under the rate limit, or schedule another - // attempt after the appropriate timeout. - const underRateLimit = this._rateLimiter.tryMakeRequest( + // Use the write with the longest backoff duration when determining backoff. + const highestBackoffDuration = pendingBatch.pendingOps.reduce((prev, cur) => + prev.backoffDuration > cur.backoffDuration ? prev : cur + ).backoffDuration; + const backoffMsWithJitter = BulkWriter.applyJitter(highestBackoffDuration); + const delayMs = this._rateLimiter.getNextRequestDelayMs( pendingBatch._opCount ); + const finalDelayMs = Math.max(backoffMsWithJitter, delayMs); const delayedExecution = new Deferred(); - if (underRateLimit) { - delayedExecution.resolve(); - } else { - const delayMs = this._rateLimiter.getNextRequestDelayMs( + this._bulkCommitBatch = new BulkCommitBatch(this.firestore); + + // Send the batch if it is does not require any delay, or schedule another + // attempt after the appropriate timeout. + if (finalDelayMs === 0) { + const underRateLimit = this._rateLimiter.tryMakeRequest( pendingBatch._opCount ); + assert( + underRateLimit, + 'RateLimiter should allow request if delayMs === 0' + ); + delayedExecution.resolve(); + } else { logger( 'BulkWriter._sendCurrentBatch', tag, - `Backing off for ${delayMs} seconds` + `Backing off for ${finalDelayMs} seconds` ); - delayExecution(() => delayedExecution.resolve(), delayMs); + delayExecution(() => delayedExecution.resolve(), finalDelayMs); } delayedExecution.promise.then(async () => { + // This should subtract rate limit, but it's not. await pendingBatch.bulkCommit({requestTag: tag}); if (flush) this._sendCurrentBatch(flush); }); } + /** + * Adds a 30% jitter to the provided backoff. + * + * @private + */ + private static applyJitter(backoffMs: number): number { + if (backoffMs === 0) return 0; + // Random value in [-0.3, 0.3]. + const jitter = DEFAULT_JITTER_FACTOR * (Math.random() * 2 - 1); + return Math.min( + DEFAULT_BACKOFF_MAX_DELAY_MS, + backoffMs + jitter * backoffMs + ); + } + /** * Schedules and runs the provided operation on the next available batch. * @private diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index 98db720cc..81456a6e0 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -26,10 +26,17 @@ import { Timestamp, WriteResult, } from '../src'; -import {setTimeoutHandler} from '../src/backoff'; +import { + DEFAULT_BACKOFF_FACTOR, + DEFAULT_BACKOFF_INITIAL_DELAY_MS, + DEFAULT_BACKOFF_MAX_DELAY_MS, + MAX_RETRY_ATTEMPTS, + setTimeoutHandler, +} from '../src/backoff'; import { BulkWriterError, DEFAULT_INITIAL_OPS_PER_SECOND_LIMIT, + DEFAULT_JITTER_FACTOR, DEFAULT_MAXIMUM_OPS_PER_SECOND_LIMIT, } from '../src/bulk-writer'; import { @@ -45,7 +52,6 @@ import { updateMask, verifyInstance, } from './util/helpers'; - import api = proto.google.firestore.v1; // Change the argument to 'console.log' to enable debug output. @@ -180,7 +186,6 @@ describe('BulkWriter', () => { afterEach(() => { verifyInstance(firestore); - expect(timeoutHandlerCounter).to.equal(0); setTimeoutHandler(setTimeout); }); @@ -579,6 +584,7 @@ describe('BulkWriter', () => { 'success', ]); expect(writeResults).to.deep.equal([1, 2, 3, 4]); + expect(timeoutHandlerCounter).to.equal(1); }); }); @@ -707,6 +713,7 @@ describe('BulkWriter', () => { }); await bulkWriter.close(); expect(writeResult).to.equal(1); + expect(timeoutHandlerCounter).to.equal(3); }); it('retries maintain correct write resolution ordering', async () => { @@ -1027,7 +1034,16 @@ describe('BulkWriter', () => { }); it('fails writes after all retry attempts failed', async () => { - setTimeoutHandler(setImmediate); + setTimeoutHandler((fn, timeout) => { + const expected = + DEFAULT_BACKOFF_INITIAL_DELAY_MS * Math.pow(1.5, timeoutHandlerCounter); + expect(timeout).to.be.within( + (1 - DEFAULT_JITTER_FACTOR) * expected, + (1 + DEFAULT_JITTER_FACTOR) * expected + ); + timeoutHandlerCounter++; + fn(); + }); function instantiateInstance(): Promise { const overrides: ApiOverride = { batchWrite: () => { @@ -1053,7 +1069,123 @@ describe('BulkWriter', () => { }); return bulkWriter.close().then(() => { verifyOpCount(1); + expect(timeoutHandlerCounter).to.equal(MAX_RETRY_ATTEMPTS - 1); + }); + }); + + it('applies maximum backoff on retries for RESOURCE_EXHAUSTED', async () => { + setTimeoutHandler((fn, timeout) => { + timeoutHandlerCounter++; + expect(timeout).to.be.within( + (1 - DEFAULT_JITTER_FACTOR) * DEFAULT_BACKOFF_MAX_DELAY_MS, + (1 + DEFAULT_JITTER_FACTOR) * DEFAULT_BACKOFF_MAX_DELAY_MS + ); + fn(); + }); + function instantiateInstance(): Promise { + const overrides: ApiOverride = { + batchWrite: () => { + const error = new GoogleError('Mock batchWrite failed in test'); + error.code = Status.RESOURCE_EXHAUSTED; + throw error; + }, + }; + return createInstance(overrides).then(firestoreClient => { + firestore = firestoreClient; + return firestore.bulkWriter(); + }); + } + const bulkWriter = await instantiateInstance(); + bulkWriter.onWriteError(err => err.failedAttempts < 5); + bulkWriter + .create(firestore.doc('collectionId/doc'), { + foo: 'bar', + }) + .catch(err => { + expect(err instanceof BulkWriterError).to.be.true; + expect(err.code).to.equal(Status.RESOURCE_EXHAUSTED); + incrementOpCount(); + }); + return bulkWriter.close().then(() => { + verifyOpCount(1); + expect(timeoutHandlerCounter).to.equal(4); + }); + }); + + it('uses the highest backoff found in the batch', async () => { + const expected = [ + DEFAULT_BACKOFF_MAX_DELAY_MS, + DEFAULT_BACKOFF_INITIAL_DELAY_MS * DEFAULT_BACKOFF_FACTOR, + ]; + setTimeoutHandler((fn, timeout) => { + // 1st batch should have max backoff. 2nd batch should have 1 round + // of backoff applied. + expect(timeout).to.be.within( + (1 - DEFAULT_JITTER_FACTOR) * expected[timeoutHandlerCounter], + (1 + DEFAULT_JITTER_FACTOR) * expected[timeoutHandlerCounter] + ); + timeoutHandlerCounter++; + fn(); + }); + const bulkWriter = await instantiateInstance([ + { + request: createRequest([createOp('doc1', 'bar'), setOp('doc2', 'bar')]), + response: mergeResponses([ + failedResponse(Status.RESOURCE_EXHAUSTED), + failedResponse(Status.UNAVAILABLE), + ]), + }, + { + request: createRequest([createOp('doc1', 'bar'), setOp('doc2', 'bar')]), + response: mergeResponses([ + successResponse(1), + failedResponse(Status.UNAVAILABLE), + ]), + }, + { + request: createRequest([setOp('doc2', 'bar')]), + response: successResponse(2), + }, + ]); + + bulkWriter.onWriteError(err => err.failedAttempts < 5); + bulkWriter.create(firestore.doc('collectionId/doc1'), { + foo: 'bar', + }); + bulkWriter.set(firestore.doc('collectionId/doc2'), { + foo: 'bar', + }); + return bulkWriter.close().then(() => { + expect(timeoutHandlerCounter).to.equal(2); + }); + }); + + it('sends backoff batch after other enqueued batches', async () => { + setTimeoutHandler(setImmediate); + const bulkWriter = await instantiateInstance([ + { + request: createRequest([createOp('doc1', 'bar')]), + response: failedResponse(Status.RESOURCE_EXHAUSTED), + }, + { + request: createRequest([setOp('doc2', 'bar')]), + response: successResponse(1), + }, + { + request: createRequest([createOp('doc1', 'bar')]), + response: successResponse(2), + }, + ]); + + bulkWriter.onWriteError(err => err.failedAttempts < 5); + bulkWriter.create(firestore.doc('collectionId/doc1'), { + foo: 'bar', }); + bulkWriter.flush(); + bulkWriter.set(firestore.doc('collectionId/doc2'), { + foo: 'bar', + }); + return bulkWriter.close(); }); describe('if bulkCommit() fails', async () => { From fee8a0439c61628c41b82adee8dc6573414f9fd7 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 16 Mar 2021 12:24:08 -0600 Subject: [PATCH 266/337] chore: release 4.9.8 (#1450) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5d749dc4..69d86620e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.9.8](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.7...v4.9.8) (2021-03-15) + + +### Bug Fixes + +* BulkWriter: add backoff on retries ([#1447](https://www.github.com/googleapis/nodejs-firestore/issues/1447)) ([f483083](https://www.github.com/googleapis/nodejs-firestore/commit/f48308344a90d2da48af99a878f0384b7b93f704)) + ### [4.9.7](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.6...v4.9.7) (2021-03-09) diff --git a/package.json b/package.json index d859a9841..e89188e6c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.9.7", + "version": "4.9.8", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index efbe6014c..69751534b 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.9.7" + "@google-cloud/firestore": "^4.9.8" }, "devDependencies": { "chai": "^4.2.0", From 3a50f8b524a73d60c6034d4828682b9dc1b49d6e Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 16 Mar 2021 18:31:20 -0500 Subject: [PATCH 267/337] fix: BulkWriter: apply rate limiter before sending batch (#1451) --- dev/src/bulk-writer.ts | 64 ++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index d4d2ac598..1ddad577d 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -684,7 +684,7 @@ export class BulkWriter { */ flush(): Promise { this._verifyNotClosed(); - this._sendCurrentBatch(/* flush= */ true); + this._scheduleCurrentBatch(/* flush= */ true); return this._lastOp; } @@ -738,50 +738,52 @@ export class BulkWriter { * `flush()` or `close()` call. * @private */ - private _sendCurrentBatch(flush = false): void { + private _scheduleCurrentBatch(flush = false): void { if (this._bulkCommitBatch._opCount === 0) return; - const tag = requestTag(); const pendingBatch = this._bulkCommitBatch; + this._bulkCommitBatch = new BulkCommitBatch(this.firestore); // Use the write with the longest backoff duration when determining backoff. const highestBackoffDuration = pendingBatch.pendingOps.reduce((prev, cur) => prev.backoffDuration > cur.backoffDuration ? prev : cur ).backoffDuration; - const backoffMsWithJitter = BulkWriter.applyJitter(highestBackoffDuration); - const delayMs = this._rateLimiter.getNextRequestDelayMs( - pendingBatch._opCount - ); - const finalDelayMs = Math.max(backoffMsWithJitter, delayMs); - + const backoffMsWithJitter = BulkWriter._applyJitter(highestBackoffDuration); const delayedExecution = new Deferred(); - this._bulkCommitBatch = new BulkCommitBatch(this.firestore); + + if (backoffMsWithJitter > 0) { + delayExecution(() => delayedExecution.resolve(), backoffMsWithJitter); + } else { + delayedExecution.resolve(); + } + + delayedExecution.promise.then(() => this._sendBatch(pendingBatch, flush)); + } + + /** + * Sends the provided batch once the rate limiter does not require any delay. + */ + private async _sendBatch( + batch: BulkCommitBatch, + flush = false + ): Promise { + const tag = requestTag(); // Send the batch if it is does not require any delay, or schedule another // attempt after the appropriate timeout. - if (finalDelayMs === 0) { - const underRateLimit = this._rateLimiter.tryMakeRequest( - pendingBatch._opCount - ); - assert( - underRateLimit, - 'RateLimiter should allow request if delayMs === 0' - ); - delayedExecution.resolve(); + const underRateLimit = this._rateLimiter.tryMakeRequest(batch._opCount); + if (underRateLimit) { + await batch.bulkCommit({requestTag: tag}); + if (flush) this._scheduleCurrentBatch(flush); } else { + const delayMs = this._rateLimiter.getNextRequestDelayMs(batch._opCount); logger( - 'BulkWriter._sendCurrentBatch', + 'BulkWriter._sendBatch', tag, - `Backing off for ${finalDelayMs} seconds` + `Backing off for ${delayMs} seconds` ); - delayExecution(() => delayedExecution.resolve(), finalDelayMs); + delayExecution(() => this._sendBatch(batch, flush), delayMs); } - - delayedExecution.promise.then(async () => { - // This should subtract rate limit, but it's not. - await pendingBatch.bulkCommit({requestTag: tag}); - if (flush) this._sendCurrentBatch(flush); - }); } /** @@ -789,7 +791,7 @@ export class BulkWriter { * * @private */ - private static applyJitter(backoffMs: number): number { + private static _applyJitter(backoffMs: number): number { if (backoffMs === 0) return 0; // Random value in [-0.3, 0.3]. const jitter = DEFAULT_JITTER_FACTOR * (Math.random() * 2 - 1); @@ -832,7 +834,7 @@ export class BulkWriter { if (this._bulkCommitBatch.has(op.ref)) { // Create a new batch since the backend doesn't support batches with two // writes to the same document. - this._sendCurrentBatch(); + this._scheduleCurrentBatch(); } // Run the operation on the current batch and advance the `_lastOp` pointer. @@ -843,7 +845,7 @@ export class BulkWriter { this._lastOp = this._lastOp.then(() => silencePromise(op.promise)); if (this._bulkCommitBatch._opCount === this._maxBatchSize) { - this._sendCurrentBatch(); + this._scheduleCurrentBatch(); } } } From c7d67fb749aaf76050c08d29b4c6fca28ec9f5ce Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 23 Mar 2021 17:48:20 +0100 Subject: [PATCH 268/337] chore(deps): update dependency sinon to v10 (#1454) [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [sinon](https://sinonjs.org/) ([source](https://togithub.com/sinonjs/sinon)) | [`^9.0.2` -> `^10.0.0`](https://renovatebot.com/diffs/npm/sinon/9.2.4/10.0.0) | [![age](https://badges.renovateapi.com/packages/npm/sinon/10.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/sinon/10.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/sinon/10.0.0/compatibility-slim/9.2.4)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/sinon/10.0.0/confidence-slim/9.2.4)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
sinonjs/sinon ### [`v10.0.0`](https://togithub.com/sinonjs/sinon/blob/master/CHANGELOG.md#​1000--2021-03-22) [Compare Source](https://togithub.com/sinonjs/sinon/compare/v9.2.4...v10.0.0) ================== - Upgrade nise to 4.1.0 - Use [@​sinonjs/eslint-config](https://togithub.com/sinonjs/eslint-config)[@​4](https://togithub.com/4) => Adopts ES2017 => Drops support for IE 11, Legacy Edge and legacy Safari
--- ### Renovate configuration :date: **Schedule**: "after 9am and before 3pm" (UTC). :vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied. :recycle: **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. :no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/nodejs-firestore). --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e89188e6c..68308bd57 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "linkinator": "^2.0.0", "mocha": "^7.0.0", "proxyquire": "^2.1.3", - "sinon": "^9.0.2", + "sinon": "^10.0.0", "ts-node": "^9.0.0", "typescript": "3.8.3", "through2": "^4.0.0", From 42ade788be6e9c1ba01b6e81779e5185d5cc75cd Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 25 Mar 2021 17:54:06 -0700 Subject: [PATCH 269/337] docs: update dates generated code --- dev/protos/google/type/latlng.proto | 2 +- synth.metadata | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/protos/google/type/latlng.proto b/dev/protos/google/type/latlng.proto index a90b7c23d..9231456e3 100644 --- a/dev/protos/google/type/latlng.proto +++ b/dev/protos/google/type/latlng.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/synth.metadata b/synth.metadata index 1ccd99e81..549bdc5c5 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "e193ae28500227e3b0de43252fb92d21597eadda" + "sha": "c7d67fb749aaf76050c08d29b4c6fca28ec9f5ce" } }, { From 97e728188a097760bd52099ec852a716a25b4745 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 6 Apr 2021 19:33:23 -0500 Subject: [PATCH 270/337] fix: remove floating point rounding error in Timestamp.fromMillis() (#1464) --- dev/src/timestamp.ts | 4 +++- dev/test/timestamp.ts | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dev/src/timestamp.ts b/dev/src/timestamp.ts index a50e62bb2..926b4c256 100644 --- a/dev/src/timestamp.ts +++ b/dev/src/timestamp.ts @@ -107,7 +107,9 @@ export class Timestamp implements firestore.Timestamp { */ static fromMillis(milliseconds: number): Timestamp { const seconds = Math.floor(milliseconds / 1000); - const nanos = (milliseconds - seconds * 1000) * MS_TO_NANOS; + const nanos = Math.floor( + milliseconds * MS_TO_NANOS - seconds * 1000 * MS_TO_NANOS + ); return new Timestamp(seconds, nanos); } diff --git a/dev/test/timestamp.ts b/dev/test/timestamp.ts index cb08df086..34a619841 100644 --- a/dev/test/timestamp.ts +++ b/dev/test/timestamp.ts @@ -132,6 +132,12 @@ describe('timestamps', () => { expect(actual.isEqual(expected)).to.be.true; }); + it('handles decimal inputs in fromMillis()', () => { + const actual = Firestore.Timestamp.fromMillis(1000.1); + const expected = new Firestore.Timestamp(1, 100000); + expect(actual.isEqual(expected)).to.be.true; + }); + it('validates seconds', () => { expect(() => new Firestore.Timestamp(0.1, 0)).to.throw( 'Value for argument "seconds" is not a valid integer.' From db989fcb0d0a67ccbb6e42f8baed07e14e8dc210 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 7 Apr 2021 09:10:03 -0600 Subject: [PATCH 271/337] chore: release 4.9.9 (#1452) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69d86620e..9efb23765 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.9.9](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.8...v4.9.9) (2021-04-07) + + +### Bug Fixes + +* BulkWriter: apply rate limiter before sending batch ([#1451](https://www.github.com/googleapis/nodejs-firestore/issues/1451)) ([3a50f8b](https://www.github.com/googleapis/nodejs-firestore/commit/3a50f8b524a73d60c6034d4828682b9dc1b49d6e)) +* remove floating point rounding error in Timestamp.fromMillis() ([#1464](https://www.github.com/googleapis/nodejs-firestore/issues/1464)) ([97e7281](https://www.github.com/googleapis/nodejs-firestore/commit/97e728188a097760bd52099ec852a716a25b4745)) + ### [4.9.8](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.7...v4.9.8) (2021-03-15) diff --git a/package.json b/package.json index 68308bd57..7b1155b53 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.9.8", + "version": "4.9.9", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 69751534b..e6f314a6e 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.9.8" + "@google-cloud/firestore": "^4.9.9" }, "devDependencies": { "chai": "^4.2.0", From cf1949f99f840d1e34edfa31a223418abdf48372 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Mon, 12 Apr 2021 13:49:42 -0500 Subject: [PATCH 272/337] fix: use BigInt when calculating nanos in Timestamp.fromMillis() (#1468) --- dev/src/timestamp.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dev/src/timestamp.ts b/dev/src/timestamp.ts index 926b4c256..69cb98e8e 100644 --- a/dev/src/timestamp.ts +++ b/dev/src/timestamp.ts @@ -107,9 +107,7 @@ export class Timestamp implements firestore.Timestamp { */ static fromMillis(milliseconds: number): Timestamp { const seconds = Math.floor(milliseconds / 1000); - const nanos = Math.floor( - milliseconds * MS_TO_NANOS - seconds * 1000 * MS_TO_NANOS - ); + const nanos = Math.floor((milliseconds - seconds * 1000) * MS_TO_NANOS); return new Timestamp(seconds, nanos); } From 9cc954849c74199f01e52b24fc7ba045d5b56be4 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 13 Apr 2021 13:26:03 -0500 Subject: [PATCH 273/337] feat: add buffering layer to BulkWriter (#1470) --- dev/src/bulk-writer.ts | 96 ++++++++++++++++++++++++++++++++++++++--- dev/test/bulk-writer.ts | 42 ++++++++++++++++++ 2 files changed, 132 insertions(+), 6 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 1ddad577d..5871af522 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -88,6 +88,14 @@ const RATE_LIMITER_MULTIPLIER = 1.5; */ const RATE_LIMITER_MULTIPLIER_MILLIS = 5 * 60 * 1000; +/*! + * The default maximum number of pending operations that can be enqueued onto a + * BulkWriter instance. An operation is considered pending if BulkWriter has + * sent it via RPC and is awaiting the result. BulkWriter buffers additional + * writes after this many pending operations in order to avoiding going OOM. + */ +const DEFAULT_MAXIMUM_PENDING_OPERATIONS_COUNT = 500; + /** * Represents a single write for BulkWriter, encapsulating operation dispatch * and error handling. @@ -330,6 +338,39 @@ export class BulkWriter { */ readonly _rateLimiter: RateLimiter; + /** + * The number of pending operations enqueued on this BulkWriter instance. + * An operation is considered pending if BulkWriter has sent it via RPC and + * is awaiting the result. + * @private + */ + private _pendingOpsCount = 0; + + /** + * An array containing buffered BulkWriter operations after the maximum number + * of pending operations has been enqueued. + * @private + */ + private _bufferedOperations: Array<() => void> = []; + + // Visible for testing. + _getBufferedOperationsCount(): number { + return this._bufferedOperations.length; + } + + /** + * The maximum number of pending operations that can be enqueued onto this + * BulkWriter instance. Once the this number of writes have been enqueued, + * subsequent writes are buffered. + * @private + */ + private _maxPendingOpCount = DEFAULT_MAXIMUM_PENDING_OPERATIONS_COUNT; + + // Visible for testing. + _setMaxPendingOpCount(newMax: number): void { + this._maxPendingOpCount = newMax; + } + /** * The user-provided callback to be run every time a BulkWriter operation * successfully completes. @@ -817,8 +858,55 @@ export class BulkWriter { this._errorFn.bind(this), this._successFn.bind(this) ); - this._sendFn(enqueueOnBatchCallback, bulkWriterOp); - return bulkWriterOp.promise; + + // Advance the `_lastOp` pointer. This ensures that `_lastOp` only resolves + // when both the previous and the current write resolves. + this._lastOp = this._lastOp.then(() => + silencePromise(bulkWriterOp.promise) + ); + + // Schedule the operation if the BulkWriter has fewer than the maximum + // number of allowed pending operations, or add the operation to the + // buffer. + if (this._pendingOpsCount < this._maxPendingOpCount) { + this._pendingOpsCount++; + this._sendFn(enqueueOnBatchCallback, bulkWriterOp); + } else { + this._bufferedOperations.push(() => { + this._pendingOpsCount++; + this._sendFn(enqueueOnBatchCallback, bulkWriterOp); + }); + } + + // Chain the BulkWriter operation promise with the buffer processing logic + // in order to ensure that it runs and that subsequent operations are + // enqueued before the next batch is scheduled in `_sendBatch()`. + return bulkWriterOp.promise + .then(res => { + this._pendingOpsCount--; + this._processBufferedOps(); + return res; + }) + .catch(err => { + this._pendingOpsCount--; + this._processBufferedOps(); + throw err; + }); + } + + /** + * Manages the pending operation counter and schedules the next BulkWriter + * operation if we're under the maximum limit. + * @private + */ + private _processBufferedOps(): void { + if ( + this._pendingOpsCount < this._maxPendingOpCount && + this._bufferedOperations.length > 0 + ) { + const nextOp = this._bufferedOperations.shift()!; + nextOp(); + } } /** @@ -837,12 +925,8 @@ export class BulkWriter { this._scheduleCurrentBatch(); } - // Run the operation on the current batch and advance the `_lastOp` pointer. - // This ensures that `_lastOp` only resolves when both the previous and the - // current write resolves. enqueueOnBatchCallback(this._bulkCommitBatch); this._bulkCommitBatch.processLastOperation(op); - this._lastOp = this._lastOp.then(() => silencePromise(op.promise)); if (this._bulkCommitBatch._opCount === this._maxBatchSize) { this._scheduleCurrentBatch(); diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index 81456a6e0..ad904e1ff 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -500,6 +500,48 @@ describe('BulkWriter', () => { }); }); + it('buffers subsequent operations after reaching maximum pending op count', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([ + setOp('doc1', 'bar'), + setOp('doc2', 'bar'), + setOp('doc3', 'bar'), + ]), + response: mergeResponses([ + successResponse(1), + successResponse(2), + successResponse(3), + ]), + }, + { + request: createRequest([setOp('doc4', 'bar'), setOp('doc5', 'bar')]), + response: mergeResponses([successResponse(4), successResponse(5)]), + }, + ]); + bulkWriter._setMaxPendingOpCount(3); + bulkWriter + .set(firestore.doc('collectionId/doc1'), {foo: 'bar'}) + .then(incrementOpCount); + bulkWriter + .set(firestore.doc('collectionId/doc2'), {foo: 'bar'}) + .then(incrementOpCount); + bulkWriter + .set(firestore.doc('collectionId/doc3'), {foo: 'bar'}) + .then(incrementOpCount); + bulkWriter + .set(firestore.doc('collectionId/doc4'), {foo: 'bar'}) + .then(incrementOpCount); + expect(bulkWriter._getBufferedOperationsCount()).to.equal(1); + bulkWriter + .set(firestore.doc('collectionId/doc5'), {foo: 'bar'}) + .then(incrementOpCount); + expect(bulkWriter._getBufferedOperationsCount()).to.equal(2); + return bulkWriter.close().then(async () => { + verifyOpCount(5); + }); + }); + it('runs the success handler', async () => { const bulkWriter = await instantiateInstance([ { From 8a4b38a88c3f1984aa008e321b73ff1eec513522 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 14 Apr 2021 14:46:27 -0500 Subject: [PATCH 274/337] chore: run synthtool and fix synth.py (#1475) --- dev/protos/firestore_v1beta1_proto_api.d.ts | 389 +++++- dev/protos/firestore_v1beta1_proto_api.js | 1221 +++++++++++++---- dev/protos/google/firestore/v1/common.proto | 2 +- dev/protos/google/firestore/v1/document.proto | 2 +- .../google/firestore/v1/firestore.proto | 2 +- dev/protos/google/firestore/v1/query.proto | 2 +- dev/protos/google/firestore/v1/write.proto | 5 +- .../google/firestore/v1beta1/common.proto | 3 +- .../google/firestore/v1beta1/document.proto | 3 +- .../google/firestore/v1beta1/firestore.proto | 194 ++- .../google/firestore/v1beta1/query.proto | 97 +- .../google/firestore/v1beta1/write.proto | 16 +- dev/protos/protos.json | 181 ++- dev/src/v1/firestore_client_config.json | 37 +- dev/src/v1beta1/firestore_client.ts | 645 +++++++-- dev/src/v1beta1/firestore_client_config.json | 41 +- dev/src/v1beta1/gapic_metadata.json | 44 +- dev/test/gapic_firestore_v1beta1.ts | 650 +++++++-- dev/test/index.ts | 2 +- synth.py | 2 +- types/protos/firestore_v1beta1_proto_api.d.ts | 389 +++++- types/v1beta1/firestore_client.d.ts | 268 +++- 22 files changed, 3356 insertions(+), 839 deletions(-) diff --git a/dev/protos/firestore_v1beta1_proto_api.d.ts b/dev/protos/firestore_v1beta1_proto_api.d.ts index 0086457e8..58cea05f6 100644 --- a/dev/protos/firestore_v1beta1_proto_api.d.ts +++ b/dev/protos/firestore_v1beta1_proto_api.d.ts @@ -2896,20 +2896,6 @@ export namespace google { */ public listDocuments(request: google.firestore.v1beta1.IListDocumentsRequest): Promise; - /** - * Calls CreateDocument. - * @param request CreateDocumentRequest message or plain object - * @param callback Node-style callback called with the error, if any, and Document - */ - public createDocument(request: google.firestore.v1beta1.ICreateDocumentRequest, callback: google.firestore.v1beta1.Firestore.CreateDocumentCallback): void; - - /** - * Calls CreateDocument. - * @param request CreateDocumentRequest message or plain object - * @returns Promise - */ - public createDocument(request: google.firestore.v1beta1.ICreateDocumentRequest): Promise; - /** * Calls UpdateDocument. * @param request UpdateDocumentRequest message or plain object @@ -3008,6 +2994,20 @@ export namespace google { */ public runQuery(request: google.firestore.v1beta1.IRunQueryRequest): Promise; + /** + * Calls PartitionQuery. + * @param request PartitionQueryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and PartitionQueryResponse + */ + public partitionQuery(request: google.firestore.v1beta1.IPartitionQueryRequest, callback: google.firestore.v1beta1.Firestore.PartitionQueryCallback): void; + + /** + * Calls PartitionQuery. + * @param request PartitionQueryRequest message or plain object + * @returns Promise + */ + public partitionQuery(request: google.firestore.v1beta1.IPartitionQueryRequest): Promise; + /** * Calls Write. * @param request WriteRequest message or plain object @@ -3049,6 +3049,34 @@ export namespace google { * @returns Promise */ public listCollectionIds(request: google.firestore.v1beta1.IListCollectionIdsRequest): Promise; + + /** + * Calls BatchWrite. + * @param request BatchWriteRequest message or plain object + * @param callback Node-style callback called with the error, if any, and BatchWriteResponse + */ + public batchWrite(request: google.firestore.v1beta1.IBatchWriteRequest, callback: google.firestore.v1beta1.Firestore.BatchWriteCallback): void; + + /** + * Calls BatchWrite. + * @param request BatchWriteRequest message or plain object + * @returns Promise + */ + public batchWrite(request: google.firestore.v1beta1.IBatchWriteRequest): Promise; + + /** + * Calls CreateDocument. + * @param request CreateDocumentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Document + */ + public createDocument(request: google.firestore.v1beta1.ICreateDocumentRequest, callback: google.firestore.v1beta1.Firestore.CreateDocumentCallback): void; + + /** + * Calls CreateDocument. + * @param request CreateDocumentRequest message or plain object + * @returns Promise + */ + public createDocument(request: google.firestore.v1beta1.ICreateDocumentRequest): Promise; } namespace Firestore { @@ -3067,13 +3095,6 @@ export namespace google { */ type ListDocumentsCallback = (error: (Error|null), response?: google.firestore.v1beta1.ListDocumentsResponse) => void; - /** - * Callback as used by {@link google.firestore.v1beta1.Firestore#createDocument}. - * @param error Error, if any - * @param [response] Document - */ - type CreateDocumentCallback = (error: (Error|null), response?: google.firestore.v1beta1.Document) => void; - /** * Callback as used by {@link google.firestore.v1beta1.Firestore#updateDocument}. * @param error Error, if any @@ -3123,6 +3144,13 @@ export namespace google { */ type RunQueryCallback = (error: (Error|null), response?: google.firestore.v1beta1.RunQueryResponse) => void; + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#partitionQuery}. + * @param error Error, if any + * @param [response] PartitionQueryResponse + */ + type PartitionQueryCallback = (error: (Error|null), response?: google.firestore.v1beta1.PartitionQueryResponse) => void; + /** * Callback as used by {@link google.firestore.v1beta1.Firestore#write}. * @param error Error, if any @@ -3143,6 +3171,20 @@ export namespace google { * @param [response] ListCollectionIdsResponse */ type ListCollectionIdsCallback = (error: (Error|null), response?: google.firestore.v1beta1.ListCollectionIdsResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#batchWrite}. + * @param error Error, if any + * @param [response] BatchWriteResponse + */ + type BatchWriteCallback = (error: (Error|null), response?: google.firestore.v1beta1.BatchWriteResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#createDocument}. + * @param error Error, if any + * @param [response] Document + */ + type CreateDocumentCallback = (error: (Error|null), response?: google.firestore.v1beta1.Document) => void; } /** Properties of a GetDocumentRequest. */ @@ -4018,6 +4060,121 @@ export namespace google { public toJSON(): { [k: string]: any }; } + /** Properties of a PartitionQueryRequest. */ + interface IPartitionQueryRequest { + + /** PartitionQueryRequest parent */ + parent?: (string|null); + + /** PartitionQueryRequest structuredQuery */ + structuredQuery?: (google.firestore.v1beta1.IStructuredQuery|null); + + /** PartitionQueryRequest partitionCount */ + partitionCount?: (number|string|null); + + /** PartitionQueryRequest pageToken */ + pageToken?: (string|null); + + /** PartitionQueryRequest pageSize */ + pageSize?: (number|null); + } + + /** Represents a PartitionQueryRequest. */ + class PartitionQueryRequest implements IPartitionQueryRequest { + + /** + * Constructs a new PartitionQueryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IPartitionQueryRequest); + + /** PartitionQueryRequest parent. */ + public parent: string; + + /** PartitionQueryRequest structuredQuery. */ + public structuredQuery?: (google.firestore.v1beta1.IStructuredQuery|null); + + /** PartitionQueryRequest partitionCount. */ + public partitionCount: (number|string); + + /** PartitionQueryRequest pageToken. */ + public pageToken: string; + + /** PartitionQueryRequest pageSize. */ + public pageSize: number; + + /** PartitionQueryRequest queryType. */ + public queryType?: "structuredQuery"; + + /** + * Creates a PartitionQueryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PartitionQueryRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.PartitionQueryRequest; + + /** + * Creates a plain object from a PartitionQueryRequest message. Also converts values to other types if specified. + * @param message PartitionQueryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.PartitionQueryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PartitionQueryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a PartitionQueryResponse. */ + interface IPartitionQueryResponse { + + /** PartitionQueryResponse partitions */ + partitions?: (google.firestore.v1beta1.ICursor[]|null); + + /** PartitionQueryResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a PartitionQueryResponse. */ + class PartitionQueryResponse implements IPartitionQueryResponse { + + /** + * Constructs a new PartitionQueryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IPartitionQueryResponse); + + /** PartitionQueryResponse partitions. */ + public partitions: google.firestore.v1beta1.ICursor[]; + + /** PartitionQueryResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a PartitionQueryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PartitionQueryResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.PartitionQueryResponse; + + /** + * Creates a plain object from a PartitionQueryResponse message. Also converts values to other types if specified. + * @param message PartitionQueryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.PartitionQueryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PartitionQueryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + /** Properties of a WriteRequest. */ interface IWriteRequest { @@ -4615,6 +4772,106 @@ export namespace google { public toJSON(): { [k: string]: any }; } + /** Properties of a BatchWriteRequest. */ + interface IBatchWriteRequest { + + /** BatchWriteRequest database */ + database?: (string|null); + + /** BatchWriteRequest writes */ + writes?: (google.firestore.v1beta1.IWrite[]|null); + + /** BatchWriteRequest labels */ + labels?: ({ [k: string]: string }|null); + } + + /** Represents a BatchWriteRequest. */ + class BatchWriteRequest implements IBatchWriteRequest { + + /** + * Constructs a new BatchWriteRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IBatchWriteRequest); + + /** BatchWriteRequest database. */ + public database: string; + + /** BatchWriteRequest writes. */ + public writes: google.firestore.v1beta1.IWrite[]; + + /** BatchWriteRequest labels. */ + public labels: { [k: string]: string }; + + /** + * Creates a BatchWriteRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchWriteRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.BatchWriteRequest; + + /** + * Creates a plain object from a BatchWriteRequest message. Also converts values to other types if specified. + * @param message BatchWriteRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.BatchWriteRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchWriteRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BatchWriteResponse. */ + interface IBatchWriteResponse { + + /** BatchWriteResponse writeResults */ + writeResults?: (google.firestore.v1beta1.IWriteResult[]|null); + + /** BatchWriteResponse status */ + status?: (google.rpc.IStatus[]|null); + } + + /** Represents a BatchWriteResponse. */ + class BatchWriteResponse implements IBatchWriteResponse { + + /** + * Constructs a new BatchWriteResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IBatchWriteResponse); + + /** BatchWriteResponse writeResults. */ + public writeResults: google.firestore.v1beta1.IWriteResult[]; + + /** BatchWriteResponse status. */ + public status: google.rpc.IStatus[]; + + /** + * Creates a BatchWriteResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchWriteResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.BatchWriteResponse; + + /** + * Creates a plain object from a BatchWriteResponse message. Also converts values to other types if specified. + * @param message BatchWriteResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.BatchWriteResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchWriteResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + /** Properties of a StructuredQuery. */ interface IStructuredQuery { @@ -4914,7 +5171,7 @@ export namespace google { /** Operator enum. */ type Operator = - "OPERATOR_UNSPECIFIED"| "LESS_THAN"| "LESS_THAN_OR_EQUAL"| "GREATER_THAN"| "GREATER_THAN_OR_EQUAL"| "EQUAL"| "ARRAY_CONTAINS"| "IN"| "ARRAY_CONTAINS_ANY"; + "OPERATOR_UNSPECIFIED"| "LESS_THAN"| "LESS_THAN_OR_EQUAL"| "GREATER_THAN"| "GREATER_THAN_OR_EQUAL"| "EQUAL"| "NOT_EQUAL"| "ARRAY_CONTAINS"| "IN"| "ARRAY_CONTAINS_ANY"| "NOT_IN"; } /** Properties of an UnaryFilter. */ @@ -4971,92 +5228,92 @@ export namespace google { /** Operator enum. */ type Operator = - "OPERATOR_UNSPECIFIED"| "IS_NAN"| "IS_NULL"; + "OPERATOR_UNSPECIFIED"| "IS_NAN"| "IS_NULL"| "IS_NOT_NAN"| "IS_NOT_NULL"; } - /** Properties of an Order. */ - interface IOrder { - - /** Order field */ - field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + /** Properties of a FieldReference. */ + interface IFieldReference { - /** Order direction */ - direction?: (google.firestore.v1beta1.StructuredQuery.Direction|null); + /** FieldReference fieldPath */ + fieldPath?: (string|null); } - /** Represents an Order. */ - class Order implements IOrder { + /** Represents a FieldReference. */ + class FieldReference implements IFieldReference { /** - * Constructs a new Order. + * Constructs a new FieldReference. * @param [properties] Properties to set */ - constructor(properties?: google.firestore.v1beta1.StructuredQuery.IOrder); - - /** Order field. */ - public field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + constructor(properties?: google.firestore.v1beta1.StructuredQuery.IFieldReference); - /** Order direction. */ - public direction: google.firestore.v1beta1.StructuredQuery.Direction; + /** FieldReference fieldPath. */ + public fieldPath: string; /** - * Creates an Order message from a plain object. Also converts values to their respective internal types. + * Creates a FieldReference message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns Order + * @returns FieldReference */ - public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.Order; + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.FieldReference; /** - * Creates a plain object from an Order message. Also converts values to other types if specified. - * @param message Order + * Creates a plain object from a FieldReference message. Also converts values to other types if specified. + * @param message FieldReference * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.firestore.v1beta1.StructuredQuery.Order, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.firestore.v1beta1.StructuredQuery.FieldReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this Order to JSON. + * Converts this FieldReference to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; } - /** Properties of a FieldReference. */ - interface IFieldReference { + /** Properties of an Order. */ + interface IOrder { - /** FieldReference fieldPath */ - fieldPath?: (string|null); + /** Order field */ + field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + + /** Order direction */ + direction?: (google.firestore.v1beta1.StructuredQuery.Direction|null); } - /** Represents a FieldReference. */ - class FieldReference implements IFieldReference { + /** Represents an Order. */ + class Order implements IOrder { /** - * Constructs a new FieldReference. + * Constructs a new Order. * @param [properties] Properties to set */ - constructor(properties?: google.firestore.v1beta1.StructuredQuery.IFieldReference); + constructor(properties?: google.firestore.v1beta1.StructuredQuery.IOrder); - /** FieldReference fieldPath. */ - public fieldPath: string; + /** Order field. */ + public field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + + /** Order direction. */ + public direction: google.firestore.v1beta1.StructuredQuery.Direction; /** - * Creates a FieldReference message from a plain object. Also converts values to their respective internal types. + * Creates an Order message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns FieldReference + * @returns Order */ - public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.FieldReference; + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.Order; /** - * Creates a plain object from a FieldReference message. Also converts values to other types if specified. - * @param message FieldReference + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @param message Order * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.firestore.v1beta1.StructuredQuery.FieldReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.firestore.v1beta1.StructuredQuery.Order, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this FieldReference to JSON. + * Converts this Order to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; @@ -5170,6 +5427,9 @@ export namespace google { /** Write updateMask */ updateMask?: (google.firestore.v1beta1.IDocumentMask|null); + /** Write updateTransforms */ + updateTransforms?: (google.firestore.v1beta1.DocumentTransform.IFieldTransform[]|null); + /** Write currentDocument */ currentDocument?: (google.firestore.v1beta1.IPrecondition|null); } @@ -5195,6 +5455,9 @@ export namespace google { /** Write updateMask. */ public updateMask?: (google.firestore.v1beta1.IDocumentMask|null); + /** Write updateTransforms. */ + public updateTransforms: google.firestore.v1beta1.DocumentTransform.IFieldTransform[]; + /** Write currentDocument. */ public currentDocument?: (google.firestore.v1beta1.IPrecondition|null); diff --git a/dev/protos/firestore_v1beta1_proto_api.js b/dev/protos/firestore_v1beta1_proto_api.js index cd3bed502..2f966cdbc 100644 --- a/dev/protos/firestore_v1beta1_proto_api.js +++ b/dev/protos/firestore_v1beta1_proto_api.js @@ -7146,39 +7146,6 @@ * @variation 2 */ - /** - * Callback as used by {@link google.firestore.v1beta1.Firestore#createDocument}. - * @memberof google.firestore.v1beta1.Firestore - * @typedef CreateDocumentCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {google.firestore.v1beta1.Document} [response] Document - */ - - /** - * Calls CreateDocument. - * @function createDocument - * @memberof google.firestore.v1beta1.Firestore - * @instance - * @param {google.firestore.v1beta1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object - * @param {google.firestore.v1beta1.Firestore.CreateDocumentCallback} callback Node-style callback called with the error, if any, and Document - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(Firestore.prototype.createDocument = function createDocument(request, callback) { - return this.rpcCall(createDocument, $root.google.firestore.v1beta1.CreateDocumentRequest, $root.google.firestore.v1beta1.Document, request, callback); - }, "name", { value: "CreateDocument" }); - - /** - * Calls CreateDocument. - * @function createDocument - * @memberof google.firestore.v1beta1.Firestore - * @instance - * @param {google.firestore.v1beta1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - /** * Callback as used by {@link google.firestore.v1beta1.Firestore#updateDocument}. * @memberof google.firestore.v1beta1.Firestore @@ -7410,6 +7377,39 @@ * @variation 2 */ + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#partitionQuery}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef PartitionQueryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.PartitionQueryResponse} [response] PartitionQueryResponse + */ + + /** + * Calls PartitionQuery. + * @function partitionQuery + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IPartitionQueryRequest} request PartitionQueryRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.PartitionQueryCallback} callback Node-style callback called with the error, if any, and PartitionQueryResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.partitionQuery = function partitionQuery(request, callback) { + return this.rpcCall(partitionQuery, $root.google.firestore.v1beta1.PartitionQueryRequest, $root.google.firestore.v1beta1.PartitionQueryResponse, request, callback); + }, "name", { value: "PartitionQuery" }); + + /** + * Calls PartitionQuery. + * @function partitionQuery + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IPartitionQueryRequest} request PartitionQueryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link google.firestore.v1beta1.Firestore#write}. * @memberof google.firestore.v1beta1.Firestore @@ -7509,6 +7509,72 @@ * @variation 2 */ + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#batchWrite}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef BatchWriteCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.BatchWriteResponse} [response] BatchWriteResponse + */ + + /** + * Calls BatchWrite. + * @function batchWrite + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IBatchWriteRequest} request BatchWriteRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.BatchWriteCallback} callback Node-style callback called with the error, if any, and BatchWriteResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.batchWrite = function batchWrite(request, callback) { + return this.rpcCall(batchWrite, $root.google.firestore.v1beta1.BatchWriteRequest, $root.google.firestore.v1beta1.BatchWriteResponse, request, callback); + }, "name", { value: "BatchWrite" }); + + /** + * Calls BatchWrite. + * @function batchWrite + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.IBatchWriteRequest} request BatchWriteRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#createDocument}. + * @memberof google.firestore.v1beta1.Firestore + * @typedef CreateDocumentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.firestore.v1beta1.Document} [response] Document + */ + + /** + * Calls CreateDocument. + * @function createDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object + * @param {google.firestore.v1beta1.Firestore.CreateDocumentCallback} callback Node-style callback called with the error, if any, and Document + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Firestore.prototype.createDocument = function createDocument(request, callback) { + return this.rpcCall(createDocument, $root.google.firestore.v1beta1.CreateDocumentRequest, $root.google.firestore.v1beta1.Document, request, callback); + }, "name", { value: "CreateDocument" }); + + /** + * Calls CreateDocument. + * @function createDocument + * @memberof google.firestore.v1beta1.Firestore + * @instance + * @param {google.firestore.v1beta1.ICreateDocumentRequest} request CreateDocumentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + return Firestore; })(); @@ -9610,30 +9676,28 @@ return RunQueryResponse; })(); - v1beta1.WriteRequest = (function() { + v1beta1.PartitionQueryRequest = (function() { /** - * Properties of a WriteRequest. + * Properties of a PartitionQueryRequest. * @memberof google.firestore.v1beta1 - * @interface IWriteRequest - * @property {string|null} [database] WriteRequest database - * @property {string|null} [streamId] WriteRequest streamId - * @property {Array.|null} [writes] WriteRequest writes - * @property {Uint8Array|null} [streamToken] WriteRequest streamToken - * @property {Object.|null} [labels] WriteRequest labels + * @interface IPartitionQueryRequest + * @property {string|null} [parent] PartitionQueryRequest parent + * @property {google.firestore.v1beta1.IStructuredQuery|null} [structuredQuery] PartitionQueryRequest structuredQuery + * @property {number|string|null} [partitionCount] PartitionQueryRequest partitionCount + * @property {string|null} [pageToken] PartitionQueryRequest pageToken + * @property {number|null} [pageSize] PartitionQueryRequest pageSize */ /** - * Constructs a new WriteRequest. + * Constructs a new PartitionQueryRequest. * @memberof google.firestore.v1beta1 - * @classdesc Represents a WriteRequest. - * @implements IWriteRequest + * @classdesc Represents a PartitionQueryRequest. + * @implements IPartitionQueryRequest * @constructor - * @param {google.firestore.v1beta1.IWriteRequest=} [properties] Properties to set + * @param {google.firestore.v1beta1.IPartitionQueryRequest=} [properties] Properties to set */ - function WriteRequest(properties) { - this.writes = []; - this.labels = {}; + function PartitionQueryRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -9641,165 +9705,450 @@ } /** - * WriteRequest database. - * @member {string} database - * @memberof google.firestore.v1beta1.WriteRequest + * PartitionQueryRequest parent. + * @member {string} parent + * @memberof google.firestore.v1beta1.PartitionQueryRequest * @instance */ - WriteRequest.prototype.database = ""; + PartitionQueryRequest.prototype.parent = ""; /** - * WriteRequest streamId. - * @member {string} streamId - * @memberof google.firestore.v1beta1.WriteRequest + * PartitionQueryRequest structuredQuery. + * @member {google.firestore.v1beta1.IStructuredQuery|null|undefined} structuredQuery + * @memberof google.firestore.v1beta1.PartitionQueryRequest * @instance */ - WriteRequest.prototype.streamId = ""; + PartitionQueryRequest.prototype.structuredQuery = null; /** - * WriteRequest writes. - * @member {Array.} writes - * @memberof google.firestore.v1beta1.WriteRequest + * PartitionQueryRequest partitionCount. + * @member {number|string} partitionCount + * @memberof google.firestore.v1beta1.PartitionQueryRequest * @instance */ - WriteRequest.prototype.writes = $util.emptyArray; + PartitionQueryRequest.prototype.partitionCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; /** - * WriteRequest streamToken. - * @member {Uint8Array} streamToken - * @memberof google.firestore.v1beta1.WriteRequest + * PartitionQueryRequest pageToken. + * @member {string} pageToken + * @memberof google.firestore.v1beta1.PartitionQueryRequest * @instance */ - WriteRequest.prototype.streamToken = $util.newBuffer([]); + PartitionQueryRequest.prototype.pageToken = ""; /** - * WriteRequest labels. - * @member {Object.} labels - * @memberof google.firestore.v1beta1.WriteRequest + * PartitionQueryRequest pageSize. + * @member {number} pageSize + * @memberof google.firestore.v1beta1.PartitionQueryRequest * @instance */ - WriteRequest.prototype.labels = $util.emptyObject; + PartitionQueryRequest.prototype.pageSize = 0; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; /** - * Creates a WriteRequest message from a plain object. Also converts values to their respective internal types. + * PartitionQueryRequest queryType. + * @member {"structuredQuery"|undefined} queryType + * @memberof google.firestore.v1beta1.PartitionQueryRequest + * @instance + */ + Object.defineProperty(PartitionQueryRequest.prototype, "queryType", { + get: $util.oneOfGetter($oneOfFields = ["structuredQuery"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a PartitionQueryRequest message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.firestore.v1beta1.WriteRequest + * @memberof google.firestore.v1beta1.PartitionQueryRequest * @static * @param {Object.} object Plain object - * @returns {google.firestore.v1beta1.WriteRequest} WriteRequest + * @returns {google.firestore.v1beta1.PartitionQueryRequest} PartitionQueryRequest */ - WriteRequest.fromObject = function fromObject(object) { - if (object instanceof $root.google.firestore.v1beta1.WriteRequest) + PartitionQueryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.PartitionQueryRequest) return object; - var message = new $root.google.firestore.v1beta1.WriteRequest(); - if (object.database != null) - message.database = String(object.database); - if (object.streamId != null) - message.streamId = String(object.streamId); - if (object.writes) { - if (!Array.isArray(object.writes)) - throw TypeError(".google.firestore.v1beta1.WriteRequest.writes: array expected"); - message.writes = []; - for (var i = 0; i < object.writes.length; ++i) { - if (typeof object.writes[i] !== "object") - throw TypeError(".google.firestore.v1beta1.WriteRequest.writes: object expected"); - message.writes[i] = $root.google.firestore.v1beta1.Write.fromObject(object.writes[i]); - } - } - if (object.streamToken != null) - if (typeof object.streamToken === "string") - $util.base64.decode(object.streamToken, message.streamToken = $util.newBuffer($util.base64.length(object.streamToken)), 0); - else if (object.streamToken.length) - message.streamToken = object.streamToken; - if (object.labels) { - if (typeof object.labels !== "object") - throw TypeError(".google.firestore.v1beta1.WriteRequest.labels: object expected"); - message.labels = {}; - for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) - message.labels[keys[i]] = String(object.labels[keys[i]]); + var message = new $root.google.firestore.v1beta1.PartitionQueryRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.structuredQuery != null) { + if (typeof object.structuredQuery !== "object") + throw TypeError(".google.firestore.v1beta1.PartitionQueryRequest.structuredQuery: object expected"); + message.structuredQuery = $root.google.firestore.v1beta1.StructuredQuery.fromObject(object.structuredQuery); } + if (object.partitionCount != null) + if ($util.Long) + (message.partitionCount = $util.Long.fromValue(object.partitionCount)).unsigned = false; + else if (typeof object.partitionCount === "string") + message.partitionCount = parseInt(object.partitionCount, 10); + else if (typeof object.partitionCount === "number") + message.partitionCount = object.partitionCount; + else if (typeof object.partitionCount === "object") + message.partitionCount = new $util.LongBits(object.partitionCount.low >>> 0, object.partitionCount.high >>> 0).toNumber(); + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; return message; }; /** - * Creates a plain object from a WriteRequest message. Also converts values to other types if specified. + * Creates a plain object from a PartitionQueryRequest message. Also converts values to other types if specified. * @function toObject - * @memberof google.firestore.v1beta1.WriteRequest + * @memberof google.firestore.v1beta1.PartitionQueryRequest * @static - * @param {google.firestore.v1beta1.WriteRequest} message WriteRequest + * @param {google.firestore.v1beta1.PartitionQueryRequest} message PartitionQueryRequest * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - WriteRequest.toObject = function toObject(message, options) { + PartitionQueryRequest.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.arrays || options.defaults) - object.writes = []; - if (options.objects || options.defaults) - object.labels = {}; if (options.defaults) { - object.database = ""; - object.streamId = ""; - if (options.bytes === String) - object.streamToken = ""; - else { - object.streamToken = []; - if (options.bytes !== Array) - object.streamToken = $util.newBuffer(object.streamToken); - } - } - if (message.database != null && message.hasOwnProperty("database")) - object.database = message.database; - if (message.streamId != null && message.hasOwnProperty("streamId")) - object.streamId = message.streamId; - if (message.writes && message.writes.length) { - object.writes = []; - for (var j = 0; j < message.writes.length; ++j) - object.writes[j] = $root.google.firestore.v1beta1.Write.toObject(message.writes[j], options); + object.parent = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.partitionCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.partitionCount = options.longs === String ? "0" : 0; + object.pageToken = ""; + object.pageSize = 0; } - if (message.streamToken != null && message.hasOwnProperty("streamToken")) - object.streamToken = options.bytes === String ? $util.base64.encode(message.streamToken, 0, message.streamToken.length) : options.bytes === Array ? Array.prototype.slice.call(message.streamToken) : message.streamToken; - var keys2; - if (message.labels && (keys2 = Object.keys(message.labels)).length) { - object.labels = {}; - for (var j = 0; j < keys2.length; ++j) - object.labels[keys2[j]] = message.labels[keys2[j]]; + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.structuredQuery != null && message.hasOwnProperty("structuredQuery")) { + object.structuredQuery = $root.google.firestore.v1beta1.StructuredQuery.toObject(message.structuredQuery, options); + if (options.oneofs) + object.queryType = "structuredQuery"; } + if (message.partitionCount != null && message.hasOwnProperty("partitionCount")) + if (typeof message.partitionCount === "number") + object.partitionCount = options.longs === String ? String(message.partitionCount) : message.partitionCount; + else + object.partitionCount = options.longs === String ? $util.Long.prototype.toString.call(message.partitionCount) : options.longs === Number ? new $util.LongBits(message.partitionCount.low >>> 0, message.partitionCount.high >>> 0).toNumber() : message.partitionCount; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; return object; }; /** - * Converts this WriteRequest to JSON. + * Converts this PartitionQueryRequest to JSON. * @function toJSON - * @memberof google.firestore.v1beta1.WriteRequest + * @memberof google.firestore.v1beta1.PartitionQueryRequest * @instance * @returns {Object.} JSON object */ - WriteRequest.prototype.toJSON = function toJSON() { + PartitionQueryRequest.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; - return WriteRequest; + return PartitionQueryRequest; })(); - v1beta1.WriteResponse = (function() { + v1beta1.PartitionQueryResponse = (function() { /** - * Properties of a WriteResponse. + * Properties of a PartitionQueryResponse. * @memberof google.firestore.v1beta1 - * @interface IWriteResponse - * @property {string|null} [streamId] WriteResponse streamId - * @property {Uint8Array|null} [streamToken] WriteResponse streamToken - * @property {Array.|null} [writeResults] WriteResponse writeResults - * @property {google.protobuf.ITimestamp|null} [commitTime] WriteResponse commitTime + * @interface IPartitionQueryResponse + * @property {Array.|null} [partitions] PartitionQueryResponse partitions + * @property {string|null} [nextPageToken] PartitionQueryResponse nextPageToken */ /** - * Constructs a new WriteResponse. + * Constructs a new PartitionQueryResponse. * @memberof google.firestore.v1beta1 - * @classdesc Represents a WriteResponse. - * @implements IWriteResponse + * @classdesc Represents a PartitionQueryResponse. + * @implements IPartitionQueryResponse + * @constructor + * @param {google.firestore.v1beta1.IPartitionQueryResponse=} [properties] Properties to set + */ + function PartitionQueryResponse(properties) { + this.partitions = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PartitionQueryResponse partitions. + * @member {Array.} partitions + * @memberof google.firestore.v1beta1.PartitionQueryResponse + * @instance + */ + PartitionQueryResponse.prototype.partitions = $util.emptyArray; + + /** + * PartitionQueryResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.firestore.v1beta1.PartitionQueryResponse + * @instance + */ + PartitionQueryResponse.prototype.nextPageToken = ""; + + /** + * Creates a PartitionQueryResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.PartitionQueryResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.PartitionQueryResponse} PartitionQueryResponse + */ + PartitionQueryResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.PartitionQueryResponse) + return object; + var message = new $root.google.firestore.v1beta1.PartitionQueryResponse(); + if (object.partitions) { + if (!Array.isArray(object.partitions)) + throw TypeError(".google.firestore.v1beta1.PartitionQueryResponse.partitions: array expected"); + message.partitions = []; + for (var i = 0; i < object.partitions.length; ++i) { + if (typeof object.partitions[i] !== "object") + throw TypeError(".google.firestore.v1beta1.PartitionQueryResponse.partitions: object expected"); + message.partitions[i] = $root.google.firestore.v1beta1.Cursor.fromObject(object.partitions[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a PartitionQueryResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.PartitionQueryResponse + * @static + * @param {google.firestore.v1beta1.PartitionQueryResponse} message PartitionQueryResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PartitionQueryResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.partitions = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.partitions && message.partitions.length) { + object.partitions = []; + for (var j = 0; j < message.partitions.length; ++j) + object.partitions[j] = $root.google.firestore.v1beta1.Cursor.toObject(message.partitions[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this PartitionQueryResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.PartitionQueryResponse + * @instance + * @returns {Object.} JSON object + */ + PartitionQueryResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return PartitionQueryResponse; + })(); + + v1beta1.WriteRequest = (function() { + + /** + * Properties of a WriteRequest. + * @memberof google.firestore.v1beta1 + * @interface IWriteRequest + * @property {string|null} [database] WriteRequest database + * @property {string|null} [streamId] WriteRequest streamId + * @property {Array.|null} [writes] WriteRequest writes + * @property {Uint8Array|null} [streamToken] WriteRequest streamToken + * @property {Object.|null} [labels] WriteRequest labels + */ + + /** + * Constructs a new WriteRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a WriteRequest. + * @implements IWriteRequest + * @constructor + * @param {google.firestore.v1beta1.IWriteRequest=} [properties] Properties to set + */ + function WriteRequest(properties) { + this.writes = []; + this.labels = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WriteRequest database. + * @member {string} database + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + */ + WriteRequest.prototype.database = ""; + + /** + * WriteRequest streamId. + * @member {string} streamId + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + */ + WriteRequest.prototype.streamId = ""; + + /** + * WriteRequest writes. + * @member {Array.} writes + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + */ + WriteRequest.prototype.writes = $util.emptyArray; + + /** + * WriteRequest streamToken. + * @member {Uint8Array} streamToken + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + */ + WriteRequest.prototype.streamToken = $util.newBuffer([]); + + /** + * WriteRequest labels. + * @member {Object.} labels + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + */ + WriteRequest.prototype.labels = $util.emptyObject; + + /** + * Creates a WriteRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.WriteRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.WriteRequest} WriteRequest + */ + WriteRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.WriteRequest) + return object; + var message = new $root.google.firestore.v1beta1.WriteRequest(); + if (object.database != null) + message.database = String(object.database); + if (object.streamId != null) + message.streamId = String(object.streamId); + if (object.writes) { + if (!Array.isArray(object.writes)) + throw TypeError(".google.firestore.v1beta1.WriteRequest.writes: array expected"); + message.writes = []; + for (var i = 0; i < object.writes.length; ++i) { + if (typeof object.writes[i] !== "object") + throw TypeError(".google.firestore.v1beta1.WriteRequest.writes: object expected"); + message.writes[i] = $root.google.firestore.v1beta1.Write.fromObject(object.writes[i]); + } + } + if (object.streamToken != null) + if (typeof object.streamToken === "string") + $util.base64.decode(object.streamToken, message.streamToken = $util.newBuffer($util.base64.length(object.streamToken)), 0); + else if (object.streamToken.length) + message.streamToken = object.streamToken; + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.firestore.v1beta1.WriteRequest.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } + return message; + }; + + /** + * Creates a plain object from a WriteRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.WriteRequest + * @static + * @param {google.firestore.v1beta1.WriteRequest} message WriteRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WriteRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.writes = []; + if (options.objects || options.defaults) + object.labels = {}; + if (options.defaults) { + object.database = ""; + object.streamId = ""; + if (options.bytes === String) + object.streamToken = ""; + else { + object.streamToken = []; + if (options.bytes !== Array) + object.streamToken = $util.newBuffer(object.streamToken); + } + } + if (message.database != null && message.hasOwnProperty("database")) + object.database = message.database; + if (message.streamId != null && message.hasOwnProperty("streamId")) + object.streamId = message.streamId; + if (message.writes && message.writes.length) { + object.writes = []; + for (var j = 0; j < message.writes.length; ++j) + object.writes[j] = $root.google.firestore.v1beta1.Write.toObject(message.writes[j], options); + } + if (message.streamToken != null && message.hasOwnProperty("streamToken")) + object.streamToken = options.bytes === String ? $util.base64.encode(message.streamToken, 0, message.streamToken.length) : options.bytes === Array ? Array.prototype.slice.call(message.streamToken) : message.streamToken; + var keys2; + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } + return object; + }; + + /** + * Converts this WriteRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.WriteRequest + * @instance + * @returns {Object.} JSON object + */ + WriteRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return WriteRequest; + })(); + + v1beta1.WriteResponse = (function() { + + /** + * Properties of a WriteResponse. + * @memberof google.firestore.v1beta1 + * @interface IWriteResponse + * @property {string|null} [streamId] WriteResponse streamId + * @property {Uint8Array|null} [streamToken] WriteResponse streamToken + * @property {Array.|null} [writeResults] WriteResponse writeResults + * @property {google.protobuf.ITimestamp|null} [commitTime] WriteResponse commitTime + */ + + /** + * Constructs a new WriteResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a WriteResponse. + * @implements IWriteResponse * @constructor * @param {google.firestore.v1beta1.IWriteResponse=} [properties] Properties to set */ @@ -10985,33 +11334,276 @@ * @instance * @returns {Object.} JSON object */ - ListCollectionIdsRequest.prototype.toJSON = function toJSON() { + ListCollectionIdsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListCollectionIdsRequest; + })(); + + v1beta1.ListCollectionIdsResponse = (function() { + + /** + * Properties of a ListCollectionIdsResponse. + * @memberof google.firestore.v1beta1 + * @interface IListCollectionIdsResponse + * @property {Array.|null} [collectionIds] ListCollectionIdsResponse collectionIds + * @property {string|null} [nextPageToken] ListCollectionIdsResponse nextPageToken + */ + + /** + * Constructs a new ListCollectionIdsResponse. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a ListCollectionIdsResponse. + * @implements IListCollectionIdsResponse + * @constructor + * @param {google.firestore.v1beta1.IListCollectionIdsResponse=} [properties] Properties to set + */ + function ListCollectionIdsResponse(properties) { + this.collectionIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListCollectionIdsResponse collectionIds. + * @member {Array.} collectionIds + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @instance + */ + ListCollectionIdsResponse.prototype.collectionIds = $util.emptyArray; + + /** + * ListCollectionIdsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @instance + */ + ListCollectionIdsResponse.prototype.nextPageToken = ""; + + /** + * Creates a ListCollectionIdsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.ListCollectionIdsResponse} ListCollectionIdsResponse + */ + ListCollectionIdsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.ListCollectionIdsResponse) + return object; + var message = new $root.google.firestore.v1beta1.ListCollectionIdsResponse(); + if (object.collectionIds) { + if (!Array.isArray(object.collectionIds)) + throw TypeError(".google.firestore.v1beta1.ListCollectionIdsResponse.collectionIds: array expected"); + message.collectionIds = []; + for (var i = 0; i < object.collectionIds.length; ++i) + message.collectionIds[i] = String(object.collectionIds[i]); + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListCollectionIdsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @static + * @param {google.firestore.v1beta1.ListCollectionIdsResponse} message ListCollectionIdsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListCollectionIdsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.collectionIds = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.collectionIds && message.collectionIds.length) { + object.collectionIds = []; + for (var j = 0; j < message.collectionIds.length; ++j) + object.collectionIds[j] = message.collectionIds[j]; + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListCollectionIdsResponse to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @instance + * @returns {Object.} JSON object + */ + ListCollectionIdsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListCollectionIdsResponse; + })(); + + v1beta1.BatchWriteRequest = (function() { + + /** + * Properties of a BatchWriteRequest. + * @memberof google.firestore.v1beta1 + * @interface IBatchWriteRequest + * @property {string|null} [database] BatchWriteRequest database + * @property {Array.|null} [writes] BatchWriteRequest writes + * @property {Object.|null} [labels] BatchWriteRequest labels + */ + + /** + * Constructs a new BatchWriteRequest. + * @memberof google.firestore.v1beta1 + * @classdesc Represents a BatchWriteRequest. + * @implements IBatchWriteRequest + * @constructor + * @param {google.firestore.v1beta1.IBatchWriteRequest=} [properties] Properties to set + */ + function BatchWriteRequest(properties) { + this.writes = []; + this.labels = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BatchWriteRequest database. + * @member {string} database + * @memberof google.firestore.v1beta1.BatchWriteRequest + * @instance + */ + BatchWriteRequest.prototype.database = ""; + + /** + * BatchWriteRequest writes. + * @member {Array.} writes + * @memberof google.firestore.v1beta1.BatchWriteRequest + * @instance + */ + BatchWriteRequest.prototype.writes = $util.emptyArray; + + /** + * BatchWriteRequest labels. + * @member {Object.} labels + * @memberof google.firestore.v1beta1.BatchWriteRequest + * @instance + */ + BatchWriteRequest.prototype.labels = $util.emptyObject; + + /** + * Creates a BatchWriteRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.BatchWriteRequest + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.BatchWriteRequest} BatchWriteRequest + */ + BatchWriteRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.BatchWriteRequest) + return object; + var message = new $root.google.firestore.v1beta1.BatchWriteRequest(); + if (object.database != null) + message.database = String(object.database); + if (object.writes) { + if (!Array.isArray(object.writes)) + throw TypeError(".google.firestore.v1beta1.BatchWriteRequest.writes: array expected"); + message.writes = []; + for (var i = 0; i < object.writes.length; ++i) { + if (typeof object.writes[i] !== "object") + throw TypeError(".google.firestore.v1beta1.BatchWriteRequest.writes: object expected"); + message.writes[i] = $root.google.firestore.v1beta1.Write.fromObject(object.writes[i]); + } + } + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.firestore.v1beta1.BatchWriteRequest.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } + return message; + }; + + /** + * Creates a plain object from a BatchWriteRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.BatchWriteRequest + * @static + * @param {google.firestore.v1beta1.BatchWriteRequest} message BatchWriteRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchWriteRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.writes = []; + if (options.objects || options.defaults) + object.labels = {}; + if (options.defaults) + object.database = ""; + if (message.database != null && message.hasOwnProperty("database")) + object.database = message.database; + if (message.writes && message.writes.length) { + object.writes = []; + for (var j = 0; j < message.writes.length; ++j) + object.writes[j] = $root.google.firestore.v1beta1.Write.toObject(message.writes[j], options); + } + var keys2; + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } + return object; + }; + + /** + * Converts this BatchWriteRequest to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.BatchWriteRequest + * @instance + * @returns {Object.} JSON object + */ + BatchWriteRequest.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; - return ListCollectionIdsRequest; + return BatchWriteRequest; })(); - v1beta1.ListCollectionIdsResponse = (function() { + v1beta1.BatchWriteResponse = (function() { /** - * Properties of a ListCollectionIdsResponse. + * Properties of a BatchWriteResponse. * @memberof google.firestore.v1beta1 - * @interface IListCollectionIdsResponse - * @property {Array.|null} [collectionIds] ListCollectionIdsResponse collectionIds - * @property {string|null} [nextPageToken] ListCollectionIdsResponse nextPageToken + * @interface IBatchWriteResponse + * @property {Array.|null} [writeResults] BatchWriteResponse writeResults + * @property {Array.|null} [status] BatchWriteResponse status */ /** - * Constructs a new ListCollectionIdsResponse. + * Constructs a new BatchWriteResponse. * @memberof google.firestore.v1beta1 - * @classdesc Represents a ListCollectionIdsResponse. - * @implements IListCollectionIdsResponse + * @classdesc Represents a BatchWriteResponse. + * @implements IBatchWriteResponse * @constructor - * @param {google.firestore.v1beta1.IListCollectionIdsResponse=} [properties] Properties to set + * @param {google.firestore.v1beta1.IBatchWriteResponse=} [properties] Properties to set */ - function ListCollectionIdsResponse(properties) { - this.collectionIds = []; + function BatchWriteResponse(properties) { + this.writeResults = []; + this.status = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -11019,84 +11611,98 @@ } /** - * ListCollectionIdsResponse collectionIds. - * @member {Array.} collectionIds - * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * BatchWriteResponse writeResults. + * @member {Array.} writeResults + * @memberof google.firestore.v1beta1.BatchWriteResponse * @instance */ - ListCollectionIdsResponse.prototype.collectionIds = $util.emptyArray; + BatchWriteResponse.prototype.writeResults = $util.emptyArray; /** - * ListCollectionIdsResponse nextPageToken. - * @member {string} nextPageToken - * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * BatchWriteResponse status. + * @member {Array.} status + * @memberof google.firestore.v1beta1.BatchWriteResponse * @instance */ - ListCollectionIdsResponse.prototype.nextPageToken = ""; + BatchWriteResponse.prototype.status = $util.emptyArray; /** - * Creates a ListCollectionIdsResponse message from a plain object. Also converts values to their respective internal types. + * Creates a BatchWriteResponse message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @memberof google.firestore.v1beta1.BatchWriteResponse * @static * @param {Object.} object Plain object - * @returns {google.firestore.v1beta1.ListCollectionIdsResponse} ListCollectionIdsResponse + * @returns {google.firestore.v1beta1.BatchWriteResponse} BatchWriteResponse */ - ListCollectionIdsResponse.fromObject = function fromObject(object) { - if (object instanceof $root.google.firestore.v1beta1.ListCollectionIdsResponse) + BatchWriteResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.BatchWriteResponse) return object; - var message = new $root.google.firestore.v1beta1.ListCollectionIdsResponse(); - if (object.collectionIds) { - if (!Array.isArray(object.collectionIds)) - throw TypeError(".google.firestore.v1beta1.ListCollectionIdsResponse.collectionIds: array expected"); - message.collectionIds = []; - for (var i = 0; i < object.collectionIds.length; ++i) - message.collectionIds[i] = String(object.collectionIds[i]); + var message = new $root.google.firestore.v1beta1.BatchWriteResponse(); + if (object.writeResults) { + if (!Array.isArray(object.writeResults)) + throw TypeError(".google.firestore.v1beta1.BatchWriteResponse.writeResults: array expected"); + message.writeResults = []; + for (var i = 0; i < object.writeResults.length; ++i) { + if (typeof object.writeResults[i] !== "object") + throw TypeError(".google.firestore.v1beta1.BatchWriteResponse.writeResults: object expected"); + message.writeResults[i] = $root.google.firestore.v1beta1.WriteResult.fromObject(object.writeResults[i]); + } + } + if (object.status) { + if (!Array.isArray(object.status)) + throw TypeError(".google.firestore.v1beta1.BatchWriteResponse.status: array expected"); + message.status = []; + for (var i = 0; i < object.status.length; ++i) { + if (typeof object.status[i] !== "object") + throw TypeError(".google.firestore.v1beta1.BatchWriteResponse.status: object expected"); + message.status[i] = $root.google.rpc.Status.fromObject(object.status[i]); + } } - if (object.nextPageToken != null) - message.nextPageToken = String(object.nextPageToken); return message; }; /** - * Creates a plain object from a ListCollectionIdsResponse message. Also converts values to other types if specified. + * Creates a plain object from a BatchWriteResponse message. Also converts values to other types if specified. * @function toObject - * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @memberof google.firestore.v1beta1.BatchWriteResponse * @static - * @param {google.firestore.v1beta1.ListCollectionIdsResponse} message ListCollectionIdsResponse + * @param {google.firestore.v1beta1.BatchWriteResponse} message BatchWriteResponse * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - ListCollectionIdsResponse.toObject = function toObject(message, options) { + BatchWriteResponse.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.arrays || options.defaults) - object.collectionIds = []; - if (options.defaults) - object.nextPageToken = ""; - if (message.collectionIds && message.collectionIds.length) { - object.collectionIds = []; - for (var j = 0; j < message.collectionIds.length; ++j) - object.collectionIds[j] = message.collectionIds[j]; + if (options.arrays || options.defaults) { + object.writeResults = []; + object.status = []; + } + if (message.writeResults && message.writeResults.length) { + object.writeResults = []; + for (var j = 0; j < message.writeResults.length; ++j) + object.writeResults[j] = $root.google.firestore.v1beta1.WriteResult.toObject(message.writeResults[j], options); + } + if (message.status && message.status.length) { + object.status = []; + for (var j = 0; j < message.status.length; ++j) + object.status[j] = $root.google.rpc.Status.toObject(message.status[j], options); } - if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) - object.nextPageToken = message.nextPageToken; return object; }; /** - * Converts this ListCollectionIdsResponse to JSON. + * Converts this BatchWriteResponse to JSON. * @function toJSON - * @memberof google.firestore.v1beta1.ListCollectionIdsResponse + * @memberof google.firestore.v1beta1.BatchWriteResponse * @instance * @returns {Object.} JSON object */ - ListCollectionIdsResponse.prototype.toJSON = function toJSON() { + BatchWriteResponse.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; - return ListCollectionIdsResponse; + return BatchWriteResponse; })(); v1beta1.StructuredQuery = (function() { @@ -11780,6 +12386,10 @@ case 5: message.op = 5; break; + case "NOT_EQUAL": + case 6: + message.op = 6; + break; case "ARRAY_CONTAINS": case 7: message.op = 7; @@ -11792,6 +12402,10 @@ case 9: message.op = 9; break; + case "NOT_IN": + case 10: + message.op = 10; + break; } if (object.value != null) { if (typeof object.value !== "object") @@ -11849,9 +12463,11 @@ * @property {string} GREATER_THAN=GREATER_THAN GREATER_THAN value * @property {string} GREATER_THAN_OR_EQUAL=GREATER_THAN_OR_EQUAL GREATER_THAN_OR_EQUAL value * @property {string} EQUAL=EQUAL EQUAL value + * @property {string} NOT_EQUAL=NOT_EQUAL NOT_EQUAL value * @property {string} ARRAY_CONTAINS=ARRAY_CONTAINS ARRAY_CONTAINS value * @property {string} IN=IN IN value * @property {string} ARRAY_CONTAINS_ANY=ARRAY_CONTAINS_ANY ARRAY_CONTAINS_ANY value + * @property {string} NOT_IN=NOT_IN NOT_IN value */ FieldFilter.Operator = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -11861,9 +12477,11 @@ values[valuesById[3] = "GREATER_THAN"] = "GREATER_THAN"; values[valuesById[4] = "GREATER_THAN_OR_EQUAL"] = "GREATER_THAN_OR_EQUAL"; values[valuesById[5] = "EQUAL"] = "EQUAL"; + values[valuesById[6] = "NOT_EQUAL"] = "NOT_EQUAL"; values[valuesById[7] = "ARRAY_CONTAINS"] = "ARRAY_CONTAINS"; values[valuesById[8] = "IN"] = "IN"; values[valuesById[9] = "ARRAY_CONTAINS_ANY"] = "ARRAY_CONTAINS_ANY"; + values[valuesById[10] = "NOT_IN"] = "NOT_IN"; return values; })(); @@ -11950,6 +12568,14 @@ case 3: message.op = 3; break; + case "IS_NOT_NAN": + case 4: + message.op = 4; + break; + case "IS_NOT_NULL": + case 5: + message.op = 5; + break; } if (object.field != null) { if (typeof object.field !== "object") @@ -12002,18 +12628,105 @@ * @property {string} OPERATOR_UNSPECIFIED=OPERATOR_UNSPECIFIED OPERATOR_UNSPECIFIED value * @property {string} IS_NAN=IS_NAN IS_NAN value * @property {string} IS_NULL=IS_NULL IS_NULL value + * @property {string} IS_NOT_NAN=IS_NOT_NAN IS_NOT_NAN value + * @property {string} IS_NOT_NULL=IS_NOT_NULL IS_NOT_NULL value */ UnaryFilter.Operator = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = "OPERATOR_UNSPECIFIED"; values[valuesById[2] = "IS_NAN"] = "IS_NAN"; values[valuesById[3] = "IS_NULL"] = "IS_NULL"; + values[valuesById[4] = "IS_NOT_NAN"] = "IS_NOT_NAN"; + values[valuesById[5] = "IS_NOT_NULL"] = "IS_NOT_NULL"; return values; })(); return UnaryFilter; })(); + StructuredQuery.FieldReference = (function() { + + /** + * Properties of a FieldReference. + * @memberof google.firestore.v1beta1.StructuredQuery + * @interface IFieldReference + * @property {string|null} [fieldPath] FieldReference fieldPath + */ + + /** + * Constructs a new FieldReference. + * @memberof google.firestore.v1beta1.StructuredQuery + * @classdesc Represents a FieldReference. + * @implements IFieldReference + * @constructor + * @param {google.firestore.v1beta1.StructuredQuery.IFieldReference=} [properties] Properties to set + */ + function FieldReference(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldReference fieldPath. + * @member {string} fieldPath + * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference + * @instance + */ + FieldReference.prototype.fieldPath = ""; + + /** + * Creates a FieldReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference + * @static + * @param {Object.} object Plain object + * @returns {google.firestore.v1beta1.StructuredQuery.FieldReference} FieldReference + */ + FieldReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.firestore.v1beta1.StructuredQuery.FieldReference) + return object; + var message = new $root.google.firestore.v1beta1.StructuredQuery.FieldReference(); + if (object.fieldPath != null) + message.fieldPath = String(object.fieldPath); + return message; + }; + + /** + * Creates a plain object from a FieldReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference + * @static + * @param {google.firestore.v1beta1.StructuredQuery.FieldReference} message FieldReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.fieldPath = ""; + if (message.fieldPath != null && message.hasOwnProperty("fieldPath")) + object.fieldPath = message.fieldPath; + return object; + }; + + /** + * Converts this FieldReference to JSON. + * @function toJSON + * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference + * @instance + * @returns {Object.} JSON object + */ + FieldReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FieldReference; + })(); + StructuredQuery.Order = (function() { /** @@ -12127,89 +12840,6 @@ return Order; })(); - StructuredQuery.FieldReference = (function() { - - /** - * Properties of a FieldReference. - * @memberof google.firestore.v1beta1.StructuredQuery - * @interface IFieldReference - * @property {string|null} [fieldPath] FieldReference fieldPath - */ - - /** - * Constructs a new FieldReference. - * @memberof google.firestore.v1beta1.StructuredQuery - * @classdesc Represents a FieldReference. - * @implements IFieldReference - * @constructor - * @param {google.firestore.v1beta1.StructuredQuery.IFieldReference=} [properties] Properties to set - */ - function FieldReference(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FieldReference fieldPath. - * @member {string} fieldPath - * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference - * @instance - */ - FieldReference.prototype.fieldPath = ""; - - /** - * Creates a FieldReference message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference - * @static - * @param {Object.} object Plain object - * @returns {google.firestore.v1beta1.StructuredQuery.FieldReference} FieldReference - */ - FieldReference.fromObject = function fromObject(object) { - if (object instanceof $root.google.firestore.v1beta1.StructuredQuery.FieldReference) - return object; - var message = new $root.google.firestore.v1beta1.StructuredQuery.FieldReference(); - if (object.fieldPath != null) - message.fieldPath = String(object.fieldPath); - return message; - }; - - /** - * Creates a plain object from a FieldReference message. Also converts values to other types if specified. - * @function toObject - * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference - * @static - * @param {google.firestore.v1beta1.StructuredQuery.FieldReference} message FieldReference - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - FieldReference.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.fieldPath = ""; - if (message.fieldPath != null && message.hasOwnProperty("fieldPath")) - object.fieldPath = message.fieldPath; - return object; - }; - - /** - * Converts this FieldReference to JSON. - * @function toJSON - * @memberof google.firestore.v1beta1.StructuredQuery.FieldReference - * @instance - * @returns {Object.} JSON object - */ - FieldReference.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return FieldReference; - })(); - StructuredQuery.Projection = (function() { /** @@ -12444,6 +13074,7 @@ * @property {string|null} ["delete"] Write delete * @property {google.firestore.v1beta1.IDocumentTransform|null} [transform] Write transform * @property {google.firestore.v1beta1.IDocumentMask|null} [updateMask] Write updateMask + * @property {Array.|null} [updateTransforms] Write updateTransforms * @property {google.firestore.v1beta1.IPrecondition|null} [currentDocument] Write currentDocument */ @@ -12456,6 +13087,7 @@ * @param {google.firestore.v1beta1.IWrite=} [properties] Properties to set */ function Write(properties) { + this.updateTransforms = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -12494,6 +13126,14 @@ */ Write.prototype.updateMask = null; + /** + * Write updateTransforms. + * @member {Array.} updateTransforms + * @memberof google.firestore.v1beta1.Write + * @instance + */ + Write.prototype.updateTransforms = $util.emptyArray; + /** * Write currentDocument. * @member {google.firestore.v1beta1.IPrecondition|null|undefined} currentDocument @@ -12545,6 +13185,16 @@ throw TypeError(".google.firestore.v1beta1.Write.updateMask: object expected"); message.updateMask = $root.google.firestore.v1beta1.DocumentMask.fromObject(object.updateMask); } + if (object.updateTransforms) { + if (!Array.isArray(object.updateTransforms)) + throw TypeError(".google.firestore.v1beta1.Write.updateTransforms: array expected"); + message.updateTransforms = []; + for (var i = 0; i < object.updateTransforms.length; ++i) { + if (typeof object.updateTransforms[i] !== "object") + throw TypeError(".google.firestore.v1beta1.Write.updateTransforms: object expected"); + message.updateTransforms[i] = $root.google.firestore.v1beta1.DocumentTransform.FieldTransform.fromObject(object.updateTransforms[i]); + } + } if (object.currentDocument != null) { if (typeof object.currentDocument !== "object") throw TypeError(".google.firestore.v1beta1.Write.currentDocument: object expected"); @@ -12566,6 +13216,8 @@ if (!options) options = {}; var object = {}; + if (options.arrays || options.defaults) + object.updateTransforms = []; if (options.defaults) { object.updateMask = null; object.currentDocument = null; @@ -12589,6 +13241,11 @@ if (options.oneofs) object.operation = "transform"; } + if (message.updateTransforms && message.updateTransforms.length) { + object.updateTransforms = []; + for (var j = 0; j < message.updateTransforms.length; ++j) + object.updateTransforms[j] = $root.google.firestore.v1beta1.DocumentTransform.FieldTransform.toObject(message.updateTransforms[j], options); + } return object; }; diff --git a/dev/protos/google/firestore/v1/common.proto b/dev/protos/google/firestore/v1/common.proto index 4367f168d..3bc978ca9 100644 --- a/dev/protos/google/firestore/v1/common.proto +++ b/dev/protos/google/firestore/v1/common.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/dev/protos/google/firestore/v1/document.proto b/dev/protos/google/firestore/v1/document.proto index 148d2bddd..5238a943c 100644 --- a/dev/protos/google/firestore/v1/document.proto +++ b/dev/protos/google/firestore/v1/document.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/dev/protos/google/firestore/v1/firestore.proto b/dev/protos/google/firestore/v1/firestore.proto index e035d1b4e..b149a7634 100644 --- a/dev/protos/google/firestore/v1/firestore.proto +++ b/dev/protos/google/firestore/v1/firestore.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/dev/protos/google/firestore/v1/query.proto b/dev/protos/google/firestore/v1/query.proto index eea1d1178..304499847 100644 --- a/dev/protos/google/firestore/v1/query.proto +++ b/dev/protos/google/firestore/v1/query.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/dev/protos/google/firestore/v1/write.proto b/dev/protos/google/firestore/v1/write.proto index a6befb0e6..c78437bab 100644 --- a/dev/protos/google/firestore/v1/write.proto +++ b/dev/protos/google/firestore/v1/write.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -80,7 +80,8 @@ message DocumentTransform { SERVER_VALUE_UNSPECIFIED = 0; // The time at which the server processed the request, with millisecond - // precision. + // precision. If used on multiple fields (same or different documents) in + // a transaction, all the fields will get the same server timestamp. REQUEST_TIME = 1; } diff --git a/dev/protos/google/firestore/v1beta1/common.proto b/dev/protos/google/firestore/v1beta1/common.proto index b71a2e32e..59c34dd5d 100644 --- a/dev/protos/google/firestore/v1beta1/common.proto +++ b/dev/protos/google/firestore/v1beta1/common.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; diff --git a/dev/protos/google/firestore/v1beta1/document.proto b/dev/protos/google/firestore/v1beta1/document.proto index 38d81af96..7b9d955b9 100644 --- a/dev/protos/google/firestore/v1beta1/document.proto +++ b/dev/protos/google/firestore/v1beta1/document.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; diff --git a/dev/protos/google/firestore/v1beta1/firestore.proto b/dev/protos/google/firestore/v1beta1/firestore.proto index 5cdccb7ea..1fd3a58f3 100644 --- a/dev/protos/google/firestore/v1beta1/firestore.proto +++ b/dev/protos/google/firestore/v1beta1/firestore.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; @@ -41,20 +40,12 @@ option ruby_package = "Google::Cloud::Firestore::V1beta1"; // The Cloud Firestore service. // -// This service exposes several types of comparable timestamps: -// -// * `create_time` - The time at which a document was created. Changes only -// when a document is deleted, then re-created. Increases in a strict -// monotonic fashion. -// * `update_time` - The time at which a document was last updated. Changes -// every time a document is modified. Does not change when a write results -// in no modifications. Increases in a strict monotonic fashion. -// * `read_time` - The time at which a particular state was observed. Used -// to denote a consistent snapshot of the database or the time at which a -// Document was observed to not exist. -// * `commit_time` - The time at which the writes in a transaction were -// committed. Any read with an equal or greater `read_time` is guaranteed -// to see the effects of the transaction. +// Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL +// document database that simplifies storing, syncing, and querying data for +// your mobile, web, and IoT apps at global scale. Its client libraries provide +// live synchronization and offline support, while its security features and +// integrations with Firebase and Google Cloud Platform (GCP) accelerate +// building truly serverless apps. service Firestore { option (google.api.default_host) = "firestore.googleapis.com"; option (google.api.oauth_scopes) = @@ -75,14 +66,6 @@ service Firestore { }; } - // Creates a new document. - rpc CreateDocument(CreateDocumentRequest) returns (Document) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}" - body: "document" - }; - } - // Updates or inserts a document. rpc UpdateDocument(UpdateDocumentRequest) returns (Document) { option (google.api.http) = { @@ -150,6 +133,20 @@ service Firestore { }; } + // 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. + rpc PartitionQuery(PartitionQueryRequest) returns (PartitionQueryResponse) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/databases/*/documents}:partitionQuery" + body: "*" + additional_bindings { + post: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:partitionQuery" + body: "*" + } + }; + } + // Streams batches of document updates and deletes, in order. rpc Write(stream WriteRequest) returns (stream WriteResponse) { option (google.api.http) = { @@ -178,6 +175,30 @@ service Firestore { }; option (google.api.method_signature) = "parent"; } + + // 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 + // [BatchWriteResponse][google.firestore.v1beta1.BatchWriteResponse] for the success status of each write. + // + // If you require an atomically applied set of writes, use + // [Commit][google.firestore.v1beta1.Firestore.Commit] instead. + rpc BatchWrite(BatchWriteRequest) returns (BatchWriteResponse) { + option (google.api.http) = { + post: "/v1beta1/{database=projects/*/databases/*}/documents:batchWrite" + body: "*" + }; + } + + // Creates a new document. + rpc CreateDocument(CreateDocumentRequest) returns (Document) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}" + body: "document" + }; + } } // The request for [Firestore.GetDocument][google.firestore.v1beta1.Firestore.GetDocument]. @@ -199,7 +220,7 @@ message GetDocumentRequest { bytes transaction = 3; // 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. google.protobuf.Timestamp read_time = 5; } } @@ -240,7 +261,7 @@ message ListDocumentsRequest { bytes transaction = 8; // 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. google.protobuf.Timestamp read_time = 10; } @@ -356,7 +377,7 @@ message BatchGetDocumentsRequest { TransactionOptions new_transaction = 5; // 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. google.protobuf.Timestamp read_time = 7; } } @@ -426,7 +447,8 @@ message CommitResponse { // request. repeated WriteResult write_results = 1; - // The time at which the commit occurred. + // The time at which the commit occurred. Any read with an equal or greater + // `read_time` is guaranteed to see the effects of the commit. google.protobuf.Timestamp commit_time = 2; } @@ -469,7 +491,7 @@ message RunQueryRequest { TransactionOptions new_transaction = 6; // 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. google.protobuf.Timestamp read_time = 7; } } @@ -500,6 +522,85 @@ message RunQueryResponse { int32 skipped_results = 4; } +// The request for [Firestore.PartitionQuery][google.firestore.v1beta1.Firestore.PartitionQuery]. +message PartitionQueryRequest { + // 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. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The query to partition. + oneof query_type { + // A structured query. + // Query must specify collection with all descendants and be ordered by name + // ascending. Other filters, order bys, limits, offsets, and start/end + // cursors are not supported. + StructuredQuery structured_query = 2; + } + + // The desired maximum number of partition points. + // The partitions may be returned across multiple pages of results. + // The number must be 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. + int64 partition_count = 3; + + // 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 + string page_token = 4; + + // 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`. + int32 page_size = 5; +} + +// The response for [Firestore.PartitionQuery][google.firestore.v1beta1.Firestore.PartitionQuery]. +message PartitionQueryResponse { + // Partition results. + // Each partition is a split point that can be used by RunQuery as a starting + // or end point for the query results. The RunQuery requests must be made with + // the same query supplied to this PartitionQuery request. The partition + // cursors will be ordered according to same ordering as the results of the + // query supplied to PartitionQuery. + // + // For example, if a PartitionQuery request returns partition cursors A and B, + // running the following three queries will return the entire result set of + // the original query: + // + // * query, end_at A + // * query, start_at A, end_at B + // * query, start_at B + // + // An empty result may indicate that the query has too few results to be + // partitioned. + repeated Cursor partitions = 1; + + // A page token that may be used to request an additional set of results, up + // to the number specified by `partition_count` in the PartitionQuery request. + // If blank, there are no more results. + string next_page_token = 2; +} + // The request for [Firestore.Write][google.firestore.v1beta1.Firestore.Write]. // // The first request creates a stream, or resumes an existing one from a token. @@ -567,7 +668,8 @@ message WriteResponse { // request. repeated WriteResult write_results = 3; - // The time at which the commit occurred. + // The time at which the commit occurred. Any read with an equal or greater + // `read_time` is guaranteed to see the effects of the write. google.protobuf.Timestamp commit_time = 4; } @@ -764,3 +866,35 @@ message ListCollectionIdsResponse { // A page token that may be used to continue the list. string next_page_token = 2; } + +// The request for [Firestore.BatchWrite][google.firestore.v1beta1.Firestore.BatchWrite]. +message BatchWriteRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // 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. + repeated Write writes = 2; + + // Labels associated with this batch write. + map labels = 3; +} + +// The response from [Firestore.BatchWrite][google.firestore.v1beta1.Firestore.BatchWrite]. +message BatchWriteResponse { + // The result of applying the writes. + // + // This i-th write result corresponds to the i-th write in the + // request. + repeated WriteResult write_results = 1; + + // The status of applying the writes. + // + // This i-th write status corresponds to the i-th write in the + // request. + repeated google.rpc.Status status = 2; +} diff --git a/dev/protos/google/firestore/v1beta1/query.proto b/dev/protos/google/firestore/v1beta1/query.proto index 5f9c3ab93..0c14777a2 100644 --- a/dev/protos/google/firestore/v1beta1/query.proto +++ b/dev/protos/google/firestore/v1beta1/query.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; @@ -85,32 +84,74 @@ message StructuredQuery { // Unspecified. This value must not be used. OPERATOR_UNSPECIFIED = 0; - // Less than. Requires that the field come first in `order_by`. + // The given `field` is less than the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. LESS_THAN = 1; - // Less than or equal. Requires that the field come first in `order_by`. + // The given `field` is less than or equal to the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. LESS_THAN_OR_EQUAL = 2; - // Greater than. Requires that the field come first in `order_by`. + // The given `field` is greater than the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. GREATER_THAN = 3; - // Greater than or equal. Requires that the field come first in - // `order_by`. + // The given `field` is greater than or equal to the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. GREATER_THAN_OR_EQUAL = 4; - // Equal. + // The given `field` is equal to the given `value`. EQUAL = 5; - // Contains. Requires that the field is an array. + // The given `field` is not equal to the given `value`. + // + // Requires: + // + // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + NOT_EQUAL = 6; + + // The given `field` is an array that contains the given `value`. ARRAY_CONTAINS = 7; - // In. Requires that `value` is a non-empty ArrayValue with at most 10 - // values. + // The given `field` is equal to at least one value in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN` or `ARRAY_CONTAINS_ANY` or `NOT_IN`. IN = 8; - // Contains any. Requires that the field is an array and - // `value` is a non-empty ArrayValue with at most 10 values. + // The given `field` is an array that contains any of the values in the + // given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN` or `ARRAY_CONTAINS_ANY` or `NOT_IN`. ARRAY_CONTAINS_ANY = 9; + + // The value of the `field` is not in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN`, `ARRAY_CONTAINS_ANY`, `NOT_IN`, `NOT_EQUAL`, + // `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + NOT_IN = 10; } // The field to filter by. @@ -130,11 +171,27 @@ message StructuredQuery { // Unspecified. This value must not be used. OPERATOR_UNSPECIFIED = 0; - // Test if a field is equal to NaN. + // The given `field` is equal to `NaN`. IS_NAN = 2; - // Test if an expression evaluates to Null. + // The given `field` is equal to `NULL`. IS_NULL = 3; + + // The given `field` is not equal to `NaN`. + // + // Requires: + // + // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + IS_NOT_NAN = 4; + + // The given `field` is not equal to `NULL`. + // + // Requires: + // + // * A single `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + IS_NOT_NULL = 5; } // The unary operator to apply. @@ -147,6 +204,11 @@ message StructuredQuery { } } + // A reference to a field, such as `max(messages.time) as max_time`. + message FieldReference { + string field_path = 2; + } + // An order on a field. message Order { // The field to order by. @@ -156,11 +218,6 @@ message StructuredQuery { Direction direction = 2; } - // A reference to a field, such as `max(messages.time) as max_time`. - message FieldReference { - string field_path = 2; - } - // The projection of document's fields to return. message Projection { // The fields to return. diff --git a/dev/protos/google/firestore/v1beta1/write.proto b/dev/protos/google/firestore/v1beta1/write.proto index ba75b42a0..1ca3c1911 100644 --- a/dev/protos/google/firestore/v1beta1/write.proto +++ b/dev/protos/google/firestore/v1beta1/write.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; @@ -43,9 +42,6 @@ message Write { string delete = 2; // Applies a transformation to a document. - // At most one `transform` per document is allowed in a given request. - // An `update` cannot follow a `transform` on the same document in a given - // request. DocumentTransform transform = 6; } @@ -61,6 +57,13 @@ message Write { // The field paths in this mask must not contain a reserved field name. DocumentMask update_mask = 3; + // The transforms to perform after update. + // + // This field can be set only when the operation is `update`. If present, this + // write is equivalent to performing `update` and `transform` to the same + // document atomically and in order. + repeated DocumentTransform.FieldTransform update_transforms = 7; + // An optional precondition on the document. // // The write will fail if this is set and not met by the target document. @@ -77,7 +80,8 @@ message DocumentTransform { SERVER_VALUE_UNSPECIFIED = 0; // The time at which the server processed the request, with millisecond - // precision. + // precision. If used on multiple fields (same or different documents) in + // a transaction, all the fields will get the same server timestamp. REQUEST_TIME = 1; } diff --git a/dev/protos/protos.json b/dev/protos/protos.json index 3c9a3370f..44043811b 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -2535,22 +2535,6 @@ } ] }, - "CreateDocument": { - "requestType": "CreateDocumentRequest", - "responseType": "Document", - "options": { - "(google.api.http).post": "/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}", - "(google.api.http).body": "document" - }, - "parsedOptions": [ - { - "(google.api.http)": { - "post": "/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}", - "body": "document" - } - } - ] - }, "UpdateDocument": { "requestType": "UpdateDocumentRequest", "responseType": "Document", @@ -2689,6 +2673,28 @@ } ] }, + "PartitionQuery": { + "requestType": "PartitionQueryRequest", + "responseType": "PartitionQueryResponse", + "options": { + "(google.api.http).post": "/v1beta1/{parent=projects/*/databases/*/documents}:partitionQuery", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:partitionQuery", + "(google.api.http).additional_bindings.body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta1/{parent=projects/*/databases/*/documents}:partitionQuery", + "body": "*", + "additional_bindings": { + "post": "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:partitionQuery", + "body": "*" + } + } + } + ] + }, "Write": { "requestType": "WriteRequest", "requestStream": true, @@ -2750,6 +2756,38 @@ "(google.api.method_signature)": "parent" } ] + }, + "BatchWrite": { + "requestType": "BatchWriteRequest", + "responseType": "BatchWriteResponse", + "options": { + "(google.api.http).post": "/v1beta1/{database=projects/*/databases/*}/documents:batchWrite", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta1/{database=projects/*/databases/*}/documents:batchWrite", + "body": "*" + } + } + ] + }, + "CreateDocument": { + "requestType": "CreateDocumentRequest", + "responseType": "Document", + "options": { + "(google.api.http).post": "/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}", + "(google.api.http).body": "document" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}", + "body": "document" + } + } + ] } } }, @@ -3126,6 +3164,53 @@ } } }, + "PartitionQueryRequest": { + "oneofs": { + "queryType": { + "oneof": [ + "structuredQuery" + ] + } + }, + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "structuredQuery": { + "type": "StructuredQuery", + "id": 2 + }, + "partitionCount": { + "type": "int64", + "id": 3 + }, + "pageToken": { + "type": "string", + "id": 4 + }, + "pageSize": { + "type": "int32", + "id": 5 + } + } + }, + "PartitionQueryResponse": { + "fields": { + "partitions": { + "rule": "repeated", + "type": "Cursor", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, "WriteRequest": { "fields": { "database": { @@ -3383,6 +3468,41 @@ } } }, + "BatchWriteRequest": { + "fields": { + "database": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "writes": { + "rule": "repeated", + "type": "Write", + "id": 2 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 3 + } + } + }, + "BatchWriteResponse": { + "fields": { + "writeResults": { + "rule": "repeated", + "type": "WriteResult", + "id": 1 + }, + "status": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 2 + } + } + }, "StructuredQuery": { "fields": { "select": { @@ -3503,9 +3623,11 @@ "GREATER_THAN": 3, "GREATER_THAN_OR_EQUAL": 4, "EQUAL": 5, + "NOT_EQUAL": 6, "ARRAY_CONTAINS": 7, "IN": 8, - "ARRAY_CONTAINS_ANY": 9 + "ARRAY_CONTAINS_ANY": 9, + "NOT_IN": 10 } } } @@ -3533,11 +3655,21 @@ "values": { "OPERATOR_UNSPECIFIED": 0, "IS_NAN": 2, - "IS_NULL": 3 + "IS_NULL": 3, + "IS_NOT_NAN": 4, + "IS_NOT_NULL": 5 } } } }, + "FieldReference": { + "fields": { + "fieldPath": { + "type": "string", + "id": 2 + } + } + }, "Order": { "fields": { "field": { @@ -3550,14 +3682,6 @@ } } }, - "FieldReference": { - "fields": { - "fieldPath": { - "type": "string", - "id": 2 - } - } - }, "Projection": { "fields": { "fields": { @@ -3616,6 +3740,11 @@ "type": "DocumentMask", "id": 3 }, + "updateTransforms": { + "rule": "repeated", + "type": "DocumentTransform.FieldTransform", + "id": 7 + }, "currentDocument": { "type": "Precondition", "id": 4 diff --git a/dev/src/v1/firestore_client_config.json b/dev/src/v1/firestore_client_config.json index 9a0b3025b..65c9d8705 100644 --- a/dev/src/v1/firestore_client_config.json +++ b/dev/src/v1/firestore_client_config.json @@ -7,15 +7,18 @@ "DEADLINE_EXCEEDED", "UNAVAILABLE" ], - "deadline_exceeded_internal_unavailable": [ + "deadline_exceeded_resource_exhausted_internal_unavailable": [ "DEADLINE_EXCEEDED", + "RESOURCE_EXHAUSTED", "INTERNAL", "UNAVAILABLE" ], - "unavailable": [ + "resource_exhausted_unavailable": [ + "RESOURCE_EXHAUSTED", "UNAVAILABLE" ], - "aborted_unavailable": [ + "resource_exhausted_aborted_unavailable": [ + "RESOURCE_EXHAUSTED", "ABORTED", "UNAVAILABLE" ] @@ -34,52 +37,52 @@ "methods": { "GetDocument": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", "retry_params_name": "default" }, "ListDocuments": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", "retry_params_name": "default" }, "UpdateDocument": { "timeout_millis": 60000, - "retry_codes_name": "unavailable", + "retry_codes_name": "resource_exhausted_unavailable", "retry_params_name": "default" }, "DeleteDocument": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", "retry_params_name": "default" }, "BatchGetDocuments": { "timeout_millis": 300000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", "retry_params_name": "default" }, "BeginTransaction": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", "retry_params_name": "default" }, "Commit": { "timeout_millis": 60000, - "retry_codes_name": "unavailable", + "retry_codes_name": "resource_exhausted_unavailable", "retry_params_name": "default" }, "Rollback": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", "retry_params_name": "default" }, "RunQuery": { "timeout_millis": 300000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", "retry_params_name": "default" }, "PartitionQuery": { "timeout_millis": 300000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", "retry_params_name": "default" }, "Write": { @@ -89,22 +92,22 @@ }, "Listen": { "timeout_millis": 86400000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", "retry_params_name": "default" }, "ListCollectionIds": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", "retry_params_name": "default" }, "BatchWrite": { "timeout_millis": 60000, - "retry_codes_name": "aborted_unavailable", + "retry_codes_name": "resource_exhausted_aborted_unavailable", "retry_params_name": "default" }, "CreateDocument": { "timeout_millis": 60000, - "retry_codes_name": "unavailable", + "retry_codes_name": "resource_exhausted_unavailable", "retry_params_name": "default" } } diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index d3834a18d..49f1f77d8 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -45,20 +45,12 @@ const version = require('../../../package.json').version; /** * The Cloud Firestore service. * - * This service exposes several types of comparable timestamps: - * - * * `create_time` - The time at which a document was created. Changes only - * when a document is deleted, then re-created. Increases in a strict - * monotonic fashion. - * * `update_time` - The time at which a document was last updated. Changes - * every time a document is modified. Does not change when a write results - * in no modifications. Increases in a strict monotonic fashion. - * * `read_time` - The time at which a particular state was observed. Used - * to denote a consistent snapshot of the database or the time at which a - * Document was observed to not exist. - * * `commit_time` - The time at which the writes in a transaction were - * committed. Any read with an equal or greater `read_time` is guaranteed - * to see the effects of the transaction. + * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL + * document database that simplifies storing, syncing, and querying data for + * your mobile, web, and IoT apps at global scale. Its client libraries provide + * live synchronization and offline support, while its security features and + * integrations with Firebase and Google Cloud Platform (GCP) accelerate + * building truly serverless apps. * @class * @deprecated Use v1/firestore_client instead. * @memberof v1beta1 @@ -188,6 +180,11 @@ export class FirestoreClient { 'nextPageToken', 'documents' ), + partitionQuery: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'partitions' + ), listCollectionIds: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', @@ -260,7 +257,6 @@ export class FirestoreClient { const firestoreStubMethods = [ 'getDocument', 'listDocuments', - 'createDocument', 'updateDocument', 'deleteDocument', 'batchGetDocuments', @@ -268,9 +264,12 @@ export class FirestoreClient { 'commit', 'rollback', 'runQuery', + 'partitionQuery', 'write', 'listen', 'listCollectionIds', + 'batchWrite', + 'createDocument', ]; for (const methodName of firestoreStubMethods) { const callPromise = this.firestoreStub.then( @@ -402,7 +401,7 @@ export class FirestoreClient { * Reads the document in a transaction. * @param {google.protobuf.Timestamp} request.readTime * 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] * 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. @@ -455,107 +454,6 @@ export class FirestoreClient { this.initialize(); return this.innerApiCalls.getDocument(request, options, callback); } - createDocument( - request: protos.google.firestore.v1beta1.ICreateDocumentRequest, - options?: CallOptions - ): Promise< - [ - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.ICreateDocumentRequest | undefined, - {} | undefined - ] - >; - createDocument( - request: protos.google.firestore.v1beta1.ICreateDocumentRequest, - options: 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; - /** - * Creates a new document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource. For example: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` - * @param {string} request.collectionId - * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. - * @param {string} request.documentId - * The client-assigned document ID to use for this document. - * - * Optional. If not specified, an ID will be assigned by the service. - * @param {google.firestore.v1beta1.Document} request.document - * Required. The document to create. `name` must not be set. - * @param {google.firestore.v1beta1.DocumentMask} request.mask - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * @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 [Document]{@link google.firestore.v1beta1.Document}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.createDocument(request); - */ - createDocument( - request: protos.google.firestore.v1beta1.ICreateDocumentRequest, - optionsOrCallback?: - | CallOptions - | Callback< - protos.google.firestore.v1beta1.IDocument, - | protos.google.firestore.v1beta1.ICreateDocumentRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.ICreateDocumentRequest | null | undefined, - {} | null | undefined - > - ): Promise< - [ - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.ICreateDocumentRequest | undefined, - {} | undefined - ] - > | void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as CallOptions; - } - 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.createDocument(request, options, callback); - } updateDocument( request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, options?: CallOptions @@ -1023,6 +921,208 @@ export class FirestoreClient { this.initialize(); return this.innerApiCalls.rollback(request, options, callback); } + batchWrite( + request: protos.google.firestore.v1beta1.IBatchWriteRequest, + options?: CallOptions + ): Promise< + [ + protos.google.firestore.v1beta1.IBatchWriteResponse, + protos.google.firestore.v1beta1.IBatchWriteRequest | undefined, + {} | undefined + ] + >; + batchWrite( + request: protos.google.firestore.v1beta1.IBatchWriteRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.v1beta1.IBatchWriteResponse, + protos.google.firestore.v1beta1.IBatchWriteRequest | null | undefined, + {} | null | undefined + > + ): void; + batchWrite( + request: protos.google.firestore.v1beta1.IBatchWriteRequest, + callback: Callback< + protos.google.firestore.v1beta1.IBatchWriteResponse, + protos.google.firestore.v1beta1.IBatchWriteRequest | null | undefined, + {} | null | undefined + > + ): void; + /** + * 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.v1beta1.BatchWriteResponse|BatchWriteResponse} for the success status of each write. + * + * If you require an atomically applied set of writes, use + * {@link google.firestore.v1beta1.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.v1beta1.BatchWriteResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.batchWrite(request); + */ + batchWrite( + request: protos.google.firestore.v1beta1.IBatchWriteRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.firestore.v1beta1.IBatchWriteResponse, + protos.google.firestore.v1beta1.IBatchWriteRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.firestore.v1beta1.IBatchWriteResponse, + protos.google.firestore.v1beta1.IBatchWriteRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.firestore.v1beta1.IBatchWriteResponse, + protos.google.firestore.v1beta1.IBatchWriteRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + 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); + } + createDocument( + request: protos.google.firestore.v1beta1.ICreateDocumentRequest, + options?: CallOptions + ): Promise< + [ + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.ICreateDocumentRequest | undefined, + {} | undefined + ] + >; + createDocument( + request: protos.google.firestore.v1beta1.ICreateDocumentRequest, + options: 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; + /** + * Creates a new document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. For example: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` + * @param {string} request.collectionId + * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. + * @param {string} request.documentId + * The client-assigned document ID to use for this document. + * + * Optional. If not specified, an ID will be assigned by the service. + * @param {google.firestore.v1beta1.Document} request.document + * Required. The document to create. `name` must not be set. + * @param {google.firestore.v1beta1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + * @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 [Document]{@link google.firestore.v1beta1.Document}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createDocument(request); + */ + createDocument( + request: protos.google.firestore.v1beta1.ICreateDocumentRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.firestore.v1beta1.IDocument, + | protos.google.firestore.v1beta1.ICreateDocumentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.ICreateDocumentRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.ICreateDocumentRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + 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.createDocument(request, options, callback); + } /** * Gets multiple documents. @@ -1054,7 +1154,7 @@ export class FirestoreClient { * stream. * @param {google.protobuf.Timestamp} request.readTime * 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] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} @@ -1107,7 +1207,7 @@ export class FirestoreClient { * stream. * @param {google.protobuf.Timestamp} request.readTime * 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] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} @@ -1242,7 +1342,7 @@ export class FirestoreClient { * 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. + * 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 @@ -1336,7 +1436,7 @@ export class FirestoreClient { * 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. + * 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 @@ -1410,7 +1510,7 @@ export class FirestoreClient { * 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. + * 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 @@ -1457,6 +1557,307 @@ export class FirestoreClient { callSettings ) as AsyncIterable; } + partitionQuery( + request: protos.google.firestore.v1beta1.IPartitionQueryRequest, + options?: CallOptions + ): Promise< + [ + protos.google.firestore.v1beta1.ICursor[], + protos.google.firestore.v1beta1.IPartitionQueryRequest | null, + protos.google.firestore.v1beta1.IPartitionQueryResponse + ] + >; + partitionQuery( + request: protos.google.firestore.v1beta1.IPartitionQueryRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.firestore.v1beta1.IPartitionQueryRequest, + | protos.google.firestore.v1beta1.IPartitionQueryResponse + | null + | undefined, + protos.google.firestore.v1beta1.ICursor + > + ): void; + partitionQuery( + request: protos.google.firestore.v1beta1.IPartitionQueryRequest, + callback: PaginationCallback< + protos.google.firestore.v1beta1.IPartitionQueryRequest, + | protos.google.firestore.v1beta1.IPartitionQueryResponse + | null + | undefined, + protos.google.firestore.v1beta1.ICursor + > + ): void; + /** + * 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.v1beta1.StructuredQuery} request.structuredQuery + * A structured query. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other 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 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.v1beta1.Cursor}. + * The client library will perform 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. + * Note that it can affect your quota. + * We recommend using `partitionQueryAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + partitionQuery( + request: protos.google.firestore.v1beta1.IPartitionQueryRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.firestore.v1beta1.IPartitionQueryRequest, + | protos.google.firestore.v1beta1.IPartitionQueryResponse + | null + | undefined, + protos.google.firestore.v1beta1.ICursor + >, + callback?: PaginationCallback< + protos.google.firestore.v1beta1.IPartitionQueryRequest, + | protos.google.firestore.v1beta1.IPartitionQueryResponse + | null + | undefined, + protos.google.firestore.v1beta1.ICursor + > + ): Promise< + [ + protos.google.firestore.v1beta1.ICursor[], + protos.google.firestore.v1beta1.IPartitionQueryRequest | null, + protos.google.firestore.v1beta1.IPartitionQueryResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + 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 `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @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.v1beta1.StructuredQuery} request.structuredQuery + * A structured query. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other 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 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.v1beta1.Cursor} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `partitionQueryAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + partitionQueryStream( + request?: protos.google.firestore.v1beta1.IPartitionQueryRequest, + options?: CallOptions + ): Transform { + 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 as gax.GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `partitionQuery`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements 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.v1beta1.StructuredQuery} request.structuredQuery + * A structured query. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other 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 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Cursor]{@link google.firestore.v1beta1.Cursor}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.partitionQueryAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + partitionQueryAsync( + request?: protos.google.firestore.v1beta1.IPartitionQueryRequest, + options?: CallOptions + ): AsyncIterable { + 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'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } listCollectionIds( request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, options?: CallOptions diff --git a/dev/src/v1beta1/firestore_client_config.json b/dev/src/v1beta1/firestore_client_config.json index f180f8359..b0366d662 100644 --- a/dev/src/v1beta1/firestore_client_config.json +++ b/dev/src/v1beta1/firestore_client_config.json @@ -6,11 +6,6 @@ "idempotent": [ "DEADLINE_EXCEEDED", "UNAVAILABLE" - ], - "deadline_exceeded_resource_exhausted_unavailable": [ - "DEADLINE_EXCEEDED", - "RESOURCE_EXHAUSTED", - "UNAVAILABLE" ] }, "retry_params": { @@ -27,17 +22,12 @@ "methods": { "GetDocument": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", + "retry_codes_name": "idempotent", "retry_params_name": "default" }, "ListDocuments": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", - "retry_params_name": "default" - }, - "CreateDocument": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", + "retry_codes_name": "idempotent", "retry_params_name": "default" }, "UpdateDocument": { @@ -47,17 +37,17 @@ }, "DeleteDocument": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", + "retry_codes_name": "idempotent", "retry_params_name": "default" }, "BatchGetDocuments": { "timeout_millis": 300000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", + "retry_codes_name": "idempotent", "retry_params_name": "default" }, "BeginTransaction": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", + "retry_codes_name": "idempotent", "retry_params_name": "default" }, "Commit": { @@ -67,12 +57,16 @@ }, "Rollback": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", + "retry_codes_name": "idempotent", "retry_params_name": "default" }, "RunQuery": { "timeout_millis": 300000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "PartitionQuery": { + "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, "Write": { @@ -82,12 +76,21 @@ }, "Listen": { "timeout_millis": 86400000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", + "retry_codes_name": "idempotent", "retry_params_name": "default" }, "ListCollectionIds": { "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "BatchWrite": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateDocument": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", "retry_params_name": "default" } } diff --git a/dev/src/v1beta1/gapic_metadata.json b/dev/src/v1beta1/gapic_metadata.json index ec44c4bac..45483c761 100644 --- a/dev/src/v1beta1/gapic_metadata.json +++ b/dev/src/v1beta1/gapic_metadata.json @@ -15,11 +15,6 @@ "getDocument" ] }, - "CreateDocument": { - "methods": [ - "createDocument" - ] - }, "UpdateDocument": { "methods": [ "updateDocument" @@ -45,6 +40,16 @@ "rollback" ] }, + "BatchWrite": { + "methods": [ + "batchWrite" + ] + }, + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, "BatchGetDocuments": { "methods": [ "batchGetDocuments" @@ -72,6 +77,13 @@ "listDocumentsAsync" ] }, + "PartitionQuery": { + "methods": [ + "partitionQuery", + "partitionQueryStream", + "partitionQueryAsync" + ] + }, "ListCollectionIds": { "methods": [ "listCollectionIds", @@ -89,11 +101,6 @@ "getDocument" ] }, - "CreateDocument": { - "methods": [ - "createDocument" - ] - }, "UpdateDocument": { "methods": [ "updateDocument" @@ -119,6 +126,16 @@ "rollback" ] }, + "BatchWrite": { + "methods": [ + "batchWrite" + ] + }, + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, "ListDocuments": { "methods": [ "listDocuments", @@ -126,6 +143,13 @@ "listDocumentsAsync" ] }, + "PartitionQuery": { + "methods": [ + "partitionQuery", + "partitionQueryStream", + "partitionQueryAsync" + ] + }, "ListCollectionIds": { "methods": [ "listCollectionIds", diff --git a/dev/test/gapic_firestore_v1beta1.ts b/dev/test/gapic_firestore_v1beta1.ts index 157dea64d..ffb04ee50 100644 --- a/dev/test/gapic_firestore_v1beta1.ts +++ b/dev/test/gapic_firestore_v1beta1.ts @@ -341,118 +341,6 @@ describe('v1beta1.FirestoreClient', () => { }); }); - describe('createDocument', () => { - it('invokes createDocument without error', async () => { - const client = new firestoreModule.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.firestore.v1beta1.CreateDocumentRequest() - ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1beta1.Document() - ); - client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); - const [response] = await client.createDocument(request); - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createDocument as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); - }); - - it('invokes createDocument without error using callback', async () => { - const client = new firestoreModule.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.firestore.v1beta1.CreateDocumentRequest() - ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1beta1.Document() - ); - client.innerApiCalls.createDocument = stubSimpleCallWithCallback( - expectedResponse - ); - const promise = new Promise((resolve, reject) => { - client.createDocument( - request, - ( - err?: Error | null, - result?: protos.google.firestore.v1beta1.IDocument | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - } - ); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createDocument as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); - }); - - it('invokes createDocument with error', async () => { - const client = new firestoreModule.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.firestore.v1beta1.CreateDocumentRequest() - ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createDocument = stubSimpleCall( - undefined, - expectedError - ); - await assert.rejects(client.createDocument(request), expectedError); - assert( - (client.innerApiCalls.createDocument as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); - }); - }); - describe('updateDocument', () => { it('invokes updateDocument without error', async () => { const client = new firestoreModule.FirestoreClient({ @@ -952,17 +840,238 @@ describe('v1beta1.FirestoreClient', () => { }, }; const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.rollback = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.rollback( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.rollback as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes rollback with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.RollbackRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.rollback(request), expectedError); + assert( + (client.innerApiCalls.rollback as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('batchWrite', () => { + it('invokes batchWrite without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.BatchWriteRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.BatchWriteResponse() + ); + client.innerApiCalls.batchWrite = stubSimpleCall(expectedResponse); + const [response] = await client.batchWrite(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes batchWrite without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.BatchWriteRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.BatchWriteResponse() + ); + client.innerApiCalls.batchWrite = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.batchWrite( + request, + ( + err?: Error | null, + result?: protos.google.firestore.v1beta1.IBatchWriteResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes batchWrite with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.BatchWriteRequest() + ); + request.database = ''; + const expectedHeaderRequestParams = 'database='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchWrite = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.batchWrite(request), expectedError); + assert( + (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('createDocument', () => { + it('invokes createDocument without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.CreateDocumentRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.Document() + ); + client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); + const [response] = await client.createDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createDocument as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createDocument without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.CreateDocumentRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.Document() ); - client.innerApiCalls.rollback = stubSimpleCallWithCallback( + client.innerApiCalls.createDocument = stubSimpleCallWithCallback( expectedResponse ); const promise = new Promise((resolve, reject) => { - client.rollback( + client.createDocument( request, ( err?: Error | null, - result?: protos.google.protobuf.IEmpty | null + result?: protos.google.firestore.v1beta1.IDocument | null ) => { if (err) { reject(err); @@ -975,23 +1084,23 @@ describe('v1beta1.FirestoreClient', () => { const response = await promise; assert.deepStrictEqual(response, expectedResponse); assert( - (client.innerApiCalls.rollback as SinonStub) + (client.innerApiCalls.createDocument as SinonStub) .getCall(0) .calledWith(request, expectedOptions /*, callback defined above */) ); }); - it('invokes rollback with error', async () => { + it('invokes createDocument with error', async () => { const client = new firestoreModule.FirestoreClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); client.initialize(); const request = generateSampleMessage( - new protos.google.firestore.v1beta1.RollbackRequest() + new protos.google.firestore.v1beta1.CreateDocumentRequest() ); - request.database = ''; - const expectedHeaderRequestParams = 'database='; + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; const expectedOptions = { otherArgs: { headers: { @@ -1000,10 +1109,13 @@ describe('v1beta1.FirestoreClient', () => { }, }; const expectedError = new Error('expected'); - client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rollback(request), expectedError); + client.innerApiCalls.createDocument = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createDocument(request), expectedError); assert( - (client.innerApiCalls.rollback as SinonStub) + (client.innerApiCalls.createDocument as SinonStub) .getCall(0) .calledWith(request, expectedOptions, undefined) ); @@ -1658,6 +1770,296 @@ describe('v1beta1.FirestoreClient', () => { }); }); + describe('partitionQuery', () => { + it('invokes partitionQuery without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.PartitionQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + ]; + client.innerApiCalls.partitionQuery = stubSimpleCall(expectedResponse); + const [response] = await client.partitionQuery(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes partitionQuery without error using callback', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.PartitionQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + ]; + client.innerApiCalls.partitionQuery = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.partitionQuery( + request, + ( + err?: Error | null, + result?: protos.google.firestore.v1beta1.ICursor[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes partitionQuery with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.PartitionQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.partitionQuery = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.partitionQuery(request), expectedError); + assert( + (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes partitionQueryStream without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.PartitionQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + ]; + client.descriptors.page.partitionQuery.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.partitionQueryStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.v1beta1.Cursor[] = []; + stream.on( + 'data', + (response: protos.google.firestore.v1beta1.Cursor) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.partitionQuery, request) + ); + assert.strictEqual( + (client.descriptors.page.partitionQuery + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes partitionQueryStream with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.PartitionQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.partitionQuery.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.partitionQueryStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.v1beta1.Cursor[] = []; + stream.on( + 'data', + (response: protos.google.firestore.v1beta1.Cursor) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.partitionQuery, request) + ); + assert.strictEqual( + (client.descriptors.page.partitionQuery + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with partitionQuery without error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.PartitionQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + ]; + client.descriptors.page.partitionQuery.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.firestore.v1beta1.ICursor[] = []; + const iterable = client.partitionQueryAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.partitionQuery + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.partitionQuery + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with partitionQuery with error', async () => { + const client = new firestoreModule.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.firestore.v1beta1.PartitionQueryRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.partitionQuery.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.partitionQueryAsync(request); + await assert.rejects(async () => { + const responses: protos.google.firestore.v1beta1.ICursor[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.partitionQuery + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.partitionQuery + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); + describe('listCollectionIds', () => { it('invokes listCollectionIds without error', async () => { const client = new firestoreModule.FirestoreClient({ diff --git a/dev/test/index.ts b/dev/test/index.ts index 4355e1131..7cdf3e0a5 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -1105,7 +1105,7 @@ describe('getAll() method', () => { [Status.NOT_FOUND]: 1, [Status.ALREADY_EXISTS]: 1, [Status.PERMISSION_DENIED]: 1, - [Status.RESOURCE_EXHAUSTED]: 1, + [Status.RESOURCE_EXHAUSTED]: 5, [Status.FAILED_PRECONDITION]: 1, [Status.ABORTED]: 1, [Status.OUT_OF_RANGE]: 1, diff --git a/synth.py b/synth.py index 2dc885617..dfe589f36 100644 --- a/synth.py +++ b/synth.py @@ -158,7 +158,6 @@ # Remove auto-generated packaging tests os.system('rm -rf dev/system-test/fixtures dev/system-test/install.ts') -node.install() os.chdir("dev") node.compile_protos() os.chdir("protos") @@ -166,6 +165,7 @@ os.unlink('protos.d.ts') subprocess.run('./update.sh', shell=True) os.chdir("../../") +node.install() # Copy types into types/ os.system("cp build/src/v1/firestore*.d.ts types/v1") diff --git a/types/protos/firestore_v1beta1_proto_api.d.ts b/types/protos/firestore_v1beta1_proto_api.d.ts index 0086457e8..58cea05f6 100644 --- a/types/protos/firestore_v1beta1_proto_api.d.ts +++ b/types/protos/firestore_v1beta1_proto_api.d.ts @@ -2896,20 +2896,6 @@ export namespace google { */ public listDocuments(request: google.firestore.v1beta1.IListDocumentsRequest): Promise; - /** - * Calls CreateDocument. - * @param request CreateDocumentRequest message or plain object - * @param callback Node-style callback called with the error, if any, and Document - */ - public createDocument(request: google.firestore.v1beta1.ICreateDocumentRequest, callback: google.firestore.v1beta1.Firestore.CreateDocumentCallback): void; - - /** - * Calls CreateDocument. - * @param request CreateDocumentRequest message or plain object - * @returns Promise - */ - public createDocument(request: google.firestore.v1beta1.ICreateDocumentRequest): Promise; - /** * Calls UpdateDocument. * @param request UpdateDocumentRequest message or plain object @@ -3008,6 +2994,20 @@ export namespace google { */ public runQuery(request: google.firestore.v1beta1.IRunQueryRequest): Promise; + /** + * Calls PartitionQuery. + * @param request PartitionQueryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and PartitionQueryResponse + */ + public partitionQuery(request: google.firestore.v1beta1.IPartitionQueryRequest, callback: google.firestore.v1beta1.Firestore.PartitionQueryCallback): void; + + /** + * Calls PartitionQuery. + * @param request PartitionQueryRequest message or plain object + * @returns Promise + */ + public partitionQuery(request: google.firestore.v1beta1.IPartitionQueryRequest): Promise; + /** * Calls Write. * @param request WriteRequest message or plain object @@ -3049,6 +3049,34 @@ export namespace google { * @returns Promise */ public listCollectionIds(request: google.firestore.v1beta1.IListCollectionIdsRequest): Promise; + + /** + * Calls BatchWrite. + * @param request BatchWriteRequest message or plain object + * @param callback Node-style callback called with the error, if any, and BatchWriteResponse + */ + public batchWrite(request: google.firestore.v1beta1.IBatchWriteRequest, callback: google.firestore.v1beta1.Firestore.BatchWriteCallback): void; + + /** + * Calls BatchWrite. + * @param request BatchWriteRequest message or plain object + * @returns Promise + */ + public batchWrite(request: google.firestore.v1beta1.IBatchWriteRequest): Promise; + + /** + * Calls CreateDocument. + * @param request CreateDocumentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Document + */ + public createDocument(request: google.firestore.v1beta1.ICreateDocumentRequest, callback: google.firestore.v1beta1.Firestore.CreateDocumentCallback): void; + + /** + * Calls CreateDocument. + * @param request CreateDocumentRequest message or plain object + * @returns Promise + */ + public createDocument(request: google.firestore.v1beta1.ICreateDocumentRequest): Promise; } namespace Firestore { @@ -3067,13 +3095,6 @@ export namespace google { */ type ListDocumentsCallback = (error: (Error|null), response?: google.firestore.v1beta1.ListDocumentsResponse) => void; - /** - * Callback as used by {@link google.firestore.v1beta1.Firestore#createDocument}. - * @param error Error, if any - * @param [response] Document - */ - type CreateDocumentCallback = (error: (Error|null), response?: google.firestore.v1beta1.Document) => void; - /** * Callback as used by {@link google.firestore.v1beta1.Firestore#updateDocument}. * @param error Error, if any @@ -3123,6 +3144,13 @@ export namespace google { */ type RunQueryCallback = (error: (Error|null), response?: google.firestore.v1beta1.RunQueryResponse) => void; + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#partitionQuery}. + * @param error Error, if any + * @param [response] PartitionQueryResponse + */ + type PartitionQueryCallback = (error: (Error|null), response?: google.firestore.v1beta1.PartitionQueryResponse) => void; + /** * Callback as used by {@link google.firestore.v1beta1.Firestore#write}. * @param error Error, if any @@ -3143,6 +3171,20 @@ export namespace google { * @param [response] ListCollectionIdsResponse */ type ListCollectionIdsCallback = (error: (Error|null), response?: google.firestore.v1beta1.ListCollectionIdsResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#batchWrite}. + * @param error Error, if any + * @param [response] BatchWriteResponse + */ + type BatchWriteCallback = (error: (Error|null), response?: google.firestore.v1beta1.BatchWriteResponse) => void; + + /** + * Callback as used by {@link google.firestore.v1beta1.Firestore#createDocument}. + * @param error Error, if any + * @param [response] Document + */ + type CreateDocumentCallback = (error: (Error|null), response?: google.firestore.v1beta1.Document) => void; } /** Properties of a GetDocumentRequest. */ @@ -4018,6 +4060,121 @@ export namespace google { public toJSON(): { [k: string]: any }; } + /** Properties of a PartitionQueryRequest. */ + interface IPartitionQueryRequest { + + /** PartitionQueryRequest parent */ + parent?: (string|null); + + /** PartitionQueryRequest structuredQuery */ + structuredQuery?: (google.firestore.v1beta1.IStructuredQuery|null); + + /** PartitionQueryRequest partitionCount */ + partitionCount?: (number|string|null); + + /** PartitionQueryRequest pageToken */ + pageToken?: (string|null); + + /** PartitionQueryRequest pageSize */ + pageSize?: (number|null); + } + + /** Represents a PartitionQueryRequest. */ + class PartitionQueryRequest implements IPartitionQueryRequest { + + /** + * Constructs a new PartitionQueryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IPartitionQueryRequest); + + /** PartitionQueryRequest parent. */ + public parent: string; + + /** PartitionQueryRequest structuredQuery. */ + public structuredQuery?: (google.firestore.v1beta1.IStructuredQuery|null); + + /** PartitionQueryRequest partitionCount. */ + public partitionCount: (number|string); + + /** PartitionQueryRequest pageToken. */ + public pageToken: string; + + /** PartitionQueryRequest pageSize. */ + public pageSize: number; + + /** PartitionQueryRequest queryType. */ + public queryType?: "structuredQuery"; + + /** + * Creates a PartitionQueryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PartitionQueryRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.PartitionQueryRequest; + + /** + * Creates a plain object from a PartitionQueryRequest message. Also converts values to other types if specified. + * @param message PartitionQueryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.PartitionQueryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PartitionQueryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a PartitionQueryResponse. */ + interface IPartitionQueryResponse { + + /** PartitionQueryResponse partitions */ + partitions?: (google.firestore.v1beta1.ICursor[]|null); + + /** PartitionQueryResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a PartitionQueryResponse. */ + class PartitionQueryResponse implements IPartitionQueryResponse { + + /** + * Constructs a new PartitionQueryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IPartitionQueryResponse); + + /** PartitionQueryResponse partitions. */ + public partitions: google.firestore.v1beta1.ICursor[]; + + /** PartitionQueryResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a PartitionQueryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PartitionQueryResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.PartitionQueryResponse; + + /** + * Creates a plain object from a PartitionQueryResponse message. Also converts values to other types if specified. + * @param message PartitionQueryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.PartitionQueryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PartitionQueryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + /** Properties of a WriteRequest. */ interface IWriteRequest { @@ -4615,6 +4772,106 @@ export namespace google { public toJSON(): { [k: string]: any }; } + /** Properties of a BatchWriteRequest. */ + interface IBatchWriteRequest { + + /** BatchWriteRequest database */ + database?: (string|null); + + /** BatchWriteRequest writes */ + writes?: (google.firestore.v1beta1.IWrite[]|null); + + /** BatchWriteRequest labels */ + labels?: ({ [k: string]: string }|null); + } + + /** Represents a BatchWriteRequest. */ + class BatchWriteRequest implements IBatchWriteRequest { + + /** + * Constructs a new BatchWriteRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IBatchWriteRequest); + + /** BatchWriteRequest database. */ + public database: string; + + /** BatchWriteRequest writes. */ + public writes: google.firestore.v1beta1.IWrite[]; + + /** BatchWriteRequest labels. */ + public labels: { [k: string]: string }; + + /** + * Creates a BatchWriteRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchWriteRequest + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.BatchWriteRequest; + + /** + * Creates a plain object from a BatchWriteRequest message. Also converts values to other types if specified. + * @param message BatchWriteRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.BatchWriteRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchWriteRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BatchWriteResponse. */ + interface IBatchWriteResponse { + + /** BatchWriteResponse writeResults */ + writeResults?: (google.firestore.v1beta1.IWriteResult[]|null); + + /** BatchWriteResponse status */ + status?: (google.rpc.IStatus[]|null); + } + + /** Represents a BatchWriteResponse. */ + class BatchWriteResponse implements IBatchWriteResponse { + + /** + * Constructs a new BatchWriteResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.firestore.v1beta1.IBatchWriteResponse); + + /** BatchWriteResponse writeResults. */ + public writeResults: google.firestore.v1beta1.IWriteResult[]; + + /** BatchWriteResponse status. */ + public status: google.rpc.IStatus[]; + + /** + * Creates a BatchWriteResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchWriteResponse + */ + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.BatchWriteResponse; + + /** + * Creates a plain object from a BatchWriteResponse message. Also converts values to other types if specified. + * @param message BatchWriteResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.firestore.v1beta1.BatchWriteResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchWriteResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + /** Properties of a StructuredQuery. */ interface IStructuredQuery { @@ -4914,7 +5171,7 @@ export namespace google { /** Operator enum. */ type Operator = - "OPERATOR_UNSPECIFIED"| "LESS_THAN"| "LESS_THAN_OR_EQUAL"| "GREATER_THAN"| "GREATER_THAN_OR_EQUAL"| "EQUAL"| "ARRAY_CONTAINS"| "IN"| "ARRAY_CONTAINS_ANY"; + "OPERATOR_UNSPECIFIED"| "LESS_THAN"| "LESS_THAN_OR_EQUAL"| "GREATER_THAN"| "GREATER_THAN_OR_EQUAL"| "EQUAL"| "NOT_EQUAL"| "ARRAY_CONTAINS"| "IN"| "ARRAY_CONTAINS_ANY"| "NOT_IN"; } /** Properties of an UnaryFilter. */ @@ -4971,92 +5228,92 @@ export namespace google { /** Operator enum. */ type Operator = - "OPERATOR_UNSPECIFIED"| "IS_NAN"| "IS_NULL"; + "OPERATOR_UNSPECIFIED"| "IS_NAN"| "IS_NULL"| "IS_NOT_NAN"| "IS_NOT_NULL"; } - /** Properties of an Order. */ - interface IOrder { - - /** Order field */ - field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + /** Properties of a FieldReference. */ + interface IFieldReference { - /** Order direction */ - direction?: (google.firestore.v1beta1.StructuredQuery.Direction|null); + /** FieldReference fieldPath */ + fieldPath?: (string|null); } - /** Represents an Order. */ - class Order implements IOrder { + /** Represents a FieldReference. */ + class FieldReference implements IFieldReference { /** - * Constructs a new Order. + * Constructs a new FieldReference. * @param [properties] Properties to set */ - constructor(properties?: google.firestore.v1beta1.StructuredQuery.IOrder); - - /** Order field. */ - public field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + constructor(properties?: google.firestore.v1beta1.StructuredQuery.IFieldReference); - /** Order direction. */ - public direction: google.firestore.v1beta1.StructuredQuery.Direction; + /** FieldReference fieldPath. */ + public fieldPath: string; /** - * Creates an Order message from a plain object. Also converts values to their respective internal types. + * Creates a FieldReference message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns Order + * @returns FieldReference */ - public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.Order; + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.FieldReference; /** - * Creates a plain object from an Order message. Also converts values to other types if specified. - * @param message Order + * Creates a plain object from a FieldReference message. Also converts values to other types if specified. + * @param message FieldReference * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.firestore.v1beta1.StructuredQuery.Order, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.firestore.v1beta1.StructuredQuery.FieldReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this Order to JSON. + * Converts this FieldReference to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; } - /** Properties of a FieldReference. */ - interface IFieldReference { + /** Properties of an Order. */ + interface IOrder { - /** FieldReference fieldPath */ - fieldPath?: (string|null); + /** Order field */ + field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + + /** Order direction */ + direction?: (google.firestore.v1beta1.StructuredQuery.Direction|null); } - /** Represents a FieldReference. */ - class FieldReference implements IFieldReference { + /** Represents an Order. */ + class Order implements IOrder { /** - * Constructs a new FieldReference. + * Constructs a new Order. * @param [properties] Properties to set */ - constructor(properties?: google.firestore.v1beta1.StructuredQuery.IFieldReference); + constructor(properties?: google.firestore.v1beta1.StructuredQuery.IOrder); - /** FieldReference fieldPath. */ - public fieldPath: string; + /** Order field. */ + public field?: (google.firestore.v1beta1.StructuredQuery.IFieldReference|null); + + /** Order direction. */ + public direction: google.firestore.v1beta1.StructuredQuery.Direction; /** - * Creates a FieldReference message from a plain object. Also converts values to their respective internal types. + * Creates an Order message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns FieldReference + * @returns Order */ - public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.FieldReference; + public static fromObject(object: { [k: string]: any }): google.firestore.v1beta1.StructuredQuery.Order; /** - * Creates a plain object from a FieldReference message. Also converts values to other types if specified. - * @param message FieldReference + * Creates a plain object from an Order message. Also converts values to other types if specified. + * @param message Order * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.firestore.v1beta1.StructuredQuery.FieldReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.firestore.v1beta1.StructuredQuery.Order, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this FieldReference to JSON. + * Converts this Order to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; @@ -5170,6 +5427,9 @@ export namespace google { /** Write updateMask */ updateMask?: (google.firestore.v1beta1.IDocumentMask|null); + /** Write updateTransforms */ + updateTransforms?: (google.firestore.v1beta1.DocumentTransform.IFieldTransform[]|null); + /** Write currentDocument */ currentDocument?: (google.firestore.v1beta1.IPrecondition|null); } @@ -5195,6 +5455,9 @@ export namespace google { /** Write updateMask. */ public updateMask?: (google.firestore.v1beta1.IDocumentMask|null); + /** Write updateTransforms. */ + public updateTransforms: google.firestore.v1beta1.DocumentTransform.IFieldTransform[]; + /** Write currentDocument. */ public currentDocument?: (google.firestore.v1beta1.IPrecondition|null); diff --git a/types/v1beta1/firestore_client.d.ts b/types/v1beta1/firestore_client.d.ts index 9402af1da..9a1213250 100644 --- a/types/v1beta1/firestore_client.d.ts +++ b/types/v1beta1/firestore_client.d.ts @@ -28,20 +28,12 @@ import * as protos from '../protos/firestore_v1beta1_proto_api'; /** * The Cloud Firestore service. * - * This service exposes several types of comparable timestamps: - * - * * `create_time` - The time at which a document was created. Changes only - * when a document is deleted, then re-created. Increases in a strict - * monotonic fashion. - * * `update_time` - The time at which a document was last updated. Changes - * every time a document is modified. Does not change when a write results - * in no modifications. Increases in a strict monotonic fashion. - * * `read_time` - The time at which a particular state was observed. Used - * to denote a consistent snapshot of the database or the time at which a - * Document was observed to not exist. - * * `commit_time` - The time at which the writes in a transaction were - * committed. Any read with an equal or greater `read_time` is guaranteed - * to see the effects of the transaction. + * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL + * document database that simplifies storing, syncing, and querying data for + * your mobile, web, and IoT apps at global scale. Its client libraries provide + * live synchronization and offline support, while its security features and + * integrations with Firebase and Google Cloud Platform (GCP) accelerate + * building truly serverless apps. * @class * @deprecated Use v1/firestore_client instead. * @memberof v1beta1 @@ -161,33 +153,6 @@ export declare class FirestoreClient { {} | null | undefined > ): void; - createDocument( - request: protos.google.firestore.v1beta1.ICreateDocumentRequest, - options?: CallOptions - ): Promise< - [ - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.ICreateDocumentRequest | undefined, - {} | undefined - ] - >; - createDocument( - request: protos.google.firestore.v1beta1.ICreateDocumentRequest, - options: 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?: CallOptions @@ -327,6 +292,60 @@ export declare class FirestoreClient { {} | null | undefined > ): void; + batchWrite( + request: protos.google.firestore.v1beta1.IBatchWriteRequest, + options?: CallOptions + ): Promise< + [ + protos.google.firestore.v1beta1.IBatchWriteResponse, + protos.google.firestore.v1beta1.IBatchWriteRequest | undefined, + {} | undefined + ] + >; + batchWrite( + request: protos.google.firestore.v1beta1.IBatchWriteRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.v1beta1.IBatchWriteResponse, + protos.google.firestore.v1beta1.IBatchWriteRequest | null | undefined, + {} | null | undefined + > + ): void; + batchWrite( + request: protos.google.firestore.v1beta1.IBatchWriteRequest, + callback: Callback< + protos.google.firestore.v1beta1.IBatchWriteResponse, + protos.google.firestore.v1beta1.IBatchWriteRequest | null | undefined, + {} | null | undefined + > + ): void; + createDocument( + request: protos.google.firestore.v1beta1.ICreateDocumentRequest, + options?: CallOptions + ): Promise< + [ + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.ICreateDocumentRequest | undefined, + {} | undefined + ] + >; + createDocument( + request: protos.google.firestore.v1beta1.ICreateDocumentRequest, + options: 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; /** * Gets multiple documents. * @@ -357,7 +376,7 @@ export declare class FirestoreClient { * stream. * @param {google.protobuf.Timestamp} request.readTime * 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] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} @@ -397,7 +416,7 @@ export declare class FirestoreClient { * stream. * @param {google.protobuf.Timestamp} request.readTime * 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] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Stream} @@ -510,7 +529,7 @@ export declare class FirestoreClient { * 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. + * 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 @@ -566,7 +585,7 @@ export declare class FirestoreClient { * 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. + * 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 @@ -595,6 +614,165 @@ export declare class FirestoreClient { request?: protos.google.firestore.v1beta1.IListDocumentsRequest, options?: CallOptions ): AsyncIterable; + partitionQuery( + request: protos.google.firestore.v1beta1.IPartitionQueryRequest, + options?: CallOptions + ): Promise< + [ + protos.google.firestore.v1beta1.ICursor[], + protos.google.firestore.v1beta1.IPartitionQueryRequest | null, + protos.google.firestore.v1beta1.IPartitionQueryResponse + ] + >; + partitionQuery( + request: protos.google.firestore.v1beta1.IPartitionQueryRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.firestore.v1beta1.IPartitionQueryRequest, + | protos.google.firestore.v1beta1.IPartitionQueryResponse + | null + | undefined, + protos.google.firestore.v1beta1.ICursor + > + ): void; + partitionQuery( + request: protos.google.firestore.v1beta1.IPartitionQueryRequest, + callback: PaginationCallback< + protos.google.firestore.v1beta1.IPartitionQueryRequest, + | protos.google.firestore.v1beta1.IPartitionQueryResponse + | null + | undefined, + protos.google.firestore.v1beta1.ICursor + > + ): void; + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @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.v1beta1.StructuredQuery} request.structuredQuery + * A structured query. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other 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 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.v1beta1.Cursor} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `partitionQueryAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + partitionQueryStream( + request?: protos.google.firestore.v1beta1.IPartitionQueryRequest, + options?: CallOptions + ): Transform; + /** + * Equivalent to `partitionQuery`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements 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.v1beta1.StructuredQuery} request.structuredQuery + * A structured query. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other 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 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Cursor]{@link google.firestore.v1beta1.Cursor}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.partitionQueryAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + partitionQueryAsync( + request?: protos.google.firestore.v1beta1.IPartitionQueryRequest, + options?: CallOptions + ): AsyncIterable; listCollectionIds( request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, options?: CallOptions From 6f82615311f80102f7fe9b86035f4330e642ebfc Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 14 Apr 2021 23:08:04 +0200 Subject: [PATCH 275/337] chore(deps): update dependency @types/sinon to v10 (#1474) [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@types/sinon](https://togithub.com/DefinitelyTyped/DefinitelyTyped) | [`^9.0.0` -> `^10.0.0`](https://renovatebot.com/diffs/npm/@types%2fsinon/9.0.11/10.0.0) | [![age](https://badges.renovateapi.com/packages/npm/@types%2fsinon/10.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@types%2fsinon/10.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@types%2fsinon/10.0.0/compatibility-slim/9.0.11)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@types%2fsinon/10.0.0/confidence-slim/9.0.11)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration :date: **Schedule**: "after 9am and before 3pm" (UTC). :vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied. :recycle: **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. :no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/nodejs-firestore). --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7b1155b53..ffd57bea6 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "@types/extend": "^3.0.0", "@types/mocha": "^7.0.0", "@types/node": "^12.12.17", - "@types/sinon": "^9.0.0", + "@types/sinon": "^10.0.0", "@types/through2": "^2.0.34", "c8": "^7.0.0", "chai": "^4.1.2", From 4845d1a81a40fd059b6e06a051074135ccdb1969 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Thu, 15 Apr 2021 11:18:04 -0500 Subject: [PATCH 276/337] chore: fix synth.py scriptc (#1476) --- synth.metadata | 54 +------------------------------------------------- synth.py | 2 +- 2 files changed, 2 insertions(+), 54 deletions(-) diff --git a/synth.metadata b/synth.metadata index 549bdc5c5..f3e833a76 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,55 +1,3 @@ { - "sources": [ - { - "git": { - "name": ".", - "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "c7d67fb749aaf76050c08d29b4c6fca28ec9f5ce" - } - }, - { - "git": { - "name": "googleapis", - "remote": "https://github.com/googleapis/googleapis.git", - "sha": "c5435cb4ae272fc2ed9e059c3d035c09c8fd1273", - "internalRef": "360469636" - } - }, - { - "git": { - "name": "synthtool", - "remote": "https://github.com/googleapis/synthtool.git", - "sha": "21da7d9fa02f6916d9f87cf4072b3547b5c72eb5" - } - } - ], - "destinations": [ - { - "client": { - "source": "googleapis", - "apiName": "firestore-admin", - "apiVersion": "v1", - "language": "nodejs", - "generator": "bazel" - } - }, - { - "client": { - "source": "googleapis", - "apiName": "firestore", - "apiVersion": "v1beta1", - "language": "nodejs", - "generator": "bazel" - } - }, - { - "client": { - "source": "googleapis", - "apiName": "firestore", - "apiVersion": "v1", - "language": "nodejs", - "generator": "bazel" - } - } - ] + "updateTime": "2021-04-15T15:12:20.509557Z" } \ No newline at end of file diff --git a/synth.py b/synth.py index dfe589f36..2dc885617 100644 --- a/synth.py +++ b/synth.py @@ -158,6 +158,7 @@ # Remove auto-generated packaging tests os.system('rm -rf dev/system-test/fixtures dev/system-test/install.ts') +node.install() os.chdir("dev") node.compile_protos() os.chdir("protos") @@ -165,7 +166,6 @@ os.unlink('protos.d.ts') subprocess.run('./update.sh', shell=True) os.chdir("../../") -node.install() # Copy types into types/ os.system("cp build/src/v1/firestore*.d.ts types/v1") From c2e01646401f72520a4775a1f678634667225e6d Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 20 Apr 2021 14:04:06 -0500 Subject: [PATCH 277/337] chore: release 4.10.0 (#1473) --- CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9efb23765..5d734030b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [4.10.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.9...v4.10.0) (2021-04-15) + + +### Features + +* add buffering layer to BulkWriter ([#1470](https://www.github.com/googleapis/nodejs-firestore/issues/1470)) ([9cc9548](https://www.github.com/googleapis/nodejs-firestore/commit/9cc954849c74199f01e52b24fc7ba045d5b56be4)) + + +### Bug Fixes + +* use BigInt when calculating nanos in Timestamp.fromMillis() ([#1468](https://www.github.com/googleapis/nodejs-firestore/issues/1468)) ([cf1949f](https://www.github.com/googleapis/nodejs-firestore/commit/cf1949f99f840d1e34edfa31a223418abdf48372)) + ### [4.9.9](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.8...v4.9.9) (2021-04-07) diff --git a/package.json b/package.json index ffd57bea6..e6669a252 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.9.9", + "version": "4.10.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index e6f314a6e..8fd0e7e17 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.9.9" + "@google-cloud/firestore": "^4.10.0" }, "devDependencies": { "chai": "^4.2.0", From d7a9f44d031f63f8eb2c9afa4af6da2fc7190f28 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 27 Apr 2021 08:23:43 -0700 Subject: [PATCH 278/337] changes without context (#1485) autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. --- .github/workflows/ci.yaml | 2 +- synth.metadata | 54 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 891c92531..3df11de40 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,7 +1,7 @@ on: push: branches: - - master + - $default-branch pull_request: name: ci jobs: diff --git a/synth.metadata b/synth.metadata index f3e833a76..6d5194e64 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,3 +1,55 @@ { - "updateTime": "2021-04-15T15:12:20.509557Z" + "sources": [ + { + "git": { + "name": ".", + "remote": "https://github.com/googleapis/nodejs-firestore.git", + "sha": "c2e01646401f72520a4775a1f678634667225e6d" + } + }, + { + "git": { + "name": "googleapis", + "remote": "https://github.com/googleapis/googleapis.git", + "sha": "e7d77d65f0e05ce584c1a824c7ecab53b411498b", + "internalRef": "370589666" + } + }, + { + "git": { + "name": "synthtool", + "remote": "https://github.com/googleapis/synthtool.git", + "sha": "6244244abd0da5ef750e3bbb63fa22ec6803b4db" + } + } + ], + "destinations": [ + { + "client": { + "source": "googleapis", + "apiName": "firestore-admin", + "apiVersion": "v1", + "language": "nodejs", + "generator": "bazel" + } + }, + { + "client": { + "source": "googleapis", + "apiName": "firestore", + "apiVersion": "v1beta1", + "language": "nodejs", + "generator": "bazel" + } + }, + { + "client": { + "source": "googleapis", + "apiName": "firestore", + "apiVersion": "v1", + "language": "nodejs", + "generator": "bazel" + } + } + ] } \ No newline at end of file From 3ed1929a06b4c019bbb0b1db3e1abcd62ee668d2 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 28 Apr 2021 11:00:22 -0600 Subject: [PATCH 279/337] fix: type of QuerySnapshot.docChanges() should be generic (#1484) --- types/firestore.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 9181c4fde..91ec3cc7a 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -1464,7 +1464,7 @@ declare namespace FirebaseFirestore { * this is the first snapshot, all documents will be in the list as added * changes. */ - docChanges(): DocumentChange[]; + docChanges(): DocumentChange[]; /** * Enumerates all of the documents in the QuerySnapshot. From 69a9b972f5b09a3842ea80fda187e15996f8cd27 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 28 Apr 2021 11:18:53 -0600 Subject: [PATCH 280/337] chore: release 4.10.1 (#1489) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d734030b..856233f98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.10.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.10.0...v4.10.1) (2021-04-28) + + +### Bug Fixes + +* type of QuerySnapshot.docChanges() should be generic ([#1484](https://www.github.com/googleapis/nodejs-firestore/issues/1484)) ([3ed1929](https://www.github.com/googleapis/nodejs-firestore/commit/3ed1929a06b4c019bbb0b1db3e1abcd62ee668d2)) + ## [4.10.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.9.9...v4.10.0) (2021-04-15) diff --git a/package.json b/package.json index e6669a252..8f4381613 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.10.0", + "version": "4.10.1", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 8fd0e7e17..e4c60b23a 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.10.0" + "@google-cloud/firestore": "^4.10.1" }, "devDependencies": { "chai": "^4.2.0", From 71e4ae4a68a9236566e1e570197cfbda33009eba Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 28 Apr 2021 11:10:02 -0700 Subject: [PATCH 281/337] chore: fix copyright statements (#1487) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/68331f79-ab43-4c98-8229-61ee7eab39f7/targets - [ ] To automatically regenerate this PR, check this box. (May take up to 24 hours.) --- dev/protos/google/api/annotations.proto | 2 +- dev/protos/google/api/client.proto | 2 +- dev/protos/google/api/field_behavior.proto | 2 +- dev/protos/google/api/http.proto | 2 +- dev/protos/google/api/resource.proto | 2 +- synth.metadata | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dev/protos/google/api/annotations.proto b/dev/protos/google/api/annotations.proto index 85c361b47..efdab3db6 100644 --- a/dev/protos/google/api/annotations.proto +++ b/dev/protos/google/api/annotations.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2015, Google Inc. +// Copyright 2015 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/dev/protos/google/api/client.proto b/dev/protos/google/api/client.proto index 2102623d3..3b3fd0c40 100644 --- a/dev/protos/google/api/client.proto +++ b/dev/protos/google/api/client.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2018 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/dev/protos/google/api/field_behavior.proto b/dev/protos/google/api/field_behavior.proto index 614b31a00..ee836185c 100644 --- a/dev/protos/google/api/field_behavior.proto +++ b/dev/protos/google/api/field_behavior.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2018 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/dev/protos/google/api/http.proto b/dev/protos/google/api/http.proto index 69460cf79..113fa936a 100644 --- a/dev/protos/google/api/http.proto +++ b/dev/protos/google/api/http.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2015 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/dev/protos/google/api/resource.proto b/dev/protos/google/api/resource.proto index fd9ee66de..2dfff1590 100644 --- a/dev/protos/google/api/resource.proto +++ b/dev/protos/google/api/resource.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2018 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/synth.metadata b/synth.metadata index 6d5194e64..8a616b995 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "c2e01646401f72520a4775a1f678634667225e6d" + "sha": "d7a9f44d031f63f8eb2c9afa4af6da2fc7190f28" } }, { From 4ac8e7ef37a40d99ecaae4ce502c276786416495 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 28 Apr 2021 17:10:05 -0700 Subject: [PATCH 282/337] build: add generated-files bot config (#1488) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/68331f79-ab43-4c98-8229-61ee7eab39f7/targets - [ ] To automatically regenerate this PR, check this box. (May take up to 24 hours.) Source-Link: https://github.com/googleapis/synthtool/commit/e6f3d54be015a394b6ab5a25903ec09062a2b424 Source-Link: https://github.com/googleapis/synthtool/commit/04573fd73f56791c659832aa84d35a4ec860d6f7 --- .github/generated-files-bot.yml | 13 +++++++++++++ .github/workflows/ci.yaml | 2 +- synth.metadata | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .github/generated-files-bot.yml diff --git a/.github/generated-files-bot.yml b/.github/generated-files-bot.yml new file mode 100644 index 000000000..1b3ef1c78 --- /dev/null +++ b/.github/generated-files-bot.yml @@ -0,0 +1,13 @@ +generatedFiles: +- path: '.kokoro/**' + message: '`.kokoro` files are templated and should be updated in [`synthtool`](https://github.com/googleapis/synthtool)' +- path: '.github/CODEOWNERS' + message: 'CODEOWNERS should instead be modified via the `codeowner_team` property in .repo-metadata.json' +- path: '.github/workflows/**' + message: '`.github/workflows` (GitHub Actions) should be updated in [`synthtool`](https://github.com/googleapis/synthtool)' +- path: '.github/generated-files-bot.+(yml|yaml)' + message: '`.github/generated-files-bot.(yml|yaml)` should be updated in [`synthtool`](https://github.com/googleapis/synthtool)' +- path: 'README.md' + message: '`README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/master/.readme-partials.yaml' +- path: 'samples/README.md' + message: '`samples/README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/master/.readme-partials.yaml' diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3df11de40..891c92531 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,7 +1,7 @@ on: push: branches: - - $default-branch + - master pull_request: name: ci jobs: diff --git a/synth.metadata b/synth.metadata index 8a616b995..73df84b49 100644 --- a/synth.metadata +++ b/synth.metadata @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "6244244abd0da5ef750e3bbb63fa22ec6803b4db" + "sha": "e6f3d54be015a394b6ab5a25903ec09062a2b424" } } ], From 09f7095b3bdfa2d6994890818331d73f04775165 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 29 Apr 2021 09:07:57 -0700 Subject: [PATCH 283/337] changes without context (#1491) autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. --- dev/protos/firestore_admin_v1_proto_api.d.ts | 22 ++-- dev/protos/firestore_admin_v1_proto_api.js | 44 ++++---- dev/protos/firestore_v1_proto_api.d.ts | 52 +++++----- dev/protos/firestore_v1_proto_api.js | 104 +++++++++---------- dev/protos/firestore_v1beta1_proto_api.d.ts | 52 +++++----- dev/protos/firestore_v1beta1_proto_api.js | 104 +++++++++---------- synth.metadata | 2 +- 7 files changed, 190 insertions(+), 190 deletions(-) diff --git a/dev/protos/firestore_admin_v1_proto_api.d.ts b/dev/protos/firestore_admin_v1_proto_api.d.ts index 37ad40a47..289e6b6d9 100644 --- a/dev/protos/firestore_admin_v1_proto_api.d.ts +++ b/dev/protos/firestore_admin_v1_proto_api.d.ts @@ -962,10 +962,10 @@ export namespace google { public fieldPath: string; /** IndexField order. */ - public order: google.firestore.admin.v1.Index.IndexField.Order; + public order?: (google.firestore.admin.v1.Index.IndexField.Order|null); /** IndexField arrayConfig. */ - public arrayConfig: google.firestore.admin.v1.Index.IndexField.ArrayConfig; + public arrayConfig?: (google.firestore.admin.v1.Index.IndexField.ArrayConfig|null); /** IndexField valueMode. */ public valueMode?: ("order"|"arrayConfig"); @@ -1586,19 +1586,19 @@ export namespace google { constructor(properties?: google.api.IHttpRule); /** HttpRule get. */ - public get: string; + public get?: (string|null); /** HttpRule put. */ - public put: string; + public put?: (string|null); /** HttpRule post. */ - public post: string; + public post?: (string|null); /** HttpRule delete. */ - public delete: string; + public delete?: (string|null); /** HttpRule patch. */ - public patch: string; + public patch?: (string|null); /** HttpRule custom. */ public custom?: (google.api.ICustomHttpPattern|null); @@ -3679,16 +3679,16 @@ export namespace google { constructor(properties?: google.protobuf.IValue); /** Value nullValue. */ - public nullValue: google.protobuf.NullValue; + public nullValue?: (google.protobuf.NullValue|null); /** Value numberValue. */ - public numberValue: number; + public numberValue?: (number|null); /** Value stringValue. */ - public stringValue: string; + public stringValue?: (string|null); /** Value boolValue. */ - public boolValue: boolean; + public boolValue?: (boolean|null); /** Value structValue. */ public structValue?: (google.protobuf.IStruct|null); diff --git a/dev/protos/firestore_admin_v1_proto_api.js b/dev/protos/firestore_admin_v1_proto_api.js index eebf6ce7d..840a3bb5a 100644 --- a/dev/protos/firestore_admin_v1_proto_api.js +++ b/dev/protos/firestore_admin_v1_proto_api.js @@ -1996,19 +1996,19 @@ /** * IndexField order. - * @member {google.firestore.admin.v1.Index.IndexField.Order} order + * @member {google.firestore.admin.v1.Index.IndexField.Order|null|undefined} order * @memberof google.firestore.admin.v1.Index.IndexField * @instance */ - IndexField.prototype.order = 0; + IndexField.prototype.order = null; /** * IndexField arrayConfig. - * @member {google.firestore.admin.v1.Index.IndexField.ArrayConfig} arrayConfig + * @member {google.firestore.admin.v1.Index.IndexField.ArrayConfig|null|undefined} arrayConfig * @memberof google.firestore.admin.v1.Index.IndexField * @instance */ - IndexField.prototype.arrayConfig = 0; + IndexField.prototype.arrayConfig = null; // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -3619,43 +3619,43 @@ /** * HttpRule get. - * @member {string} get + * @member {string|null|undefined} get * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.get = ""; + HttpRule.prototype.get = null; /** * HttpRule put. - * @member {string} put + * @member {string|null|undefined} put * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.put = ""; + HttpRule.prototype.put = null; /** * HttpRule post. - * @member {string} post + * @member {string|null|undefined} post * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.post = ""; + HttpRule.prototype.post = null; /** * HttpRule delete. - * @member {string} delete + * @member {string|null|undefined} delete * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype["delete"] = ""; + HttpRule.prototype["delete"] = null; /** * HttpRule patch. - * @member {string} patch + * @member {string|null|undefined} patch * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.patch = ""; + HttpRule.prototype.patch = null; /** * HttpRule custom. @@ -8979,35 +8979,35 @@ /** * Value nullValue. - * @member {google.protobuf.NullValue} nullValue + * @member {google.protobuf.NullValue|null|undefined} nullValue * @memberof google.protobuf.Value * @instance */ - Value.prototype.nullValue = 0; + Value.prototype.nullValue = null; /** * Value numberValue. - * @member {number} numberValue + * @member {number|null|undefined} numberValue * @memberof google.protobuf.Value * @instance */ - Value.prototype.numberValue = 0; + Value.prototype.numberValue = null; /** * Value stringValue. - * @member {string} stringValue + * @member {string|null|undefined} stringValue * @memberof google.protobuf.Value * @instance */ - Value.prototype.stringValue = ""; + Value.prototype.stringValue = null; /** * Value boolValue. - * @member {boolean} boolValue + * @member {boolean|null|undefined} boolValue * @memberof google.protobuf.Value * @instance */ - Value.prototype.boolValue = false; + Value.prototype.boolValue = null; /** * Value structValue. diff --git a/dev/protos/firestore_v1_proto_api.d.ts b/dev/protos/firestore_v1_proto_api.d.ts index 8ff113db2..ea61f2467 100644 --- a/dev/protos/firestore_v1_proto_api.d.ts +++ b/dev/protos/firestore_v1_proto_api.d.ts @@ -2056,16 +2056,16 @@ export namespace google { constructor(properties?: google.protobuf.IValue); /** Value nullValue. */ - public nullValue: google.protobuf.NullValue; + public nullValue?: (google.protobuf.NullValue|null); /** Value numberValue. */ - public numberValue: number; + public numberValue?: (number|null); /** Value stringValue. */ - public stringValue: string; + public stringValue?: (string|null); /** Value boolValue. */ - public boolValue: boolean; + public boolValue?: (boolean|null); /** Value structValue. */ public structValue?: (google.protobuf.IStruct|null); @@ -2750,7 +2750,7 @@ export namespace google { constructor(properties?: google.firestore.v1.IPrecondition); /** Precondition exists. */ - public exists: boolean; + public exists?: (boolean|null); /** Precondition updateTime. */ public updateTime?: (google.protobuf.ITimestamp|null); @@ -3024,28 +3024,28 @@ export namespace google { constructor(properties?: google.firestore.v1.IValue); /** Value nullValue. */ - public nullValue: google.protobuf.NullValue; + public nullValue?: (google.protobuf.NullValue|null); /** Value booleanValue. */ - public booleanValue: boolean; + public booleanValue?: (boolean|null); /** Value integerValue. */ - public integerValue: (number|string); + public integerValue?: (number|string|null); /** Value doubleValue. */ - public doubleValue: number; + public doubleValue?: (number|null); /** Value timestampValue. */ public timestampValue?: (google.protobuf.ITimestamp|null); /** Value stringValue. */ - public stringValue: string; + public stringValue?: (string|null); /** Value bytesValue. */ - public bytesValue: Uint8Array; + public bytesValue?: (Uint8Array|null); /** Value referenceValue. */ - public referenceValue: string; + public referenceValue?: (string|null); /** Value geoPointValue. */ public geoPointValue?: (google.type.ILatLng|null); @@ -3525,7 +3525,7 @@ export namespace google { public mask?: (google.firestore.v1.IDocumentMask|null); /** GetDocumentRequest transaction. */ - public transaction: Uint8Array; + public transaction?: (Uint8Array|null); /** GetDocumentRequest readTime. */ public readTime?: (google.protobuf.ITimestamp|null); @@ -3614,7 +3614,7 @@ export namespace google { public mask?: (google.firestore.v1.IDocumentMask|null); /** ListDocumentsRequest transaction. */ - public transaction: Uint8Array; + public transaction?: (Uint8Array|null); /** ListDocumentsRequest readTime. */ public readTime?: (google.protobuf.ITimestamp|null); @@ -3906,7 +3906,7 @@ export namespace google { public mask?: (google.firestore.v1.IDocumentMask|null); /** BatchGetDocumentsRequest transaction. */ - public transaction: Uint8Array; + public transaction?: (Uint8Array|null); /** BatchGetDocumentsRequest newTransaction. */ public newTransaction?: (google.firestore.v1.ITransactionOptions|null); @@ -3968,7 +3968,7 @@ export namespace google { public found?: (google.firestore.v1.IDocument|null); /** BatchGetDocumentsResponse missing. */ - public missing: string; + public missing?: (string|null); /** BatchGetDocumentsResponse transaction. */ public transaction: Uint8Array; @@ -4271,7 +4271,7 @@ export namespace google { public structuredQuery?: (google.firestore.v1.IStructuredQuery|null); /** RunQueryRequest transaction. */ - public transaction: Uint8Array; + public transaction?: (Uint8Array|null); /** RunQueryRequest newTransaction. */ public newTransaction?: (google.firestore.v1.ITransactionOptions|null); @@ -4637,7 +4637,7 @@ export namespace google { public addTarget?: (google.firestore.v1.ITarget|null); /** ListenRequest removeTarget. */ - public removeTarget: number; + public removeTarget?: (number|null); /** ListenRequest labels. */ public labels: { [k: string]: string }; @@ -4773,7 +4773,7 @@ export namespace google { public documents?: (google.firestore.v1.Target.IDocumentsTarget|null); /** Target resumeToken. */ - public resumeToken: Uint8Array; + public resumeToken?: (Uint8Array|null); /** Target readTime. */ public readTime?: (google.protobuf.ITimestamp|null); @@ -5753,7 +5753,7 @@ export namespace google { public update?: (google.firestore.v1.IDocument|null); /** Write delete. */ - public delete: string; + public delete?: (string|null); /** Write transform. */ public transform?: (google.firestore.v1.IDocumentTransform|null); @@ -5879,7 +5879,7 @@ export namespace google { public fieldPath: string; /** FieldTransform setToServerValue. */ - public setToServerValue: google.firestore.v1.DocumentTransform.FieldTransform.ServerValue; + public setToServerValue?: (google.firestore.v1.DocumentTransform.FieldTransform.ServerValue|null); /** FieldTransform increment. */ public increment?: (google.firestore.v1.IValue|null); @@ -6269,19 +6269,19 @@ export namespace google { constructor(properties?: google.api.IHttpRule); /** HttpRule get. */ - public get: string; + public get?: (string|null); /** HttpRule put. */ - public put: string; + public put?: (string|null); /** HttpRule post. */ - public post: string; + public post?: (string|null); /** HttpRule delete. */ - public delete: string; + public delete?: (string|null); /** HttpRule patch. */ - public patch: string; + public patch?: (string|null); /** HttpRule custom. */ public custom?: (google.api.ICustomHttpPattern|null); diff --git a/dev/protos/firestore_v1_proto_api.js b/dev/protos/firestore_v1_proto_api.js index a43075136..499af0eac 100644 --- a/dev/protos/firestore_v1_proto_api.js +++ b/dev/protos/firestore_v1_proto_api.js @@ -5209,35 +5209,35 @@ /** * Value nullValue. - * @member {google.protobuf.NullValue} nullValue + * @member {google.protobuf.NullValue|null|undefined} nullValue * @memberof google.protobuf.Value * @instance */ - Value.prototype.nullValue = 0; + Value.prototype.nullValue = null; /** * Value numberValue. - * @member {number} numberValue + * @member {number|null|undefined} numberValue * @memberof google.protobuf.Value * @instance */ - Value.prototype.numberValue = 0; + Value.prototype.numberValue = null; /** * Value stringValue. - * @member {string} stringValue + * @member {string|null|undefined} stringValue * @memberof google.protobuf.Value * @instance */ - Value.prototype.stringValue = ""; + Value.prototype.stringValue = null; /** * Value boolValue. - * @member {boolean} boolValue + * @member {boolean|null|undefined} boolValue * @memberof google.protobuf.Value * @instance */ - Value.prototype.boolValue = false; + Value.prototype.boolValue = null; /** * Value structValue. @@ -6772,11 +6772,11 @@ /** * Precondition exists. - * @member {boolean} exists + * @member {boolean|null|undefined} exists * @memberof google.firestore.v1.Precondition * @instance */ - Precondition.prototype.exists = false; + Precondition.prototype.exists = null; /** * Precondition updateTime. @@ -7357,35 +7357,35 @@ /** * Value nullValue. - * @member {google.protobuf.NullValue} nullValue + * @member {google.protobuf.NullValue|null|undefined} nullValue * @memberof google.firestore.v1.Value * @instance */ - Value.prototype.nullValue = 0; + Value.prototype.nullValue = null; /** * Value booleanValue. - * @member {boolean} booleanValue + * @member {boolean|null|undefined} booleanValue * @memberof google.firestore.v1.Value * @instance */ - Value.prototype.booleanValue = false; + Value.prototype.booleanValue = null; /** * Value integerValue. - * @member {number|string} integerValue + * @member {number|string|null|undefined} integerValue * @memberof google.firestore.v1.Value * @instance */ - Value.prototype.integerValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + Value.prototype.integerValue = null; /** * Value doubleValue. - * @member {number} doubleValue + * @member {number|null|undefined} doubleValue * @memberof google.firestore.v1.Value * @instance */ - Value.prototype.doubleValue = 0; + Value.prototype.doubleValue = null; /** * Value timestampValue. @@ -7397,27 +7397,27 @@ /** * Value stringValue. - * @member {string} stringValue + * @member {string|null|undefined} stringValue * @memberof google.firestore.v1.Value * @instance */ - Value.prototype.stringValue = ""; + Value.prototype.stringValue = null; /** * Value bytesValue. - * @member {Uint8Array} bytesValue + * @member {Uint8Array|null|undefined} bytesValue * @memberof google.firestore.v1.Value * @instance */ - Value.prototype.bytesValue = $util.newBuffer([]); + Value.prototype.bytesValue = null; /** * Value referenceValue. - * @member {string} referenceValue + * @member {string|null|undefined} referenceValue * @memberof google.firestore.v1.Value * @instance */ - Value.prototype.referenceValue = ""; + Value.prototype.referenceValue = null; /** * Value geoPointValue. @@ -8360,11 +8360,11 @@ /** * GetDocumentRequest transaction. - * @member {Uint8Array} transaction + * @member {Uint8Array|null|undefined} transaction * @memberof google.firestore.v1.GetDocumentRequest * @instance */ - GetDocumentRequest.prototype.transaction = $util.newBuffer([]); + GetDocumentRequest.prototype.transaction = null; /** * GetDocumentRequest readTime. @@ -8550,11 +8550,11 @@ /** * ListDocumentsRequest transaction. - * @member {Uint8Array} transaction + * @member {Uint8Array|null|undefined} transaction * @memberof google.firestore.v1.ListDocumentsRequest * @instance */ - ListDocumentsRequest.prototype.transaction = $util.newBuffer([]); + ListDocumentsRequest.prototype.transaction = null; /** * ListDocumentsRequest readTime. @@ -9242,11 +9242,11 @@ /** * BatchGetDocumentsRequest transaction. - * @member {Uint8Array} transaction + * @member {Uint8Array|null|undefined} transaction * @memberof google.firestore.v1.BatchGetDocumentsRequest * @instance */ - BatchGetDocumentsRequest.prototype.transaction = $util.newBuffer([]); + BatchGetDocumentsRequest.prototype.transaction = null; /** * BatchGetDocumentsRequest newTransaction. @@ -9419,11 +9419,11 @@ /** * BatchGetDocumentsResponse missing. - * @member {string} missing + * @member {string|null|undefined} missing * @memberof google.firestore.v1.BatchGetDocumentsResponse * @instance */ - BatchGetDocumentsResponse.prototype.missing = ""; + BatchGetDocumentsResponse.prototype.missing = null; /** * BatchGetDocumentsResponse transaction. @@ -10134,11 +10134,11 @@ /** * RunQueryRequest transaction. - * @member {Uint8Array} transaction + * @member {Uint8Array|null|undefined} transaction * @memberof google.firestore.v1.RunQueryRequest * @instance */ - RunQueryRequest.prototype.transaction = $util.newBuffer([]); + RunQueryRequest.prototype.transaction = null; /** * RunQueryRequest newTransaction. @@ -11066,11 +11066,11 @@ /** * ListenRequest removeTarget. - * @member {number} removeTarget + * @member {number|null|undefined} removeTarget * @memberof google.firestore.v1.ListenRequest * @instance */ - ListenRequest.prototype.removeTarget = 0; + ListenRequest.prototype.removeTarget = null; /** * ListenRequest labels. @@ -11401,11 +11401,11 @@ /** * Target resumeToken. - * @member {Uint8Array} resumeToken + * @member {Uint8Array|null|undefined} resumeToken * @memberof google.firestore.v1.Target * @instance */ - Target.prototype.resumeToken = $util.newBuffer([]); + Target.prototype.resumeToken = null; /** * Target readTime. @@ -13841,11 +13841,11 @@ /** * Write delete. - * @member {string} delete + * @member {string|null|undefined} delete * @memberof google.firestore.v1.Write * @instance */ - Write.prototype["delete"] = ""; + Write.prototype["delete"] = null; /** * Write transform. @@ -14147,11 +14147,11 @@ /** * FieldTransform setToServerValue. - * @member {google.firestore.v1.DocumentTransform.FieldTransform.ServerValue} setToServerValue + * @member {google.firestore.v1.DocumentTransform.FieldTransform.ServerValue|null|undefined} setToServerValue * @memberof google.firestore.v1.DocumentTransform.FieldTransform * @instance */ - FieldTransform.prototype.setToServerValue = 0; + FieldTransform.prototype.setToServerValue = null; /** * FieldTransform increment. @@ -15080,43 +15080,43 @@ /** * HttpRule get. - * @member {string} get + * @member {string|null|undefined} get * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.get = ""; + HttpRule.prototype.get = null; /** * HttpRule put. - * @member {string} put + * @member {string|null|undefined} put * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.put = ""; + HttpRule.prototype.put = null; /** * HttpRule post. - * @member {string} post + * @member {string|null|undefined} post * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.post = ""; + HttpRule.prototype.post = null; /** * HttpRule delete. - * @member {string} delete + * @member {string|null|undefined} delete * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype["delete"] = ""; + HttpRule.prototype["delete"] = null; /** * HttpRule patch. - * @member {string} patch + * @member {string|null|undefined} patch * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.patch = ""; + HttpRule.prototype.patch = null; /** * HttpRule custom. diff --git a/dev/protos/firestore_v1beta1_proto_api.d.ts b/dev/protos/firestore_v1beta1_proto_api.d.ts index 58cea05f6..79b6a4658 100644 --- a/dev/protos/firestore_v1beta1_proto_api.d.ts +++ b/dev/protos/firestore_v1beta1_proto_api.d.ts @@ -1750,16 +1750,16 @@ export namespace google { constructor(properties?: google.protobuf.IValue); /** Value nullValue. */ - public nullValue: google.protobuf.NullValue; + public nullValue?: (google.protobuf.NullValue|null); /** Value numberValue. */ - public numberValue: number; + public numberValue?: (number|null); /** Value stringValue. */ - public stringValue: string; + public stringValue?: (string|null); /** Value boolValue. */ - public boolValue: boolean; + public boolValue?: (boolean|null); /** Value structValue. */ public structValue?: (google.protobuf.IStruct|null); @@ -2444,7 +2444,7 @@ export namespace google { constructor(properties?: google.firestore.v1beta1.IPrecondition); /** Precondition exists. */ - public exists: boolean; + public exists?: (boolean|null); /** Precondition updateTime. */ public updateTime?: (google.protobuf.ITimestamp|null); @@ -2718,28 +2718,28 @@ export namespace google { constructor(properties?: google.firestore.v1beta1.IValue); /** Value nullValue. */ - public nullValue: google.protobuf.NullValue; + public nullValue?: (google.protobuf.NullValue|null); /** Value booleanValue. */ - public booleanValue: boolean; + public booleanValue?: (boolean|null); /** Value integerValue. */ - public integerValue: (number|string); + public integerValue?: (number|string|null); /** Value doubleValue. */ - public doubleValue: number; + public doubleValue?: (number|null); /** Value timestampValue. */ public timestampValue?: (google.protobuf.ITimestamp|null); /** Value stringValue. */ - public stringValue: string; + public stringValue?: (string|null); /** Value bytesValue. */ - public bytesValue: Uint8Array; + public bytesValue?: (Uint8Array|null); /** Value referenceValue. */ - public referenceValue: string; + public referenceValue?: (string|null); /** Value geoPointValue. */ public geoPointValue?: (google.type.ILatLng|null); @@ -3219,7 +3219,7 @@ export namespace google { public mask?: (google.firestore.v1beta1.IDocumentMask|null); /** GetDocumentRequest transaction. */ - public transaction: Uint8Array; + public transaction?: (Uint8Array|null); /** GetDocumentRequest readTime. */ public readTime?: (google.protobuf.ITimestamp|null); @@ -3308,7 +3308,7 @@ export namespace google { public mask?: (google.firestore.v1beta1.IDocumentMask|null); /** ListDocumentsRequest transaction. */ - public transaction: Uint8Array; + public transaction?: (Uint8Array|null); /** ListDocumentsRequest readTime. */ public readTime?: (google.protobuf.ITimestamp|null); @@ -3600,7 +3600,7 @@ export namespace google { public mask?: (google.firestore.v1beta1.IDocumentMask|null); /** BatchGetDocumentsRequest transaction. */ - public transaction: Uint8Array; + public transaction?: (Uint8Array|null); /** BatchGetDocumentsRequest newTransaction. */ public newTransaction?: (google.firestore.v1beta1.ITransactionOptions|null); @@ -3662,7 +3662,7 @@ export namespace google { public found?: (google.firestore.v1beta1.IDocument|null); /** BatchGetDocumentsResponse missing. */ - public missing: string; + public missing?: (string|null); /** BatchGetDocumentsResponse transaction. */ public transaction: Uint8Array; @@ -3965,7 +3965,7 @@ export namespace google { public structuredQuery?: (google.firestore.v1beta1.IStructuredQuery|null); /** RunQueryRequest transaction. */ - public transaction: Uint8Array; + public transaction?: (Uint8Array|null); /** RunQueryRequest newTransaction. */ public newTransaction?: (google.firestore.v1beta1.ITransactionOptions|null); @@ -4331,7 +4331,7 @@ export namespace google { public addTarget?: (google.firestore.v1beta1.ITarget|null); /** ListenRequest removeTarget. */ - public removeTarget: number; + public removeTarget?: (number|null); /** ListenRequest labels. */ public labels: { [k: string]: string }; @@ -4467,7 +4467,7 @@ export namespace google { public documents?: (google.firestore.v1beta1.Target.IDocumentsTarget|null); /** Target resumeToken. */ - public resumeToken: Uint8Array; + public resumeToken?: (Uint8Array|null); /** Target readTime. */ public readTime?: (google.protobuf.ITimestamp|null); @@ -5447,7 +5447,7 @@ export namespace google { public update?: (google.firestore.v1beta1.IDocument|null); /** Write delete. */ - public delete: string; + public delete?: (string|null); /** Write transform. */ public transform?: (google.firestore.v1beta1.IDocumentTransform|null); @@ -5573,7 +5573,7 @@ export namespace google { public fieldPath: string; /** FieldTransform setToServerValue. */ - public setToServerValue: google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue; + public setToServerValue?: (google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue|null); /** FieldTransform increment. */ public increment?: (google.firestore.v1beta1.IValue|null); @@ -5963,19 +5963,19 @@ export namespace google { constructor(properties?: google.api.IHttpRule); /** HttpRule get. */ - public get: string; + public get?: (string|null); /** HttpRule put. */ - public put: string; + public put?: (string|null); /** HttpRule post. */ - public post: string; + public post?: (string|null); /** HttpRule delete. */ - public delete: string; + public delete?: (string|null); /** HttpRule patch. */ - public patch: string; + public patch?: (string|null); /** HttpRule custom. */ public custom?: (google.api.ICustomHttpPattern|null); diff --git a/dev/protos/firestore_v1beta1_proto_api.js b/dev/protos/firestore_v1beta1_proto_api.js index 2f966cdbc..4d5237bc9 100644 --- a/dev/protos/firestore_v1beta1_proto_api.js +++ b/dev/protos/firestore_v1beta1_proto_api.js @@ -4472,35 +4472,35 @@ /** * Value nullValue. - * @member {google.protobuf.NullValue} nullValue + * @member {google.protobuf.NullValue|null|undefined} nullValue * @memberof google.protobuf.Value * @instance */ - Value.prototype.nullValue = 0; + Value.prototype.nullValue = null; /** * Value numberValue. - * @member {number} numberValue + * @member {number|null|undefined} numberValue * @memberof google.protobuf.Value * @instance */ - Value.prototype.numberValue = 0; + Value.prototype.numberValue = null; /** * Value stringValue. - * @member {string} stringValue + * @member {string|null|undefined} stringValue * @memberof google.protobuf.Value * @instance */ - Value.prototype.stringValue = ""; + Value.prototype.stringValue = null; /** * Value boolValue. - * @member {boolean} boolValue + * @member {boolean|null|undefined} boolValue * @memberof google.protobuf.Value * @instance */ - Value.prototype.boolValue = false; + Value.prototype.boolValue = null; /** * Value structValue. @@ -6035,11 +6035,11 @@ /** * Precondition exists. - * @member {boolean} exists + * @member {boolean|null|undefined} exists * @memberof google.firestore.v1beta1.Precondition * @instance */ - Precondition.prototype.exists = false; + Precondition.prototype.exists = null; /** * Precondition updateTime. @@ -6620,35 +6620,35 @@ /** * Value nullValue. - * @member {google.protobuf.NullValue} nullValue + * @member {google.protobuf.NullValue|null|undefined} nullValue * @memberof google.firestore.v1beta1.Value * @instance */ - Value.prototype.nullValue = 0; + Value.prototype.nullValue = null; /** * Value booleanValue. - * @member {boolean} booleanValue + * @member {boolean|null|undefined} booleanValue * @memberof google.firestore.v1beta1.Value * @instance */ - Value.prototype.booleanValue = false; + Value.prototype.booleanValue = null; /** * Value integerValue. - * @member {number|string} integerValue + * @member {number|string|null|undefined} integerValue * @memberof google.firestore.v1beta1.Value * @instance */ - Value.prototype.integerValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + Value.prototype.integerValue = null; /** * Value doubleValue. - * @member {number} doubleValue + * @member {number|null|undefined} doubleValue * @memberof google.firestore.v1beta1.Value * @instance */ - Value.prototype.doubleValue = 0; + Value.prototype.doubleValue = null; /** * Value timestampValue. @@ -6660,27 +6660,27 @@ /** * Value stringValue. - * @member {string} stringValue + * @member {string|null|undefined} stringValue * @memberof google.firestore.v1beta1.Value * @instance */ - Value.prototype.stringValue = ""; + Value.prototype.stringValue = null; /** * Value bytesValue. - * @member {Uint8Array} bytesValue + * @member {Uint8Array|null|undefined} bytesValue * @memberof google.firestore.v1beta1.Value * @instance */ - Value.prototype.bytesValue = $util.newBuffer([]); + Value.prototype.bytesValue = null; /** * Value referenceValue. - * @member {string} referenceValue + * @member {string|null|undefined} referenceValue * @memberof google.firestore.v1beta1.Value * @instance */ - Value.prototype.referenceValue = ""; + Value.prototype.referenceValue = null; /** * Value geoPointValue. @@ -7623,11 +7623,11 @@ /** * GetDocumentRequest transaction. - * @member {Uint8Array} transaction + * @member {Uint8Array|null|undefined} transaction * @memberof google.firestore.v1beta1.GetDocumentRequest * @instance */ - GetDocumentRequest.prototype.transaction = $util.newBuffer([]); + GetDocumentRequest.prototype.transaction = null; /** * GetDocumentRequest readTime. @@ -7813,11 +7813,11 @@ /** * ListDocumentsRequest transaction. - * @member {Uint8Array} transaction + * @member {Uint8Array|null|undefined} transaction * @memberof google.firestore.v1beta1.ListDocumentsRequest * @instance */ - ListDocumentsRequest.prototype.transaction = $util.newBuffer([]); + ListDocumentsRequest.prototype.transaction = null; /** * ListDocumentsRequest readTime. @@ -8505,11 +8505,11 @@ /** * BatchGetDocumentsRequest transaction. - * @member {Uint8Array} transaction + * @member {Uint8Array|null|undefined} transaction * @memberof google.firestore.v1beta1.BatchGetDocumentsRequest * @instance */ - BatchGetDocumentsRequest.prototype.transaction = $util.newBuffer([]); + BatchGetDocumentsRequest.prototype.transaction = null; /** * BatchGetDocumentsRequest newTransaction. @@ -8682,11 +8682,11 @@ /** * BatchGetDocumentsResponse missing. - * @member {string} missing + * @member {string|null|undefined} missing * @memberof google.firestore.v1beta1.BatchGetDocumentsResponse * @instance */ - BatchGetDocumentsResponse.prototype.missing = ""; + BatchGetDocumentsResponse.prototype.missing = null; /** * BatchGetDocumentsResponse transaction. @@ -9397,11 +9397,11 @@ /** * RunQueryRequest transaction. - * @member {Uint8Array} transaction + * @member {Uint8Array|null|undefined} transaction * @memberof google.firestore.v1beta1.RunQueryRequest * @instance */ - RunQueryRequest.prototype.transaction = $util.newBuffer([]); + RunQueryRequest.prototype.transaction = null; /** * RunQueryRequest newTransaction. @@ -10329,11 +10329,11 @@ /** * ListenRequest removeTarget. - * @member {number} removeTarget + * @member {number|null|undefined} removeTarget * @memberof google.firestore.v1beta1.ListenRequest * @instance */ - ListenRequest.prototype.removeTarget = 0; + ListenRequest.prototype.removeTarget = null; /** * ListenRequest labels. @@ -10664,11 +10664,11 @@ /** * Target resumeToken. - * @member {Uint8Array} resumeToken + * @member {Uint8Array|null|undefined} resumeToken * @memberof google.firestore.v1beta1.Target * @instance */ - Target.prototype.resumeToken = $util.newBuffer([]); + Target.prototype.resumeToken = null; /** * Target readTime. @@ -13104,11 +13104,11 @@ /** * Write delete. - * @member {string} delete + * @member {string|null|undefined} delete * @memberof google.firestore.v1beta1.Write * @instance */ - Write.prototype["delete"] = ""; + Write.prototype["delete"] = null; /** * Write transform. @@ -13410,11 +13410,11 @@ /** * FieldTransform setToServerValue. - * @member {google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue} setToServerValue + * @member {google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue|null|undefined} setToServerValue * @memberof google.firestore.v1beta1.DocumentTransform.FieldTransform * @instance */ - FieldTransform.prototype.setToServerValue = 0; + FieldTransform.prototype.setToServerValue = null; /** * FieldTransform increment. @@ -14343,43 +14343,43 @@ /** * HttpRule get. - * @member {string} get + * @member {string|null|undefined} get * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.get = ""; + HttpRule.prototype.get = null; /** * HttpRule put. - * @member {string} put + * @member {string|null|undefined} put * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.put = ""; + HttpRule.prototype.put = null; /** * HttpRule post. - * @member {string} post + * @member {string|null|undefined} post * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.post = ""; + HttpRule.prototype.post = null; /** * HttpRule delete. - * @member {string} delete + * @member {string|null|undefined} delete * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype["delete"] = ""; + HttpRule.prototype["delete"] = null; /** * HttpRule patch. - * @member {string} patch + * @member {string|null|undefined} patch * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.patch = ""; + HttpRule.prototype.patch = null; /** * HttpRule custom. diff --git a/synth.metadata b/synth.metadata index 73df84b49..bbfd285fa 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "d7a9f44d031f63f8eb2c9afa4af6da2fc7190f28" + "sha": "4ac8e7ef37a40d99ecaae4ce502c276786416495" } }, { From 6f1e3040800d0dcc5ed3f9f7cef16fe41804266a Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 5 May 2021 11:06:34 -0500 Subject: [PATCH 284/337] feat: add recursive delete to Firestore class (#1494) --- dev/src/bulk-writer.ts | 2 +- dev/src/index.ts | 120 +++---- dev/src/recursive-delete.ts | 314 ++++++++++++++++++ dev/src/reference.ts | 40 ++- dev/system-test/firestore.ts | 150 +++++---- dev/test/bulk-writer.ts | 132 ++++---- dev/test/query.ts | 60 +++- dev/test/recursive-delete.ts | 603 +++++++++++++++++++++++++++++++++++ types/firestore.d.ts | 40 +++ 9 files changed, 1253 insertions(+), 208 deletions(-) create mode 100644 dev/src/recursive-delete.ts create mode 100644 dev/test/recursive-delete.ts diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 5871af522..72c3b2949 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -765,7 +765,7 @@ export class BulkWriter { * Throws an error if the BulkWriter instance has been closed. * @private */ - private _verifyNotClosed(): void { + _verifyNotClosed(): void { if (this._closing) { throw new Error('BulkWriter has already been closed.'); } diff --git a/dev/src/index.ts b/dev/src/index.ts index c4b6e66b8..8742429a7 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -40,7 +40,7 @@ import { validateResourcePath, } from './path'; import {ClientPool} from './pool'; -import {CollectionReference, Query, QueryOptions} from './reference'; +import {CollectionReference} from './reference'; import {DocumentReference} from './reference'; import {Serializer} from './serializer'; import {Timestamp} from './timestamp'; @@ -76,6 +76,7 @@ const serviceConfig = interfaces['google.firestore.v1.Firestore']; import api = google.firestore.v1; import {CollectionGroup} from './collection-group'; +import {RecursiveDelete} from './recursive-delete'; export { CollectionReference, @@ -141,7 +142,7 @@ const CLOUD_RESOURCE_HEADER = 'google-cloud-resource-prefix'; /*! * The maximum number of times to retry idempotent requests. */ -const MAX_REQUEST_RETRIES = 5; +export const MAX_REQUEST_RETRIES = 5; /*! * The default number of idle GRPC channel to keep. @@ -156,18 +157,6 @@ const DEFAULT_MAX_IDLE_CHANNELS = 1; */ const MAX_CONCURRENT_REQUESTS_PER_CLIENT = 100; -/** - * Datastore allowed numeric IDs where Firestore only allows strings. Numeric - * IDs are exposed to Firestore as __idNUM__, so this is the lowest possible - * negative numeric value expressed in that format. - * - * This constant is used to specify startAt/endAt values when querying for all - * descendants in a single collection. - * - * @private - */ -const REFERENCE_NAME_MIN_ID = '__id-9223372036854775808__'; - /** * Document data (e.g. for use with * [set()]{@link DocumentReference#set}) consisting of fields mapped @@ -399,6 +388,26 @@ export class Firestore implements firestore.Firestore { */ private registeredListenersCount = 0; + /** + * A lazy-loaded BulkWriter instance to be used with recursiveDelete() if no + * BulkWriter instance is provided. + * + * @private + */ + private _bulkWriter: BulkWriter | undefined; + + /** + * Lazy-load the Firestore's default BulkWriter. + * + * @private + */ + private getBulkWriter(): BulkWriter { + if (!this._bulkWriter) { + this._bulkWriter = this.bulkWriter(); + } + return this._bulkWriter; + } + /** * Number of pending operations on the client. * @@ -1200,50 +1209,49 @@ export class Firestore implements firestore.Firestore { } /** - * Retrieves all descendant documents nested under the provided reference. + * Recursively deletes all documents and subcollections at and under the + * specified level. * - * @private - * @return {Stream} Stream of descendant documents. + * If any delete fails, the promise is rejected with an error message + * containing the number of failed deletes and the stack trace of the last + * failed delete. The provided reference is deleted regardless of whether + * all deletes succeeded. + * + * `recursiveDelete()` uses a BulkWriter instance with default settings to + * perform the deletes. To customize throttling rates or add success/error + * callbacks, pass in a custom BulkWriter instance. + * + * @param ref The reference of a document or collection to delete. + * @param bulkWriter A custom BulkWriter instance used to perform the + * deletes. + * @return A promise that resolves when all deletes have been performed. + * The promise is rejected if any of the deletes fail. + * + * @example + * // Recursively delete a reference and log the references of failures. + * const bulkWriter = firestore.bulkWriter(); + * bulkWriter + * .onWriteError((error) => { + * if ( + * error.failedAttempts < MAX_RETRY_ATTEMPTS + * ) { + * return true; + * } else { + * console.log('Failed write at document: ', error.documentRef.path); + * return false; + * } + * }); + * await firestore.recursiveDelete(docRef, bulkWriter); */ - // TODO(chenbrian): Make this a private method after adding recursive delete. - _getAllDescendants( - ref: CollectionReference | DocumentReference - ): NodeJS.ReadableStream { - // The parent is the closest ancestor document to the location we're - // deleting. If we are deleting a document, the parent is the path of that - // document. If we are deleting a collection, the parent is the path of the - // document containing that collection (or the database root, if it is a - // root collection). - let parentPath = ref._resourcePath; - if (ref instanceof CollectionReference) { - parentPath = parentPath.popLast(); - } - const collectionId = - ref instanceof CollectionReference ? ref.id : ref.parent.id; - - let query: Query = new Query( - this, - QueryOptions.forKindlessAllDescendants(parentPath, collectionId) - ); - - // Query for names only to fetch empty snapshots. - query = query.select(FieldPath.documentId()); - - if (ref instanceof CollectionReference) { - // To find all descendants of a collection reference, we need to use a - // composite filter that captures all documents that start with the - // collection prefix. The MIN_KEY constant represents the minimum key in - // this collection, and a null byte + the MIN_KEY represents the minimum - // key is the next possible collection. - const nullChar = String.fromCharCode(0); - const startAt = collectionId + '/' + REFERENCE_NAME_MIN_ID; - const endAt = collectionId + nullChar + '/' + REFERENCE_NAME_MIN_ID; - query = query - .where(FieldPath.documentId(), '>=', startAt) - .where(FieldPath.documentId(), '<', endAt); - } - - return query.stream(); + recursiveDelete( + ref: + | firestore.CollectionReference + | firestore.DocumentReference, + bulkWriter?: BulkWriter + ): Promise { + const writer = bulkWriter ?? this.getBulkWriter(); + const deleter = new RecursiveDelete(this, writer, ref); + return deleter.run(); } /** diff --git a/dev/src/recursive-delete.ts b/dev/src/recursive-delete.ts new file mode 100644 index 000000000..5aeecfd20 --- /dev/null +++ b/dev/src/recursive-delete.ts @@ -0,0 +1,314 @@ +/*! + * Copyright 2021 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 * as assert from 'assert'; + +import Firestore, { + BulkWriter, + CollectionReference, + DocumentReference, + FieldPath, + Query, + QueryDocumentSnapshot, +} from '.'; +import {Deferred, wrapError} from './util'; +import {GoogleError, Status} from 'google-gax'; +import {BulkWriterError} from './bulk-writer'; +import {QueryOptions} from './reference'; + +/** + * Datastore allowed numeric IDs where Firestore only allows strings. Numeric + * IDs are exposed to Firestore as __idNUM__, so this is the lowest possible + * negative numeric value expressed in that format. + * + * This constant is used to specify startAt/endAt values when querying for all + * descendants in a single collection. + * + * @private + */ +export const REFERENCE_NAME_MIN_ID = '__id-9223372036854775808__'; + +/*! + * The query limit used for recursive deletes when fetching all descendants of + * the specified reference to delete. This is done to prevent the query stream + * from streaming documents faster than Firestore can delete. + */ +// Visible for testing. +export const MAX_PENDING_OPS = 5000; + +/** + * The number of pending BulkWriter operations at which RecursiveDelete + * starts the next limit query to fetch descendants. By starting the query + * while there are pending operations, Firestore can improve BulkWriter + * throughput. This helps prevent BulkWriter from idling while Firestore + * fetches the next query. + */ +const MIN_PENDING_OPS = 1000; + +/** + * Class used to store state required for running a recursive delete operation. + * Each recursive delete call should use a new instance of the class. + * @private + */ +export class RecursiveDelete { + /** + * The number of deletes that failed with a permanent error. + * @private + */ + private errorCount = 0; + + /** + * The most recently thrown error. Used to populate the developer-facing + * error message when the recursive delete operation completes. + * @private + */ + private lastError: GoogleError | BulkWriterError | undefined; + + /** + * Whether there are still documents to delete that still need to be fetched. + * @private + */ + private documentsPending = true; + + /** + * A deferred promise that resolves when the recursive delete operation + * is completed. + * @private + */ + private readonly completionDeferred = new Deferred(); + + /** + * Whether a query stream is currently in progress. Only one stream can be + * run at a time. + * @private + */ + private streamInProgress = false; + + /** + * The last document snapshot returned by the stream. Used to set the + * startAfter() field in the subsequent stream. + * @private + */ + private lastDocumentSnap: QueryDocumentSnapshot | undefined; + + /** + * The number of pending BulkWriter operations. Used to determine when the + * next query can be run. + * @private + */ + private pendingOpsCount = 0; + + private errorStack = ''; + + /** + * + * @param firestore The Firestore instance to use. + * @param writer The BulkWriter instance to use for delete operations. + * @param ref The document or collection reference to recursively delete. + */ + constructor( + private readonly firestore: Firestore, + private readonly writer: BulkWriter, + private readonly ref: + | firestore.CollectionReference + | firestore.DocumentReference + ) {} + + /** + * Recursively deletes the reference provided in the class constructor. + * Returns a promise that resolves when all descendants have been deleted, or + * if an error occurs. + */ + run(): Promise { + assert( + this.documentsPending, + 'The recursive delete operation has already been completed.' + ); + + // Capture the error stack to preserve stack tracing across async calls. + this.errorStack = Error().stack!; + + this.writer._verifyNotClosed(); + this.setupStream(); + return this.completionDeferred.promise; + } + + /** + * Creates a query stream and attaches event handlers to it. + * @private + */ + private setupStream(): void { + const limit = MAX_PENDING_OPS; + const stream = this.getAllDescendants( + this.ref instanceof CollectionReference + ? (this.ref as CollectionReference) + : (this.ref as DocumentReference), + limit + ); + this.streamInProgress = true; + let streamedDocsCount = 0; + stream + .on('error', err => { + err.code = Status.UNAVAILABLE; + err.stack = 'Failed to fetch children documents: ' + err.stack; + this.lastError = err; + this.onQueryEnd(); + }) + .on('data', (snap: QueryDocumentSnapshot) => { + streamedDocsCount++; + this.lastDocumentSnap = snap; + this.deleteRef(snap.ref); + }) + .on('end', () => { + this.streamInProgress = false; + // If there are fewer than the number of documents specified in the + // limit() field, we know that the query is complete. + if (streamedDocsCount < limit) { + this.onQueryEnd(); + } else if (this.pendingOpsCount === 0) { + this.setupStream(); + } + }); + } + + /** + * Retrieves all descendant documents nested under the provided reference. + * @param ref The reference to fetch all descendants for. + * @param limit The number of descendants to fetch in the query. + * @private + * @return {Stream} Stream of descendant documents. + */ + private getAllDescendants( + ref: CollectionReference | DocumentReference, + limit: number + ): NodeJS.ReadableStream { + // The parent is the closest ancestor document to the location we're + // deleting. If we are deleting a document, the parent is the path of that + // document. If we are deleting a collection, the parent is the path of the + // document containing that collection (or the database root, if it is a + // root collection). + let parentPath = ref._resourcePath; + if (ref instanceof CollectionReference) { + parentPath = parentPath.popLast(); + } + const collectionId = + ref instanceof CollectionReference + ? ref.id + : (ref as DocumentReference).parent.id; + + let query: Query = new Query( + this.firestore, + QueryOptions.forKindlessAllDescendants( + parentPath, + collectionId, + /* requireConsistency= */ false + ) + ); + + // Query for names only to fetch empty snapshots. + query = query.select(FieldPath.documentId()).limit(limit); + + if (ref instanceof CollectionReference) { + // To find all descendants of a collection reference, we need to use a + // composite filter that captures all documents that start with the + // collection prefix. The MIN_KEY constant represents the minimum key in + // this collection, and a null byte + the MIN_KEY represents the minimum + // key is the next possible collection. + const nullChar = String.fromCharCode(0); + const startAt = collectionId + '/' + REFERENCE_NAME_MIN_ID; + const endAt = collectionId + nullChar + '/' + REFERENCE_NAME_MIN_ID; + query = query + .where(FieldPath.documentId(), '>=', startAt) + .where(FieldPath.documentId(), '<', endAt); + } + + if (this.lastDocumentSnap) { + query = query.startAfter(this.lastDocumentSnap); + } + + return query.stream(); + } + + /** + * Called when all descendants of the provided reference have been streamed + * or if a permanent error occurs during the stream. Deletes the developer + * provided reference and wraps any errors that occurred. + * @private + */ + private onQueryEnd(): void { + this.documentsPending = false; + if (this.ref instanceof DocumentReference) { + this.writer.delete(this.ref).catch(err => this.incrementErrorCount(err)); + } + this.writer.flush().then(async () => { + if (this.lastError === undefined) { + this.completionDeferred.resolve(); + } else { + let error = new GoogleError( + `${this.errorCount} ` + + `${this.errorCount !== 1 ? 'deletes' : 'delete'} ` + + 'failed. The last delete failed with: ' + ); + if (this.lastError.code !== undefined) { + error.code = (this.lastError.code as number) as Status; + } + error = wrapError(error, this.errorStack); + + // Wrap the BulkWriter error last to provide the full stack trace. + this.completionDeferred.reject( + this.lastError.stack + ? wrapError(error, this.lastError.stack ?? '') + : error + ); + } + }); + } + + /** + * Deletes the provided reference and starts the next stream if conditions + * are met. + * @private + */ + private deleteRef(docRef: DocumentReference): void { + this.pendingOpsCount++; + this.writer + .delete(docRef) + .catch(err => { + this.incrementErrorCount(err); + }) + .then(() => { + this.pendingOpsCount--; + + // We wait until the previous stream has ended in order to sure the + // startAfter document is correct. Starting the next stream while + // there are pending operations allows Firestore to maximize + // BulkWriter throughput. + if ( + this.documentsPending && + !this.streamInProgress && + this.pendingOpsCount < MIN_PENDING_OPS + ) { + this.setupStream(); + } + }); + } + + private incrementErrorCount(err: Error): void { + this.errorCount++; + this.lastError = err; + } +} diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 40953c5c9..06283c4b0 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -1006,7 +1006,11 @@ export class QueryOptions { readonly projection?: api.StructuredQuery.IProjection, // Whether to select all documents under `parentPath`. By default, only // collections that match `collectionId` are selected. - readonly kindless = false + readonly kindless = false, + // Whether to require consistent documents when restarting the query. By + // default, restarting the query uses the readTime offset of the original + // query to provide consistent results. + readonly requireConsistency = true ) {} /** @@ -1053,7 +1057,8 @@ export class QueryOptions { */ static forKindlessAllDescendants( parent: ResourcePath, - id: string + id: string, + requireConsistency = true ): QueryOptions { let options = new QueryOptions( parent, @@ -1066,6 +1071,7 @@ export class QueryOptions { options = options.with({ kindless: true, + requireConsistency, }); return options; } @@ -1088,7 +1094,8 @@ export class QueryOptions { coalesce(settings.limitType, this.limitType), coalesce(settings.offset, this.offset), coalesce(settings.projection, this.projection), - coalesce(settings.kindless, this.kindless) + coalesce(settings.kindless, this.kindless), + coalesce(settings.requireConsistency, this.requireConsistency) ); } @@ -1133,7 +1140,8 @@ export class QueryOptions { deepEqual(this.startAt, other.startAt) && deepEqual(this.endAt, other.endAt) && deepEqual(this.projection, other.projection) && - this.kindless === other.kindless + this.kindless === other.kindless && + this.requireConsistency === other.requireConsistency ); } } @@ -1515,25 +1523,21 @@ export class Query implements firestore.Query { } const fieldOrders = this._queryOptions.fieldOrders.slice(); - let hasDocumentId = false; + // If no explicit ordering is specified, use the first inequality to + // define an implicit order. if (fieldOrders.length === 0) { - // If no explicit ordering is specified, use the first inequality to - // define an implicit order. for (const fieldFilter of this._queryOptions.fieldFilters) { if (fieldFilter.isInequalityFilter()) { fieldOrders.push(new FieldOrder(fieldFilter.field)); break; } } - } else { - for (const fieldOrder of fieldOrders) { - if (FieldPath.documentId().isEqual(fieldOrder.field)) { - hasDocumentId = true; - } - } } + const hasDocumentId = !!fieldOrders.find(fieldOrder => + FieldPath.documentId().isEqual(fieldOrder.field) + ); if (!hasDocumentId) { // Add implicit sorting by name, using the last specified direction. const lastDirection = @@ -2181,9 +2185,13 @@ export class Query implements firestore.Query { // query cursor. Note that we do not use backoff here. The call to // `requestStream()` will backoff should the restart fail before // delivering any results. - request = this.startAfter(lastReceivedDocument).toProto( - lastReceivedDocument.readTime - ); + if (this._queryOptions.requireConsistency) { + request = this.startAfter(lastReceivedDocument).toProto( + lastReceivedDocument.readTime + ); + } else { + request = this.startAfter(lastReceivedDocument).toProto(); + } } streamActive.resolve(/* active= */ true); } else { diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 6a388b6d8..77922d4cd 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -2629,69 +2629,105 @@ describe('BulkWriter class', () => { return firestore.terminate(); }); - // TODO(chenbrian): This is a temporary test used to validate that the - // StructuredQuery calls work properly. Remove these tests after adding - // recursive delete tests. - it('finds nested documents and collection', async () => { - // ROOT-DB - // └── randomCol - // ├── anna - // └── bob - // └── parentsCol - // ├── charlie - // └── daniel - // └── childCol - // ├── ernie - // └── francis - const batch = firestore.batch(); - batch.set(randomCol.doc('anna'), {name: 'anna'}); - batch.set(randomCol.doc('bob'), {name: 'bob'}); - batch.set(randomCol.doc('bob/parentsCol/charlie'), {name: 'charlie'}); - batch.set(randomCol.doc('bob/parentsCol/daniel'), {name: 'daniel'}); - batch.set(randomCol.doc('bob/parentsCol/daniel/childCol/ernie'), { - name: 'ernie', - }); - batch.set(randomCol.doc('bob/parentsCol/daniel/childCol/francis'), { - name: 'francis', - }); - await batch.commit(); + describe('recursiveDelete()', () => { + async function countDocumentChildren( + ref: DocumentReference + ): Promise { + let count = 0; + const collections = await ref.listCollections(); + for (const collection of collections) { + count += await countCollectionChildren(collection); + } + return count; + } - const numStreamItems = async ( - stream: NodeJS.ReadableStream - ): Promise => { + async function countCollectionChildren( + ref: CollectionReference + ): Promise { let count = 0; - // eslint-disable-next-line @typescript-eslint/no-unused-vars - for await (const _ of stream) { - ++count; + const docs = await ref.listDocuments(); + for (const doc of docs) { + count += (await countDocumentChildren(doc)) + 1; } return count; - }; + } - // Query all descendants of collections. - let descendantsStream = await firestore._getAllDescendants(randomCol); - expect(await numStreamItems(descendantsStream)).to.equal(6); - descendantsStream = await firestore._getAllDescendants( - randomCol.doc('bob').collection('parentsCol') - ); - expect(await numStreamItems(descendantsStream)).to.equal(4); - descendantsStream = await firestore._getAllDescendants( - randomCol.doc('bob').collection('parentsCol/daniel/childCol') - ); - expect(await numStreamItems(descendantsStream)).to.equal(2); + beforeEach(async () => { + // ROOT-DB + // └── randomCol + // ├── anna + // └── bob + // └── parentsCol + // ├── charlie + // └── daniel + // └── childCol + // ├── ernie + // └── francis + const batch = firestore.batch(); + batch.set(randomCol.doc('anna'), {name: 'anna'}); + batch.set(randomCol.doc('bob'), {name: 'bob'}); + batch.set(randomCol.doc('bob/parentsCol/charlie'), {name: 'charlie'}); + batch.set(randomCol.doc('bob/parentsCol/daniel'), {name: 'daniel'}); + batch.set(randomCol.doc('bob/parentsCol/daniel/childCol/ernie'), { + name: 'ernie', + }); + batch.set(randomCol.doc('bob/parentsCol/daniel/childCol/francis'), { + name: 'francis', + }); + await batch.commit(); + }); - // Query all descendants of documents. - descendantsStream = await firestore._getAllDescendants( - randomCol.doc('bob') - ); - expect(await numStreamItems(descendantsStream)).to.equal(4); - descendantsStream = await firestore._getAllDescendants( - randomCol.doc('bob/parentsCol/daniel') - ); - expect(await numStreamItems(descendantsStream)).to.equal(2); - descendantsStream = await firestore._getAllDescendants( - randomCol.doc('anna') - ); - expect(await numStreamItems(descendantsStream)).to.equal(0); + it('on top-level collection', async () => { + await firestore.recursiveDelete(randomCol); + expect(await countCollectionChildren(randomCol)).to.equal(0); + }); + + it('on nested collection', async () => { + const coll = randomCol.doc('bob').collection('parentsCol'); + await firestore.recursiveDelete(coll); + + expect(await countCollectionChildren(coll)).to.equal(0); + expect(await countCollectionChildren(randomCol)).to.equal(2); + }); + + it('on nested document', async () => { + const doc = randomCol.doc('bob/parentsCol/daniel'); + await firestore.recursiveDelete(doc); + + const docSnap = await doc.get(); + expect(docSnap.exists).to.be.false; + expect(await countDocumentChildren(randomCol.doc('bob'))).to.equal(1); + expect(await countCollectionChildren(randomCol)).to.equal(3); + }); + + it('on leaf document', async () => { + const doc = randomCol.doc('bob/parentsCol/daniel/childCol/ernie'); + await firestore.recursiveDelete(doc); + + const docSnap = await doc.get(); + expect(docSnap.exists).to.be.false; + expect(await countCollectionChildren(randomCol)).to.equal(5); + }); + + it('does not affect other collections', async () => { + // Add other nested collection that shouldn't be deleted. + const collB = firestore.collection('doggos'); + await collB.doc('doggo').set({name: 'goodboi'}); + + await firestore.recursiveDelete(collB); + expect(await countCollectionChildren(randomCol)).to.equal(6); + expect(await countCollectionChildren(collB)).to.equal(0); + }); + + it('with custom BulkWriter instance', async () => { + const bulkWriter = firestore.bulkWriter(); + let callbackCount = 0; + bulkWriter.onWriteResult(() => { + callbackCount++; + }); + await firestore.recursiveDelete(randomCol, bulkWriter); + expect(callbackCount).to.equal(6); + }); }); it('can retry failed writes with a provided callback', async () => { diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index ad904e1ff..b9c49ef58 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -64,6 +64,73 @@ interface RequestResponse { response: api.IBatchWriteResponse; } +export function createRequest(requests: api.IWrite[]): api.IBatchWriteRequest { + return { + writes: requests, + }; +} + +export function successResponse( + updateTimeSeconds: number +): api.IBatchWriteResponse { + return { + writeResults: [ + { + updateTime: { + nanos: 0, + seconds: updateTimeSeconds, + }, + }, + ], + status: [{code: Status.OK}], + }; +} + +export function failedResponse( + code = Status.DEADLINE_EXCEEDED +): api.IBatchWriteResponse { + return { + writeResults: [ + { + updateTime: null, + }, + ], + status: [{code}], + }; +} + +export function mergeResponses( + responses: api.IBatchWriteResponse[] +): api.IBatchWriteResponse { + return { + writeResults: responses.map(v => v.writeResults![0]), + status: responses.map(v => v.status![0]), + }; +} + +export function setOp(doc: string, value: string): api.IWrite { + return set({ + document: document(doc, 'foo', value), + }).writes![0]; +} + +export function updateOp(doc: string, value: string): api.IWrite { + return update({ + document: document(doc, 'foo', value), + mask: updateMask('foo'), + }).writes![0]; +} + +export function createOp(doc: string, value: string): api.IWrite { + return create({ + document: document(doc, 'foo', value), + }).writes![0]; +} + +export function deleteOp(doc: string): api.IWrite { + return remove(doc).writes![0]; +} + describe('BulkWriter', () => { let firestore: Firestore; let requestCounter: number; @@ -93,71 +160,6 @@ describe('BulkWriter', () => { expect(opCount).to.equal(expected); } - function setOp(doc: string, value: string): api.IWrite { - return set({ - document: document(doc, 'foo', value), - }).writes![0]; - } - - function updateOp(doc: string, value: string): api.IWrite { - return update({ - document: document(doc, 'foo', value), - mask: updateMask('foo'), - }).writes![0]; - } - - function createOp(doc: string, value: string): api.IWrite { - return create({ - document: document(doc, 'foo', value), - }).writes![0]; - } - - function deleteOp(doc: string): api.IWrite { - return remove(doc).writes![0]; - } - - function createRequest(requests: api.IWrite[]): api.IBatchWriteRequest { - return { - writes: requests, - }; - } - - function successResponse(updateTimeSeconds: number): api.IBatchWriteResponse { - return { - writeResults: [ - { - updateTime: { - nanos: 0, - seconds: updateTimeSeconds, - }, - }, - ], - status: [{code: Status.OK}], - }; - } - - function failedResponse( - code = Status.DEADLINE_EXCEEDED - ): api.IBatchWriteResponse { - return { - writeResults: [ - { - updateTime: null, - }, - ], - status: [{code}], - }; - } - - function mergeResponses( - responses: api.IBatchWriteResponse[] - ): api.IBatchWriteResponse { - return { - writeResults: responses.map(v => v.writeResults![0]), - status: responses.map(v => v.status![0]), - }; - } - /** * Creates an instance with the mocked objects. */ diff --git a/dev/test/query.ts b/dev/test/query.ts index 1c7264504..f92a1ac5f 100644 --- a/dev/test/query.ts +++ b/dev/test/query.ts @@ -49,6 +49,7 @@ import { } from './util/helpers'; import api = google.firestore.v1; +import protobuf = google.protobuf; const PROJECT_ID = 'test-project'; const DATABASE_ROOT = `projects/${PROJECT_ID}/databases/(default)`; @@ -202,7 +203,7 @@ export function orderBy( return {orderBy}; } -function limit(n: number): api.IStructuredQuery { +export function limit(n: number): api.IStructuredQuery { return { limit: { value: n, @@ -216,11 +217,14 @@ function offset(n: number): api.IStructuredQuery { }; } -function allDescendants(): api.IStructuredQuery { +export function allDescendants(kindless = false): api.IStructuredQuery { + if (kindless) { + return {from: [{allDescendants: true}]}; + } return {from: [{collectionId: 'collectionId', allDescendants: true}]}; } -function select(...fields: string[]): api.IStructuredQuery { +export function select(...fields: string[]): api.IStructuredQuery { const select: api.StructuredQuery.IProjection = { fields: [], }; @@ -282,27 +286,50 @@ function endAt( return {endAt: cursor}; } -export function queryEquals( +/** + * Returns the timestamp value for the provided readTimes, or the default + * readTime value used in tests if no values are provided. + */ +export function readTime( + seconds?: number, + nanos?: number +): protobuf.ITimestamp { + if (seconds === undefined && nanos === undefined) { + return {seconds: '5', nanos: 6}; + } + return {seconds: String(seconds), nanos: nanos}; +} + +export function queryEqualsWithParent( actual: api.IRunQueryRequest | undefined, + parent: string, ...protoComponents: api.IStructuredQuery[] -) { +): void { expect(actual).to.not.be.undefined; + if (parent !== '') { + parent = '/' + parent; + } + const query: api.IRunQueryRequest = { - parent: DATABASE_ROOT + '/documents', - structuredQuery: { - from: [ - { - collectionId: 'collectionId', - }, - ], - }, + parent: DATABASE_ROOT + '/documents' + parent, + structuredQuery: {}, }; for (const protoComponent of protoComponents) { extend(true, query.structuredQuery, protoComponent); } + // We add the `from` selector here in order to avoid setting collectionId on + // kindless queries. + if (query.structuredQuery!.from === undefined) { + query.structuredQuery!.from = [ + { + collectionId: 'collectionId', + }, + ]; + } + // 'extend' removes undefined fields in the request object. The backend // ignores these fields, but we need to manually strip them before we compare // the expected and the actual request. @@ -310,6 +337,13 @@ export function queryEquals( expect(actual).to.deep.eq(query); } +export function queryEquals( + actual: api.IRunQueryRequest | undefined, + ...protoComponents: api.IStructuredQuery[] +): void { + queryEqualsWithParent(actual, /* parent= */ '', ...protoComponents); +} + function bundledQueryEquals( actual: firestore.IBundledQuery | undefined, limitType: firestore.BundledQuery.LimitType | undefined, diff --git a/dev/test/recursive-delete.ts b/dev/test/recursive-delete.ts new file mode 100644 index 000000000..ad62e28c1 --- /dev/null +++ b/dev/test/recursive-delete.ts @@ -0,0 +1,603 @@ +// Copyright 2021 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 {afterEach, beforeEach, describe, it} from 'mocha'; +import {fail} from 'assert'; +import {expect} from 'chai'; +import {GoogleError, Status} from 'google-gax'; +import sinon = require('sinon'); + +import {google} from '../protos/firestore_v1_proto_api'; + +import * as Firestore from '../src'; +import {setTimeoutHandler} from '../src/backoff'; +import { + ApiOverride, + createInstance, + postConverter, + response, + stream, + verifyInstance, +} from './util/helpers'; +import { + allDescendants, + fieldFilters, + limit, + orderBy, + queryEquals, + queryEqualsWithParent, + result, + select, + startAt as queryStartAt, +} from './query'; +import { + createRequest, + deleteOp, + failedResponse, + mergeResponses, + successResponse, +} from './bulk-writer'; +import {MAX_REQUEST_RETRIES} from '../src'; + +import api = google.firestore.v1; +import {MAX_PENDING_OPS, REFERENCE_NAME_MIN_ID} from '../src/recursive-delete'; + +const PROJECT_ID = 'test-project'; +const DATABASE_ROOT = `projects/${PROJECT_ID}/databases/(default)`; + +describe('recursiveDelete() method:', () => { + // We store errors from batchWrite inside an error object since errors thrown + // in batchWrite do not affect the recursiveDelete promise. + let batchWriteError: Error | undefined; + let firestore: Firestore.Firestore; + + beforeEach(() => { + setTimeoutHandler(setImmediate); + }); + + afterEach(() => { + verifyInstance(firestore); + setTimeoutHandler(setTimeout); + expect(batchWriteError, 'batchWrite should not have errored').to.be + .undefined; + }); + + function instantiateInstance( + childrenDocs: Array, + deleteDocRef = '', + responses?: api.IBatchWriteResponse + ): Promise { + const overrides: ApiOverride = { + runQuery: () => { + return stream(...childrenDocs.map(docId => result(docId))); + }, + batchWrite: request => { + const documents = childrenDocs; + if (deleteDocRef.length > 0) { + documents.push(deleteDocRef); + } + const expected = createRequest(documents.map(docId => deleteOp(docId))); + try { + expect(request.writes).to.deep.equal(expected.writes); + } catch (e) { + batchWriteError = e; + } + const returnedResponse = + responses ?? mergeResponses(documents.map(() => successResponse(1))); + + return response({ + writeResults: returnedResponse.writeResults, + status: returnedResponse.status, + }); + }, + }; + + return createInstance(overrides); + } + + describe('calls getAllDescendants() with correct StructuredQuery', () => { + function startAt(name: string): api.IValue { + return { + referenceValue: + DATABASE_ROOT + '/documents/' + name + '/' + REFERENCE_NAME_MIN_ID, + }; + } + + function endAt(name: string): api.IValue { + return { + referenceValue: + DATABASE_ROOT + + '/documents/' + + name + + String.fromCharCode(0) + + '/' + + REFERENCE_NAME_MIN_ID, + }; + } + + it('for root-level collections', async () => { + const overrides: ApiOverride = { + runQuery: req => { + queryEquals( + req, + select('__name__'), + allDescendants(/* kindless= */ true), + fieldFilters( + '__name__', + 'GREATER_THAN_OR_EQUAL', + startAt('root'), + '__name__', + 'LESS_THAN', + endAt('root') + ), + limit(MAX_PENDING_OPS) + ); + return stream(); + }, + }; + firestore = await createInstance(overrides); + return firestore.recursiveDelete(firestore.collection('root')); + }); + + it('for nested collections', async () => { + const overrides: ApiOverride = { + runQuery: req => { + queryEqualsWithParent( + req, + 'root/doc', + select('__name__'), + allDescendants(/* kindless= */ true), + fieldFilters( + '__name__', + 'GREATER_THAN_OR_EQUAL', + startAt('root/doc/nestedCol'), + '__name__', + 'LESS_THAN', + endAt('root/doc/nestedCol') + ), + limit(MAX_PENDING_OPS) + ); + return stream(); + }, + }; + firestore = await createInstance(overrides); + return firestore.recursiveDelete( + firestore.collection('root/doc/nestedCol') + ); + }); + + it('documents', async () => { + const overrides: ApiOverride = { + runQuery: req => { + queryEqualsWithParent( + req, + 'root/doc', + select('__name__'), + allDescendants(/* kindless= */ true), + limit(MAX_PENDING_OPS) + ); + return stream(); + }, + // Include dummy response for the deleted docRef. + batchWrite: () => response(successResponse(1)), + }; + firestore = await createInstance(overrides); + return firestore.recursiveDelete(firestore.doc('root/doc')); + }); + + it('creates retry query after stream exception with last received doc', async () => { + let callCount = 0; + const overrides: ApiOverride = { + runQuery: request => { + callCount++; + if (callCount === 1) { + return stream(result('doc1'), new Error('failed in test')); + } else { + queryEqualsWithParent( + request, + /* parent= */ '', + select('__name__'), + allDescendants(/* kindless= */ true), + orderBy('__name__', 'ASCENDING'), + queryStartAt(false, { + referenceValue: + `projects/${PROJECT_ID}/databases/(default)/` + + 'documents/collectionId/doc1', + }), + fieldFilters( + '__name__', + 'GREATER_THAN_OR_EQUAL', + startAt('root'), + '__name__', + 'LESS_THAN', + endAt('root') + ), + limit(MAX_PENDING_OPS) + ); + return stream(); + } + }, + batchWrite: () => response(successResponse(1)), + }; + + const firestore = await createInstance(overrides); + await firestore.recursiveDelete(firestore.collection('root')); + }); + + it('creates a second query with the correct startAfter', async () => { + const firstStream = Array.from( + Array(MAX_PENDING_OPS).keys() + ).map((_, i) => result('doc' + i)); + + // Use an array to store that the queryEquals() method succeeded, since + // thrown errors do not result in the recursiveDelete() method failing. + const called: number[] = []; + const overrides: ApiOverride = { + runQuery: request => { + if (called.length === 0) { + queryEquals( + request, + select('__name__'), + allDescendants(/* kindless= */ true), + fieldFilters( + '__name__', + 'GREATER_THAN_OR_EQUAL', + startAt('root'), + '__name__', + 'LESS_THAN', + endAt('root') + ), + limit(MAX_PENDING_OPS) + ); + called.push(1); + return stream(...firstStream); + } else if (called.length === 1) { + queryEquals( + request, + select('__name__'), + allDescendants(/* kindless= */ true), + orderBy('__name__', 'ASCENDING'), + fieldFilters( + '__name__', + 'GREATER_THAN_OR_EQUAL', + startAt('root'), + '__name__', + 'LESS_THAN', + endAt('root') + ), + queryStartAt(false, { + referenceValue: + `projects/${PROJECT_ID}/databases/(default)/` + + 'documents/collectionId/doc' + + (MAX_PENDING_OPS - 1), + }), + limit(MAX_PENDING_OPS) + ); + called.push(2); + return stream(); + } else { + called.push(3); + return stream(); + } + }, + batchWrite: () => { + const responses = mergeResponses( + Array.from(Array(500).keys()).map(() => successResponse(1)) + ); + return response({ + writeResults: responses.writeResults, + status: responses.status, + }); + }, + }; + const firestore = await createInstance(overrides); + + // Use a custom batch size with BulkWriter to simplify the dummy + // batchWrite() response logic. + const bulkWriter = firestore.bulkWriter(); + bulkWriter._maxBatchSize = 500; + await firestore.recursiveDelete(firestore.collection('root'), bulkWriter); + expect(called).to.deep.equal([1, 2]); + }); + }); + + describe('deletes', () => { + it('collection', async () => { + // The four documents are under the 'collectionId' collection, and is + // automatically prefixed by `instantiateInstance()`. + firestore = await instantiateInstance([ + 'anna', + 'bob', + 'bob/children/charlie', + 'bob/children/daniel', + ]); + await firestore.recursiveDelete(firestore.collection('collectionId')); + }); + + it('document along with reference', async () => { + firestore = await instantiateInstance( + ['bob/children/brian', 'bob/children/charlie', 'bob/children/daniel'], + 'bob' + ); + await firestore.recursiveDelete( + firestore.collection('collectionId').doc('bob') + ); + }); + + it('promise is rejected with the last error code if writes fail', async () => { + firestore = await instantiateInstance( + ['bob/children/brian', 'bob/children/charlie', 'bob/children/daniel'], + 'bob', + mergeResponses([ + successResponse(1), + failedResponse(Status.CANCELLED), + failedResponse(Status.PERMISSION_DENIED), + successResponse(1), + ]) + ); + try { + await firestore.recursiveDelete( + firestore.collection('collectionId').doc('bob') + ); + fail('recursiveDelete should have failed'); + } catch (err) { + expect(err.code).to.equal(Status.PERMISSION_DENIED); + expect(err.message).to.contain('2 deletes failed'); + } + }); + + it('promise is rejected if BulkWriter success handler fails', async () => { + firestore = await instantiateInstance(['bob/children/brian'], 'bob'); + + const bulkWriter = firestore.bulkWriter(); + bulkWriter.onWriteResult(() => { + throw new Error('User provided result callback failed'); + }); + + try { + await firestore.recursiveDelete( + firestore.collection('collectionId').doc('bob'), + bulkWriter + ); + fail('recursiveDelete() should have failed'); + } catch (err) { + expect(err.message).to.contain('2 deletes failed'); + expect(err.stack).to.contain('User provided result callback failed'); + } + }); + + it('BulkWriter success handler provides the correct references and results', async () => { + firestore = await instantiateInstance( + ['bob/children/brian', 'bob/children/charlie'], + 'bob', + mergeResponses([ + successResponse(1), + successResponse(2), + successResponse(3), + ]) + ); + const results: number[] = []; + const refs: string[] = []; + const bulkWriter = firestore.bulkWriter(); + bulkWriter.onWriteResult((ref, result) => { + results.push(result.writeTime.seconds); + refs.push(ref.path); + }); + + await firestore.recursiveDelete( + firestore.collection('collectionId').doc('bob'), + bulkWriter + ); + expect(results).to.deep.equal([1, 2, 3]); + expect(refs).to.deep.equal([ + 'collectionId/bob/children/brian', + 'collectionId/bob/children/charlie', + 'collectionId/bob', + ]); + }); + + it('BulkWriter error handler provides the correct information', async () => { + firestore = await instantiateInstance( + ['bob/children/brian', 'bob/children/charlie'], + 'bob', + mergeResponses([ + failedResponse(Status.PERMISSION_DENIED), + failedResponse(Status.UNAVAILABLE), + failedResponse(Status.INTERNAL), + ]) + ); + const codes: Status[] = []; + const refs: string[] = []; + const bulkWriter = firestore.bulkWriter(); + bulkWriter.onWriteError(err => { + codes.push((err.code as unknown) as Status); + refs.push(err.documentRef.path); + return false; + }); + + try { + await firestore.recursiveDelete( + firestore.collection('collectionId').doc('bob'), + bulkWriter + ); + fail('recursiveDelete() should have failed'); + } catch (err) { + expect(codes).to.deep.equal([ + Status.PERMISSION_DENIED, + Status.UNAVAILABLE, + Status.INTERNAL, + ]); + expect(refs).to.deep.equal([ + 'collectionId/bob/children/brian', + 'collectionId/bob/children/charlie', + 'collectionId/bob', + ]); + } + }); + + it('promise is rejected if provided reference was not deleted', async () => { + const overrides: ApiOverride = { + runQuery: () => stream(), + batchWrite: () => { + throw new GoogleError('batchWrite() failed in test'); + }, + }; + firestore = await createInstance(overrides); + try { + await firestore.recursiveDelete(firestore.doc('root/doc')); + } catch (err) { + expect(err.stack).to.contain('batchWrite() failed in test'); + } + }); + + it('retries stream errors', async () => { + let attempts = 0; + const overrides: ApiOverride = { + runQuery: () => { + attempts++; + throw new Error('runQuery() error in test'); + }, + batchWrite: () => response(successResponse(1)), + }; + firestore = await createInstance(overrides); + try { + await firestore.recursiveDelete(firestore.doc('coll/foo')); + fail('recursiveDelete() should have failed'); + } catch (err) { + expect(err.code).to.equal(Status.UNAVAILABLE); + expect(err.stack).to.contain('Failed to fetch children documents'); + expect(err.stack).to.contain('runQuery() error in test'); + expect(attempts).to.equal(MAX_REQUEST_RETRIES); + } + }); + + it('handles successful stream error retries', async () => { + let requestCounter = 0; + const streamItems = [ + [result('a'), result('b'), new Error('runQuery() error in test')], + [new Error('runQuery() error in test')], + [result('c'), new Error('runQuery() error in test')], + [result('d')], + ]; + + const overrides: ApiOverride = { + runQuery: () => { + const streamPromise = stream(...streamItems[requestCounter]); + requestCounter++; + return streamPromise; + }, + batchWrite: request => { + const expected = createRequest([ + deleteOp('a'), + deleteOp('b'), + deleteOp('c'), + deleteOp('d'), + ]); + try { + expect(request.writes).to.deep.equal(expected.writes); + } catch (e) { + batchWriteError = e; + } + return response( + mergeResponses(expected.writes!.map(() => successResponse(1))) + ); + }, + }; + firestore = await createInstance(overrides); + await firestore.recursiveDelete(firestore.collection('letters')); + }); + + it('handles multiple calls to recursiveDelete()', async () => { + let requestCounter = 0; + const docIds = ['a', 'b', 'c']; + const streamItems = docIds.map(docId => [result(docId)]); + const expected = docIds.map(docId => createRequest([deleteOp(docId)])); + const responses = docIds.map(() => successResponse(1)); + + const overrides: ApiOverride = { + runQuery: () => { + return stream(...streamItems[requestCounter]); + }, + batchWrite: request => { + try { + expect(request.writes).to.deep.equal( + expected[requestCounter]!.writes + ); + } catch (e) { + batchWriteError = e; + } + const responsePromise = response(responses[requestCounter]); + requestCounter++; + return responsePromise; + }, + }; + firestore = await createInstance(overrides); + await firestore.recursiveDelete(firestore.collection('a')); + await firestore.recursiveDelete(firestore.collection('b')); + await firestore.recursiveDelete(firestore.collection('c')); + }); + + it('accepts references with converters', async () => { + const overrides: ApiOverride = { + runQuery: () => stream(), + // Include response for deleting the provided document reference. + batchWrite: () => response(successResponse(1)), + }; + firestore = await createInstance(overrides); + await firestore.recursiveDelete( + firestore.doc('root/doc').withConverter(postConverter) + ); + await firestore.recursiveDelete( + firestore.collection('root').withConverter(postConverter) + ); + }); + }); + + describe('BulkWriter instance', () => { + it('uses custom BulkWriter instance if provided', async () => { + firestore = await instantiateInstance(['a', 'b', 'c']); + let callbackCount = 0; + const bulkWriter = firestore.bulkWriter(); + bulkWriter.onWriteResult(() => { + callbackCount++; + }); + await firestore.recursiveDelete(firestore.collection('foo'), bulkWriter); + expect(callbackCount).to.equal(3); + }); + + it('default: uses the same BulkWriter instance across calls', async () => { + const overrides: ApiOverride = { + runQuery: () => stream(), + }; + firestore = await createInstance(overrides); + const spy = sinon.spy(firestore, 'bulkWriter'); + + await firestore.recursiveDelete(firestore.collection('foo')); + await firestore.recursiveDelete(firestore.collection('boo')); + await firestore.recursiveDelete(firestore.collection('moo')); + + // Only the first recursiveDelete() call should have called the + // constructor. Subsequent calls should have used the same bulkWriter. + expect(spy.callCount).to.equal(1); + }); + + it('throws error if BulkWriter instance is closed', async () => { + firestore = await createInstance(); + const bulkWriter = firestore.bulkWriter(); + await bulkWriter.close(); + await expect(() => () => + firestore.recursiveDelete(firestore.collection('foo'), bulkWriter) + ).to.throw; + }); + }); +}); diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 91ec3cc7a..8763562b2 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -240,6 +240,46 @@ declare namespace FirebaseFirestore { > ): Promise>>; + /** + * Recursively deletes all documents and subcollections at and under the + * specified level. + * + * If any delete fails, the promise is rejected with an error message + * containing the number of failed deletes and the stack trace of the last + * failed delete. The provided reference is deleted regardless of whether + * all deletes succeeded. + * + * `recursiveDelete()` uses a BulkWriter instance with default settings to + * perform the deletes. To customize throttling rates or add success/error + * callbacks, pass in a custom BulkWriter instance. + * + * @param ref The reference of a document or collection to delete. + * @param bulkWriter A custom BulkWriter instance used to perform the + * deletes. + * @return A promise that resolves when all deletes have been performed. + * The promise is rejected if any of the deletes fail. + * + * @example + * // Recursively delete a reference and log the references of failures. + * const bulkWriter = firestore.bulkWriter(); + * bulkWriter + * .onWriteError((error) => { + * if ( + * error.failedAttempts < MAX_RETRY_ATTEMPTS + * ) { + * return true; + * } else { + * console.log('Failed write at document: ', error.documentRef.path); + * return false; + * } + * }); + * await firestore.recursiveDelete(docRef, bulkWriter); + */ + recursiveDelete( + ref: CollectionReference | DocumentReference, + bulkWriter?: BulkWriter + ): Promise; + /** * Terminates the Firestore client and closes all open streams. * From abc7e8ad5f7317455ec39cabd39564c49a1ca49b Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 5 May 2021 10:16:59 -0600 Subject: [PATCH 285/337] chore: release 4.11.0 (#1495) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 856233f98..7379b0ca8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [4.11.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.10.1...v4.11.0) (2021-05-05) + + +### Features + +* add recursive delete to Firestore class ([#1494](https://www.github.com/googleapis/nodejs-firestore/issues/1494)) ([6f1e304](https://www.github.com/googleapis/nodejs-firestore/commit/6f1e3040800d0dcc5ed3f9f7cef16fe41804266a)) + ### [4.10.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.10.0...v4.10.1) (2021-04-28) diff --git a/package.json b/package.json index 8f4381613..34a0127ee 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.10.1", + "version": "4.11.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index e4c60b23a..a21aad003 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.10.1" + "@google-cloud/firestore": "^4.11.0" }, "devDependencies": { "chai": "^4.2.0", From a8d5f0b1e4503ef9f0d289dbf8ed67a30eb9ed4b Mon Sep 17 00:00:00 2001 From: Alexander Fenster Date: Thu, 6 May 2021 17:52:05 -0700 Subject: [PATCH 286/337] fix(deps): require google-gax v2.12.0 (#1497) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 34a0127ee..bc579ad02 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "dependencies": { "fast-deep-equal": "^3.1.1", "functional-red-black-tree": "^1.0.1", - "google-gax": "^2.9.2", + "google-gax": "^2.12.0", "protobufjs": "^6.8.6" }, "devDependencies": { From f1d78ac245a12b233ce1aa46e33dceacf215bcb9 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 7 May 2021 11:08:07 -0700 Subject: [PATCH 287/337] chore: use require() to load JSON protos (#1500) * changes without context autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. * fix: use require() to load JSON protos The library is regenerated with gapic-generator-typescript v1.3.1. Committer: @alexander-fenster PiperOrigin-RevId: 372468161 Source-Author: Google APIs Source-Date: Thu May 6 18:50:48 2021 -0700 Source-Repo: googleapis/googleapis Source-Sha: 75880c3e6a6aa2597400582848e81bbbfac51dea Source-Link: https://github.com/googleapis/googleapis/commit/75880c3e6a6aa2597400582848e81bbbfac51dea --- dev/src/v1/firestore_admin_client.ts | 26 ++-------- dev/src/v1/firestore_client.ts | 18 +------ dev/src/v1beta1/firestore_client.ts | 18 +------ synth.metadata | 6 +-- .../protos/firestore_admin_v1_proto_api.d.ts | 22 ++++---- types/protos/firestore_v1_proto_api.d.ts | 52 +++++++++---------- types/protos/firestore_v1beta1_proto_api.d.ts | 52 +++++++++---------- 7 files changed, 74 insertions(+), 120 deletions(-) diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index e533909e2..49d40f5b7 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -32,6 +32,7 @@ import * as path from 'path'; import {Transform} from 'stream'; import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/firestore_admin_v1_proto_api'; +import jsonProtos = require('../../protos/protos.json'); /** * Client JSON configuration object, loaded from * `src/v1/firestore_admin_client_config.json`. @@ -148,22 +149,7 @@ export class FirestoreAdminClient { clientHeader.push(`${opts.libName}/${opts.libVersion}`); } // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join( - __dirname, - '..', - '..', - 'protos', - 'protos.json' - ); - this._protos = this._gaxGrpc.loadProto( - opts.fallback - ? // eslint-disable-next-line @typescript-eslint/no-var-requires - require('../../protos/protos.json') - : nodejsProtoPath - ); + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); // This API contains "path templates"; forward-slash-separated // identifiers to uniquely identify resources within the API. @@ -199,15 +185,11 @@ export class FirestoreAdminClient { ), }; + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a // an Operation object that allows for tracking of the operation, // rather than holding a request open. - const protoFilesRoot = opts.fallback - ? this._gaxModule.protobuf.Root.fromJSON( - // eslint-disable-next-line @typescript-eslint/no-var-requires - require('../../protos/protos.json') - ) - : this._gaxModule.protobuf.loadSync(nodejsProtoPath); this.operationsClient = this._gaxModule .lro({ diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 867c933ec..d0de5245a 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -31,6 +31,7 @@ import * as path from 'path'; import {Transform} from 'stream'; import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/firestore_v1_proto_api'; +import jsonProtos = require('../../protos/protos.json'); /** * Client JSON configuration object, loaded from * `src/v1/firestore_client_config.json`. @@ -151,22 +152,7 @@ export class FirestoreClient { clientHeader.push(`${opts.libName}/${opts.libVersion}`); } // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join( - __dirname, - '..', - '..', - 'protos', - 'protos.json' - ); - this._protos = this._gaxGrpc.loadProto( - opts.fallback - ? // eslint-disable-next-line @typescript-eslint/no-var-requires - require('../../protos/protos.json') - : nodejsProtoPath - ); + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index 49f1f77d8..3ed8d880d 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -31,6 +31,7 @@ import * as path from 'path'; import {Transform} from 'stream'; import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/firestore_v1beta1_proto_api'; +import jsonProtos = require('../../protos/protos.json'); /** * Client JSON configuration object, loaded from * `src/v1beta1/firestore_client_config.json`. @@ -154,22 +155,7 @@ export class FirestoreClient { clientHeader.push(`${opts.libName}/${opts.libVersion}`); } // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join( - __dirname, - '..', - '..', - 'protos', - 'protos.json' - ); - this._protos = this._gaxGrpc.loadProto( - opts.fallback - ? // eslint-disable-next-line @typescript-eslint/no-var-requires - require('../../protos/protos.json') - : nodejsProtoPath - ); + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent diff --git a/synth.metadata b/synth.metadata index bbfd285fa..acfeaed93 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "4ac8e7ef37a40d99ecaae4ce502c276786416495" + "sha": "a8d5f0b1e4503ef9f0d289dbf8ed67a30eb9ed4b" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "e7d77d65f0e05ce584c1a824c7ecab53b411498b", - "internalRef": "370589666" + "sha": "75880c3e6a6aa2597400582848e81bbbfac51dea", + "internalRef": "372468161" } }, { diff --git a/types/protos/firestore_admin_v1_proto_api.d.ts b/types/protos/firestore_admin_v1_proto_api.d.ts index 37ad40a47..289e6b6d9 100644 --- a/types/protos/firestore_admin_v1_proto_api.d.ts +++ b/types/protos/firestore_admin_v1_proto_api.d.ts @@ -962,10 +962,10 @@ export namespace google { public fieldPath: string; /** IndexField order. */ - public order: google.firestore.admin.v1.Index.IndexField.Order; + public order?: (google.firestore.admin.v1.Index.IndexField.Order|null); /** IndexField arrayConfig. */ - public arrayConfig: google.firestore.admin.v1.Index.IndexField.ArrayConfig; + public arrayConfig?: (google.firestore.admin.v1.Index.IndexField.ArrayConfig|null); /** IndexField valueMode. */ public valueMode?: ("order"|"arrayConfig"); @@ -1586,19 +1586,19 @@ export namespace google { constructor(properties?: google.api.IHttpRule); /** HttpRule get. */ - public get: string; + public get?: (string|null); /** HttpRule put. */ - public put: string; + public put?: (string|null); /** HttpRule post. */ - public post: string; + public post?: (string|null); /** HttpRule delete. */ - public delete: string; + public delete?: (string|null); /** HttpRule patch. */ - public patch: string; + public patch?: (string|null); /** HttpRule custom. */ public custom?: (google.api.ICustomHttpPattern|null); @@ -3679,16 +3679,16 @@ export namespace google { constructor(properties?: google.protobuf.IValue); /** Value nullValue. */ - public nullValue: google.protobuf.NullValue; + public nullValue?: (google.protobuf.NullValue|null); /** Value numberValue. */ - public numberValue: number; + public numberValue?: (number|null); /** Value stringValue. */ - public stringValue: string; + public stringValue?: (string|null); /** Value boolValue. */ - public boolValue: boolean; + public boolValue?: (boolean|null); /** Value structValue. */ public structValue?: (google.protobuf.IStruct|null); diff --git a/types/protos/firestore_v1_proto_api.d.ts b/types/protos/firestore_v1_proto_api.d.ts index 8ff113db2..ea61f2467 100644 --- a/types/protos/firestore_v1_proto_api.d.ts +++ b/types/protos/firestore_v1_proto_api.d.ts @@ -2056,16 +2056,16 @@ export namespace google { constructor(properties?: google.protobuf.IValue); /** Value nullValue. */ - public nullValue: google.protobuf.NullValue; + public nullValue?: (google.protobuf.NullValue|null); /** Value numberValue. */ - public numberValue: number; + public numberValue?: (number|null); /** Value stringValue. */ - public stringValue: string; + public stringValue?: (string|null); /** Value boolValue. */ - public boolValue: boolean; + public boolValue?: (boolean|null); /** Value structValue. */ public structValue?: (google.protobuf.IStruct|null); @@ -2750,7 +2750,7 @@ export namespace google { constructor(properties?: google.firestore.v1.IPrecondition); /** Precondition exists. */ - public exists: boolean; + public exists?: (boolean|null); /** Precondition updateTime. */ public updateTime?: (google.protobuf.ITimestamp|null); @@ -3024,28 +3024,28 @@ export namespace google { constructor(properties?: google.firestore.v1.IValue); /** Value nullValue. */ - public nullValue: google.protobuf.NullValue; + public nullValue?: (google.protobuf.NullValue|null); /** Value booleanValue. */ - public booleanValue: boolean; + public booleanValue?: (boolean|null); /** Value integerValue. */ - public integerValue: (number|string); + public integerValue?: (number|string|null); /** Value doubleValue. */ - public doubleValue: number; + public doubleValue?: (number|null); /** Value timestampValue. */ public timestampValue?: (google.protobuf.ITimestamp|null); /** Value stringValue. */ - public stringValue: string; + public stringValue?: (string|null); /** Value bytesValue. */ - public bytesValue: Uint8Array; + public bytesValue?: (Uint8Array|null); /** Value referenceValue. */ - public referenceValue: string; + public referenceValue?: (string|null); /** Value geoPointValue. */ public geoPointValue?: (google.type.ILatLng|null); @@ -3525,7 +3525,7 @@ export namespace google { public mask?: (google.firestore.v1.IDocumentMask|null); /** GetDocumentRequest transaction. */ - public transaction: Uint8Array; + public transaction?: (Uint8Array|null); /** GetDocumentRequest readTime. */ public readTime?: (google.protobuf.ITimestamp|null); @@ -3614,7 +3614,7 @@ export namespace google { public mask?: (google.firestore.v1.IDocumentMask|null); /** ListDocumentsRequest transaction. */ - public transaction: Uint8Array; + public transaction?: (Uint8Array|null); /** ListDocumentsRequest readTime. */ public readTime?: (google.protobuf.ITimestamp|null); @@ -3906,7 +3906,7 @@ export namespace google { public mask?: (google.firestore.v1.IDocumentMask|null); /** BatchGetDocumentsRequest transaction. */ - public transaction: Uint8Array; + public transaction?: (Uint8Array|null); /** BatchGetDocumentsRequest newTransaction. */ public newTransaction?: (google.firestore.v1.ITransactionOptions|null); @@ -3968,7 +3968,7 @@ export namespace google { public found?: (google.firestore.v1.IDocument|null); /** BatchGetDocumentsResponse missing. */ - public missing: string; + public missing?: (string|null); /** BatchGetDocumentsResponse transaction. */ public transaction: Uint8Array; @@ -4271,7 +4271,7 @@ export namespace google { public structuredQuery?: (google.firestore.v1.IStructuredQuery|null); /** RunQueryRequest transaction. */ - public transaction: Uint8Array; + public transaction?: (Uint8Array|null); /** RunQueryRequest newTransaction. */ public newTransaction?: (google.firestore.v1.ITransactionOptions|null); @@ -4637,7 +4637,7 @@ export namespace google { public addTarget?: (google.firestore.v1.ITarget|null); /** ListenRequest removeTarget. */ - public removeTarget: number; + public removeTarget?: (number|null); /** ListenRequest labels. */ public labels: { [k: string]: string }; @@ -4773,7 +4773,7 @@ export namespace google { public documents?: (google.firestore.v1.Target.IDocumentsTarget|null); /** Target resumeToken. */ - public resumeToken: Uint8Array; + public resumeToken?: (Uint8Array|null); /** Target readTime. */ public readTime?: (google.protobuf.ITimestamp|null); @@ -5753,7 +5753,7 @@ export namespace google { public update?: (google.firestore.v1.IDocument|null); /** Write delete. */ - public delete: string; + public delete?: (string|null); /** Write transform. */ public transform?: (google.firestore.v1.IDocumentTransform|null); @@ -5879,7 +5879,7 @@ export namespace google { public fieldPath: string; /** FieldTransform setToServerValue. */ - public setToServerValue: google.firestore.v1.DocumentTransform.FieldTransform.ServerValue; + public setToServerValue?: (google.firestore.v1.DocumentTransform.FieldTransform.ServerValue|null); /** FieldTransform increment. */ public increment?: (google.firestore.v1.IValue|null); @@ -6269,19 +6269,19 @@ export namespace google { constructor(properties?: google.api.IHttpRule); /** HttpRule get. */ - public get: string; + public get?: (string|null); /** HttpRule put. */ - public put: string; + public put?: (string|null); /** HttpRule post. */ - public post: string; + public post?: (string|null); /** HttpRule delete. */ - public delete: string; + public delete?: (string|null); /** HttpRule patch. */ - public patch: string; + public patch?: (string|null); /** HttpRule custom. */ public custom?: (google.api.ICustomHttpPattern|null); diff --git a/types/protos/firestore_v1beta1_proto_api.d.ts b/types/protos/firestore_v1beta1_proto_api.d.ts index 58cea05f6..79b6a4658 100644 --- a/types/protos/firestore_v1beta1_proto_api.d.ts +++ b/types/protos/firestore_v1beta1_proto_api.d.ts @@ -1750,16 +1750,16 @@ export namespace google { constructor(properties?: google.protobuf.IValue); /** Value nullValue. */ - public nullValue: google.protobuf.NullValue; + public nullValue?: (google.protobuf.NullValue|null); /** Value numberValue. */ - public numberValue: number; + public numberValue?: (number|null); /** Value stringValue. */ - public stringValue: string; + public stringValue?: (string|null); /** Value boolValue. */ - public boolValue: boolean; + public boolValue?: (boolean|null); /** Value structValue. */ public structValue?: (google.protobuf.IStruct|null); @@ -2444,7 +2444,7 @@ export namespace google { constructor(properties?: google.firestore.v1beta1.IPrecondition); /** Precondition exists. */ - public exists: boolean; + public exists?: (boolean|null); /** Precondition updateTime. */ public updateTime?: (google.protobuf.ITimestamp|null); @@ -2718,28 +2718,28 @@ export namespace google { constructor(properties?: google.firestore.v1beta1.IValue); /** Value nullValue. */ - public nullValue: google.protobuf.NullValue; + public nullValue?: (google.protobuf.NullValue|null); /** Value booleanValue. */ - public booleanValue: boolean; + public booleanValue?: (boolean|null); /** Value integerValue. */ - public integerValue: (number|string); + public integerValue?: (number|string|null); /** Value doubleValue. */ - public doubleValue: number; + public doubleValue?: (number|null); /** Value timestampValue. */ public timestampValue?: (google.protobuf.ITimestamp|null); /** Value stringValue. */ - public stringValue: string; + public stringValue?: (string|null); /** Value bytesValue. */ - public bytesValue: Uint8Array; + public bytesValue?: (Uint8Array|null); /** Value referenceValue. */ - public referenceValue: string; + public referenceValue?: (string|null); /** Value geoPointValue. */ public geoPointValue?: (google.type.ILatLng|null); @@ -3219,7 +3219,7 @@ export namespace google { public mask?: (google.firestore.v1beta1.IDocumentMask|null); /** GetDocumentRequest transaction. */ - public transaction: Uint8Array; + public transaction?: (Uint8Array|null); /** GetDocumentRequest readTime. */ public readTime?: (google.protobuf.ITimestamp|null); @@ -3308,7 +3308,7 @@ export namespace google { public mask?: (google.firestore.v1beta1.IDocumentMask|null); /** ListDocumentsRequest transaction. */ - public transaction: Uint8Array; + public transaction?: (Uint8Array|null); /** ListDocumentsRequest readTime. */ public readTime?: (google.protobuf.ITimestamp|null); @@ -3600,7 +3600,7 @@ export namespace google { public mask?: (google.firestore.v1beta1.IDocumentMask|null); /** BatchGetDocumentsRequest transaction. */ - public transaction: Uint8Array; + public transaction?: (Uint8Array|null); /** BatchGetDocumentsRequest newTransaction. */ public newTransaction?: (google.firestore.v1beta1.ITransactionOptions|null); @@ -3662,7 +3662,7 @@ export namespace google { public found?: (google.firestore.v1beta1.IDocument|null); /** BatchGetDocumentsResponse missing. */ - public missing: string; + public missing?: (string|null); /** BatchGetDocumentsResponse transaction. */ public transaction: Uint8Array; @@ -3965,7 +3965,7 @@ export namespace google { public structuredQuery?: (google.firestore.v1beta1.IStructuredQuery|null); /** RunQueryRequest transaction. */ - public transaction: Uint8Array; + public transaction?: (Uint8Array|null); /** RunQueryRequest newTransaction. */ public newTransaction?: (google.firestore.v1beta1.ITransactionOptions|null); @@ -4331,7 +4331,7 @@ export namespace google { public addTarget?: (google.firestore.v1beta1.ITarget|null); /** ListenRequest removeTarget. */ - public removeTarget: number; + public removeTarget?: (number|null); /** ListenRequest labels. */ public labels: { [k: string]: string }; @@ -4467,7 +4467,7 @@ export namespace google { public documents?: (google.firestore.v1beta1.Target.IDocumentsTarget|null); /** Target resumeToken. */ - public resumeToken: Uint8Array; + public resumeToken?: (Uint8Array|null); /** Target readTime. */ public readTime?: (google.protobuf.ITimestamp|null); @@ -5447,7 +5447,7 @@ export namespace google { public update?: (google.firestore.v1beta1.IDocument|null); /** Write delete. */ - public delete: string; + public delete?: (string|null); /** Write transform. */ public transform?: (google.firestore.v1beta1.IDocumentTransform|null); @@ -5573,7 +5573,7 @@ export namespace google { public fieldPath: string; /** FieldTransform setToServerValue. */ - public setToServerValue: google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue; + public setToServerValue?: (google.firestore.v1beta1.DocumentTransform.FieldTransform.ServerValue|null); /** FieldTransform increment. */ public increment?: (google.firestore.v1beta1.IValue|null); @@ -5963,19 +5963,19 @@ export namespace google { constructor(properties?: google.api.IHttpRule); /** HttpRule get. */ - public get: string; + public get?: (string|null); /** HttpRule put. */ - public put: string; + public put?: (string|null); /** HttpRule post. */ - public post: string; + public post?: (string|null); /** HttpRule delete. */ - public delete: string; + public delete?: (string|null); /** HttpRule patch. */ - public patch: string; + public patch?: (string|null); /** HttpRule custom. */ public custom?: (google.api.ICustomHttpPattern|null); From 50a521004aa2ef7d75ad0603c510d3bf39568a03 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 13 May 2021 09:50:41 -0700 Subject: [PATCH 288/337] chore: code format (#1502) * changes without context autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. * build: remove codecov action Source-Author: Benjamin E. Coe Source-Date: Tue May 11 17:35:28 2021 -0700 Source-Repo: googleapis/synthtool Source-Sha: b891fb474173f810051a7fdb0d66915e0a9bc82f Source-Link: https://github.com/googleapis/synthtool/commit/b891fb474173f810051a7fdb0d66915e0a9bc82f --- .github/workflows/ci.yaml | 10 - dev/src/backoff.ts | 6 +- dev/src/bulk-writer.ts | 2 +- dev/src/collection-group.ts | 6 +- dev/src/document-change.ts | 3 +- dev/src/document.ts | 10 +- dev/src/index.ts | 7 +- dev/src/query-partition.ts | 3 +- dev/src/recursive-delete.ts | 2 +- dev/src/reference.ts | 26 +-- dev/src/v1/firestore_admin_client.ts | 136 +++++++------- dev/src/v1/firestore_client.ts | 192 +++++++++---------- dev/src/v1beta1/firestore_client.ts | 192 +++++++++---------- dev/src/watch.ts | 8 +- dev/system-test/firestore.ts | 164 ++++++++-------- dev/test/bundle.ts | 5 +- dev/test/collection.ts | 3 +- dev/test/gapic_firestore_admin_v1.ts | 82 ++++---- dev/test/gapic_firestore_v1.ts | 267 ++++++++++++--------------- dev/test/gapic_firestore_v1beta1.ts | 267 ++++++++++++--------------- dev/test/pool.ts | 6 +- dev/test/recursive-delete.ts | 13 +- dev/test/watch.ts | 3 +- synth.metadata | 4 +- 24 files changed, 636 insertions(+), 781 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 891c92531..dbcdc7ce7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,11 +24,6 @@ jobs: - run: rm -rf node_modules - run: npm install - run: npm test - - name: coverage - uses: codecov/codecov-action@v1 - with: - name: actions ${{ matrix.node }} - fail_ci_if_error: false windows: runs-on: windows-latest steps: @@ -38,11 +33,6 @@ jobs: node-version: 14 - run: npm install - run: npm test - - name: coverage - uses: codecov/codecov-action@v1 - with: - name: actions windows - fail_ci_if_error: false lint: runs-on: ubuntu-latest steps: diff --git a/dev/src/backoff.ts b/dev/src/backoff.ts index b7e2669b9..fe7a726d6 100644 --- a/dev/src/backoff.ts +++ b/dev/src/backoff.ts @@ -57,10 +57,8 @@ export const MAX_RETRY_ATTEMPTS = 10; /*! * The timeout handler used by `ExponentialBackoff` and `BulkWriter`. */ -export let delayExecution: ( - f: () => void, - ms: number -) => NodeJS.Timeout = setTimeout; +export let delayExecution: (f: () => void, ms: number) => NodeJS.Timeout = + setTimeout; /** * Allows overriding of the timeout handler used by the exponential backoff diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 72c3b2949..b774d0ac4 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -138,7 +138,7 @@ class BulkWriterOperation { try { const bulkWriterError = new BulkWriterError( - (error.code as number) as GrpcStatus, + error.code as number as GrpcStatus, error.message, this.ref, this.type, diff --git a/dev/src/collection-group.ts b/dev/src/collection-group.ts index f3b2537db..70a371937 100644 --- a/dev/src/collection-group.ts +++ b/dev/src/collection-group.ts @@ -36,7 +36,8 @@ import {defaultConverter} from './types'; */ export class CollectionGroup extends Query - implements firestore.CollectionGroup { + implements firestore.CollectionGroup +{ /** @hideconstructor */ constructor( firestore: Firestore, @@ -84,7 +85,8 @@ export class CollectionGroup if (desiredPartitionCount > 1) { // Partition queries require explicit ordering by __name__. const queryWithDefaultOrder = this.orderBy(FieldPath.documentId()); - const request: api.IPartitionQueryRequest = queryWithDefaultOrder.toProto(); + const request: api.IPartitionQueryRequest = + queryWithDefaultOrder.toProto(); // Since we are always returning an extra partition (with an empty endBefore // cursor), we reduce the desired partition count by one. diff --git a/dev/src/document-change.ts b/dev/src/document-change.ts index 57595b8b2..b4dcb2f0a 100644 --- a/dev/src/document-change.ts +++ b/dev/src/document-change.ts @@ -27,7 +27,8 @@ export type DocumentChangeType = 'added' | 'removed' | 'modified'; * @class DocumentChange */ export class DocumentChange - implements firestore.DocumentChange { + implements firestore.DocumentChange +{ private readonly _type: DocumentChangeType; private readonly _document: QueryDocumentSnapshot; private readonly _oldIndex: number; diff --git a/dev/src/document.ts b/dev/src/document.ts index ca73ce2c9..9eee75dbc 100644 --- a/dev/src/document.ts +++ b/dev/src/document.ts @@ -97,7 +97,8 @@ export class DocumentSnapshotBuilder { * @class DocumentSnapshot */ export class DocumentSnapshot - implements firestore.DocumentSnapshot { + implements firestore.DocumentSnapshot +{ private _ref: DocumentReference; private _serializer: Serializer; private _readTime: Timestamp | undefined; @@ -539,7 +540,8 @@ export class DocumentSnapshot */ export class QueryDocumentSnapshot extends DocumentSnapshot - implements firestore.QueryDocumentSnapshot { + implements firestore.QueryDocumentSnapshot +{ /** * The time the document was created. * @@ -984,8 +986,8 @@ export class DocumentTransform { * @private */ validate(): void { - const allowUndefined = !!this.ref.firestore._settings - .ignoreUndefinedProperties; + const allowUndefined = + !!this.ref.firestore._settings.ignoreUndefinedProperties; this.transforms.forEach(transform => transform.validate(allowUndefined)); } diff --git a/dev/src/index.ts b/dev/src/index.ts index 8742429a7..d8127fcc7 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -1542,10 +1542,9 @@ export class Firestore implements firestore.Firestore { return this._clientPool.run(requestTag, async gapicClient => { try { logger('Firestore.request', requestTag, 'Sending request: %j', request); - const [result] = await (gapicClient[methodName] as UnaryMethod< - Req, - Resp - >)(request, callOptions); + const [result] = await ( + gapicClient[methodName] as UnaryMethod + )(request, callOptions); logger( 'Firestore.request', requestTag, diff --git a/dev/src/query-partition.ts b/dev/src/query-partition.ts index 34cb21a97..bc28f0044 100644 --- a/dev/src/query-partition.ts +++ b/dev/src/query-partition.ts @@ -33,7 +33,8 @@ import api = protos.google.firestore.v1; * @class QueryPartition */ export class QueryPartition - implements firestore.QueryPartition { + implements firestore.QueryPartition +{ private readonly _serializer: Serializer; private _memoizedStartAt: unknown[] | undefined; private _memoizedEndBefore: unknown[] | undefined; diff --git a/dev/src/recursive-delete.ts b/dev/src/recursive-delete.ts index 5aeecfd20..dd14ed949 100644 --- a/dev/src/recursive-delete.ts +++ b/dev/src/recursive-delete.ts @@ -264,7 +264,7 @@ export class RecursiveDelete { 'failed. The last delete failed with: ' ); if (this.lastError.code !== undefined) { - error.code = (this.lastError.code as number) as Status; + error.code = this.lastError.code as number as Status; } error = wrapError(error, this.errorStack); diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 06283c4b0..6ce5920a4 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -123,7 +123,8 @@ const comparisonOperators: { * @class DocumentReference */ export class DocumentReference - implements Serializable, firestore.DocumentReference { + implements Serializable, firestore.DocumentReference +{ /** * @hideconstructor * @@ -736,7 +737,8 @@ class FieldFilter { * @class QuerySnapshot */ export class QuerySnapshot - implements firestore.QuerySnapshot { + implements firestore.QuerySnapshot +{ private _materializedDocs: Array> | null = null; private _materializedChanges: Array> | null = null; private _docs: (() => Array>) | null = null; @@ -1167,8 +1169,8 @@ export class Query implements firestore.Query { protected readonly _queryOptions: QueryOptions ) { this._serializer = new Serializer(_firestore); - this._allowUndefined = !!this._firestore._settings - .ignoreUndefinedProperties; + this._allowUndefined = + !!this._firestore._settings.ignoreUndefinedProperties; } /** @@ -1989,9 +1991,8 @@ export class Query implements firestore.Query { transactionIdOrReadTime?: Uint8Array | Timestamp ): api.IRunQueryRequest { const projectId = this.firestore.projectId; - const parentPath = this._queryOptions.parentPath.toQualifiedResourcePath( - projectId - ); + const parentPath = + this._queryOptions.parentPath.toQualifiedResourcePath(projectId); const structuredQuery = this.toStructuredQuery(); @@ -2034,7 +2035,8 @@ export class Query implements firestore.Query { if (transactionIdOrReadTime instanceof Uint8Array) { runQueryRequest.transaction = transactionIdOrReadTime; } else if (transactionIdOrReadTime instanceof Timestamp) { - runQueryRequest.readTime = transactionIdOrReadTime.toProto().timestampValue; + runQueryRequest.readTime = + transactionIdOrReadTime.toProto().timestampValue; } return runQueryRequest; @@ -2047,9 +2049,8 @@ export class Query implements firestore.Query { */ _toBundledQuery(): protos.firestore.IBundledQuery { const projectId = this.firestore.projectId; - const parentPath = this._queryOptions.parentPath.toQualifiedResourcePath( - projectId - ); + const parentPath = + this._queryOptions.parentPath.toQualifiedResourcePath(projectId); const structuredQuery = this.toStructuredQuery(); const bundledQuery: protos.firestore.IBundledQuery = { @@ -2376,7 +2377,8 @@ export class Query implements firestore.Query { */ export class CollectionReference extends Query - implements firestore.CollectionReference { + implements firestore.CollectionReference +{ /** * @hideconstructor * diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index 49d40f5b7..4d5812dfe 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -303,13 +303,14 @@ export class FirestoreAdminClient { ]; for (const methodName of firestoreAdminStubMethods) { const callPromise = this.firestoreAdminStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, + stub => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, (err: Error | null | undefined) => () => { throw err; } @@ -464,11 +465,10 @@ export class FirestoreAdminClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.getIndex(request, options, callback); } @@ -551,11 +551,10 @@ export class FirestoreAdminClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.deleteIndex(request, options, callback); } @@ -636,11 +635,10 @@ export class FirestoreAdminClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.getField(request, options, callback); } @@ -747,11 +745,10 @@ export class FirestoreAdminClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.createIndex(request, options, callback); } @@ -904,11 +901,10 @@ export class FirestoreAdminClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'field.name': request.field!.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + 'field.name': request.field!.name || '', + }); this.initialize(); return this.innerApiCalls.updateField(request, options, callback); } @@ -1065,11 +1061,10 @@ export class FirestoreAdminClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.exportDocuments(request, options, callback); } @@ -1221,11 +1216,10 @@ export class FirestoreAdminClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.importDocuments(request, options, callback); } @@ -1356,11 +1350,10 @@ export class FirestoreAdminClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listIndexes(request, options, callback); } @@ -1400,11 +1393,10 @@ export class FirestoreAdminClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listIndexes.createStream( @@ -1455,17 +1447,16 @@ export class FirestoreAdminClient { 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.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'] as GaxCall, - (request as unknown) as RequestType, + request as unknown as RequestType, callSettings ) as AsyncIterable; } @@ -1568,11 +1559,10 @@ export class FirestoreAdminClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listFields(request, options, callback); } @@ -1616,11 +1606,10 @@ export class FirestoreAdminClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listFields.createStream( @@ -1675,17 +1664,16 @@ export class FirestoreAdminClient { 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.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'] as GaxCall, - (request as unknown) as RequestType, + request as unknown as RequestType, callSettings ) as AsyncIterable; } diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index d0de5245a..6b3406748 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -256,13 +256,14 @@ export class FirestoreClient { ]; for (const methodName of firestoreStubMethods) { const callPromise = this.firestoreStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, + stub => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, (err: Error | null | undefined) => () => { throw err; } @@ -427,11 +428,10 @@ export class FirestoreClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.getDocument(request, options, callback); } @@ -528,11 +528,10 @@ export class FirestoreClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'document.name': request.document!.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + 'document.name': request.document!.name || '', + }); this.initialize(); return this.innerApiCalls.updateDocument(request, options, callback); } @@ -616,11 +615,10 @@ export class FirestoreClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.deleteDocument(request, options, callback); } @@ -706,11 +704,10 @@ export class FirestoreClient { 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 || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + database: request.database || '', + }); this.initialize(); return this.innerApiCalls.beginTransaction(request, options, callback); } @@ -797,11 +794,10 @@ export class FirestoreClient { 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 || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + database: request.database || '', + }); this.initialize(); return this.innerApiCalls.commit(request, options, callback); } @@ -884,11 +880,10 @@ export class FirestoreClient { 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 || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + database: request.database || '', + }); this.initialize(); return this.innerApiCalls.rollback(request, options, callback); } @@ -985,11 +980,10 @@ export class FirestoreClient { 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 || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + database: request.database || '', + }); this.initialize(); return this.innerApiCalls.batchWrite(request, options, callback); } @@ -1084,11 +1078,10 @@ export class FirestoreClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.createDocument(request, options, callback); } @@ -1144,11 +1137,10 @@ export class FirestoreClient { 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 || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + database: request.database || '', + }); this.initialize(); return this.innerApiCalls.batchGetDocuments(request, options); } @@ -1197,11 +1189,10 @@ export class FirestoreClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.runQuery(request, options); } @@ -1365,11 +1356,10 @@ export class FirestoreClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listDocuments(request, options, callback); } @@ -1432,11 +1422,10 @@ export class FirestoreClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listDocuments.createStream( @@ -1510,17 +1499,16 @@ export class FirestoreClient { 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.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'] as GaxCall, - (request as unknown) as RequestType, + request as unknown as RequestType, callSettings ) as AsyncIterable; } @@ -1644,11 +1632,10 @@ export class FirestoreClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.partitionQuery(request, options, callback); } @@ -1718,11 +1705,10 @@ export class FirestoreClient { 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.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( @@ -1803,17 +1789,16 @@ export class FirestoreClient { 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.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'] as GaxCall, - (request as unknown) as RequestType, + request as unknown as RequestType, callSettings ) as AsyncIterable; } @@ -1906,11 +1891,10 @@ export class FirestoreClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listCollectionIds(request, options, callback); } @@ -1949,11 +1933,10 @@ export class FirestoreClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listCollectionIds.createStream( @@ -2003,17 +1986,16 @@ export class FirestoreClient { 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.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'] as GaxCall, - (request as unknown) as RequestType, + request as unknown as RequestType, callSettings ) as AsyncIterable; } diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index 3ed8d880d..c5b016087 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -259,13 +259,14 @@ export class FirestoreClient { ]; for (const methodName of firestoreStubMethods) { const callPromise = this.firestoreStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, + stub => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, (err: Error | null | undefined) => () => { throw err; } @@ -432,11 +433,10 @@ export class FirestoreClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.getDocument(request, options, callback); } @@ -535,11 +535,10 @@ export class FirestoreClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'document.name': request.document!.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + 'document.name': request.document!.name || '', + }); this.initialize(); return this.innerApiCalls.updateDocument(request, options, callback); } @@ -625,11 +624,10 @@ export class FirestoreClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.deleteDocument(request, options, callback); } @@ -721,11 +719,10 @@ export class FirestoreClient { 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 || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + database: request.database || '', + }); this.initialize(); return this.innerApiCalls.beginTransaction(request, options, callback); } @@ -812,11 +809,10 @@ export class FirestoreClient { 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 || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + database: request.database || '', + }); this.initialize(); return this.innerApiCalls.commit(request, options, callback); } @@ -899,11 +895,10 @@ export class FirestoreClient { 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 || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + database: request.database || '', + }); this.initialize(); return this.innerApiCalls.rollback(request, options, callback); } @@ -1000,11 +995,10 @@ export class FirestoreClient { 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 || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + database: request.database || '', + }); this.initialize(); return this.innerApiCalls.batchWrite(request, options, callback); } @@ -1101,11 +1095,10 @@ export class FirestoreClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.createDocument(request, options, callback); } @@ -1161,11 +1154,10 @@ export class FirestoreClient { 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 || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + database: request.database || '', + }); this.initialize(); return this.innerApiCalls.batchGetDocuments(request, options); } @@ -1214,11 +1206,10 @@ export class FirestoreClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.runQuery(request, options); } @@ -1384,11 +1375,10 @@ export class FirestoreClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listDocuments(request, options, callback); } @@ -1451,11 +1441,10 @@ export class FirestoreClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listDocuments.createStream( @@ -1529,17 +1518,16 @@ export class FirestoreClient { 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.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'] as GaxCall, - (request as unknown) as RequestType, + request as unknown as RequestType, callSettings ) as AsyncIterable; } @@ -1671,11 +1659,10 @@ export class FirestoreClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.partitionQuery(request, options, callback); } @@ -1745,11 +1732,10 @@ export class FirestoreClient { 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.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( @@ -1830,17 +1816,16 @@ export class FirestoreClient { 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.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'] as GaxCall, - (request as unknown) as RequestType, + request as unknown as RequestType, callSettings ) as AsyncIterable; } @@ -1939,11 +1924,10 @@ export class FirestoreClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listCollectionIds(request, options, callback); } @@ -1982,11 +1966,10 @@ export class FirestoreClient { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listCollectionIds.createStream( @@ -2036,17 +2019,16 @@ export class FirestoreClient { 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.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'] as GaxCall, - (request as unknown) as RequestType, + request as unknown as RequestType, callSettings ) as AsyncIterable; } diff --git a/dev/src/watch.ts b/dev/src/watch.ts index 23b1b6f69..6264b2d5d 100644 --- a/dev/src/watch.ts +++ b/dev/src/watch.ts @@ -544,8 +544,8 @@ abstract class Watch { const document = proto.documentChange.document!; const name = document.name!; - const relativeName = QualifiedResourcePath.fromSlashSeparatedString(name) - .relativeName; + const relativeName = + QualifiedResourcePath.fromSlashSeparatedString(name).relativeName; if (changed) { logger('Watch.onData', this.requestTag, 'Received document change'); @@ -564,8 +564,8 @@ abstract class Watch { } else if (proto.documentDelete || proto.documentRemove) { logger('Watch.onData', this.requestTag, 'Processing remove event'); const name = (proto.documentDelete || proto.documentRemove)!.document!; - const relativeName = QualifiedResourcePath.fromSlashSeparatedString(name) - .relativeName; + const relativeName = + QualifiedResourcePath.fromSlashSeparatedString(name).relativeName; this.changeMap.set(relativeName, REMOVED as DocumentSnapshotBuilder); } else if (proto.filter) { logger('Watch.onData', this.requestTag, 'Processing filter update'); diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 77922d4cd..70e5a9517 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -287,9 +287,8 @@ describe('CollectionGroup class', () => { }); it('partition query with converter', async () => { - const collectionGroupWithConverter = collectionGroup.withConverter( - postConverter - ); + const collectionGroupWithConverter = + collectionGroup.withConverter(postConverter); const partitions = await getPartitions( collectionGroupWithConverter, desiredPartitionCount @@ -2750,85 +2749,88 @@ describe('BulkWriter class', () => { }); describe('Client initialization', () => { - const ops: Array< - [string, (coll: CollectionReference) => Promise] - > = [ - ['CollectionReference.get()', randomColl => randomColl.get()], - ['CollectionReference.add()', randomColl => randomColl.add({})], - [ - 'CollectionReference.stream()', - randomColl => { - const deferred = new Deferred(); - randomColl.stream().on('finish', () => { - deferred.resolve(); - }); - return deferred.promise; - }, - ], - [ - 'CollectionReference.listDocuments()', - randomColl => randomColl.listDocuments(), - ], - [ - 'CollectionReference.onSnapshot()', - randomColl => { - const deferred = new Deferred(); - const unsubscribe = randomColl.onSnapshot(() => { - unsubscribe(); - deferred.resolve(); - }); - return deferred.promise; - }, - ], - ['DocumentReference.get()', randomColl => randomColl.doc().get()], - ['DocumentReference.create()', randomColl => randomColl.doc().create({})], - ['DocumentReference.set()', randomColl => randomColl.doc().set({})], - [ - 'DocumentReference.update()', - async randomColl => { - const update = randomColl.doc().update('foo', 'bar'); - await expect(update).to.eventually.be.rejectedWith( - 'No document to update' - ); - }, - ], - ['DocumentReference.delete()', randomColl => randomColl.doc().delete()], - [ - 'DocumentReference.listCollections()', - randomColl => randomColl.doc().listCollections(), - ], - [ - 'DocumentReference.onSnapshot()', - randomColl => { - const deferred = new Deferred(); - const unsubscribe = randomColl.doc().onSnapshot(() => { - unsubscribe(); - deferred.resolve(); - }); - return deferred.promise; - }, - ], - [ - 'CollectionGroup.getPartitions()', - async randomColl => { - const partitions = randomColl.firestore - .collectionGroup('id') - .getPartitions(2); - // eslint-disable-next-line @typescript-eslint/no-unused-vars - for await (const _ of partitions); - }, - ], + const ops: Array<[string, (coll: CollectionReference) => Promise]> = [ - 'Firestore.runTransaction()', - randomColl => randomColl.firestore.runTransaction(t => t.get(randomColl)), - ], - [ - 'Firestore.getAll()', - randomColl => randomColl.firestore.getAll(randomColl.doc()), - ], - ['Firestore.batch()', randomColl => randomColl.firestore.batch().commit()], - ['Firestore.terminate()', randomColl => randomColl.firestore.terminate()], - ]; + ['CollectionReference.get()', randomColl => randomColl.get()], + ['CollectionReference.add()', randomColl => randomColl.add({})], + [ + 'CollectionReference.stream()', + randomColl => { + const deferred = new Deferred(); + randomColl.stream().on('finish', () => { + deferred.resolve(); + }); + return deferred.promise; + }, + ], + [ + 'CollectionReference.listDocuments()', + randomColl => randomColl.listDocuments(), + ], + [ + 'CollectionReference.onSnapshot()', + randomColl => { + const deferred = new Deferred(); + const unsubscribe = randomColl.onSnapshot(() => { + unsubscribe(); + deferred.resolve(); + }); + return deferred.promise; + }, + ], + ['DocumentReference.get()', randomColl => randomColl.doc().get()], + ['DocumentReference.create()', randomColl => randomColl.doc().create({})], + ['DocumentReference.set()', randomColl => randomColl.doc().set({})], + [ + 'DocumentReference.update()', + async randomColl => { + const update = randomColl.doc().update('foo', 'bar'); + await expect(update).to.eventually.be.rejectedWith( + 'No document to update' + ); + }, + ], + ['DocumentReference.delete()', randomColl => randomColl.doc().delete()], + [ + 'DocumentReference.listCollections()', + randomColl => randomColl.doc().listCollections(), + ], + [ + 'DocumentReference.onSnapshot()', + randomColl => { + const deferred = new Deferred(); + const unsubscribe = randomColl.doc().onSnapshot(() => { + unsubscribe(); + deferred.resolve(); + }); + return deferred.promise; + }, + ], + [ + 'CollectionGroup.getPartitions()', + async randomColl => { + const partitions = randomColl.firestore + .collectionGroup('id') + .getPartitions(2); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + for await (const _ of partitions); + }, + ], + [ + 'Firestore.runTransaction()', + randomColl => + randomColl.firestore.runTransaction(t => t.get(randomColl)), + ], + [ + 'Firestore.getAll()', + randomColl => randomColl.firestore.getAll(randomColl.doc()), + ], + [ + 'Firestore.batch()', + randomColl => randomColl.firestore.batch().commit(), + ], + ['Firestore.terminate()', randomColl => randomColl.firestore.terminate()], + ]; for (const [description, op] of ops) { it(`succeeds for ${description}`, () => { diff --git a/dev/test/bundle.ts b/dev/test/bundle.ts index 3f1f11792..59617ce65 100644 --- a/dev/test/bundle.ts +++ b/dev/test/bundle.ts @@ -169,8 +169,9 @@ describe('Bundle Builder', () => { ); // Verify named query - const namedQuery = elements.find(e => e.namedQuery?.name === 'test-query')! - .namedQuery; + const namedQuery = elements.find( + e => e.namedQuery?.name === 'test-query' + )!.namedQuery; const newNamedQuery = elements.find( e => e.namedQuery?.name === 'test-query-new' )!.namedQuery; diff --git a/dev/test/collection.ts b/dev/test/collection.ts index fb46e925d..c2d5b845e 100644 --- a/dev/test/collection.ts +++ b/dev/test/collection.ts @@ -99,7 +99,8 @@ describe('Collection interface', () => { const overrides: ApiOverride = { commit: request => { // Verify that the document name uses an auto-generated id. - const docIdRe = /^projects\/test-project\/databases\/\(default\)\/documents\/collectionId\/[a-zA-Z0-9]{20}$/; + const docIdRe = + /^projects\/test-project\/databases\/\(default\)\/documents\/collectionId\/[a-zA-Z0-9]{20}$/; expect(request.writes![0].update!.name).to.match(docIdRe); delete request.writes![0].update!.name; diff --git a/dev/test/gapic_firestore_admin_v1.ts b/dev/test/gapic_firestore_admin_v1.ts index b33525580..85d34175c 100644 --- a/dev/test/gapic_firestore_admin_v1.ts +++ b/dev/test/gapic_firestore_admin_v1.ts @@ -28,10 +28,9 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message).toObject( - instance as protobuf.Message, - {defaults: true} - ); + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); return (instance.constructor as typeof protobuf.Message).fromObject( filledObject ) as T; @@ -279,9 +278,8 @@ describe('v1.FirestoreAdminClient', () => { const expectedResponse = generateSampleMessage( new protos.google.firestore.admin.v1.Index() ); - client.innerApiCalls.getIndex = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.getIndex = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.getIndex( request, @@ -388,9 +386,8 @@ describe('v1.FirestoreAdminClient', () => { const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); - client.innerApiCalls.deleteIndex = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.deleteIndex = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.deleteIndex( request, @@ -500,9 +497,8 @@ describe('v1.FirestoreAdminClient', () => { const expectedResponse = generateSampleMessage( new protos.google.firestore.admin.v1.Field() ); - client.innerApiCalls.getField = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.getField = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.getField( request, @@ -610,9 +606,8 @@ describe('v1.FirestoreAdminClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.createIndex = stubLongRunningCallWithCallback( - expectedResponse - ); + client.innerApiCalls.createIndex = + stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.createIndex( request, @@ -803,9 +798,8 @@ describe('v1.FirestoreAdminClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.updateField = stubLongRunningCallWithCallback( - expectedResponse - ); + client.innerApiCalls.updateField = + stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.updateField( request, @@ -964,9 +958,8 @@ describe('v1.FirestoreAdminClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.exportDocuments = stubLongRunningCall( - expectedResponse - ); + client.innerApiCalls.exportDocuments = + stubLongRunningCall(expectedResponse); const [operation] = await client.exportDocuments(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); @@ -998,9 +991,8 @@ describe('v1.FirestoreAdminClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.exportDocuments = stubLongRunningCallWithCallback( - expectedResponse - ); + client.innerApiCalls.exportDocuments = + stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.exportDocuments( request, @@ -1160,9 +1152,8 @@ describe('v1.FirestoreAdminClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.importDocuments = stubLongRunningCall( - expectedResponse - ); + client.innerApiCalls.importDocuments = + stubLongRunningCall(expectedResponse); const [operation] = await client.importDocuments(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); @@ -1194,9 +1185,8 @@ describe('v1.FirestoreAdminClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.importDocuments = stubLongRunningCallWithCallback( - expectedResponse - ); + client.innerApiCalls.importDocuments = + stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.importDocuments( request, @@ -1391,9 +1381,8 @@ describe('v1.FirestoreAdminClient', () => { generateSampleMessage(new protos.google.firestore.admin.v1.Index()), generateSampleMessage(new protos.google.firestore.admin.v1.Index()), ]; - client.innerApiCalls.listIndexes = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.listIndexes = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.listIndexes( request, @@ -1465,9 +1454,8 @@ describe('v1.FirestoreAdminClient', () => { generateSampleMessage(new protos.google.firestore.admin.v1.Index()), generateSampleMessage(new protos.google.firestore.admin.v1.Index()), ]; - client.descriptors.page.listIndexes.createStream = stubPageStreamingCall( - expectedResponse - ); + client.descriptors.page.listIndexes.createStream = + stubPageStreamingCall(expectedResponse); const stream = client.listIndexesStream(request); const promise = new Promise((resolve, reject) => { const responses: protos.google.firestore.admin.v1.Index[] = []; @@ -1561,9 +1549,8 @@ describe('v1.FirestoreAdminClient', () => { generateSampleMessage(new protos.google.firestore.admin.v1.Index()), generateSampleMessage(new protos.google.firestore.admin.v1.Index()), ]; - client.descriptors.page.listIndexes.asyncIterate = stubAsyncIterationCall( - expectedResponse - ); + client.descriptors.page.listIndexes.asyncIterate = + stubAsyncIterationCall(expectedResponse); const responses: protos.google.firestore.admin.v1.IIndex[] = []; const iterable = client.listIndexesAsync(request); for await (const resource of iterable) { @@ -1679,9 +1666,8 @@ describe('v1.FirestoreAdminClient', () => { generateSampleMessage(new protos.google.firestore.admin.v1.Field()), generateSampleMessage(new protos.google.firestore.admin.v1.Field()), ]; - client.innerApiCalls.listFields = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.listFields = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.listFields( request, @@ -1753,9 +1739,8 @@ describe('v1.FirestoreAdminClient', () => { generateSampleMessage(new protos.google.firestore.admin.v1.Field()), generateSampleMessage(new protos.google.firestore.admin.v1.Field()), ]; - client.descriptors.page.listFields.createStream = stubPageStreamingCall( - expectedResponse - ); + client.descriptors.page.listFields.createStream = + stubPageStreamingCall(expectedResponse); const stream = client.listFieldsStream(request); const promise = new Promise((resolve, reject) => { const responses: protos.google.firestore.admin.v1.Field[] = []; @@ -1849,9 +1834,8 @@ describe('v1.FirestoreAdminClient', () => { generateSampleMessage(new protos.google.firestore.admin.v1.Field()), generateSampleMessage(new protos.google.firestore.admin.v1.Field()), ]; - client.descriptors.page.listFields.asyncIterate = stubAsyncIterationCall( - expectedResponse - ); + client.descriptors.page.listFields.asyncIterate = + stubAsyncIterationCall(expectedResponse); const responses: protos.google.firestore.admin.v1.IField[] = []; const iterable = client.listFieldsAsync(request); for await (const resource of iterable) { diff --git a/dev/test/gapic_firestore_v1.ts b/dev/test/gapic_firestore_v1.ts index 0b53c4062..79e305af4 100644 --- a/dev/test/gapic_firestore_v1.ts +++ b/dev/test/gapic_firestore_v1.ts @@ -28,10 +28,9 @@ import {PassThrough} from 'stream'; import {protobuf} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message).toObject( - instance as protobuf.Message, - {defaults: true} - ); + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); return (instance.constructor as typeof protobuf.Message).fromObject( filledObject ) as T; @@ -282,9 +281,8 @@ describe('v1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.firestore.v1.Document() ); - client.innerApiCalls.getDocument = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.getDocument = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.getDocument( request, @@ -396,9 +394,8 @@ describe('v1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.firestore.v1.Document() ); - client.innerApiCalls.updateDocument = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.updateDocument = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.updateDocument( request, @@ -509,9 +506,8 @@ describe('v1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); - client.innerApiCalls.deleteDocument = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.deleteDocument = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.deleteDocument( request, @@ -621,9 +617,8 @@ describe('v1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.firestore.v1.BeginTransactionResponse() ); - client.innerApiCalls.beginTransaction = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.beginTransaction = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.beginTransaction( request, @@ -733,9 +728,8 @@ describe('v1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.firestore.v1.CommitResponse() ); - client.innerApiCalls.commit = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.commit = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.commit( request, @@ -842,9 +836,8 @@ describe('v1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); - client.innerApiCalls.rollback = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.rollback = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.rollback( request, @@ -951,9 +944,8 @@ describe('v1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.firestore.v1.BatchWriteResponse() ); - client.innerApiCalls.batchWrite = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.batchWrite = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.batchWrite( request, @@ -1063,9 +1055,8 @@ describe('v1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.firestore.v1.Document() ); - client.innerApiCalls.createDocument = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.createDocument = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.createDocument( request, @@ -1144,9 +1135,8 @@ describe('v1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.firestore.v1.BatchGetDocumentsResponse() ); - client.innerApiCalls.batchGetDocuments = stubServerStreamingCall( - expectedResponse - ); + client.innerApiCalls.batchGetDocuments = + stubServerStreamingCall(expectedResponse); const stream = client.batchGetDocuments(request); const promise = new Promise((resolve, reject) => { stream.on( @@ -1336,9 +1326,8 @@ describe('v1.FirestoreClient', () => { .calledWithExactly({}, undefined) ); assert.deepStrictEqual( - (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( - 0 - ).args[0], + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], request ); }); @@ -1380,9 +1369,8 @@ describe('v1.FirestoreClient', () => { .calledWithExactly({}, undefined) ); assert.deepStrictEqual( - (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( - 0 - ).args[0], + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], request ); }); @@ -1424,9 +1412,8 @@ describe('v1.FirestoreClient', () => { .calledWithExactly({}, undefined) ); assert.deepStrictEqual( - (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( - 0 - ).args[0], + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], request ); }); @@ -1468,9 +1455,8 @@ describe('v1.FirestoreClient', () => { .calledWithExactly({}, undefined) ); assert.deepStrictEqual( - (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( - 0 - ).args[0], + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], request ); }); @@ -1533,9 +1519,8 @@ describe('v1.FirestoreClient', () => { generateSampleMessage(new protos.google.firestore.v1.Document()), generateSampleMessage(new protos.google.firestore.v1.Document()), ]; - client.innerApiCalls.listDocuments = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.listDocuments = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.listDocuments( request, @@ -1607,9 +1592,8 @@ describe('v1.FirestoreClient', () => { generateSampleMessage(new protos.google.firestore.v1.Document()), generateSampleMessage(new protos.google.firestore.v1.Document()), ]; - client.descriptors.page.listDocuments.createStream = stubPageStreamingCall( - expectedResponse - ); + client.descriptors.page.listDocuments.createStream = + stubPageStreamingCall(expectedResponse); const stream = client.listDocumentsStream(request); const promise = new Promise((resolve, reject) => { const responses: protos.google.firestore.v1.Document[] = []; @@ -1631,10 +1615,9 @@ describe('v1.FirestoreClient', () => { .calledWith(client.innerApiCalls.listDocuments, request) ); assert.strictEqual( - (client.descriptors.page.listDocuments - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listDocuments.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1651,10 +1634,8 @@ describe('v1.FirestoreClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.listDocuments.createStream = stubPageStreamingCall( - undefined, - expectedError - ); + client.descriptors.page.listDocuments.createStream = + stubPageStreamingCall(undefined, expectedError); const stream = client.listDocumentsStream(request); const promise = new Promise((resolve, reject) => { const responses: protos.google.firestore.v1.Document[] = []; @@ -1675,10 +1656,9 @@ describe('v1.FirestoreClient', () => { .calledWith(client.innerApiCalls.listDocuments, request) ); assert.strictEqual( - (client.descriptors.page.listDocuments - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listDocuments.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1699,9 +1679,8 @@ describe('v1.FirestoreClient', () => { generateSampleMessage(new protos.google.firestore.v1.Document()), generateSampleMessage(new protos.google.firestore.v1.Document()), ]; - client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall( - expectedResponse - ); + client.descriptors.page.listDocuments.asyncIterate = + stubAsyncIterationCall(expectedResponse); const responses: protos.google.firestore.v1.IDocument[] = []; const iterable = client.listDocumentsAsync(request); for await (const resource of iterable) { @@ -1709,15 +1688,15 @@ describe('v1.FirestoreClient', () => { } assert.deepStrictEqual(responses, expectedResponse); assert.deepStrictEqual( - (client.descriptors.page.listDocuments - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.listDocuments.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.listDocuments - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listDocuments.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1734,10 +1713,8 @@ describe('v1.FirestoreClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall( - undefined, - expectedError - ); + client.descriptors.page.listDocuments.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); const iterable = client.listDocumentsAsync(request); await assert.rejects(async () => { const responses: protos.google.firestore.v1.IDocument[] = []; @@ -1746,15 +1723,15 @@ describe('v1.FirestoreClient', () => { } }); assert.deepStrictEqual( - (client.descriptors.page.listDocuments - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.listDocuments.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.listDocuments - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listDocuments.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1817,9 +1794,8 @@ describe('v1.FirestoreClient', () => { generateSampleMessage(new protos.google.firestore.v1.Cursor()), generateSampleMessage(new protos.google.firestore.v1.Cursor()), ]; - client.innerApiCalls.partitionQuery = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.partitionQuery = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.partitionQuery( request, @@ -1891,9 +1867,8 @@ describe('v1.FirestoreClient', () => { generateSampleMessage(new protos.google.firestore.v1.Cursor()), generateSampleMessage(new protos.google.firestore.v1.Cursor()), ]; - client.descriptors.page.partitionQuery.createStream = stubPageStreamingCall( - expectedResponse - ); + client.descriptors.page.partitionQuery.createStream = + stubPageStreamingCall(expectedResponse); const stream = client.partitionQueryStream(request); const promise = new Promise((resolve, reject) => { const responses: protos.google.firestore.v1.Cursor[] = []; @@ -1915,10 +1890,9 @@ describe('v1.FirestoreClient', () => { .calledWith(client.innerApiCalls.partitionQuery, request) ); assert.strictEqual( - (client.descriptors.page.partitionQuery - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.partitionQuery.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1935,10 +1909,8 @@ describe('v1.FirestoreClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.partitionQuery.createStream = stubPageStreamingCall( - undefined, - expectedError - ); + client.descriptors.page.partitionQuery.createStream = + stubPageStreamingCall(undefined, expectedError); const stream = client.partitionQueryStream(request); const promise = new Promise((resolve, reject) => { const responses: protos.google.firestore.v1.Cursor[] = []; @@ -1959,10 +1931,9 @@ describe('v1.FirestoreClient', () => { .calledWith(client.innerApiCalls.partitionQuery, request) ); assert.strictEqual( - (client.descriptors.page.partitionQuery - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.partitionQuery.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1983,9 +1954,8 @@ describe('v1.FirestoreClient', () => { generateSampleMessage(new protos.google.firestore.v1.Cursor()), generateSampleMessage(new protos.google.firestore.v1.Cursor()), ]; - client.descriptors.page.partitionQuery.asyncIterate = stubAsyncIterationCall( - expectedResponse - ); + client.descriptors.page.partitionQuery.asyncIterate = + stubAsyncIterationCall(expectedResponse); const responses: protos.google.firestore.v1.ICursor[] = []; const iterable = client.partitionQueryAsync(request); for await (const resource of iterable) { @@ -1993,15 +1963,15 @@ describe('v1.FirestoreClient', () => { } assert.deepStrictEqual(responses, expectedResponse); assert.deepStrictEqual( - (client.descriptors.page.partitionQuery - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.partitionQuery.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.partitionQuery - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.partitionQuery.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -2018,10 +1988,8 @@ describe('v1.FirestoreClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.partitionQuery.asyncIterate = stubAsyncIterationCall( - undefined, - expectedError - ); + client.descriptors.page.partitionQuery.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); const iterable = client.partitionQueryAsync(request); await assert.rejects(async () => { const responses: protos.google.firestore.v1.ICursor[] = []; @@ -2030,15 +1998,15 @@ describe('v1.FirestoreClient', () => { } }); assert.deepStrictEqual( - (client.descriptors.page.partitionQuery - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.partitionQuery.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.partitionQuery - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.partitionQuery.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -2093,9 +2061,8 @@ describe('v1.FirestoreClient', () => { }, }; const expectedResponse = [new String(), new String(), new String()]; - client.innerApiCalls.listCollectionIds = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.listCollectionIds = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.listCollectionIds( request, @@ -2160,9 +2127,8 @@ describe('v1.FirestoreClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedResponse = [new String(), new String(), new String()]; - client.descriptors.page.listCollectionIds.createStream = stubPageStreamingCall( - expectedResponse - ); + client.descriptors.page.listCollectionIds.createStream = + stubPageStreamingCall(expectedResponse); const stream = client.listCollectionIdsStream(request); const promise = new Promise((resolve, reject) => { const responses: string[] = []; @@ -2184,10 +2150,9 @@ describe('v1.FirestoreClient', () => { .calledWith(client.innerApiCalls.listCollectionIds, request) ); assert.strictEqual( - (client.descriptors.page.listCollectionIds - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listCollectionIds.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -2204,10 +2169,8 @@ describe('v1.FirestoreClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.listCollectionIds.createStream = stubPageStreamingCall( - undefined, - expectedError - ); + client.descriptors.page.listCollectionIds.createStream = + stubPageStreamingCall(undefined, expectedError); const stream = client.listCollectionIdsStream(request); const promise = new Promise((resolve, reject) => { const responses: string[] = []; @@ -2228,10 +2191,9 @@ describe('v1.FirestoreClient', () => { .calledWith(client.innerApiCalls.listCollectionIds, request) ); assert.strictEqual( - (client.descriptors.page.listCollectionIds - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listCollectionIds.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -2248,9 +2210,8 @@ describe('v1.FirestoreClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedResponse = [new String(), new String(), new String()]; - client.descriptors.page.listCollectionIds.asyncIterate = stubAsyncIterationCall( - expectedResponse - ); + client.descriptors.page.listCollectionIds.asyncIterate = + stubAsyncIterationCall(expectedResponse); const responses: string[] = []; const iterable = client.listCollectionIdsAsync(request); for await (const resource of iterable) { @@ -2258,15 +2219,15 @@ describe('v1.FirestoreClient', () => { } assert.deepStrictEqual(responses, expectedResponse); assert.deepStrictEqual( - (client.descriptors.page.listCollectionIds - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.listCollectionIds.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.listCollectionIds - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listCollectionIds.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -2283,10 +2244,8 @@ describe('v1.FirestoreClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.listCollectionIds.asyncIterate = stubAsyncIterationCall( - undefined, - expectedError - ); + client.descriptors.page.listCollectionIds.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); const iterable = client.listCollectionIdsAsync(request); await assert.rejects(async () => { const responses: string[] = []; @@ -2295,15 +2254,15 @@ describe('v1.FirestoreClient', () => { } }); assert.deepStrictEqual( - (client.descriptors.page.listCollectionIds - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.listCollectionIds.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.listCollectionIds - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listCollectionIds.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); diff --git a/dev/test/gapic_firestore_v1beta1.ts b/dev/test/gapic_firestore_v1beta1.ts index ffb04ee50..00b9d9dd2 100644 --- a/dev/test/gapic_firestore_v1beta1.ts +++ b/dev/test/gapic_firestore_v1beta1.ts @@ -28,10 +28,9 @@ import {PassThrough} from 'stream'; import {protobuf} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message).toObject( - instance as protobuf.Message, - {defaults: true} - ); + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); return (instance.constructor as typeof protobuf.Message).fromObject( filledObject ) as T; @@ -282,9 +281,8 @@ describe('v1beta1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.firestore.v1beta1.Document() ); - client.innerApiCalls.getDocument = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.getDocument = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.getDocument( request, @@ -396,9 +394,8 @@ describe('v1beta1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.firestore.v1beta1.Document() ); - client.innerApiCalls.updateDocument = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.updateDocument = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.updateDocument( request, @@ -509,9 +506,8 @@ describe('v1beta1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); - client.innerApiCalls.deleteDocument = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.deleteDocument = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.deleteDocument( request, @@ -621,9 +617,8 @@ describe('v1beta1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.firestore.v1beta1.BeginTransactionResponse() ); - client.innerApiCalls.beginTransaction = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.beginTransaction = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.beginTransaction( request, @@ -733,9 +728,8 @@ describe('v1beta1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.firestore.v1beta1.CommitResponse() ); - client.innerApiCalls.commit = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.commit = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.commit( request, @@ -842,9 +836,8 @@ describe('v1beta1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); - client.innerApiCalls.rollback = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.rollback = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.rollback( request, @@ -951,9 +944,8 @@ describe('v1beta1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.firestore.v1beta1.BatchWriteResponse() ); - client.innerApiCalls.batchWrite = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.batchWrite = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.batchWrite( request, @@ -1063,9 +1055,8 @@ describe('v1beta1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.firestore.v1beta1.Document() ); - client.innerApiCalls.createDocument = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.createDocument = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.createDocument( request, @@ -1144,9 +1135,8 @@ describe('v1beta1.FirestoreClient', () => { const expectedResponse = generateSampleMessage( new protos.google.firestore.v1beta1.BatchGetDocumentsResponse() ); - client.innerApiCalls.batchGetDocuments = stubServerStreamingCall( - expectedResponse - ); + client.innerApiCalls.batchGetDocuments = + stubServerStreamingCall(expectedResponse); const stream = client.batchGetDocuments(request); const promise = new Promise((resolve, reject) => { stream.on( @@ -1340,9 +1330,8 @@ describe('v1beta1.FirestoreClient', () => { .calledWithExactly({}, undefined) ); assert.deepStrictEqual( - (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( - 0 - ).args[0], + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], request ); }); @@ -1384,9 +1373,8 @@ describe('v1beta1.FirestoreClient', () => { .calledWithExactly({}, undefined) ); assert.deepStrictEqual( - (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( - 0 - ).args[0], + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], request ); }); @@ -1428,9 +1416,8 @@ describe('v1beta1.FirestoreClient', () => { .calledWithExactly({}, undefined) ); assert.deepStrictEqual( - (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( - 0 - ).args[0], + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], request ); }); @@ -1472,9 +1459,8 @@ describe('v1beta1.FirestoreClient', () => { .calledWithExactly({}, undefined) ); assert.deepStrictEqual( - (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( - 0 - ).args[0], + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], request ); }); @@ -1537,9 +1523,8 @@ describe('v1beta1.FirestoreClient', () => { generateSampleMessage(new protos.google.firestore.v1beta1.Document()), generateSampleMessage(new protos.google.firestore.v1beta1.Document()), ]; - client.innerApiCalls.listDocuments = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.listDocuments = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.listDocuments( request, @@ -1611,9 +1596,8 @@ describe('v1beta1.FirestoreClient', () => { generateSampleMessage(new protos.google.firestore.v1beta1.Document()), generateSampleMessage(new protos.google.firestore.v1beta1.Document()), ]; - client.descriptors.page.listDocuments.createStream = stubPageStreamingCall( - expectedResponse - ); + client.descriptors.page.listDocuments.createStream = + stubPageStreamingCall(expectedResponse); const stream = client.listDocumentsStream(request); const promise = new Promise((resolve, reject) => { const responses: protos.google.firestore.v1beta1.Document[] = []; @@ -1638,10 +1622,9 @@ describe('v1beta1.FirestoreClient', () => { .calledWith(client.innerApiCalls.listDocuments, request) ); assert.strictEqual( - (client.descriptors.page.listDocuments - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listDocuments.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1658,10 +1641,8 @@ describe('v1beta1.FirestoreClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.listDocuments.createStream = stubPageStreamingCall( - undefined, - expectedError - ); + client.descriptors.page.listDocuments.createStream = + stubPageStreamingCall(undefined, expectedError); const stream = client.listDocumentsStream(request); const promise = new Promise((resolve, reject) => { const responses: protos.google.firestore.v1beta1.Document[] = []; @@ -1685,10 +1666,9 @@ describe('v1beta1.FirestoreClient', () => { .calledWith(client.innerApiCalls.listDocuments, request) ); assert.strictEqual( - (client.descriptors.page.listDocuments - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listDocuments.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1709,9 +1689,8 @@ describe('v1beta1.FirestoreClient', () => { generateSampleMessage(new protos.google.firestore.v1beta1.Document()), generateSampleMessage(new protos.google.firestore.v1beta1.Document()), ]; - client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall( - expectedResponse - ); + client.descriptors.page.listDocuments.asyncIterate = + stubAsyncIterationCall(expectedResponse); const responses: protos.google.firestore.v1beta1.IDocument[] = []; const iterable = client.listDocumentsAsync(request); for await (const resource of iterable) { @@ -1719,15 +1698,15 @@ describe('v1beta1.FirestoreClient', () => { } assert.deepStrictEqual(responses, expectedResponse); assert.deepStrictEqual( - (client.descriptors.page.listDocuments - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.listDocuments.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.listDocuments - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listDocuments.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1744,10 +1723,8 @@ describe('v1beta1.FirestoreClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall( - undefined, - expectedError - ); + client.descriptors.page.listDocuments.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); const iterable = client.listDocumentsAsync(request); await assert.rejects(async () => { const responses: protos.google.firestore.v1beta1.IDocument[] = []; @@ -1756,15 +1733,15 @@ describe('v1beta1.FirestoreClient', () => { } }); assert.deepStrictEqual( - (client.descriptors.page.listDocuments - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.listDocuments.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.listDocuments - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listDocuments.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1827,9 +1804,8 @@ describe('v1beta1.FirestoreClient', () => { generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), ]; - client.innerApiCalls.partitionQuery = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.partitionQuery = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.partitionQuery( request, @@ -1901,9 +1877,8 @@ describe('v1beta1.FirestoreClient', () => { generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), ]; - client.descriptors.page.partitionQuery.createStream = stubPageStreamingCall( - expectedResponse - ); + client.descriptors.page.partitionQuery.createStream = + stubPageStreamingCall(expectedResponse); const stream = client.partitionQueryStream(request); const promise = new Promise((resolve, reject) => { const responses: protos.google.firestore.v1beta1.Cursor[] = []; @@ -1928,10 +1903,9 @@ describe('v1beta1.FirestoreClient', () => { .calledWith(client.innerApiCalls.partitionQuery, request) ); assert.strictEqual( - (client.descriptors.page.partitionQuery - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.partitionQuery.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1948,10 +1922,8 @@ describe('v1beta1.FirestoreClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.partitionQuery.createStream = stubPageStreamingCall( - undefined, - expectedError - ); + client.descriptors.page.partitionQuery.createStream = + stubPageStreamingCall(undefined, expectedError); const stream = client.partitionQueryStream(request); const promise = new Promise((resolve, reject) => { const responses: protos.google.firestore.v1beta1.Cursor[] = []; @@ -1975,10 +1947,9 @@ describe('v1beta1.FirestoreClient', () => { .calledWith(client.innerApiCalls.partitionQuery, request) ); assert.strictEqual( - (client.descriptors.page.partitionQuery - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.partitionQuery.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1999,9 +1970,8 @@ describe('v1beta1.FirestoreClient', () => { generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), ]; - client.descriptors.page.partitionQuery.asyncIterate = stubAsyncIterationCall( - expectedResponse - ); + client.descriptors.page.partitionQuery.asyncIterate = + stubAsyncIterationCall(expectedResponse); const responses: protos.google.firestore.v1beta1.ICursor[] = []; const iterable = client.partitionQueryAsync(request); for await (const resource of iterable) { @@ -2009,15 +1979,15 @@ describe('v1beta1.FirestoreClient', () => { } assert.deepStrictEqual(responses, expectedResponse); assert.deepStrictEqual( - (client.descriptors.page.partitionQuery - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.partitionQuery.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.partitionQuery - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.partitionQuery.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -2034,10 +2004,8 @@ describe('v1beta1.FirestoreClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.partitionQuery.asyncIterate = stubAsyncIterationCall( - undefined, - expectedError - ); + client.descriptors.page.partitionQuery.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); const iterable = client.partitionQueryAsync(request); await assert.rejects(async () => { const responses: protos.google.firestore.v1beta1.ICursor[] = []; @@ -2046,15 +2014,15 @@ describe('v1beta1.FirestoreClient', () => { } }); assert.deepStrictEqual( - (client.descriptors.page.partitionQuery - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.partitionQuery.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.partitionQuery - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.partitionQuery.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -2109,9 +2077,8 @@ describe('v1beta1.FirestoreClient', () => { }, }; const expectedResponse = [new String(), new String(), new String()]; - client.innerApiCalls.listCollectionIds = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.listCollectionIds = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.listCollectionIds( request, @@ -2176,9 +2143,8 @@ describe('v1beta1.FirestoreClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedResponse = [new String(), new String(), new String()]; - client.descriptors.page.listCollectionIds.createStream = stubPageStreamingCall( - expectedResponse - ); + client.descriptors.page.listCollectionIds.createStream = + stubPageStreamingCall(expectedResponse); const stream = client.listCollectionIdsStream(request); const promise = new Promise((resolve, reject) => { const responses: string[] = []; @@ -2200,10 +2166,9 @@ describe('v1beta1.FirestoreClient', () => { .calledWith(client.innerApiCalls.listCollectionIds, request) ); assert.strictEqual( - (client.descriptors.page.listCollectionIds - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listCollectionIds.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -2220,10 +2185,8 @@ describe('v1beta1.FirestoreClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.listCollectionIds.createStream = stubPageStreamingCall( - undefined, - expectedError - ); + client.descriptors.page.listCollectionIds.createStream = + stubPageStreamingCall(undefined, expectedError); const stream = client.listCollectionIdsStream(request); const promise = new Promise((resolve, reject) => { const responses: string[] = []; @@ -2244,10 +2207,9 @@ describe('v1beta1.FirestoreClient', () => { .calledWith(client.innerApiCalls.listCollectionIds, request) ); assert.strictEqual( - (client.descriptors.page.listCollectionIds - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listCollectionIds.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -2264,9 +2226,8 @@ describe('v1beta1.FirestoreClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedResponse = [new String(), new String(), new String()]; - client.descriptors.page.listCollectionIds.asyncIterate = stubAsyncIterationCall( - expectedResponse - ); + client.descriptors.page.listCollectionIds.asyncIterate = + stubAsyncIterationCall(expectedResponse); const responses: string[] = []; const iterable = client.listCollectionIdsAsync(request); for await (const resource of iterable) { @@ -2274,15 +2235,15 @@ describe('v1beta1.FirestoreClient', () => { } assert.deepStrictEqual(responses, expectedResponse); assert.deepStrictEqual( - (client.descriptors.page.listCollectionIds - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.listCollectionIds.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.listCollectionIds - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listCollectionIds.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -2299,10 +2260,8 @@ describe('v1beta1.FirestoreClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.listCollectionIds.asyncIterate = stubAsyncIterationCall( - undefined, - expectedError - ); + client.descriptors.page.listCollectionIds.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); const iterable = client.listCollectionIdsAsync(request); await assert.rejects(async () => { const responses: string[] = []; @@ -2311,15 +2270,15 @@ describe('v1beta1.FirestoreClient', () => { } }); assert.deepStrictEqual( - (client.descriptors.page.listCollectionIds - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.listCollectionIds.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.listCollectionIds - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listCollectionIds.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); diff --git a/dev/test/pool.ts b/dev/test/pool.ts index ce8a45e54..a78a31631 100644 --- a/dev/test/pool.ts +++ b/dev/test/pool.ts @@ -216,9 +216,9 @@ describe('Client pool', () => { operationPromises.forEach(deferred => deferred.reject(new Error())); - return Promise.all( - completionPromises.map(p => p.catch(() => {})) - ).then(() => expect(clientPool.size).to.equal(0)); + return Promise.all(completionPromises.map(p => p.catch(() => {}))).then( + () => expect(clientPool.size).to.equal(0) + ); }); it('garbage collection calls destructor', () => { diff --git a/dev/test/recursive-delete.ts b/dev/test/recursive-delete.ts index ad62e28c1..62e2d85a4 100644 --- a/dev/test/recursive-delete.ts +++ b/dev/test/recursive-delete.ts @@ -235,9 +235,9 @@ describe('recursiveDelete() method:', () => { }); it('creates a second query with the correct startAfter', async () => { - const firstStream = Array.from( - Array(MAX_PENDING_OPS).keys() - ).map((_, i) => result('doc' + i)); + const firstStream = Array.from(Array(MAX_PENDING_OPS).keys()).map( + (_, i) => result('doc' + i) + ); // Use an array to store that the queryEquals() method succeeded, since // thrown errors do not result in the recursiveDelete() method failing. @@ -420,7 +420,7 @@ describe('recursiveDelete() method:', () => { const refs: string[] = []; const bulkWriter = firestore.bulkWriter(); bulkWriter.onWriteError(err => { - codes.push((err.code as unknown) as Status); + codes.push(err.code as unknown as Status); refs.push(err.documentRef.path); return false; }); @@ -595,8 +595,9 @@ describe('recursiveDelete() method:', () => { firestore = await createInstance(); const bulkWriter = firestore.bulkWriter(); await bulkWriter.close(); - await expect(() => () => - firestore.recursiveDelete(firestore.collection('foo'), bulkWriter) + await expect( + () => () => + firestore.recursiveDelete(firestore.collection('foo'), bulkWriter) ).to.throw; }); }); diff --git a/dev/test/watch.ts b/dev/test/watch.ts index 65cfea72f..fcc984daf 100644 --- a/dev/test/watch.ts +++ b/dev/test/watch.ts @@ -242,7 +242,8 @@ class DeferredListener { * sequential invocations of the Listen API. */ class StreamHelper { - private readonly deferredListener = new DeferredListener(); + private readonly deferredListener = + new DeferredListener(); private backendStream: Duplex | null = null; streamCount = 0; // The number of streams that the client has requested diff --git a/synth.metadata b/synth.metadata index acfeaed93..7034e9a3d 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "a8d5f0b1e4503ef9f0d289dbf8ed67a30eb9ed4b" + "sha": "f1d78ac245a12b233ce1aa46e33dceacf215bcb9" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "e6f3d54be015a394b6ab5a25903ec09062a2b424" + "sha": "b891fb474173f810051a7fdb0d66915e0a9bc82f" } } ], From 150745e8ca542f9c6cff8cd5936b4d11b954a2f8 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 13 May 2021 16:58:07 +0000 Subject: [PATCH 289/337] chore: release 4.11.1 (#1498) :robot: I have created a release \*beep\* \*boop\* --- ### [4.11.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.11.0...v4.11.1) (2021-05-13) ### Bug Fixes * **deps:** require google-gax v2.12.0 ([#1497](https://www.github.com/googleapis/nodejs-firestore/issues/1497)) ([a8d5f0b](https://www.github.com/googleapis/nodejs-firestore/commit/a8d5f0b1e4503ef9f0d289dbf8ed67a30eb9ed4b)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7379b0ca8..56bfe3d74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.11.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.11.0...v4.11.1) (2021-05-13) + + +### Bug Fixes + +* **deps:** require google-gax v2.12.0 ([#1497](https://www.github.com/googleapis/nodejs-firestore/issues/1497)) ([a8d5f0b](https://www.github.com/googleapis/nodejs-firestore/commit/a8d5f0b1e4503ef9f0d289dbf8ed67a30eb9ed4b)) + ## [4.11.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.10.1...v4.11.0) (2021-05-05) diff --git a/package.json b/package.json index bc579ad02..b0e99f1d7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.11.0", + "version": "4.11.1", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index a21aad003..50b401f29 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.11.0" + "@google-cloud/firestore": "^4.11.1" }, "devDependencies": { "chai": "^4.2.0", From c2c160663f1d3338d6e156cefe65633f2c2690a1 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Fri, 14 May 2021 11:40:14 -0500 Subject: [PATCH 290/337] docs: update and fix BulkWriter docs (#1504) --- dev/src/bulk-writer.ts | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index b774d0ac4..787095107 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -639,12 +639,22 @@ export class BulkWriter { return op; } + /** + * Callback function set by {@link BulkWriter#onWriteResult} that is run + * every time a {@link BulkWriter} operation successfully completes. + * + * @callback BulkWriter~successCallback + * @param {DocumentReference} documentRef The document reference the + * operation was performed on + * @param {WriteResult} result The server write time of the operation. + */ + /** * Attaches a listener that is run every time a BulkWriter operation * successfully completes. * - * @param callback A callback to be called every time a BulkWriter operation - * successfully completes. + * @param {BulkWriter~successCallback} successCallback A callback to be + * called every time a BulkWriter operation successfully completes. * @example * let bulkWriter = firestore.bulkWriter(); * @@ -659,14 +669,26 @@ export class BulkWriter { * }); */ onWriteResult( - callback: ( + successCallback: ( documentRef: firestore.DocumentReference, result: WriteResult ) => void ): void { - this._successFn = callback; + this._successFn = successCallback; } + /** + * Callback function set by {@link BulkWriter#onWriteError} that is run when + * a write fails in order to determine whether {@link BulkWriter} should + * retry the operation. + * + * @callback BulkWriter~shouldRetryCallback + * @param {BulkWriterError} error The error object with information about the + * operation and error. + * @returns {boolean} Whether or not to retry the failed operation. Returning + * `true` retries the operation. Returning `false` will stop the retry loop. + */ + /** * Attaches an error handler listener that is run every time a BulkWriter * operation fails. @@ -675,9 +697,9 @@ export class BulkWriter { * ABORTED errors up to a maximum of 10 failed attempts. When an error * handler is specified, the default error handler will be overwritten. * - * @param shouldRetryCallback A callback to be called every time a BulkWriter - * operation fails. Returning `true` will retry the operation. Returning - * `false` will stop the retry loop. + * @param shouldRetryCallback {BulkWriter~shouldRetryCallback} A callback to + * be called every time a BulkWriter operation fails. Returning `true` will + * retry the operation. Returning `false` will stop the retry loop. * @example * let bulkWriter = firestore.bulkWriter(); * @@ -803,6 +825,7 @@ export class BulkWriter { /** * Sends the provided batch once the rate limiter does not require any delay. + * @private */ private async _sendBatch( batch: BulkCommitBatch, From 28d645bd3e368abde592bfa2611de3378ca175a6 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 19 May 2021 10:45:29 -0500 Subject: [PATCH 291/337] feat: add Precondition.exists to delete() (#1505) --- dev/src/index.ts | 4 +++- dev/src/reference.ts | 2 ++ dev/src/transaction.ts | 2 ++ dev/src/write-batch.ts | 2 ++ dev/system-test/firestore.ts | 10 ++++++++++ types/firestore.d.ts | 7 +++++++ 6 files changed, 26 insertions(+), 1 deletion(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index d8127fcc7..d6ab41765 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -225,7 +225,7 @@ const MAX_CONCURRENT_REQUESTS_PER_CLIENT = 100; * [update()]{@link DocumentReference#update} and * [delete()]{@link DocumentReference#delete} calls in * [DocumentReference]{@link DocumentReference}, - * [WriteBatch]{@link WriteBatch}, and + * [WriteBatch]{@link WriteBatch}, [BulkWriter]({@link BulkWriter}, and * [Transaction]{@link Transaction}. Using Preconditions, these calls * can be restricted to only apply to documents that match the specified * conditions. @@ -243,6 +243,8 @@ const MAX_CONCURRENT_REQUESTS_PER_CLIENT = 100; * @property {Timestamp} lastUpdateTime The update time to enforce. If set, * enforces that the document was last updated at lastUpdateTime. Fails the * operation if the document was last updated at a different time. + * @property {boolean} exists If set, enforces that the target document must + * or must not exist. * @typedef {Object} Precondition */ diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 6ce5920a4..2c62dde71 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -371,6 +371,8 @@ export class DocumentReference * @param {Timestamp=} precondition.lastUpdateTime If set, enforces that the * document was last updated at lastUpdateTime. Fails the delete if the * document was last updated at a different time. + * @param {boolean=} precondition.exists If set, enforces that the target + * document must or must not exist. * @returns {Promise.} A Promise that resolves with the * delete time. * diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index 3ad7a56eb..ccd50588f 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -330,6 +330,8 @@ export class Transaction implements firestore.Transaction { * @param {Timestamp=} precondition.lastUpdateTime If set, enforces that the * document was last updated at lastUpdateTime. Fails the transaction if the * document doesn't exist or was last updated at a different time. + * @param {boolean=} precondition.exists If set, enforces that the target + * document must or must not exist. * @returns {Transaction} This Transaction instance. Used for * chaining method calls. * diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index 60e721772..d4adf0e51 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -222,6 +222,8 @@ export class WriteBatch implements firestore.WriteBatch { * @param {Timestamp=} precondition.lastUpdateTime If set, enforces that the * document was last updated at lastUpdateTime. Fails the batch if the * document doesn't exist or was last updated at a different time. + * @param {boolean= } precondition.exists If set to true, enforces that the target + * document must or must not exist. * @returns {WriteBatch} This WriteBatch instance. Used for chaining * method calls. * diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 70e5a9517..10379e830 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -735,6 +735,16 @@ describe('DocumentReference class', () => { return ref.delete(); }); + it('will fail to delete document with exists: true if doc does not exist', () => { + const ref = randomCol.doc(); + return ref + .delete({exists: true}) + .then(() => Promise.reject('Delete should have failed')) + .catch((err: Error) => { + expect(err.message).to.contain('NOT_FOUND: No document to update'); + }); + }); + it('supports non-alphanumeric field names', () => { const ref = randomCol.doc('doc'); return ref diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 8763562b2..464e65ceb 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -551,6 +551,8 @@ declare namespace FirebaseFirestore { * @param precondition.lastUpdateTime If set, enforces that the * document was last updated at lastUpdateTime. Fails the batch if the * document doesn't exist or was last updated at a different time. + * @param precondition.exists If set, enforces that the target document + * must or must not exist. * @returns A promise that resolves with the result of the delete. If the * delete fails, the promise is rejected with a * [BulkWriterError]{@link BulkWriterError}. @@ -878,6 +880,11 @@ declare namespace FirebaseFirestore { * If set, the last update time to enforce. */ readonly lastUpdateTime?: Timestamp; + + /** + * If set, enforces that the target document must or must not exist. + */ + readonly exists?: boolean; } /** From 6fa1d4da627f17d76cf2d6109765862fd5083e03 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 19 May 2021 09:42:06 -0700 Subject: [PATCH 292/337] feat: add `gcf-owl-bot[bot]` to `ignoreAuthors` (#1506) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/8f860fcf-f503-4a41-a7bf-956268097f37/targets - [ ] To automatically regenerate this PR, check this box. (May take up to 24 hours.) Source-Link: https://github.com/googleapis/synthtool/commit/7332178a11ddddc91188dc0f25bca1ccadcaa6c6 --- .github/generated-files-bot.yml | 3 +++ synth.metadata | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/generated-files-bot.yml b/.github/generated-files-bot.yml index 1b3ef1c78..6b04910c0 100644 --- a/.github/generated-files-bot.yml +++ b/.github/generated-files-bot.yml @@ -11,3 +11,6 @@ generatedFiles: message: '`README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/master/.readme-partials.yaml' - path: 'samples/README.md' message: '`samples/README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/master/.readme-partials.yaml' +ignoreAuthors: +- 'gcf-owl-bot[bot]' +- 'yoshi-automation' diff --git a/synth.metadata b/synth.metadata index 7034e9a3d..fadbb8318 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "f1d78ac245a12b233ce1aa46e33dceacf215bcb9" + "sha": "c2c160663f1d3338d6e156cefe65633f2c2690a1" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "b891fb474173f810051a7fdb0d66915e0a9bc82f" + "sha": "7332178a11ddddc91188dc0f25bca1ccadcaa6c6" } } ], From aa92a1545a64e1164d5454c24fb38fb99aa1fd24 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 20 May 2021 14:38:42 -0600 Subject: [PATCH 293/337] chore: release 4.12.0 (#1507) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56bfe3d74..871311d76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [4.12.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.11.1...v4.12.0) (2021-05-19) + + +### Features + +* add `gcf-owl-bot[bot]` to `ignoreAuthors` ([#1506](https://www.github.com/googleapis/nodejs-firestore/issues/1506)) ([6fa1d4d](https://www.github.com/googleapis/nodejs-firestore/commit/6fa1d4da627f17d76cf2d6109765862fd5083e03)) +* add Precondition.exists to delete() ([#1505](https://www.github.com/googleapis/nodejs-firestore/issues/1505)) ([28d645b](https://www.github.com/googleapis/nodejs-firestore/commit/28d645bd3e368abde592bfa2611de3378ca175a6)) + ### [4.11.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.11.0...v4.11.1) (2021-05-13) diff --git a/package.json b/package.json index b0e99f1d7..72244cfbf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.11.1", + "version": "4.12.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 50b401f29..1908abd30 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.11.1" + "@google-cloud/firestore": "^4.12.0" }, "devDependencies": { "chai": "^4.2.0", From 3a068816bb73985167571529be226f29affcd32a Mon Sep 17 00:00:00 2001 From: "google-cloud-policy-bot[bot]" <80869356+google-cloud-policy-bot[bot]@users.noreply.github.com> Date: Fri, 21 May 2021 07:44:57 -0700 Subject: [PATCH 294/337] chore: add SECURITY.md (#1509) Co-authored-by: google-cloud-policy-bot[bot] <80869356+google-cloud-policy-bot[bot]@users.noreply.github.com> --- SECURITY.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..8b58ae9c0 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,7 @@ +# Security Policy + +To report a security issue, please use [g.co/vulnz](https://g.co/vulnz). + +The Google Security Team will respond within 5 working days of your report on g.co/vulnz. + +We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue. From 821924960ab0a44fdd89c564323482736255e408 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 21 May 2021 19:02:40 +0200 Subject: [PATCH 295/337] chore(deps): update dependency @types/node to v14 (#1510) Co-authored-by: Sebastian Schmidt --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 72244cfbf..e0c8bfa17 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "@types/duplexify": "^3.5.0", "@types/extend": "^3.0.0", "@types/mocha": "^7.0.0", - "@types/node": "^12.12.17", + "@types/node": "^14.0.0", "@types/sinon": "^10.0.0", "@types/through2": "^2.0.34", "c8": "^7.0.0", From 88ea85666d565e9e3b960407a4d083da40f69878 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 24 May 2021 16:52:49 +0200 Subject: [PATCH 296/337] chore(deps): update dependency ts-node to v10 (#1512) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e0c8bfa17..6765aff96 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "mocha": "^7.0.0", "proxyquire": "^2.1.3", "sinon": "^10.0.0", - "ts-node": "^9.0.0", + "ts-node": "^10.0.0", "typescript": "3.8.3", "through2": "^4.0.0", "@microsoft/api-documenter": "^7.8.10", From 245c3a95345603e52e3a803edc981fa6cfa34010 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 25 May 2021 17:12:54 +0200 Subject: [PATCH 297/337] chore(deps): update dependency sinon to v11 (#1513) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6765aff96..434655b1d 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "linkinator": "^2.0.0", "mocha": "^7.0.0", "proxyquire": "^2.1.3", - "sinon": "^10.0.0", + "sinon": "^11.0.0", "ts-node": "^10.0.0", "typescript": "3.8.3", "through2": "^4.0.0", From 92ea651adc84ba854ae7cd203af231573f885307 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 26 May 2021 10:52:50 -0500 Subject: [PATCH 298/337] fix: recursive delete: backporting changes from Java (#1514) --- dev/src/index.ts | 37 +++++++++++++++- dev/src/recursive-delete.ts | 54 +++++++++++++++------- dev/test/recursive-delete.ts | 86 +++++++++++++++++++++++++++--------- 3 files changed, 138 insertions(+), 39 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index d6ab41765..6088be6f6 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -76,7 +76,11 @@ const serviceConfig = interfaces['google.firestore.v1.Firestore']; import api = google.firestore.v1; import {CollectionGroup} from './collection-group'; -import {RecursiveDelete} from './recursive-delete'; +import { + RECURSIVE_DELETE_MAX_PENDING_OPS, + RECURSIVE_DELETE_MIN_PENDING_OPS, + RecursiveDelete, +} from './recursive-delete'; export { CollectionReference, @@ -1250,9 +1254,38 @@ export class Firestore implements firestore.Firestore { | firestore.CollectionReference | firestore.DocumentReference, bulkWriter?: BulkWriter + ): Promise { + return this._recursiveDelete( + ref, + RECURSIVE_DELETE_MAX_PENDING_OPS, + RECURSIVE_DELETE_MIN_PENDING_OPS, + bulkWriter + ); + } + + /** + * This overload is not private in order to test the query resumption with + * startAfter() once the RecursiveDelete instance has MAX_PENDING_OPS pending. + * + * @private + */ + // Visible for testing + _recursiveDelete( + ref: + | firestore.CollectionReference + | firestore.DocumentReference, + maxPendingOps: number, + minPendingOps: number, + bulkWriter?: BulkWriter ): Promise { const writer = bulkWriter ?? this.getBulkWriter(); - const deleter = new RecursiveDelete(this, writer, ref); + const deleter = new RecursiveDelete( + this, + writer, + ref, + maxPendingOps, + minPendingOps + ); return deleter.run(); } diff --git a/dev/src/recursive-delete.ts b/dev/src/recursive-delete.ts index dd14ed949..97071b7ac 100644 --- a/dev/src/recursive-delete.ts +++ b/dev/src/recursive-delete.ts @@ -48,7 +48,7 @@ export const REFERENCE_NAME_MIN_ID = '__id-9223372036854775808__'; * from streaming documents faster than Firestore can delete. */ // Visible for testing. -export const MAX_PENDING_OPS = 5000; +export const RECURSIVE_DELETE_MAX_PENDING_OPS = 5000; /** * The number of pending BulkWriter operations at which RecursiveDelete @@ -57,7 +57,7 @@ export const MAX_PENDING_OPS = 5000; * throughput. This helps prevent BulkWriter from idling while Firestore * fetches the next query. */ -const MIN_PENDING_OPS = 1000; +export const RECURSIVE_DELETE_MIN_PENDING_OPS = 1000; /** * Class used to store state required for running a recursive delete operation. @@ -84,6 +84,25 @@ export class RecursiveDelete { */ private documentsPending = true; + /** + * Whether run() has been called. + * @private + */ + private started = false; + + /** + * Query limit to use when fetching all descendants. + * @private + */ + private readonly maxPendingOps: number; + + /** + * The number of pending BulkWriter operations at which RecursiveDelete + * starts the next limit query to fetch descendants. + * @private + */ + private readonly minPendingOps: number; + /** * A deferred promise that resolves when the recursive delete operation * is completed. @@ -119,14 +138,22 @@ export class RecursiveDelete { * @param firestore The Firestore instance to use. * @param writer The BulkWriter instance to use for delete operations. * @param ref The document or collection reference to recursively delete. + * @param maxLimit The query limit to use when fetching descendants + * @param minLimit The number of pending BulkWriter operations at which + * RecursiveDelete starts the next limit query to fetch descendants. */ constructor( private readonly firestore: Firestore, private readonly writer: BulkWriter, private readonly ref: | firestore.CollectionReference - | firestore.DocumentReference - ) {} + | firestore.DocumentReference, + private readonly maxLimit: number, + private readonly minLimit: number + ) { + this.maxPendingOps = maxLimit; + this.minPendingOps = minLimit; + } /** * Recursively deletes the reference provided in the class constructor. @@ -134,10 +161,7 @@ export class RecursiveDelete { * if an error occurs. */ run(): Promise { - assert( - this.documentsPending, - 'The recursive delete operation has already been completed.' - ); + assert(!this.started, 'RecursiveDelete.run() should only be called once.'); // Capture the error stack to preserve stack tracing across async calls. this.errorStack = Error().stack!; @@ -152,12 +176,10 @@ export class RecursiveDelete { * @private */ private setupStream(): void { - const limit = MAX_PENDING_OPS; const stream = this.getAllDescendants( this.ref instanceof CollectionReference ? (this.ref as CollectionReference) - : (this.ref as DocumentReference), - limit + : (this.ref as DocumentReference) ); this.streamInProgress = true; let streamedDocsCount = 0; @@ -177,7 +199,7 @@ export class RecursiveDelete { this.streamInProgress = false; // If there are fewer than the number of documents specified in the // limit() field, we know that the query is complete. - if (streamedDocsCount < limit) { + if (streamedDocsCount < this.minPendingOps) { this.onQueryEnd(); } else if (this.pendingOpsCount === 0) { this.setupStream(); @@ -188,13 +210,11 @@ export class RecursiveDelete { /** * Retrieves all descendant documents nested under the provided reference. * @param ref The reference to fetch all descendants for. - * @param limit The number of descendants to fetch in the query. * @private * @return {Stream} Stream of descendant documents. */ private getAllDescendants( - ref: CollectionReference | DocumentReference, - limit: number + ref: CollectionReference | DocumentReference ): NodeJS.ReadableStream { // The parent is the closest ancestor document to the location we're // deleting. If we are deleting a document, the parent is the path of that @@ -220,7 +240,7 @@ export class RecursiveDelete { ); // Query for names only to fetch empty snapshots. - query = query.select(FieldPath.documentId()).limit(limit); + query = query.select(FieldPath.documentId()).limit(this.maxPendingOps); if (ref instanceof CollectionReference) { // To find all descendants of a collection reference, we need to use a @@ -300,7 +320,7 @@ export class RecursiveDelete { if ( this.documentsPending && !this.streamInProgress && - this.pendingOpsCount < MIN_PENDING_OPS + this.pendingOpsCount < this.minPendingOps ) { this.setupStream(); } diff --git a/dev/test/recursive-delete.ts b/dev/test/recursive-delete.ts index 62e2d85a4..0d0840e36 100644 --- a/dev/test/recursive-delete.ts +++ b/dev/test/recursive-delete.ts @@ -50,7 +50,11 @@ import { import {MAX_REQUEST_RETRIES} from '../src'; import api = google.firestore.v1; -import {MAX_PENDING_OPS, REFERENCE_NAME_MIN_ID} from '../src/recursive-delete'; +import { + RECURSIVE_DELETE_MAX_PENDING_OPS, + REFERENCE_NAME_MIN_ID, +} from '../src/recursive-delete'; +import {Deferred} from '../src/util'; const PROJECT_ID = 'test-project'; const DATABASE_ROOT = `projects/${PROJECT_ID}/databases/(default)`; @@ -140,7 +144,7 @@ describe('recursiveDelete() method:', () => { 'LESS_THAN', endAt('root') ), - limit(MAX_PENDING_OPS) + limit(RECURSIVE_DELETE_MAX_PENDING_OPS) ); return stream(); }, @@ -165,7 +169,7 @@ describe('recursiveDelete() method:', () => { 'LESS_THAN', endAt('root/doc/nestedCol') ), - limit(MAX_PENDING_OPS) + limit(RECURSIVE_DELETE_MAX_PENDING_OPS) ); return stream(); }, @@ -184,7 +188,7 @@ describe('recursiveDelete() method:', () => { 'root/doc', select('__name__'), allDescendants(/* kindless= */ true), - limit(MAX_PENDING_OPS) + limit(RECURSIVE_DELETE_MAX_PENDING_OPS) ); return stream(); }, @@ -222,7 +226,7 @@ describe('recursiveDelete() method:', () => { 'LESS_THAN', endAt('root') ), - limit(MAX_PENDING_OPS) + limit(RECURSIVE_DELETE_MAX_PENDING_OPS) ); return stream(); } @@ -235,8 +239,32 @@ describe('recursiveDelete() method:', () => { }); it('creates a second query with the correct startAfter', async () => { - const firstStream = Array.from(Array(MAX_PENDING_OPS).keys()).map( - (_, i) => result('doc' + i) + // This test checks that the second query is created with the correct + // startAfter() once the RecursiveDelete instance is below the + // MIN_PENDING_OPS threshold to send the next batch. Use lower limits + // than the actual RecursiveDelete class in order to make this test run fast. + const maxPendingOps = 100; + const minPendingOps = 11; + const maxBatchSize = 10; + const cutoff = maxPendingOps - minPendingOps; + let numDeletesBuffered = 0; + + // This deferred promise is used to delay the BatchWriteResponses from + // returning in order to create the situation where the number of pending + // operations is less than `minPendingOps`. + const bufferDeferred = new Deferred(); + + // This deferred completes when the second query is run. + const secondQueryDeferred = new Deferred(); + + const nLengthArray = (n: number): number[] => Array.from(Array(n).keys()); + + const firstStream = nLengthArray(maxPendingOps).map((_, i) => + result('doc' + i) + ); + + const batchWriteResponse = mergeResponses( + nLengthArray(maxBatchSize).map(() => successResponse(1)) ); // Use an array to store that the queryEquals() method succeeded, since @@ -257,7 +285,7 @@ describe('recursiveDelete() method:', () => { 'LESS_THAN', endAt('root') ), - limit(MAX_PENDING_OPS) + limit(maxPendingOps) ); called.push(1); return stream(...firstStream); @@ -279,11 +307,12 @@ describe('recursiveDelete() method:', () => { referenceValue: `projects/${PROJECT_ID}/databases/(default)/` + 'documents/collectionId/doc' + - (MAX_PENDING_OPS - 1), + (maxPendingOps - 1), }), - limit(MAX_PENDING_OPS) + limit(maxPendingOps) ); called.push(2); + secondQueryDeferred.resolve(); return stream(); } else { called.push(3); @@ -291,22 +320,39 @@ describe('recursiveDelete() method:', () => { } }, batchWrite: () => { - const responses = mergeResponses( - Array.from(Array(500).keys()).map(() => successResponse(1)) - ); - return response({ - writeResults: responses.writeResults, - status: responses.status, + const returnedResponse = response({ + writeResults: batchWriteResponse.writeResults, + status: batchWriteResponse.status, }); + if (numDeletesBuffered < cutoff) { + numDeletesBuffered += batchWriteResponse.writeResults!.length; + + // By waiting for `bufferFuture` to complete, we can guarantee that + // the writes complete after all documents are streamed. Without + // this future, the test can race and complete the writes before + // the stream is finished, which is a different scenario this test + // is not for. + return bufferDeferred.promise.then(() => returnedResponse); + } else { + // Once there are `cutoff` pending deletes, completing the future + // allows enough responses to be returned such that the number of + // pending deletes should be less than `minPendingOps`. This allows + // us to test that the second query is made. + bufferDeferred.resolve(); + return secondQueryDeferred.promise.then(() => returnedResponse); + } }, }; const firestore = await createInstance(overrides); - // Use a custom batch size with BulkWriter to simplify the dummy - // batchWrite() response logic. const bulkWriter = firestore.bulkWriter(); - bulkWriter._maxBatchSize = 500; - await firestore.recursiveDelete(firestore.collection('root'), bulkWriter); + bulkWriter._maxBatchSize = maxBatchSize; + await firestore._recursiveDelete( + firestore.collection('root'), + maxPendingOps, + minPendingOps, + bulkWriter + ); expect(called).to.deep.equal([1, 2]); }); }); From 0515d1feada842545075bb197cb20ddaefc5cd58 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 26 May 2021 14:19:11 -0500 Subject: [PATCH 299/337] docs: update BulkWriterError documentation (#1518) --- dev/src/index.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index 6088be6f6..b97969d5e 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -229,7 +229,7 @@ const MAX_CONCURRENT_REQUESTS_PER_CLIENT = 100; * [update()]{@link DocumentReference#update} and * [delete()]{@link DocumentReference#delete} calls in * [DocumentReference]{@link DocumentReference}, - * [WriteBatch]{@link WriteBatch}, [BulkWriter]({@link BulkWriter}, and + * [WriteBatch]{@link WriteBatch}, [BulkWriter]{@link BulkWriter}, and * [Transaction]{@link Transaction}. Using Preconditions, these calls * can be restricted to only apply to documents that match the specified * conditions. @@ -305,6 +305,23 @@ const MAX_CONCURRENT_REQUESTS_PER_CLIENT = 100; * @typedef {Object} BulkWriterOptions */ +/** + * An error thrown when a BulkWriter operation fails. + * + * The error used by {@link BulkWriter~shouldRetryCallback} set in + * {@link BulkWriter#onWriteError}. + * + * @property {GrpcStatus} code The status code of the error. + * @property {string} message The error message of the error. + * @property {DocumentReference} documentRef The document reference the operation was + * performed on. + * @property {'create' | 'set' | 'update' | 'delete'} operationType The type + * of operation performed. + * @property {number} failedAttempts How many times this operation has been + * attempted unsuccessfully. + * @typedef {Error} BulkWriterError + */ + /** * Status codes returned by GRPC operations. * From 2141b0879cbccb1354f9821edcc917b6aa4ff0ab Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 27 May 2021 08:59:41 -0600 Subject: [PATCH 300/337] fix: do not load google-gax at client startup (#1517) --- dev/src/bulk-writer.ts | 19 +++++++------ dev/src/bundle.ts | 6 +++-- dev/src/index.ts | 53 ++++++++++++++++--------------------- dev/src/recursive-delete.ts | 9 ++++--- dev/src/reference.ts | 8 +++--- dev/src/status-code.ts | 39 +++++++++++++++++++++++++++ dev/src/transaction.ts | 26 +++++++++--------- dev/src/util.ts | 37 +++++++++++++------------- dev/src/write-batch.ts | 5 ++-- dev/test/lazy-load.ts | 40 ++++++++++++++++++++++++++++ 10 files changed, 162 insertions(+), 80 deletions(-) create mode 100644 dev/src/status-code.ts create mode 100644 dev/test/lazy-load.ts diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 787095107..9c7cd1579 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -16,6 +16,7 @@ import * as firestore from '@google-cloud/firestore'; import * as assert from 'assert'; +import {GoogleError} from 'google-gax'; import {google} from '../protos/firestore_v1_proto_api'; import {FieldPath, Firestore} from '.'; @@ -44,7 +45,7 @@ import { validateOptional, } from './validate'; import {logger} from './logger'; -import {GoogleError, Status} from 'google-gax'; +import {StatusCode} from './status-code'; // eslint-disable-next-line no-undef import GrpcStatus = FirebaseFirestore.GrpcStatus; @@ -104,7 +105,7 @@ const DEFAULT_MAXIMUM_PENDING_OPERATIONS_COUNT = 500; class BulkWriterOperation { private deferred = new Deferred(); private failedAttempts = 0; - private lastStatus?: Status; + private lastStatus?: StatusCode; private _backoffDuration = 0; /** @@ -157,7 +158,7 @@ class BulkWriterOperation { ); if (shouldRetry) { - this.lastStatus = error.code; + this.lastStatus = error.code as number; this.updateBackoffDuration(); this.sendFn(this); } else { @@ -169,7 +170,7 @@ class BulkWriterOperation { } private updateBackoffDuration(): void { - if (this.lastStatus === Status.RESOURCE_EXHAUSTED) { + if (this.lastStatus === StatusCode.RESOURCE_EXHAUSTED) { this._backoffDuration = DEFAULT_BACKOFF_MAX_DELAY_MS; } else if (this._backoffDuration === 0) { this._backoffDuration = DEFAULT_BACKOFF_INITIAL_DELAY_MS; @@ -241,14 +242,16 @@ class BulkCommitBatch extends WriteBatch { const DELETE_TIMESTAMP_SENTINEL = Timestamp.fromMillis(0); const status = (response.status || [])[i]; - if (status.code === Status.OK) { + if (status.code === StatusCode.OK) { const updateTime = Timestamp.fromProto( response.writeResults![i].updateTime || DELETE_TIMESTAMP_SENTINEL ); this.pendingOps[i].onSuccess(new WriteResult(updateTime)); } else { - const error = new GoogleError(status.message || undefined); - error.code = status.code as Status; + const error = new (require('google-gax').GoogleError)( + status.message || undefined + ); + error.code = status.code as number; this.pendingOps[i].onError(wrapError(error, stack)); } } @@ -389,7 +392,7 @@ export class BulkWriter { private _errorFn: (error: BulkWriterError) => boolean = error => { const isRetryableDeleteError = error.operationType === 'delete' && - (error.code as number) === Status.INTERNAL; + (error.code as number) === StatusCode.INTERNAL; const retryCodes = getRetryCodes('batchWrite'); return ( (retryCodes.includes(error.code) || isRetryableDeleteError) && diff --git a/dev/src/bundle.ts b/dev/src/bundle.ts index 4f134404f..374b453bd 100644 --- a/dev/src/bundle.ts +++ b/dev/src/bundle.ts @@ -25,7 +25,6 @@ import { } from './validate'; import api = google.firestore.v1; -import BundleElement = firestore.BundleElement; const BUNDLE_VERSION = 1; @@ -146,7 +145,10 @@ export class BundleBuilder { // Convert to a valid proto message object then take its JSON representation. // This take cares of stuff like converting internal byte array fields // to Base64 encodings. - const message = BundleElement.fromObject(bundleElement).toJSON(); + // We lazy-load the Proto file to reduce cold-start times. + const message = require('../protos/firestore_v1_proto_api') + .firestore.BundleElement.fromObject(bundleElement) + .toJSON(); const buffer = Buffer.from(JSON.stringify(message), 'utf-8'); const lengthBuffer = Buffer.from(buffer.length.toString()); return Buffer.concat([lengthBuffer, buffer]); diff --git a/dev/src/index.ts b/dev/src/index.ts index b97969d5e..60cd32358 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -16,7 +16,7 @@ import * as firestore from '@google-cloud/firestore'; -import {CallOptions, grpc, RetryOptions} from 'google-gax'; +import {CallOptions} from 'google-gax'; import {Duplex, PassThrough, Transform} from 'stream'; import {URL} from 'url'; @@ -100,7 +100,6 @@ export {GeoPoint} from './geo-point'; export {CollectionGroup}; export {QueryPartition} from './query-partition'; export {setLogFunction} from './logger'; -export {Status as GrpcStatus} from 'google-gax'; const libVersion = require('../../package.json').version; setLibVersion(libVersion); @@ -127,16 +126,6 @@ setLibVersion(libVersion); * @namespace google.firestore.admin.v1 */ -/*! - * @see v1 - */ -let v1: unknown; // Lazy-loaded in `_runRequest()` - -/*! - * @see v1beta1 - */ -let v1beta1: unknown; // Lazy-loaded upon access. - /*! * HTTP header for the resource prefix to improve routing and project isolation * by the backend. @@ -504,7 +493,7 @@ export class Firestore implements firestore.Firestore { let client: GapicClient; if (this._settings.ssl === false) { - const grpcModule = this._settings.grpc ?? grpc; + const grpcModule = this._settings.grpc ?? require('google-gax').grpc; const sslCreds = grpcModule.credentials.createInsecure(); client = new module.exports.v1({ @@ -1392,7 +1381,10 @@ export class Firestore implements firestore.Firestore { if (retryCodes) { const retryParams = getRetryParams(methodName); - callOptions.retry = new RetryOptions(retryCodes, retryParams); + callOptions.retry = new (require('google-gax').RetryOptions)( + retryCodes, + retryParams + ); } return callOptions; @@ -1740,18 +1732,12 @@ module.exports = Object.assign(module.exports, existingExports); * * @private * @name Firestore.v1beta1 - * @see v1beta1 * @type {function} */ Object.defineProperty(module.exports, 'v1beta1', { // The v1beta1 module is very large. To avoid pulling it in from static - // scope, we lazy-load and cache the module. - get: () => { - if (!v1beta1) { - v1beta1 = require('./v1beta1'); - } - return v1beta1; - }, + // scope, we lazy-load the module. + get: () => require('./v1beta1'), }); /** @@ -1759,16 +1745,23 @@ Object.defineProperty(module.exports, 'v1beta1', { * * @private * @name Firestore.v1 - * @see v1 * @type {function} */ Object.defineProperty(module.exports, 'v1', { // The v1 module is very large. To avoid pulling it in from static - // scope, we lazy-load and cache the module. - get: () => { - if (!v1) { - v1 = require('./v1'); - } - return v1; - }, + // scope, we lazy-load the module. + get: () => require('./v1'), +}); + +/** + * {@link Status} factory function. + * + * @private + * @name Firestore.GrpcStatus + * @type {function} + */ +Object.defineProperty(module.exports, 'GrpcStatus', { + // The gax module is very large. To avoid pulling it in from static + // scope, we lazy-load the module. + get: () => require('google-gax').Status, }); diff --git a/dev/src/recursive-delete.ts b/dev/src/recursive-delete.ts index 97071b7ac..3c66f49f5 100644 --- a/dev/src/recursive-delete.ts +++ b/dev/src/recursive-delete.ts @@ -26,9 +26,10 @@ import Firestore, { QueryDocumentSnapshot, } from '.'; import {Deferred, wrapError} from './util'; -import {GoogleError, Status} from 'google-gax'; +import {GoogleError} from 'google-gax'; import {BulkWriterError} from './bulk-writer'; import {QueryOptions} from './reference'; +import {StatusCode} from './status-code'; /** * Datastore allowed numeric IDs where Firestore only allows strings. Numeric @@ -185,7 +186,7 @@ export class RecursiveDelete { let streamedDocsCount = 0; stream .on('error', err => { - err.code = Status.UNAVAILABLE; + err.code = StatusCode.UNAVAILABLE; err.stack = 'Failed to fetch children documents: ' + err.stack; this.lastError = err; this.onQueryEnd(); @@ -278,13 +279,13 @@ export class RecursiveDelete { if (this.lastError === undefined) { this.completionDeferred.resolve(); } else { - let error = new GoogleError( + let error = new (require('google-gax').GoogleError)( `${this.errorCount} ` + `${this.errorCount !== 1 ? 'deletes' : 'delete'} ` + 'failed. The last delete failed with: ' ); if (this.lastError.code !== undefined) { - error.code = this.lastError.code as number as Status; + error.code = this.lastError.code as number; } error = wrapError(error, this.errorStack); diff --git a/dev/src/reference.ts b/dev/src/reference.ts index 2c62dde71..a33208fb2 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -505,8 +505,10 @@ export class DocumentReference validateFunction('onNext', onNext); validateFunction('onError', onError, {optional: true}); - const watch = new DocumentWatch(this.firestore, this); - + const watch: DocumentWatch = new (require('./watch').DocumentWatch)( + this.firestore, + this + ); return watch.onSnapshot((readTime, size, docs) => { for (const document of docs()) { if (document.ref.path === this.path) { @@ -2250,7 +2252,7 @@ export class Query implements firestore.Query { validateFunction('onNext', onNext); validateFunction('onError', onError, {optional: true}); - const watch = new QueryWatch( + const watch: QueryWatch = new (require('./watch').QueryWatch)( this.firestore, this, this._queryOptions.converter diff --git a/dev/src/status-code.ts b/dev/src/status-code.ts new file mode 100644 index 000000000..a93837d2d --- /dev/null +++ b/dev/src/status-code.ts @@ -0,0 +1,39 @@ +/** + * Copyright 2021 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. + */ + +/** + * Internal copy of GRPC status code. Copied to prevent loading of google-gax + * at SDK startup. + */ +export const enum StatusCode { + OK = 0, + CANCELLED = 1, + UNKNOWN = 2, + INVALID_ARGUMENT = 3, + DEADLINE_EXCEEDED = 4, + NOT_FOUND = 5, + ALREADY_EXISTS = 6, + PERMISSION_DENIED = 7, + RESOURCE_EXHAUSTED = 8, + FAILED_PRECONDITION = 9, + ABORTED = 10, + OUT_OF_RANGE = 11, + UNIMPLEMENTED = 12, + INTERNAL = 13, + UNAVAILABLE = 14, + DATA_LOSS = 15, + UNAUTHENTICATED = 16, +} diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index ccd50588f..e7c5766c5 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -16,8 +16,7 @@ import * as firestore from '@google-cloud/firestore'; -import {GoogleError, Status} from 'google-gax'; - +import {GoogleError} from 'google-gax'; import * as proto from '../protos/firestore_v1_proto_api'; import {ExponentialBackoff} from './backoff'; @@ -25,6 +24,7 @@ import {DocumentSnapshot} from './document'; import {Firestore, WriteBatch} from './index'; import {logger} from './logger'; import {FieldPath, validateFieldPath} from './path'; +import {StatusCode} from './status-code'; import { DocumentReference, Query, @@ -484,7 +484,7 @@ export class Transaction implements firestore.Transaction { * @return A Promise that resolves after the delay expired. */ private async maybeBackoff(error?: GoogleError): Promise { - if (error && error.code === Status.RESOURCE_EXHAUSTED) { + if ((error?.code as number | undefined) === StatusCode.RESOURCE_EXHAUSTED) { this._backoff.resetToMax(); } await this._backoff.backoffAndWait(); @@ -592,17 +592,17 @@ function validateReadOptions( function isRetryableTransactionError(error: GoogleError): boolean { if (error.code !== undefined) { // This list is based on https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore/src/core/transaction_runner.ts#L112 - switch (error.code) { - case Status.ABORTED: - case Status.CANCELLED: - case Status.UNKNOWN: - case Status.DEADLINE_EXCEEDED: - case Status.INTERNAL: - case Status.UNAVAILABLE: - case Status.UNAUTHENTICATED: - case Status.RESOURCE_EXHAUSTED: + switch (error.code as number) { + case StatusCode.ABORTED: + case StatusCode.CANCELLED: + case StatusCode.UNKNOWN: + case StatusCode.DEADLINE_EXCEEDED: + case StatusCode.INTERNAL: + case StatusCode.UNAVAILABLE: + case StatusCode.UNAUTHENTICATED: + case StatusCode.RESOURCE_EXHAUSTED: return true; - case Status.INVALID_ARGUMENT: + case StatusCode.INVALID_ARGUMENT: // The Firestore backend uses "INVALID_ARGUMENT" for transactions // IDs that have expired. While INVALID_ARGUMENT is generally not // retryable, we retry this specific case. diff --git a/dev/src/util.ts b/dev/src/util.ts index d61306558..920f7d502 100644 --- a/dev/src/util.ts +++ b/dev/src/util.ts @@ -17,24 +17,10 @@ import {DocumentData} from '@google-cloud/firestore'; import {randomBytes} from 'crypto'; -import { - CallSettings, - ClientConfig, - constructSettings, - createDefaultBackoffSettings, - GoogleError, - Status, -} from 'google-gax'; +import {CallSettings, ClientConfig, GoogleError} from 'google-gax'; import {BackoffSettings} from 'google-gax/build/src/gax'; import * as gapicConfig from './v1/firestore_client_config.json'; -const serviceConfig = constructSettings( - 'google.firestore.v1.Firestore', - gapicConfig as ClientConfig, - {}, - Status -) as {[k: string]: CallSettings}; - /** * A Promise implementation that supports deferred resolution. * @private @@ -158,13 +144,28 @@ export function isPermanentRpcError( } } +let serviceConfig: Record | undefined; + +/** Lazy-loads the service config when first accessed. */ +function getServiceConfig(methodName: string): CallSettings | undefined { + if (!serviceConfig) { + serviceConfig = require('google-gax').constructSettings( + 'google.firestore.v1.Firestore', + gapicConfig as ClientConfig, + {}, + require('google-gax').Status + ) as {[k: string]: CallSettings}; + } + return serviceConfig[methodName]; +} + /** * Returns the list of retryable error codes specified in the service * configuration. * @private */ export function getRetryCodes(methodName: string): number[] { - return serviceConfig[methodName]?.retry?.retryCodes ?? []; + return getServiceConfig(methodName)?.retry?.retryCodes ?? []; } /** @@ -173,8 +174,8 @@ export function getRetryCodes(methodName: string): number[] { */ export function getRetryParams(methodName: string): BackoffSettings { return ( - serviceConfig[methodName]?.retry?.backoffSettings ?? - createDefaultBackoffSettings() + getServiceConfig(methodName)?.retry?.backoffSettings ?? + require('google-gax').createDefaultBackoffSettings() ); } diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index d4adf0e51..b6e684b1e 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -45,7 +45,8 @@ import { validateMinNumberOfArguments, validateOptional, } from './validate'; -import {Status} from 'google-gax'; +import {StatusCode} from './status-code'; + import api = google.firestore.v1; /** @@ -544,7 +545,7 @@ export class WriteBatch implements firestore.WriteBatch { const stack = Error().stack!; // Commits should also be retried when they fail with status code ABORTED. - const retryCodes = [Status.ABORTED, ...getRetryCodes('commit')]; + const retryCodes = [StatusCode.ABORTED, ...getRetryCodes('commit')]; return this._commit({retryCodes}) .then(response => { diff --git a/dev/test/lazy-load.ts b/dev/test/lazy-load.ts new file mode 100644 index 000000000..7d4f1bf2a --- /dev/null +++ b/dev/test/lazy-load.ts @@ -0,0 +1,40 @@ +// Copyright 2021 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 {describe, it} from 'mocha'; +import {expect} from 'chai'; + +function isModuleLoaded(moduleName: string) { + return !!Object.keys(require.cache).find( + path => path.indexOf(`node_modules/${moduleName}`) !== -1 + ); +} + +describe('Index.js', () => { + (isModuleLoaded('google-gax') ? it.skip : it)( + 'does not load google-gax', + () => { + require('../src/index'); + expect(isModuleLoaded('google-gax')).to.be.false; + } + ); + + (isModuleLoaded('protobufjs') ? it.skip : it)( + 'does not load protobufjs', + () => { + require('../src/index'); + expect(isModuleLoaded('protobufjs')).to.be.false; + } + ); +}); From a70abfd13569af7c43d4804b3594f94425532128 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 27 May 2021 08:13:46 -0700 Subject: [PATCH 301/337] chore: update gapic-generator-typescript to v1.3.2 (#1511) --- dev/src/v1/firestore_admin_client.ts | 1 - dev/src/v1/firestore_client.ts | 1 - dev/src/v1beta1/firestore_client.ts | 1 - synth.metadata | 6 +++--- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index 4d5812dfe..709830cf6 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -27,7 +27,6 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; -import * as path from 'path'; import {Transform} from 'stream'; import {RequestType} from 'google-gax/build/src/apitypes'; diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 6b3406748..3d9020996 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -26,7 +26,6 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; -import * as path from 'path'; import {Transform} from 'stream'; import {RequestType} from 'google-gax/build/src/apitypes'; diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index c5b016087..b2d3c7ada 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -26,7 +26,6 @@ import { PaginationCallback, GaxCall, } from 'google-gax'; -import * as path from 'path'; import {Transform} from 'stream'; import {RequestType} from 'google-gax/build/src/apitypes'; diff --git a/synth.metadata b/synth.metadata index fadbb8318..849ca008c 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "c2c160663f1d3338d6e156cefe65633f2c2690a1" + "sha": "aa92a1545a64e1164d5454c24fb38fb99aa1fd24" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "75880c3e6a6aa2597400582848e81bbbfac51dea", - "internalRef": "372468161" + "sha": "6fa858c6489b1bbc505a7d7afe39f2dc45819c38", + "internalRef": "372656503" } }, { From c8168a83a864dd77f88b1743adcd3568671702fe Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 27 May 2021 10:34:31 -0600 Subject: [PATCH 302/337] fix: return results from getPartitions() in order (#1521) --- dev/src/collection-group.ts | 32 +++++++++-------- dev/src/order.ts | 2 +- dev/test/partition-query.ts | 70 ++++++++++++++++++++++++++++++++----- 3 files changed, 80 insertions(+), 24 deletions(-) diff --git a/dev/src/collection-group.ts b/dev/src/collection-group.ts index 70a371937..663c229b0 100644 --- a/dev/src/collection-group.ts +++ b/dev/src/collection-group.ts @@ -27,6 +27,7 @@ import {validateInteger} from './validate'; import api = protos.google.firestore.v1; import {defaultConverter} from './types'; +import {compareArrays} from './order'; /** * A `CollectionGroup` refers to all documents that are contained in a @@ -79,8 +80,7 @@ export class CollectionGroup const tag = requestTag(); await this.firestore.initializeIfNeeded(tag); - let lastValues: api.IValue[] | undefined = undefined; - let partitionCount = 0; + const partitions: Array[] = []; if (desiredPartitionCount > 1) { // Partition queries require explicit ordering by __name__. @@ -100,16 +100,7 @@ export class CollectionGroup stream.resume(); for await (const currentCursor of stream) { - ++partitionCount; - const currentValues = currentCursor.values ?? []; - yield new QueryPartition( - this._firestore, - this._queryOptions.collectionId, - this._queryOptions.converter, - lastValues, - currentValues - ); - lastValues = currentValues; + partitions.push(currentCursor.values ?? []); } } @@ -117,15 +108,28 @@ export class CollectionGroup 'Firestore.getPartitions', tag, 'Received %d partitions', - partitionCount + partitions.length ); + // Sort the partitions as they may not be ordered if responses are paged. + partitions.sort((l, r) => compareArrays(l, r)); + + for (let i = 0; i < partitions.length; ++i) { + yield new QueryPartition( + this._firestore, + this._queryOptions.collectionId, + this._queryOptions.converter, + i > 0 ? partitions[i - 1] : undefined, + partitions[i] + ); + } + // Return the extra partition with the empty cursor. yield new QueryPartition( this._firestore, this._queryOptions.collectionId, this._queryOptions.converter, - lastValues, + partitions.pop(), undefined ); } diff --git a/dev/src/order.ts b/dev/src/order.ts index 88c62c63b..5aa264b09 100644 --- a/dev/src/order.ts +++ b/dev/src/order.ts @@ -179,7 +179,7 @@ function compareGeoPoints( /*! * @private */ -function compareArrays(left: api.IValue[], right: api.IValue[]): number { +export function compareArrays(left: api.IValue[], right: api.IValue[]): number { for (let i = 0; i < left.length && i < right.length; i++) { const valueComparison = compare(left[i], right[i]); if (valueComparison !== 0) { diff --git a/dev/test/partition-query.ts b/dev/test/partition-query.ts index 647c3d391..70a338971 100644 --- a/dev/test/partition-query.ts +++ b/dev/test/partition-query.ts @@ -18,13 +18,13 @@ import { QueryPartition, } from '@google-cloud/firestore'; -import {describe, it, beforeEach, afterEach} from 'mocha'; +import {afterEach, beforeEach, describe, it} from 'mocha'; import {expect, use} from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; import * as extend from 'extend'; import {google} from '../protos/firestore_v1_proto_api'; -import {Firestore} from '../src'; +import {DocumentReference, Firestore} from '../src'; import {setTimeoutHandler} from '../src/backoff'; import { ApiOverride, @@ -39,6 +39,8 @@ import api = google.firestore.v1; const PROJECT_ID = 'test-project'; const DATABASE_ROOT = `projects/${PROJECT_ID}/databases/(default)`; +const DOC1 = `${DATABASE_ROOT}/documents/coll/doc1`; +const DOC2 = `${DATABASE_ROOT}/documents/coll/doc2`; export function partitionQueryEquals( actual: api.IPartitionQueryRequest | undefined, @@ -102,10 +104,32 @@ describe('Partition Query', () => { return partitions; } + function verifyPartition( + partition: FirebaseFirestore.QueryPartition, + startAt: string | null, + endBefore: string | null + ) { + if (startAt) { + expect( + partition.startAt?.map(value => (value as DocumentReference).path) + ).to.have.members([startAt]); + } else { + expect(partition.startAt).to.be.undefined; + } + + if (endBefore) { + expect( + partition.endBefore?.map(value => (value as DocumentReference).path) + ).to.have.members([endBefore]); + } else { + expect(partition.endBefore).to.be.undefined; + } + } + it('requests one less than desired partitions', () => { const desiredPartitionsCount = 2; const cursorValue = { - values: [{referenceValue: 'projects/p1/databases/d1/documents/coll/doc'}], + values: [{referenceValue: DOC1}], }; const overrides: ApiOverride = { @@ -156,12 +180,12 @@ describe('Partition Query', () => { const expectedStartAt: Array = [ undefined, - {referenceValue: 'coll/doc1'}, - {referenceValue: 'coll/doc2'}, + {referenceValue: DOC1}, + {referenceValue: DOC2}, ]; const expectedEndBefore: Array = [ - {referenceValue: 'coll/doc1'}, - {referenceValue: 'coll/doc2'}, + {referenceValue: DOC1}, + {referenceValue: DOC2}, undefined, ]; @@ -174,10 +198,10 @@ describe('Partition Query', () => { return stream( { - values: [{referenceValue: 'coll/doc1'}], + values: [{referenceValue: DOC1}], }, { - values: [{referenceValue: 'coll/doc2'}], + values: [{referenceValue: DOC2}], } ); }, @@ -255,4 +279,32 @@ describe('Partition Query', () => { return result[0].toQuery().get(); }); }); + + it('sorts partitions', () => { + const desiredPartitionsCount = 3; + + const overrides: ApiOverride = { + partitionQueryStream: () => { + return stream( + { + values: [{referenceValue: DOC2}], + }, + { + values: [{referenceValue: DOC1}], + } + ); + }, + }; + + return createInstance(overrides).then(async firestore => { + const query = firestore.collectionGroup('collectionId'); + + const partitions = await getPartitions(query, desiredPartitionsCount); + expect(partitions.length).to.equal(3); + + verifyPartition(partitions[0], null, 'coll/doc1'); + verifyPartition(partitions[1], 'coll/doc1', 'coll/doc2'); + verifyPartition(partitions[2], 'coll/doc2', null); + }); + }); }); From 8da2a8c754887a0dfedfc488547ced6fbdb27ccb Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 27 May 2021 16:44:02 +0000 Subject: [PATCH 303/337] chore: release 4.12.1 (#1516) :robot: I have created a release \*beep\* \*boop\* --- ### [4.12.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.12.0...v4.12.1) (2021-05-27) ### Bug Fixes * do not load google-gax at client startup ([#1517](https://www.github.com/googleapis/nodejs-firestore/issues/1517)) ([2141b08](https://www.github.com/googleapis/nodejs-firestore/commit/2141b0879cbccb1354f9821edcc917b6aa4ff0ab)) * recursive delete: backporting changes from Java ([#1514](https://www.github.com/googleapis/nodejs-firestore/issues/1514)) ([92ea651](https://www.github.com/googleapis/nodejs-firestore/commit/92ea651adc84ba854ae7cd203af231573f885307)) * return results from getPartitions() in order ([#1521](https://www.github.com/googleapis/nodejs-firestore/issues/1521)) ([c8168a8](https://www.github.com/googleapis/nodejs-firestore/commit/c8168a83a864dd77f88b1743adcd3568671702fe)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 871311d76..790c4cdef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.12.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.12.0...v4.12.1) (2021-05-27) + + +### Bug Fixes + +* do not load google-gax at client startup ([#1517](https://www.github.com/googleapis/nodejs-firestore/issues/1517)) ([2141b08](https://www.github.com/googleapis/nodejs-firestore/commit/2141b0879cbccb1354f9821edcc917b6aa4ff0ab)) +* recursive delete: backporting changes from Java ([#1514](https://www.github.com/googleapis/nodejs-firestore/issues/1514)) ([92ea651](https://www.github.com/googleapis/nodejs-firestore/commit/92ea651adc84ba854ae7cd203af231573f885307)) +* return results from getPartitions() in order ([#1521](https://www.github.com/googleapis/nodejs-firestore/issues/1521)) ([c8168a8](https://www.github.com/googleapis/nodejs-firestore/commit/c8168a83a864dd77f88b1743adcd3568671702fe)) + ## [4.12.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.11.1...v4.12.0) (2021-05-19) diff --git a/package.json b/package.json index 434655b1d..df6d4916e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.12.0", + "version": "4.12.1", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 1908abd30..78002cef3 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.12.0" + "@google-cloud/firestore": "^4.12.1" }, "devDependencies": { "chai": "^4.2.0", From 791310ff4b0a828ca6d1f5c0fa03a110972afb1f Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 27 May 2021 12:18:44 -0600 Subject: [PATCH 304/337] fix: do not leak credentials in Firestore.toJSON() (#1522) --- dev/src/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dev/src/index.ts b/dev/src/index.ts index 60cd32358..e143554e7 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -1312,6 +1312,16 @@ export class Firestore implements firestore.Firestore { return this._clientPool.terminate(); } + /** + * Returns the Project ID to serve as the JSON representation of this + * Firestore instance. + * + * @return An object that contains the project ID (or `undefined` if not yet + * available). + */ + toJSON(): object { + return {projectId: this._projectId}; + } /** * Initializes the client if it is not already initialized. All methods in the * SDK can be used after this method completes. From c4096affaa69017ff1515d02631fd68614605528 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 27 May 2021 18:26:02 +0000 Subject: [PATCH 305/337] chore: release 4.12.2 (#1523) :robot: I have created a release \*beep\* \*boop\* --- ### [4.12.2](https://www.github.com/googleapis/nodejs-firestore/compare/v4.12.1...v4.12.2) (2021-05-27) ### Bug Fixes * do not leak credentials in Firestore.toJSON() ([#1522](https://www.github.com/googleapis/nodejs-firestore/issues/1522)) ([791310f](https://www.github.com/googleapis/nodejs-firestore/commit/791310ff4b0a828ca6d1f5c0fa03a110972afb1f)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 790c4cdef..8463384c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.12.2](https://www.github.com/googleapis/nodejs-firestore/compare/v4.12.1...v4.12.2) (2021-05-27) + + +### Bug Fixes + +* do not leak credentials in Firestore.toJSON() ([#1522](https://www.github.com/googleapis/nodejs-firestore/issues/1522)) ([791310f](https://www.github.com/googleapis/nodejs-firestore/commit/791310ff4b0a828ca6d1f5c0fa03a110972afb1f)) + ### [4.12.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.12.0...v4.12.1) (2021-05-27) diff --git a/package.json b/package.json index df6d4916e..cdfbe3fe5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.12.1", + "version": "4.12.2", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 78002cef3..c4edb652e 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.12.1" + "@google-cloud/firestore": "^4.12.2" }, "devDependencies": { "chai": "^4.2.0", From adfe68e194d518369d5b4f89e9be89f948efbdbb Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Sat, 29 May 2021 13:55:39 -0700 Subject: [PATCH 306/337] fix: GoogleAdsError missing using generator version after 1.3.0 (#1526) [PR](https://github.com/googleapis/gapic-generator-typescript/pull/878) within updated gapic-generator-typescript version 1.4.0 Committer: @summer-ji-eng PiperOrigin-RevId: 375759421 Source-Author: Google APIs Source-Date: Tue May 25 11:51:53 2021 -0700 Source-Repo: googleapis/googleapis Source-Sha: 95fa72fdd0d69b02d72c33b37d1e4cc66d4b1446 Source-Link: https://github.com/googleapis/googleapis/commit/95fa72fdd0d69b02d72c33b37d1e4cc66d4b1446 --- dev/src/v1/firestore_admin_client.ts | 2 ++ dev/src/v1/firestore_client.ts | 2 ++ dev/src/v1beta1/firestore_client.ts | 2 ++ synth.metadata | 6 +++--- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index 709830cf6..5343adc33 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -143,6 +143,8 @@ export class FirestoreAdminClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { clientHeader.push(`${opts.libName}/${opts.libVersion}`); diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 3d9020996..0f3525328 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -146,6 +146,8 @@ export class FirestoreClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { clientHeader.push(`${opts.libName}/${opts.libVersion}`); diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index b2d3c7ada..0da6be8e3 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -149,6 +149,8 @@ export class FirestoreClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { clientHeader.push(`${opts.libName}/${opts.libVersion}`); diff --git a/synth.metadata b/synth.metadata index 849ca008c..c87b0f08d 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "aa92a1545a64e1164d5454c24fb38fb99aa1fd24" + "sha": "c4096affaa69017ff1515d02631fd68614605528" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "6fa858c6489b1bbc505a7d7afe39f2dc45819c38", - "internalRef": "372656503" + "sha": "95fa72fdd0d69b02d72c33b37d1e4cc66d4b1446", + "internalRef": "375759421" } }, { From cd7e35c5e47f709399bd64d5620004ce9f494b0d Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 1 Jun 2021 10:05:00 -0500 Subject: [PATCH 307/337] docs: hiding MIN_PENDING_OPS from global docs (#1525) --- dev/src/recursive-delete.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dev/src/recursive-delete.ts b/dev/src/recursive-delete.ts index 3c66f49f5..cb413b15b 100644 --- a/dev/src/recursive-delete.ts +++ b/dev/src/recursive-delete.ts @@ -31,15 +31,13 @@ import {BulkWriterError} from './bulk-writer'; import {QueryOptions} from './reference'; import {StatusCode} from './status-code'; -/** +/*! * Datastore allowed numeric IDs where Firestore only allows strings. Numeric * IDs are exposed to Firestore as __idNUM__, so this is the lowest possible * negative numeric value expressed in that format. * * This constant is used to specify startAt/endAt values when querying for all * descendants in a single collection. - * - * @private */ export const REFERENCE_NAME_MIN_ID = '__id-9223372036854775808__'; @@ -51,7 +49,7 @@ export const REFERENCE_NAME_MIN_ID = '__id-9223372036854775808__'; // Visible for testing. export const RECURSIVE_DELETE_MAX_PENDING_OPS = 5000; -/** +/*! * The number of pending BulkWriter operations at which RecursiveDelete * starts the next limit query to fetch descendants. By starting the query * while there are pending operations, Firestore can improve BulkWriter From b135242976deace96d4a1843975b9f563cfab4c7 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 8 Jun 2021 08:46:28 -0700 Subject: [PATCH 308/337] chore: Report warning on `.github/workflows/ci.yaml` (#1530) * fix: Report warning on `.github/workflows/ci.yaml` Not all files in `.github/workflows` are managed, only `ci.yaml`. Related false-positive: https://github.com/googleapis/repo-automation-bots/pull/1952#issuecomment-856142886 * fix: Report warning on `.github/workflows/ci.yaml` Not all files in `.github/workflows` are managed, only `ci.yaml`. Source-Author: Daniel Bankhead Source-Date: Mon Jun 7 11:30:30 2021 -0700 Source-Repo: googleapis/synthtool Source-Sha: 2430f8d90ed8a508e8422a3a7191e656d5a6bf53 Source-Link: https://github.com/googleapis/synthtool/commit/2430f8d90ed8a508e8422a3a7191e656d5a6bf53 --- .github/generated-files-bot.yml | 4 ++-- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/generated-files-bot.yml b/.github/generated-files-bot.yml index 6b04910c0..7bb7ce54c 100644 --- a/.github/generated-files-bot.yml +++ b/.github/generated-files-bot.yml @@ -3,8 +3,8 @@ generatedFiles: message: '`.kokoro` files are templated and should be updated in [`synthtool`](https://github.com/googleapis/synthtool)' - path: '.github/CODEOWNERS' message: 'CODEOWNERS should instead be modified via the `codeowner_team` property in .repo-metadata.json' -- path: '.github/workflows/**' - message: '`.github/workflows` (GitHub Actions) should be updated in [`synthtool`](https://github.com/googleapis/synthtool)' +- path: '.github/workflows/ci.yaml' + message: '`.github/workflows/ci.yaml` (GitHub Actions) should be updated in [`synthtool`](https://github.com/googleapis/synthtool)' - path: '.github/generated-files-bot.+(yml|yaml)' message: '`.github/generated-files-bot.(yml|yaml)` should be updated in [`synthtool`](https://github.com/googleapis/synthtool)' - path: 'README.md' diff --git a/synth.metadata b/synth.metadata index c87b0f08d..12174dc3e 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "c4096affaa69017ff1515d02631fd68614605528" + "sha": "cd7e35c5e47f709399bd64d5620004ce9f494b0d" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "7332178a11ddddc91188dc0f25bca1ccadcaa6c6" + "sha": "2430f8d90ed8a508e8422a3a7191e656d5a6bf53" } } ], From 9107a7b25218273f5a1578ccfdc7bdd8dffee8e8 Mon Sep 17 00:00:00 2001 From: "F. Hinkelmann" Date: Thu, 10 Jun 2021 23:02:32 +0200 Subject: [PATCH 309/337] chore(nodejs): remove api-extractor dependencies (#1533) --- package.json | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index cdfbe3fe5..64777e4ea 100644 --- a/package.json +++ b/package.json @@ -47,9 +47,7 @@ "docs-test": "linkinator docs", "predocs-test": "npm run docs", "prelint": "cd samples; npm link ../; npm install", - "precompile": "gts clean", - "api-extractor": "api-extractor run --local", - "api-documenter": "api-documenter yaml --input-folder=temp" + "precompile": "gts clean" }, "dependencies": { "fast-deep-equal": "^3.1.1", @@ -84,8 +82,6 @@ "sinon": "^11.0.0", "ts-node": "^10.0.0", "typescript": "3.8.3", - "through2": "^4.0.0", - "@microsoft/api-documenter": "^7.8.10", - "@microsoft/api-extractor": "^7.8.10" + "through2": "^4.0.0" } } From 9f4c313225273fb0027b82b402dc6088351ef2da Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 14 Jun 2021 17:13:00 +0200 Subject: [PATCH 310/337] chore(deps): update dependency @types/mocha to v8 (#1528) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 64777e4ea..3d25cba43 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "@types/chai-as-promised": "^7.1.2", "@types/duplexify": "^3.5.0", "@types/extend": "^3.0.0", - "@types/mocha": "^7.0.0", + "@types/mocha": "^8.0.0", "@types/node": "^14.0.0", "@types/sinon": "^10.0.0", "@types/through2": "^2.0.34", From 115a13407b907887a930b4299ebed042532c3ec2 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 16 Jun 2021 10:02:49 -0700 Subject: [PATCH 311/337] fix: bulkWriter: ensure buffered batches are sent after flush (#1535) --- dev/src/bulk-writer.ts | 50 +++++++++++++++++++++++++++++---- dev/test/bulk-writer.ts | 62 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 6 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 9c7cd1579..2a2d8c5d5 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -108,6 +108,9 @@ class BulkWriterOperation { private lastStatus?: StatusCode; private _backoffDuration = 0; + /** Whether flush() was called when this was the last enqueued operation. */ + private _flushed = false; + /** * @param ref The document reference being written to. * @param type The type of operation that created this write. @@ -134,6 +137,14 @@ class BulkWriterOperation { return this._backoffDuration; } + markFlushed(): void { + this._flushed = true; + } + + get flushed(): boolean { + return this._flushed; + } + onError(error: GoogleError): void { ++this.failedAttempts; @@ -271,6 +282,18 @@ class BulkCommitBatch extends WriteBatch { } } +/** + * Used to represent a buffered BulkWriterOperation. + * + * @private + */ +class BufferedOperation { + constructor( + readonly operation: BulkWriterOperation, + readonly sendFn: () => void + ) {} +} + /** * The error thrown when a BulkWriter operation fails. * @@ -354,7 +377,7 @@ export class BulkWriter { * of pending operations has been enqueued. * @private */ - private _bufferedOperations: Array<() => void> = []; + private _bufferedOperations: Array = []; // Visible for testing. _getBufferedOperationsCount(): number { @@ -751,6 +774,15 @@ export class BulkWriter { flush(): Promise { this._verifyNotClosed(); this._scheduleCurrentBatch(/* flush= */ true); + + // Mark the most recent operation as flushed to ensure that the batch + // containing it will be sent once it's popped from the buffer. + if (this._bufferedOperations.length > 0) { + this._bufferedOperations[ + this._bufferedOperations.length - 1 + ].operation.markFlushed(); + } + return this._lastOp; } @@ -898,10 +930,12 @@ export class BulkWriter { this._pendingOpsCount++; this._sendFn(enqueueOnBatchCallback, bulkWriterOp); } else { - this._bufferedOperations.push(() => { - this._pendingOpsCount++; - this._sendFn(enqueueOnBatchCallback, bulkWriterOp); - }); + this._bufferedOperations.push( + new BufferedOperation(bulkWriterOp, () => { + this._pendingOpsCount++; + this._sendFn(enqueueOnBatchCallback, bulkWriterOp); + }) + ); } // Chain the BulkWriter operation promise with the buffer processing logic @@ -931,7 +965,7 @@ export class BulkWriter { this._bufferedOperations.length > 0 ) { const nextOp = this._bufferedOperations.shift()!; - nextOp(); + nextOp.sendFn(); } } @@ -956,6 +990,10 @@ export class BulkWriter { if (this._bulkCommitBatch._opCount === this._maxBatchSize) { this._scheduleCurrentBatch(); + } else if (op.flushed) { + // If flush() was called before this operation was enqueued into a batch, + // we still need to schedule it. + this._scheduleCurrentBatch(/* flush= */ true); } } } diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index b9c49ef58..61ad9278d 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -544,6 +544,68 @@ describe('BulkWriter', () => { }); }); + it('buffered operations are flushed after being enqueued', async () => { + const bulkWriter = await instantiateInstance([ + { + request: createRequest([ + setOp('doc1', 'bar'), + setOp('doc2', 'bar'), + setOp('doc3', 'bar'), + ]), + response: mergeResponses([ + successResponse(1), + successResponse(2), + successResponse(3), + ]), + }, + { + request: createRequest([ + setOp('doc4', 'bar'), + setOp('doc5', 'bar'), + setOp('doc6', 'bar'), + ]), + response: mergeResponses([ + successResponse(4), + successResponse(5), + successResponse(6), + ]), + }, + { + request: createRequest([setOp('doc7', 'bar')]), + response: successResponse(7), + }, + ]); + bulkWriter._setMaxPendingOpCount(6); + bulkWriter._maxBatchSize = 3; + bulkWriter + .set(firestore.doc('collectionId/doc1'), {foo: 'bar'}) + .then(incrementOpCount); + bulkWriter + .set(firestore.doc('collectionId/doc2'), {foo: 'bar'}) + .then(incrementOpCount); + bulkWriter + .set(firestore.doc('collectionId/doc3'), {foo: 'bar'}) + .then(incrementOpCount); + bulkWriter + .set(firestore.doc('collectionId/doc4'), {foo: 'bar'}) + .then(incrementOpCount); + bulkWriter + .set(firestore.doc('collectionId/doc5'), {foo: 'bar'}) + .then(incrementOpCount); + bulkWriter + .set(firestore.doc('collectionId/doc6'), {foo: 'bar'}) + .then(incrementOpCount); + + // The 7th operation is buffered. We want to check that the operation is + // still sent even though it is not enqueued when close() is called. + bulkWriter + .set(firestore.doc('collectionId/doc7'), {foo: 'bar'}) + .then(incrementOpCount); + return bulkWriter.close().then(async () => { + verifyOpCount(7); + }); + }); + it('runs the success handler', async () => { const bulkWriter = await instantiateInstance([ { From 334d754217fabc7878cd0845c8a6f686f78c93d4 Mon Sep 17 00:00:00 2001 From: Takashi Matsuo Date: Wed, 16 Jun 2021 11:40:37 -0700 Subject: [PATCH 312/337] chore: create flakybot.yaml (#1534) * chore: create flakybot.yaml This will instruct flakybot to apply `priority: p2` label to its issues. * Update flakybot.yaml Co-authored-by: Christopher Wilcox --- .github/flakybot.yaml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/flakybot.yaml diff --git a/.github/flakybot.yaml b/.github/flakybot.yaml new file mode 100644 index 000000000..ba7969774 --- /dev/null +++ b/.github/flakybot.yaml @@ -0,0 +1,3 @@ +issuePriority: p2 + + From 1805c3ff411e42ae584f0e6c2629b1f2231340da Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 16 Jun 2021 15:02:23 -0500 Subject: [PATCH 313/337] chore: release 4.12.3 (#1527) --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8463384c2..c86ca46b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.12.3](https://www.github.com/googleapis/nodejs-firestore/compare/v4.12.2...v4.12.3) (2021-06-16) + + +### Bug Fixes + +* bulkWriter: ensure buffered batches are sent after flush ([#1535](https://www.github.com/googleapis/nodejs-firestore/issues/1535)) ([115a134](https://www.github.com/googleapis/nodejs-firestore/commit/115a13407b907887a930b4299ebed042532c3ec2)) +* GoogleAdsError missing using generator version after 1.3.0 ([#1526](https://www.github.com/googleapis/nodejs-firestore/issues/1526)) ([adfe68e](https://www.github.com/googleapis/nodejs-firestore/commit/adfe68e194d518369d5b4f89e9be89f948efbdbb)) + ### [4.12.2](https://www.github.com/googleapis/nodejs-firestore/compare/v4.12.1...v4.12.2) (2021-05-27) diff --git a/package.json b/package.json index 3d25cba43..c2bfa004c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.12.2", + "version": "4.12.3", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index c4edb652e..a13fd6ba0 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.12.2" + "@google-cloud/firestore": "^4.12.3" }, "devDependencies": { "chai": "^4.2.0", From f6edfc181ca39cd307eab6d141db08f377d5cfdf Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 22 Jun 2021 13:20:32 -0700 Subject: [PATCH 314/337] fix: make request optional in all cases (#1536) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/a5e72088-ff72-4878-81b8-64ec843e7a09/targets - [ ] To automatically regenerate this PR, check this box. (May take up to 24 hours.) PiperOrigin-RevId: 380641501 Source-Link: https://github.com/googleapis/googleapis/commit/076f7e9f0b258bdb54338895d7251b202e8f0de3 --- dev/src/v1/firestore_admin_client.ts | 36 +++++++++++------------ dev/src/v1/firestore_client.ts | 44 ++++++++++++++-------------- dev/src/v1beta1/firestore_client.ts | 44 ++++++++++++++-------------- synth.metadata | 6 ++-- types/v1/firestore_admin_client.d.ts | 18 ++++++------ types/v1/firestore_client.d.ts | 22 +++++++------- types/v1beta1/firestore_client.d.ts | 22 +++++++------- 7 files changed, 96 insertions(+), 96 deletions(-) diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index 5343adc33..aedca6d4a 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -390,7 +390,7 @@ export class FirestoreAdminClient { // -- Service calls -- // ------------------- getIndex( - request: protos.google.firestore.admin.v1.IGetIndexRequest, + request?: protos.google.firestore.admin.v1.IGetIndexRequest, options?: CallOptions ): Promise< [ @@ -435,7 +435,7 @@ export class FirestoreAdminClient { * const [response] = await client.getIndex(request); */ getIndex( - request: protos.google.firestore.admin.v1.IGetIndexRequest, + request?: protos.google.firestore.admin.v1.IGetIndexRequest, optionsOrCallback?: | CallOptions | Callback< @@ -474,7 +474,7 @@ export class FirestoreAdminClient { return this.innerApiCalls.getIndex(request, options, callback); } deleteIndex( - request: protos.google.firestore.admin.v1.IDeleteIndexRequest, + request?: protos.google.firestore.admin.v1.IDeleteIndexRequest, options?: CallOptions ): Promise< [ @@ -519,7 +519,7 @@ export class FirestoreAdminClient { * const [response] = await client.deleteIndex(request); */ deleteIndex( - request: protos.google.firestore.admin.v1.IDeleteIndexRequest, + request?: protos.google.firestore.admin.v1.IDeleteIndexRequest, optionsOrCallback?: | CallOptions | Callback< @@ -560,7 +560,7 @@ export class FirestoreAdminClient { return this.innerApiCalls.deleteIndex(request, options, callback); } getField( - request: protos.google.firestore.admin.v1.IGetFieldRequest, + request?: protos.google.firestore.admin.v1.IGetFieldRequest, options?: CallOptions ): Promise< [ @@ -605,7 +605,7 @@ export class FirestoreAdminClient { * const [response] = await client.getField(request); */ getField( - request: protos.google.firestore.admin.v1.IGetFieldRequest, + request?: protos.google.firestore.admin.v1.IGetFieldRequest, optionsOrCallback?: | CallOptions | Callback< @@ -645,7 +645,7 @@ export class FirestoreAdminClient { } createIndex( - request: protos.google.firestore.admin.v1.ICreateIndexRequest, + request?: protos.google.firestore.admin.v1.ICreateIndexRequest, options?: CallOptions ): Promise< [ @@ -706,7 +706,7 @@ export class FirestoreAdminClient { * const [response] = await operation.promise(); */ createIndex( - request: protos.google.firestore.admin.v1.ICreateIndexRequest, + request?: protos.google.firestore.admin.v1.ICreateIndexRequest, optionsOrCallback?: | CallOptions | Callback< @@ -791,7 +791,7 @@ export class FirestoreAdminClient { >; } updateField( - request: protos.google.firestore.admin.v1.IUpdateFieldRequest, + request?: protos.google.firestore.admin.v1.IUpdateFieldRequest, options?: CallOptions ): Promise< [ @@ -862,7 +862,7 @@ export class FirestoreAdminClient { * const [response] = await operation.promise(); */ updateField( - request: protos.google.firestore.admin.v1.IUpdateFieldRequest, + request?: protos.google.firestore.admin.v1.IUpdateFieldRequest, optionsOrCallback?: | CallOptions | Callback< @@ -947,7 +947,7 @@ export class FirestoreAdminClient { >; } exportDocuments( - request: protos.google.firestore.admin.v1.IExportDocumentsRequest, + request?: protos.google.firestore.admin.v1.IExportDocumentsRequest, options?: CallOptions ): Promise< [ @@ -1022,7 +1022,7 @@ export class FirestoreAdminClient { * const [response] = await operation.promise(); */ exportDocuments( - request: protos.google.firestore.admin.v1.IExportDocumentsRequest, + request?: protos.google.firestore.admin.v1.IExportDocumentsRequest, optionsOrCallback?: | CallOptions | Callback< @@ -1107,7 +1107,7 @@ export class FirestoreAdminClient { >; } importDocuments( - request: protos.google.firestore.admin.v1.IImportDocumentsRequest, + request?: protos.google.firestore.admin.v1.IImportDocumentsRequest, options?: CallOptions ): Promise< [ @@ -1177,7 +1177,7 @@ export class FirestoreAdminClient { * const [response] = await operation.promise(); */ importDocuments( - request: protos.google.firestore.admin.v1.IImportDocumentsRequest, + request?: protos.google.firestore.admin.v1.IImportDocumentsRequest, optionsOrCallback?: | CallOptions | Callback< @@ -1262,7 +1262,7 @@ export class FirestoreAdminClient { >; } listIndexes( - request: protos.google.firestore.admin.v1.IListIndexesRequest, + request?: protos.google.firestore.admin.v1.IListIndexesRequest, options?: CallOptions ): Promise< [ @@ -1318,7 +1318,7 @@ export class FirestoreAdminClient { * for more details and examples. */ listIndexes( - request: protos.google.firestore.admin.v1.IListIndexesRequest, + request?: protos.google.firestore.admin.v1.IListIndexesRequest, optionsOrCallback?: | CallOptions | PaginationCallback< @@ -1462,7 +1462,7 @@ export class FirestoreAdminClient { ) as AsyncIterable; } listFields( - request: protos.google.firestore.admin.v1.IListFieldsRequest, + request?: protos.google.firestore.admin.v1.IListFieldsRequest, options?: CallOptions ): Promise< [ @@ -1527,7 +1527,7 @@ export class FirestoreAdminClient { * for more details and examples. */ listFields( - request: protos.google.firestore.admin.v1.IListFieldsRequest, + request?: protos.google.firestore.admin.v1.IListFieldsRequest, optionsOrCallback?: | CallOptions | PaginationCallback< diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 0f3525328..958e74688 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -343,7 +343,7 @@ export class FirestoreClient { // -- Service calls -- // ------------------- getDocument( - request: protos.google.firestore.v1.IGetDocumentRequest, + request?: protos.google.firestore.v1.IGetDocumentRequest, options?: CallOptions ): Promise< [ @@ -398,7 +398,7 @@ export class FirestoreClient { * const [response] = await client.getDocument(request); */ getDocument( - request: protos.google.firestore.v1.IGetDocumentRequest, + request?: protos.google.firestore.v1.IGetDocumentRequest, optionsOrCallback?: | CallOptions | Callback< @@ -437,7 +437,7 @@ export class FirestoreClient { return this.innerApiCalls.getDocument(request, options, callback); } updateDocument( - request: protos.google.firestore.v1.IUpdateDocumentRequest, + request?: protos.google.firestore.v1.IUpdateDocumentRequest, options?: CallOptions ): Promise< [ @@ -498,7 +498,7 @@ export class FirestoreClient { * const [response] = await client.updateDocument(request); */ updateDocument( - request: protos.google.firestore.v1.IUpdateDocumentRequest, + request?: protos.google.firestore.v1.IUpdateDocumentRequest, optionsOrCallback?: | CallOptions | Callback< @@ -537,7 +537,7 @@ export class FirestoreClient { return this.innerApiCalls.updateDocument(request, options, callback); } deleteDocument( - request: protos.google.firestore.v1.IDeleteDocumentRequest, + request?: protos.google.firestore.v1.IDeleteDocumentRequest, options?: CallOptions ): Promise< [ @@ -585,7 +585,7 @@ export class FirestoreClient { * const [response] = await client.deleteDocument(request); */ deleteDocument( - request: protos.google.firestore.v1.IDeleteDocumentRequest, + request?: protos.google.firestore.v1.IDeleteDocumentRequest, optionsOrCallback?: | CallOptions | Callback< @@ -624,7 +624,7 @@ export class FirestoreClient { return this.innerApiCalls.deleteDocument(request, options, callback); } beginTransaction( - request: protos.google.firestore.v1.IBeginTransactionRequest, + request?: protos.google.firestore.v1.IBeginTransactionRequest, options?: CallOptions ): Promise< [ @@ -672,7 +672,7 @@ export class FirestoreClient { * const [response] = await client.beginTransaction(request); */ beginTransaction( - request: protos.google.firestore.v1.IBeginTransactionRequest, + request?: protos.google.firestore.v1.IBeginTransactionRequest, optionsOrCallback?: | CallOptions | Callback< @@ -713,7 +713,7 @@ export class FirestoreClient { return this.innerApiCalls.beginTransaction(request, options, callback); } commit( - request: protos.google.firestore.v1.ICommitRequest, + request?: protos.google.firestore.v1.ICommitRequest, options?: CallOptions ): Promise< [ @@ -764,7 +764,7 @@ export class FirestoreClient { * const [response] = await client.commit(request); */ commit( - request: protos.google.firestore.v1.ICommitRequest, + request?: protos.google.firestore.v1.ICommitRequest, optionsOrCallback?: | CallOptions | Callback< @@ -803,7 +803,7 @@ export class FirestoreClient { return this.innerApiCalls.commit(request, options, callback); } rollback( - request: protos.google.firestore.v1.IRollbackRequest, + request?: protos.google.firestore.v1.IRollbackRequest, options?: CallOptions ): Promise< [ @@ -850,7 +850,7 @@ export class FirestoreClient { * const [response] = await client.rollback(request); */ rollback( - request: protos.google.firestore.v1.IRollbackRequest, + request?: protos.google.firestore.v1.IRollbackRequest, optionsOrCallback?: | CallOptions | Callback< @@ -889,7 +889,7 @@ export class FirestoreClient { return this.innerApiCalls.rollback(request, options, callback); } batchWrite( - request: protos.google.firestore.v1.IBatchWriteRequest, + request?: protos.google.firestore.v1.IBatchWriteRequest, options?: CallOptions ): Promise< [ @@ -950,7 +950,7 @@ export class FirestoreClient { * const [response] = await client.batchWrite(request); */ batchWrite( - request: protos.google.firestore.v1.IBatchWriteRequest, + request?: protos.google.firestore.v1.IBatchWriteRequest, optionsOrCallback?: | CallOptions | Callback< @@ -989,7 +989,7 @@ export class FirestoreClient { return this.innerApiCalls.batchWrite(request, options, callback); } createDocument( - request: protos.google.firestore.v1.ICreateDocumentRequest, + request?: protos.google.firestore.v1.ICreateDocumentRequest, options?: CallOptions ): Promise< [ @@ -1048,7 +1048,7 @@ export class FirestoreClient { * const [response] = await client.createDocument(request); */ createDocument( - request: protos.google.firestore.v1.ICreateDocumentRequest, + request?: protos.google.firestore.v1.ICreateDocumentRequest, optionsOrCallback?: | CallOptions | Callback< @@ -1247,7 +1247,7 @@ export class FirestoreClient { } listDocuments( - request: protos.google.firestore.v1.IListDocumentsRequest, + request?: protos.google.firestore.v1.IListDocumentsRequest, options?: CallOptions ): Promise< [ @@ -1326,7 +1326,7 @@ export class FirestoreClient { * for more details and examples. */ listDocuments( - request: protos.google.firestore.v1.IListDocumentsRequest, + request?: protos.google.firestore.v1.IListDocumentsRequest, optionsOrCallback?: | CallOptions | PaginationCallback< @@ -1514,7 +1514,7 @@ export class FirestoreClient { ) as AsyncIterable; } partitionQuery( - request: protos.google.firestore.v1.IPartitionQueryRequest, + request?: protos.google.firestore.v1.IPartitionQueryRequest, options?: CallOptions ): Promise< [ @@ -1602,7 +1602,7 @@ export class FirestoreClient { * for more details and examples. */ partitionQuery( - request: protos.google.firestore.v1.IPartitionQueryRequest, + request?: protos.google.firestore.v1.IPartitionQueryRequest, optionsOrCallback?: | CallOptions | PaginationCallback< @@ -1804,7 +1804,7 @@ export class FirestoreClient { ) as AsyncIterable; } listCollectionIds( - request: protos.google.firestore.v1.IListCollectionIdsRequest, + request?: protos.google.firestore.v1.IListCollectionIdsRequest, options?: CallOptions ): Promise< [ @@ -1859,7 +1859,7 @@ export class FirestoreClient { * for more details and examples. */ listCollectionIds( - request: protos.google.firestore.v1.IListCollectionIdsRequest, + request?: protos.google.firestore.v1.IListCollectionIdsRequest, optionsOrCallback?: | CallOptions | PaginationCallback< diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index 0da6be8e3..10fbc0a3f 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -346,7 +346,7 @@ export class FirestoreClient { // -- Service calls -- // ------------------- getDocument( - request: protos.google.firestore.v1beta1.IGetDocumentRequest, + request?: protos.google.firestore.v1beta1.IGetDocumentRequest, options?: CallOptions ): Promise< [ @@ -401,7 +401,7 @@ export class FirestoreClient { * const [response] = await client.getDocument(request); */ getDocument( - request: protos.google.firestore.v1beta1.IGetDocumentRequest, + request?: protos.google.firestore.v1beta1.IGetDocumentRequest, optionsOrCallback?: | CallOptions | Callback< @@ -442,7 +442,7 @@ export class FirestoreClient { return this.innerApiCalls.getDocument(request, options, callback); } updateDocument( - request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, + request?: protos.google.firestore.v1beta1.IUpdateDocumentRequest, options?: CallOptions ): Promise< [ @@ -503,7 +503,7 @@ export class FirestoreClient { * const [response] = await client.updateDocument(request); */ updateDocument( - request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, + request?: protos.google.firestore.v1beta1.IUpdateDocumentRequest, optionsOrCallback?: | CallOptions | Callback< @@ -544,7 +544,7 @@ export class FirestoreClient { return this.innerApiCalls.updateDocument(request, options, callback); } deleteDocument( - request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, + request?: protos.google.firestore.v1beta1.IDeleteDocumentRequest, options?: CallOptions ): Promise< [ @@ -592,7 +592,7 @@ export class FirestoreClient { * const [response] = await client.deleteDocument(request); */ deleteDocument( - request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, + request?: protos.google.firestore.v1beta1.IDeleteDocumentRequest, optionsOrCallback?: | CallOptions | Callback< @@ -633,7 +633,7 @@ export class FirestoreClient { return this.innerApiCalls.deleteDocument(request, options, callback); } beginTransaction( - request: protos.google.firestore.v1beta1.IBeginTransactionRequest, + request?: protos.google.firestore.v1beta1.IBeginTransactionRequest, options?: CallOptions ): Promise< [ @@ -685,7 +685,7 @@ export class FirestoreClient { * const [response] = await client.beginTransaction(request); */ beginTransaction( - request: protos.google.firestore.v1beta1.IBeginTransactionRequest, + request?: protos.google.firestore.v1beta1.IBeginTransactionRequest, optionsOrCallback?: | CallOptions | Callback< @@ -728,7 +728,7 @@ export class FirestoreClient { return this.innerApiCalls.beginTransaction(request, options, callback); } commit( - request: protos.google.firestore.v1beta1.ICommitRequest, + request?: protos.google.firestore.v1beta1.ICommitRequest, options?: CallOptions ): Promise< [ @@ -779,7 +779,7 @@ export class FirestoreClient { * const [response] = await client.commit(request); */ commit( - request: protos.google.firestore.v1beta1.ICommitRequest, + request?: protos.google.firestore.v1beta1.ICommitRequest, optionsOrCallback?: | CallOptions | Callback< @@ -818,7 +818,7 @@ export class FirestoreClient { return this.innerApiCalls.commit(request, options, callback); } rollback( - request: protos.google.firestore.v1beta1.IRollbackRequest, + request?: protos.google.firestore.v1beta1.IRollbackRequest, options?: CallOptions ): Promise< [ @@ -865,7 +865,7 @@ export class FirestoreClient { * const [response] = await client.rollback(request); */ rollback( - request: protos.google.firestore.v1beta1.IRollbackRequest, + request?: protos.google.firestore.v1beta1.IRollbackRequest, optionsOrCallback?: | CallOptions | Callback< @@ -904,7 +904,7 @@ export class FirestoreClient { return this.innerApiCalls.rollback(request, options, callback); } batchWrite( - request: protos.google.firestore.v1beta1.IBatchWriteRequest, + request?: protos.google.firestore.v1beta1.IBatchWriteRequest, options?: CallOptions ): Promise< [ @@ -965,7 +965,7 @@ export class FirestoreClient { * const [response] = await client.batchWrite(request); */ batchWrite( - request: protos.google.firestore.v1beta1.IBatchWriteRequest, + request?: protos.google.firestore.v1beta1.IBatchWriteRequest, optionsOrCallback?: | CallOptions | Callback< @@ -1004,7 +1004,7 @@ export class FirestoreClient { return this.innerApiCalls.batchWrite(request, options, callback); } createDocument( - request: protos.google.firestore.v1beta1.ICreateDocumentRequest, + request?: protos.google.firestore.v1beta1.ICreateDocumentRequest, options?: CallOptions ): Promise< [ @@ -1063,7 +1063,7 @@ export class FirestoreClient { * const [response] = await client.createDocument(request); */ createDocument( - request: protos.google.firestore.v1beta1.ICreateDocumentRequest, + request?: protos.google.firestore.v1beta1.ICreateDocumentRequest, optionsOrCallback?: | CallOptions | Callback< @@ -1264,7 +1264,7 @@ export class FirestoreClient { } listDocuments( - request: protos.google.firestore.v1beta1.IListDocumentsRequest, + request?: protos.google.firestore.v1beta1.IListDocumentsRequest, options?: CallOptions ): Promise< [ @@ -1343,7 +1343,7 @@ export class FirestoreClient { * for more details and examples. */ listDocuments( - request: protos.google.firestore.v1beta1.IListDocumentsRequest, + request?: protos.google.firestore.v1beta1.IListDocumentsRequest, optionsOrCallback?: | CallOptions | PaginationCallback< @@ -1533,7 +1533,7 @@ export class FirestoreClient { ) as AsyncIterable; } partitionQuery( - request: protos.google.firestore.v1beta1.IPartitionQueryRequest, + request?: protos.google.firestore.v1beta1.IPartitionQueryRequest, options?: CallOptions ): Promise< [ @@ -1625,7 +1625,7 @@ export class FirestoreClient { * for more details and examples. */ partitionQuery( - request: protos.google.firestore.v1beta1.IPartitionQueryRequest, + request?: protos.google.firestore.v1beta1.IPartitionQueryRequest, optionsOrCallback?: | CallOptions | PaginationCallback< @@ -1831,7 +1831,7 @@ export class FirestoreClient { ) as AsyncIterable; } listCollectionIds( - request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, + request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, options?: CallOptions ): Promise< [ @@ -1890,7 +1890,7 @@ export class FirestoreClient { * for more details and examples. */ listCollectionIds( - request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, + request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, optionsOrCallback?: | CallOptions | PaginationCallback< diff --git a/synth.metadata b/synth.metadata index 12174dc3e..f31e16d00 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "cd7e35c5e47f709399bd64d5620004ce9f494b0d" + "sha": "1805c3ff411e42ae584f0e6c2629b1f2231340da" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "95fa72fdd0d69b02d72c33b37d1e4cc66d4b1446", - "internalRef": "375759421" + "sha": "076f7e9f0b258bdb54338895d7251b202e8f0de3", + "internalRef": "380641501" } }, { diff --git a/types/v1/firestore_admin_client.d.ts b/types/v1/firestore_admin_client.d.ts index 9b5b5ac70..945ebe8a0 100644 --- a/types/v1/firestore_admin_client.d.ts +++ b/types/v1/firestore_admin_client.d.ts @@ -125,7 +125,7 @@ export declare class FirestoreAdminClient { getProjectId(): Promise; getProjectId(callback: Callback): void; getIndex( - request: protos.google.firestore.admin.v1.IGetIndexRequest, + request?: protos.google.firestore.admin.v1.IGetIndexRequest, options?: CallOptions ): Promise< [ @@ -152,7 +152,7 @@ export declare class FirestoreAdminClient { > ): void; deleteIndex( - request: protos.google.firestore.admin.v1.IDeleteIndexRequest, + request?: protos.google.firestore.admin.v1.IDeleteIndexRequest, options?: CallOptions ): Promise< [ @@ -179,7 +179,7 @@ export declare class FirestoreAdminClient { > ): void; getField( - request: protos.google.firestore.admin.v1.IGetFieldRequest, + request?: protos.google.firestore.admin.v1.IGetFieldRequest, options?: CallOptions ): Promise< [ @@ -206,7 +206,7 @@ export declare class FirestoreAdminClient { > ): void; createIndex( - request: protos.google.firestore.admin.v1.ICreateIndexRequest, + request?: protos.google.firestore.admin.v1.ICreateIndexRequest, options?: CallOptions ): Promise< [ @@ -265,7 +265,7 @@ export declare class FirestoreAdminClient { > >; updateField( - request: protos.google.firestore.admin.v1.IUpdateFieldRequest, + request?: protos.google.firestore.admin.v1.IUpdateFieldRequest, options?: CallOptions ): Promise< [ @@ -324,7 +324,7 @@ export declare class FirestoreAdminClient { > >; exportDocuments( - request: protos.google.firestore.admin.v1.IExportDocumentsRequest, + request?: protos.google.firestore.admin.v1.IExportDocumentsRequest, options?: CallOptions ): Promise< [ @@ -383,7 +383,7 @@ export declare class FirestoreAdminClient { > >; importDocuments( - request: protos.google.firestore.admin.v1.IImportDocumentsRequest, + request?: protos.google.firestore.admin.v1.IImportDocumentsRequest, options?: CallOptions ): Promise< [ @@ -442,7 +442,7 @@ export declare class FirestoreAdminClient { > >; listIndexes( - request: protos.google.firestore.admin.v1.IListIndexesRequest, + request?: protos.google.firestore.admin.v1.IListIndexesRequest, options?: CallOptions ): Promise< [ @@ -537,7 +537,7 @@ export declare class FirestoreAdminClient { options?: CallOptions ): AsyncIterable; listFields( - request: protos.google.firestore.admin.v1.IListFieldsRequest, + request?: protos.google.firestore.admin.v1.IListFieldsRequest, options?: CallOptions ): Promise< [ diff --git a/types/v1/firestore_client.d.ts b/types/v1/firestore_client.d.ts index 0f44774c0..fca4787e1 100644 --- a/types/v1/firestore_client.d.ts +++ b/types/v1/firestore_client.d.ts @@ -126,7 +126,7 @@ export declare class FirestoreClient { getProjectId(): Promise; getProjectId(callback: Callback): void; getDocument( - request: protos.google.firestore.v1.IGetDocumentRequest, + request?: protos.google.firestore.v1.IGetDocumentRequest, options?: CallOptions ): Promise< [ @@ -153,7 +153,7 @@ export declare class FirestoreClient { > ): void; updateDocument( - request: protos.google.firestore.v1.IUpdateDocumentRequest, + request?: protos.google.firestore.v1.IUpdateDocumentRequest, options?: CallOptions ): Promise< [ @@ -180,7 +180,7 @@ export declare class FirestoreClient { > ): void; deleteDocument( - request: protos.google.firestore.v1.IDeleteDocumentRequest, + request?: protos.google.firestore.v1.IDeleteDocumentRequest, options?: CallOptions ): Promise< [ @@ -207,7 +207,7 @@ export declare class FirestoreClient { > ): void; beginTransaction( - request: protos.google.firestore.v1.IBeginTransactionRequest, + request?: protos.google.firestore.v1.IBeginTransactionRequest, options?: CallOptions ): Promise< [ @@ -234,7 +234,7 @@ export declare class FirestoreClient { > ): void; commit( - request: protos.google.firestore.v1.ICommitRequest, + request?: protos.google.firestore.v1.ICommitRequest, options?: CallOptions ): Promise< [ @@ -261,7 +261,7 @@ export declare class FirestoreClient { > ): void; rollback( - request: protos.google.firestore.v1.IRollbackRequest, + request?: protos.google.firestore.v1.IRollbackRequest, options?: CallOptions ): Promise< [ @@ -288,7 +288,7 @@ export declare class FirestoreClient { > ): void; batchWrite( - request: protos.google.firestore.v1.IBatchWriteRequest, + request?: protos.google.firestore.v1.IBatchWriteRequest, options?: CallOptions ): Promise< [ @@ -315,7 +315,7 @@ export declare class FirestoreClient { > ): void; createDocument( - request: protos.google.firestore.v1.ICreateDocumentRequest, + request?: protos.google.firestore.v1.ICreateDocumentRequest, options?: CallOptions ): Promise< [ @@ -469,7 +469,7 @@ export declare class FirestoreClient { */ listen(options?: CallOptions): gax.CancellableStream; listDocuments( - request: protos.google.firestore.v1.IListDocumentsRequest, + request?: protos.google.firestore.v1.IListDocumentsRequest, options?: CallOptions ): Promise< [ @@ -610,7 +610,7 @@ export declare class FirestoreClient { options?: CallOptions ): AsyncIterable; partitionQuery( - request: protos.google.firestore.v1.IPartitionQueryRequest, + request?: protos.google.firestore.v1.IPartitionQueryRequest, options?: CallOptions ): Promise< [ @@ -765,7 +765,7 @@ export declare class FirestoreClient { options?: CallOptions ): AsyncIterable; listCollectionIds( - request: protos.google.firestore.v1.IListCollectionIdsRequest, + request?: protos.google.firestore.v1.IListCollectionIdsRequest, options?: CallOptions ): Promise< [ diff --git a/types/v1beta1/firestore_client.d.ts b/types/v1beta1/firestore_client.d.ts index 9a1213250..2f182209a 100644 --- a/types/v1beta1/firestore_client.d.ts +++ b/types/v1beta1/firestore_client.d.ts @@ -127,7 +127,7 @@ export declare class FirestoreClient { getProjectId(): Promise; getProjectId(callback: Callback): void; getDocument( - request: protos.google.firestore.v1beta1.IGetDocumentRequest, + request?: protos.google.firestore.v1beta1.IGetDocumentRequest, options?: CallOptions ): Promise< [ @@ -154,7 +154,7 @@ export declare class FirestoreClient { > ): void; updateDocument( - request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, + request?: protos.google.firestore.v1beta1.IUpdateDocumentRequest, options?: CallOptions ): Promise< [ @@ -181,7 +181,7 @@ export declare class FirestoreClient { > ): void; deleteDocument( - request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, + request?: protos.google.firestore.v1beta1.IDeleteDocumentRequest, options?: CallOptions ): Promise< [ @@ -208,7 +208,7 @@ export declare class FirestoreClient { > ): void; beginTransaction( - request: protos.google.firestore.v1beta1.IBeginTransactionRequest, + request?: protos.google.firestore.v1beta1.IBeginTransactionRequest, options?: CallOptions ): Promise< [ @@ -239,7 +239,7 @@ export declare class FirestoreClient { > ): void; commit( - request: protos.google.firestore.v1beta1.ICommitRequest, + request?: protos.google.firestore.v1beta1.ICommitRequest, options?: CallOptions ): Promise< [ @@ -266,7 +266,7 @@ export declare class FirestoreClient { > ): void; rollback( - request: protos.google.firestore.v1beta1.IRollbackRequest, + request?: protos.google.firestore.v1beta1.IRollbackRequest, options?: CallOptions ): Promise< [ @@ -293,7 +293,7 @@ export declare class FirestoreClient { > ): void; batchWrite( - request: protos.google.firestore.v1beta1.IBatchWriteRequest, + request?: protos.google.firestore.v1beta1.IBatchWriteRequest, options?: CallOptions ): Promise< [ @@ -320,7 +320,7 @@ export declare class FirestoreClient { > ): void; createDocument( - request: protos.google.firestore.v1beta1.ICreateDocumentRequest, + request?: protos.google.firestore.v1beta1.ICreateDocumentRequest, options?: CallOptions ): Promise< [ @@ -474,7 +474,7 @@ export declare class FirestoreClient { */ listen(options?: CallOptions): gax.CancellableStream; listDocuments( - request: protos.google.firestore.v1beta1.IListDocumentsRequest, + request?: protos.google.firestore.v1beta1.IListDocumentsRequest, options?: CallOptions ): Promise< [ @@ -615,7 +615,7 @@ export declare class FirestoreClient { options?: CallOptions ): AsyncIterable; partitionQuery( - request: protos.google.firestore.v1beta1.IPartitionQueryRequest, + request?: protos.google.firestore.v1beta1.IPartitionQueryRequest, options?: CallOptions ): Promise< [ @@ -774,7 +774,7 @@ export declare class FirestoreClient { options?: CallOptions ): AsyncIterable; listCollectionIds( - request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, + request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, options?: CallOptions ): Promise< [ From c61c725a6e00903c0434b897bad4e1abafc4b446 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 23 Jun 2021 08:30:07 -0700 Subject: [PATCH 315/337] build: include version in pass down variables (#1537) Source-Author: F. Hinkelmann Source-Date: Wed Jun 9 19:33:01 2021 +0200 Source-Repo: googleapis/synthtool Source-Sha: 740366bbb9a7e0f4b77fc75dc26be1d3a376c3e0 Source-Link: https://github.com/googleapis/synthtool/commit/740366bbb9a7e0f4b77fc75dc26be1d3a376c3e0 --- .github/auto-approve.yml | 7 +++++++ .trampolinerc | 1 + synth.metadata | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .github/auto-approve.yml diff --git a/.github/auto-approve.yml b/.github/auto-approve.yml new file mode 100644 index 000000000..903697974 --- /dev/null +++ b/.github/auto-approve.yml @@ -0,0 +1,7 @@ +rules: +- author: "release-please[bot]" + title: "^chore: release" + changedFiles: + - "package\\.json$" + - "CHANGELOG\\.md$" + maxFiles: 3 \ No newline at end of file diff --git a/.trampolinerc b/.trampolinerc index 164613b9e..5fc225313 100644 --- a/.trampolinerc +++ b/.trampolinerc @@ -21,6 +21,7 @@ required_envvars+=( # Add env vars which are passed down into the container here. pass_down_envvars+=( "AUTORELEASE_PR" + "VERSION" ) # Prevent unintentional override on the default image. diff --git a/synth.metadata b/synth.metadata index f31e16d00..ecdb2c9bc 100644 --- a/synth.metadata +++ b/synth.metadata @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "2430f8d90ed8a508e8422a3a7191e656d5a6bf53" + "sha": "41ccd8cd13ec31f4fb839cf8182aea3c7156e19d" } } ], From 525275b0149b6292fdfe9d2f271881db35864022 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 23 Jun 2021 10:20:17 -0600 Subject: [PATCH 316/337] docs: improve docs for UpdateData (#1540) --- dev/src/index.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index e143554e7..1c0148860 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -207,8 +207,25 @@ const MAX_CONCURRENT_REQUESTS_PER_CLIENT = 100; /** * Update data (for use with [update]{@link DocumentReference#update}) - * that contains paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that - * contain dots reference nested fields within the document. + * that contains paths mapped to values. Fields that contain dots + * reference nested fields within the document. + * + * You can update a top-level field in your document by using the field name + * as a key (e.g. `foo`). The provided value completely replaces the contents + * for this field. + * + * You can also update a nested field directly by using its field path as a key + * (e.g. `foo.bar`). This nested field update replaces the contents at `bar` + * but does not modify other data under `foo`. + * + * @example + * const documentRef = firestore.doc('coll/doc'); + * documentRef.set({a1: {a2: 'val'}, b1: {b2: 'val'}, c1: {c2: 'val'}}); + * documentRef.update({ + * b1: {b3: 'val'}, + * 'c1.c3': 'val', + * }); + * // Value is {a1: {a2: 'val'}, b1: {b3: 'val'}, c1: {c2: 'val', c3: 'val'}} * * @typedef {Object.} UpdateData */ From 2406f6adf938126b642482ec34cd1094920d0442 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 23 Jun 2021 11:07:40 -0600 Subject: [PATCH 317/337] docs: expand documentation on transactions (#1539) --- dev/src/index.ts | 18 ++++++++++++++++-- types/firestore.d.ts | 32 +++++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index 1c0148860..9cf3a8483 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -937,8 +937,22 @@ export class Firestore implements firestore.Firestore { * the transaction. * * You can use the transaction object passed to 'updateFunction' to read and - * modify Firestore documents under lock. Transactions are committed once - * 'updateFunction' resolves and attempted up to five times on failure. + * modify Firestore documents under lock. You have to perform all reads before + * before you perform any write. + * + * Documents read during a transaction are locked pessimistically. A + * transaction's lock on a document blocks other transactions, batched + * writes, and other non-transactional writes from changing that document. + * A transaction releases its document locks at commit time or once it times + * out or fails for any reason. + * + * Transactions are committed once 'updateFunction' resolves. If a transaction + * fails with contention, the transaction is retried up to five times. The + * `updateFunction` is invoked once for each attempt. + * + * Transactions time out after 60 seconds if no documents are read. + * Transactions that are not committed within than 270 seconds are also + * aborted. * * @template T * @param {Firestore~updateFunction} updateFunction The user function to diff --git a/types/firestore.d.ts b/types/firestore.d.ts index 464e65ceb..ad393532f 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -28,9 +28,17 @@ declare namespace FirebaseFirestore { export type 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. + * Update data (for use with [update]{@link DocumentReference#update}) + * that contains paths mapped to values. Fields that contain dots reference + * nested fields within the document. + * + * You can update a top-level field in your document by using the field name + * as a key (e.g. `foo`). The provided value completely replaces the contents + * for this field. + * + * You can also update a nested field directly by using its field path as a + * key (e.g. `foo.bar`). This nested field update replaces the contents at + * `bar` but does not modify other data under `foo`. */ export type UpdateData = {[fieldPath: string]: any}; @@ -300,8 +308,22 @@ declare namespace FirebaseFirestore { * the transaction. * * You can use the transaction object passed to 'updateFunction' to read and - * modify Firestore documents under lock. Transactions are committed once - * 'updateFunction' resolves and attempted up to five times on failure. + * modify Firestore documents under lock. You have to perform all reads + * before before you perform any write. + * + * Documents read during a transaction are locked pessimistically. A + * transaction's lock on a document blocks other transactions, batched + * writes, and other non-transactional writes from changing that document. + * A transaction releases its document locks at commit time or once it times + * out or fails for any reason. + * + * Transactions are committed once 'updateFunction' resolves. If a + * transaction fails with contention, the transaction is retried up to five + * times. The `updateFunction` is invoked once for each attempt. + * + * Transactions time out after 60 seconds if no documents are read. + * Transactions that are not committed within than 270 seconds are also + * aborted. * * @param updateFunction The function to execute within the transaction * context. From 113200ac0b8c5f46c964321eaef162e2ea13bd1e Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 24 Jun 2021 07:24:22 -0700 Subject: [PATCH 318/337] build(node): don't throw on deprecation in unit tests (#1543) Source-Author: Benjamin E. Coe Source-Date: Wed Jun 23 18:46:45 2021 -0400 Source-Repo: googleapis/synthtool Source-Sha: e60186990fae9c4e14e046085b79c08917217040 Source-Link: https://github.com/googleapis/synthtool/commit/e60186990fae9c4e14e046085b79c08917217040 --- .github/workflows/ci.yaml | 4 ++++ synth.metadata | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dbcdc7ce7..f033c0d2f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,6 +24,8 @@ jobs: - run: rm -rf node_modules - run: npm install - run: npm test + env: + MOCHA_THROW_DEPRECATION: false windows: runs-on: windows-latest steps: @@ -33,6 +35,8 @@ jobs: node-version: 14 - run: npm install - run: npm test + env: + MOCHA_THROW_DEPRECATION: false lint: runs-on: ubuntu-latest steps: diff --git a/synth.metadata b/synth.metadata index ecdb2c9bc..26897e4c8 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "1805c3ff411e42ae584f0e6c2629b1f2231340da" + "sha": "2406f6adf938126b642482ec34cd1094920d0442" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "41ccd8cd13ec31f4fb839cf8182aea3c7156e19d" + "sha": "e60186990fae9c4e14e046085b79c08917217040" } } ], From 7473343761abd37f0fe49c9c3f342d0d8c381f57 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Thu, 24 Jun 2021 15:10:38 -0700 Subject: [PATCH 319/337] chore: move transaction default max retry attempts to a const (#1542) --- dev/src/index.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index 9cf3a8483..1bf31be98 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -137,6 +137,11 @@ const CLOUD_RESOURCE_HEADER = 'google-cloud-resource-prefix'; */ export const MAX_REQUEST_RETRIES = 5; +/*! + * The maximum number of times to attempt a transaction before failing. + */ +export const DEFAULT_MAX_TRANSACTION_ATTEMPTS = 5; + /*! * The default number of idle GRPC channel to keep. */ @@ -994,10 +999,9 @@ export class Firestore implements firestore.Firestore { ): Promise { validateFunction('updateFunction', updateFunction); - const defaultAttempts = 5; const tag = requestTag(); - let maxAttempts: number; + let maxAttempts = DEFAULT_MAX_TRANSACTION_ATTEMPTS; if (transactionOptions) { validateObject('transactionOptions', transactionOptions); @@ -1006,9 +1010,8 @@ export class Firestore implements firestore.Firestore { transactionOptions.maxAttempts, {optional: true, minValue: 1} ); - maxAttempts = transactionOptions.maxAttempts || defaultAttempts; - } else { - maxAttempts = defaultAttempts; + maxAttempts = + transactionOptions.maxAttempts || DEFAULT_MAX_TRANSACTION_ATTEMPTS; } const transaction = new Transaction(this, tag); From b39dd3c65549fb1a651c1722d8ea2c038e152417 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Fri, 25 Jun 2021 16:52:46 -0600 Subject: [PATCH 320/337] feat: retry BatchGetDocuments RPCs that fail with errors (#1544) --- dev/src/document-reader.ts | 182 +++++++++++++++++++++++++++++++++++++ dev/src/index.ts | 137 ++-------------------------- dev/src/transaction.ts | 25 ++--- dev/test/index.ts | 88 ++++++++++-------- 4 files changed, 245 insertions(+), 187 deletions(-) create mode 100644 dev/src/document-reader.ts diff --git a/dev/src/document-reader.ts b/dev/src/document-reader.ts new file mode 100644 index 000000000..21af91a7f --- /dev/null +++ b/dev/src/document-reader.ts @@ -0,0 +1,182 @@ +/*! + * Copyright 2021 Google LLC. All Rights Reserved. + * + * 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 {DocumentSnapshot, DocumentSnapshotBuilder} from './document'; +import {DocumentReference} from './reference'; +import {FieldPath} from './path'; +import {isPermanentRpcError} from './util'; +import {google} from '../protos/firestore_v1_proto_api'; +import {logger} from './logger'; +import {Firestore} from './index'; +import {DocumentData} from '@google-cloud/firestore'; +import api = google.firestore.v1; + +/** + * A wrapper around BatchGetDocumentsRequest that retries request upon stream + * failure and returns ordered results. + * + * @private + */ +export class DocumentReader { + /** An optional field mask to apply to this read. */ + fieldMask?: FieldPath[]; + /** An optional transaction ID to use for this read. */ + transactionId?: Uint8Array; + + private outstandingDocuments = new Set(); + private retrievedDocuments = new Map(); + + /** + * Creates a new DocumentReader that fetches the provided documents (via + * `get()`). + * + * @param firestore The Firestore instance to use. + * @param allDocuments The documents to get. + */ + constructor( + private firestore: Firestore, + private allDocuments: Array> + ) { + for (const docRef of this.allDocuments) { + this.outstandingDocuments.add(docRef.formattedName); + } + } + + /** + * Invokes the BatchGetDocuments RPC and returns the results. + * + * @param requestTag A unique client-assigned identifier for this request. + */ + async get(requestTag: string): Promise>> { + await this.fetchDocuments(requestTag); + + // BatchGetDocuments doesn't preserve document order. We use the request + // order to sort the resulting documents. + const orderedDocuments: Array> = []; + + for (const docRef of this.allDocuments) { + const document = this.retrievedDocuments.get(docRef.formattedName); + if (document !== undefined) { + // Recreate the DocumentSnapshot with the DocumentReference + // containing the original converter. + const finalDoc = new DocumentSnapshotBuilder( + docRef as DocumentReference + ); + finalDoc.fieldsProto = document._fieldsProto; + finalDoc.readTime = document.readTime; + finalDoc.createTime = document.createTime; + finalDoc.updateTime = document.updateTime; + orderedDocuments.push(finalDoc.build()); + } else { + throw new Error(`Did not receive document for "${docRef.path}".`); + } + } + + return orderedDocuments; + } + + private async fetchDocuments(requestTag: string): Promise { + if (!this.outstandingDocuments.size) { + return; + } + + const request: api.IBatchGetDocumentsRequest = { + database: this.firestore.formattedName, + transaction: this.transactionId, + documents: Array.from(this.outstandingDocuments), + }; + + if (this.fieldMask) { + const fieldPaths = this.fieldMask.map( + fieldPath => fieldPath.formattedName + ); + request.mask = {fieldPaths}; + } + + let resultCount = 0; + + try { + const stream = await this.firestore.requestStream( + 'batchGetDocuments', + request, + requestTag + ); + stream.resume(); + + for await (const response of stream) { + let snapshot: DocumentSnapshot; + + if (response.found) { + logger( + 'DocumentReader.fetchDocuments', + requestTag, + 'Received document: %s', + response.found.name! + ); + snapshot = this.firestore.snapshot_( + response.found, + response.readTime! + ); + } else { + logger( + 'DocumentReader.fetchDocuments', + requestTag, + 'Document missing: %s', + response.missing! + ); + snapshot = this.firestore.snapshot_( + response.missing!, + response.readTime! + ); + } + + const path = snapshot.ref.formattedName; + this.outstandingDocuments.delete(path); + this.retrievedDocuments.set(path, snapshot); + ++resultCount; + } + } catch (error) { + const shouldRetry = + // Transactional reads are retried via the transaction runner. + !this.transactionId && + // Only retry if we made progress. + resultCount > 0 && + // Don't retry permanent errors. + error.code !== undefined && + !isPermanentRpcError(error, 'batchGetDocuments'); + + logger( + 'DocumentReader.fetchDocuments', + requestTag, + 'BatchGetDocuments failed with error: %s. Retrying: %s', + error, + shouldRetry + ); + if (shouldRetry) { + return this.fetchDocuments(requestTag); + } else { + throw error; + } + } finally { + logger( + 'DocumentReader.fetchDocuments', + requestTag, + 'Received %d results', + resultCount + ); + } + } +} diff --git a/dev/src/index.ts b/dev/src/index.ts index 1bf31be98..cd79b3332 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -26,6 +26,7 @@ import {ExponentialBackoff, ExponentialBackoffSetting} from './backoff'; import {BulkWriter} from './bulk-writer'; import {BundleBuilder} from './bundle'; import {fieldsFromJson, timestampFromJson} from './convert'; +import {DocumentReader} from './document-reader'; import { DocumentSnapshot, DocumentSnapshotBuilder, @@ -34,14 +35,12 @@ import { import {logger, setLibVersion} from './logger'; import { DEFAULT_DATABASE_ID, - FieldPath, QualifiedResourcePath, ResourcePath, validateResourcePath, } from './path'; import {ClientPool} from './pool'; -import {CollectionReference} from './reference'; -import {DocumentReference} from './reference'; +import {CollectionReference, DocumentReference} from './reference'; import {Serializer} from './serializer'; import {Timestamp} from './timestamp'; import {parseGetAllArguments, Transaction} from './transaction'; @@ -1080,138 +1079,16 @@ export class Firestore implements firestore.Firestore { const stack = Error().stack!; return this.initializeIfNeeded(tag) - .then(() => this.getAll_(documents, fieldMask, tag)) + .then(() => { + const reader = new DocumentReader(this, documents); + reader.fieldMask = fieldMask || undefined; + return reader.get(tag); + }) .catch(err => { throw wrapError(err, stack); }); } - /** - * Internal method to retrieve multiple documents from Firestore, optionally - * as part of a transaction. - * - * @private - * @param docRefs The documents to receive. - * @param fieldMask An optional field mask to apply to this read. - * @param requestTag A unique client-assigned identifier for this request. - * @param transactionId The transaction ID to use for this read. - * @returns A Promise that contains an array with the resulting documents. - */ - getAll_( - docRefs: Array>, - fieldMask: firestore.FieldPath[] | null, - requestTag: string, - transactionId?: Uint8Array - ): Promise>> { - const requestedDocuments = new Set(); - const retrievedDocuments = new Map(); - - for (const docRef of docRefs) { - requestedDocuments.add((docRef as DocumentReference).formattedName); - } - - const request: api.IBatchGetDocumentsRequest = { - database: this.formattedName, - transaction: transactionId, - documents: Array.from(requestedDocuments), - }; - - if (fieldMask) { - const fieldPaths = fieldMask.map( - fieldPath => (fieldPath as FieldPath).formattedName - ); - request.mask = {fieldPaths}; - } - - return this.requestStream('batchGetDocuments', request, requestTag).then( - stream => { - return new Promise>>((resolve, reject) => { - stream - .on('error', err => { - logger( - 'Firestore.getAll_', - requestTag, - 'GetAll failed with error:', - err - ); - reject(err); - }) - .on('data', (response: api.IBatchGetDocumentsResponse) => { - try { - let document; - - if (response.found) { - logger( - 'Firestore.getAll_', - requestTag, - 'Received document: %s', - response.found.name! - ); - document = this.snapshot_(response.found, response.readTime!); - } else { - logger( - 'Firestore.getAll_', - requestTag, - 'Document missing: %s', - response.missing! - ); - document = this.snapshot_( - response.missing!, - response.readTime! - ); - } - - const path = document.ref.path; - retrievedDocuments.set(path, document); - } catch (err) { - logger( - 'Firestore.getAll_', - requestTag, - 'GetAll failed with exception:', - err - ); - reject(err); - } - }) - .on('end', () => { - logger( - 'Firestore.getAll_', - requestTag, - 'Received %d results', - retrievedDocuments.size - ); - - // BatchGetDocuments doesn't preserve document order. We use - // the request order to sort the resulting documents. - const orderedDocuments: Array> = []; - - for (const docRef of docRefs) { - const document = retrievedDocuments.get(docRef.path); - if (document !== undefined) { - // Recreate the DocumentSnapshot with the DocumentReference - // containing the original converter. - const finalDoc = new DocumentSnapshotBuilder( - docRef as DocumentReference - ); - finalDoc.fieldsProto = document._fieldsProto; - finalDoc.readTime = document.readTime; - finalDoc.createTime = document.createTime; - finalDoc.updateTime = document.updateTime; - orderedDocuments.push(finalDoc.build()); - } else { - reject( - new Error(`Did not receive document for "${docRef.path}".`) - ); - } - } - resolve(orderedDocuments); - }); - stream.resume(); - }); - } - ); - } - /** * Registers a listener on this client, incrementing the listener count. This * is used to verify that all listeners are unsubscribed when terminate() is diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index e7c5766c5..678f6cc4d 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -38,7 +38,7 @@ import { validateMinNumberOfArguments, validateOptional, } from './validate'; - +import {DocumentReader} from './document-reader'; import api = proto.google.firestore.v1; /*! @@ -125,16 +125,9 @@ export class Transaction implements firestore.Transaction { } if (refOrQuery instanceof DocumentReference) { - return this._firestore - .getAll_( - [refOrQuery], - /* fieldMask= */ null, - this._requestTag, - this._transactionId - ) - .then(res => { - return Promise.resolve(res[0]); - }); + const documentReader = new DocumentReader(this._firestore, [refOrQuery]); + documentReader.transactionId = this._transactionId; + return documentReader.get(this._requestTag).then(([res]) => res); } if (refOrQuery instanceof Query) { @@ -191,12 +184,10 @@ export class Transaction implements firestore.Transaction { documentRefsOrReadOptions ); - return this._firestore.getAll_( - documents, - fieldMask, - this._requestTag, - this._transactionId - ); + const documentReader = new DocumentReader(this._firestore, documents); + documentReader.fieldMask = fieldMask || undefined; + documentReader.transactionId = this._transactionId; + return documentReader.get(this._requestTag); } /** diff --git a/dev/test/index.ts b/dev/test/index.ts index 7cdf3e0a5..68bf967cd 100644 --- a/dev/test/index.ts +++ b/dev/test/index.ts @@ -1024,32 +1024,7 @@ describe('getAll() method', () => { }); }); - it('handles stream exception after initialization', () => { - let attempts = 0; - - const overrides: ApiOverride = { - batchGetDocuments: () => { - ++attempts; - return stream(found('documentId'), new Error('Expected exception')); - }, - }; - - return createInstance(overrides).then(firestore => { - return firestore - .getAll(firestore.doc('collectionId/documentId')) - .then(() => { - throw new Error('Unexpected success in Promise'); - }) - .catch(err => { - // We don't retry since the stream might have already been released - // to the end user. - expect(attempts).to.equal(1); - expect(err.message).to.equal('Expected exception'); - }); - }); - }); - - it('handles intermittent stream exception', () => { + it('handles stream exception (before first result)', () => { let attempts = 0; const overrides: ApiOverride = { @@ -1073,26 +1048,59 @@ describe('getAll() method', () => { }); }); - it('handles serialization error', () => { + it('handles stream exception (with retryable error)', () => { + let attempts = 0; + + const error = new GoogleError('Expected exception'); + error.code = Status.DEADLINE_EXCEEDED; + const overrides: ApiOverride = { batchGetDocuments: () => { - return stream(found('documentId')); + ++attempts; + return stream(found(document(`doc${attempts}`)), error); }, }; - return createInstance(overrides).then(firestore => { - firestore['snapshot_'] = () => { - throw new Error('Expected exception'); - }; + return createInstance(overrides).then(async firestore => { + const docs = await firestore.getAll( + firestore.doc('collectionId/doc1'), + firestore.doc('collectionId/doc2'), + firestore.doc('collectionId/doc3') + ); - return firestore - .getAll(firestore.doc('collectionId/documentId')) - .then(() => { - throw new Error('Unexpected success in Promise'); - }) - .catch(err => { - expect(err.message).to.equal('Expected exception'); - }); + expect(attempts).to.equal(3); + expect(docs.length).to.equal(3); + expect(docs[0].ref.path).to.equal('collectionId/doc1'); + expect(docs[1].ref.path).to.equal('collectionId/doc2'); + expect(docs[2].ref.path).to.equal('collectionId/doc3'); + }); + }); + + it('handles stream exception (with non-retryable error)', () => { + let attempts = 0; + + const error = new GoogleError('Expected exception'); + error.code = Status.PERMISSION_DENIED; + + const overrides: ApiOverride = { + batchGetDocuments: () => { + ++attempts; + return stream(found(document(`doc${attempts}`)), error); + }, + }; + + return createInstance(overrides).then(async firestore => { + try { + await firestore.getAll( + firestore.doc('collectionId/doc1'), + firestore.doc('collectionId/doc2'), + firestore.doc('collectionId/doc3') + ); + expect.fail(); + } catch (err) { + expect(attempts).to.equal(1); + expect(err.code).to.equal(Status.PERMISSION_DENIED); + } }); }); From ca4241eb3ee4abb8453b6da0911397187dc18dde Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Mon, 28 Jun 2021 20:52:26 -0600 Subject: [PATCH 321/337] feat: add read-only transactions (#1541) --- dev/src/index.ts | 101 +++++++++++++++++++----- dev/src/transaction.ts | 23 ++++-- dev/src/validate.ts | 21 +++++ dev/system-test/firestore.ts | 41 ++++++++++ dev/test/transaction.ts | 149 +++++++++++++++++++++++++++-------- types/firestore.d.ts | 55 ++++++++++--- 6 files changed, 317 insertions(+), 73 deletions(-) diff --git a/dev/src/index.ts b/dev/src/index.ts index cd79b3332..5d90c452f 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -67,6 +67,7 @@ import { validateMinNumberOfArguments, validateObject, validateString, + validateTimestamp, } from './validate'; import {WriteBatch} from './write-batch'; @@ -929,13 +930,37 @@ export class Firestore implements firestore.Firestore { * * @callback Firestore~updateFunction * @template T - * @param {Transaction} transaction The transaction object for this + * @param {Transaction} transaction The transaction object for this * transaction. * @returns {Promise} The promise returned at the end of the transaction. * This promise will be returned by {@link Firestore#runTransaction} if the * transaction completed successfully. */ + /** + * Options object for {@link Firestore#runTransaction} to configure a + * read-only transaction. + * + * @callback Firestore~ReadOnlyTransactionOptions + * @template T + * @param {true} readOnly Set to true to indicate a read-only transaction. + * @param {Timestamp=} readTime If specified, documents are read at the given + * time. This may not be more than 60 seconds in the past from when the + * request is processed by the server. + */ + + /** + * Options object for {@link Firestore#runTransaction} to configure a + * read-write transaction. + * + * @callback Firestore~ReadWriteTransactionOptions + * @template T + * @param {false=} readOnly Set to false or omit to indicate a read-write + * transaction. + * @param {number=} maxAttempts The maximum number of attempts for this + * transaction. Defaults to five. + */ + /** * Executes the given updateFunction and commits the changes applied within * the transaction. @@ -944,26 +969,33 @@ export class Firestore implements firestore.Firestore { * modify Firestore documents under lock. You have to perform all reads before * before you perform any write. * - * Documents read during a transaction are locked pessimistically. A - * transaction's lock on a document blocks other transactions, batched - * writes, and other non-transactional writes from changing that document. - * A transaction releases its document locks at commit time or once it times - * out or fails for any reason. + * Transactions can be performed as read-only or read-write transactions. By + * default, transactions are executed in read-write mode. + * + * A read-write transaction obtains a pessimistic lock on all documents that + * are read during the transaction. These locks block other transactions, + * batched writes, and other non-transactional writes from changing that + * document. Any writes in a read-write transactions are committed once + * 'updateFunction' resolves, which also releases all locks. + * + * If a read-write transaction fails with contention, the transaction is + * retried up to five times. The `updateFunction` is invoked once for each + * attempt. * - * Transactions are committed once 'updateFunction' resolves. If a transaction - * fails with contention, the transaction is retried up to five times. The - * `updateFunction` is invoked once for each attempt. + * Read-only transactions do not lock documents. They can be used to read + * documents at a consistent snapshot in time, which may be up to 60 seconds + * in the past. Read-only transactions are not retried. * * Transactions time out after 60 seconds if no documents are read. * Transactions that are not committed within than 270 seconds are also - * aborted. + * aborted. Any remaining locks are released when a transaction times out. * * @template T * @param {Firestore~updateFunction} updateFunction The user function to * execute within the transaction context. - * @param {object=} transactionOptions Transaction options. - * @param {number=} transactionOptions.maxAttempts - The maximum number of - * attempts for this transaction. + * @param { + * Firestore~ReadWriteTransactionOptions|Firestore~ReadOnlyTransactionOptions= + * } transactionOptions Transaction options. * @returns {Promise} If the transaction completed successfully or was * explicitly aborted (by the updateFunction returning a failed Promise), the * Promise returned by the updateFunction will be returned here. Else if the @@ -994,28 +1026,55 @@ export class Firestore implements firestore.Firestore { */ runTransaction( updateFunction: (transaction: Transaction) => Promise, - transactionOptions?: {maxAttempts?: number} + transactionOptions?: + | firestore.ReadWriteTransactionOptions + | firestore.ReadOnlyTransactionOptions ): Promise { validateFunction('updateFunction', updateFunction); const tag = requestTag(); let maxAttempts = DEFAULT_MAX_TRANSACTION_ATTEMPTS; + let readOnly = false; + let readTime: Timestamp | undefined; if (transactionOptions) { validateObject('transactionOptions', transactionOptions); - validateInteger( - 'transactionOptions.maxAttempts', - transactionOptions.maxAttempts, - {optional: true, minValue: 1} + validateBoolean( + 'transactionOptions.readOnly', + transactionOptions.readOnly, + {optional: true} ); - maxAttempts = - transactionOptions.maxAttempts || DEFAULT_MAX_TRANSACTION_ATTEMPTS; + + if (transactionOptions.readOnly) { + validateTimestamp( + 'transactionOptions.readTime', + transactionOptions.readTime, + {optional: true} + ); + + readOnly = true; + readTime = transactionOptions.readTime as Timestamp | undefined; + maxAttempts = 1; + } else { + validateInteger( + 'transactionOptions.maxAttempts', + transactionOptions.maxAttempts, + {optional: true, minValue: 1} + ); + + maxAttempts = + transactionOptions.maxAttempts || DEFAULT_MAX_TRANSACTION_ATTEMPTS; + } } const transaction = new Transaction(this, tag); return this.initializeIfNeeded(tag).then(() => - transaction.runTransaction(updateFunction, maxAttempts) + transaction.runTransaction(updateFunction, { + maxAttempts, + readOnly, + readTime, + }) ); } diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index 678f6cc4d..7274a9cb0 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -22,6 +22,7 @@ import * as proto from '../protos/firestore_v1_proto_api'; import {ExponentialBackoff} from './backoff'; import {DocumentSnapshot} from './document'; import {Firestore, WriteBatch} from './index'; +import {Timestamp} from './timestamp'; import {logger} from './logger'; import {FieldPath, validateFieldPath} from './path'; import {StatusCode} from './status-code'; @@ -346,12 +347,18 @@ export class Transaction implements firestore.Transaction { * * @private */ - begin(): Promise { + begin(readOnly: boolean, readTime: Timestamp | undefined): Promise { const request: api.IBeginTransactionRequest = { database: this._firestore.formattedName, }; - if (this._transactionId) { + if (readOnly) { + request.options = { + readOnly: { + readTime: readTime?.toProto()?.timestampValue, + }, + }; + } else if (this._transactionId) { request.options = { readWrite: { retryTransaction: this._transactionId, @@ -406,16 +413,20 @@ export class Transaction implements firestore.Transaction { * context. * @param requestTag A unique client-assigned identifier for the scope of * this transaction. - * @param maxAttempts The maximum number of attempts for this transaction. + * @param options The user-defined options for this transaction. */ async runTransaction( updateFunction: (transaction: Transaction) => Promise, - maxAttempts: number + options: { + maxAttempts: number; + readOnly: boolean; + readTime?: Timestamp; + } ): Promise { let result: T; let lastError: GoogleError | undefined = undefined; - for (let attempt = 0; attempt < maxAttempts; ++attempt) { + for (let attempt = 0; attempt < options.maxAttempts; ++attempt) { try { if (lastError) { logger( @@ -430,7 +441,7 @@ export class Transaction implements firestore.Transaction { this._writeBatch._reset(); await this.maybeBackoff(lastError); - await this.begin(); + await this.begin(options.readOnly, options.readTime); const promise = updateFunction(this); if (!(promise instanceof Promise)) { diff --git a/dev/src/validate.ts b/dev/src/validate.ts index 3db6390f1..0270b5f50 100644 --- a/dev/src/validate.ts +++ b/dev/src/validate.ts @@ -17,6 +17,7 @@ import {URL} from 'url'; import {FieldPath} from './path'; import {isFunction, isObject} from './util'; +import {Timestamp} from './timestamp'; /** * Options to allow argument omission. @@ -278,6 +279,26 @@ export function validateInteger( } } +/** + * Validates that 'value' is a Timestamp. + * + * @private + * @param arg The argument name or argument index (for varargs methods). + * @param value The input to validate. + * @param options Options that specify whether the Timestamp can be omitted. + */ +export function validateTimestamp( + arg: string | number, + value: unknown, + options?: RequiredArgumentOptions +): void { + if (!validateOptional(value, options)) { + if (!(value instanceof Timestamp)) { + throw new Error(invalidArgumentMessage(arg, 'Timestamp')); + } + } +} + /** * Generates an error message to use with invalid arguments. * diff --git a/dev/system-test/firestore.ts b/dev/system-test/firestore.ts index 10379e830..11e45e1aa 100644 --- a/dev/system-test/firestore.ts +++ b/dev/system-test/firestore.ts @@ -2345,6 +2345,47 @@ describe('Transaction class', () => { const finalSnapshot = await ref.get(); expect(finalSnapshot.data()).to.deep.equal({first: true, second: true}); }); + + it('supports read-only transactions', async () => { + const ref = randomCol.doc('doc'); + await ref.set({foo: 'bar'}); + const snapshot = await firestore.runTransaction( + updateFunction => updateFunction.get(ref), + {readOnly: true} + ); + expect(snapshot.exists).to.be.true; + }); + + it('supports read-only transactions with custom read-time', async () => { + const ref = randomCol.doc('doc'); + const writeResult = await ref.set({foo: 1}); + await ref.set({foo: 2}); + const snapshot = await firestore.runTransaction( + updateFunction => updateFunction.get(ref), + {readOnly: true, readTime: writeResult.writeTime} + ); + expect(snapshot.exists).to.be.true; + expect(snapshot.get('foo')).to.equal(1); + }); + + it('fails read-only with writes', async () => { + let attempts = 0; + + const ref = randomCol.doc('doc'); + try { + await firestore.runTransaction( + async updateFunction => { + ++attempts; + updateFunction.set(ref, {}); + }, + {readOnly: true} + ); + expect.fail(); + } catch (e) { + expect(attempts).to.equal(1); + expect(e.code).to.equal(Status.INVALID_ARGUMENT); + } + }); }); describe('WriteBatch class', () => { diff --git a/dev/test/transaction.ts b/dev/test/transaction.ts index 5434c86ff..8854bc159 100644 --- a/dev/test/transaction.ts +++ b/dev/test/transaction.ts @@ -22,7 +22,7 @@ import * as through2 from 'through2'; import * as proto from '../protos/firestore_v1_proto_api'; import * as Firestore from '../src'; -import {DocumentReference, FieldPath, Transaction} from '../src'; +import {DocumentReference, FieldPath, Timestamp, Transaction} from '../src'; import {setTimeoutHandler} from '../src/backoff'; import { ApiOverride, @@ -35,6 +35,10 @@ import { } from './util/helpers'; import api = proto.google.firestore.v1; +import { + ReadOnlyTransactionOptions, + ReadWriteTransactionOptions, +} from '@google-cloud/firestore'; use(chaiAsPromised); @@ -128,29 +132,38 @@ function rollback( }; } -function begin( - transaction?: Uint8Array | string, - prevTransaction?: Uint8Array | string, - error?: Error -): TransactionStep { +function begin(options?: { + transactionId?: Uint8Array | string; + readOnly?: {readTime?: {seconds?: number; nanos?: number}}; + readWrite?: { + prevTransactionId?: Uint8Array | string; + }; + error?: Error; +}): TransactionStep { const proto: api.IBeginTransactionRequest = {database: DATABASE_ROOT}; - if (prevTransaction) { + if (options?.readOnly) { + proto.options = { + readOnly: { + readTime: options.readOnly.readTime, + }, + }; + } else if (options?.readWrite?.prevTransactionId) { proto.options = { readWrite: { - retryTransaction: transactionId(prevTransaction), + retryTransaction: transactionId(options.readWrite.prevTransactionId), }, }; } const response = { - transaction: transactionId(transaction), + transaction: transactionId(options?.transactionId), }; return { type: 'begin', request: proto, - error, + error: options?.error, response, }; } @@ -278,6 +291,7 @@ function backoff(maxDelay?: boolean): TransactionStep { * Asserts that the given transaction function issues the expected requests. */ function runTransaction( + transactionOptions: ReadWriteTransactionOptions | ReadOnlyTransactionOptions, transactionCallback: ( transaction: Transaction, docRef: DocumentReference @@ -352,7 +366,7 @@ function runTransaction( return await firestore.runTransaction(transaction => { const docRef = firestore.doc('collectionId/documentId'); return transactionCallback(transaction, docRef); - }); + }, transactionOptions); } finally { setTimeoutHandler(setTimeout); expect(expectedRequests.length).to.equal( @@ -366,6 +380,7 @@ function runTransaction( describe('successful transactions', () => { it('empty transaction', () => { return runTransaction( + /* transactionOptions= */ {}, () => { return Promise.resolve(); }, @@ -376,6 +391,7 @@ describe('successful transactions', () => { it('returns value', () => { return runTransaction( + /* transactionOptions= */ {}, () => { return Promise.resolve('bar'); }, @@ -415,19 +431,24 @@ describe('failed transactions', () => { if (retry) { await runTransaction( + /* transactionOptions= */ {}, transactionFunction, - begin('foo1'), + begin({transactionId: 'foo1'}), commit('foo1', undefined, serverError), rollback('foo1'), backoff(), - begin('foo2', 'foo1'), + begin({ + transactionId: 'foo2', + readWrite: {prevTransactionId: 'foo1'}, + }), commit('foo2') ); } else { await expect( runTransaction( + /* transactionOptions= */ {}, transactionFunction, - begin('foo1'), + begin({transactionId: 'foo1'}), commit('foo1', undefined, serverError), rollback('foo1') ) @@ -445,12 +466,13 @@ describe('failed transactions', () => { serverError.code = Status.INVALID_ARGUMENT; await runTransaction( + /* transactionOptions= */ {}, transactionFunction, - begin('foo1'), + begin({transactionId: 'foo1'}), commit('foo1', undefined, serverError), rollback('foo1'), backoff(), - begin('foo2', 'foo1'), + begin({transactionId: 'foo2', readWrite: {prevTransactionId: 'foo1'}}), commit('foo2') ); }); @@ -470,20 +492,25 @@ describe('failed transactions', () => { if (retry) { await runTransaction( + /* transactionOptions= */ {}, transactionFunction, - begin('foo1'), + begin({transactionId: 'foo1'}), query('foo1', serverError), rollback('foo1'), backoff(), - begin('foo2', 'foo1'), + begin({ + transactionId: 'foo2', + readWrite: {prevTransactionId: 'foo1'}, + }), query('foo2'), commit('foo2') ); } else { await expect( runTransaction( + /* transactionOptions= */ {}, transactionFunction, - begin('foo1'), + begin({transactionId: 'foo1'}), query('foo1', serverError), rollback('foo1') ) @@ -506,20 +533,25 @@ describe('failed transactions', () => { if (retry) { await runTransaction( + /* transactionOptions= */ {}, transactionFunction, - begin('foo1'), + begin({transactionId: 'foo1'}), getDocument('foo1', serverError), rollback('foo1'), backoff(), - begin('foo2', 'foo1'), + begin({ + transactionId: 'foo2', + readWrite: {prevTransactionId: 'foo1'}, + }), getDocument('foo2'), commit('foo2') ); } else { await expect( runTransaction( + /* transactionOptions= */ {}, transactionFunction, - begin('foo1'), + begin({transactionId: 'foo1'}), getDocument('foo1', serverError), rollback('foo1') ) @@ -537,20 +569,25 @@ describe('failed transactions', () => { if (retry) { await runTransaction( + /* transactionOptions= */ {}, transactionFunction, - begin('foo1'), + begin({transactionId: 'foo1'}), commit('foo1', /* writes=*/ undefined, serverError), rollback('foo1', serverError), rollback('foo1'), backoff(), - begin('foo2', 'foo1'), + begin({ + transactionId: 'foo2', + readWrite: {prevTransactionId: 'foo1'}, + }), commit('foo2') ); } else { await expect( runTransaction( + /* transactionOptions= */ {}, transactionFunction, - begin('foo1'), + begin({transactionId: 'foo1'}), commit('foo1', /* writes=*/ undefined, serverError), rollback('foo1', serverError) ) @@ -595,7 +632,12 @@ describe('failed transactions', () => { it('requires a promise', () => { return expect( - runTransaction((() => {}) as InvalidApiUsage, begin(), rollback()) + runTransaction( + /* transactionOptions= */ {}, + (() => {}) as InvalidApiUsage, + begin(), + rollback() + ) ).to.eventually.be.rejectedWith( 'You must return a Promise in your transaction()-callback.' ); @@ -618,6 +660,7 @@ describe('failed transactions', () => { it("doesn't retry custom user exceptions in callback", () => { return expect( runTransaction( + /* transactionOptions= */ {}, () => { return Promise.reject('request exception'); }, @@ -633,24 +676,25 @@ describe('failed transactions', () => { return expect( runTransaction( + /* transactionOptions= */ {}, () => Promise.resolve(), - begin('foo1'), + begin({transactionId: 'foo1'}), commit('foo1', [], err), rollback('foo1'), backoff(), - begin('foo2', 'foo1'), + begin({transactionId: 'foo2', readWrite: {prevTransactionId: 'foo1'}}), commit('foo2', [], err), rollback('foo2'), backoff(), - begin('foo3', 'foo2'), + begin({transactionId: 'foo3', readWrite: {prevTransactionId: 'foo2'}}), commit('foo3', [], err), rollback('foo3'), backoff(), - begin('foo4', 'foo3'), + begin({transactionId: 'foo4', readWrite: {prevTransactionId: 'foo3'}}), commit('foo4', [], err), rollback('foo4'), backoff(), - begin('foo5', 'foo4'), + begin({transactionId: 'foo5', readWrite: {prevTransactionId: 'foo4'}}), commit('foo5', [], new Error('Final exception')), rollback('foo5') ) @@ -662,12 +706,13 @@ describe('failed transactions', () => { err.code = Status.RESOURCE_EXHAUSTED; return runTransaction( + /* transactionOptions= */ {}, async () => {}, - begin('foo1'), + begin({transactionId: 'foo1'}), commit('foo1', [], err), rollback('foo1'), backoff(/* maxDelay= */ true), - begin('foo2', 'foo1'), + begin({transactionId: 'foo2', readWrite: {prevTransactionId: 'foo1'}}), commit('foo2') ); }); @@ -676,6 +721,7 @@ describe('failed transactions', () => { describe('transaction operations', () => { it('support get with document ref', () => { return runTransaction( + /* transactionOptions= */ {}, (transaction, docRef) => { return transaction.get(docRef).then(doc => { expect(doc.id).to.equal('documentId'); @@ -689,6 +735,7 @@ describe('transaction operations', () => { it('requires a query or document for get', () => { return runTransaction( + /* transactionOptions= */ {}, (transaction: InvalidApiUsage) => { expect(() => transaction.get()).to.throw( 'Value for argument "refOrQuery" must be a DocumentReference or a Query.' @@ -708,6 +755,7 @@ describe('transaction operations', () => { it('enforce that gets come before writes', () => { return expect( runTransaction( + /* transactionOptions= */ {}, (transaction, docRef) => { transaction.set(docRef, {foo: 'bar'}); return transaction.get(docRef); @@ -722,6 +770,7 @@ describe('transaction operations', () => { it('support get with query', () => { return runTransaction( + /* transactionOptions= */ {}, (transaction, docRef) => { const query = docRef.parent.where('foo', '==', 'bar'); return transaction.get(query).then(results => { @@ -734,8 +783,32 @@ describe('transaction operations', () => { ); }); + it('supports read-only transactions', () => { + return runTransaction( + {readOnly: true}, + (transaction, docRef) => transaction.get(docRef), + begin({readOnly: {}}), + getDocument(), + commit() + ); + }); + + it('supports read-only transactions with read time', () => { + return runTransaction( + { + readOnly: true, + readTime: Timestamp.fromMillis(1), + }, + (transaction, docRef) => transaction.get(docRef), + begin({readOnly: {readTime: {nanos: 1000000}}}), + getDocument(), + commit() + ); + }); + it('support getAll', () => { return runTransaction( + /* transactionOptions= */ {}, (transaction, docRef) => { const firstDoc = docRef.parent.doc('firstDocument'); const secondDoc = docRef.parent.doc('secondDocument'); @@ -754,6 +827,7 @@ describe('transaction operations', () => { it('support getAll with field mask', () => { return runTransaction( + /* transactionOptions= */ {}, (transaction, docRef) => { const doc = docRef.parent.doc('doc'); @@ -770,6 +844,7 @@ describe('transaction operations', () => { it('enforce that getAll come before writes', () => { return expect( runTransaction( + /* transactionOptions= */ {}, (transaction, docRef) => { transaction.set(docRef, {foo: 'bar'}); return transaction.getAll(docRef); @@ -794,6 +869,7 @@ describe('transaction operations', () => { }; return runTransaction( + /* transactionOptions= */ {}, (transaction, docRef) => { transaction.create(docRef, {}); return Promise.resolve(); @@ -828,6 +904,7 @@ describe('transaction operations', () => { }; return runTransaction( + /* transactionOptions= */ {}, (transaction, docRef) => { transaction.update(docRef, {'a.b': 'c'}); transaction.update(docRef, 'a.b', 'c'); @@ -852,6 +929,7 @@ describe('transaction operations', () => { }; return runTransaction( + /* transactionOptions= */ {}, (transaction, docRef) => { transaction.set(docRef, {'a.b': 'c'}); return Promise.resolve(); @@ -877,6 +955,7 @@ describe('transaction operations', () => { }; return runTransaction( + /* transactionOptions= */ {}, (transaction, docRef) => { transaction.set(docRef, {'a.b': 'c'}, {merge: true}); return Promise.resolve(); @@ -902,6 +981,7 @@ describe('transaction operations', () => { }; return runTransaction( + /* transactionOptions= */ {}, (transaction, docRef) => { const postRef = docRef.withConverter(postConverterMerge); transaction.set(postRef, {title: 'story'} as Partial, { @@ -930,6 +1010,7 @@ describe('transaction operations', () => { }; return runTransaction( + /* transactionOptions= */ {}, (transaction, docRef) => { const postRef = docRef.withConverter(postConverter); transaction.set( @@ -952,6 +1033,7 @@ describe('transaction operations', () => { }; return runTransaction( + /* transactionOptions= */ {}, (transaction, docRef) => { transaction.delete(docRef); return Promise.resolve(); @@ -974,6 +1056,7 @@ describe('transaction operations', () => { }; return runTransaction( + /* transactionOptions= */ {}, (transaction, docRef) => { transaction.delete(docRef).set(docRef, {}); return Promise.resolve(); diff --git a/types/firestore.d.ts b/types/firestore.d.ts index ad393532f..558ae812a 100644 --- a/types/firestore.d.ts +++ b/types/firestore.d.ts @@ -174,6 +174,28 @@ declare namespace FirebaseFirestore { [key: string]: any; // Accept other properties, such as GRPC settings. } + /** Options to configure a read-only transaction. */ + export interface ReadOnlyTransactionOptions { + /** Set to true to indicate a read-only transaction. */ + readOnly: true; + /** + * If specified, documents are read at the given time. This may not be more + * than 60 seconds in the past from when the request is processed by the + * server. + */ + readTime?: Timestamp; + } + + /** Options to configure a read-write transaction. */ + export interface ReadWriteTransactionOptions { + /** Set to false or omit to indicate a read-write transaction. */ + readOnly?: false; + /** + * The maximum number of attempts for this transaction. Defaults to five. + */ + maxAttempts?: number; + } + /** * `Firestore` represents a Firestore Database and is the entry point for all * Firestore operations. @@ -311,25 +333,30 @@ declare namespace FirebaseFirestore { * modify Firestore documents under lock. You have to perform all reads * before before you perform any write. * - * Documents read during a transaction are locked pessimistically. A - * transaction's lock on a document blocks other transactions, batched - * writes, and other non-transactional writes from changing that document. - * A transaction releases its document locks at commit time or once it times - * out or fails for any reason. + * Transactions can be performed as read-only or read-write transactions. By + * default, transactions are executed in read-write mode. + * + * A read-write transaction obtains a pessimistic lock on all documents that + * are read during the transaction. These locks block other transactions, + * batched writes, and other non-transactional writes from changing that + * document. Any writes in a read-write transactions are committed once + * 'updateFunction' resolves, which also releases all locks. + * + * If a read-write transaction fails with contention, the transaction is + * retried up to five times. The `updateFunction` is invoked once for each + * attempt. * - * Transactions are committed once 'updateFunction' resolves. If a - * transaction fails with contention, the transaction is retried up to five - * times. The `updateFunction` is invoked once for each attempt. + * Read-only transactions do not lock documents. They can be used to read + * documents at a consistent snapshot in time, which may be up to 60 seconds + * in the past. Read-only transactions are not retried. * * Transactions time out after 60 seconds if no documents are read. * Transactions that are not committed within than 270 seconds are also - * aborted. + * aborted. Any remaining locks are released when a transaction times out. * * @param updateFunction The function to execute within the transaction * context. - * @param {object=} transactionOptions Transaction options. - * @param {number=} transactionOptions.maxAttempts The maximum number of - * attempts for this transaction. + * @param transactionOptions Transaction options. * @return If the transaction completed successfully or was explicitly * aborted (by the updateFunction returning a failed Promise), the Promise * returned by the updateFunction will be returned here. Else if the @@ -338,7 +365,9 @@ declare namespace FirebaseFirestore { */ runTransaction( updateFunction: (transaction: Transaction) => Promise, - transactionOptions?: {maxAttempts?: number} + transactionOptions?: + | ReadWriteTransactionOptions + | ReadOnlyTransactionOptions ): Promise; /** From a32234510d487982b950c88575b9425c531c2d94 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Tue, 29 Jun 2021 11:38:32 -0400 Subject: [PATCH 322/337] fix(deps): google-gax v2.17.0 with mTLS (#1546) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c2bfa004c..ff5c94c64 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "dependencies": { "fast-deep-equal": "^3.1.1", "functional-red-black-tree": "^1.0.1", - "google-gax": "^2.12.0", + "google-gax": "^2.17.0", "protobufjs": "^6.8.6" }, "devDependencies": { From 8d97847414a70683d3ffea3a16fa0b6b13511687 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 29 Jun 2021 15:56:37 +0000 Subject: [PATCH 323/337] chore: release 4.13.0 (#1545) :robot: I have created a release \*beep\* \*boop\* --- ## [4.13.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.12.3...v4.13.0) (2021-06-29) ### Features * add read-only transactions ([#1541](https://www.github.com/googleapis/nodejs-firestore/issues/1541)) ([ca4241e](https://www.github.com/googleapis/nodejs-firestore/commit/ca4241eb3ee4abb8453b6da0911397187dc18dde)) * retry BatchGetDocuments RPCs that fail with errors ([#1544](https://www.github.com/googleapis/nodejs-firestore/issues/1544)) ([b39dd3c](https://www.github.com/googleapis/nodejs-firestore/commit/b39dd3c65549fb1a651c1722d8ea2c038e152417)) ### Bug Fixes * **deps:** google-gax v2.17.0 with mTLS ([#1546](https://www.github.com/googleapis/nodejs-firestore/issues/1546)) ([a322345](https://www.github.com/googleapis/nodejs-firestore/commit/a32234510d487982b950c88575b9425c531c2d94)) * make request optional in all cases ([#1536](https://www.github.com/googleapis/nodejs-firestore/issues/1536)) ([f6edfc1](https://www.github.com/googleapis/nodejs-firestore/commit/f6edfc181ca39cd307eab6d141db08f377d5cfdf)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 14 ++++++++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c86ca46b0..3ca176376 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [4.13.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.12.3...v4.13.0) (2021-06-29) + + +### Features + +* add read-only transactions ([#1541](https://www.github.com/googleapis/nodejs-firestore/issues/1541)) ([ca4241e](https://www.github.com/googleapis/nodejs-firestore/commit/ca4241eb3ee4abb8453b6da0911397187dc18dde)) +* retry BatchGetDocuments RPCs that fail with errors ([#1544](https://www.github.com/googleapis/nodejs-firestore/issues/1544)) ([b39dd3c](https://www.github.com/googleapis/nodejs-firestore/commit/b39dd3c65549fb1a651c1722d8ea2c038e152417)) + + +### Bug Fixes + +* **deps:** google-gax v2.17.0 with mTLS ([#1546](https://www.github.com/googleapis/nodejs-firestore/issues/1546)) ([a322345](https://www.github.com/googleapis/nodejs-firestore/commit/a32234510d487982b950c88575b9425c531c2d94)) +* make request optional in all cases ([#1536](https://www.github.com/googleapis/nodejs-firestore/issues/1536)) ([f6edfc1](https://www.github.com/googleapis/nodejs-firestore/commit/f6edfc181ca39cd307eab6d141db08f377d5cfdf)) + ### [4.12.3](https://www.github.com/googleapis/nodejs-firestore/compare/v4.12.2...v4.12.3) (2021-06-16) diff --git a/package.json b/package.json index ff5c94c64..218575422 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.12.3", + "version": "4.13.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index a13fd6ba0..20934b9fc 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.12.3" + "@google-cloud/firestore": "^4.13.0" }, "devDependencies": { "chai": "^4.2.0", From 26d480b4a7fbeb26e99bb23d7aa1fbd4802b738a Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 30 Jun 2021 10:47:33 -0700 Subject: [PATCH 324/337] fix: lower batch size on BulkWriter retry (#1549) --- dev/src/bulk-writer.ts | 39 +++++++++++++++++++++++++++--- dev/test/bulk-writer.ts | 47 +++++++++++++++++++++++++++++++++--- dev/test/recursive-delete.ts | 2 +- 3 files changed, 80 insertions(+), 8 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 2a2d8c5d5..d1bd4d77f 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -56,6 +56,11 @@ import api = google.firestore.v1; */ const MAX_BATCH_SIZE = 20; +/*! + * The maximum number of writes can be can in a single batch that is being retried. + */ +export const RETRY_MAX_BATCH_SIZE = 10; + /*! * The starting maximum number of operations per second as allowed by the * 500/50/5 rule. @@ -213,6 +218,13 @@ class BulkCommitBatch extends WriteBatch { // been resolved. readonly pendingOps: Array = []; + readonly maxBatchSize: number; + + constructor(firestore: Firestore, maxBatchSize: number) { + super(firestore); + this.maxBatchSize = maxBatchSize; + } + has(documentRef: firestore.DocumentReference): boolean { return this.docPaths.has(documentRef.path); } @@ -333,14 +345,17 @@ export class BulkWriter { * Visible for testing. * @private */ - _maxBatchSize = MAX_BATCH_SIZE; + private _maxBatchSize = MAX_BATCH_SIZE; /** * The batch that is currently used to schedule operations. Once this batch * reaches maximum capacity, a new batch is created. * @private */ - private _bulkCommitBatch = new BulkCommitBatch(this.firestore); + private _bulkCommitBatch = new BulkCommitBatch( + this.firestore, + this._maxBatchSize + ); /** * A pointer to the tail of all active BulkWriter operations. This pointer @@ -384,6 +399,16 @@ export class BulkWriter { return this._bufferedOperations.length; } + // Visible for testing. + _setMaxBatchSize(size: number): void { + assert( + this._bulkCommitBatch.pendingOps.length === 0, + 'BulkCommitBatch should be empty' + ); + this._maxBatchSize = size; + this._bulkCommitBatch = new BulkCommitBatch(this.firestore, size); + } + /** * The maximum number of pending operations that can be enqueued onto this * BulkWriter instance. Once the this number of writes have been enqueued, @@ -840,7 +865,6 @@ export class BulkWriter { if (this._bulkCommitBatch._opCount === 0) return; const pendingBatch = this._bulkCommitBatch; - this._bulkCommitBatch = new BulkCommitBatch(this.firestore); // Use the write with the longest backoff duration when determining backoff. const highestBackoffDuration = pendingBatch.pendingOps.reduce((prev, cur) => @@ -849,6 +873,13 @@ export class BulkWriter { const backoffMsWithJitter = BulkWriter._applyJitter(highestBackoffDuration); const delayedExecution = new Deferred(); + // A backoff duration greater than 0 implies that this batch is a retry. + // Retried writes are sent with a batch size of 10 in order to guarantee + // that the batch is under the 10MiB limit. + const maxBatchSize = + highestBackoffDuration > 0 ? RETRY_MAX_BATCH_SIZE : this._maxBatchSize; + this._bulkCommitBatch = new BulkCommitBatch(this.firestore, maxBatchSize); + if (backoffMsWithJitter > 0) { delayExecution(() => delayedExecution.resolve(), backoffMsWithJitter); } else { @@ -988,7 +1019,7 @@ export class BulkWriter { enqueueOnBatchCallback(this._bulkCommitBatch); this._bulkCommitBatch.processLastOperation(op); - if (this._bulkCommitBatch._opCount === this._maxBatchSize) { + if (this._bulkCommitBatch._opCount === this._bulkCommitBatch.maxBatchSize) { this._scheduleCurrentBatch(); } else if (op.flushed) { // If flush() was called before this operation was enqueued into a batch, diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index 61ad9278d..73d2c5610 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -38,6 +38,7 @@ import { DEFAULT_INITIAL_OPS_PER_SECOND_LIMIT, DEFAULT_JITTER_FACTOR, DEFAULT_MAXIMUM_OPS_PER_SECOND_LIMIT, + RETRY_MAX_BATCH_SIZE, } from '../src/bulk-writer'; import { ApiOverride, @@ -576,7 +577,7 @@ describe('BulkWriter', () => { }, ]); bulkWriter._setMaxPendingOpCount(6); - bulkWriter._maxBatchSize = 3; + bulkWriter._setMaxBatchSize(3); bulkWriter .set(firestore.doc('collectionId/doc1'), {foo: 'bar'}) .then(incrementOpCount); @@ -822,6 +823,46 @@ describe('BulkWriter', () => { expect(timeoutHandlerCounter).to.equal(3); }); + it('retries with smaller batch size', async () => { + const nLengthArray = (n: number): number[] => Array.from(Array(n).keys()); + + const bulkWriter = await instantiateInstance([ + { + request: createRequest( + nLengthArray(15).map((_, i) => setOp('doc' + i, 'bar')) + ), + response: mergeResponses( + nLengthArray(15).map(() => failedResponse(Status.ABORTED)) + ), + }, + { + request: createRequest( + nLengthArray(RETRY_MAX_BATCH_SIZE).map((_, i) => + setOp('doc' + i, 'bar') + ) + ), + response: mergeResponses( + nLengthArray(RETRY_MAX_BATCH_SIZE).map(() => successResponse(1)) + ), + }, + { + request: createRequest( + nLengthArray(15 - RETRY_MAX_BATCH_SIZE).map((_, i) => + setOp('doc' + i + RETRY_MAX_BATCH_SIZE, 'bar') + ) + ), + response: mergeResponses( + nLengthArray(15 - RETRY_MAX_BATCH_SIZE).map(() => successResponse(1)) + ), + }, + ]); + for (let i = 0; i < 15; i++) { + bulkWriter.set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}); + } + + await bulkWriter.close(); + }); + it('retries maintain correct write resolution ordering', async () => { const bulkWriter = await instantiateInstance([ { @@ -910,7 +951,7 @@ describe('BulkWriter', () => { }, ]); - bulkWriter._maxBatchSize = 2; + bulkWriter._setMaxBatchSize(2); for (let i = 0; i < 6; i++) { bulkWriter .set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}) @@ -942,7 +983,7 @@ describe('BulkWriter', () => { }, ]); - bulkWriter._maxBatchSize = 3; + bulkWriter._setMaxBatchSize(3); const promise1 = bulkWriter .set(firestore.doc('collectionId/doc1'), {foo: 'bar'}) .then(incrementOpCount); diff --git a/dev/test/recursive-delete.ts b/dev/test/recursive-delete.ts index 0d0840e36..65d7f94fe 100644 --- a/dev/test/recursive-delete.ts +++ b/dev/test/recursive-delete.ts @@ -346,7 +346,7 @@ describe('recursiveDelete() method:', () => { const firestore = await createInstance(overrides); const bulkWriter = firestore.bulkWriter(); - bulkWriter._maxBatchSize = maxBatchSize; + bulkWriter._setMaxBatchSize(maxBatchSize); await firestore._recursiveDelete( firestore.collection('root'), maxPendingOps, From db6e8c1aabb6cf63ad813be9c992a7bae357e480 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 1 Jul 2021 08:43:33 -0700 Subject: [PATCH 325/337] build: automatically merge renovate PRs (#1553) Source-Author: sofisl <55454395+sofisl@users.noreply.github.com> Source-Date: Wed Jun 30 10:50:40 2021 -0400 Source-Repo: googleapis/synthtool Source-Sha: 39652e3948f455fd0b77535a0145eeec561a3706 Source-Link: https://github.com/googleapis/synthtool/commit/39652e3948f455fd0b77535a0145eeec561a3706 --- .github/auto-approve.yml | 7 ++++++- dev/protos/firestore_admin_v1_proto_api.d.ts | 2 +- dev/protos/firestore_admin_v1_proto_api.js | 6 ++++++ dev/protos/firestore_v1_proto_api.d.ts | 2 +- dev/protos/firestore_v1_proto_api.js | 6 ++++++ dev/protos/firestore_v1beta1_proto_api.d.ts | 2 +- dev/protos/firestore_v1beta1_proto_api.js | 6 ++++++ dev/protos/google/api/field_behavior.proto | 6 ++++++ synth.metadata | 4 ++-- 9 files changed, 35 insertions(+), 6 deletions(-) diff --git a/.github/auto-approve.yml b/.github/auto-approve.yml index 903697974..a79ba66c2 100644 --- a/.github/auto-approve.yml +++ b/.github/auto-approve.yml @@ -4,4 +4,9 @@ rules: changedFiles: - "package\\.json$" - "CHANGELOG\\.md$" - maxFiles: 3 \ No newline at end of file + maxFiles: 3 +- author: "renovate-bot" + title: "^(fix\\(deps\\)|chore\\(deps\\)):" + changedFiles: + - "/package\\.json$" + maxFiles: 2 diff --git a/dev/protos/firestore_admin_v1_proto_api.d.ts b/dev/protos/firestore_admin_v1_proto_api.d.ts index 289e6b6d9..50387a415 100644 --- a/dev/protos/firestore_admin_v1_proto_api.d.ts +++ b/dev/protos/firestore_admin_v1_proto_api.d.ts @@ -1686,7 +1686,7 @@ export namespace google { /** FieldBehavior enum. */ type FieldBehavior = - "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"; + "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"| "NON_EMPTY_DEFAULT"; /** Properties of a ResourceDescriptor. */ interface IResourceDescriptor { diff --git a/dev/protos/firestore_admin_v1_proto_api.js b/dev/protos/firestore_admin_v1_proto_api.js index 840a3bb5a..d1fae8bb8 100644 --- a/dev/protos/firestore_admin_v1_proto_api.js +++ b/dev/protos/firestore_admin_v1_proto_api.js @@ -3931,6 +3931,7 @@ * @property {string} INPUT_ONLY=INPUT_ONLY INPUT_ONLY value * @property {string} IMMUTABLE=IMMUTABLE IMMUTABLE value * @property {string} UNORDERED_LIST=UNORDERED_LIST UNORDERED_LIST value + * @property {string} NON_EMPTY_DEFAULT=NON_EMPTY_DEFAULT NON_EMPTY_DEFAULT value */ api.FieldBehavior = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -3941,6 +3942,7 @@ values[valuesById[4] = "INPUT_ONLY"] = "INPUT_ONLY"; values[valuesById[5] = "IMMUTABLE"] = "IMMUTABLE"; values[valuesById[6] = "UNORDERED_LIST"] = "UNORDERED_LIST"; + values[valuesById[7] = "NON_EMPTY_DEFAULT"] = "NON_EMPTY_DEFAULT"; return values; })(); @@ -6919,6 +6921,10 @@ case 6: message[".google.api.fieldBehavior"][i] = 6; break; + case "NON_EMPTY_DEFAULT": + case 7: + message[".google.api.fieldBehavior"][i] = 7; + break; } } if (object[".google.api.resourceReference"] != null) { diff --git a/dev/protos/firestore_v1_proto_api.d.ts b/dev/protos/firestore_v1_proto_api.d.ts index ea61f2467..56b3627cc 100644 --- a/dev/protos/firestore_v1_proto_api.d.ts +++ b/dev/protos/firestore_v1_proto_api.d.ts @@ -6369,7 +6369,7 @@ export namespace google { /** FieldBehavior enum. */ type FieldBehavior = - "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"; + "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"| "NON_EMPTY_DEFAULT"; /** Properties of a ResourceDescriptor. */ interface IResourceDescriptor { diff --git a/dev/protos/firestore_v1_proto_api.js b/dev/protos/firestore_v1_proto_api.js index 499af0eac..9eb210403 100644 --- a/dev/protos/firestore_v1_proto_api.js +++ b/dev/protos/firestore_v1_proto_api.js @@ -3524,6 +3524,10 @@ case 6: message[".google.api.fieldBehavior"][i] = 6; break; + case "NON_EMPTY_DEFAULT": + case 7: + message[".google.api.fieldBehavior"][i] = 7; + break; } } if (object[".google.api.resourceReference"] != null) { @@ -15392,6 +15396,7 @@ * @property {string} INPUT_ONLY=INPUT_ONLY INPUT_ONLY value * @property {string} IMMUTABLE=IMMUTABLE IMMUTABLE value * @property {string} UNORDERED_LIST=UNORDERED_LIST UNORDERED_LIST value + * @property {string} NON_EMPTY_DEFAULT=NON_EMPTY_DEFAULT NON_EMPTY_DEFAULT value */ api.FieldBehavior = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -15402,6 +15407,7 @@ values[valuesById[4] = "INPUT_ONLY"] = "INPUT_ONLY"; values[valuesById[5] = "IMMUTABLE"] = "IMMUTABLE"; values[valuesById[6] = "UNORDERED_LIST"] = "UNORDERED_LIST"; + values[valuesById[7] = "NON_EMPTY_DEFAULT"] = "NON_EMPTY_DEFAULT"; return values; })(); diff --git a/dev/protos/firestore_v1beta1_proto_api.d.ts b/dev/protos/firestore_v1beta1_proto_api.d.ts index 79b6a4658..898267f2a 100644 --- a/dev/protos/firestore_v1beta1_proto_api.d.ts +++ b/dev/protos/firestore_v1beta1_proto_api.d.ts @@ -6063,7 +6063,7 @@ export namespace google { /** FieldBehavior enum. */ type FieldBehavior = - "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"; + "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"| "NON_EMPTY_DEFAULT"; /** Properties of a ResourceDescriptor. */ interface IResourceDescriptor { diff --git a/dev/protos/firestore_v1beta1_proto_api.js b/dev/protos/firestore_v1beta1_proto_api.js index 4d5237bc9..b75dc6656 100644 --- a/dev/protos/firestore_v1beta1_proto_api.js +++ b/dev/protos/firestore_v1beta1_proto_api.js @@ -2787,6 +2787,10 @@ case 6: message[".google.api.fieldBehavior"][i] = 6; break; + case "NON_EMPTY_DEFAULT": + case 7: + message[".google.api.fieldBehavior"][i] = 7; + break; } } if (object[".google.api.resourceReference"] != null) { @@ -14655,6 +14659,7 @@ * @property {string} INPUT_ONLY=INPUT_ONLY INPUT_ONLY value * @property {string} IMMUTABLE=IMMUTABLE IMMUTABLE value * @property {string} UNORDERED_LIST=UNORDERED_LIST UNORDERED_LIST value + * @property {string} NON_EMPTY_DEFAULT=NON_EMPTY_DEFAULT NON_EMPTY_DEFAULT value */ api.FieldBehavior = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -14665,6 +14670,7 @@ values[valuesById[4] = "INPUT_ONLY"] = "INPUT_ONLY"; values[valuesById[5] = "IMMUTABLE"] = "IMMUTABLE"; values[valuesById[6] = "UNORDERED_LIST"] = "UNORDERED_LIST"; + values[valuesById[7] = "NON_EMPTY_DEFAULT"] = "NON_EMPTY_DEFAULT"; return values; })(); diff --git a/dev/protos/google/api/field_behavior.proto b/dev/protos/google/api/field_behavior.proto index ee836185c..c4abe3b67 100644 --- a/dev/protos/google/api/field_behavior.proto +++ b/dev/protos/google/api/field_behavior.proto @@ -81,4 +81,10 @@ enum FieldBehavior { // in any arbitrary order, rather than the order the user originally // provided. Additionally, the list's order may or may not be stable. UNORDERED_LIST = 6; + + // Denotes that this field returns a non-empty default value if not set. + // This indicates that if the user provides the empty value in a request, + // a non-empty value will be returned. The user will not be aware of what + // non-empty value to expect. + NON_EMPTY_DEFAULT = 7; } diff --git a/synth.metadata b/synth.metadata index 26897e4c8..bfd7b588b 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "2406f6adf938126b642482ec34cd1094920d0442" + "sha": "26d480b4a7fbeb26e99bb23d7aa1fbd4802b738a" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "e60186990fae9c4e14e046085b79c08917217040" + "sha": "39652e3948f455fd0b77535a0145eeec561a3706" } } ], From 7cebee27f6ffe0a58b03ec8010dc50abee51944b Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 1 Jul 2021 09:56:29 -0600 Subject: [PATCH 326/337] chore: release 4.13.1 (#1550) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ca176376..f1da0e7b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.13.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.13.0...v4.13.1) (2021-07-01) + + +### Bug Fixes + +* lower batch size on BulkWriter retry ([#1549](https://www.github.com/googleapis/nodejs-firestore/issues/1549)) ([26d480b](https://www.github.com/googleapis/nodejs-firestore/commit/26d480b4a7fbeb26e99bb23d7aa1fbd4802b738a)) + ## [4.13.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.12.3...v4.13.0) (2021-06-29) diff --git a/package.json b/package.json index 218575422..e69a95c0c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.13.0", + "version": "4.13.1", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 20934b9fc..59ed46d65 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.13.0" + "@google-cloud/firestore": "^4.13.1" }, "devDependencies": { "chai": "^4.2.0", From 866bd255d930850956609a0941d4010847c0d196 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Mon, 12 Jul 2021 17:44:18 -0400 Subject: [PATCH 327/337] fix(deps): google-gax v2.17.1 (#1557) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e69a95c0c..3555ddfda 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "dependencies": { "fast-deep-equal": "^3.1.1", "functional-red-black-tree": "^1.0.1", - "google-gax": "^2.17.0", + "google-gax": "^2.17.1", "protobufjs": "^6.8.6" }, "devDependencies": { From f17a36e3fa1ce532c1c68ed63ea1845408368469 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 14 Jul 2021 09:38:16 -0700 Subject: [PATCH 328/337] fix: lower batch size on BulkWriter retry to stay under throughput limits (#1556) --- dev/src/bulk-writer.ts | 37 ++++++++++++++++++++++++++++--------- dev/test/bulk-writer.ts | 7 +++++-- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index d1bd4d77f..7c077658c 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -218,11 +218,23 @@ class BulkCommitBatch extends WriteBatch { // been resolved. readonly pendingOps: Array = []; - readonly maxBatchSize: number; + private _maxBatchSize: number; constructor(firestore: Firestore, maxBatchSize: number) { super(firestore); - this.maxBatchSize = maxBatchSize; + this._maxBatchSize = maxBatchSize; + } + + get maxBatchSize(): number { + return this._maxBatchSize; + } + + setMaxBatchSize(size: number): void { + assert( + this.pendingOps.length <= size, + 'New batch size cannot be less than the number of enqueued writes' + ); + this._maxBatchSize = size; } has(documentRef: firestore.DocumentReference): boolean { @@ -865,6 +877,10 @@ export class BulkWriter { if (this._bulkCommitBatch._opCount === 0) return; const pendingBatch = this._bulkCommitBatch; + this._bulkCommitBatch = new BulkCommitBatch( + this.firestore, + this._maxBatchSize + ); // Use the write with the longest backoff duration when determining backoff. const highestBackoffDuration = pendingBatch.pendingOps.reduce((prev, cur) => @@ -873,13 +889,6 @@ export class BulkWriter { const backoffMsWithJitter = BulkWriter._applyJitter(highestBackoffDuration); const delayedExecution = new Deferred(); - // A backoff duration greater than 0 implies that this batch is a retry. - // Retried writes are sent with a batch size of 10 in order to guarantee - // that the batch is under the 10MiB limit. - const maxBatchSize = - highestBackoffDuration > 0 ? RETRY_MAX_BATCH_SIZE : this._maxBatchSize; - this._bulkCommitBatch = new BulkCommitBatch(this.firestore, maxBatchSize); - if (backoffMsWithJitter > 0) { delayExecution(() => delayedExecution.resolve(), backoffMsWithJitter); } else { @@ -1010,6 +1019,16 @@ export class BulkWriter { enqueueOnBatchCallback: (bulkCommitBatch: BulkCommitBatch) => void, op: BulkWriterOperation ): void { + // A backoff duration greater than 0 implies that this batch is a retry. + // Retried writes are sent with a batch size of 10 in order to guarantee + // that the batch is under the 10MiB limit. + if (op.backoffDuration > 0) { + if (this._bulkCommitBatch.pendingOps.length >= RETRY_MAX_BATCH_SIZE) { + this._scheduleCurrentBatch(/* flush= */ false); + } + this._bulkCommitBatch.setMaxBatchSize(RETRY_MAX_BATCH_SIZE); + } + if (this._bulkCommitBatch.has(op.ref)) { // Create a new batch since the backend doesn't support batches with two // writes to the same document. diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index 73d2c5610..b25033e1b 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -848,7 +848,7 @@ describe('BulkWriter', () => { { request: createRequest( nLengthArray(15 - RETRY_MAX_BATCH_SIZE).map((_, i) => - setOp('doc' + i + RETRY_MAX_BATCH_SIZE, 'bar') + setOp('doc' + (i + RETRY_MAX_BATCH_SIZE), 'bar') ) ), response: mergeResponses( @@ -857,10 +857,13 @@ describe('BulkWriter', () => { }, ]); for (let i = 0; i < 15; i++) { - bulkWriter.set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}); + bulkWriter + .set(firestore.doc('collectionId/doc' + i), {foo: 'bar'}) + .then(incrementOpCount); } await bulkWriter.close(); + expect(opCount).to.equal(15); }); it('retries maintain correct write resolution ordering', async () => { From 86584a8eec0c1ce4865b27ac7c499a53d931a779 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 14 Jul 2021 15:06:04 -0600 Subject: [PATCH 329/337] chore: release 4.13.2 (#1558) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1da0e7b9..1d41b1489 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +### [4.13.2](https://www.github.com/googleapis/nodejs-firestore/compare/v4.13.1...v4.13.2) (2021-07-14) + + +### Bug Fixes + +* **deps:** google-gax v2.17.1 ([#1557](https://www.github.com/googleapis/nodejs-firestore/issues/1557)) ([866bd25](https://www.github.com/googleapis/nodejs-firestore/commit/866bd255d930850956609a0941d4010847c0d196)) +* lower batch size on BulkWriter retry to stay under throughput limits ([#1556](https://www.github.com/googleapis/nodejs-firestore/issues/1556)) ([f17a36e](https://www.github.com/googleapis/nodejs-firestore/commit/f17a36e3fa1ce532c1c68ed63ea1845408368469)) + ### [4.13.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.13.0...v4.13.1) (2021-07-01) diff --git a/package.json b/package.json index 3555ddfda..9bd65eeaa 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.13.1", + "version": "4.13.2", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 59ed46d65..10e94e5a2 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.13.1" + "@google-cloud/firestore": "^4.13.2" }, "devDependencies": { "chai": "^4.2.0", From 8d9c50381eedf6ee8043eed681d03b44262b9820 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 16 Jul 2021 11:18:47 -0700 Subject: [PATCH 330/337] feat: add "NON_EMPTY_DEFAULT" FieldBehavior (#1554) Co-authored-by: Takashi Matsuo --- dev/protos/protos.json | 3 ++- synth.metadata | 2 +- types/protos/firestore_admin_v1_proto_api.d.ts | 2 +- types/protos/firestore_v1_proto_api.d.ts | 2 +- types/protos/firestore_v1beta1_proto_api.d.ts | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dev/protos/protos.json b/dev/protos/protos.json index 44043811b..f2e02f118 100644 --- a/dev/protos/protos.json +++ b/dev/protos/protos.json @@ -4103,7 +4103,8 @@ "OUTPUT_ONLY": 3, "INPUT_ONLY": 4, "IMMUTABLE": 5, - "UNORDERED_LIST": 6 + "UNORDERED_LIST": 6, + "NON_EMPTY_DEFAULT": 7 } } } diff --git a/synth.metadata b/synth.metadata index bfd7b588b..23699b48e 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "26d480b4a7fbeb26e99bb23d7aa1fbd4802b738a" + "sha": "7cebee27f6ffe0a58b03ec8010dc50abee51944b" } }, { diff --git a/types/protos/firestore_admin_v1_proto_api.d.ts b/types/protos/firestore_admin_v1_proto_api.d.ts index 289e6b6d9..50387a415 100644 --- a/types/protos/firestore_admin_v1_proto_api.d.ts +++ b/types/protos/firestore_admin_v1_proto_api.d.ts @@ -1686,7 +1686,7 @@ export namespace google { /** FieldBehavior enum. */ type FieldBehavior = - "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"; + "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"| "NON_EMPTY_DEFAULT"; /** Properties of a ResourceDescriptor. */ interface IResourceDescriptor { diff --git a/types/protos/firestore_v1_proto_api.d.ts b/types/protos/firestore_v1_proto_api.d.ts index ea61f2467..56b3627cc 100644 --- a/types/protos/firestore_v1_proto_api.d.ts +++ b/types/protos/firestore_v1_proto_api.d.ts @@ -6369,7 +6369,7 @@ export namespace google { /** FieldBehavior enum. */ type FieldBehavior = - "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"; + "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"| "NON_EMPTY_DEFAULT"; /** Properties of a ResourceDescriptor. */ interface IResourceDescriptor { diff --git a/types/protos/firestore_v1beta1_proto_api.d.ts b/types/protos/firestore_v1beta1_proto_api.d.ts index 79b6a4658..898267f2a 100644 --- a/types/protos/firestore_v1beta1_proto_api.d.ts +++ b/types/protos/firestore_v1beta1_proto_api.d.ts @@ -6063,7 +6063,7 @@ export namespace google { /** FieldBehavior enum. */ type FieldBehavior = - "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"; + "FIELD_BEHAVIOR_UNSPECIFIED"| "OPTIONAL"| "REQUIRED"| "OUTPUT_ONLY"| "INPUT_ONLY"| "IMMUTABLE"| "UNORDERED_LIST"| "NON_EMPTY_DEFAULT"; /** Properties of a ResourceDescriptor. */ interface IResourceDescriptor { From 5e384157efda51dc91eeb314a7ac53466764af3d Mon Sep 17 00:00:00 2001 From: "F. Hinkelmann" Date: Tue, 20 Jul 2021 12:47:53 -0400 Subject: [PATCH 331/337] chore: use cloud-rad publication process (#1567) --- .kokoro/release/docs-devsite.cfg | 2 +- .kokoro/release/docs-devsite.sh | 48 +--- api-extractor.json | 369 ------------------------------- 3 files changed, 6 insertions(+), 413 deletions(-) delete mode 100644 api-extractor.json diff --git a/.kokoro/release/docs-devsite.cfg b/.kokoro/release/docs-devsite.cfg index 525699f56..eba5ec1bf 100644 --- a/.kokoro/release/docs-devsite.cfg +++ b/.kokoro/release/docs-devsite.cfg @@ -11,7 +11,7 @@ before_action { # doc publications use a Python image. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" } # Download trampoline resources. diff --git a/.kokoro/release/docs-devsite.sh b/.kokoro/release/docs-devsite.sh index fa089cf29..2198e67fe 100755 --- a/.kokoro/release/docs-devsite.sh +++ b/.kokoro/release/docs-devsite.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright 2019 Google LLC +# Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,52 +16,14 @@ set -eo pipefail -# build jsdocs (Python is installed on the Node 10 docker image). if [[ -z "$CREDENTIALS" ]]; then # if CREDENTIALS are explicitly set, assume we're testing locally # and don't set NPM_CONFIG_PREFIX. - export NPM_CONFIG_PREFIX=/home/node/.npm-global - export PATH="$PATH:/home/node/.npm-global/bin" + export NPM_CONFIG_PREFIX=${HOME}/.npm-global + export PATH="$PATH:${NPM_CONFIG_PREFIX}/bin" cd $(dirname $0)/../.. fi -mkdir ./etc - npm install -npm run api-extractor -npm run api-documenter - -npm i json@9.0.6 -g -NAME=$(cat .repo-metadata.json | json name) - -mkdir ./_devsite -cp ./yaml/$NAME/* ./_devsite - -# Delete SharePoint item, see https://github.com/microsoft/rushstack/issues/1229 -sed -i -e '1,3d' ./yaml/toc.yml -sed -i -e 's/^ //' ./yaml/toc.yml - -cp ./yaml/toc.yml ./_devsite/toc.yml - -# create docs.metadata, based on package.json and .repo-metadata.json. -pip install -U pip -python3 -m pip install --user gcp-docuploader -python3 -m docuploader create-metadata \ - --name=$NAME \ - --version=$(cat package.json | json version) \ - --language=$(cat .repo-metadata.json | json language) \ - --distribution-name=$(cat .repo-metadata.json | json distribution_name) \ - --product-page=$(cat .repo-metadata.json | json product_documentation) \ - --github-repository=$(cat .repo-metadata.json | json repo) \ - --issue-tracker=$(cat .repo-metadata.json | json issue_tracker) -cp docs.metadata ./_devsite/docs.metadata - -# deploy the docs. -if [[ -z "$CREDENTIALS" ]]; then - CREDENTIALS=${KOKORO_KEYSTORE_DIR}/73713_docuploader_service_account -fi -if [[ -z "$BUCKET" ]]; then - BUCKET=docs-staging-v2-staging -fi - -python3 -m docuploader upload ./_devsite --destination-prefix docfx --credentials $CREDENTIALS --staging-bucket $BUCKET +npm install --no-save @google-cloud/cloud-rad@^0.2.5 +npx @google-cloud/cloud-rad \ No newline at end of file diff --git a/api-extractor.json b/api-extractor.json deleted file mode 100644 index de228294b..000000000 --- a/api-extractor.json +++ /dev/null @@ -1,369 +0,0 @@ -/** - * Config file for API Extractor. For more info, please visit: https://api-extractor.com - */ -{ - "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", - - /** - * Optionally specifies another JSON config file that this file extends from. This provides a way for - * standard settings to be shared across multiple projects. - * - * If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains - * the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be - * resolved using NodeJS require(). - * - * SUPPORTED TOKENS: none - * DEFAULT VALUE: "" - */ - // "extends": "./shared/api-extractor-base.json" - // "extends": "my-package/include/api-extractor-base.json" - - /** - * Determines the "" token that can be used with other config file settings. The project folder - * typically contains the tsconfig.json and package.json config files, but the path is user-defined. - * - * The path is resolved relative to the folder of the config file that contains the setting. - * - * The default value for "projectFolder" is the token "", which means the folder is determined by traversing - * parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder - * that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error - * will be reported. - * - * SUPPORTED TOKENS: - * DEFAULT VALUE: "" - */ - // "projectFolder": "..", - - /** - * (REQUIRED) Specifies the .d.ts file to be used as the starting point for analysis. API Extractor - * analyzes the symbols exported by this module. - * - * The file extension must be ".d.ts" and not ".ts". - * - * The path is resolved relative to the folder of the config file that contains the setting; to change this, - * prepend a folder token such as "". - * - * SUPPORTED TOKENS: , , - */ - "mainEntryPointFilePath": "/protos/protos.d.ts", - - /** - * A list of NPM package names whose exports should be treated as part of this package. - * - * For example, suppose that Webpack is used to generate a distributed bundle for the project "library1", - * and another NPM package "library2" is embedded in this bundle. Some types from library2 may become part - * of the exported API for library1, but by default API Extractor would generate a .d.ts rollup that explicitly - * imports library2. To avoid this, we can specify: - * - * "bundledPackages": [ "library2" ], - * - * This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been - * local files for library1. - */ - "bundledPackages": [ ], - - /** - * Determines how the TypeScript compiler engine will be invoked by API Extractor. - */ - "compiler": { - /** - * Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project. - * - * The path is resolved relative to the folder of the config file that contains the setting; to change this, - * prepend a folder token such as "". - * - * Note: This setting will be ignored if "overrideTsconfig" is used. - * - * SUPPORTED TOKENS: , , - * DEFAULT VALUE: "/tsconfig.json" - */ - // "tsconfigFilePath": "/tsconfig.json", - - /** - * Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk. - * The object must conform to the TypeScript tsconfig schema: - * - * http://json.schemastore.org/tsconfig - * - * If omitted, then the tsconfig.json file will be read from the "projectFolder". - * - * DEFAULT VALUE: no overrideTsconfig section - */ - // "overrideTsconfig": { - // . . . - // } - - /** - * This option causes the compiler to be invoked with the --skipLibCheck option. This option is not recommended - * and may cause API Extractor to produce incomplete or incorrect declarations, but it may be required when - * dependencies contain declarations that are incompatible with the TypeScript engine that API Extractor uses - * for its analysis. Where possible, the underlying issue should be fixed rather than relying on skipLibCheck. - * - * DEFAULT VALUE: false - */ - // "skipLibCheck": true, - }, - - /** - * Configures how the API report file (*.api.md) will be generated. - */ - "apiReport": { - /** - * (REQUIRED) Whether to generate an API report. - */ - "enabled": true, - - /** - * The filename for the API report files. It will be combined with "reportFolder" or "reportTempFolder" to produce - * a full file path. - * - * The file extension should be ".api.md", and the string should not contain a path separator such as "\" or "/". - * - * SUPPORTED TOKENS: , - * DEFAULT VALUE: ".api.md" - */ - // "reportFileName": ".api.md", - - /** - * Specifies the folder where the API report file is written. The file name portion is determined by - * the "reportFileName" setting. - * - * The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy, - * e.g. for an API review. - * - * The path is resolved relative to the folder of the config file that contains the setting; to change this, - * prepend a folder token such as "". - * - * SUPPORTED TOKENS: , , - * DEFAULT VALUE: "/etc/" - */ - // "reportFolder": "/etc/", - - /** - * Specifies the folder where the temporary report file is written. The file name portion is determined by - * the "reportFileName" setting. - * - * After the temporary file is written to disk, it is compared with the file in the "reportFolder". - * If they are different, a production build will fail. - * - * The path is resolved relative to the folder of the config file that contains the setting; to change this, - * prepend a folder token such as "". - * - * SUPPORTED TOKENS: , , - * DEFAULT VALUE: "/temp/" - */ - // "reportTempFolder": "/temp/" - }, - - /** - * Configures how the doc model file (*.api.json) will be generated. - */ - "docModel": { - /** - * (REQUIRED) Whether to generate a doc model file. - */ - "enabled": true, - - /** - * The output path for the doc model file. The file extension should be ".api.json". - * - * The path is resolved relative to the folder of the config file that contains the setting; to change this, - * prepend a folder token such as "". - * - * SUPPORTED TOKENS: , , - * DEFAULT VALUE: "/temp/.api.json" - */ - // "apiJsonFilePath": "/temp/.api.json" - }, - - /** - * Configures how the .d.ts rollup file will be generated. - */ - "dtsRollup": { - /** - * (REQUIRED) Whether to generate the .d.ts rollup file. - */ - "enabled": true, - - /** - * Specifies the output path for a .d.ts rollup file to be generated without any trimming. - * This file will include all declarations that are exported by the main entry point. - * - * If the path is an empty string, then this file will not be written. - * - * The path is resolved relative to the folder of the config file that contains the setting; to change this, - * prepend a folder token such as "". - * - * SUPPORTED TOKENS: , , - * DEFAULT VALUE: "/dist/.d.ts" - */ - // "untrimmedFilePath": "/dist/.d.ts", - - /** - * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release. - * This file will include only declarations that are marked as "@public" or "@beta". - * - * The path is resolved relative to the folder of the config file that contains the setting; to change this, - * prepend a folder token such as "". - * - * SUPPORTED TOKENS: , , - * DEFAULT VALUE: "" - */ - // "betaTrimmedFilePath": "/dist/-beta.d.ts", - - - /** - * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release. - * This file will include only declarations that are marked as "@public". - * - * If the path is an empty string, then this file will not be written. - * - * The path is resolved relative to the folder of the config file that contains the setting; to change this, - * prepend a folder token such as "". - * - * SUPPORTED TOKENS: , , - * DEFAULT VALUE: "" - */ - // "publicTrimmedFilePath": "/dist/-public.d.ts", - - /** - * When a declaration is trimmed, by default it will be replaced by a code comment such as - * "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the - * declaration completely. - * - * DEFAULT VALUE: false - */ - // "omitTrimmingComments": true - }, - - /** - * Configures how the tsdoc-metadata.json file will be generated. - */ - "tsdocMetadata": { - /** - * Whether to generate the tsdoc-metadata.json file. - * - * DEFAULT VALUE: true - */ - // "enabled": true, - - /** - * Specifies where the TSDoc metadata file should be written. - * - * The path is resolved relative to the folder of the config file that contains the setting; to change this, - * prepend a folder token such as "". - * - * The default value is "", which causes the path to be automatically inferred from the "tsdocMetadata", - * "typings" or "main" fields of the project's package.json. If none of these fields are set, the lookup - * falls back to "tsdoc-metadata.json" in the package folder. - * - * SUPPORTED TOKENS: , , - * DEFAULT VALUE: "" - */ - // "tsdocMetadataFilePath": "/dist/tsdoc-metadata.json" - }, - - /** - * Specifies what type of newlines API Extractor should use when writing output files. By default, the output files - * will be written with Windows-style newlines. To use POSIX-style newlines, specify "lf" instead. - * To use the OS's default newline kind, specify "os". - * - * DEFAULT VALUE: "crlf" - */ - // "newlineKind": "crlf", - - /** - * Configures how API Extractor reports error and warning messages produced during analysis. - * - * There are three sources of messages: compiler messages, API Extractor messages, and TSDoc messages. - */ - "messages": { - /** - * Configures handling of diagnostic messages reported by the TypeScript compiler engine while analyzing - * the input .d.ts files. - * - * TypeScript message identifiers start with "TS" followed by an integer. For example: "TS2551" - * - * DEFAULT VALUE: A single "default" entry with logLevel=warning. - */ - "compilerMessageReporting": { - /** - * Configures the default routing for messages that don't match an explicit rule in this table. - */ - "default": { - /** - * Specifies whether the message should be written to the the tool's output log. Note that - * the "addToApiReportFile" property may supersede this option. - * - * Possible values: "error", "warning", "none" - * - * Errors cause the build to fail and return a nonzero exit code. Warnings cause a production build fail - * and return a nonzero exit code. For a non-production build (e.g. when "api-extractor run" includes - * the "--local" option), the warning is displayed but the build will not fail. - * - * DEFAULT VALUE: "warning" - */ - "logLevel": "warning", - - /** - * When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md), - * then the message will be written inside that file; otherwise, the message is instead logged according to - * the "logLevel" option. - * - * DEFAULT VALUE: false - */ - // "addToApiReportFile": false - }, - - // "TS2551": { - // "logLevel": "warning", - // "addToApiReportFile": true - // }, - // - // . . . - }, - - /** - * Configures handling of messages reported by API Extractor during its analysis. - * - * API Extractor message identifiers start with "ae-". For example: "ae-extra-release-tag" - * - * DEFAULT VALUE: See api-extractor-defaults.json for the complete table of extractorMessageReporting mappings - */ - "extractorMessageReporting": { - "default": { - "logLevel": "warning", - // "addToApiReportFile": false - }, - - // "ae-extra-release-tag": { - // "logLevel": "warning", - // "addToApiReportFile": true - // }, - // - // . . . - }, - - /** - * Configures handling of messages reported by the TSDoc parser when analyzing code comments. - * - * TSDoc message identifiers start with "tsdoc-". For example: "tsdoc-link-tag-unescaped-text" - * - * DEFAULT VALUE: A single "default" entry with logLevel=warning. - */ - "tsdocMessageReporting": { - "default": { - "logLevel": "warning", - // "addToApiReportFile": false - } - - // "tsdoc-link-tag-unescaped-text": { - // "logLevel": "warning", - // "addToApiReportFile": true - // }, - // - // . . . - } - } - -} From 6331da48a5f5f32523a309d476bc0e2108d6f43d Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 21 Jul 2021 09:04:30 -0600 Subject: [PATCH 332/337] docs: unhide withConverter docs (#1568) --- dev/src/reference.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/dev/src/reference.ts b/dev/src/reference.ts index a33208fb2..e18da1e56 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -555,6 +555,10 @@ export class DocumentReference return {referenceValue: this.formattedName}; } + withConverter(converter: null): DocumentReference; + withConverter( + converter: firestore.FirestoreDataConverter + ): DocumentReference; /** * Applies a custom data converter to this DocumentReference, allowing you to * use your own custom model objects with Firestore. When you call set(), @@ -603,10 +607,6 @@ export class DocumentReference * from Firestore. Passing in `null` removes the current converter. * @return A DocumentReference that uses the provided converter. */ - withConverter(converter: null): DocumentReference; - withConverter( - converter: firestore.FirestoreDataConverter - ): DocumentReference; withConverter( converter: firestore.FirestoreDataConverter | null ): DocumentReference { @@ -2311,6 +2311,8 @@ export class Query implements firestore.Query { }; } + withConverter(converter: null): Query; + withConverter(converter: firestore.FirestoreDataConverter): Query; /** * Applies a custom data converter to this Query, allowing you to use your * own custom model objects with Firestore. When you call get() on the @@ -2359,8 +2361,6 @@ export class Query implements firestore.Query { * from Firestore. Passing in `null` removes the current converter. * @return A Query that uses the provided converter. */ - withConverter(converter: null): Query; - withConverter(converter: firestore.FirestoreDataConverter): Query; withConverter( converter: firestore.FirestoreDataConverter | null ): Query { @@ -2609,6 +2609,10 @@ export class CollectionReference ); } + withConverter(converter: null): CollectionReference; + withConverter( + converter: firestore.FirestoreDataConverter + ): CollectionReference; /** * Applies a custom data converter to this CollectionReference, allowing you * to use your own custom model objects with Firestore. When you call add() on @@ -2657,10 +2661,6 @@ export class CollectionReference * from Firestore. Passing in `null` removes the current converter. * @return A CollectionReference that uses the provided converter. */ - withConverter(converter: null): CollectionReference; - withConverter( - converter: firestore.FirestoreDataConverter - ): CollectionReference; withConverter( converter: firestore.FirestoreDataConverter | null ): CollectionReference { From 10b5d3ddbdff3bbaf0da2acece9b0e48f93c360e Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 21 Jul 2021 09:20:24 -0700 Subject: [PATCH 333/337] build: switch to release-please release tagging (#1569) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/966f2b32-a53f-4964-8f1b-96412cbe1b18/targets - [ ] To automatically regenerate this PR, check this box. (May take up to 24 hours.) Source-Link: https://github.com/googleapis/synthtool/commit/1563597d28eca099d6411bbc29ecd09314a80746 --- .github/release-please.yml | 1 + synth.metadata | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/release-please.yml b/.github/release-please.yml index 85344b92c..a1b41da3c 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1 +1,2 @@ +handleGHRelease: true releaseType: node diff --git a/synth.metadata b/synth.metadata index 23699b48e..ce7e5b0e4 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "7cebee27f6ffe0a58b03ec8010dc50abee51944b" + "sha": "5e384157efda51dc91eeb314a7ac53466764af3d" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "39652e3948f455fd0b77535a0145eeec561a3706" + "sha": "1563597d28eca099d6411bbc29ecd09314a80746" } } ], From 446abb0cc3529a11b18ad7af08c2354a6fee59e2 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 21 Jul 2021 17:11:01 -0600 Subject: [PATCH 334/337] chore: annotate private APIs with @internal (#1570) --- dev/src/backoff.ts | 15 ++++++++++++++ dev/src/bulk-writer.ts | 21 ++++++++++++++++++++ dev/src/bundle.ts | 4 ++++ dev/src/convert.ts | 6 ++++++ dev/src/document-reader.ts | 1 + dev/src/document.ts | 30 ++++++++++++++++++++++++++++ dev/src/field-value.ts | 19 ++++++++++++++++++ dev/src/geo-point.ts | 2 ++ dev/src/index.ts | 28 ++++++++++++++++++++++++++ dev/src/logger.ts | 2 ++ dev/src/order.ts | 11 +++++++++++ dev/src/path.ts | 39 +++++++++++++++++++++++++++++++++++++ dev/src/pool.ts | 7 +++++++ dev/src/rate-limiter.ts | 5 +++++ dev/src/recursive-delete.ts | 15 ++++++++++++++ dev/src/reference.ts | 33 +++++++++++++++++++++++++++++++ dev/src/serializer.ts | 8 ++++++++ dev/src/timestamp.ts | 2 ++ dev/src/transaction.ts | 7 +++++++ dev/src/types.ts | 4 ++++ dev/src/util.ts | 12 ++++++++++++ dev/src/validate.ts | 18 +++++++++++++++++ dev/src/watch.ts | 33 +++++++++++++++++++++++++++++++ dev/src/write-batch.ts | 14 +++++++++++++ 24 files changed, 336 insertions(+) diff --git a/dev/src/backoff.ts b/dev/src/backoff.ts index fe7a726d6..4ec81c91b 100644 --- a/dev/src/backoff.ts +++ b/dev/src/backoff.ts @@ -19,6 +19,7 @@ import {logger} from './logger'; /* * @module firestore/backoff * @private + * @internal * * Contains backoff logic to facilitate RPC error handling. This class derives * its implementation from the Firestore Mobile Web Client. @@ -67,6 +68,7 @@ export let delayExecution: (f: () => void, ms: number) => NodeJS.Timeout = * Used only in testing. * * @private + * @internal * @param {function} handler A handler than matches the API of `setTimeout()`. */ export function setTimeoutHandler( @@ -100,6 +102,7 @@ export function setTimeoutHandler( * algorithm. * * @private + * @internal */ export interface ExponentialBackoffSetting { /** Optional override for the initial retry delay. */ @@ -126,6 +129,7 @@ export interface ExponentialBackoffSetting { * synchronizing their delays causing spikes of load to the backend. * * @private + * @internal */ export class ExponentialBackoff { /** @@ -134,6 +138,7 @@ export class ExponentialBackoff { * little as 0.5*initialDelayMs (based on a jitter factor of 1.0). * * @private + * @internal */ private readonly initialDelayMs: number; @@ -142,6 +147,7 @@ export class ExponentialBackoff { * attempt. * * @private + * @internal */ private readonly backoffFactor: number; @@ -151,6 +157,7 @@ export class ExponentialBackoff { * much as 1.5*maxDelayMs (based on a jitter factor of 1.0). * * @private + * @internal */ private readonly maxDelayMs: number; @@ -159,6 +166,7 @@ export class ExponentialBackoff { * points. * * @private + * @internal */ private readonly jitterFactor: number; @@ -166,6 +174,7 @@ export class ExponentialBackoff { * The number of retries that has been attempted. * * @private + * @internal */ private _retryCount = 0; @@ -173,6 +182,7 @@ export class ExponentialBackoff { * The backoff delay of the current attempt. * * @private + * @internal */ private currentBaseMs = 0; @@ -180,6 +190,7 @@ export class ExponentialBackoff { * Whether we are currently waiting for backoff to complete. * * @private + * @internal */ private awaitingBackoffCompletion = false; @@ -210,6 +221,7 @@ export class ExponentialBackoff { * subsequent ones will increase according to the backoffFactor. * * @private + * @internal */ reset(): void { this._retryCount = 0; @@ -221,6 +233,7 @@ export class ExponentialBackoff { * RESOURCE_EXHAUSTED error). * * @private + * @internal */ resetToMax(): void { this.currentBaseMs = this.maxDelayMs; @@ -232,6 +245,7 @@ export class ExponentialBackoff { * * @return A Promise that resolves when the current delay elapsed. * @private + * @internal */ backoffAndWait(): Promise { if (this.awaitingBackoffCompletion) { @@ -285,6 +299,7 @@ export class ExponentialBackoff { * * @returns {number} The jitter to apply based on the current delay. * @private + * @internal */ private jitterDelayMs(): number { return (Math.random() - 0.5) * this.jitterFactor * this.currentBaseMs; diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index 7c077658c..f39387dce 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -106,6 +106,7 @@ const DEFAULT_MAXIMUM_PENDING_OPERATIONS_COUNT = 500; * Represents a single write for BulkWriter, encapsulating operation dispatch * and error handling. * @private + * @internal */ class BulkWriterOperation { private deferred = new Deferred(); @@ -209,6 +210,7 @@ class BulkWriterOperation { * Used to represent a batch on the BatchQueue. * * @private + * @internal */ class BulkCommitBatch extends WriteBatch { // The set of document reference paths present in the WriteBatch. @@ -310,6 +312,7 @@ class BulkCommitBatch extends WriteBatch { * Used to represent a buffered BulkWriterOperation. * * @private + * @internal */ class BufferedOperation { constructor( @@ -356,6 +359,7 @@ export class BulkWriter { * The maximum number of writes that can be in a single batch. * Visible for testing. * @private + * @internal */ private _maxBatchSize = MAX_BATCH_SIZE; @@ -363,6 +367,7 @@ export class BulkWriter { * The batch that is currently used to schedule operations. Once this batch * reaches maximum capacity, a new batch is created. * @private + * @internal */ private _bulkCommitBatch = new BulkCommitBatch( this.firestore, @@ -373,6 +378,7 @@ export class BulkWriter { * A pointer to the tail of all active BulkWriter operations. This pointer * is advanced every time a new write is enqueued. * @private + * @internal */ private _lastOp: Promise = Promise.resolve(); @@ -381,6 +387,7 @@ export class BulkWriter { * new operations can be enqueued, except for retry operations scheduled by * the error handler. * @private + * @internal */ private _closing = false; @@ -388,6 +395,7 @@ export class BulkWriter { * Rate limiter used to throttle requests as per the 500/50/5 rule. * Visible for testing. * @private + * @internal */ readonly _rateLimiter: RateLimiter; @@ -396,6 +404,7 @@ export class BulkWriter { * An operation is considered pending if BulkWriter has sent it via RPC and * is awaiting the result. * @private + * @internal */ private _pendingOpsCount = 0; @@ -403,6 +412,7 @@ export class BulkWriter { * An array containing buffered BulkWriter operations after the maximum number * of pending operations has been enqueued. * @private + * @internal */ private _bufferedOperations: Array = []; @@ -426,6 +436,7 @@ export class BulkWriter { * BulkWriter instance. Once the this number of writes have been enqueued, * subsequent writes are buffered. * @private + * @internal */ private _maxPendingOpCount = DEFAULT_MAXIMUM_PENDING_OPERATIONS_COUNT; @@ -438,6 +449,7 @@ export class BulkWriter { * The user-provided callback to be run every time a BulkWriter operation * successfully completes. * @private + * @internal */ private _successFn: ( document: firestore.DocumentReference, @@ -448,6 +460,7 @@ export class BulkWriter { * The user-provided callback to be run every time a BulkWriter operation * fails. * @private + * @internal */ private _errorFn: (error: BulkWriterError) => boolean = error => { const isRetryableDeleteError = @@ -858,6 +871,7 @@ export class BulkWriter { /** * Throws an error if the BulkWriter instance has been closed. * @private + * @internal */ _verifyNotClosed(): void { if (this._closing) { @@ -872,6 +886,7 @@ export class BulkWriter { * operations are enqueued. This allows retries to resolve as part of a * `flush()` or `close()` call. * @private + * @internal */ private _scheduleCurrentBatch(flush = false): void { if (this._bulkCommitBatch._opCount === 0) return; @@ -901,6 +916,7 @@ export class BulkWriter { /** * Sends the provided batch once the rate limiter does not require any delay. * @private + * @internal */ private async _sendBatch( batch: BulkCommitBatch, @@ -929,6 +945,7 @@ export class BulkWriter { * Adds a 30% jitter to the provided backoff. * * @private + * @internal */ private static _applyJitter(backoffMs: number): number { if (backoffMs === 0) return 0; @@ -943,6 +960,7 @@ export class BulkWriter { /** * Schedules and runs the provided operation on the next available batch. * @private + * @internal */ private _enqueue( ref: firestore.DocumentReference, @@ -998,6 +1016,7 @@ export class BulkWriter { * Manages the pending operation counter and schedules the next BulkWriter * operation if we're under the maximum limit. * @private + * @internal */ private _processBufferedOps(): void { if ( @@ -1014,6 +1033,7 @@ export class BulkWriter { * Sends the BulkCommitBatch if it reaches maximum capacity. * * @private + * @internal */ _sendFn( enqueueOnBatchCallback: (bulkCommitBatch: BulkCommitBatch) => void, @@ -1052,6 +1072,7 @@ export class BulkWriter { * Validates the use of 'value' as BulkWriterOptions. * * @private + * @internal * @param value The BulkWriterOptions object to validate. * @throws if the input is not a valid BulkWriterOptions object. */ diff --git a/dev/src/bundle.ts b/dev/src/bundle.ts index 374b453bd..584a4c11c 100644 --- a/dev/src/bundle.ts +++ b/dev/src/bundle.ts @@ -138,6 +138,7 @@ export class BundleBuilder { * Converts a IBundleElement to a Buffer whose content is the length prefixed JSON representation * of the element. * @private + * @internal */ private elementToLengthPrefixedBuffer( bundleElement: firestore.IBundleElement @@ -201,6 +202,7 @@ export class BundleBuilder { /** * Convenient class to hold both the metadata and the actual content of a document to be bundled. * @private + * @internal */ class BundledDocument { constructor( @@ -213,6 +215,7 @@ class BundledDocument { * Validates that 'value' is DocumentSnapshot. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The input to validate. */ @@ -226,6 +229,7 @@ function validateDocumentSnapshot(arg: string | number, value: unknown): void { * Validates that 'value' is QuerySnapshot. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The input to validate. */ diff --git a/dev/src/convert.ts b/dev/src/convert.ts index e1c50bfb8..58b33da47 100644 --- a/dev/src/convert.ts +++ b/dev/src/convert.ts @@ -24,6 +24,7 @@ import api = google.firestore.v1; /*! * @module firestore/convert * @private + * @internal * * This module contains utility functions to convert * `firestore.v1.Documents` from Proto3 JSON to their equivalent @@ -37,6 +38,7 @@ import api = google.firestore.v1; * Converts an ISO 8601 or google.protobuf.Timestamp proto into Protobuf JS. * * @private + * @internal * @param timestampValue The value to convert. * @param argumentName The argument name to use in the error message if the * conversion fails. If omitted, 'timestampValue' is used. @@ -89,6 +91,7 @@ export function timestampFromJson( * Converts a Proto3 JSON 'bytesValue' field into Protobuf JS. * * @private + * @internal * @param bytesValue The value to convert. * @return The value as expected by Protobuf JS. */ @@ -104,6 +107,7 @@ function bytesFromJson(bytesValue: string | Uint8Array): Uint8Array { * Detects 'valueType' from a Proto3 JSON `firestore.v1.Value` proto. * * @private + * @internal * @param proto The `firestore.v1.Value` proto. * @return The string value for 'valueType'. */ @@ -162,6 +166,7 @@ export function detectValueType(proto: ProtobufJsValue): string { * Protobuf JS format expected by this client. * * @private + * @internal * @param fieldValue The `firestore.v1.Value` in Proto3 JSON format. * @return The `firestore.v1.Value` in Protobuf JS format. */ @@ -219,6 +224,7 @@ export function valueFromJson(fieldValue: api.IValue): api.IValue { * fields. * * @private + * @internal * @param document An object with IValues in Proto3 JSON format. * @return The object in Protobuf JS format. */ diff --git a/dev/src/document-reader.ts b/dev/src/document-reader.ts index 21af91a7f..5cdf87a3c 100644 --- a/dev/src/document-reader.ts +++ b/dev/src/document-reader.ts @@ -29,6 +29,7 @@ import api = google.firestore.v1; * failure and returns ordered results. * * @private + * @internal */ export class DocumentReader { /** An optional field mask to apply to this read. */ diff --git a/dev/src/document.ts b/dev/src/document.ts index 9eee75dbc..75f4e3725 100644 --- a/dev/src/document.ts +++ b/dev/src/document.ts @@ -36,6 +36,7 @@ import api = google.firestore.v1; * Invoke `.build()' to assemble the final snapshot. * * @private + * @internal */ export class DocumentSnapshotBuilder { /** The fields of the Firestore `Document` Protobuf backing this document. */ @@ -58,6 +59,7 @@ export class DocumentSnapshotBuilder { * Builds the DocumentSnapshot. * * @private + * @internal * @returns Returns either a QueryDocumentSnapshot (if `fieldsProto` was * provided) or a DocumentSnapshot. */ @@ -136,6 +138,7 @@ export class DocumentSnapshot * Creates a DocumentSnapshot from an object. * * @private + * @internal * @param ref The reference to the document. * @param obj The object to store in the DocumentSnapshot. * @return The created DocumentSnapshot. @@ -157,6 +160,7 @@ export class DocumentSnapshot * turns { foo.bar : foobar } into { foo { bar : foobar }} * * @private + * @internal * @param ref The reference to the document. * @param data The field/value map to expand. * @return The created DocumentSnapshot. @@ -450,6 +454,7 @@ export class DocumentSnapshot * representation. * * @private + * @internal * @param field The path (e.g. 'foo' or 'foo.bar') to a specific field. * @returns The Protobuf-encoded data at the specified field location or * undefined if no such field exists. @@ -479,6 +484,7 @@ export class DocumentSnapshot * Convert a document snapshot to the Firestore 'Write' proto. * * @private + * @internal */ toWriteProto(): api.IWrite { return { @@ -493,6 +499,7 @@ export class DocumentSnapshot * Convert a document snapshot to the Firestore 'Document' proto. * * @private + * @internal */ toDocumentProto(): api.IDocument { return { @@ -612,12 +619,14 @@ export class QueryDocumentSnapshot * * @class * @private + * @internal */ export class DocumentMask { private _sortedPaths: FieldPath[]; /** * @private + * @internal * @hideconstructor * * @param fieldPaths The field paths in this mask. @@ -631,6 +640,7 @@ export class DocumentMask { * Creates a document mask with the field paths of a document. * * @private + * @internal * @param data A map with fields to modify. Only the keys are used to extract * the document mask. */ @@ -650,6 +660,7 @@ export class DocumentMask { * Creates a document mask from an array of field paths. * * @private + * @internal * @param fieldMask A list of field paths. */ static fromFieldMask( @@ -668,6 +679,7 @@ export class DocumentMask { * Creates a document mask with the field names of a document. * * @private + * @internal * @param data An object with fields to modify. Only the keys are used to * extract the document mask. */ @@ -720,6 +732,7 @@ export class DocumentMask { * Returns true if this document mask contains no fields. * * @private + * @internal * @return {boolean} Whether this document mask is empty. */ get isEmpty(): boolean { @@ -730,6 +743,7 @@ export class DocumentMask { * Removes the specified values from a sorted field path array. * * @private + * @internal * @param input A sorted array of FieldPaths. * @param values An array of FieldPaths to remove. */ @@ -758,6 +772,7 @@ export class DocumentMask { * Removes the field path specified in 'fieldPaths' from this document mask. * * @private + * @internal * @param fieldPaths An array of FieldPaths. */ removeFields(fieldPaths: FieldPath[]): void { @@ -768,6 +783,7 @@ export class DocumentMask { * Returns whether this document mask contains 'fieldPath'. * * @private + * @internal * @param fieldPath The field path to test. * @return Whether this document mask contains 'fieldPath'. */ @@ -790,6 +806,7 @@ export class DocumentMask { * mask. * * @private + * @internal * @param data An object to filter. * @return A shallow copy of the object filtered by this document mask. */ @@ -856,6 +873,7 @@ export class DocumentMask { * Converts a document mask to the Firestore 'DocumentMask' Proto. * * @private + * @internal * @returns A Firestore 'DocumentMask' Proto. */ toProto(): api.IDocumentMask { @@ -881,11 +899,13 @@ export class DocumentMask { * corresponding field paths. * * @private + * @internal * @class */ export class DocumentTransform { /** * @private + * @internal * @hideconstructor * * @param ref The DocumentReference for this transform. @@ -900,6 +920,7 @@ export class DocumentTransform { * Generates a DocumentTransform from a JavaScript object. * * @private + * @internal * @param ref The `DocumentReference` to use for the DocumentTransform. * @param obj The object to extract the transformations from. * @returns The Document Transform. @@ -921,6 +942,7 @@ export class DocumentTransform { * Generates a DocumentTransform from an Update Map. * * @private + * @internal * @param ref The `DocumentReference` to use for the DocumentTransform. * @param data The update data to extract the transformations from. * @returns The Document Transform. @@ -967,6 +989,7 @@ export class DocumentTransform { * Whether this DocumentTransform contains any actionable transformations. * * @private + * @internal */ get isEmpty(): boolean { return this.transforms.size === 0; @@ -976,6 +999,7 @@ export class DocumentTransform { * Returns the array of fields in this DocumentTransform. * * @private + * @internal */ get fields(): FieldPath[] { return Array.from(this.transforms.keys()); @@ -984,6 +1008,7 @@ export class DocumentTransform { /** * Validates the user provided field values in this document transform. * @private + * @internal */ validate(): void { const allowUndefined = @@ -995,6 +1020,7 @@ export class DocumentTransform { * Converts a document transform to the Firestore 'FieldTransform' Proto. * * @private + * @internal * @param serializer The Firestore serializer * @returns A list of Firestore 'FieldTransform' Protos */ @@ -1009,6 +1035,7 @@ export class DocumentTransform { * A Firestore Precondition encapsulates options for database writes. * * @private + * @internal * @class */ export class Precondition { @@ -1017,6 +1044,7 @@ export class Precondition { /** * @private + * @internal * @hideconstructor * * @param options.exists - Whether the referenced document should exist in @@ -1039,6 +1067,7 @@ export class Precondition { * Generates the Protobuf `Preconditon` object for this precondition. * * @private + * @internal * @returns The `Preconditon` Protobuf object or 'null' if there are no * preconditions. */ @@ -1062,6 +1091,7 @@ export class Precondition { * Whether this DocumentTransform contains any enforcement. * * @private + * @internal */ get isEmpty(): boolean { return this._exists === undefined && !this._lastUpdateTime; diff --git a/dev/src/field-value.ts b/dev/src/field-value.ts index 64ea6df49..720f37b7c 100644 --- a/dev/src/field-value.ts +++ b/dev/src/field-value.ts @@ -214,6 +214,7 @@ export class FieldValue implements firestore.FieldValue { * is 'true'). * * @private + * @internal * @abstract */ export abstract class FieldTransform extends FieldValue { @@ -253,11 +254,13 @@ export abstract class FieldTransform extends FieldValue { * A transform that deletes a field from a Firestore document. * * @private + * @internal */ export class DeleteTransform extends FieldTransform { /** * Sentinel value for a field delete. * @private + * @internal */ static DELETE_SENTINEL = new DeleteTransform(); @@ -268,6 +271,7 @@ export class DeleteTransform extends FieldTransform { /** * Deletes are included in document masks. * @private + * @internal */ get includeInDocumentMask(): true { return true; @@ -276,6 +280,7 @@ export class DeleteTransform extends FieldTransform { /** * Deletes are are omitted from document transforms. * @private + * @internal */ get includeInDocumentTransform(): false { return false; @@ -298,12 +303,14 @@ export class DeleteTransform extends FieldTransform { * A transform that sets a field to the Firestore server time. * * @private + * @internal */ class ServerTimestampTransform extends FieldTransform { /** * Sentinel value for a server timestamp. * * @private + * @internal */ static SERVER_TIMESTAMP_SENTINEL = new ServerTimestampTransform(); @@ -315,6 +322,7 @@ class ServerTimestampTransform extends FieldTransform { * Server timestamps are omitted from document masks. * * @private + * @internal */ get includeInDocumentMask(): false { return false; @@ -324,6 +332,7 @@ class ServerTimestampTransform extends FieldTransform { * Server timestamps are included in document transforms. * * @private + * @internal */ get includeInDocumentTransform(): true { return true; @@ -350,6 +359,7 @@ class ServerTimestampTransform extends FieldTransform { * Increments a field value on the backend. * * @private + * @internal */ class NumericIncrementTransform extends FieldTransform { constructor(private readonly operand: number) { @@ -360,6 +370,7 @@ class NumericIncrementTransform extends FieldTransform { * Numeric transforms are omitted from document masks. * * @private + * @internal */ get includeInDocumentMask(): false { return false; @@ -369,6 +380,7 @@ class NumericIncrementTransform extends FieldTransform { * Numeric transforms are included in document transforms. * * @private + * @internal */ get includeInDocumentTransform(): true { return true; @@ -403,6 +415,7 @@ class NumericIncrementTransform extends FieldTransform { * Transforms an array value via a union operation. * * @private + * @internal */ class ArrayUnionTransform extends FieldTransform { constructor(private readonly elements: unknown[]) { @@ -412,6 +425,7 @@ class ArrayUnionTransform extends FieldTransform { /** * Array transforms are omitted from document masks. * @private + * @internal */ get includeInDocumentMask(): false { return false; @@ -420,6 +434,7 @@ class ArrayUnionTransform extends FieldTransform { /** * Array transforms are included in document transforms. * @private + * @internal */ get includeInDocumentTransform(): true { return true; @@ -459,6 +474,7 @@ class ArrayUnionTransform extends FieldTransform { * Transforms an array value via a remove operation. * * @private + * @internal */ class ArrayRemoveTransform extends FieldTransform { constructor(private readonly elements: unknown[]) { @@ -468,6 +484,7 @@ class ArrayRemoveTransform extends FieldTransform { /** * Array transforms are omitted from document masks. * @private + * @internal */ get includeInDocumentMask(): false { return false; @@ -476,6 +493,7 @@ class ArrayRemoveTransform extends FieldTransform { /** * Array transforms are included in document transforms. * @private + * @internal */ get includeInDocumentTransform(): true { return true; @@ -517,6 +535,7 @@ class ArrayRemoveTransform extends FieldTransform { * rejected. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The value to validate. * @param allowUndefined Whether to allow nested properties that are `undefined`. diff --git a/dev/src/geo-point.ts b/dev/src/geo-point.ts index 5bd7f3c7d..da9c443ae 100644 --- a/dev/src/geo-point.ts +++ b/dev/src/geo-point.ts @@ -96,6 +96,7 @@ export class GeoPoint implements Serializable, firestore.GeoPoint { /** * Converts the GeoPoint to a google.type.LatLng proto. * @private + * @internal */ toProto(): api.IValue { return { @@ -109,6 +110,7 @@ export class GeoPoint implements Serializable, firestore.GeoPoint { /** * Converts a google.type.LatLng proto to its GeoPoint representation. * @private + * @internal */ static fromProto(proto: google.type.ILatLng): GeoPoint { return new GeoPoint(proto.latitude || 0, proto.longitude || 0); diff --git a/dev/src/index.ts b/dev/src/index.ts index 5d90c452f..532be48d8 100644 --- a/dev/src/index.ts +++ b/dev/src/index.ts @@ -376,18 +376,21 @@ export class Firestore implements firestore.Firestore { * A client pool to distribute requests over multiple GAPIC clients in order * to work around a connection limit of 100 concurrent requests per client. * @private + * @internal */ private _clientPool: ClientPool; /** * The configuration options for the GAPIC client. * @private + * @internal */ _settings: firestore.Settings = {}; /** * Settings for the exponential backoff used by the streaming endpoints. * @private + * @internal */ private _backoffSettings: ExponentialBackoffSetting; @@ -395,12 +398,14 @@ export class Firestore implements firestore.Firestore { * Whether the initialization settings can still be changed by invoking * `settings()`. * @private + * @internal */ private _settingsFrozen = false; /** * The serializer to use for the Protobuf transformation. * @private + * @internal */ _serializer: Serializer | null = null; @@ -410,6 +415,7 @@ export class Firestore implements firestore.Firestore { * The project ID is auto-detected during the first request unless a project * ID is passed to the constructor (or provided via `.settings()`). * @private + * @internal */ private _projectId: string | undefined = undefined; @@ -419,6 +425,7 @@ export class Firestore implements firestore.Firestore { * The client can only be terminated when there are no pending writes or * registered listeners. * @private + * @internal */ private registeredListenersCount = 0; @@ -427,6 +434,7 @@ export class Firestore implements firestore.Firestore { * BulkWriter instance is provided. * * @private + * @internal */ private _bulkWriter: BulkWriter | undefined; @@ -434,6 +442,7 @@ export class Firestore implements firestore.Firestore { * Lazy-load the Firestore's default BulkWriter. * * @private + * @internal */ private getBulkWriter(): BulkWriter { if (!this._bulkWriter) { @@ -448,6 +457,7 @@ export class Firestore implements firestore.Firestore { * The client can only be terminated when there are no pending writes or * registered listeners. * @private + * @internal */ private bulkWritersCount = 0; @@ -637,6 +647,7 @@ export class Firestore implements firestore.Firestore { * `initializeIfNeeded()` was called before. * * @private + * @internal */ get projectId(): string { if (this._projectId === undefined) { @@ -652,6 +663,7 @@ export class Firestore implements firestore.Firestore { * `initializeIfNeeded()` was called before. * * @private + * @internal */ get formattedName(): string { return `projects/${this.projectId}/databases/${DEFAULT_DATABASE_ID}`; @@ -813,6 +825,7 @@ export class Firestore implements firestore.Firestore { * 'Proto3 JSON' and 'Protobuf JS' encoded data. * * @private + * @internal * @param documentOrName The Firestore 'Document' proto or the resource name * of a missing document. * @param readTime A 'Timestamp' proto indicating the time this document was @@ -1154,6 +1167,7 @@ export class Firestore implements firestore.Firestore { * called. * * @private + * @internal */ registerListener(): void { this.registeredListenersCount += 1; @@ -1165,6 +1179,7 @@ export class Firestore implements firestore.Firestore { * is called. * * @private + * @internal */ unregisterListener(): void { this.registeredListenersCount -= 1; @@ -1175,6 +1190,7 @@ export class Firestore implements firestore.Firestore { * that all pending operations are complete when terminate() is called. * * @private + * @internal */ _incrementBulkWritersCount(): void { this.bulkWritersCount += 1; @@ -1185,6 +1201,7 @@ export class Firestore implements firestore.Firestore { * that all pending operations are complete when terminate() is called. * * @private + * @internal */ _decrementBulkWritersCount(): void { this.bulkWritersCount -= 1; @@ -1244,6 +1261,7 @@ export class Firestore implements firestore.Firestore { * startAfter() once the RecursiveDelete instance has MAX_PENDING_OPS pending. * * @private + * @internal */ // Visible for testing _recursiveDelete( @@ -1297,6 +1315,7 @@ export class Firestore implements firestore.Firestore { * SDK can be used after this method completes. * * @private + * @internal * @param requestTag A unique client-assigned identifier that caused this * initialization. * @return A Promise that resolves when the client is initialized. @@ -1344,6 +1363,7 @@ export class Firestore implements firestore.Firestore { /** * Returns GAX call options that set the cloud resource header. * @private + * @internal */ private createCallOptions( methodName: string, @@ -1374,6 +1394,7 @@ export class Firestore implements firestore.Firestore { * A function returning a Promise that can be retried. * * @private + * @internal * @callback retryFunction * @returns {Promise} A Promise indicating the function's success. */ @@ -1386,6 +1407,7 @@ export class Firestore implements firestore.Firestore { * for further attempts. * * @private + * @internal * @param methodName Name of the Veneer API endpoint that takes a request * and GAX options. * @param requestTag A unique client-assigned identifier for this request. @@ -1439,6 +1461,7 @@ export class Firestore implements firestore.Firestore { * method rejects the returned Promise. * * @private + * @internal * @param backendStream The Node stream to monitor. * @param lifetime A Promise that resolves when the stream receives an 'end', * 'close' or 'finish' message. @@ -1547,6 +1570,7 @@ export class Firestore implements firestore.Firestore { * necessary within the request options. * * @private + * @internal * @param methodName Name of the Veneer API endpoint that takes a request * and GAX options. * @param request The Protobuf request to send. @@ -1591,6 +1615,7 @@ export class Firestore implements firestore.Firestore { * listeners are attached. * * @private + * @internal * @param methodName Name of the streaming Veneer API endpoint that * takes a request and GAX options. * @param request The Protobuf request to send. @@ -1711,6 +1736,7 @@ module.exports = Object.assign(module.exports, existingExports); * {@link v1beta1} factory function. * * @private + * @internal * @name Firestore.v1beta1 * @type {function} */ @@ -1724,6 +1750,7 @@ Object.defineProperty(module.exports, 'v1beta1', { * {@link v1} factory function. * * @private + * @internal * @name Firestore.v1 * @type {function} */ @@ -1737,6 +1764,7 @@ Object.defineProperty(module.exports, 'v1', { * {@link Status} factory function. * * @private + * @internal * @name Firestore.GrpcStatus * @type {function} */ diff --git a/dev/src/logger.ts b/dev/src/logger.ts index 05007bc8d..9947214ab 100644 --- a/dev/src/logger.ts +++ b/dev/src/logger.ts @@ -29,6 +29,7 @@ let logFunction: ((msg: string) => void) | null = null; * logging. * * @private + * @internal */ export function logger( methodName: string, @@ -63,6 +64,7 @@ export function setLogFunction(logger: ((msg: string) => void) | null): void { * Sets the library version to be used in log messages. * * @private + * @internal */ export function setLibVersion(version: string): void { libVersion = version; diff --git a/dev/src/order.ts b/dev/src/order.ts index 5aa264b09..bcb854366 100644 --- a/dev/src/order.ts +++ b/dev/src/order.ts @@ -39,6 +39,7 @@ enum TypeOrder { /*! * @private + * @internal */ function typeOrder(val: api.IValue): TypeOrder { const valueType = detectValueType(val); @@ -73,6 +74,7 @@ function typeOrder(val: api.IValue): TypeOrder { /*! * @private + * @internal */ export function primitiveComparator( left: string | boolean | number, @@ -90,6 +92,7 @@ export function primitiveComparator( /*! * Utility function to compare doubles (using Firestore semantics for NaN). * @private + * @internal */ function compareNumbers(left: number, right: number): number { if (left < right) { @@ -110,6 +113,7 @@ function compareNumbers(left: number, right: number): number { /*! * @private + * @internal */ function compareNumberProtos(left: api.IValue, right: api.IValue): number { let leftValue, rightValue; @@ -128,6 +132,7 @@ function compareNumberProtos(left: api.IValue, right: api.IValue): number { /*! * @private + * @internal */ function compareTimestamps( left: google.protobuf.ITimestamp, @@ -142,6 +147,7 @@ function compareTimestamps( /*! * @private + * @internal */ function compareBlobs(left: Uint8Array, right: Uint8Array): number { if (!(left instanceof Buffer) || !(right instanceof Buffer)) { @@ -152,6 +158,7 @@ function compareBlobs(left: Uint8Array, right: Uint8Array): number { /*! * @private + * @internal */ function compareReferenceProtos(left: api.IValue, right: api.IValue): number { const leftPath = QualifiedResourcePath.fromSlashSeparatedString( @@ -165,6 +172,7 @@ function compareReferenceProtos(left: api.IValue, right: api.IValue): number { /*! * @private + * @internal */ function compareGeoPoints( left: google.type.ILatLng, @@ -178,6 +186,7 @@ function compareGeoPoints( /*! * @private + * @internal */ export function compareArrays(left: api.IValue[], right: api.IValue[]): number { for (let i = 0; i < left.length && i < right.length; i++) { @@ -192,6 +201,7 @@ export function compareArrays(left: api.IValue[], right: api.IValue[]): number { /*! * @private + * @internal */ function compareObjects(left: ApiMapValue, right: ApiMapValue): number { // This requires iterating over the keys in the object in order and doing a @@ -217,6 +227,7 @@ function compareObjects(left: ApiMapValue, right: ApiMapValue): number { /*! * @private + * @internal */ export function compare(left: api.IValue, right: api.IValue): number { // First compare the types. diff --git a/dev/src/path.ts b/dev/src/path.ts index 2a6709628..8002e43bf 100644 --- a/dev/src/path.ts +++ b/dev/src/path.ts @@ -68,6 +68,7 @@ const FIELD_PATH_RE = /^[^*~/[\]]+$/; * Subclasses have to implement `split()` and `canonicalString()`. * * @private + * @internal * @class */ abstract class Path { @@ -75,6 +76,7 @@ abstract class Path { * Creates a new Path with the given segments. * * @private + * @internal * @hideconstructor * @param segments Sequence of parts of a path. */ @@ -84,6 +86,7 @@ abstract class Path { * Returns the number of segments of this field path. * * @private + * @internal */ get size(): number { return this.segments.length; @@ -96,6 +99,7 @@ abstract class Path { * Create a child path beneath the current level. * * @private + * @internal * @param relativePath Relative path to append to the current path. * @returns The new path. */ @@ -110,6 +114,7 @@ abstract class Path { * Returns the path of the parent node. * * @private + * @internal * @returns The new path or null if we are already at the root. */ parent(): T | null { @@ -124,6 +129,7 @@ abstract class Path { * Checks whether the current path is a prefix of the specified path. * * @private + * @internal * @param other The path to check against. * @returns 'true' iff the current path is a prefix match with 'other'. */ @@ -145,6 +151,7 @@ abstract class Path { * Compare the current path against another Path object. * * @private + * @internal * @param other The path to compare to. * @returns -1 if current < other, 1 if current > other, 0 if equal */ @@ -171,6 +178,7 @@ abstract class Path { * Returns a copy of the underlying segments. * * @private + * @internal * @returns A copy of the segments that make up this path. */ toArray(): string[] { @@ -182,6 +190,7 @@ abstract class Path { * `Path`. * * @private + * @internal * @returns The newly created Path. */ popLast(): T { @@ -193,6 +202,7 @@ abstract class Path { * Returns true if this `Path` is equal to the provided value. * * @private + * @internal * @param other The value to compare against. * @return true if this `Path` is equal to the provided value. */ @@ -206,11 +216,13 @@ abstract class Path { * instance. * * @private + * @internal */ export class ResourcePath extends Path { /** * A default instance pointing to the root collection. * @private + * @internal */ static EMPTY = new ResourcePath(); @@ -218,6 +230,7 @@ export class ResourcePath extends Path { * Constructs a ResourcePath. * * @private + * @internal * @param segments Sequence of names of the parts of the path. */ constructor(...segments: string[]) { @@ -227,6 +240,7 @@ export class ResourcePath extends Path { /** * Indicates whether this path points to a document. * @private + * @internal */ get isDocument(): boolean { return this.segments.length > 0 && this.segments.length % 2 === 0; @@ -235,6 +249,7 @@ export class ResourcePath extends Path { /** * Indicates whether this path points to a collection. * @private + * @internal */ get isCollection(): boolean { return this.segments.length % 2 === 1; @@ -243,6 +258,7 @@ export class ResourcePath extends Path { /** * The last component of the path. * @private + * @internal */ get id(): string | null { if (this.segments.length > 0) { @@ -255,6 +271,7 @@ export class ResourcePath extends Path { * Returns the location of this path relative to the root of the project's * database. * @private + * @internal */ get relativeName(): string { return this.segments.join('/'); @@ -264,6 +281,7 @@ export class ResourcePath extends Path { * Constructs a new instance of ResourcePath. * * @private + * @internal * @param segments Sequence of parts of the path. * @returns The newly created ResourcePath. */ @@ -275,6 +293,7 @@ export class ResourcePath extends Path { * Splits a string into path segments, using slashes as separators. * * @private + * @internal * @param relativePath The path to split. * @returns The split path segments. */ @@ -288,6 +307,7 @@ export class ResourcePath extends Path { * Converts this path to a fully qualified ResourcePath. * * @private + * @internal * @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. @@ -307,6 +327,7 @@ export class ResourcePath extends Path { * to resources in any Firestore project. * * @private + * @internal */ export class QualifiedResourcePath extends ResourcePath { /** @@ -323,6 +344,7 @@ export class QualifiedResourcePath extends ResourcePath { * Constructs a Firestore Resource Path. * * @private + * @internal * @param projectId The Firestore project id. * @param databaseId The Firestore database id. * @param segments Sequence of names of the parts of the path. @@ -337,6 +359,7 @@ export class QualifiedResourcePath extends ResourcePath { /** * String representation of the path relative to the database root. * @private + * @internal */ get relativeName(): string { return this.segments.join('/'); @@ -346,6 +369,7 @@ export class QualifiedResourcePath extends ResourcePath { * Creates a resource path from an absolute Firestore path. * * @private + * @internal * @param absolutePath A string representation of a Resource Path. * @returns The new ResourcePath. */ @@ -366,6 +390,7 @@ export class QualifiedResourcePath extends ResourcePath { * Create a child path beneath the current level. * * @private + * @internal * @param relativePath Relative path to append to the current path. * @returns The new path. */ @@ -379,6 +404,7 @@ export class QualifiedResourcePath extends ResourcePath { * Create a child path beneath the current level. * * @private + * @internal * @returns The new path. */ parent(): QualifiedResourcePath | null { @@ -389,6 +415,7 @@ export class QualifiedResourcePath extends ResourcePath { * String representation of a ResourcePath as expected by the API. * * @private + * @internal * @returns The representation as expected by the API. */ get formattedName(): string { @@ -409,6 +436,7 @@ export class QualifiedResourcePath extends ResourcePath { * methods. * * @private + * @internal * @param segments Sequence of names of the parts of the path. * @returns The newly created QualifiedResourcePath. */ @@ -425,6 +453,7 @@ export class QualifiedResourcePath extends ResourcePath { * returns the current instance. * * @private + * @internal */ toQualifiedResourcePath(): QualifiedResourcePath { return this; @@ -434,6 +463,7 @@ export class QualifiedResourcePath extends ResourcePath { * Compare the current path against another ResourcePath object. * * @private + * @internal * @param other The path to compare to. * @returns -1 if current < other, 1 if current > other, 0 if equal */ @@ -460,6 +490,7 @@ export class QualifiedResourcePath extends ResourcePath { /** * Converts this ResourcePath to the Firestore Proto representation. * @private + * @internal */ toProto(): api.IValue { return { @@ -473,6 +504,7 @@ export class QualifiedResourcePath extends ResourcePath { * resource path. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param resourcePath The path to validate. * @throws if the string can't be used as a resource path. @@ -510,6 +542,7 @@ export class FieldPath extends Path implements firestore.FieldPath { * A special sentinel value to refer to the ID of a document. * * @private + * @internal */ private static _DOCUMENT_ID = new FieldPath('__name__'); @@ -564,6 +597,7 @@ export class FieldPath extends Path implements firestore.FieldPath { * strings. * * @private + * @internal * @param {string|FieldPath} fieldPath The FieldPath to create. * @returns {FieldPath} A field path representation. */ @@ -579,6 +613,7 @@ export class FieldPath extends Path implements firestore.FieldPath { * String representation of a FieldPath as expected by the API. * * @private + * @internal * @override * @returns {string} The representation as expected by the API. */ @@ -596,6 +631,7 @@ export class FieldPath extends Path implements firestore.FieldPath { * Returns a string representation of this path. * * @private + * @internal * @returns A string representing this path. */ toString(): string { @@ -606,6 +642,7 @@ export class FieldPath extends Path implements firestore.FieldPath { * Splits a string into path segments, using dots as separators. * * @private + * @internal * @override * @param {string} fieldPath The path to split. * @returns {Array.} - The split path segments. @@ -620,6 +657,7 @@ export class FieldPath extends Path implements firestore.FieldPath { * methods. * * @private + * @internal * @override * @param segments Sequence of field names. * @returns The newly created FieldPath. @@ -643,6 +681,7 @@ export class FieldPath extends Path implements firestore.FieldPath { * Validates that the provided value can be used as a field path argument. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param fieldPath The value to verify. * @throws if the string can't be used as a field path. diff --git a/dev/src/pool.ts b/dev/src/pool.ts index 54638dc28..c9351556e 100644 --- a/dev/src/pool.ts +++ b/dev/src/pool.ts @@ -32,6 +32,7 @@ export const CLIENT_TERMINATED_ERROR_MSG = * concurrent operations. * * @private + * @internal */ export class ClientPool { /** @@ -81,6 +82,7 @@ export class ClientPool { * of concurrent operations or initializes and returns a new client. * * @private + * @internal */ private acquire(requestTag: string): T { let selectedClient: T | null = null; @@ -126,6 +128,7 @@ export class ClientPool { * Reduces the number of operations for the provided client, potentially * removing it from the pool of active clients. * @private + * @internal */ private async release(requestTag: string, client: T): Promise { const requestCount = this.activeClients.get(client) || 0; @@ -147,6 +150,7 @@ export class ClientPool { * Given the current operation counts, determines if the given client should * be garbage collected. * @private + * @internal */ private shouldGarbageCollectClient(client: T): boolean { // Don't garbage collect clients that have active requests. @@ -176,6 +180,7 @@ export class ClientPool { * * @return Number of currently registered clients. * @private + * @internal */ // Visible for testing. get size(): number { @@ -187,6 +192,7 @@ export class ClientPool { * * @return Number of currently active operations. * @private + * @internal */ // Visible for testing. get opCount(): number { @@ -205,6 +211,7 @@ export class ClientPool { * be returned to the pool when callback finishes. * @return A Promise that resolves with the result of `op`. * @private + * @internal */ run(requestTag: string, op: (client: T) => Promise): Promise { if (this.terminated) { diff --git a/dev/src/rate-limiter.ts b/dev/src/rate-limiter.ts index a92c26106..213479f99 100644 --- a/dev/src/rate-limiter.ts +++ b/dev/src/rate-limiter.ts @@ -29,6 +29,7 @@ import {logger} from './logger'; * (https://firebase.google.com/docs/firestore/best-practices#ramping_up_traffic). * * @private + * @internal */ export class RateLimiter { // Number of tokens available. Each operation consumes one token. @@ -70,6 +71,7 @@ export class RateLimiter { * @param requestTimeMillis The time used to calculate the number of available * tokens. Used for testing the limiter. * @private + * @internal */ tryMakeRequest( numOperations: number, @@ -92,6 +94,7 @@ export class RateLimiter { * @param requestTimeMillis The time used to calculate the number of available * tokens. Used for testing the limiter. * @private + * @internal */ getNextRequestDelayMs( numOperations: number, @@ -118,6 +121,7 @@ export class RateLimiter { * @param requestTimeMillis The time used to calculate the number of available * tokens. Used for testing the limiter. * @private + * @internal */ private refillTokens(requestTimeMillis: number): void { if (requestTimeMillis >= this.lastRefillTimeMillis) { @@ -142,6 +146,7 @@ export class RateLimiter { * Calculates the maximum capacity based on the provided date. * * @private + * @internal */ // Visible for testing. calculateCapacity(requestTimeMillis: number): number { diff --git a/dev/src/recursive-delete.ts b/dev/src/recursive-delete.ts index cb413b15b..c4a8bbec0 100644 --- a/dev/src/recursive-delete.ts +++ b/dev/src/recursive-delete.ts @@ -62,11 +62,13 @@ export const RECURSIVE_DELETE_MIN_PENDING_OPS = 1000; * Class used to store state required for running a recursive delete operation. * Each recursive delete call should use a new instance of the class. * @private + * @internal */ export class RecursiveDelete { /** * The number of deletes that failed with a permanent error. * @private + * @internal */ private errorCount = 0; @@ -74,24 +76,28 @@ export class RecursiveDelete { * The most recently thrown error. Used to populate the developer-facing * error message when the recursive delete operation completes. * @private + * @internal */ private lastError: GoogleError | BulkWriterError | undefined; /** * Whether there are still documents to delete that still need to be fetched. * @private + * @internal */ private documentsPending = true; /** * Whether run() has been called. * @private + * @internal */ private started = false; /** * Query limit to use when fetching all descendants. * @private + * @internal */ private readonly maxPendingOps: number; @@ -99,6 +105,7 @@ export class RecursiveDelete { * The number of pending BulkWriter operations at which RecursiveDelete * starts the next limit query to fetch descendants. * @private + * @internal */ private readonly minPendingOps: number; @@ -106,6 +113,7 @@ export class RecursiveDelete { * A deferred promise that resolves when the recursive delete operation * is completed. * @private + * @internal */ private readonly completionDeferred = new Deferred(); @@ -113,6 +121,7 @@ export class RecursiveDelete { * Whether a query stream is currently in progress. Only one stream can be * run at a time. * @private + * @internal */ private streamInProgress = false; @@ -120,6 +129,7 @@ export class RecursiveDelete { * The last document snapshot returned by the stream. Used to set the * startAfter() field in the subsequent stream. * @private + * @internal */ private lastDocumentSnap: QueryDocumentSnapshot | undefined; @@ -127,6 +137,7 @@ export class RecursiveDelete { * The number of pending BulkWriter operations. Used to determine when the * next query can be run. * @private + * @internal */ private pendingOpsCount = 0; @@ -173,6 +184,7 @@ export class RecursiveDelete { /** * Creates a query stream and attaches event handlers to it. * @private + * @internal */ private setupStream(): void { const stream = this.getAllDescendants( @@ -210,6 +222,7 @@ export class RecursiveDelete { * Retrieves all descendant documents nested under the provided reference. * @param ref The reference to fetch all descendants for. * @private + * @internal * @return {Stream} Stream of descendant documents. */ private getAllDescendants( @@ -267,6 +280,7 @@ export class RecursiveDelete { * or if a permanent error occurs during the stream. Deletes the developer * provided reference and wraps any errors that occurred. * @private + * @internal */ private onQueryEnd(): void { this.documentsPending = false; @@ -301,6 +315,7 @@ export class RecursiveDelete { * Deletes the provided reference and starts the next stream if conditions * are met. * @private + * @internal */ private deleteRef(docRef: DocumentReference): void { this.pendingOpsCount++; diff --git a/dev/src/reference.ts b/dev/src/reference.ts index e18da1e56..b720c3ab3 100644 --- a/dev/src/reference.ts +++ b/dev/src/reference.ts @@ -63,6 +63,7 @@ import api = protos.google.firestore.v1; * (descending or ascending). * * @private + * @internal */ const directionOperators: {[k: string]: api.StructuredQuery.Direction} = { asc: 'ASCENDING', @@ -75,6 +76,7 @@ const directionOperators: {[k: string]: api.StructuredQuery.Direction} = { * and 'array-contains-any'. * * @private + * @internal */ const comparisonOperators: { [k: string]: api.StructuredQuery.FieldFilter.Operator; @@ -140,6 +142,7 @@ export class DocumentReference /** * The string representation of the DocumentReference's location. * @private + * @internal * @type {string} * @name DocumentReference#formattedName */ @@ -208,6 +211,7 @@ export class DocumentReference /** * Returns a resource path for this document. * @private + * @internal */ get _resourcePath(): ResourcePath { return this._path; @@ -550,6 +554,7 @@ export class DocumentReference * Converts this DocumentReference to the Firestore Proto representation. * * @private + * @internal */ toProto(): api.IValue { return {referenceValue: this.formattedName}; @@ -622,6 +627,7 @@ export class DocumentReference * A Query order-by field. * * @private + * @internal * @class */ export class FieldOrder { @@ -639,6 +645,7 @@ export class FieldOrder { /** * Generates the proto representation for this field order. * @private + * @internal */ toProto(): api.StructuredQuery.IOrder { return { @@ -654,6 +661,7 @@ export class FieldOrder { * A field constraint for a Query where clause. * * @private + * @internal * @class */ class FieldFilter { @@ -675,6 +683,7 @@ class FieldFilter { * Returns whether this FieldFilter uses an equals comparison. * * @private + * @internal */ isInequalityFilter(): boolean { switch (this.op) { @@ -692,6 +701,7 @@ class FieldFilter { * Generates the proto representation for this field filter. * * @private + * @internal */ toProto(): api.StructuredQuery.IFilter { if (typeof this.value === 'number' && isNaN(this.value)) { @@ -995,6 +1005,7 @@ enum LimitType { * * These options are immutable. Modified options can be created using `with()`. * @private + * @internal */ export class QueryOptions { constructor( @@ -1022,6 +1033,7 @@ export class QueryOptions { /** * Returns query options for a collection group query. * @private + * @internal */ static forCollectionGroupQuery( collectionId: string, @@ -1040,6 +1052,7 @@ export class QueryOptions { /** * Returns query options for a single-collection query. * @private + * @internal */ static forCollectionQuery( collectionRef: ResourcePath, @@ -1060,6 +1073,7 @@ export class QueryOptions { * specified reference. * * @private + * @internal */ static forKindlessAllDescendants( parent: ResourcePath, @@ -1085,6 +1099,7 @@ export class QueryOptions { /** * Returns the union of the current and the provided options. * @private + * @internal */ with(settings: Partial, 'converter'>>): QueryOptions { return new QueryOptions( @@ -1182,11 +1197,13 @@ export class Query implements firestore.Query { * field order. * * @private + * @internal * @param documentSnapshot The document to extract the fields from. * @param fieldOrders The field order that defines what fields we should * extract. * @return {Array.<*>} The field values to use. * @private + * @internal */ static _extractFieldValues( documentSnapshot: DocumentSnapshot, @@ -1509,6 +1526,7 @@ export class Query implements firestore.Query { * Computes the backend ordering semantics for DocumentSnapshot cursors. * * @private + * @internal * @param cursorValuesOrDocumentSnapshot The snapshot of the document or the * set of field values to use as the boundary. * @returns The implicit ordering semantics. @@ -1561,6 +1579,7 @@ export class Query implements firestore.Query { * Builds a Firestore 'Position' proto message. * * @private + * @internal * @param {Array.} fieldOrders The field orders to use for this * cursor. * @param {Array.} cursorValuesOrDocumentSnapshot The @@ -1622,6 +1641,7 @@ export class Query implements firestore.Query { * @return If valid, returns a DocumentReference that can be used with the * query. * @private + * @internal */ private validateReference(val: unknown): DocumentReference { const basePath = this._queryOptions.allDescendants @@ -1878,6 +1898,7 @@ export class Query implements firestore.Query { * Internal get() method that accepts an optional transaction id. * * @private + * @internal * @param {bytes=} transactionId A transaction ID. */ _get(transactionId?: Uint8Array): Promise> { @@ -1971,6 +1992,7 @@ export class Query implements firestore.Query { * * @param cursor The original cursor value * @private + * @internal */ private toCursor(cursor: QueryCursor | undefined): api.ICursor | undefined { if (cursor) { @@ -1989,6 +2011,7 @@ export class Query implements firestore.Query { * @param transactionIdOrReadTime A transaction ID or the read time at which * to execute the query. * @private + * @internal * @returns Serialized JSON for the query. */ toProto( @@ -2050,6 +2073,7 @@ export class Query implements firestore.Query { * Converts current Query to an IBundledQuery. * * @private + * @internal */ _toBundledQuery(): protos.firestore.IBundledQuery { const projectId = this.firestore.projectId; @@ -2124,6 +2148,7 @@ export class Query implements firestore.Query { * * @param transactionId A transaction ID. * @private + * @internal * @returns A stream of document results. */ _stream(transactionId?: Uint8Array): NodeJS.ReadableStream { @@ -2268,6 +2293,7 @@ export class Query implements firestore.Query { * according to the sort criteria of this query. * * @private + * @internal */ comparator(): ( s1: QueryDocumentSnapshot, @@ -2400,6 +2426,7 @@ export class CollectionReference /** * Returns a resource path for this collection. * @private + * @internal */ get _resourcePath(): ResourcePath { return this._queryOptions.parentPath.append( @@ -2676,6 +2703,7 @@ export class CollectionReference * Validates the input string as a field order direction. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param op Order direction to validate. * @throws when the direction is invalid @@ -2696,6 +2724,7 @@ export function validateQueryOrder( * Validates the input string as a field comparison operator. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param op Field comparison operator to validate. * @param fieldValue Value that is used in the filter. @@ -2739,6 +2768,7 @@ export function validateQueryOperator( * Validates that 'value' is a DocumentReference. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The argument to validate. * @return the DocumentReference if valid @@ -2757,6 +2787,7 @@ export function validateDocumentReference( * Validates that 'value' can be used as a query value. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The argument to validate. * @param allowUndefined Whether to allow nested properties that are `undefined`. @@ -2777,6 +2808,7 @@ function validateQueryValue( * Verifies equality for an array of objects using the `isEqual` interface. * * @private + * @internal * @param left Array of objects supporting `isEqual`. * @param right Array of objects supporting `isEqual`. * @return True if arrays are equal. @@ -2801,6 +2833,7 @@ function isArrayEqual boolean}>( /** * Returns the first non-undefined value or `undefined` if no such value exists. * @private + * @internal */ function coalesce(...values: Array): T | undefined { return values.find(value => value !== undefined); diff --git a/dev/src/serializer.ts b/dev/src/serializer.ts index 5460ebcf8..8b5a9c760 100644 --- a/dev/src/serializer.ts +++ b/dev/src/serializer.ts @@ -34,6 +34,7 @@ import api = proto.google.firestore.v1; * The maximum depth of a Firestore object. * * @private + * @internal */ const MAX_DEPTH = 20; @@ -41,6 +42,7 @@ const MAX_DEPTH = 20; * An interface for Firestore types that can be serialized to Protobuf. * * @private + * @internal */ export interface Serializable { toProto(): api.IValue; @@ -51,6 +53,7 @@ export interface Serializable { * Firestore Protobuf representation. * * @private + * @internal */ export class Serializer { private allowUndefined: boolean; @@ -71,6 +74,7 @@ export class Serializer { * Encodes a JavaScript object into the Firestore 'Fields' representation. * * @private + * @internal * @param obj The object to encode. * @returns The Firestore 'Fields' representation */ @@ -92,6 +96,7 @@ export class Serializer { * Encodes a JavaScript value into the Firestore 'Value' representation. * * @private + * @internal * @param val The object to encode * @returns The Firestore Proto or null if we are deleting a field. */ @@ -215,6 +220,7 @@ export class Serializer { * Decodes a single Firestore 'Value' Protobuf. * * @private + * @internal * @param proto A Firestore 'Value' Protobuf. * @returns The converted JS type. */ @@ -285,6 +291,7 @@ export class Serializer { * Validates a JavaScript value for usage as a Firestore value. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value JavaScript value to validate. * @param desc A description of the expected type. @@ -428,6 +435,7 @@ export function validateUserInput( /** * Returns true if value is a MomentJs date object. * @private + * @internal */ function isMomentJsType(value: unknown): value is {toDate(): Date} { return ( diff --git a/dev/src/timestamp.ts b/dev/src/timestamp.ts index 69cb98e8e..ab981dd4c 100644 --- a/dev/src/timestamp.ts +++ b/dev/src/timestamp.ts @@ -115,6 +115,7 @@ export class Timestamp implements firestore.Timestamp { * Generates a `Timestamp` object from a Timestamp proto. * * @private + * @internal * @param {Object} timestamp The `Timestamp` Protobuf object. */ static fromProto(timestamp: google.protobuf.ITimestamp): Timestamp { @@ -253,6 +254,7 @@ export class Timestamp implements firestore.Timestamp { * Generates the Protobuf `Timestamp` object for this timestamp. * * @private + * @internal * @returns {Object} The `Timestamp` Protobuf object. */ toProto(): api.IValue { diff --git a/dev/src/transaction.ts b/dev/src/transaction.ts index 7274a9cb0..37f316f56 100644 --- a/dev/src/transaction.ts +++ b/dev/src/transaction.ts @@ -346,6 +346,7 @@ export class Transaction implements firestore.Transaction { * Starts a transaction and obtains the transaction id from the server. * * @private + * @internal */ begin(readOnly: boolean, readTime: Timestamp | undefined): Promise { const request: api.IBeginTransactionRequest = { @@ -381,6 +382,7 @@ export class Transaction implements firestore.Transaction { * Commits all queued-up changes in this transaction and releases all locks. * * @private + * @internal */ commit(): Promise { return this._writeBatch @@ -395,6 +397,7 @@ export class Transaction implements firestore.Transaction { * Releases all locks and rolls back this transaction. * * @private + * @internal */ rollback(): Promise { const request = { @@ -409,6 +412,7 @@ export class Transaction implements firestore.Transaction { * Executes `updateFunction()` and commits the transaction with retry. * * @private + * @internal * @param updateFunction The user function to execute within the transaction * context. * @param requestTag A unique client-assigned identifier for the scope of @@ -483,6 +487,7 @@ export class Transaction implements firestore.Transaction { * Delays further operations based on the provided error. * * @private + * @internal * @return A Promise that resolves after the delay expired. */ private async maybeBackoff(error?: GoogleError): Promise { @@ -498,6 +503,7 @@ export class Transaction implements firestore.Transaction { * and Transaction class. * * @private + * @internal * @param documentRefsOrReadOptions An array of document references followed by * an optional ReadOptions object. */ @@ -547,6 +553,7 @@ export function parseGetAllArguments( * is an array of strings or field paths. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The input to validate. * @param options Options that specify whether the ReadOptions can be omitted. diff --git a/dev/src/types.ts b/dev/src/types.ts index 2b62b03e9..64fe05b38 100644 --- a/dev/src/types.ts +++ b/dev/src/types.ts @@ -111,6 +111,7 @@ export type RBTree = any; * inside defaultConverter(), object equality when comparing default converters * is preserved. * @private + * @internal */ const defaultConverterObj: FirestoreDataConverter = { toFirestore(modelObject: DocumentData): DocumentData { @@ -124,6 +125,7 @@ const defaultConverterObj: FirestoreDataConverter = { /** * A default converter to use when none is provided. * @private + * @internal */ export function defaultConverter(): FirestoreDataConverter { return defaultConverterObj as FirestoreDataConverter; @@ -137,6 +139,7 @@ export type UpdateMap = Map; /** * Internal user data validation options. * @private + * @internal */ export interface ValidationOptions { /** At what level field deletes are supported. */ @@ -155,6 +158,7 @@ export interface ValidationOptions { /** * A Firestore Proto value in ProtoJs format. * @private + * @internal */ export interface ProtobufJsValue extends api.IValue { valueType?: string; diff --git a/dev/src/util.ts b/dev/src/util.ts index 920f7d502..20045c153 100644 --- a/dev/src/util.ts +++ b/dev/src/util.ts @@ -24,6 +24,7 @@ import * as gapicConfig from './v1/firestore_client_config.json'; /** * A Promise implementation that supports deferred resolution. * @private + * @internal */ export class Deferred { promise: Promise; @@ -49,6 +50,7 @@ export class Deferred { * Used for the creation of new documents. * * @private + * @internal * @returns {string} A unique 20-character wide identifier. */ export function autoId(): string { @@ -76,6 +78,7 @@ export function autoId(): string { * Used for the creation of request tags. * * @private + * @internal * @returns {string} A random 5-character wide identifier. */ export function requestTag(): string { @@ -86,6 +89,7 @@ export function requestTag(): string { * Determines whether `value` is a JavaScript object. * * @private + * @internal */ export function isObject(value: unknown): value is {[k: string]: unknown} { return Object.prototype.toString.call(value) === '[object Object]'; @@ -96,6 +100,7 @@ export function isObject(value: unknown): value is {[k: string]: unknown} { * 'Map' in Firestore. * * @private + * @internal * @param input The argument to verify. * @returns 'true' if the input can be a treated as a plain object. */ @@ -112,6 +117,7 @@ export function isPlainObject(input: unknown): input is DocumentData { * Returns whether `value` has no custom properties. * * @private + * @internal */ export function isEmpty(value: {}): boolean { return Object.keys(value).length === 0; @@ -121,6 +127,7 @@ export function isEmpty(value: {}): boolean { * Determines whether `value` is a JavaScript function. * * @private + * @internal */ export function isFunction(value: unknown): boolean { return typeof value === 'function'; @@ -131,6 +138,7 @@ export function isFunction(value: unknown): boolean { * RPC. * * @private + * @internal */ export function isPermanentRpcError( err: GoogleError, @@ -163,6 +171,7 @@ function getServiceConfig(methodName: string): CallSettings | undefined { * Returns the list of retryable error codes specified in the service * configuration. * @private + * @internal */ export function getRetryCodes(methodName: string): number[] { return getServiceConfig(methodName)?.retry?.retryCodes ?? []; @@ -171,6 +180,7 @@ export function getRetryCodes(methodName: string): number[] { /** * Returns the backoff setting from the service configuration. * @private + * @internal */ export function getRetryParams(methodName: string): BackoffSettings { return ( @@ -187,6 +197,7 @@ export function getRetryParams(methodName: string): BackoffSettings { * the promise will be discarded. * * @private + * @internal */ export function silencePromise(promise: Promise): Promise { return promise.then( @@ -200,6 +211,7 @@ export function silencePromise(promise: Promise): Promise { * * Used to preserve stack traces across async calls. * @private + * @internal */ export function wrapError(err: Error, stack: string): Error { err.stack += '\nCaused by: ' + stack; diff --git a/dev/src/validate.ts b/dev/src/validate.ts index 0270b5f50..9af546258 100644 --- a/dev/src/validate.ts +++ b/dev/src/validate.ts @@ -23,6 +23,7 @@ import {Timestamp} from './timestamp'; * Options to allow argument omission. * * @private + * @internal */ export interface RequiredArgumentOptions { optional?: boolean; @@ -32,6 +33,7 @@ export interface RequiredArgumentOptions { * Options to limit the range of numbers. * * @private + * @internal */ export interface NumericRangeOptions { minValue?: number; @@ -43,6 +45,7 @@ export interface NumericRangeOptions { * serialized. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The value that failed serialization. * @param path The field path that the object is assigned to. @@ -100,6 +103,7 @@ export function customObjectMessage( * Validates that 'value' is a function. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The input to validate. * @param options Options that specify whether the function can be omitted. @@ -120,6 +124,7 @@ export function validateFunction( * Validates that 'value' is an object. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The input to validate. * @param options Options that specify whether the object can be omitted. @@ -140,6 +145,7 @@ export function validateObject( * Validates that 'value' is a string. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The input to validate. * @param options Options that specify whether the string can be omitted. @@ -160,6 +166,7 @@ export function validateString( * Validates that 'value' is a host. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The input to validate. * @param options Options that specify whether the host can be omitted. @@ -193,6 +200,7 @@ export function validateHost( * Validates that 'value' is a boolean. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The input to validate. * @param options Options that specify whether the boolean can be omitted. @@ -213,6 +221,7 @@ export function validateBoolean( * Validates that 'value' is a number. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The input to validate. * @param options Options that specify whether the number can be omitted. @@ -248,6 +257,7 @@ export function validateNumber( * Validates that 'value' is a integer. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The input to validate. * @param options Options that specify whether the integer can be omitted. @@ -283,6 +293,7 @@ export function validateInteger( * Validates that 'value' is a Timestamp. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The input to validate. * @param options Options that specify whether the Timestamp can be omitted. @@ -303,6 +314,7 @@ export function validateTimestamp( * Generates an error message to use with invalid arguments. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param expectedType The expected input type. */ @@ -317,6 +329,7 @@ export function invalidArgumentMessage( * Enforces the 'options.optional' constraint for 'value'. * * @private + * @internal * @param value The input to validate. * @param options Whether the function can be omitted. * @return Whether the object is omitted and is allowed to be omitted. @@ -334,6 +347,7 @@ export function validateOptional( * Formats the given word as plural conditionally given the preceding number. * * @private + * @internal * @param num The number to use for formatting. * @param str The string to format. */ @@ -345,6 +359,7 @@ function formatPlural(num: number, str: string): string { * Creates a descriptive name for the provided argument name or index. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @return Either the argument name or its index description. */ @@ -358,6 +373,7 @@ function formatArgumentName(arg: string | number): string { * Verifies that 'args' has at least 'minSize' elements. * * @private + * @internal * @param funcName The function name to use in the error message. * @param args The array (or array-like structure) to verify. * @param minSize The minimum number of elements to enforce. @@ -380,6 +396,7 @@ export function validateMinNumberOfArguments( * Verifies that 'args' has at most 'maxSize' elements. * * @private + * @internal * @param funcName The function name to use in the error message. * @param args The array (or array-like structure) to verify. * @param maxSize The maximum number of elements to enforce. @@ -406,6 +423,7 @@ export function validateMaxNumberOfArguments( * @param allowedValues A list of expected values. * @param options Whether the input can be omitted. * @private + * @internal */ export function validateEnumValue( arg: string | number, diff --git a/dev/src/watch.ts b/dev/src/watch.ts index 6264b2d5d..da8da8c4a 100644 --- a/dev/src/watch.ts +++ b/dev/src/watch.ts @@ -81,12 +81,14 @@ const EMPTY_FUNCTION: () => void = () => {}; /** * @private + * @internal * @callback docsCallback * @returns {Array.} An ordered list of documents. */ /** * @private + * @internal * @callback changeCallback * @returns {Array.} An ordered list of document * changes. @@ -96,6 +98,7 @@ const EMPTY_FUNCTION: () => void = () => {}; * onSnapshot() callback that receives the updated query state. * * @private + * @internal * @callback watchSnapshotCallback * * @param {Timestamp} readTime The time at which this snapshot was obtained. @@ -123,6 +126,7 @@ interface DocumentChangeSet { * * @class * @private + * @internal */ abstract class Watch { protected readonly firestore: Firestore; @@ -133,24 +137,28 @@ abstract class Watch { * Indicates whether we are interested in data from the stream. Set to false in the * 'unsubscribe()' callback. * @private + * @internal */ private isActive = true; /** * The current stream to the backend. * @private + * @internal */ private currentStream: Duplex | null = null; /** * The server assigns and updates the resume token. * @private + * @internal */ private resumeToken: Uint8Array | undefined = undefined; /** * A map of document names to QueryDocumentSnapshots for the last sent snapshot. * @private + * @internal */ private docMap = new Map>(); @@ -158,12 +166,14 @@ abstract class Watch { * The accumulated map of document changes (keyed by document name) for the * current snapshot. * @private + * @internal */ private changeMap = new Map>(); /** * The current state of the query results. * * @private + * @internal */ private current = false; @@ -171,6 +181,7 @@ abstract class Watch { * The sorted tree of QueryDocumentSnapshots as sent in the last snapshot. * We only look at the keys. * @private + * @internal */ private docTree: RBTree | undefined; @@ -179,6 +190,7 @@ abstract class Watch { * since we should push those even when there are no changes, if there * aren't docs. * @private + * @internal */ private hasPushed = false; @@ -199,6 +211,7 @@ abstract class Watch { /** * @private + * @internal * @hideconstructor * * @param firestore The Firestore Database client. @@ -227,6 +240,7 @@ abstract class Watch { * Starts a watch and attaches a listener for document change events. * * @private + * @internal * @param onNext A callback to be called every time a new snapshot is * available. * @param onError A callback to be called if the listen fails or is cancelled. @@ -277,6 +291,7 @@ abstract class Watch { * Returns the current count of all documents, including the changes from * the current changeMap. * @private + * @internal */ private currentSize(): number { const changes = this.extractCurrentChanges(Timestamp.now()); @@ -286,6 +301,7 @@ abstract class Watch { /** * Splits up document changes into removals, additions, and updates. * @private + * @internal */ private extractCurrentChanges(readTime: Timestamp): DocumentChangeSet { const deletes: string[] = []; @@ -312,6 +328,7 @@ abstract class Watch { /** * Helper to clear the docs on RESET or filter mismatch. * @private + * @internal */ private resetDocs(): void { logger('Watch.resetDocs', this.requestTag, 'Resetting documents'); @@ -333,6 +350,7 @@ abstract class Watch { /** * Closes the stream and calls onError() if the stream is still active. * @private + * @internal */ private closeStream(err: GoogleError): void { if (this.isActive) { @@ -346,6 +364,7 @@ abstract class Watch { * Re-opens the stream unless the specified error is considered permanent. * Clears the change map. * @private + * @internal */ private maybeReopenStream(err: GoogleError): void { if (this.isActive && !this.isPermanentWatchError(err)) { @@ -371,6 +390,7 @@ abstract class Watch { * Cancels the current idle timeout and reschedules a new timer. * * @private + * @internal */ private resetIdleTimeout(): void { if (this.idleTimeoutHandle) { @@ -395,6 +415,7 @@ abstract class Watch { /** * Helper to restart the outgoing stream to the backend. * @private + * @internal */ private resetStream(): void { logger('Watch.resetStream', this.requestTag, 'Restarting stream'); @@ -408,6 +429,7 @@ abstract class Watch { /** * Initializes a new stream to the backend with backoff. * @private + * @internal */ private initStream(): void { this.backoff @@ -477,6 +499,7 @@ abstract class Watch { * Handles 'data' events and closes the stream if the response type is * invalid. * @private + * @internal */ private onData(proto: api.IListenResponse): void { if (proto.targetChange) { @@ -586,6 +609,7 @@ abstract class Watch { * Checks if the current target id is included in the list of target ids. * If no targetIds are provided, returns true. * @private + * @internal */ private affectsTarget( targetIds: number[] | undefined, @@ -608,6 +632,7 @@ abstract class Watch { * Assembles a new snapshot from the current set of changes and invokes the * user's callback. Clears the current changes on completion. * @private + * @internal */ private pushSnapshot( readTime: Timestamp, @@ -642,6 +667,7 @@ abstract class Watch { * Applies a document delete to the document tree and the document map. * Returns the corresponding DocumentChange event. * @private + * @internal */ private deleteDoc(name: string): DocumentChange { assert(this.docMap.has(name), 'Document to delete does not exist'); @@ -657,6 +683,7 @@ abstract class Watch { * Applies a document add to the document tree and the document map. Returns * the corresponding DocumentChange event. * @private + * @internal */ private addDoc(newDocument: QueryDocumentSnapshot): DocumentChange { const name = newDocument.ref.path; @@ -671,6 +698,7 @@ abstract class Watch { * Applies a document modification to the document tree and the document map. * Returns the DocumentChange event for successful modifications. * @private + * @internal */ private modifyDoc( newDocument: QueryDocumentSnapshot @@ -696,6 +724,7 @@ abstract class Watch { * document lookup map. Modified docMap in-place and returns the updated * state. * @private + * @internal */ private computeSnapshot(readTime: Timestamp): Array> { const changeSet = this.extractCurrentChanges(readTime); @@ -745,6 +774,7 @@ abstract class Watch { * transient in this context. * * @private + * @internal * @param error An error object. * @return Whether the error is permanent. */ @@ -779,6 +809,7 @@ abstract class Watch { * overload. * * @private + * @internal * @param error A GRPC Error object that exposes an error code. * @return Whether we need to back off our retries. */ @@ -806,6 +837,7 @@ abstract class Watch { * Creates a new Watch instance to listen on DocumentReferences. * * @private + * @internal */ export class DocumentWatch extends Watch { constructor( @@ -835,6 +867,7 @@ export class DocumentWatch extends Watch { * Creates a new Watch instance to listen on Queries. * * @private + * @internal */ export class QueryWatch extends Watch { private comparator: DocumentComparator; diff --git a/dev/src/write-batch.ts b/dev/src/write-batch.ts index b6e684b1e..ae22a5656 100644 --- a/dev/src/write-batch.ts +++ b/dev/src/write-batch.ts @@ -100,6 +100,7 @@ export class WriteResult implements firestore.WriteResult { * A lazily-evaluated write that allows us to detect the Project ID before * serializing the request. * @private + * @internal */ export type PendingWriteOp = () => api.IWrite; @@ -120,6 +121,7 @@ export class WriteBatch implements firestore.WriteBatch { * the backend. * * @private + * @internal */ private readonly _ops: Array<{docPath: string; op: PendingWriteOp}> = []; @@ -145,6 +147,7 @@ export class WriteBatch implements firestore.WriteBatch { * Checks if this write batch has any pending operations. * * @private + * @internal */ get isEmpty(): boolean { return this._ops.length === 0; @@ -154,6 +157,7 @@ export class WriteBatch implements firestore.WriteBatch { * Throws an error if this batch has already been committed. * * @private + * @internal */ private verifyNotCommitted(): void { if (this._committed) { @@ -567,6 +571,7 @@ export class WriteBatch implements firestore.WriteBatch { * Commit method that takes an optional transaction ID. * * @private + * @internal * @param commitOptions Options to use for this commit. * @param commitOptions.transactionId The transaction ID of this commit. * @param commitOptions.requestTag A unique client-assigned identifier for @@ -614,6 +619,7 @@ export class WriteBatch implements firestore.WriteBatch { /** * Resets the WriteBatch and dequeues all pending operations. * @private + * @internal */ _reset(): void { this._ops.splice(0); @@ -626,6 +632,7 @@ export class WriteBatch implements firestore.WriteBatch { * and 'lastUpdateTime' use valid types. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The object to validate * @param allowExists Whether to allow the 'exists' preconditions. @@ -689,6 +696,7 @@ function validatePrecondition( * Validates the use of 'value' as an update Precondition. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The object to validate. * @param options Optional validation options specifying whether the value can @@ -708,6 +716,7 @@ function validateUpdatePrecondition( * Validates the use of 'value' as a delete Precondition. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The object to validate. * @param options Optional validation options specifying whether the value can @@ -728,6 +737,7 @@ function validateDeletePrecondition( * boolean. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param value The object to validate. * @param options Optional validation options specifying whether the value can @@ -799,6 +809,7 @@ export function validateSetOptions( * Validates a JavaScript object for usage as a Firestore document. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param obj JavaScript object to validate. * @param allowDeletes Whether to allow FieldValue.delete() sentinels. @@ -826,6 +837,7 @@ export function validateDocumentData( * Validates that a value can be used as field value during an update. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param val The value to verify. * @param allowUndefined Whether to allow nested properties that are `undefined`. @@ -851,6 +863,7 @@ export function validateFieldValue( * definitions (such as 'a.b' and 'a'). * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param data An update map with field/value pairs. */ @@ -880,6 +893,7 @@ function validateNoConflictingFields( * Validates that a JavaScript object is a map of field paths to field values. * * @private + * @internal * @param arg The argument name or argument index (for varargs methods). * @param obj JavaScript object to validate. * @param allowUndefined Whether to allow nested properties that are `undefined`. From 8b38f32508bb9626a321322db257607053d9535e Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 27 Jul 2021 08:28:25 -0700 Subject: [PATCH 335/337] chore: add Warn to generated client (#1564) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/70f72a53-eb64-4c25-a7ef-dbae8cf796ea/targets - [ ] To automatically regenerate this PR, check this box. (May take up to 24 hours.) PiperOrigin-RevId: 385101839 Source-Link: https://github.com/googleapis/googleapis/commit/80f404215a9346259db760d80d0671f28c433453 --- dev/src/v1/firestore_admin_client.ts | 11 ++++++++++- dev/src/v1/firestore_client.ts | 11 ++++++++++- dev/src/v1beta1/firestore_client.ts | 11 ++++++++++- synth.metadata | 6 +++--- types/v1/firestore_admin_client.d.ts | 2 ++ types/v1/firestore_client.d.ts | 2 ++ types/v1beta1/firestore_client.d.ts | 2 ++ 7 files changed, 39 insertions(+), 6 deletions(-) diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index aedca6d4a..6dee553f7 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -50,6 +50,7 @@ const version = require('../../../package.json').version; export class FirestoreAdminClient { private _terminated = false; private _opts: ClientOptions; + private _providedCustomServicePath: boolean; private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; @@ -61,6 +62,7 @@ export class FirestoreAdminClient { longrunning: {}, batching: {}, }; + warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; pathTemplates: {[name: string]: gax.PathTemplate}; operationsClient: gax.OperationsClient; @@ -105,6 +107,9 @@ export class FirestoreAdminClient { const staticMembers = this.constructor as typeof FirestoreAdminClient; const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; const fallback = @@ -258,6 +263,9 @@ export class FirestoreAdminClient { // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; } /** @@ -286,7 +294,8 @@ export class FirestoreAdminClient { ) : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.firestore.admin.v1.FirestoreAdmin, - this._opts + this._opts, + this._providedCustomServicePath ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 958e74688..f216b4c27 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -55,6 +55,7 @@ const version = require('../../../package.json').version; export class FirestoreClient { private _terminated = false; private _opts: ClientOptions; + private _providedCustomServicePath: boolean; private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; @@ -66,6 +67,7 @@ export class FirestoreClient { longrunning: {}, batching: {}, }; + warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; firestoreStub?: Promise<{[name: string]: Function}>; @@ -108,6 +110,9 @@ export class FirestoreClient { const staticMembers = this.constructor as typeof FirestoreClient; const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; const fallback = @@ -205,6 +210,9 @@ export class FirestoreClient { // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; } /** @@ -233,7 +241,8 @@ export class FirestoreClient { ) : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.firestore.v1.Firestore, - this._opts + this._opts, + this._providedCustomServicePath ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index 10fbc0a3f..a64604cdd 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -58,6 +58,7 @@ const version = require('../../../package.json').version; export class FirestoreClient { private _terminated = false; private _opts: ClientOptions; + private _providedCustomServicePath: boolean; private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; @@ -69,6 +70,7 @@ export class FirestoreClient { longrunning: {}, batching: {}, }; + warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; firestoreStub?: Promise<{[name: string]: Function}>; @@ -111,6 +113,9 @@ export class FirestoreClient { const staticMembers = this.constructor as typeof FirestoreClient; const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; const fallback = @@ -208,6 +213,9 @@ export class FirestoreClient { // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; } /** @@ -236,7 +244,8 @@ export class FirestoreClient { ) : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.firestore.v1beta1.Firestore, - this._opts + this._opts, + this._providedCustomServicePath ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides diff --git a/synth.metadata b/synth.metadata index ce7e5b0e4..eda4970c3 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-firestore.git", - "sha": "5e384157efda51dc91eeb314a7ac53466764af3d" + "sha": "8d9c50381eedf6ee8043eed681d03b44262b9820" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "076f7e9f0b258bdb54338895d7251b202e8f0de3", - "internalRef": "380641501" + "sha": "80f404215a9346259db760d80d0671f28c433453", + "internalRef": "385101839" } }, { diff --git a/types/v1/firestore_admin_client.d.ts b/types/v1/firestore_admin_client.d.ts index 945ebe8a0..523c92ad7 100644 --- a/types/v1/firestore_admin_client.d.ts +++ b/types/v1/firestore_admin_client.d.ts @@ -35,12 +35,14 @@ import * as protos from '../protos/firestore_admin_v1_proto_api'; export declare class FirestoreAdminClient { private _terminated; private _opts; + private _providedCustomServicePath; private _gaxModule; private _gaxGrpc; private _protos; private _defaults; auth: gax.GoogleAuth; descriptors: Descriptors; + warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: { [name: string]: Function; }; diff --git a/types/v1/firestore_client.d.ts b/types/v1/firestore_client.d.ts index fca4787e1..139527dd9 100644 --- a/types/v1/firestore_client.d.ts +++ b/types/v1/firestore_client.d.ts @@ -40,12 +40,14 @@ import * as protos from '../protos/firestore_v1_proto_api'; export declare class FirestoreClient { private _terminated; private _opts; + private _providedCustomServicePath; private _gaxModule; private _gaxGrpc; private _protos; private _defaults; auth: gax.GoogleAuth; descriptors: Descriptors; + warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: { [name: string]: Function; }; diff --git a/types/v1beta1/firestore_client.d.ts b/types/v1beta1/firestore_client.d.ts index 2f182209a..24ea51b39 100644 --- a/types/v1beta1/firestore_client.d.ts +++ b/types/v1beta1/firestore_client.d.ts @@ -41,12 +41,14 @@ import * as protos from '../protos/firestore_v1beta1_proto_api'; export declare class FirestoreClient { private _terminated; private _opts; + private _providedCustomServicePath; private _gaxModule; private _gaxGrpc; private _protos; private _defaults; auth: gax.GoogleAuth; descriptors: Descriptors; + warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: { [name: string]: Function; }; From e862ac81cbb99287a226989b184fc2e683defa16 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Fri, 30 Jul 2021 12:37:09 -0700 Subject: [PATCH 336/337] feat: allow UnhandledPromiseRejection errors in BulkWriter if no error handler is specified (#1572) --- dev/src/bulk-writer.ts | 49 +++++++++++++++++++++++++++-------------- dev/test/bulk-writer.ts | 29 +++++++++++++++++++++++- 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/dev/src/bulk-writer.ts b/dev/src/bulk-writer.ts index f39387dce..a2b7c0a92 100644 --- a/dev/src/bulk-writer.ts +++ b/dev/src/bulk-writer.ts @@ -416,6 +416,16 @@ export class BulkWriter { */ private _bufferedOperations: Array = []; + /** + * Whether a custom error handler has been set. BulkWriter only swallows + * errors if an error handler is set. Otherwise, an UnhandledPromiseRejection + * is thrown by Node if an operation promise is rejected without being + * handled. + * @private + * @internal + */ + private _errorHandlerSet = false; + // Visible for testing. _getBufferedOperationsCount(): number { return this._bufferedOperations.length; @@ -555,11 +565,9 @@ export class BulkWriter { data: T ): Promise { this._verifyNotClosed(); - const op = this._enqueue(documentRef, 'create', bulkCommitBatch => + return this._enqueue(documentRef, 'create', bulkCommitBatch => bulkCommitBatch.create(documentRef, data) ); - silencePromise(op); - return op; } /** @@ -595,11 +603,9 @@ export class BulkWriter { precondition?: firestore.Precondition ): Promise { this._verifyNotClosed(); - const op = this._enqueue(documentRef, 'delete', bulkCommitBatch => + return this._enqueue(documentRef, 'delete', bulkCommitBatch => bulkCommitBatch.delete(documentRef, precondition) ); - silencePromise(op); - return op; } set( @@ -652,11 +658,9 @@ export class BulkWriter { options?: firestore.SetOptions ): Promise { this._verifyNotClosed(); - const op = this._enqueue(documentRef, 'set', bulkCommitBatch => + return this._enqueue(documentRef, 'set', bulkCommitBatch => bulkCommitBatch.set(documentRef, data, options) ); - silencePromise(op); - return op; } /** @@ -708,11 +712,9 @@ export class BulkWriter { > ): Promise { this._verifyNotClosed(); - const op = this._enqueue(documentRef, 'update', bulkCommitBatch => + return this._enqueue(documentRef, 'update', bulkCommitBatch => bulkCommitBatch.update(documentRef, dataOrField, ...preconditionOrValues) ); - silencePromise(op); - return op; } /** @@ -793,6 +795,7 @@ export class BulkWriter { * }); */ onWriteError(shouldRetryCallback: (error: BulkWriterError) => boolean): void { + this._errorHandlerSet = true; this._errorFn = shouldRetryCallback; } @@ -975,11 +978,23 @@ export class BulkWriter { this._successFn.bind(this) ); + // Swallow the error if the developer has set an error listener. This + // prevents UnhandledPromiseRejections from being thrown if a floating + // BulkWriter operation promise fails when an error handler is specified. + // + // This is done here in order to chain the caught promise onto `lastOp`, + // which ensures that flush() resolves after the operation promise. + const userPromise = bulkWriterOp.promise.catch(err => { + if (!this._errorHandlerSet) { + throw err; + } else { + return bulkWriterOp.promise; + } + }); + // Advance the `_lastOp` pointer. This ensures that `_lastOp` only resolves - // when both the previous and the current write resolves. - this._lastOp = this._lastOp.then(() => - silencePromise(bulkWriterOp.promise) - ); + // when both the previous and the current write resolve. + this._lastOp = this._lastOp.then(() => silencePromise(userPromise)); // Schedule the operation if the BulkWriter has fewer than the maximum // number of allowed pending operations, or add the operation to the @@ -999,7 +1014,7 @@ export class BulkWriter { // Chain the BulkWriter operation promise with the buffer processing logic // in order to ensure that it runs and that subsequent operations are // enqueued before the next batch is scheduled in `_sendBatch()`. - return bulkWriterOp.promise + return userPromise .then(res => { this._pendingOpsCount--; this._processBufferedOps(); diff --git a/dev/test/bulk-writer.ts b/dev/test/bulk-writer.ts index b25033e1b..193b991d8 100644 --- a/dev/test/bulk-writer.ts +++ b/dev/test/bulk-writer.ts @@ -40,6 +40,7 @@ import { DEFAULT_MAXIMUM_OPS_PER_SECOND_LIMIT, RETRY_MAX_BATCH_SIZE, } from '../src/bulk-writer'; +import {Deferred} from '../src/util'; import { ApiOverride, create, @@ -391,7 +392,30 @@ describe('BulkWriter', () => { return bulkWriter.close().then(async () => verifyOpCount(1)); }); - it('swallows UnhandledPromiseRejections even if the error is not caught', async () => { + it('throws UnhandledPromiseRejections if no error handler is passed in', async () => { + let errorThrown = false; + const unhandledDeferred = new Deferred(); + process.on('unhandledRejection', () => { + errorThrown = true; + unhandledDeferred.resolve(); + }); + + const bulkWriter = await instantiateInstance([ + { + request: createRequest([setOp('doc', 'bar')]), + response: failedResponse(), + }, + ]); + + const doc = firestore.doc('collectionId/doc'); + bulkWriter.set(doc, {foo: 'bar'}); + + await bulkWriter.close(); + await unhandledDeferred.promise; + expect(errorThrown).to.be.true; + }); + + it('swallows UnhandledPromiseRejections if an error handler is passed in', async () => { const bulkWriter = await instantiateInstance([ { request: createRequest([setOp('doc', 'bar')]), @@ -401,6 +425,9 @@ describe('BulkWriter', () => { const doc = firestore.doc('collectionId/doc'); bulkWriter.set(doc, {foo: 'bar'}); + // Set the error handler after calling set() to ensure that the check is + // performed when the promise resolves. + bulkWriter.onWriteError(() => false); return bulkWriter.close(); }); From f5bec38de92479ca7930178089843e77411ead3d Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Fri, 30 Jul 2021 19:46:09 +0000 Subject: [PATCH 337/337] chore: release 4.14.0 (#1565) :robot: I have created a release \*beep\* \*boop\* --- ## [4.14.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.13.2...v4.14.0) (2021-07-30) ### Features * add "NON_EMPTY_DEFAULT" FieldBehavior ([#1554](https://www.github.com/googleapis/nodejs-firestore/issues/1554)) ([8d9c503](https://www.github.com/googleapis/nodejs-firestore/commit/8d9c50381eedf6ee8043eed681d03b44262b9820)) * allow UnhandledPromiseRejection errors in BulkWriter if no error handler is specified ([#1572](https://www.github.com/googleapis/nodejs-firestore/issues/1572)) ([e862ac8](https://www.github.com/googleapis/nodejs-firestore/commit/e862ac81cbb99287a226989b184fc2e683defa16)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d41b1489..c9f78dda3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ [1]: https://www.npmjs.com/package/@google-cloud/firestore?activeTab=versions +## [4.14.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.13.2...v4.14.0) (2021-07-30) + + +### Features + +* add "NON_EMPTY_DEFAULT" FieldBehavior ([#1554](https://www.github.com/googleapis/nodejs-firestore/issues/1554)) ([8d9c503](https://www.github.com/googleapis/nodejs-firestore/commit/8d9c50381eedf6ee8043eed681d03b44262b9820)) +* allow UnhandledPromiseRejection errors in BulkWriter if no error handler is specified ([#1572](https://www.github.com/googleapis/nodejs-firestore/issues/1572)) ([e862ac8](https://www.github.com/googleapis/nodejs-firestore/commit/e862ac81cbb99287a226989b184fc2e683defa16)) + ### [4.13.2](https://www.github.com/googleapis/nodejs-firestore/compare/v4.13.1...v4.13.2) (2021-07-14) diff --git a/package.json b/package.json index 9bd65eeaa..057fc1f9a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@google-cloud/firestore", "description": "Firestore Client Library for Node.js", - "version": "4.13.2", + "version": "4.14.0", "license": "Apache-2.0", "author": "Google Inc.", "engines": { diff --git a/samples/package.json b/samples/package.json index 10e94e5a2..cff0a5cff 100644 --- a/samples/package.json +++ b/samples/package.json @@ -11,7 +11,7 @@ "test": "mocha --timeout 600000" }, "dependencies": { - "@google-cloud/firestore": "^4.13.2" + "@google-cloud/firestore": "^4.14.0" }, "devDependencies": { "chai": "^4.2.0",